From 83ba5dc931834fd44b6e455e203621ddacc65104 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 23 Aug 2021 19:26:12 -0400 Subject: [PATCH] v1.0.1: added info buttons to the scroll of enchantment window --- .../scrolls/exotic/ScrollOfEnchantment.java | 29 +++++++++++++++++++ .../windows/WndOptions.java | 23 ++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfEnchantment.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfEnchantment.java index e92db9998..02acb94e7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfEnchantment.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/exotic/ScrollOfEnchantment.java @@ -37,9 +37,12 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; +import com.shatteredpixel.shatteredpixeldungeon.ui.Icons; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage; import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndTitledMessage; import com.watabou.noosa.audio.Sample; public class ScrollOfEnchantment extends ExoticScroll { @@ -113,6 +116,19 @@ public class ScrollOfEnchantment extends ExoticScroll { } } + @Override + protected boolean hasInfo(int index) { + return index < 3; + } + + @Override + protected void onInfo( int index ) { + GameScene.show(new WndTitledMessage( + Icons.get(Icons.INFO), + Messages.titleCase(enchants[index].name()), + enchants[index].desc())); + } + @Override public void onBackPressed() { //do nothing, reader has to cancel @@ -150,6 +166,19 @@ public class ScrollOfEnchantment extends ExoticScroll { Talent.onUpgradeScrollUsed( Dungeon.hero ); } } + + @Override + protected boolean hasInfo(int index) { + return index < 3; + } + + @Override + protected void onInfo( int index ) { + GameScene.show(new WndTitledMessage( + Icons.get(Icons.INFO), + Messages.titleCase(glyphs[index].name()), + glyphs[index].desc())); + } @Override public void onBackPressed() { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndOptions.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndOptions.java index 47051d359..15d9599ac 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndOptions.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndOptions.java @@ -22,6 +22,8 @@ package com.shatteredpixel.shatteredpixeldungeon.windows; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; +import com.shatteredpixel.shatteredpixeldungeon.ui.IconButton; +import com.shatteredpixel.shatteredpixeldungeon.ui.Icons; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; @@ -91,9 +93,22 @@ public class WndOptions extends Window { } }; btn.enable(enabled(i)); - btn.setRect( 0, pos, width, BUTTON_HEIGHT ); add( btn ); + if (!hasInfo(i)) { + btn.setRect(0, pos, width, BUTTON_HEIGHT); + } else { + btn.setRect(0, pos, width - BUTTON_HEIGHT, BUTTON_HEIGHT); + IconButton info = new IconButton(Icons.get(Icons.INFO)){ + @Override + protected void onClick() { + onInfo( index ); + } + }; + info.setRect(width-BUTTON_HEIGHT, pos, BUTTON_HEIGHT, BUTTON_HEIGHT); + add(info); + } + pos += BUTTON_HEIGHT + MARGIN; } @@ -105,4 +120,10 @@ public class WndOptions extends Window { } protected void onSelect( int index ) {} + + protected boolean hasInfo( int index) { + return false; + } + + protected void onInfo( int index ) {} }