v0.3.4 externalized most scene strings

This commit is contained in:
Evan Debenham
2015-12-31 02:23:01 -05:00
committed by Evan Debenham
parent c16ae2ac0b
commit d8b74a3a0e
10 changed files with 145 additions and 168 deletions
@@ -20,6 +20,7 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.BitmapTextMultiline;
import com.watabou.noosa.Camera;
import com.watabou.noosa.Game;
@@ -33,21 +34,12 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
import com.watabou.utils.Random;
public class AmuletScene extends PixelScene {
private static final String TXT_EXIT = "Let's call it a day";
private static final String TXT_STAY = "I'm not done yet";
private static final int WIDTH = 120;
private static final int BTN_HEIGHT = 18;
private static final float SMALL_GAP = 2;
private static final float LARGE_GAP = 8;
private static final String TXT =
"You finally hold it in your hands, the Amulet of Yendor. Using its power " +
"you can take over the world or bring peace and prosperity to people or whatever. " +
"Anyway, your life will change forever and this game will end here. " +
"Or you can stay a mere mortal a little longer.";
public static boolean noText = false;
private Image amulet;
@@ -58,7 +50,7 @@ public class AmuletScene extends PixelScene {
BitmapTextMultiline text = null;
if (!noText) {
text = createMultiline( TXT, 8 );
text = createMultiline( Messages.get(this, "text"), 8 );
text.maxWidth = WIDTH;
text.measure();
add( text );
@@ -67,7 +59,7 @@ public class AmuletScene extends PixelScene {
amulet = new Image( Assets.AMULET );
add( amulet );
RedButton btnExit = new RedButton( TXT_EXIT ) {
RedButton btnExit = new RedButton( Messages.get(this, "exit") ) {
@Override
protected void onClick() {
Dungeon.win( ResultDescriptions.WIN );
@@ -78,7 +70,7 @@ public class AmuletScene extends PixelScene {
btnExit.setSize( WIDTH, BTN_HEIGHT );
add( btnExit );
RedButton btnStay = new RedButton( TXT_STAY ) {
RedButton btnStay = new RedButton( Messages.get(this, "stay") ) {
@Override
protected void onClick() {
onBackPressed();
@@ -21,6 +21,7 @@
package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.effects.BadgeBanner;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBadge;
import com.watabou.noosa.BitmapText;
import com.watabou.noosa.Camera;
@@ -42,8 +43,6 @@ import java.util.List;
public class BadgesScene extends PixelScene {
private static final String TXT_TITLE = "Your Badges";
@Override
public void create() {
@@ -72,7 +71,7 @@ public class BadgesScene extends PixelScene {
float left = (w - size * nCols) / 2;
float top = (h - size * nRows) / 2;
BitmapText title = PixelScene.createText( TXT_TITLE, 9 );
BitmapText title = PixelScene.createText( Messages.get(this, "title"), 9 );
title.hardlight(Window.TITLE_COLOR);
title.measure();
title.x = (w - title.width()) / 2 ;
@@ -32,6 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.bags.WandHolster;
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfTeleportation;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.CustomTileVisual;
import com.shatteredpixel.shatteredpixeldungeon.sprites.TrapSprite;
import com.shatteredpixel.shatteredpixeldungeon.ui.LootIndicator;
@@ -93,16 +94,7 @@ import com.watabou.utils.GameMath;
import com.watabou.utils.Random;
public class GameScene extends PixelScene {
private static final String TXT_WELCOME = "Welcome to the level %d of Pixel Dungeon!";
private static final String TXT_WELCOME_BACK = "Welcome back to the level %d of Pixel Dungeon!";
private static final String TXT_CHASM = "Your steps echo across the dungeon.";
private static final String TXT_WATER = "You hear water splashing around you.";
private static final String TXT_GRASS = "The smell of vegetation is thick in the air.";
private static final String TXT_DARK = "You can hear enemies moving in the darkness...";
private static final String TXT_SECRETS = "The atmosphere hints that this floor hides many secrets.";
static GameScene scene;
private SkinnedBlock water;
@@ -341,30 +333,30 @@ public class GameScene extends PixelScene {
if (InterlevelScene.mode != InterlevelScene.Mode.NONE) {
if (Dungeon.depth < Statistics.deepestFloor) {
GLog.h(TXT_WELCOME_BACK, Dungeon.depth);
GLog.h(Messages.get(this, "welcome_back"), Dungeon.depth);
} else {
GLog.h(TXT_WELCOME, Dungeon.depth);
GLog.h(Messages.get(this, "welcome"), Dungeon.depth);
Sample.INSTANCE.play(Assets.SND_DESCEND);
}
switch (Dungeon.level.feeling) {
case CHASM:
GLog.w(TXT_CHASM);
GLog.w(Messages.get(this, "chasm"));
break;
case WATER:
GLog.w(TXT_WATER);
GLog.w(Messages.get(this, "water"));
break;
case GRASS:
GLog.w(TXT_GRASS);
GLog.w(Messages.get(this, "grass"));
break;
case DARK:
GLog.w(TXT_DARK);
GLog.w(Messages.get(this, "dark"));
break;
default:
}
if (Dungeon.level instanceof RegularLevel &&
((RegularLevel) Dungeon.level).secretDoors > Random.IntRange(3, 4)) {
GLog.w(TXT_SECRETS);
GLog.w(Messages.get(this, "secrets"));
}
InterlevelScene.mode = InterlevelScene.Mode.NONE;
@@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.ui.GameLog;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndError;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory;
@@ -43,22 +44,9 @@ public class InterlevelScene extends PixelScene {
private static final float TIME_TO_FADE = 0.3f;
private static final String TXT_DESCENDING = "Descending...";
private static final String TXT_ASCENDING = "Ascending...";
private static final String TXT_LOADING = "Loading...";
private static final String TXT_RESURRECTING= "Resurrecting...";
private static final String TXT_RETURNING = "Returning...";
private static final String TXT_FALLING = "Falling...";
private static final String TXT_RESETTING = "Resetting...";
private static final String ERR_FILE_NOT_FOUND = "Save file not found. If this error persists after restarting, " +
"it may mean this save game is corrupted. Sorry about that.";
private static final String ERR_IO = "Cannot read save file. If this error persists after restarting, " +
"it may mean this save game is corrupted. Sorry about that.";
public static enum Mode {
public enum Mode {
DESCEND, ASCEND, CONTINUE, RESURRECT, RETURN, FALL, RESET, NONE
};
}
public static Mode mode;
public static int returnDepth;
@@ -70,7 +58,7 @@ public class InterlevelScene extends PixelScene {
private enum Phase {
FADE_IN, STATIC, FADE_OUT
};
}
private Phase phase;
private float timeLeft;
@@ -83,30 +71,7 @@ public class InterlevelScene extends PixelScene {
public void create() {
super.create();
String text = "";
switch (mode) {
case DESCEND:
text = TXT_DESCENDING;
break;
case ASCEND:
text = TXT_ASCENDING;
break;
case CONTINUE:
text = TXT_LOADING;
break;
case RESURRECT:
text = TXT_RESURRECTING;
break;
case RETURN:
text = TXT_RETURNING;
break;
case FALL:
text = TXT_FALLING;
break;
case RESET:
text = TXT_RESETTING;
break;
}
String text = Messages.get(Mode.class, mode.name());
message = PixelScene.createText( text, 9 );
message.measure();
@@ -202,8 +167,8 @@ public class InterlevelScene extends PixelScene {
case STATIC:
if (error != null) {
String errorMsg;
if (error instanceof FileNotFoundException) errorMsg = ERR_FILE_NOT_FOUND;
else if (error instanceof IOException) errorMsg = ERR_IO;
if (error instanceof FileNotFoundException) errorMsg = Messages.get(this, "file_not_found");
else if (error instanceof IOException) errorMsg = Messages.get(this, "io_error");
else throw new RuntimeException("fatal error occured while moving between floors", error);
@@ -211,7 +176,7 @@ public class InterlevelScene extends PixelScene {
public void onBackPressed() {
super.onBackPressed();
Game.switchScene( StartScene.class );
};
}
} );
error = null;
}
@@ -20,25 +20,17 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.Game;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory;
public class IntroScene extends PixelScene {
private static final String TEXT =
"Many heroes have ventured into the dungeon before you from the city above. Some " +
"have returned with treasures and magical artifacts, most have never been heard from again.\n\n" +
"None, however, have ventured to the bottom and retrieved the Amulet of Yendor, " +
"which is said to be guarded by an ancient evil in the depths. " +
"Even now dark energy radiates from below, making its way up into the city.\n\n" +
"You consider yourself ready for the challenge. Most importantly, " +
"you feel that fortune smiles upon you. It's time to start your own adventure!";
@Override
public void create() {
super.create();
add( new WndStory( TEXT ) {
add( new WndStory( Messages.get(this, "text") ) {
@Override
public void hide() {
super.hide();
@@ -20,6 +20,7 @@
*/
package com.shatteredpixel.shatteredpixeldungeon.scenes;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.BitmapText;
import com.watabou.noosa.BitmapTextMultiline;
import com.watabou.noosa.Camera;
@@ -42,12 +43,6 @@ import com.watabou.utils.GameMath;
public class RankingsScene extends PixelScene {
private static final String TXT_TITLE = "Top Rankings";
private static final String TXT_TOTAL = "Games Played: ";
private static final String TXT_NO_GAMES = "No games have been played yet.";
private static final String TXT_NO_INFO = "No additional information";
private static final float ROW_HEIGHT_MAX = 20;
private static final float ROW_HEIGHT_MIN = 12;
@@ -76,7 +71,7 @@ public class RankingsScene extends PixelScene {
Rankings.INSTANCE.load();
BitmapText title = PixelScene.createText(TXT_TITLE, 9);
BitmapText title = PixelScene.createText( Messages.get(this, "title"), 9);
title.hardlight(Window.SHPX_COLOR);
title.measure();
title.x = (w - title.width()) / 2;
@@ -108,7 +103,7 @@ public class RankingsScene extends PixelScene {
}
if (Rankings.INSTANCE.totalNumber >= Rankings.TABLE_SIZE) {
BitmapText label = PixelScene.createText( TXT_TOTAL, 8 );
BitmapText label = PixelScene.createText( Messages.get(this, "total") + " ", 8 );
label.hardlight( 0xCCCCCC );
label.measure();
add( label );
@@ -135,7 +130,7 @@ public class RankingsScene extends PixelScene {
} else {
BitmapText noRec = PixelScene.createText(TXT_NO_GAMES, 8);
BitmapText noRec = PixelScene.createText(Messages.get(this, "no_games"), 8);
noRec.hardlight( 0xCCCCCC );
noRec.measure();
noRec.x = (w - noRec.width()) / 2;
@@ -297,7 +292,7 @@ public class RankingsScene extends PixelScene {
if (rec.gameFile.length() > 0) {
parent.add( new WndRanking( rec.gameFile ) );
} else {
parent.add( new WndError( TXT_NO_INFO ) );
parent.add( new WndError( Messages.get(this, "no_info") ) );
}
}
}
@@ -22,6 +22,7 @@ package com.shatteredpixel.shatteredpixeldungeon.scenes;
import java.util.HashMap;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.noosa.BitmapText;
import com.watabou.noosa.BitmapTextMultiline;
import com.watabou.noosa.Camera;
@@ -57,29 +58,13 @@ public class StartScene extends PixelScene {
private static final float BUTTON_HEIGHT = 24;
private static final float GAP = 2;
private static final String TXT_LOAD = "Load Game";
private static final String TXT_NEW = "New Game";
private static final String TXT_ERASE = "Erases Progress";
private static final String TXT_DPTH_LVL = "Depth: %d, Level: %d";
private static final String TXT_REALLY = "Do you really want to start new game?";
private static final String TXT_WARNING = "Your current game progress will be erased.";
private static final String TXT_YES = "Yes, start new game";
private static final String TXT_NO = "No, return to main menu";
private static final String TXT_UNLOCK = "To unlock this character class, slay the 3rd boss with any other class";
private static final String TXT_WIN_THE_GAME =
"To unlock \"Challenges\", win the game with any character class.";
private static final float WIDTH_P = 116;
private static final float HEIGHT_P = 220;
private static final float WIDTH_L = 224;
private static final float HEIGHT_L = 124;
private static HashMap<HeroClass, ClassShield> shields = new HashMap<HeroClass, ClassShield>();
private static HashMap<HeroClass, ClassShield> shields = new HashMap<>();
private float buttonX;
private float buttonY;
@@ -129,11 +114,15 @@ public class StartScene extends PixelScene {
buttonX = left;
buttonY = bottom - BUTTON_HEIGHT;
btnNewGame = new GameButton( TXT_NEW ) {
btnNewGame = new GameButton( Messages.get(this, "new") ) {
@Override
protected void onClick() {
if (GamesInProgress.check( curClass ) != null) {
StartScene.this.add( new WndOptions( TXT_REALLY, TXT_WARNING, TXT_YES, TXT_NO ) {
StartScene.this.add( new WndOptions(
Messages.get(this, "really"),
Messages.get(this, "warning"),
Messages.get(this, "yes"),
Messages.get(this, "no") ) {
@Override
protected void onSelect( int index ) {
if (index == 0) {
@@ -149,7 +138,7 @@ public class StartScene extends PixelScene {
};
add( btnNewGame );
btnLoad = new GameButton( TXT_LOAD ) {
btnLoad = new GameButton( Messages.get(this, "load") ) {
@Override
protected void onClick() {
InterlevelScene.mode = InterlevelScene.Mode.CONTINUE;
@@ -208,7 +197,7 @@ public class StartScene extends PixelScene {
if (!(huntressUnlocked = Badges.isUnlocked( Badges.Badge.BOSS_SLAIN_3 ))) {
BitmapTextMultiline text = PixelScene.createMultiline( TXT_UNLOCK, 9 );
BitmapTextMultiline text = PixelScene.createMultiline( Messages.get(this, "unlock"), 9 );
text.maxWidth = (int)width;
text.measure();
@@ -273,9 +262,9 @@ public class StartScene extends PixelScene {
if (info != null) {
btnLoad.visible = true;
btnLoad.secondary( Utils.format( TXT_DPTH_LVL, info.depth, info.level ), info.challenges );
btnLoad.secondary( Utils.format( Messages.get(this, "depth_level"), info.depth, info.level ), info.challenges );
btnNewGame.visible = true;
btnNewGame.secondary( TXT_ERASE, false );
btnNewGame.secondary( Messages.get(this, "erase"), false );
float w = (Camera.main.width - GAP) / 2 - buttonX;
@@ -517,10 +506,10 @@ public class StartScene extends PixelScene {
super.onBackPressed();
image.copy( Icons.get( ShatteredPixelDungeon.challenges() > 0 ?
Icons.CHALLENGE_ON :Icons.CHALLENGE_OFF ) );
};
}
} );
} else {
StartScene.this.add( new WndMessage( TXT_WIN_THE_GAME ) );
StartScene.this.add( new WndMessage( Messages.get(this, "need_to_win") ) );
}
}
@@ -24,6 +24,7 @@ import java.nio.FloatBuffer;
import java.util.Calendar;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.watabou.gltextures.Gradient;
import com.watabou.gltextures.SmartTexture;
import com.watabou.glwrap.Matrix;
@@ -142,7 +143,7 @@ public class SurfaceScene extends PixelScene {
window.add( new TouchArea( sky ) {
protected void onClick( Touch touch ) {
pet.jump();
};
}
} );
for (int i=0; i < nPatches; i++) {
@@ -165,7 +166,7 @@ public class SurfaceScene extends PixelScene {
frame.hardlight( 0xDDEEFF );
}
RedButton gameOver = new RedButton( "Game Over" ) {
RedButton gameOver = new RedButton( Messages.get(this, "exit") ) {
protected void onClick() {
Game.switchScene( TitleScene.class );
}
@@ -25,6 +25,7 @@ import javax.microedition.khronos.opengles.GL10;
import android.opengl.GLES20;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.shatteredpixel.shatteredpixeldungeon.ui.ChangesButton;
@@ -45,11 +46,6 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton;
import com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton;
public class TitleScene extends PixelScene {
private static final String TXT_PLAY = "Play";
private static final String TXT_HIGHSCORES = "Rankings";
private static final String TXT_BADGES = "Badges";
private static final String TXT_ABOUT = "About";
@Override
public void create() {
@@ -99,7 +95,7 @@ public class TitleScene extends PixelScene {
signs.y = title.y;
add( signs );
DashboardItem btnBadges = new DashboardItem( TXT_BADGES, 3 ) {
DashboardItem btnBadges = new DashboardItem( Messages.get(this, "badges"), 3 ) {
@Override
protected void onClick() {
ShatteredPixelDungeon.switchNoFade( BadgesScene.class );
@@ -107,7 +103,7 @@ public class TitleScene extends PixelScene {
};
add(btnBadges);
DashboardItem btnAbout = new DashboardItem( TXT_ABOUT, 1 ) {
DashboardItem btnAbout = new DashboardItem( Messages.get(this, "about"), 1 ) {
@Override
protected void onClick() {
ShatteredPixelDungeon.switchNoFade( AboutScene.class );
@@ -115,7 +111,7 @@ public class TitleScene extends PixelScene {
};
add( btnAbout );
DashboardItem btnPlay = new DashboardItem( TXT_PLAY, 0 ) {
DashboardItem btnPlay = new DashboardItem( Messages.get(this, "play"), 0 ) {
@Override
protected void onClick() {
ShatteredPixelDungeon.switchNoFade( StartScene.class );
@@ -123,25 +119,25 @@ public class TitleScene extends PixelScene {
};
add( btnPlay );
DashboardItem btnHighscores = new DashboardItem( TXT_HIGHSCORES, 2 ) {
DashboardItem btnRankings = new DashboardItem( Messages.get(this, "rankings"), 2 ) {
@Override
protected void onClick() {
ShatteredPixelDungeon.switchNoFade( RankingsScene.class );
}
};
add( btnHighscores );
add( btnRankings );
if (ShatteredPixelDungeon.landscape()) {
float y = (h + height) / 2 - DashboardItem.SIZE;
btnHighscores .setPos( w / 2 - btnHighscores.width(), y );
btnBadges .setPos( w / 2, y );
btnPlay .setPos( btnHighscores.left() - btnPlay.width(), y );
btnRankings .setPos( w / 2 - btnRankings.width(), y );
btnBadges .setPos( w / 2, y );
btnPlay .setPos( btnRankings.left() - btnPlay.width(), y );
btnAbout .setPos( btnBadges.right(), y );
} else {
btnBadges.setPos( w / 2 - btnBadges.width(), (h + height) / 2 - DashboardItem.SIZE );
btnAbout.setPos( w / 2, (h + height) / 2 - DashboardItem.SIZE );
btnPlay.setPos( w / 2 - btnPlay.width(), btnAbout.top() - DashboardItem.SIZE );
btnHighscores.setPos( w / 2, btnPlay.top() );
btnRankings.setPos( w / 2, btnPlay.top() );
}
BitmapText version = new BitmapText( "v " + Game.version + "", pixelFont);