From 79eb1b11df770d1a322b2f0df2b353bf56a428cc Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 11 Jul 2019 01:57:12 -0400 Subject: [PATCH] v0.7.4: reworked the title scene --- core/src/main/assets/chrome.png | Bin 1060 -> 1159 bytes core/src/main/assets/dashboard.png | Bin 1113 -> 0 bytes core/src/main/assets/icons.png | Bin 2113 -> 2766 bytes .../shatteredpixeldungeon/Chrome.java | 10 +- .../scenes/AlchemyScene.java | 2 +- .../scenes/TitleScene.java | 169 +++++++++--------- .../ui/ChangesButton.java | 74 -------- .../shatteredpixeldungeon/ui/Icons.java | 35 +++- .../ui/OptionSlider.java | 4 +- .../shatteredpixeldungeon/ui/RedButton.java | 119 +----------- .../ui/StyledButton.java | 147 +++++++++++++++ .../windows/WndBlacksmith.java | 2 +- 12 files changed, 271 insertions(+), 291 deletions(-) delete mode 100644 core/src/main/assets/dashboard.png delete mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/ChangesButton.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StyledButton.java diff --git a/core/src/main/assets/chrome.png b/core/src/main/assets/chrome.png index 2eba9e0fbc05e88189dda956ba16b65a59fcb0c4..cf2cf117c8acf6c87b959d772ef97a0886ebbb4c 100644 GIT binary patch delta 914 zcmV;D18w}I2!{!fBmvuzB~lxXl7n$}YJ!J(XKP?gOi)QnLwkO4V`p7iT~m>Ias=@B zrJs@TCVvA%Nkl3vN+X^m?!F|B4r)n~5dY`+isB4C8-g1(R7| z{pel+76|6od*YZUAn}3_Y%q*Q3@}61xnjt=#d5V;Z|2wgvMehv(5wVld}lP~fEa`r z-1N#~g|_qSeOXs^DdDUH*j&x>NC6>4W=#$VA%8JzIAC_YFDtyIfU^={1B#4B3W%}k z#n=U;)b>)sE6an`YO|eR@2k2#tOcBvfSeE;7IB0wpgHO_yMXq%*X97&BA8$AeOc8f z0*+n}koS5+K!HG6PXVWl0^BDD6ldq>7njclT=l*v;2d4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/core/src/main/assets/icons.png b/core/src/main/assets/icons.png index e0a5104ad1fd9cecd89539a6a0fe6eea21262d8d..49375b94762938bf387e6ade21cb6bad26d56dfc 100644 GIT binary patch delta 2373 zcmV-L3A*;d5Y82lBLV_sp(O!-kB)qNd};scfyrkZt0002~(gB(;E)95js-cC|$)-w~ z0D&hp3}0`amVd>(pW5c+bA5nwXi1riWuddPP;!VXD=P~~W-d!wIyyQ^N=hCc9ttyE zfhIL9KuL~?q5jg+=0IzgXPE!D8<>eax|NsA!+yP6I@Bsz^O_SjP z7Xh=A;Q<$u@Bs(}|NsB|li>jufB&Pz7ui?<00(MGL_t(|0i4v;b|WzmgyAwXlg68N zn9ThCkG3t?3pq*W>mzG{^}poUy^pwR$pw%Q&1Hr?-P zDkyqDN%wnJDnO+_2=yx%jzZ(H3MSK>VCGzwWh7w!XMyeqL6Lw`x%b1mer*KUv({(bp>v&fzh8%7S42{96G5N+^5?O(0;B-UBg! z5g@YUUji5phdVt19)LXse}2C<2>=Q*3J$yq@vy|#K)(P1AfVg*JK%Ucp7a+0UZ9tu zrhthvfC=m>L;x{B2!ID50pKj!83tgy2TtK004P{YFk{Za1eslhCIRVva6wc8SgPQ> zq&R;MFao?_0yxeSK*1w;73R%(?hGtp``62#0Kjrd_Ls+SYykEKf6Xyix=+E!95Eo? zH$e(8ubj`a%)f}flh}N`AAUK2mH=L5nY@bsyX7rJ0{#q8zO%{(z*55gPtxir=Sd(4 z;P_0khPS?$KK23}0L21}tvJOluIl~o;_OU;p#(zWpENE{`*T?M#y-t`wrc>K0?yuT zR7z&$Oba_$z?Z43e_aD&Q502G)it7gWSYi%-?rO=@+()Gm9v5A2tfB2K!sd$YPz3#7ooB_GZ1z;*ChXArOPeB0?2BM!tLx3XyK(4CoYv^0O69E6; zom~0qU9bQ%fe`2e5&uG10=fsc0&og|R|=4&OhC4G#{q!>8m|s~2RL~I6F?q;0bG=@ z{|Igx144{pe<1$y(vX%%0kr{qiZaD-xK`fwk*@+h+!c5Rp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pdyMeg&K_$4(?(nc+7`Dx@_Q;0-BDC1dvuq=@1M;se4!o zn9RQuf7tF^o&xlr(-M$CFA5A}$E&d1inRR1hrm06B>-RFntK7sV1hu`O;Q8Ega2-U z!~Y;?0;IWXpzr%xYG4?~p-V1@5qN4KC4rBn)nDI>1`t5d!Bj2;X#Q{_9~K}q3Cywp zGGQAme?Xs>8Chvy>PVp*rm36Mmqz460R7{{CN+Gqz%1|~@HAg60RE5Wd-=C`2acqC SC-h|i0000 - */ - -package com.shatteredpixel.shatteredpixeldungeon.ui; - -import com.shatteredpixel.shatteredpixeldungeon.Assets; -import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; -import com.shatteredpixel.shatteredpixeldungeon.scenes.ChangesScene; -import com.watabou.noosa.Image; -import com.watabou.noosa.audio.Sample; -import com.watabou.noosa.ui.Button; - -public class ChangesButton extends Button { - - protected Image image; - - public ChangesButton() { - super(); - - width = image.width; - height = image.height; - } - - @Override - protected void createChildren() { - super.createChildren(); - - image = Icons.NOTES.get(); - add( image ); - } - - @Override - protected void layout() { - super.layout(); - - image.x = x; - image.y = y; - } - - @Override - protected void onTouchDown() { - image.brightness( 1.5f ); - Sample.INSTANCE.play( Assets.SND_CLICK ); - } - - @Override - protected void onTouchUp() { - image.resetColor(); - } - - @Override - protected void onClick() { - ChangesScene.changesSelected = 0; - ShatteredPixelDungeon.switchNoFade(ChangesScene.class); - } -} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java index 32072e3fc..25bf6b1b8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Icons.java @@ -36,7 +36,6 @@ public enum Icons { TARGET, MASTERY, WATA, - SHPX, WARRIOR, MAGE, ROGUE, @@ -58,7 +57,13 @@ public enum Icons { LANGS, CHALLENGE_OFF, CHALLENGE_ON, - RESUME; + RESUME, + ENTER, + GOLD, + RANKINGS, + BADGES, + CHANGES, + SHPX; public Image get() { return get( this ); @@ -94,9 +99,6 @@ public enum Icons { case WATA: icon.frame( icon.texture.uvRect( 30, 16, 45, 26 ) ); break; - case SHPX: - icon.frame( icon.texture.uvRect( 64, 44, 80, 60 ) ); - break; case WARRIOR: icon.frame( icon.texture.uvRect( 0, 29, 16, 45 ) ); break; @@ -148,11 +150,8 @@ public enum Icons { case EXIT: icon.frame( icon.texture.uvRect( 108, 0, 124, 16 ) ); break; - case NOTES: - icon.frame( icon.texture.uvRect( 79, 40, 94, 56 ) ); - break; case LANGS: - icon.frame( icon.texture.uvRect( 95, 42, 107, 51 ) ); + icon.frame( icon.texture.uvRect( 109, 16, 121, 25 ) ); break; case CHALLENGE_OFF: icon.frame( icon.texture.uvRect( 78, 12, 92, 24 ) ); @@ -163,6 +162,24 @@ public enum Icons { case RESUME: icon.frame( icon.texture.uvRect( 13, 53, 24, 64 ) ); break; + case ENTER: + icon.frame( icon.texture.uvRect( 66, 26, 83, 43 ) ); + break; + case GOLD: + icon.frame( icon.texture.uvRect( 83, 26, 100, 42 ) ); + break; + case RANKINGS: + icon.frame( icon.texture.uvRect( 100, 26, 117, 43 ) ); + break; + case BADGES: + icon.frame( icon.texture.uvRect( 66, 46, 83, 63 ) ); + break; + case CHANGES: + icon.frame( icon.texture.uvRect( 83, 47, 100, 62 ) ); + break; + case SHPX: + icon.frame( icon.texture.uvRect( 100, 46, 116, 62 ) ); + break; } return icon; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/OptionSlider.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/OptionSlider.java index 43bbb9008..ddbca0389 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/OptionSlider.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/OptionSlider.java @@ -91,7 +91,7 @@ public abstract class OptionSlider extends Component { protected void createChildren() { super.createChildren(); - add( BG = Chrome.get(Chrome.Type.BUTTON)); + add( BG = Chrome.get(Chrome.Type.RED_BUTTON)); BG.alpha(0.5f); add(title = PixelScene.renderText(9)); @@ -99,7 +99,7 @@ public abstract class OptionSlider extends Component { add(this.maxTxt = PixelScene.renderText(6)); add(sliderBG = new ColorBlock(1, 1, 0xFF222222)); - sliderNode = Chrome.get(Chrome.Type.BUTTON); + sliderNode = Chrome.get(Chrome.Type.RED_BUTTON); sliderNode.size(5, 9); touchArea = new TouchArea(0, 0, 0, 0){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/RedButton.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/RedButton.java index e4446a05c..1b96edff8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/RedButton.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/RedButton.java @@ -21,131 +21,16 @@ package com.shatteredpixel.shatteredpixeldungeon.ui; -import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Chrome; -import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; -import com.watabou.noosa.Image; -import com.watabou.noosa.NinePatch; -import com.watabou.noosa.RenderedText; -import com.watabou.noosa.audio.Sample; -import com.watabou.noosa.ui.Button; -public class RedButton extends Button { - - protected NinePatch bg; - protected RenderedText text; - protected Image icon; +public class RedButton extends StyledButton { public RedButton( String label ) { this(label, 9); } public RedButton( String label, int size ){ - super(); - - text = PixelScene.renderText( size ); - text.text( label ); - add( text ); + super( Chrome.Type.RED_BUTTON, label, size); } - @Override - protected void createChildren() { - super.createChildren(); - - bg = Chrome.get( Chrome.Type.BUTTON ); - add( bg ); - } - - @Override - protected void layout() { - - super.layout(); - - bg.x = x; - bg.y = y; - bg.size( width, height ); - - float componentWidth = 0; - - if (icon != null) componentWidth += icon.width() + 2; - - if (text != null && !text.text().equals("")){ - componentWidth += text.width() + 2; - - text.x = x + (width() + componentWidth)/2f - text.width() - 1; - text.y = y + (height() - text.baseLine()) / 2f; - PixelScene.align(text); - - } - - if (icon != null) { - - icon.x = x + (width() - componentWidth)/2f + 1; - icon.y = y + (height() - icon.height()) / 2f; - PixelScene.align(icon); - } - - } - - @Override - protected void onTouchDown() { - bg.brightness( 1.2f ); - Sample.INSTANCE.play( Assets.SND_CLICK ); - } - - @Override - protected void onTouchUp() { - bg.resetColor(); - } - - public void enable( boolean value ) { - active = value; - text.alpha( value ? 1.0f : 0.3f ); - } - - public void text( String value ) { - text.text( value ); - layout(); - } - - public void textColor( int value ) { - text.hardlight( value ); - } - - public void icon( Image icon ) { - if (this.icon != null) { - remove( this.icon ); - } - this.icon = icon; - if (this.icon != null) { - add( this.icon ); - layout(); - } - } - - public Image icon(){ - return icon; - } - - public float reqWidth() { - float reqWidth = 0; - if (icon != null){ - reqWidth += icon.width() + 2; - } - if (text != null && !text.text().equals("")){ - reqWidth += text.width() + 2; - } - return reqWidth; - } - - public float reqHeight() { - float reqHeight = 0; - if (icon != null){ - reqHeight = Math.max(icon.height() + 4, reqHeight); - } - if (text != null && !text.text().equals("")){ - reqHeight = Math.max(text.baseLine() + 4, reqHeight); - } - return reqHeight; - } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StyledButton.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StyledButton.java new file mode 100644 index 000000000..c2b3b0e6b --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/StyledButton.java @@ -0,0 +1,147 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2019 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.ui; + +import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.Chrome; +import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; +import com.watabou.noosa.Image; +import com.watabou.noosa.NinePatch; +import com.watabou.noosa.RenderedText; +import com.watabou.noosa.audio.Sample; +import com.watabou.noosa.ui.Button; + +//simple button which support a background chrome, text, and an icon. +public class StyledButton extends Button { + + protected NinePatch bg; + protected RenderedText text; + protected Image icon; + + public StyledButton(Chrome.Type type, String label ) { + this(type, label, 9); + } + + public StyledButton(Chrome.Type type, String label, int size ){ + super(); + + bg = Chrome.get( type ); + add( bg ); + + text = PixelScene.renderText( size ); + text.text( label ); + add( text ); + } + + @Override + protected void layout() { + + super.layout(); + + bg.x = x; + bg.y = y; + bg.size( width, height ); + + float componentWidth = 0; + + if (icon != null) componentWidth += icon.width() + 2; + + if (text != null && !text.text().equals("")){ + componentWidth += text.width() + 2; + + text.x = x + (width() + componentWidth)/2f - text.width() - 1; + text.y = y + (height() - text.baseLine()) / 2f; + PixelScene.align(text); + + } + + if (icon != null) { + + icon.x = x + (width() - componentWidth)/2f + 1; + icon.y = y + (height() - icon.height()) / 2f; + PixelScene.align(icon); + } + + } + + @Override + protected void onTouchDown() { + bg.brightness( 1.2f ); + Sample.INSTANCE.play( Assets.SND_CLICK ); + } + + @Override + protected void onTouchUp() { + bg.resetColor(); + } + + public void enable( boolean value ) { + active = value; + text.alpha( value ? 1.0f : 0.3f ); + } + + public void text( String value ) { + text.text( value ); + layout(); + } + + public void textColor( int value ) { + text.hardlight( value ); + } + + public void icon( Image icon ) { + if (this.icon != null) { + remove( this.icon ); + } + this.icon = icon; + if (this.icon != null) { + add( this.icon ); + layout(); + } + } + + public Image icon(){ + return icon; + } + + public float reqWidth() { + float reqWidth = 0; + if (icon != null){ + reqWidth += icon.width() + 2; + } + if (text != null && !text.text().equals("")){ + reqWidth += text.width() + 2; + } + return reqWidth; + } + + public float reqHeight() { + float reqHeight = 0; + if (icon != null){ + reqHeight = Math.max(icon.height() + 4, reqHeight); + } + if (text != null && !text.text().equals("")){ + reqHeight = Math.max(text.baseLine() + 4, reqHeight); + } + return reqHeight; + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBlacksmith.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBlacksmith.java index af3d20070..2535c38d7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBlacksmith.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndBlacksmith.java @@ -130,7 +130,7 @@ public class WndBlacksmith extends Window { protected void createChildren() { super.createChildren(); - bg = Chrome.get( Chrome.Type.BUTTON ); + bg = Chrome.get( Chrome.Type.RED_BUTTON); add( bg ); slot = new ItemSlot() {