diff --git a/core/src/main/assets/messages/windows/windows.properties b/core/src/main/assets/messages/windows/windows.properties index 9f8c27b2c..c659ccae1 100644 --- a/core/src/main/assets/messages/windows/windows.properties +++ b/core/src/main/assets/messages/windows/windows.properties @@ -103,8 +103,8 @@ windows.wndkeybindings$wndchangebinding.confirm=Confirm windows.wndkeybindings$wndchangebinding.cancel=Cancel windows.wndlangs.completed=This language has been fully translated and reviewed. -windows.wndlangs.unreviewed=This language has not yet been reviewed.\n\nIt may contain errors, but all text has been translated. -windows.wndlangs.unfinished=This language has not been fully translated.\n\nLarge amounts of text may still be in English. +windows.wndlangs.unreviewed=_This language has not yet been reviewed._ It may contain errors, but all text has been translated. +windows.wndlangs.unfinished=_This language has not been fully translated._ Large amounts of text may still be in English. windows.wndlangs.transifex=All translation provided by volunteers through _Transifex._ windows.wndlangs.credits=credits windows.wndlangs.reviewers=reviewers diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndLangs.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndLangs.java index 2f494e57c..27e5cb017 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndLangs.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/windows/WndLangs.java @@ -27,6 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.messages.Languages; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; +import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton; import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock; import com.shatteredpixel.shatteredpixeldungeon.ui.Window; @@ -39,17 +40,17 @@ import java.util.Locale; public class WndLangs extends Window { - private int WIDTH_P = 120; - private int WIDTH_L = 171; - - private int MIN_HEIGHT = 110; - - private int BTN_WIDTH = 50; + private int BTN_WIDTH = PixelScene.landscape() ? 47 : 60; private int BTN_HEIGHT = 12; + private int WIDTH_P = 2*BTN_WIDTH + 1; + private int WIDTH_L = 5*BTN_WIDTH + 4; + public WndLangs(){ super(); + int w = PixelScene.landscape() ? WIDTH_L : WIDTH_P; + final ArrayList langs = new ArrayList<>(Arrays.asList(Languages.values())); Languages nativeLang = Languages.matchLocale(Locale.getDefault()); @@ -59,8 +60,35 @@ public class WndLangs extends Window { final Languages currLang = Messages.lang(); - //language buttons layout - int y = 0; + //language description + RenderedTextBlock title = PixelScene.renderTextBlock( Messages.titleCase(currLang.nativeName()) , 9 ); + title.setPos( (w - title.width())/2f, 2 ); + title.hardlight(TITLE_COLOR); + PixelScene.align(title); + add(title); + + RenderedTextBlock info = PixelScene.renderTextBlock(6); + info.maxWidth(w); + if (currLang == Languages.ENGLISH) info.text("This is the source language, written by the developer."); + else if (currLang.status() == Languages.Status.REVIEWED) info.text(Messages.get(this, "completed")); + else if (currLang.status() == Languages.Status.UNREVIEWED) info.text(Messages.get(this, "unreviewed")); + else if (currLang.status() == Languages.Status.INCOMPLETE) info.text(Messages.get(this, "unfinished")); + + if (currLang.status() == Languages.Status.UNREVIEWED) info.setHightlighting(true, CharSprite.WARNING); + else if (currLang.status() == Languages.Status.INCOMPLETE) info.setHightlighting(true, CharSprite.NEGATIVE); + info.setPos(0, title.bottom() + 4); + add(info); + + int y = PixelScene.landscape() ? 26 : 32; + y = Math.max(y, (int)Math.ceil(info.bottom()+1)); + int x = 0; + + ColorBlock separator = new ColorBlock(w, 1, 0xFF000000); + separator.y = y; + add(separator); + y += 2; + + //language buttons for (int i = 0; i < langs.size(); i++){ final int langIndex = i; RedButton btn = new RedButton(Messages.titleCase(langs.get(i).nativeName())){ @@ -93,146 +121,114 @@ public class WndLangs extends Window { break; } } - btn.setSize(BTN_WIDTH, BTN_HEIGHT); - if (PixelScene.landscape() && i % 2 == 1){ - btn.setPos(BTN_WIDTH+1, y-(BTN_HEIGHT + 1)); - } else { - btn.setPos(0, y); - y += BTN_HEIGHT; - if (PixelScene.landscape()) y++; + btn.setRect(x, y, BTN_WIDTH, BTN_HEIGHT); + btn.setPos(x, y); + x += BTN_WIDTH+1; + if (x + BTN_WIDTH > w){ + x = 0; + y += BTN_HEIGHT+1; } - add(btn); } - y = Math.max(MIN_HEIGHT, y); - resize(PixelScene.landscape() ? WIDTH_L : WIDTH_P, y); - - int textLeft = width - 65; - int textWidth = width - textLeft; - - ColorBlock separator = new ColorBlock(1, y, 0xFF000000); - separator.x = textLeft - 2.5f; - add(separator); - - //language info layout. - RenderedTextBlock title = PixelScene.renderTextBlock( Messages.titleCase(currLang.nativeName()) , 9 ); - title.setPos( textLeft + (textWidth - title.width())/2f, 2 ); - title.hardlight(TITLE_COLOR); - PixelScene.align(title); - add(title); - - if (currLang == Languages.ENGLISH){ - - RenderedTextBlock info = PixelScene.renderTextBlock(6); - info.text("This is the source language, written by the developer.", width - textLeft); - info.setPos(textLeft, title.bottom() + 4); - add(info); - - } else { - - RenderedTextBlock info = PixelScene.renderTextBlock(6); - switch (currLang.status()) { - case REVIEWED: - info.text(Messages.get(this, "completed"), width - textLeft); - break; - case UNREVIEWED: - info.text(Messages.get(this, "unreviewed"), width - textLeft); - break; - case INCOMPLETE: - info.text(Messages.get(this, "unfinished"), width - textLeft); - break; - } - info.setPos(textLeft, title.bottom() + 4); - add(info); - - RedButton creditsBtn = new RedButton(Messages.titleCase(Messages.get(this, "credits"))){ - @Override - protected void onClick() { - super.onClick(); - String creds = ""; - String creds2 = ""; - String[] reviewers = currLang.reviewers(); - String[] translators = currLang.translators(); - - boolean wide = (2*reviewers.length + translators.length) > (PixelScene.landscape() ? 15 : 30); - - int i; - if (reviewers.length > 0){ - creds += Messages.titleCase(Messages.get(WndLangs.class, "reviewers")) + "\n"; - creds2 += ""; - for ( i = 0; i < reviewers.length; i++){ - if (wide && i % 2 == 1){ - creds2 += "-" + reviewers[i] + "\n"; - } else { - creds += "-" + reviewers[i] + "\n"; - } - } - creds += "\n"; - creds2 += "\n"; - if (i % 2 == 1) creds2 += "\n"; - } - - if (reviewers.length > 0 || translators.length > 0){ - creds += Messages.titleCase(Messages.get(WndLangs.class, "translators")) + "\n"; - creds2 += "\n"; - //reviewers are also translators - for ( i = 0; i < reviewers.length; i++){ - if (wide && i % 2 == 1){ - creds2 += "-" + reviewers[i] + "\n"; - } else { - creds += "-" + reviewers[i] + "\n"; - } - } - for (int j = 0; j < translators.length; j++){ - if (wide && (j + i) % 2 == 1){ - creds2 += "-" + translators[j] + "\n"; - } else { - creds += "-" + translators[j] + "\n"; - } - } - } - - creds = creds.substring(0, creds.length()-1); - - Window credits = new Window( 0, 0, 0, Chrome.get(Chrome.Type.TOAST) ); - - int w = wide? 135 : 65; - - RenderedTextBlock title = PixelScene.renderTextBlock(6); - title.text(Messages.titleCase(Messages.get(WndLangs.class, "credits")) , w); - title.hardlight(SHPX_COLOR); - title.setPos((w - title.width())/2, 0); - credits.add(title); - - RenderedTextBlock text = PixelScene.renderTextBlock(5); - text.setHightlighting(false); - text.text(creds, 65); - text.setPos(0, title.bottom() + 2); - credits.add(text); - - if (wide){ - RenderedTextBlock rightColumn = PixelScene.renderTextBlock(5); - rightColumn.setHightlighting(false); - rightColumn.text(creds2, 65); - rightColumn.setPos(70, title.bottom() + 8.5f); - credits.add(rightColumn); - } - - credits.resize(w, (int)text.bottom()+2); - parent.add(credits); - } - }; - creditsBtn.setSize(creditsBtn.reqWidth() + 2, 16); - creditsBtn.setPos(textLeft + (textWidth - creditsBtn.width()) / 2f, y - 18); - add(creditsBtn); - - RenderedTextBlock transifex_text = PixelScene.renderTextBlock(6); - transifex_text.text(Messages.get(this, "transifex"), width - textLeft); - transifex_text.setPos(textLeft, creditsBtn.top() - 2 - transifex_text.height()); - add(transifex_text); - + if (x > 0){ + y += BTN_HEIGHT+1; } + separator = new ColorBlock(w, 1, 0xFF000000); + separator.y = y; + add(separator); + y += 2; + + //translation info/credits + + RenderedTextBlock transifex_text = PixelScene.renderTextBlock(6); + transifex_text.text(Messages.get(this, "transifex"), w); + transifex_text.setPos(0, y); + add(transifex_text); + + RedButton creditsBtn = new RedButton(Messages.titleCase(Messages.get(this, "credits"))){ + @Override + protected void onClick() { + super.onClick(); + String creds = ""; + String creds2 = ""; + String[] reviewers = currLang.reviewers(); + String[] translators = currLang.translators(); + + boolean wide = (2*reviewers.length + translators.length) > (PixelScene.landscape() ? 15 : 30); + + int i; + if (reviewers.length > 0){ + creds += Messages.titleCase(Messages.get(WndLangs.class, "reviewers")) + "\n"; + creds2 += ""; + for ( i = 0; i < reviewers.length; i++){ + if (wide && i % 2 == 1){ + creds2 += "-" + reviewers[i] + "\n"; + } else { + creds += "-" + reviewers[i] + "\n"; + } + } + creds += "\n"; + creds2 += "\n"; + if (i % 2 == 1) creds2 += "\n"; + } + + if (reviewers.length > 0 || translators.length > 0){ + creds += Messages.titleCase(Messages.get(WndLangs.class, "translators")) + "\n"; + creds2 += "\n"; + //reviewers are also translators + for ( i = 0; i < reviewers.length; i++){ + if (wide && i % 2 == 1){ + creds2 += "-" + reviewers[i] + "\n"; + } else { + creds += "-" + reviewers[i] + "\n"; + } + } + for (int j = 0; j < translators.length; j++){ + if (wide && (j + i) % 2 == 1){ + creds2 += "-" + translators[j] + "\n"; + } else { + creds += "-" + translators[j] + "\n"; + } + } + } + + creds = creds.substring(0, creds.length()-1); + + Window credits = new Window( 0, 0, 0, Chrome.get(Chrome.Type.TOAST) ); + + int w = wide? 125 : 60; + + RenderedTextBlock title = PixelScene.renderTextBlock(6); + title.text(Messages.titleCase(Messages.get(WndLangs.class, "credits")) , w); + title.hardlight(SHPX_COLOR); + title.setPos((w - title.width())/2, 0); + credits.add(title); + + RenderedTextBlock text = PixelScene.renderTextBlock(5); + text.setHightlighting(false); + text.text(creds, 65); + text.setPos(0, title.bottom() + 2); + credits.add(text); + + if (wide){ + RenderedTextBlock rightColumn = PixelScene.renderTextBlock(5); + rightColumn.setHightlighting(false); + rightColumn.text(creds2, 65); + rightColumn.setPos(65, title.bottom() + 7.75f); + credits.add(rightColumn); + } + + credits.resize(w, (int)text.bottom()+2); + parent.add(credits); + } + }; + creditsBtn.setSize(creditsBtn.reqWidth() + 2, 16); + creditsBtn.setPos((w - creditsBtn.width())/2f, transifex_text.bottom()+2); + if (currLang != Languages.ENGLISH) add(creditsBtn); + + resize(PixelScene.landscape() ? WIDTH_L : WIDTH_P, (int)creditsBtn.bottom()); + } @Override