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.gamescene.examine=Examine
|
||||||
|
|
||||||
scenes.heroselectscene.title=Choose Your Hero
|
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_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_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.
|
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,
|
SCROLL,
|
||||||
TAB_SET,
|
TAB_SET,
|
||||||
TAB_SELECTED,
|
TAB_SELECTED,
|
||||||
TAB_UNSELECTED
|
TAB_UNSELECTED,
|
||||||
|
BLANK
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NinePatch get( Type type ) {
|
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 );
|
return new NinePatch( Asset, 65, 22, 8, 13, 3, 7, 3, 5 );
|
||||||
case TAB_UNSELECTED:
|
case TAB_UNSELECTED:
|
||||||
return new NinePatch( Asset, 75, 22, 8, 13, 3, 7, 3, 5 );
|
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:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,9 +47,12 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage;
|
|||||||
import com.watabou.gltextures.TextureCache;
|
import com.watabou.gltextures.TextureCache;
|
||||||
import com.watabou.input.PointerEvent;
|
import com.watabou.input.PointerEvent;
|
||||||
import com.watabou.noosa.Camera;
|
import com.watabou.noosa.Camera;
|
||||||
|
import com.watabou.noosa.ColorBlock;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
import com.watabou.noosa.Image;
|
import com.watabou.noosa.Image;
|
||||||
|
import com.watabou.noosa.NinePatch;
|
||||||
import com.watabou.noosa.PointerArea;
|
import com.watabou.noosa.PointerArea;
|
||||||
|
import com.watabou.noosa.ui.Component;
|
||||||
import com.watabou.utils.DeviceCompat;
|
import com.watabou.utils.DeviceCompat;
|
||||||
import com.watabou.utils.GameMath;
|
import com.watabou.utils.GameMath;
|
||||||
|
|
||||||
@@ -64,8 +67,8 @@ public class HeroSelectScene extends PixelScene {
|
|||||||
private ArrayList<StyledButton> heroBtns = new ArrayList<>();
|
private ArrayList<StyledButton> heroBtns = new ArrayList<>();
|
||||||
private StyledButton startBtn;
|
private StyledButton startBtn;
|
||||||
private IconButton infoButton;
|
private IconButton infoButton;
|
||||||
private IconButton seedButton;
|
private IconButton btnOptions;
|
||||||
private IconButton challengeButton;
|
private GameOptions optionsPane;
|
||||||
private IconButton btnExit;
|
private IconButton btnExit;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -168,100 +171,41 @@ public class HeroSelectScene extends PixelScene {
|
|||||||
heroBtns.add(button);
|
heroBtns.add(button);
|
||||||
}
|
}
|
||||||
|
|
||||||
challengeButton = new IconButton(
|
optionsPane = new GameOptions();
|
||||||
Icons.get( SPDSettings.challenges() > 0 ? Icons.CHALLENGE_ON :Icons.CHALLENGE_OFF)){
|
optionsPane.visible = optionsPane.active = false;
|
||||||
|
optionsPane.layout();
|
||||||
|
optionsPane.setPos(heroBtnleft, 0);
|
||||||
|
add(optionsPane);
|
||||||
|
|
||||||
|
btnOptions = new IconButton(Icons.get(Icons.PREFS)){
|
||||||
@Override
|
@Override
|
||||||
protected void onClick() {
|
protected void onClick() {
|
||||||
ShatteredPixelDungeon.scene().addToFront(new WndChallenges(SPDSettings.challenges(), true) {
|
super.onClick();
|
||||||
public void onBackPressed() {
|
optionsPane.visible = !optionsPane.visible;
|
||||||
super.onBackPressed();
|
optionsPane.active = !optionsPane.active;
|
||||||
icon(Icons.get(SPDSettings.challenges() > 0 ? Icons.CHALLENGE_ON : Icons.CHALLENGE_OFF));
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
protected void onPointerDown() {
|
||||||
if( !visible && GamesInProgress.selectedClass != null){
|
super.onPointerDown();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPointerUp() {
|
protected void onPointerUp() {
|
||||||
if (!SPDSettings.customSeed().isEmpty()){
|
updateOptionsColor();
|
||||||
icon.hardlight(1f, 1.5f, 0.67f);
|
|
||||||
} else {
|
|
||||||
icon.resetColor();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update() {
|
|
||||||
if( !visible && GamesInProgress.selectedClass != null){
|
|
||||||
visible = true;
|
|
||||||
}
|
|
||||||
super.update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String hoverText() {
|
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);
|
btnOptions.setRect(heroBtnleft + 16, Camera.main.height-HeroBtn.HEIGHT-16, 20, 21);
|
||||||
seedButton.setRect(challengeButton.left()-16, challengeButton.top(), 16, 21);
|
updateOptionsColor();
|
||||||
seedButton.visible = false;
|
btnOptions.visible = false;
|
||||||
|
|
||||||
if (DeviceCompat.isDebug() || Badges.isUnlocked(Badges.Badge.VICTORY)){
|
if (DeviceCompat.isDebug() || Badges.isUnlocked(Badges.Badge.VICTORY)){
|
||||||
add(seedButton);
|
add(btnOptions);
|
||||||
add(challengeButton);
|
|
||||||
} else {
|
} else {
|
||||||
Dungeon.challenges = 0;
|
Dungeon.challenges = 0;
|
||||||
SPDSettings.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){
|
private void setSelectedHero(HeroClass cl){
|
||||||
GamesInProgress.selectedClass = cl;
|
GamesInProgress.selectedClass = cl;
|
||||||
|
|
||||||
@@ -315,11 +267,11 @@ public class HeroSelectScene extends PixelScene {
|
|||||||
infoButton.visible = true;
|
infoButton.visible = true;
|
||||||
infoButton.setPos(startBtn.right(), startBtn.top());
|
infoButton.setPos(startBtn.right(), startBtn.top());
|
||||||
|
|
||||||
challengeButton.visible = true;
|
btnOptions.visible = true;
|
||||||
challengeButton.setPos(startBtn.left()-challengeButton.width(), startBtn.top());
|
btnOptions.setPos(startBtn.left()-btnOptions.width(), startBtn.top());
|
||||||
|
|
||||||
seedButton.visible = true;
|
optionsPane.setPos(optionsPane.left(), startBtn.top() - optionsPane.height() - 2);
|
||||||
seedButton.setPos(challengeButton.left()-seedButton.width(), challengeButton.top());
|
PixelScene.align(optionsPane);
|
||||||
}
|
}
|
||||||
|
|
||||||
private float uiAlpha;
|
private float uiAlpha;
|
||||||
@@ -342,8 +294,8 @@ public class HeroSelectScene extends PixelScene {
|
|||||||
}
|
}
|
||||||
startBtn.alpha(alpha);
|
startBtn.alpha(alpha);
|
||||||
btnExit.icon().alpha(alpha);
|
btnExit.icon().alpha(alpha);
|
||||||
challengeButton.icon().alpha(alpha);
|
optionsPane.alpha(alpha);
|
||||||
seedButton.icon().alpha(alpha);
|
btnOptions.icon().alpha(alpha);
|
||||||
infoButton.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