v0.6.1: major adjustments to layout of journal window
New catalogs tabs don't work yet.
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
+12
-8
@@ -35,26 +35,30 @@ public class ItemSpriteSheet {
|
|||||||
return x + WIDTH*y;
|
return x + WIDTH*y;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int PLACEHOLDERS = xy(1, 1); //8 slots
|
private static final int PLACEHOLDERS = xy(1, 1); //16 slots
|
||||||
//null warning occupies space 0, should only show up if there's a bug.
|
//null warning occupies space 0, should only show up if there's a bug.
|
||||||
public static final int NULLWARN = PLACEHOLDERS+0;
|
public static final int NULLWARN = PLACEHOLDERS+0;
|
||||||
public static final int WEAPON_HOLDER = PLACEHOLDERS+1;
|
public static final int WEAPON_HOLDER = PLACEHOLDERS+1;
|
||||||
public static final int ARMOR_HOLDER = PLACEHOLDERS+2;
|
public static final int ARMOR_HOLDER = PLACEHOLDERS+2;
|
||||||
public static final int RING_HOLDER = PLACEHOLDERS+3;
|
public static final int WAND_HOLDER = PLACEHOLDERS+3;
|
||||||
public static final int POTION_HOLDER = PLACEHOLDERS+4;
|
public static final int RING_HOLDER = PLACEHOLDERS+4;
|
||||||
public static final int SCROLL_HOLDER = PLACEHOLDERS+5;
|
public static final int ARTIFACT_HOLDER = PLACEHOLDERS+5;
|
||||||
public static final int SOMETHING = PLACEHOLDERS+6;
|
public static final int POTION_HOLDER = PLACEHOLDERS+6;
|
||||||
|
public static final int SCROLL_HOLDER = PLACEHOLDERS+7;
|
||||||
|
public static final int SOMETHING = PLACEHOLDERS+8;
|
||||||
static{
|
static{
|
||||||
assignItemRect(NULLWARN, 16, 7);
|
assignItemRect(NULLWARN, 16, 7);
|
||||||
assignItemRect(WEAPON_HOLDER, 14, 14);
|
assignItemRect(WEAPON_HOLDER, 14, 14);
|
||||||
assignItemRect(ARMOR_HOLDER, 14, 12);
|
assignItemRect(ARMOR_HOLDER, 14, 12);
|
||||||
|
assignItemRect(WAND_HOLDER, 14, 14);
|
||||||
assignItemRect(RING_HOLDER, 8, 10);
|
assignItemRect(RING_HOLDER, 8, 10);
|
||||||
|
assignItemRect(ARTIFACT_HOLDER, 15, 15);
|
||||||
assignItemRect(POTION_HOLDER, 10, 14);
|
assignItemRect(POTION_HOLDER, 10, 14);
|
||||||
assignItemRect(SCROLL_HOLDER, 15, 14);
|
assignItemRect(SCROLL_HOLDER, 15, 14);
|
||||||
assignItemRect(SOMETHING, 8, 13);
|
assignItemRect(SOMETHING, 8, 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int UNCOLLECTIBLE = xy(9, 1); //8 slots
|
private static final int UNCOLLECTIBLE = xy(1, 2); //16 slots
|
||||||
public static final int GOLD = UNCOLLECTIBLE+0;
|
public static final int GOLD = UNCOLLECTIBLE+0;
|
||||||
public static final int DEWDROP = UNCOLLECTIBLE+1;
|
public static final int DEWDROP = UNCOLLECTIBLE+1;
|
||||||
public static final int PETAL = UNCOLLECTIBLE+2;
|
public static final int PETAL = UNCOLLECTIBLE+2;
|
||||||
@@ -68,7 +72,7 @@ public class ItemSpriteSheet {
|
|||||||
assignItemRect(DBL_BOMB, 14, 13);
|
assignItemRect(DBL_BOMB, 14, 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int CONTAINERS = xy(1, 2); //16 slots
|
private static final int CONTAINERS = xy(1, 3); //16 slots
|
||||||
public static final int BONES = CONTAINERS+0;
|
public static final int BONES = CONTAINERS+0;
|
||||||
public static final int REMAINS = CONTAINERS+1;
|
public static final int REMAINS = CONTAINERS+1;
|
||||||
public static final int TOMB = CONTAINERS+2;
|
public static final int TOMB = CONTAINERS+2;
|
||||||
@@ -86,7 +90,7 @@ public class ItemSpriteSheet {
|
|||||||
assignItemRect(CRYSTAL_CHEST, 16, 15);
|
assignItemRect(CRYSTAL_CHEST, 16, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int SINGLE_USE = xy(1, 3); //32 slots
|
private static final int SINGLE_USE = xy(1, 4); //16 slots
|
||||||
public static final int ANKH = SINGLE_USE+0;
|
public static final int ANKH = SINGLE_USE+0;
|
||||||
public static final int STYLUS = SINGLE_USE+1;
|
public static final int STYLUS = SINGLE_USE+1;
|
||||||
public static final int WEIGHT = SINGLE_USE+2;
|
public static final int WEIGHT = SINGLE_USE+2;
|
||||||
|
|||||||
@@ -123,6 +123,10 @@ public class RedButton extends Button {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Image icon(){
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
public float reqWidth() {
|
public float reqWidth() {
|
||||||
float reqWidth = 0;
|
float reqWidth = 0;
|
||||||
if (icon != null){
|
if (icon != null){
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
|
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
import com.watabou.noosa.Gizmo;
|
import com.watabou.noosa.Gizmo;
|
||||||
import com.watabou.noosa.Image;
|
import com.watabou.noosa.Image;
|
||||||
@@ -121,6 +122,13 @@ public class Toolbar extends Component {
|
|||||||
GameScene.show(new WndBag(Dungeon.hero.belongings.backpack, null, WndBag.Mode.ALL, null));
|
GameScene.show(new WndBag(Dungeon.hero.belongings.backpack, null, WndBag.Mode.ALL, null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean onLongClick() {
|
||||||
|
WndJournal.last_index = 2; //catalog page
|
||||||
|
GameScene.show(new WndJournal());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createChildren() {
|
protected void createChildren() {
|
||||||
super.createChildren();
|
super.createChildren();
|
||||||
|
|||||||
+45
-50
@@ -53,28 +53,34 @@ import java.util.Collections;
|
|||||||
//FIXME a lot of cleanup and improvements to do here
|
//FIXME a lot of cleanup and improvements to do here
|
||||||
public class WndJournal extends WndTabbed {
|
public class WndJournal extends WndTabbed {
|
||||||
|
|
||||||
private static final int WIDTH = 112;
|
private static final int WIDTH_P = 112;
|
||||||
private static final int HEIGHT = 130;
|
private static final int HEIGHT_P = 160;
|
||||||
|
|
||||||
|
private static final int WIDTH_L = 160;
|
||||||
|
private static final int HEIGHT_L = 128;
|
||||||
|
|
||||||
private static final int ITEM_HEIGHT = 18;
|
private static final int ITEM_HEIGHT = 18;
|
||||||
|
|
||||||
private Notes notes;
|
private Notes notes;
|
||||||
private Catalog catalog;
|
private Catalog catalog;
|
||||||
|
|
||||||
private static int last_index = 0;
|
public static int last_index = 0;
|
||||||
|
|
||||||
public WndJournal(){
|
public WndJournal(){
|
||||||
|
|
||||||
resize(WIDTH, HEIGHT);
|
int width = ShatteredPixelDungeon.landscape() ? WIDTH_L : WIDTH_P;
|
||||||
|
int height = ShatteredPixelDungeon.landscape() ? HEIGHT_L : HEIGHT_P;
|
||||||
|
|
||||||
|
resize(width, height);
|
||||||
|
|
||||||
notes = new Notes();
|
notes = new Notes();
|
||||||
add(notes);
|
add(notes);
|
||||||
notes.setRect(0, 0, WIDTH, HEIGHT);
|
notes.setRect(0, 0, width, height);
|
||||||
notes.updateList();
|
notes.updateList();
|
||||||
|
|
||||||
catalog = new Catalog();
|
catalog = new Catalog();
|
||||||
add(catalog);
|
add(catalog);
|
||||||
catalog.setRect(0, 0, WIDTH, HEIGHT);
|
catalog.setRect(0, 0, width, height);
|
||||||
catalog.updateList();
|
catalog.updateList();
|
||||||
|
|
||||||
Tab[] tabs = {
|
Tab[] tabs = {
|
||||||
@@ -209,7 +215,7 @@ public class WndJournal extends WndTabbed {
|
|||||||
text += " x" + Dungeon.hero.belongings.specialKeys[i];
|
text += " x" + Dungeon.hero.belongings.specialKeys[i];
|
||||||
}
|
}
|
||||||
ListItem item = new ListItem( Icons.get(Icons.DEPTH), Messages.titleCase(text), i );
|
ListItem item = new ListItem( Icons.get(Icons.DEPTH), Messages.titleCase(text), i );
|
||||||
item.setRect( 0, pos, WIDTH, ITEM_HEIGHT );
|
item.setRect( 0, pos, width(), ITEM_HEIGHT );
|
||||||
content.add( item );
|
content.add( item );
|
||||||
|
|
||||||
pos += item.height();
|
pos += item.height();
|
||||||
@@ -222,7 +228,7 @@ public class WndJournal extends WndTabbed {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ListItem item = new ListItem( Icons.get(Icons.DEPTH), text, i );
|
ListItem item = new ListItem( Icons.get(Icons.DEPTH), text, i );
|
||||||
item.setRect( 0, pos, WIDTH, ITEM_HEIGHT );
|
item.setRect( 0, pos, width(), ITEM_HEIGHT );
|
||||||
content.add( item );
|
content.add( item );
|
||||||
|
|
||||||
pos += item.height();
|
pos += item.height();
|
||||||
@@ -233,22 +239,21 @@ public class WndJournal extends WndTabbed {
|
|||||||
//Journal entries
|
//Journal entries
|
||||||
for (Journal.Record rec : Journal.records) {
|
for (Journal.Record rec : Journal.records) {
|
||||||
ListItem item = new ListItem( Icons.get(Icons.DEPTH), rec.feature.desc(), rec.depth );
|
ListItem item = new ListItem( Icons.get(Icons.DEPTH), rec.feature.desc(), rec.depth );
|
||||||
item.setRect( 0, pos, WIDTH, ITEM_HEIGHT );
|
item.setRect( 0, pos, width(), ITEM_HEIGHT );
|
||||||
content.add( item );
|
content.add( item );
|
||||||
|
|
||||||
pos += item.height();
|
pos += item.height();
|
||||||
}
|
}
|
||||||
|
|
||||||
content.setSize( WIDTH, pos );
|
content.setSize( width(), pos );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Catalog extends Component{
|
private static class Catalog extends Component{
|
||||||
|
|
||||||
private RedButton btnPotions;
|
private RedButton[] itemButtons;
|
||||||
private RedButton btnScrolls;
|
private static final int NUM_BUTTONS = 7;
|
||||||
private RedButton btnRings;
|
|
||||||
|
|
||||||
private static int latestPressedIdx = 0;
|
private static int latestPressedIdx = 0;
|
||||||
|
|
||||||
@@ -256,41 +261,23 @@ public class WndJournal extends WndTabbed {
|
|||||||
|
|
||||||
private ArrayList<CatalogItem> items = new ArrayList<>();
|
private ArrayList<CatalogItem> items = new ArrayList<>();
|
||||||
|
|
||||||
private static boolean showPotions = true;
|
|
||||||
|
|
||||||
public Catalog(){
|
public Catalog(){
|
||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
btnPotions = new RedButton( "" ){
|
itemButtons = new RedButton[NUM_BUTTONS];
|
||||||
|
for (int i = 0; i < NUM_BUTTONS; i++){
|
||||||
|
final int idx = i;
|
||||||
|
itemButtons[i] = new RedButton( "" ){
|
||||||
@Override
|
@Override
|
||||||
protected void onClick() {
|
protected void onClick() {
|
||||||
latestPressedIdx = 0;
|
latestPressedIdx = idx;
|
||||||
updateList();
|
updateList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
btnPotions.icon(new ItemSprite(ItemSpriteSheet.POTION_HOLDER, null));
|
itemButtons[i].icon(new ItemSprite(ItemSpriteSheet.WEAPON_HOLDER + i, null));
|
||||||
add( btnPotions );
|
add( itemButtons[i] );
|
||||||
|
|
||||||
btnScrolls = new RedButton( "" ){
|
|
||||||
@Override
|
|
||||||
protected void onClick() {
|
|
||||||
latestPressedIdx = 1;
|
|
||||||
updateList();
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
btnScrolls.icon(new ItemSprite(ItemSpriteSheet.SCROLL_HOLDER, null));
|
|
||||||
add( btnScrolls );
|
|
||||||
|
|
||||||
btnRings = new RedButton( "" ){
|
|
||||||
@Override
|
|
||||||
protected void onClick() {
|
|
||||||
latestPressedIdx = 2;
|
|
||||||
updateList();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
btnRings.icon(new ItemSprite(ItemSpriteSheet.RING_HOLDER, null));
|
|
||||||
add( btnRings );
|
|
||||||
|
|
||||||
list = new ScrollPane( new Component() ) {
|
list = new ScrollPane( new Component() ) {
|
||||||
@Override
|
@Override
|
||||||
@@ -306,40 +293,48 @@ public class WndJournal extends WndTabbed {
|
|||||||
add( list );
|
add( list );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int BUTTON_WIDTH = 36;
|
private static final int BUTTON_HEIGHT = 17;
|
||||||
private static final int BUTTON_HEIGHT = 18;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void layout() {
|
protected void layout() {
|
||||||
super.layout();
|
super.layout();
|
||||||
|
|
||||||
btnPotions.setRect(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
|
int perRow = ShatteredPixelDungeon.landscape() ? NUM_BUTTONS : 4;
|
||||||
PixelScene.align( btnPotions );
|
float buttonWidth = (width() - (perRow-1))/perRow;
|
||||||
|
|
||||||
btnScrolls.setRect((width() - BUTTON_WIDTH)/2f, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
|
for (int i = 0; i < NUM_BUTTONS; i++) {
|
||||||
PixelScene.align(btnScrolls);
|
itemButtons[i].setRect((i%perRow) * (buttonWidth + 1), (i/perRow) * (BUTTON_HEIGHT + 1),
|
||||||
|
buttonWidth, BUTTON_HEIGHT);
|
||||||
|
PixelScene.align(itemButtons[i]);
|
||||||
|
}
|
||||||
|
|
||||||
btnRings.setRect(width() - BUTTON_WIDTH, 0, BUTTON_WIDTH, BUTTON_HEIGHT);
|
list.setRect(0, itemButtons[NUM_BUTTONS-1].bottom() + 1, width,
|
||||||
PixelScene.align(btnRings);
|
height - itemButtons[NUM_BUTTONS-1].bottom() - 1);
|
||||||
|
|
||||||
list.setRect( 0, btnPotions.height() + 1, width, height - btnPotions.height() - 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateList() {
|
private void updateList() {
|
||||||
|
|
||||||
items.clear();
|
items.clear();
|
||||||
|
|
||||||
|
for (int i = 0; i < NUM_BUTTONS; i++){
|
||||||
|
if (i == latestPressedIdx){
|
||||||
|
itemButtons[i].icon().color(TITLE_COLOR);
|
||||||
|
} else {
|
||||||
|
itemButtons[i].icon().resetColor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component content = list.content();
|
Component content = list.content();
|
||||||
content.clear();
|
content.clear();
|
||||||
list.scrollTo( 0, 0 );
|
list.scrollTo( 0, 0 );
|
||||||
|
|
||||||
ArrayList<Class<?>> itemClasses;
|
ArrayList<Class<?>> itemClasses;
|
||||||
if (latestPressedIdx == 0){
|
if (latestPressedIdx == 5){
|
||||||
itemClasses = new ArrayList<>(Arrays.asList(Generator.Category.POTION.classes));
|
itemClasses = new ArrayList<>(Arrays.asList(Generator.Category.POTION.classes));
|
||||||
for ( Class unknown : Potion.getUnknown()){
|
for ( Class unknown : Potion.getUnknown()){
|
||||||
if (itemClasses.remove(unknown)) itemClasses.add(unknown);
|
if (itemClasses.remove(unknown)) itemClasses.add(unknown);
|
||||||
}
|
}
|
||||||
} else if (latestPressedIdx == 1) {
|
} else if (latestPressedIdx == 6) {
|
||||||
itemClasses = new ArrayList<>(Arrays.asList(Generator.Category.SCROLL.classes));
|
itemClasses = new ArrayList<>(Arrays.asList(Generator.Category.SCROLL.classes));
|
||||||
for ( Class unknown : Scroll.getUnknown()){
|
for ( Class unknown : Scroll.getUnknown()){
|
||||||
if (itemClasses.remove(unknown)) itemClasses.add(unknown);
|
if (itemClasses.remove(unknown)) itemClasses.add(unknown);
|
||||||
|
|||||||
Reference in New Issue
Block a user