From 6f44503a3b0e8252b0b4999c6919af25fd7dc535 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 17 Jan 2021 20:27:14 -0500 Subject: [PATCH] v0.9.2: implemented base UI and structure for T3 talents --- .../main/assets/interfaces/talent_icons.png | Bin 1891 -> 2582 bytes .../src/main/assets/messages/ui/ui.properties | 1 + .../actors/hero/Talent.java | 148 +++++++++++++----- .../scenes/HeroSelectScene.java | 60 ++++++- .../shatteredpixeldungeon/ui/ScrollPane.java | 3 +- .../shatteredpixeldungeon/ui/TalentsPane.java | 14 +- .../windows/WndHero.java | 10 +- 7 files changed, 182 insertions(+), 54 deletions(-) diff --git a/core/src/main/assets/interfaces/talent_icons.png b/core/src/main/assets/interfaces/talent_icons.png index 22ce9c9152fad6c883aa2f3f91367912ba500a84..ee6714906b32893609c37cb7a64d9ee5fa5ee52e 100644 GIT binary patch literal 2582 zcmXYzc~n!!7su!2kr%`SP^g3eA%Y4Nsv&>~f(gnZF5p6eiiKDZQ@3EH8UvEYQn3Pp zqAUU?{;X^+xPvX4D2O6U!lqOd5Kxv#O=L+RnAdpvn?Gj0cjnB!Gv|J0&i#E$Pyoq* zVgLXj1+Mqq1^`Yc0ZSj&^%1+6S-K%<%cc;&ud{am5MjEelL0X$cgimn78d5(H-5Eu zHQ6!H9~iXHL$5LLZFY8cd&5Jp?K%Qh*ZfqY+fi5uPM2oz1;hhS*$J!6u&KKJ79h2 z)*18s1ATo$c+kg!^!r70V_(wFG>ap>8Z4V6Z>j&OO<5YYe7AY@p%@-J=5^9B=Msd(Ty z!+jcDY}W4w@}}|C5s)Gpn&E1$0?GR))q4GWP4hR5hXh)`wxyUF4#H=|CkX~<@p((Ix?WAcLX%I8cS7r-M#}3$vMHrCodH#EQ*O4c|_+ zp;QI*n#FWHr$&XVC8E_U*xHV#)F7P_hRBsdWdsgAqzQQ*@1RPk2>x9gh1(K)SKoJ@ zakmqyv;i&!Sjj=T(GECV3Fw=Nxs`J&Ew*_(DxCCFq4)x;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O1AG^s(Zj z1El-H#VmKpZHAx( zl|9#*N0Inc1x1Rp2mi+FC=3ke+>(}ack8C2!PR?46NW>zbrH?|aQhmFnTi}gCGtLj zp(#k+2AssoRp?)o5iSD_?XK0@=s-6qtM)v29OfP`(!CiKTm1iQ)-1|ET(=39lN- zFiojP;@0CMhHTzrZT4n`&SvJQ`C5!_yH8}L*NrS<8t%@QDzKiMEzCtJR)OJ1MGs#> zqxEw-zNsHCIJ*Hs8icfr5^`VTDva6Oz0%PPbzwg-Uc8oViN3~(bawFhL;?mcQ=-(! zb^_D_XF2O5vC#sSK4E{MK}bZ8S6r1NY`>)$g~JB18?Wy~bF-hct2S)%z)N~5WAUj` zHrRK$xz*NNT7~Z9ZG=u5;V{!C!(#*B?fMRev@(A${fHm)J0Hum$%k0G4%J+Zp{qD& zK5%4!a&|S^;@v8=W>vzM6Jwr;Mv;kV9tX6JYa6>vu4M5)(0XHV#*l0h+1RA5_F30a zpwRY~72VQWk0I#rh{jIVMl%%f5nkPHkXRj?$5se^g zGldo=Q<;TK9G+s#j!*Su7h?~2V23@>Q#1V~)qBT65(a$*s@ZEmqt>CP+m{=P-q1 z;drTV!G+R`!-g^@o|^DH2~cosQpJ2EQbms{Ih`{u4A?P<;aK8iQQ?A8GeJ$1UL1> talents ){ + if (cls == HeroSubClass.NONE) return; + + while (talents.size() < MAX_TALENT_TIERS){ + talents.add(new LinkedHashMap<>()); + } + + ArrayList tierTalents = new ArrayList<>(); + + //tier 3 + switch (cls){ + case BERSERKER: default: + Collections.addAll(tierTalents, BERSERKER_T3_1, BERSERKER_T3_2, BERSERKER_T3_3); + break; + case GLADIATOR: + Collections.addAll(tierTalents, GLADIATOR_T3_1, GLADIATOR_T3_2, GLADIATOR_T3_3); + break; + case BATTLEMAGE: + Collections.addAll(tierTalents, BATTLEMAGE_T3_1, BATTLEMAGE_T3_2, BATTLEMAGE_T3_3); + break; + case WARLOCK: + Collections.addAll(tierTalents, WARLOCK_T3_1, WARLOCK_T3_2, WARLOCK_T3_3); + break; + case ASSASSIN: + Collections.addAll(tierTalents, ASSASSIN_T3_1, ASSASSIN_T3_2, ASSASSIN_T3_3); + break; + case FREERUNNER: + Collections.addAll(tierTalents, FREERUNNER_T3_1, FREERUNNER_T3_2, FREERUNNER_T3_3); + break; + case SNIPER: + Collections.addAll(tierTalents, SNIPER_T3_1, SNIPER_T3_2, SNIPER_T3_3); + break; + case WARDEN: + Collections.addAll(tierTalents, WARDEN_T3_1, WARDEN_T3_2, WARDEN_T3_3); + break; + } + for (Talent talent : tierTalents){ + talents.get(2).put(talent, 0); + } + tierTalents.clear(); + + //tier4 + //TBD } private static final String TALENT_TIER = "talents_tier_"; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/HeroSelectScene.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/HeroSelectScene.java index ae36b1060..4572e17df 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/HeroSelectScene.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/scenes/HeroSelectScene.java @@ -39,6 +39,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton; 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.StyledButton; import com.shatteredpixel.shatteredpixeldungeon.ui.TalentsPane; @@ -333,12 +334,16 @@ public class HeroSelectScene extends PixelScene { private RenderedTextBlock info; private TalentsPane talents; + private RedButton firstSub; + private RedButton secondSub; - private int WIDTH = 120; + private int WIDTH = 130; private int HEIGHT = 120; private int MARGIN = 2; private int INFO_WIDTH = WIDTH - MARGIN*2; + private static boolean secondSubclass = false; + public WndHeroInfo( HeroClass cl ){ title = PixelScene.renderTextBlock(9); @@ -350,9 +355,46 @@ public class HeroSelectScene extends PixelScene { ArrayList> talentList = new ArrayList<>(); Talent.initClassTalents(cl, talentList); + Talent.initSubclassTalents(cl.subClasses()[secondSubclass ? 1 : 0], talentList); talents = new TalentsPane(false, talentList); add(talents); + firstSub = new RedButton(Messages.titleCase(cl.subClasses()[0].title()), 7){ + @Override + protected void onClick() { + super.onClick(); + if (secondSubclass){ + secondSubclass = false; + hide(); + WndHeroInfo newWindow = new WndHeroInfo(cl); + newWindow.talents.scrollTo(0, talents.content().camera.scroll.y); + newWindow.select(2); + ShatteredPixelDungeon.scene().addToFront(newWindow); + } + } + }; + if (!secondSubclass) firstSub.textColor(Window.TITLE_COLOR); + firstSub.setSize(40, firstSub.reqHeight()+2); + add(firstSub); + + secondSub = new RedButton(Messages.titleCase(cl.subClasses()[1].title()), 7){ + @Override + protected void onClick() { + super.onClick(); + if (!secondSubclass){ + secondSubclass = true; + hide(); + WndHeroInfo newWindow = new WndHeroInfo(cl); + newWindow.talents.scrollTo(0, talents.content().camera.scroll.y); + newWindow.select(2); + ShatteredPixelDungeon.scene().addToFront(newWindow); + } + } + }; + if (secondSubclass) secondSub.textColor(Window.TITLE_COLOR); + secondSub.setSize(40, secondSub.reqHeight()+2); + add(secondSub); + Tab tab; Image[] tabIcons; switch (cl){ @@ -415,6 +457,8 @@ public class HeroSelectScene extends PixelScene { info.text(Messages.get(WndHeroInfo.class, "talents_desc"), INFO_WIDTH); } talents.visible = talents.active = value; + firstSub.visible = firstSub.active = value; + secondSub.visible = secondSub.active = value; } }; add(tab); @@ -435,6 +479,7 @@ public class HeroSelectScene extends PixelScene { }; add(tab); + resize(WIDTH, HEIGHT); select(0); } @@ -445,14 +490,13 @@ public class HeroSelectScene extends PixelScene { title.setPos((WIDTH-title.width())/2, MARGIN); info.setPos(MARGIN, title.bottom()+2*MARGIN); - talents.setRect(0, info.bottom()+2*MARGIN, WIDTH, 100); - if (talents.visible) { - resize(WIDTH, (int) talents.bottom()); - talents.setRect(0, info.bottom()+2*MARGIN, WIDTH, 100); - } else { - resize(WIDTH, (int) info.bottom() + 2*MARGIN); - } + firstSub.setPos((title.left() - firstSub.width())/2, 0); + secondSub.setPos(title.right() + (WIDTH - title.right() - secondSub.width())/2, 0); + + talents.setRect(0, info.bottom()+2*MARGIN, WIDTH, HEIGHT - (info.bottom()+2*MARGIN)); + + resize(WIDTH, Math.max(HEIGHT, (int)info.bottom())); layoutTabs(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ScrollPane.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ScrollPane.java index 672a99bbe..5f8c1863d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ScrollPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ScrollPane.java @@ -61,6 +61,7 @@ public class ScrollPane extends Component { public void scrollTo( float x, float y ) { content.camera.scroll.set( x, y ); + thumb.y = y + height * content.camera.scroll.y / content.height(); } @Override @@ -92,7 +93,7 @@ public class ScrollPane extends Component { if (thumb.visible) { thumb.scale.set( 2, height * height / content.height() ); thumb.x = right() - thumb.width(); - thumb.y = y; + thumb.y = y + height * content.camera.scroll.y / content.height(); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/TalentsPane.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/TalentsPane.java index 41202c6c6..df3b5bce1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/TalentsPane.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/TalentsPane.java @@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.ui; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.HeroSubClass; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; @@ -58,6 +59,9 @@ public class TalentsPane extends ScrollPane { && Dungeon.hero.lvl+1 >= Talent.tierLevelThresholds[tiersAvailable+1]){ tiersAvailable++; } + if (tiersAvailable > 2 && Dungeon.hero.subClass == HeroSubClass.NONE){ + tiersAvailable = 2; + } } for (int i = 0; i < Math.min(tiersAvailable, talents.size()); i++){ @@ -78,6 +82,8 @@ public class TalentsPane extends ScrollPane { if (tiersAvailable == 1) { blockText = PixelScene.renderTextBlock(Messages.get(this, "unlock_tier2"), 6); + } else if (tiersAvailable == 2) { + blockText = PixelScene.renderTextBlock(Messages.get(this, "unlock_tier3"), 6); } else { blockText = PixelScene.renderTextBlock(Messages.get(this, "coming_soon"), 6); } @@ -102,13 +108,17 @@ public class TalentsPane extends ScrollPane { } + float bottom = Math.max(height, top + 20); + blocker.x = 0; blocker.y = top; - blocker.size(width, height - top); + blocker.size(width, bottom - top); blockText.maxWidth((int)width); blockText.align(RenderedTextBlock.CENTER_ALIGN); - blockText.setPos((width - blockText.width())/2f, blocker.y + (height - blocker.y - blockText.height())/2); + blockText.setPos((width - blockText.width())/2f, blocker.y + (bottom - blocker.y - blockText.height())/2); + + content.setSize(width, bottom); } public static class TalentTierPane extends Component { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java index 7588b4b35..03f1e680d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndHero.java @@ -48,8 +48,8 @@ import java.util.Locale; public class WndHero extends WndTabbed { - private static final int WIDTH = 120; - private static final int HEIGHT = 100; + private static final int WIDTH = 130; + private static final int HEIGHT = 120; private StatsTab stats; private TalentsTab talents; @@ -99,7 +99,11 @@ public class WndHero extends WndTabbed { } ); layoutTabs(); - + + talents.setRect(0, 0, WIDTH, HEIGHT); + talents.pane.scrollTo(0, talents.pane.content().height() - talents.pane.height()); + talents.layout(); + select( lastIdx ); }