diff --git a/core/src/main/assets/messages/items/items.properties b/core/src/main/assets/messages/items/items.properties index efda441b5..b578bc3ca 100644 --- a/core/src/main/assets/messages/items/items.properties +++ b/core/src/main/assets/messages/items/items.properties @@ -2158,6 +2158,7 @@ items.item.ac_drop=DROP items.item.ac_throw=THROW items.item.rankings_desc=Killed by: %s items.item.curse=curse +items.item.custom_note=This item has a custom note: "_%s_" items.kindofmisc.unequip_title=Unequip one item items.kindofmisc.unequip_message=You must unequip one of these items first. Select an item to swap with. diff --git a/core/src/main/assets/messages/windows/windows.properties b/core/src/main/assets/messages/windows/windows.properties index b43072a92..6655018e4 100644 --- a/core/src/main/assets/messages/windows/windows.properties +++ b/core/src/main/assets/messages/windows/windows.properties @@ -140,6 +140,7 @@ windows.wndjournal$catalogtab.trap_count=You have triggered this trap a total of windows.wndjournal$catalogtab.plant_count=You have trampled this plant a total of _%,d_ times. windows.wndjournal$catalogtab.not_seen_lore=You haven't found this lore text in any of your runs yet. windows.wndjournal$badgestab.title=Badges +windows.wndjournal$badgestab.title_main_menu=Your Badges windows.wndjournal$badgestab.this_run=This Run windows.wndjournal$badgestab.overall=Overall diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java index 0cba1a87b..cd3619525 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/Item.java @@ -504,16 +504,18 @@ public class Item implements Bundlable { public String info() { - Notes.CustomRecord note; - if (this instanceof EquipableItem){ - note = Notes.findCustomRecord(((EquipableItem) this).customNoteID); - } else { - note = Notes.findCustomRecord(getClass()); + if (Dungeon.hero != null) { + Notes.CustomRecord note; + if (this instanceof EquipableItem) { + note = Notes.findCustomRecord(((EquipableItem) this).customNoteID); + } else { + note = Notes.findCustomRecord(getClass()); + } + if (note != null){ + return Messages.get(this, "custom_note", note.title()) + "\n\n" + desc(); + } } - if (note != null){ - return "This item has a custom note: \"_" + note.title() + "_\"\n\n" + desc(); - } return desc(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java index 2ca1f084f..4fd07af5d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/Potion.java @@ -195,6 +195,9 @@ public class Potion extends Item { if (handler != null && handler.contains(this)) { image = handler.image(this); color = handler.label(this); + } else { + image = ItemSpriteSheet.POTION_CRIMSON; + color = "crimson"; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java index 1ab316ebf..5f7442fb8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/Ring.java @@ -110,6 +110,9 @@ public class Ring extends KindofMisc { if (handler != null && handler.contains(this)){ image = handler.image(this); gem = handler.label(this); + } else { + image = ItemSpriteSheet.RING_GARNET; + gem = "garnet"; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java index 9e9dd97b1..e4a38312a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/Scroll.java @@ -149,6 +149,9 @@ public abstract class Scroll extends Item { if (handler != null && handler.contains(this)) { image = handler.image(this); rune = handler.label(this); + } else { + image = ItemSpriteSheet.SCROLL_KAUNAN; + rune = "KAUNAN"; } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/BadgesScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/BadgesScene.java index 7bb27f318..3be26cd4b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/BadgesScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/BadgesScene.java @@ -23,23 +23,39 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; +import com.shatteredpixel.shatteredpixeldungeon.Chrome; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; +import com.shatteredpixel.shatteredpixeldungeon.journal.Journal; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.ui.Archs; -import com.shatteredpixel.shatteredpixeldungeon.ui.BadgesGrid; import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock; +import com.shatteredpixel.shatteredpixeldungeon.ui.StyledButton; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal; import com.watabou.noosa.Camera; +import com.watabou.noosa.NinePatch; import com.watabou.noosa.audio.Music; public class BadgesScene extends PixelScene { + public static final int WIDTH_P = 126; + public static final int WIDTH_L = 216; + + private static int lastIDX = 0; + @Override public void create() { super.create(); + Dungeon.hero = null; + Badges.loadGlobal(); + Journal.loadGlobal(); + Music.INSTANCE.playTracks( new String[]{Assets.Music.THEME_1, Assets.Music.THEME_2}, new float[]{1, 1}, @@ -50,13 +66,9 @@ public class BadgesScene extends PixelScene { int w = Camera.main.width; int h = Camera.main.height; - Archs archs = new Archs(); - archs.setSize( w, h ); - add( archs ); - - float margin = 5; float top = 20; + //TODO icon title? RenderedTextBlock title = PixelScene.renderTextBlock( Messages.get(this, "title"), 9 ); title.hardlight(Window.TITLE_COLOR); title.setPos( @@ -66,10 +78,137 @@ public class BadgesScene extends PixelScene { align(title); add(title); - Badges.loadGlobal(); - BadgesGrid grid = new BadgesGrid(true); - grid.setRect(margin, top, w-(2*margin), h-top-margin); - add(grid); + NinePatch panel = Chrome.get(Chrome.Type.TOAST); + + int pw = (landscape() ? WIDTH_L : WIDTH_P) + panel.marginHor(); + int ph = h - 50 + panel.marginVer(); + + panel.size(pw, ph); + panel.x = (w - pw) / 2f; + panel.y = title.bottom() + 5; + add(panel); + + switch (lastIDX){ + case 0: default: + WndJournal.BadgesTab badges = new WndJournal.BadgesTab(); + add(badges); + badges.setRect(panel.x + panel.marginLeft(), + panel.y + panel.marginTop(), + panel.width() - panel.marginHor(), + panel.height() - panel.marginVer()); + break; + case 1: + WndJournal.CatalogTab catalog = new WndJournal.CatalogTab(); + add(catalog); + catalog.setRect(panel.x + panel.marginLeft(), + panel.y + panel.marginTop(), + panel.width() - panel.marginHor(), + panel.height() - panel.marginVer()); + catalog.updateList(); + break; + case 2: + WndJournal.GuideTab guidebook = new WndJournal.GuideTab(); + add(guidebook); + guidebook.setRect(panel.x + panel.marginLeft(), + panel.y + panel.marginTop(), + panel.width() - panel.marginHor(), + panel.height() - panel.marginVer()); + guidebook.updateList(); + break; + case 3: + WndJournal.AlchemyTab alchemy = new WndJournal.AlchemyTab(); + add(alchemy); + alchemy.setRect(panel.x + panel.marginLeft(), + panel.y + panel.marginTop(), + panel.width() - panel.marginHor(), + panel.height() - panel.marginVer()); + break; + } + + StyledButton btnBadges = new StyledButton(Chrome.Type.GREY_BUTTON_TR, ""){ + @Override + protected void onClick() { + if (lastIDX != 0) { + lastIDX = 0; + } + ShatteredPixelDungeon.seamlessResetScene(); + super.onClick(); + } + + @Override + protected String hoverText() { + return Messages.get(WndJournal.BadgesTab.class, "title"); + } + }; + btnBadges.icon(Icons.BADGES.get()); + btnBadges.setRect(panel.x, panel.y + ph - 3, pw/4f + 1.5f, lastIDX == 0 ? 25 : 20); + align(btnBadges); + if (lastIDX != 0) btnBadges.icon().brightness(0.6f); + addToBack(btnBadges); + + StyledButton btnCatalog = new StyledButton(Chrome.Type.GREY_BUTTON_TR, ""){ + @Override + protected void onClick() { + if (lastIDX != 1) { + lastIDX = 1; + } + ShatteredPixelDungeon.seamlessResetScene(); + super.onClick(); + } + @Override + protected String hoverText() { + return Messages.get(WndJournal.CatalogTab.class, "title"); + } + }; + btnCatalog.icon(Icons.CATALOG.get()); + btnCatalog.setRect(btnBadges.right()-2, btnBadges.top(), pw/4f + 1.5f, lastIDX == 1 ? 25 : 20); + align(btnCatalog); + if (lastIDX != 1) btnCatalog.icon().brightness(0.6f); + addToBack(btnCatalog); + + StyledButton btnGuide = new StyledButton(Chrome.Type.GREY_BUTTON_TR, ""){ + @Override + protected void onClick() { + if (lastIDX != 2) { + lastIDX = 2; + } + ShatteredPixelDungeon.seamlessResetScene(); + super.onClick(); + } + @Override + protected String hoverText() { + return Messages.get(WndJournal.GuideTab.class, "title"); + } + }; + btnGuide.icon(new ItemSprite(ItemSpriteSheet.MASTERY)); + btnGuide.setRect(btnCatalog.right()-2, btnBadges.top(), pw/4f + 1.5f, lastIDX == 2 ? 25 : 20); + align(btnGuide); + if (lastIDX != 2) btnGuide.icon().brightness(0.6f); + addToBack(btnGuide); + + StyledButton btnAlchemy = new StyledButton(Chrome.Type.GREY_BUTTON_TR, ""){ + @Override + protected void onClick() { + if (lastIDX != 3) { + lastIDX = 3; + } + ShatteredPixelDungeon.seamlessResetScene(); + super.onClick(); + } + @Override + protected String hoverText() { + return Messages.get(WndJournal.AlchemyTab.class, "title"); + } + }; + btnAlchemy.icon(Icons.ALCHEMY.get()); + btnAlchemy.setRect(btnGuide.right()-2, btnBadges.top(), pw/4f + 1.5f, lastIDX == 3 ? 25 : 20); + align(btnAlchemy); + if (lastIDX != 3) btnAlchemy.icon().brightness(0.6f); + addToBack(btnAlchemy); + + Archs archs = new Archs(); + archs.setSize( w, h ); + addToBack( archs ); ExitButton btnExit = new ExitButton(); btnExit.setPos( Camera.main.width - btnExit.width(), 0 ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java index bbbf5adfd..44735fdd1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ItemSlot.java @@ -254,7 +254,7 @@ public class ItemSlot extends Button { if (item.levelKnown){ int str = item instanceof Weapon ? ((Weapon)item).STRReq() : ((Armor)item).STRReq(); extra.text( Messages.format( TXT_STRENGTH, str ) ); - if (str > Dungeon.hero.STR()) { + if (Dungeon.hero != null && str > Dungeon.hero.STR()) { extra.hardlight( DEGRADED ); } else if (item instanceof Weapon && ((Weapon) item).masteryPotionBonus){ extra.hardlight( MASTERED ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ScrollingGridPane.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ScrollingGridPane.java index de90b95ea..837fa9187 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ScrollingGridPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ScrollingGridPane.java @@ -54,7 +54,6 @@ public class ScrollingGridPane extends ScrollPane { public void addItem( ScrollingGridPane.GridItem item ){ content.add(item); items.add(item); - layout(); } public void addHeader( String text ){ @@ -65,7 +64,6 @@ public class ScrollingGridPane extends ScrollPane { GridHeader header = new GridHeader(text, size, center); content.add(header); items.add(header); - layout(); } @Override @@ -76,7 +74,6 @@ public class ScrollingGridPane extends ScrollPane { @Override protected void layout() { - super.layout(); float left = 0; float top = 0; @@ -122,7 +119,7 @@ public class ScrollingGridPane extends ScrollPane { } sep.size(1, item.height()+1+ITEM_SIZE); sep.x = left-1; - sep.y = y+top; + sep.y = top; } else { left = 0; top += ITEM_SIZE + 2; @@ -164,6 +161,7 @@ public class ScrollingGridPane extends ScrollPane { } content.setSize(width, top); + super.layout(); } public static class GridItem extends Component { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java index 300b05610..ce3062921 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndJournal.java @@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Badges; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.Statistics; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; @@ -219,10 +220,10 @@ public class WndJournal extends WndTabbed { @Override protected void layout() { super.layout(); - list.setRect( 0, 0, width, height); + list.setRect( x, y, width, height); } - private void updateList(){ + public void updateList(){ list.addTitle(Document.ADVENTURERS_GUIDE.title()); for (String page : Document.ADVENTURERS_GUIDE.pageNames()){ @@ -235,7 +236,7 @@ public class WndJournal extends WndTabbed { @Override public boolean onClick(float x, float y) { if (inside( x, y ) && found) { - GameScene.show( new WndStory( Document.ADVENTURERS_GUIDE.pageSprite(page), + ShatteredPixelDungeon.scene().addToFront( new WndStory( Document.ADVENTURERS_GUIDE.pageSprite(page), Document.ADVENTURERS_GUIDE.pageTitle(page), Document.ADVENTURERS_GUIDE.pageBody(page) )); Document.ADVENTURERS_GUIDE.readPage(page); @@ -320,7 +321,7 @@ public class WndJournal extends WndTabbed { if (PixelScene.landscape()){ float buttonWidth = width()/pageButtons.length; for (int i = 0; i < NUM_BUTTONS; i++) { - pageButtons[i].setRect(i*buttonWidth, 0, buttonWidth, ITEM_HEIGHT); + pageButtons[i].setRect(x + i*buttonWidth, y, buttonWidth, ITEM_HEIGHT); PixelScene.align(pageButtons[i]); } } else { @@ -329,7 +330,7 @@ public class WndJournal extends WndTabbed { float y = 0; float x = 0; for (int i = 0; i < NUM_BUTTONS; i++) { - pageButtons[i].setRect(x, y, buttonWidth, ITEM_HEIGHT); + pageButtons[i].setRect(this.x + x, this.y + y, buttonWidth, ITEM_HEIGHT); PixelScene.align(pageButtons[i]); x += buttonWidth; if (i == 4){ @@ -340,8 +341,8 @@ public class WndJournal extends WndTabbed { } } - list.setRect(0, pageButtons[NUM_BUTTONS-1].bottom() + 1, width, - height - pageButtons[NUM_BUTTONS-1].bottom() - 1); + list.setRect(x, pageButtons[NUM_BUTTONS-1].bottom() + 1, width, + height - pageButtons[NUM_BUTTONS-1].bottom() + y - 1); updateList(); } @@ -587,16 +588,19 @@ public class WndJournal extends WndTabbed { float buttonWidth = width()/perRow; for (int i = 0; i < NUM_BUTTONS; i++) { - itemButtons[i].setRect((i%perRow) * (buttonWidth), (i/perRow) * (ITEM_HEIGHT ), + itemButtons[i].setRect(x +(i%perRow) * (buttonWidth), + y + (i/perRow) * (ITEM_HEIGHT ), buttonWidth, ITEM_HEIGHT); PixelScene.align(itemButtons[i]); } - grid.setRect(0, itemButtons[NUM_BUTTONS-1].bottom() + 1, width, - height - itemButtons[NUM_BUTTONS-1].bottom() - 1); + grid.setRect(x, + itemButtons[NUM_BUTTONS-1].bottom() + 1, + width, + height - itemButtons[NUM_BUTTONS-1].height() - 1); } - private void updateList() { + public void updateList() { grid.clear(); @@ -701,7 +705,7 @@ public class WndJournal extends WndTabbed { } grid.setRect(x, itemButtons[NUM_BUTTONS-1].bottom() + 1, width, - height - itemButtons[NUM_BUTTONS-1].bottom() - 1); + height - itemButtons[NUM_BUTTONS-1].height() - 1); grid.scrollTo(0, scrollPositions[currentItemIdx]); } @@ -1020,6 +1024,8 @@ public class WndJournal extends WndTabbed { private RedButton btnLocal; private RedButton btnGlobal; + private RenderedTextBlock title; + private Component badgesLocal; private Component badgesGlobal; @@ -1028,40 +1034,42 @@ public class WndJournal extends WndTabbed { @Override protected void createChildren() { - btnLocal = new RedButton(Messages.get(this, "this_run")){ - @Override - protected void onClick() { - super.onClick(); - global = false; - updateList(); + if (Dungeon.hero != null) { + btnLocal = new RedButton(Messages.get(this, "this_run")) { + @Override + protected void onClick() { + super.onClick(); + global = false; + updateList(); + } + }; + btnLocal.icon(Icons.BADGES.get()); + add(btnLocal); + + btnGlobal = new RedButton(Messages.get(this, "overall")) { + @Override + protected void onClick() { + super.onClick(); + global = true; + updateList(); + } + }; + btnGlobal.icon(Icons.BADGES.get()); + add(btnGlobal); + + if (Badges.filterReplacedBadges(false).size() <= 8){ + badgesLocal = new BadgesList(false); + } else { + badgesLocal = new BadgesGrid(false); } - }; - btnLocal.icon(Icons.BADGES.get()); - add(btnLocal); - - btnGlobal = new RedButton(Messages.get(this, "overall")){ - @Override - protected void onClick() { - super.onClick(); - global = true; - updateList(); - } - }; - btnGlobal.icon(Icons.BADGES.get()); - add(btnGlobal); - - if (Badges.filterReplacedBadges(false).size() <= 8){ - badgesLocal = new BadgesList(false); + add( badgesLocal ); } else { - badgesLocal = new BadgesGrid(false); + title = PixelScene.renderTextBlock(Messages.get(this, "title_main_menu"), 9); + title.hardlight(Window.TITLE_COLOR); + add(title); } - add( badgesLocal ); - if (Badges.filterReplacedBadges(true).size() <= 8){ - badgesGlobal = new BadgesList(true); - } else { - badgesGlobal = new BadgesGrid(true); - } + badgesGlobal = new BadgesGrid(true); add( badgesGlobal ); } @@ -1069,19 +1077,29 @@ public class WndJournal extends WndTabbed { protected void layout() { super.layout(); - btnLocal.setRect(0, 0, width/2, 18); - btnGlobal.setRect(width/2, 0, width/2, 18); + if (btnLocal != null) { + btnLocal.setRect(x, y, width / 2, 18); + btnGlobal.setRect(x + width / 2, y, width / 2, 18); - badgesLocal.setRect( 0, 20, width, height-20); - badgesGlobal.setRect( 0, 20, width, height-20); + badgesLocal.setRect(x, y + 20, width, height-20); + badgesGlobal.setRect( x, y + 20, width, height-20); + } else { + title.setPos( x + (width - title.width())/2, y + (12-title.height())/2); + + badgesGlobal.setRect( x, y + 14, width, height-14); + } } private void updateList(){ - badgesLocal.visible = badgesLocal.active = !global; - badgesGlobal.visible = badgesGlobal.active = global; + if (btnLocal != null) { + badgesLocal.visible = badgesLocal.active = !global; + badgesGlobal.visible = badgesGlobal.active = global; - btnLocal.textColor( global ? Window.WHITE : Window.TITLE_COLOR); - btnGlobal.textColor( global ? Window.TITLE_COLOR : Window.WHITE); + btnLocal.textColor(global ? Window.WHITE : Window.TITLE_COLOR); + btnGlobal.textColor(global ? Window.TITLE_COLOR : Window.WHITE); + } else { + badgesGlobal.visible = badgesGlobal.active = true; + } } }