v1.3.0: moved clutter from hero select options into a sub menu
This commit is contained in:
@@ -47,6 +47,9 @@ scenes.gamescene.trample=Trample
|
||||
scenes.gamescene.examine=Examine
|
||||
|
||||
scenes.heroselectscene.title=Choose Your Hero
|
||||
scenes.heroselectscene.options=Game Options
|
||||
scenes.heroselectscene.custom_seed=Custom Seed
|
||||
scenes.heroselectscene.daily=Daily Run
|
||||
scenes.heroselectscene.custom_seed_title=Enter a Custom Seed
|
||||
scenes.heroselectscene.custom_seed_desc=The same seed and game version always generate the same dungeon! Seeds are nine uppercase letters (e.g. ABC-DEF-GHI), but you can enter anything you want and the game will convert it. _Games with a custom seed cannot earn badges or appear in rankings._
|
||||
scenes.heroselectscene.custom_seed_duplicate=You already have a regular game in progress with that seed. You must end that game before using that custom seed.
|
||||
|
||||
@@ -39,7 +39,8 @@ public class Chrome {
|
||||
SCROLL,
|
||||
TAB_SET,
|
||||
TAB_SELECTED,
|
||||
TAB_UNSELECTED
|
||||
TAB_UNSELECTED,
|
||||
BLANK
|
||||
}
|
||||
|
||||
public static NinePatch get( Type type ) {
|
||||
@@ -72,6 +73,8 @@ public class Chrome {
|
||||
return new NinePatch( Asset, 65, 22, 8, 13, 3, 7, 3, 5 );
|
||||
case TAB_UNSELECTED:
|
||||
return new NinePatch( Asset, 75, 22, 8, 13, 3, 7, 3, 5 );
|
||||
case BLANK:
|
||||
return new NinePatch( Asset, 45, 0, 1, 1, 0, 0, 0, 0 );
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -47,9 +47,12 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage;
|
||||
import com.watabou.gltextures.TextureCache;
|
||||
import com.watabou.input.PointerEvent;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.PointerArea;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.watabou.utils.DeviceCompat;
|
||||
import com.watabou.utils.GameMath;
|
||||
|
||||
@@ -64,8 +67,8 @@ public class HeroSelectScene extends PixelScene {
|
||||
private ArrayList<StyledButton> heroBtns = new ArrayList<>();
|
||||
private StyledButton startBtn;
|
||||
private IconButton infoButton;
|
||||
private IconButton seedButton;
|
||||
private IconButton challengeButton;
|
||||
private IconButton btnOptions;
|
||||
private GameOptions optionsPane;
|
||||
private IconButton btnExit;
|
||||
|
||||
@Override
|
||||
@@ -168,100 +171,41 @@ public class HeroSelectScene extends PixelScene {
|
||||
heroBtns.add(button);
|
||||
}
|
||||
|
||||
challengeButton = new IconButton(
|
||||
Icons.get( SPDSettings.challenges() > 0 ? Icons.CHALLENGE_ON :Icons.CHALLENGE_OFF)){
|
||||
optionsPane = new GameOptions();
|
||||
optionsPane.visible = optionsPane.active = false;
|
||||
optionsPane.layout();
|
||||
optionsPane.setPos(heroBtnleft, 0);
|
||||
add(optionsPane);
|
||||
|
||||
btnOptions = new IconButton(Icons.get(Icons.PREFS)){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
ShatteredPixelDungeon.scene().addToFront(new WndChallenges(SPDSettings.challenges(), true) {
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
icon(Icons.get(SPDSettings.challenges() > 0 ? Icons.CHALLENGE_ON : Icons.CHALLENGE_OFF));
|
||||
}
|
||||
} );
|
||||
super.onClick();
|
||||
optionsPane.visible = !optionsPane.visible;
|
||||
optionsPane.active = !optionsPane.active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if( !visible && GamesInProgress.selectedClass != null){
|
||||
visible = true;
|
||||
}
|
||||
super.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.titleCase(Messages.get(WndChallenges.class, "title"));
|
||||
}
|
||||
};
|
||||
challengeButton.setRect(heroBtnleft + 16, Camera.main.height-HeroBtn.HEIGHT-16, 20, 21);
|
||||
challengeButton.visible = false;
|
||||
|
||||
seedButton = new IconButton( Icons.get(Icons.SEED)){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
String existingSeedtext = SPDSettings.customSeed();
|
||||
ShatteredPixelDungeon.scene().addToFront( new WndTextInput(Messages.get(HeroSelectScene.class, "custom_seed_title"),
|
||||
Messages.get(HeroSelectScene.class, "custom_seed_desc"),
|
||||
existingSeedtext,
|
||||
20,
|
||||
false,
|
||||
Messages.get(HeroSelectScene.class, "custom_seed_set"),
|
||||
Messages.get(HeroSelectScene.class, "custom_seed_clear")){
|
||||
@Override
|
||||
public void onSelect(boolean positive, String text) {
|
||||
text = DungeonSeed.formatText(text);
|
||||
long seed = DungeonSeed.convertFromText(text);
|
||||
|
||||
if (positive && seed != -1){
|
||||
|
||||
for (GamesInProgress.Info info : GamesInProgress.checkAll()){
|
||||
if (info.customSeed.isEmpty() && info.seed == seed){
|
||||
SPDSettings.customSeed("");
|
||||
icon.resetColor();
|
||||
ShatteredPixelDungeon.scene().addToFront(new WndMessage(Messages.get(HeroSelectScene.class, "custom_seed_duplicate")));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SPDSettings.customSeed(text);
|
||||
icon.hardlight(1f, 1.5f, 0.67f);
|
||||
} else {
|
||||
SPDSettings.customSeed("");
|
||||
icon.resetColor();
|
||||
}
|
||||
}
|
||||
});
|
||||
protected void onPointerDown() {
|
||||
super.onPointerDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPointerUp() {
|
||||
if (!SPDSettings.customSeed().isEmpty()){
|
||||
icon.hardlight(1f, 1.5f, 0.67f);
|
||||
} else {
|
||||
icon.resetColor();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if( !visible && GamesInProgress.selectedClass != null){
|
||||
visible = true;
|
||||
}
|
||||
super.update();
|
||||
updateOptionsColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String hoverText() {
|
||||
return Messages.get(HeroSelectScene.class, "custom_seed_title");
|
||||
return Messages.get(HeroSelectScene.class, "options");
|
||||
}
|
||||
};
|
||||
if (!SPDSettings.customSeed().isEmpty()) seedButton.icon().hardlight(1f, 1.5f, 0.67f);
|
||||
seedButton.setRect(challengeButton.left()-16, challengeButton.top(), 16, 21);
|
||||
seedButton.visible = false;
|
||||
btnOptions.setRect(heroBtnleft + 16, Camera.main.height-HeroBtn.HEIGHT-16, 20, 21);
|
||||
updateOptionsColor();
|
||||
btnOptions.visible = false;
|
||||
|
||||
if (DeviceCompat.isDebug() || Badges.isUnlocked(Badges.Badge.VICTORY)){
|
||||
add(seedButton);
|
||||
add(challengeButton);
|
||||
add(btnOptions);
|
||||
} else {
|
||||
Dungeon.challenges = 0;
|
||||
SPDSettings.challenges(0);
|
||||
@@ -297,6 +241,14 @@ public class HeroSelectScene extends PixelScene {
|
||||
|
||||
}
|
||||
|
||||
private void updateOptionsColor(){
|
||||
if (!SPDSettings.customSeed().isEmpty() || SPDSettings.challenges() != 0) {
|
||||
btnOptions.icon().hardlight(1f, 1.5f, 0.67f);
|
||||
} else {
|
||||
btnOptions.icon().resetColor();
|
||||
}
|
||||
}
|
||||
|
||||
private void setSelectedHero(HeroClass cl){
|
||||
GamesInProgress.selectedClass = cl;
|
||||
|
||||
@@ -315,11 +267,11 @@ public class HeroSelectScene extends PixelScene {
|
||||
infoButton.visible = true;
|
||||
infoButton.setPos(startBtn.right(), startBtn.top());
|
||||
|
||||
challengeButton.visible = true;
|
||||
challengeButton.setPos(startBtn.left()-challengeButton.width(), startBtn.top());
|
||||
btnOptions.visible = true;
|
||||
btnOptions.setPos(startBtn.left()-btnOptions.width(), startBtn.top());
|
||||
|
||||
seedButton.visible = true;
|
||||
seedButton.setPos(challengeButton.left()-seedButton.width(), challengeButton.top());
|
||||
optionsPane.setPos(optionsPane.left(), startBtn.top() - optionsPane.height() - 2);
|
||||
PixelScene.align(optionsPane);
|
||||
}
|
||||
|
||||
private float uiAlpha;
|
||||
@@ -342,8 +294,8 @@ public class HeroSelectScene extends PixelScene {
|
||||
}
|
||||
startBtn.alpha(alpha);
|
||||
btnExit.icon().alpha(alpha);
|
||||
challengeButton.icon().alpha(alpha);
|
||||
seedButton.icon().alpha(alpha);
|
||||
optionsPane.alpha(alpha);
|
||||
btnOptions.icon().alpha(alpha);
|
||||
infoButton.icon().alpha(alpha);
|
||||
}
|
||||
}
|
||||
@@ -406,4 +358,141 @@ public class HeroSelectScene extends PixelScene {
|
||||
}
|
||||
}
|
||||
|
||||
private class GameOptions extends Component {
|
||||
|
||||
private NinePatch bg;
|
||||
|
||||
private ArrayList<StyledButton> buttons;
|
||||
private ArrayList<ColorBlock> spacers;
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
|
||||
bg = Chrome.get(Chrome.Type.GREY_BUTTON_TR);
|
||||
add(bg);
|
||||
|
||||
buttons = new ArrayList<>();
|
||||
spacers = new ArrayList<>();
|
||||
if (DeviceCompat.isDebug() || Badges.isUnlocked(Badges.Badge.VICTORY)){
|
||||
StyledButton seedButton = new StyledButton(Chrome.Type.BLANK, Messages.get(HeroSelectScene.class, "custom_seed"), 6){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
String existingSeedtext = SPDSettings.customSeed();
|
||||
ShatteredPixelDungeon.scene().addToFront( new WndTextInput(Messages.get(HeroSelectScene.class, "custom_seed_title"),
|
||||
Messages.get(HeroSelectScene.class, "custom_seed_desc"),
|
||||
existingSeedtext,
|
||||
20,
|
||||
false,
|
||||
Messages.get(HeroSelectScene.class, "custom_seed_set"),
|
||||
Messages.get(HeroSelectScene.class, "custom_seed_clear")){
|
||||
@Override
|
||||
public void onSelect(boolean positive, String text) {
|
||||
text = DungeonSeed.formatText(text);
|
||||
long seed = DungeonSeed.convertFromText(text);
|
||||
|
||||
if (positive && seed != -1){
|
||||
|
||||
for (GamesInProgress.Info info : GamesInProgress.checkAll()){
|
||||
if (info.customSeed.isEmpty() && info.seed == seed){
|
||||
SPDSettings.customSeed("");
|
||||
icon.resetColor();
|
||||
ShatteredPixelDungeon.scene().addToFront(new WndMessage(Messages.get(HeroSelectScene.class, "custom_seed_duplicate")));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
SPDSettings.customSeed(text);
|
||||
icon.hardlight(1f, 1.5f, 0.67f);
|
||||
} else {
|
||||
SPDSettings.customSeed("");
|
||||
icon.resetColor();
|
||||
}
|
||||
updateOptionsColor();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
seedButton.leftJustify = true;
|
||||
seedButton.icon(Icons.get(Icons.SEED));
|
||||
if (!SPDSettings.customSeed().isEmpty()) seedButton.icon().hardlight(1f, 1.5f, 0.67f);;
|
||||
buttons.add(seedButton);
|
||||
add(seedButton);
|
||||
|
||||
//TODO does nothing atm
|
||||
StyledButton dailyButton = new StyledButton(Chrome.Type.BLANK, Messages.get(HeroSelectScene.class, "daily"), 6);
|
||||
dailyButton.leftJustify = true;
|
||||
dailyButton.icon(Icons.get(Icons.CALENDAR));
|
||||
add(dailyButton);
|
||||
buttons.add(dailyButton);
|
||||
|
||||
StyledButton challengeButton = new StyledButton(Chrome.Type.BLANK, Messages.get(WndChallenges.class, "title"), 6){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
ShatteredPixelDungeon.scene().addToFront(new WndChallenges(SPDSettings.challenges(), true) {
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
icon(Icons.get(SPDSettings.challenges() > 0 ? Icons.CHALLENGE_ON : Icons.CHALLENGE_OFF));
|
||||
updateOptionsColor();
|
||||
}
|
||||
} );
|
||||
}
|
||||
};
|
||||
challengeButton.leftJustify = true;
|
||||
challengeButton.icon(Icons.get(SPDSettings.challenges() > 0 ? Icons.CHALLENGE_ON : Icons.CHALLENGE_OFF));
|
||||
add(challengeButton);
|
||||
buttons.add(challengeButton);
|
||||
}
|
||||
|
||||
for (int i = 1; i < buttons.size(); i++){
|
||||
ColorBlock spc = new ColorBlock(1, 1, 0xFF000000);
|
||||
add(spc);
|
||||
spacers.add(spc);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
super.layout();
|
||||
|
||||
bg.x = x;
|
||||
bg.y = y;
|
||||
|
||||
int width = 0;
|
||||
for (StyledButton btn : buttons){
|
||||
if (width < btn.reqWidth()) width = (int)btn.reqWidth();
|
||||
}
|
||||
width += bg.marginHor();
|
||||
|
||||
int top = (int)y + bg.marginTop() - 1;
|
||||
int i = 0;
|
||||
for (StyledButton btn : buttons){
|
||||
btn.setRect(x+bg.marginLeft(), top, width - bg.marginHor(), 16);
|
||||
top = (int)btn.bottom();
|
||||
if (i < spacers.size()) {
|
||||
spacers.get(i).size(btn.width(), 1);
|
||||
spacers.get(i).x = btn.left();
|
||||
spacers.get(i).y = PixelScene.align(btn.bottom()-0.5f);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
this.width = width;
|
||||
this.height = top+bg.marginBottom()-y-1;
|
||||
bg.size(this.width, this.height);
|
||||
|
||||
}
|
||||
|
||||
private void alpha( float value ){
|
||||
bg.alpha(value);
|
||||
|
||||
for (StyledButton btn : buttons){
|
||||
btn.alpha(value);
|
||||
}
|
||||
|
||||
for (ColorBlock spc : spacers){
|
||||
spc.alpha(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user