v1.3.0: custom seeds now show their original input text
This commit is contained in:
@@ -958,7 +958,7 @@ public class Badges {
|
||||
|
||||
private static void displayBadge( Badge badge ) {
|
||||
|
||||
if (badge == null || Dungeon.usingCustomSeed) {
|
||||
if (badge == null || !Dungeon.customSeedText.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -995,7 +995,7 @@ public class Badges {
|
||||
}
|
||||
|
||||
public static void unlock( Badge badge ){
|
||||
if (!isUnlocked(badge) && !Dungeon.usingCustomSeed){
|
||||
if (!isUnlocked(badge) && Dungeon.customSeedText.isEmpty()){
|
||||
global.add( badge );
|
||||
saveNeeded = true;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class Bones {
|
||||
depth = Dungeon.depth;
|
||||
|
||||
//heroes drop no bones if they have the amulet, die far above their farthest depth, are challenged, or are playing with a custom seed.
|
||||
if (Statistics.amuletObtained || (Statistics.deepestFloor - 5) >= depth || Dungeon.challenges > 0 || Dungeon.usingCustomSeed) {
|
||||
if (Statistics.amuletObtained || (Statistics.deepestFloor - 5) >= depth || Dungeon.challenges > 0 || !Dungeon.customSeedText.isEmpty()) {
|
||||
depth = -1;
|
||||
return;
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class Bones {
|
||||
|
||||
} else {
|
||||
//heroes who are challenged or on a seeded run cannot find bones
|
||||
if (depth == Dungeon.depth && Dungeon.challenges == 0 && !Dungeon.usingCustomSeed) {
|
||||
if (depth == Dungeon.depth && Dungeon.challenges == 0 && Dungeon.customSeedText.isEmpty()) {
|
||||
Bundle emptyBones = new Bundle();
|
||||
emptyBones.put(LEVEL, 0);
|
||||
try {
|
||||
|
||||
@@ -179,6 +179,7 @@ public class Dungeon {
|
||||
public static int initialVersion;
|
||||
public static int version;
|
||||
|
||||
public static String customSeedText;
|
||||
public static long seed;
|
||||
public static boolean usingCustomSeed;
|
||||
|
||||
@@ -188,12 +189,12 @@ public class Dungeon {
|
||||
challenges = SPDSettings.challenges();
|
||||
mobsToChampion = -1;
|
||||
|
||||
if (SPDSettings.customSeed() != -1){
|
||||
seed = SPDSettings.customSeed();
|
||||
usingCustomSeed = true;
|
||||
if (SPDSettings.customSeed() != ""){
|
||||
customSeedText = SPDSettings.customSeed();
|
||||
seed = DungeonSeed.convertFromText(customSeedText);
|
||||
} else {
|
||||
customSeedText = "";
|
||||
seed = DungeonSeed.randomSeed();
|
||||
usingCustomSeed = false;
|
||||
}
|
||||
|
||||
Actor.clear();
|
||||
@@ -495,7 +496,7 @@ public class Dungeon {
|
||||
bundle.put( INIT_VER, initialVersion );
|
||||
bundle.put( VERSION, version = Game.versionCode );
|
||||
bundle.put( SEED, seed );
|
||||
bundle.put( CUSTOM_SEED, usingCustomSeed );
|
||||
bundle.put( CUSTOM_SEED, customSeedText );
|
||||
bundle.put( CHALLENGES, challenges );
|
||||
bundle.put( MOBS_TO_CHAMPION, mobsToChampion );
|
||||
bundle.put( HERO, hero );
|
||||
@@ -573,7 +574,7 @@ public class Dungeon {
|
||||
saveGame( GamesInProgress.curSlot );
|
||||
saveLevel( GamesInProgress.curSlot );
|
||||
|
||||
GamesInProgress.set( GamesInProgress.curSlot, depth, challenges, seed, usingCustomSeed, hero );
|
||||
GamesInProgress.set( GamesInProgress.curSlot, depth, challenges, seed, customSeedText, hero );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -596,7 +597,7 @@ public class Dungeon {
|
||||
version = bundle.getInt( VERSION );
|
||||
|
||||
seed = bundle.contains( SEED ) ? bundle.getLong( SEED ) : DungeonSeed.randomSeed();
|
||||
usingCustomSeed = bundle.getBoolean( CUSTOM_SEED );
|
||||
customSeedText = bundle.getString( CUSTOM_SEED );
|
||||
|
||||
Actor.clear();
|
||||
Actor.restoreNextID( bundle );
|
||||
@@ -729,7 +730,7 @@ public class Dungeon {
|
||||
info.version = bundle.getInt( VERSION );
|
||||
info.challenges = bundle.getInt( CHALLENGES );
|
||||
info.seed = bundle.getLong( SEED );
|
||||
info.customSeed = bundle.getBoolean( CUSTOM_SEED );
|
||||
info.customSeed = bundle.getString( CUSTOM_SEED );
|
||||
|
||||
Hero.preview( info, bundle.getBundle( HERO ) );
|
||||
Statistics.preview( info, bundle );
|
||||
|
||||
@@ -126,7 +126,7 @@ public class GamesInProgress {
|
||||
}
|
||||
}
|
||||
|
||||
public static void set(int slot, int depth, int challenges, long seed, boolean customSeed,
|
||||
public static void set(int slot, int depth, int challenges, long seed, String customSeed,
|
||||
Hero hero) {
|
||||
Info info = new Info();
|
||||
info.slot = slot;
|
||||
@@ -170,7 +170,7 @@ public class GamesInProgress {
|
||||
public int challenges;
|
||||
|
||||
public long seed;
|
||||
public boolean customSeed;
|
||||
public String customSeed;
|
||||
|
||||
public int level;
|
||||
public int str;
|
||||
|
||||
@@ -63,7 +63,7 @@ public enum Rankings {
|
||||
public void submit( boolean win, Class cause ) {
|
||||
|
||||
//games with custom seeds do not appear in rankings
|
||||
if (Dungeon.usingCustomSeed) return;
|
||||
if (!Dungeon.customSeedText.isEmpty()) return;
|
||||
|
||||
load();
|
||||
|
||||
|
||||
@@ -209,12 +209,12 @@ public class SPDSettings extends GameSettings {
|
||||
return getInt( KEY_CHALLENGES, 0, 0, Challenges.MAX_VALUE );
|
||||
}
|
||||
|
||||
public static void customSeed( long value ){
|
||||
public static void customSeed( String value ){
|
||||
put( KEY_CUSTOM_SEED, value );
|
||||
}
|
||||
|
||||
public static long customSeed() {
|
||||
return getLong( KEY_CUSTOM_SEED, -1, -1, DungeonSeed.TOTAL_SEEDS-1);
|
||||
public static String customSeed() {
|
||||
return getString( KEY_CUSTOM_SEED, "", 20);
|
||||
}
|
||||
|
||||
public static void supportNagged( boolean value ) {
|
||||
|
||||
@@ -199,22 +199,23 @@ public class HeroSelectScene extends PixelScene {
|
||||
seedButton = new IconButton( Icons.get(Icons.SEED)){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
String existingSeedtext = SPDSettings.customSeed() == -1 ? "" : DungeonSeed.convertToCode(SPDSettings.customSeed());
|
||||
String existingSeedtext = SPDSettings.customSeed();
|
||||
ShatteredPixelDungeon.scene().addToFront( new WndTextInput(Messages.get(HeroSelectScene.class, "custom_seed_title"),
|
||||
Messages.get(HeroSelectScene.class, "custom_seed_desc"),
|
||||
existingSeedtext,
|
||||
30,
|
||||
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){
|
||||
SPDSettings.customSeed(seed);
|
||||
SPDSettings.customSeed(text);
|
||||
icon.hardlight(1f, 1.5f, 0.67f);
|
||||
} else {
|
||||
SPDSettings.customSeed(-1);
|
||||
SPDSettings.customSeed("");
|
||||
icon.resetColor();
|
||||
}
|
||||
}
|
||||
@@ -223,7 +224,7 @@ public class HeroSelectScene extends PixelScene {
|
||||
|
||||
@Override
|
||||
protected void onPointerUp() {
|
||||
if (SPDSettings.customSeed() != -1){
|
||||
if (!SPDSettings.customSeed().isEmpty()){
|
||||
icon.hardlight(1f, 1.5f, 0.67f);
|
||||
} else {
|
||||
icon.resetColor();
|
||||
@@ -243,7 +244,7 @@ public class HeroSelectScene extends PixelScene {
|
||||
return Messages.get(HeroSelectScene.class, "custom_seed_title");
|
||||
}
|
||||
};
|
||||
if (SPDSettings.customSeed() != -1) seedButton.icon().hardlight(1f, 1.5f, 0.67f);
|
||||
if (!SPDSettings.customSeed().isEmpty()) seedButton.icon().hardlight(1f, 1.5f, 0.67f);
|
||||
seedButton.setRect(challengeButton.left()-16, challengeButton.top(), 16, 21);
|
||||
seedButton.visible = false;
|
||||
|
||||
@@ -253,7 +254,7 @@ public class HeroSelectScene extends PixelScene {
|
||||
} else {
|
||||
Dungeon.challenges = 0;
|
||||
SPDSettings.challenges(0);
|
||||
SPDSettings.customSeed(-1);
|
||||
SPDSettings.customSeed("");
|
||||
}
|
||||
|
||||
btnExit = new ExitButton();
|
||||
|
||||
@@ -203,7 +203,7 @@ public class StartScene extends PixelScene {
|
||||
level.resetColor();
|
||||
}
|
||||
|
||||
if (info.customSeed){
|
||||
if (!info.customSeed.isEmpty()){
|
||||
steps.hardlight(1f, 1.5f, 0.67f);
|
||||
}
|
||||
|
||||
|
||||
@@ -295,28 +295,28 @@ public enum Icons {
|
||||
icon.frame( icon.texture.uvRectBySize( 40, 72, 8, 8 ) );
|
||||
break;
|
||||
case DEPTH:
|
||||
icon.frame( icon.texture.uvRectBySize( 48, 64 + (Dungeon.usingCustomSeed ? 8 : 0), 6, 7 ) );
|
||||
icon.frame( icon.texture.uvRectBySize( 48, 64 + (Dungeon.customSeedText.isEmpty() ? 0 : 8), 6, 7 ) );
|
||||
break;
|
||||
case DEPTH_CHASM:
|
||||
icon.frame( icon.texture.uvRectBySize( 56, 64 + (Dungeon.usingCustomSeed ? 8 : 0), 7, 7 ) );
|
||||
icon.frame( icon.texture.uvRectBySize( 56, 64 + (Dungeon.customSeedText.isEmpty() ? 0 : 8), 7, 7 ) );
|
||||
break;
|
||||
case DEPTH_WATER:
|
||||
icon.frame( icon.texture.uvRectBySize( 64, 64 + (Dungeon.usingCustomSeed ? 8 : 0), 7, 7 ) );
|
||||
icon.frame( icon.texture.uvRectBySize( 64, 64 + (Dungeon.customSeedText.isEmpty() ? 0 : 8), 7, 7 ) );
|
||||
break;
|
||||
case DEPTH_GRASS:
|
||||
icon.frame( icon.texture.uvRectBySize( 72, 64 + (Dungeon.usingCustomSeed ? 8 : 0), 7, 7 ) );
|
||||
icon.frame( icon.texture.uvRectBySize( 72, 64 + (Dungeon.customSeedText.isEmpty() ? 0 : 8), 7, 7 ) );
|
||||
break;
|
||||
case DEPTH_DARK:
|
||||
icon.frame( icon.texture.uvRectBySize( 80, 64 + (Dungeon.usingCustomSeed ? 8 : 0), 7, 7 ) );
|
||||
icon.frame( icon.texture.uvRectBySize( 80, 64 + (Dungeon.customSeedText.isEmpty() ? 0 : 8), 7, 7 ) );
|
||||
break;
|
||||
case DEPTH_LARGE:
|
||||
icon.frame( icon.texture.uvRectBySize( 88, 64 + (Dungeon.usingCustomSeed ? 8 : 0), 7, 7 ) );
|
||||
icon.frame( icon.texture.uvRectBySize( 88, 64 + (Dungeon.customSeedText.isEmpty() ? 0 : 8), 7, 7 ) );
|
||||
break;
|
||||
case DEPTH_TRAPS:
|
||||
icon.frame( icon.texture.uvRectBySize( 96, 64 + (Dungeon.usingCustomSeed ? 8 : 0), 7, 7 ) );
|
||||
icon.frame( icon.texture.uvRectBySize( 96, 64 + (Dungeon.customSeedText.isEmpty() ? 0 : 8), 7, 7 ) );
|
||||
break;
|
||||
case DEPTH_SECRETS:
|
||||
icon.frame( icon.texture.uvRectBySize( 104, 64 + (Dungeon.usingCustomSeed ? 8 : 0), 7, 7 ) );
|
||||
icon.frame( icon.texture.uvRectBySize( 104, 64 + (Dungeon.customSeedText.isEmpty() ? 0 : 8), 7, 7 ) );
|
||||
break;
|
||||
case CHAL_COUNT:
|
||||
icon.frame( icon.texture.uvRectBySize( 112, 64, 7, 7 ) );
|
||||
|
||||
@@ -23,6 +23,8 @@ package com.shatteredpixel.shatteredpixeldungeon.utils;
|
||||
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
//This class defines the parameters for seeds in ShatteredPD and contains a few convenience methods
|
||||
public class DungeonSeed {
|
||||
|
||||
@@ -122,4 +124,15 @@ public class DungeonSeed {
|
||||
return total;
|
||||
}
|
||||
|
||||
|
||||
public static String formatText( String inputText ){
|
||||
try {
|
||||
//if the seed matches a code, then just convert it to using the code system
|
||||
return convertToCode(convertFromCode(inputText));
|
||||
} catch (IllegalArgumentException e){
|
||||
//otherwise just return the input text
|
||||
return inputText;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ public class WndGameInProgress extends Window {
|
||||
pos += GAP;
|
||||
statSlot( Messages.get(this, "gold"), info.goldCollected );
|
||||
statSlot( Messages.get(this, "depth"), info.maxDepth );
|
||||
if (info.customSeed){
|
||||
statSlot( Messages.get(this, "custom_seed"), "_" + DungeonSeed.convertToCode(info.seed) + "_" );
|
||||
if (!info.customSeed.isEmpty()){
|
||||
statSlot( Messages.get(this, "custom_seed"), "_" + info.customSeed + "_" );
|
||||
} else {
|
||||
statSlot( Messages.get(this, "dungeon_seed"), DungeonSeed.convertToCode(info.seed) );
|
||||
}
|
||||
@@ -162,9 +162,12 @@ public class WndGameInProgress extends Window {
|
||||
RenderedTextBlock txt = PixelScene.renderTextBlock( label, 8 );
|
||||
txt.setPos(0, pos);
|
||||
add( txt );
|
||||
|
||||
txt = PixelScene.renderTextBlock( value, 8 );
|
||||
txt.setPos(WIDTH * 0.55f, pos);
|
||||
|
||||
int size = 8;
|
||||
if (value.length() >= 14) size -=2;
|
||||
if (value.length() >= 18) size -=1;
|
||||
txt = PixelScene.renderTextBlock( value, size );
|
||||
txt.setPos(WIDTH * 0.55f, pos + (6 - txt.height())/2);
|
||||
PixelScene.align(txt);
|
||||
add( txt );
|
||||
|
||||
|
||||
@@ -185,8 +185,8 @@ public class WndHero extends WndTabbed {
|
||||
|
||||
statSlot( Messages.get(this, "gold"), Statistics.goldCollected );
|
||||
statSlot( Messages.get(this, "depth"), Statistics.deepestFloor );
|
||||
if (Dungeon.usingCustomSeed){
|
||||
statSlot( Messages.get(this, "custom_seed"), "_" + DungeonSeed.convertToCode(Dungeon.seed) + "_" );
|
||||
if (!Dungeon.customSeedText.isEmpty()){
|
||||
statSlot( Messages.get(this, "custom_seed"), "_" + Dungeon.customSeedText + "_" );
|
||||
} else {
|
||||
statSlot( Messages.get(this, "dungeon_seed"), DungeonSeed.convertToCode(Dungeon.seed) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user