Skip to content

Commit

Permalink
Implement localization in more places (07022022)
Browse files Browse the repository at this point in the history
Another part of #1
  • Loading branch information
Feodor0090 committed Feb 7, 2022
1 parent 47d9ee1 commit 81571ea
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 32 deletions.
27 changes: 27 additions & 0 deletions res/text/common_en.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Back
Beatmapset select
Pallete editor
Check
keybinds setup
pause/exit
column
press a key for the
Cancel
There are no keybinds for this mode
Set them.
RESULTS
any key to proceed
Edit
Total score
Max combo
Accuracy
Full combo
Save & exit
Choose skin type
Settings
Audio
System
not set
Continue
Retry
Quit
8 changes: 5 additions & 3 deletions src/nmania/Nmania.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ public final class Nmania extends MIDlet {

public static Nmania inst;
public boolean running;
public static BeatmapManager bm;
public static Skin skin;
public static String[] commonText;

public Nmania() {
inst = this;
}

protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
Expand All @@ -27,19 +31,17 @@ protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
protected void pauseApp() {
}

public static BeatmapManager bm;
public static Skin skin;

public static void LoadManager(String dir) throws IOException {
bm = new BeatmapManager(dir);
bm.Init();
}

protected void startApp() throws MIDletStateChangeException {
inst = this;
if (running)
return;
Settings.Load();
commonText = getStrings("common");
Push(new MainScreen());
}

Expand Down
5 changes: 2 additions & 3 deletions src/nmania/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,6 @@ private void PassSequence() {
* Loop method, that handles pause menu redrawing.
*/
private void PauseUpdateLoop() {
String[] pauseText = new String[] { "Continue", "Retry", "Quit" };
while (isPaused) {
int sw3 = scrW / 3;
int sh5 = scrH / 5;
Expand All @@ -665,7 +664,7 @@ private void PauseUpdateLoop() {
g.setColor((i == pauseItem ? 255 : 0), 0, 0);
g.drawRect(sw3, ry, sw3 - 1, sh5 - 1);
g.setColor(-1);
g.drawString(pauseText[i], scrW / 2, ry + sh5 / 2 - fillCountersH / 2, 17); // hcenter+top
g.drawString(Nmania.commonText[24 + i], scrW / 2, ry + sh5 / 2 - fillCountersH / 2, 17); // hcenter+top
}
flushGraphics();
try {
Expand Down Expand Up @@ -734,7 +733,7 @@ private void FailSequence(boolean exitAfter) {
g.setColor((i == pauseItem ? 255 : 0), 0, 0);
g.drawRect(sw3, ry, sw3 - 1, sh5 - 1);
g.setColor(-1);
g.drawString(i == 0 ? "Retry" : "Quit", scrW / 2, ry + sh5 / 2 - fillCountersH / 2, 17); // hcenter+top
g.drawString(Nmania.commonText[25 + i], scrW / 2, ry + sh5 / 2 - fillCountersH / 2, 17); // hcenter+top
}
flushGraphics();
try {
Expand Down
4 changes: 2 additions & 2 deletions src/nmania/PlayerLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public PlayerLoader(BeatmapSet set, String bmFileName, boolean auto, BeatmapSetP
Displayable page;
final boolean auto;
Alert a;
Command cancelCmd = new Command("Cancel", Command.STOP, 1);
Command cancelCmd = new Command(Nmania.commonText[8], Command.STOP, 1);

public void run() {
a = new Alert("nmania", "Reading beatmap file", null, AlertType.INFO);
Expand Down Expand Up @@ -64,7 +64,7 @@ public void run() {
// no keyboard layout
KeyboardSetup kbs = new KeyboardSetup(b.columnsCount, page);
PushWaitPush(kbs,
new Alert("nmania", "There are no keybinds for this mode (" + b.columnsCount + "K). Set them.",
new Alert("nmania", Nmania.commonText[9] + " (" + b.columnsCount + "K). " + Nmania.commonText[10],
null, AlertType.WARNING));
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/nmania/ui/BeatmapSetsList.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
public class BeatmapSetsList extends List implements CommandListener {

private BeatmapManager bm;
private Command back = new Command("Back", Command.BACK, 1);
private Command back = new Command(Nmania.commonText[0], Command.BACK, 1);

public BeatmapSetsList(BeatmapManager bm) throws IOException {
super("Beatmapset select", Choice.IMPLICIT);
super(Nmania.commonText[1], Choice.IMPLICIT);
setCommandListener(this);
this.bm = bm;
Enumeration e = bm.list();
Expand Down
8 changes: 4 additions & 4 deletions src/nmania/ui/ColorPalleteEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
public class ColorPalleteEditor extends Form implements CommandListener {

public ColorPalleteEditor(int[] colors, Displayable prev) {
super("Pallete editor");
super(Nmania.commonText[2]);
this.prev = prev;
this.colors = colors;
fields = new TextField[colors.length];
Expand All @@ -32,8 +32,8 @@ public ColorPalleteEditor(int[] colors, Displayable prev) {
addCommand(view);
}

private final Command back = new Command("Back", Command.BACK, 1);
private final Command view = new Command("Check", Command.SCREEN, 2);
private final Command back = new Command(Nmania.commonText[0], Command.BACK, 1);
private final Command view = new Command(Nmania.commonText[3], Command.SCREEN, 2);
final Displayable prev;
public final int[] colors;
TextField[] fields;
Expand All @@ -50,7 +50,7 @@ public void commandAction(Command c, Displayable arg1) {
Nmania.Push(new ColorPalletePreview(this));
} catch (Exception e) {
e.printStackTrace();
Nmania.Push(new Alert("Pallete editor", "Color " + (i + 1) + " is invalid. Check the field.", null,
Nmania.Push(new Alert(Nmania.commonText[2], "Color " + (i + 1) + " is invalid. Check the field.", null,
AlertType.ERROR));
}

Expand Down
10 changes: 5 additions & 5 deletions src/nmania/ui/KeyboardSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected final void paint(Graphics g) {
// top text
g.setColor(-1);
g.setFont(large);
g.drawString("keybinds setup (" + columns + "K)", w / 2, 0, 17);
g.drawString(Nmania.commonText[4] + " (" + columns + "K)", w / 2, 0, 17);
String keyCapt;
switch (currentColumn) {
case 0:
Expand All @@ -65,12 +65,12 @@ protected final void paint(Graphics g) {
break;
}
if (currentColumn == columns) {
keyCapt = "pause/exit";
keyCapt = Nmania.commonText[5];
} else {
keyCapt = keyCapt + " column";
keyCapt = keyCapt + " " + Nmania.commonText[6];
}
g.setFont(small);
g.drawString("press a key for the " + keyCapt, w / 2, large.getHeight(), 17);
g.drawString(Nmania.commonText[7] + " " + keyCapt, w / 2, large.getHeight(), 17);

// cols
int colW = w / columns;
Expand Down Expand Up @@ -101,7 +101,7 @@ protected final void paint(Graphics g) {
g.fillRect(i * colW + 1, h - sfh * 3 + 1, colW - 1, sfh * 3 - 1);
}
}
if(currentColumn == columns) {
if (currentColumn == columns) {
g.setColor(255, 255, 0);
g.fillRect(0, h - sfh * 4, w, sfh);
}
Expand Down
10 changes: 5 additions & 5 deletions src/nmania/ui/ResultsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ protected void paint(Graphics g) {

g.setColor(-1);
g.setFont(Font.getFont(0, 0, 16));
g.drawString("RESULTS", w / 2, -introTimer, 17);
g.drawString(Nmania.commonText[11], w / 2, -introTimer, 17);
g.setFont(Font.getFont(0, 0, 8));
g.drawString("any key to proceed", w / 2, h + introTimer, Graphics.BOTTOM | Graphics.HCENTER);
g.drawString(Nmania.commonText[12], w / 2, h + introTimer, Graphics.BOTTOM | Graphics.HCENTER);

int th = Font.getFont(0, 0, 8).getHeight();
int y = (h - th * 9) / 2;
drawRow(g, 0, "Total score", -1, String.valueOf(score.currentHitScore), y, w);
drawRow(g, 0, Nmania.commonText[14], -1, String.valueOf(score.currentHitScore), y, w);
y += th;
drawRow(g, 1, "Max combo", -1, score.hits[0] == 0 ? "Full combo" : String.valueOf(score.maxCombo), y, w);
drawRow(g, 1, Nmania.commonText[15], -1, score.hits[0] == 0 ? Nmania.commonText[17] : String.valueOf(score.maxCombo), y, w);
y += th;
drawRow(g, 2, "Accuracy", -1, String.valueOf((score.GetAccuracy() / 100f) + "%"), y, w);
drawRow(g, 2, Nmania.commonText[16], -1, String.valueOf((score.GetAccuracy() / 100f) + "%"), y, w);
y += th;
for (int i = 0; i < 6; i++) {
drawRow(g, 3 + i, Player.judgements[i], Player.judgementColors[i], String.valueOf(score.hits[i]), y, w);
Expand Down
8 changes: 4 additions & 4 deletions src/nmania/ui/SettingsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public String[] GetItems() {
}

public String GetTitle() {
return "nmania settings";
return Nmania.commonText[20];
}

public void paint(Graphics g, int y, int sw) {
Expand Down Expand Up @@ -261,7 +261,7 @@ public void OnSelect(int i) {
}

public String GetTitle() {
return "Audio";
return Nmania.commonText[21];
}

final String[] items = Nmania.getStrings("sets_audio");
Expand Down Expand Up @@ -301,7 +301,7 @@ public void OnSelect(int i) {
}

public String GetTitle() {
return "System";
return Nmania.commonText[22];
}

final String[] items = Nmania.getStrings("sets_system");
Expand Down Expand Up @@ -340,7 +340,7 @@ public String[] GetItems() {
public void paint(Graphics g, int y, int sw) {
for (int i = 0; i < 10; i++) {
if (i > 0 && Settings.keyLayout[i] == null) {
g.drawString("not set", getWidth() - 10, y + th * i, 24);
g.drawString(Nmania.commonText[23], getWidth() - 10, y + th * i, 24);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/nmania/ui/SkinSelect.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected void paint(Graphics g) {
g.fillRect(0, 0, w, h);
g.setColor(-1);

g.drawString("Choose skin type", w / 2, -outroTimer, 17);
g.drawString(Nmania.commonText[19], w / 2, -outroTimer, 17);
int x1 = w / 4;
int x2 = w * 3 / 4;
if (outroTimer != 0) {
Expand Down Expand Up @@ -80,7 +80,7 @@ protected void paint(Graphics g) {
if (!selectionFocused && outroTimer == 0)
g.fillRect(5, h - th - 5, w - 10, th);
g.setColor(-1);
g.drawString("Save & exit", w / 2, h - 5 + outroTimer, 33);
g.drawString(Nmania.commonText[18], w / 2, h - 5 + outroTimer, 33);

if (introTimer > 0) {
g.setColor(-1);
Expand Down
4 changes: 2 additions & 2 deletions src/nmania/ui/VectorSkinSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public VectorSkinSetup(SkinSelect ss) {
append(holdKeyColors);
}

private final Command back = new Command("Back", Command.BACK, 2);
private final Command edit = new Command("Edit", Command.ITEM, 1);
private final Command back = new Command(Nmania.commonText[0], Command.BACK, 2);
private final Command edit = new Command(Nmania.commonText[13], Command.ITEM, 1);
final SkinSelect prev;
final Skin skin = Nmania.skin;

Expand Down

0 comments on commit 81571ea

Please sign in to comment.