v0.8.2: settings window is now wider in landscape and has a language tab
This commit is contained in:
parent
0f836e5042
commit
468ef2664c
|
@ -103,14 +103,6 @@ windows.wndkeybindings$wndchangebinding.unbind=Unbind Key
|
|||
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._ 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
|
||||
windows.wndlangs.translators=translators
|
||||
|
||||
windows.wndranking.error=Unable to load additional information
|
||||
windows.wndranking.stats=Stats
|
||||
windows.wndranking.items=Items
|
||||
|
@ -172,6 +164,13 @@ windows.wndsettings$audiotab.music_vol=Music Volume
|
|||
windows.wndsettings$audiotab.music_mute=Mute Music
|
||||
windows.wndsettings$audiotab.sfx_vol=SFX Volume
|
||||
windows.wndsettings$audiotab.sfx_mute=Mute SFX
|
||||
windows.wndsettings$langstab.completed=This language has been fully translated and reviewed.
|
||||
windows.wndsettings$langstab.unreviewed=_This language has not yet been reviewed._ It may contain errors, but all text has been translated.
|
||||
windows.wndsettings$langstab.unfinished=_This language has not been fully translated._ Large amounts of text may still be in English.
|
||||
windows.wndsettings$langstab.transifex=All translation provided by volunteers through _Transifex._
|
||||
windows.wndsettings$langstab.credits=credits
|
||||
windows.wndsettings$langstab.reviewers=reviewers
|
||||
windows.wndsettings$langstab.translators=translators
|
||||
|
||||
windows.wndstartgame.title=Choose Your Hero
|
||||
windows.wndstartgame.huntress_unlock=Defeat the boss on floor 15 to unlock this character
|
||||
|
|
|
@ -27,26 +27,22 @@ import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.BannerSprites;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Fireball;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Languages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.services.updates.AvailableUpdateData;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.services.updates.Updates;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Archs;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ExitButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.LanguageButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.PrefsButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.StyledButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.UpdateNotification;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndStartGame;
|
||||
import com.watabou.glwrap.Blending;
|
||||
import com.watabou.noosa.BitmapText;
|
||||
import com.watabou.noosa.Camera;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.NinePatch;
|
||||
import com.watabou.noosa.audio.Music;
|
||||
import com.watabou.utils.ColorMath;
|
||||
import com.watabou.utils.DeviceCompat;
|
||||
|
@ -179,13 +175,7 @@ public class TitleScene extends PixelScene {
|
|||
btnNews.icon(Icons.get(Icons.CHANGES));
|
||||
add(btnNews);
|
||||
|
||||
StyledButton btnSettings = new StyledButton(GREY_TR, Messages.get(this, "settings")){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
ShatteredPixelDungeon.scene().add(new WndSettings());
|
||||
}
|
||||
};
|
||||
btnSettings.icon(Icons.get(Icons.PREFS));
|
||||
StyledButton btnSettings = new SettingsButton(GREY_TR, Messages.get(this, "settings"));
|
||||
add(btnSettings);
|
||||
|
||||
StyledButton btnAbout = new StyledButton(GREY_TR, Messages.get(this, "about")){
|
||||
|
@ -233,10 +223,6 @@ public class TitleScene extends PixelScene {
|
|||
|
||||
int pos = 2;
|
||||
|
||||
LanguageButton btnLang = new LanguageButton();
|
||||
btnLang.setRect(pos, 0, 16, 20);
|
||||
add( btnLang );
|
||||
|
||||
ExitButton btnExit = new ExitButton();
|
||||
btnExit.setPos( w - btnExit.width(), 0 );
|
||||
add( btnExit );
|
||||
|
@ -250,6 +236,7 @@ public class TitleScene extends PixelScene {
|
|||
add( fb );
|
||||
}
|
||||
|
||||
//TODO change icon?
|
||||
private static class ChangesButton extends StyledButton {
|
||||
|
||||
public ChangesButton( Chrome.Type type, String label ){
|
||||
|
@ -300,4 +287,38 @@ public class TitleScene extends PixelScene {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
//TODO maybe have this blink a bit differently than the language button used to
|
||||
private static class SettingsButton extends StyledButton {
|
||||
|
||||
boolean blinking;
|
||||
|
||||
public SettingsButton( Chrome.Type type, String label ){
|
||||
super(type, label);
|
||||
if (Messages.lang().status() == Languages.Status.INCOMPLETE){
|
||||
icon(Icons.get(Icons.LANGS));
|
||||
icon.hardlight(1.5f, 0, 0);
|
||||
blinking = true;
|
||||
} else {
|
||||
icon(Icons.get(Icons.PREFS));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (blinking){
|
||||
icon.am = (float)Math.abs(Math.cos( Game.timeTotal ));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
if (blinking){
|
||||
WndSettings.last_index = 3;
|
||||
}
|
||||
ShatteredPixelDungeon.scene().add(new WndSettings());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2019 Evan Debenham
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndLangs;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
|
||||
public class LanguageButton extends Button {
|
||||
|
||||
private Image image;
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
super.createChildren();
|
||||
|
||||
image = Icons.get(Icons.LANGS);
|
||||
add( image );
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
private boolean flashing;
|
||||
private float time = 0;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
super.update();
|
||||
|
||||
if (flashing){
|
||||
image.am = (float)Math.abs(Math.cos( (time += Game.elapsed) ));
|
||||
if (time >= Math.PI) {
|
||||
time = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateIcon(){
|
||||
image.resetColor();
|
||||
flashing = false;
|
||||
switch(Messages.lang().status()){
|
||||
case INCOMPLETE:
|
||||
image.hardlight(1.5f, 0, 0);
|
||||
flashing = true;
|
||||
break;
|
||||
case UNREVIEWED:
|
||||
image.hardlight(1.5f, 0.75f, 0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
super.layout();
|
||||
|
||||
image.x = x + (width - image.width)/2f;
|
||||
image.y = y + (height - image.height)/2f;
|
||||
PixelScene.align(image);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPointerDown() {
|
||||
image.brightness( 1.5f );
|
||||
Sample.INSTANCE.play( Assets.Sounds.CLICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPointerUp() {
|
||||
image.resetColor();
|
||||
updateIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
parent.add(new WndLangs());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2019 Evan Debenham
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.ui;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndSettings;
|
||||
import com.watabou.noosa.Image;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.ui.Button;
|
||||
|
||||
public class PrefsButton extends Button {
|
||||
|
||||
private Image image;
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
super.createChildren();
|
||||
|
||||
image = Icons.PREFS.get();
|
||||
add( image );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
super.layout();
|
||||
|
||||
image.x = x + (width - image.width)/2f;
|
||||
image.y = y + (height - image.height)/2f;
|
||||
PixelScene.align(image);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPointerDown() {
|
||||
image.brightness( 1.5f );
|
||||
Sample.INSTANCE.play( Assets.Sounds.CLICK );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPointerUp() {
|
||||
image.resetColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClick() {
|
||||
parent.add( new WndSettings() );
|
||||
}
|
||||
}
|
|
@ -1,249 +0,0 @@
|
|||
/*
|
||||
* Pixel Dungeon
|
||||
* Copyright (C) 2012-2015 Oleg Dolya
|
||||
*
|
||||
* Shattered Pixel Dungeon
|
||||
* Copyright (C) 2014-2019 Evan Debenham
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
|
||||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
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;
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
import com.watabou.noosa.Game;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
public class WndLangs extends Window {
|
||||
|
||||
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<Languages> langs = new ArrayList<>(Arrays.asList(Languages.values()));
|
||||
|
||||
Languages nativeLang = Languages.matchLocale(Locale.getDefault());
|
||||
langs.remove(nativeLang);
|
||||
//move the native language to the top.
|
||||
langs.add(0, nativeLang);
|
||||
|
||||
final Languages currLang = Messages.lang();
|
||||
|
||||
//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())){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
Messages.setup(langs.get(langIndex));
|
||||
ShatteredPixelDungeon.seamlessResetScene(new Game.SceneChangeCallback() {
|
||||
@Override
|
||||
public void beforeCreate() {
|
||||
SPDSettings.language(langs.get(langIndex));
|
||||
Game.platform.resetGenerators();
|
||||
}
|
||||
@Override
|
||||
public void afterCreate() {
|
||||
//do nothing
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
if (currLang == langs.get(i)){
|
||||
btn.textColor(TITLE_COLOR);
|
||||
} else {
|
||||
switch (langs.get(i).status()) {
|
||||
case INCOMPLETE:
|
||||
btn.textColor(0x888888);
|
||||
break;
|
||||
case UNREVIEWED:
|
||||
btn.textColor(0xBBBBBB);
|
||||
break;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
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
|
||||
public void hide() {
|
||||
super.hide();
|
||||
//resets generators because there's no need to retain chars for languages not selected
|
||||
ShatteredPixelDungeon.seamlessResetScene(new Game.SceneChangeCallback() {
|
||||
@Override
|
||||
public void beforeCreate() {
|
||||
Game.platform.resetGenerators();
|
||||
}
|
||||
@Override
|
||||
public void afterCreate() {
|
||||
//do nothing
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -22,26 +22,38 @@
|
|||
package com.shatteredpixel.shatteredpixeldungeon.windows;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Chrome;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.SPDSettings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Languages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.CheckBox;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.GameLog;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Icons;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.OptionSlider;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RedButton;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.RenderedTextBlock;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Toolbar;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.Window;
|
||||
import com.watabou.noosa.ColorBlock;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.ui.Component;
|
||||
import com.watabou.utils.DeviceCompat;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
|
||||
public class WndSettings extends WndTabbed {
|
||||
|
||||
private static final int WIDTH = 112;
|
||||
private static final int WIDTH_P = 122;
|
||||
private static final int WIDTH_L = 223;
|
||||
|
||||
private static final int SLIDER_HEIGHT = 24;
|
||||
private static final int BTN_HEIGHT = 18;
|
||||
private static final int GAP_TINY = 2;
|
||||
|
@ -51,16 +63,20 @@ public class WndSettings extends WndTabbed {
|
|||
private DisplayTab display;
|
||||
private UITab ui;
|
||||
private AudioTab audio;
|
||||
private LangsTab langs;
|
||||
|
||||
private static int last_index = 0;
|
||||
public static int last_index = 0;
|
||||
|
||||
//FIXME now that this is totally refactored I should look into making this look neater. It's almost there
|
||||
public WndSettings() {
|
||||
super();
|
||||
|
||||
float height;
|
||||
|
||||
int width = PixelScene.landscape() ? WIDTH_L : WIDTH_P;
|
||||
|
||||
display = new DisplayTab();
|
||||
display.setSize(WIDTH, 0);
|
||||
display.setSize(width, 0);
|
||||
height = display.height();
|
||||
add( display );
|
||||
|
||||
|
@ -74,7 +90,7 @@ public class WndSettings extends WndTabbed {
|
|||
});
|
||||
|
||||
ui = new UITab();
|
||||
ui.setSize(WIDTH, 0);
|
||||
ui.setSize(width, 0);
|
||||
height = Math.max(height, ui.height());
|
||||
add( ui );
|
||||
|
||||
|
@ -88,7 +104,7 @@ public class WndSettings extends WndTabbed {
|
|||
});
|
||||
|
||||
audio = new AudioTab();
|
||||
audio.setSize(WIDTH, 0);
|
||||
audio.setSize(width, 0);
|
||||
height = Math.max(height, audio.height());
|
||||
add( audio );
|
||||
|
||||
|
@ -101,7 +117,35 @@ public class WndSettings extends WndTabbed {
|
|||
}
|
||||
});
|
||||
|
||||
resize(WIDTH, (int)Math.ceil(height));
|
||||
langs = new LangsTab();
|
||||
langs.setSize(width, 0);
|
||||
height = Math.max(height, langs.height());
|
||||
add( langs );
|
||||
|
||||
add( new IconTab(Icons.get(Icons.LANGS)){
|
||||
@Override
|
||||
protected void select(boolean value) {
|
||||
super.select(value);
|
||||
langs.visible = langs.active = value;
|
||||
if (value) last_index = 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
super.createChildren();
|
||||
switch(Messages.lang().status()){
|
||||
case INCOMPLETE:
|
||||
icon.hardlight(1.5f, 0, 0);
|
||||
break;
|
||||
case UNREVIEWED:
|
||||
icon.hardlight(1.5f, 0.75f, 0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
resize(width, (int)Math.ceil(height));
|
||||
|
||||
layoutTabs();
|
||||
|
||||
|
@ -109,6 +153,22 @@ public class WndSettings extends WndTabbed {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hide() {
|
||||
super.hide();
|
||||
//resets generators because there's no need to retain chars for languages not selected
|
||||
ShatteredPixelDungeon.seamlessResetScene(new Game.SceneChangeCallback() {
|
||||
@Override
|
||||
public void beforeCreate() {
|
||||
Game.platform.resetGenerators();
|
||||
}
|
||||
@Override
|
||||
public void afterCreate() {
|
||||
//do nothing
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private class DisplayTab extends Component {
|
||||
|
||||
OptionSlider optScale;
|
||||
|
@ -134,6 +194,7 @@ public class WndSettings extends WndTabbed {
|
|||
}
|
||||
}
|
||||
};
|
||||
optScale.setSelectedValue(PixelScene.defaultZoom);
|
||||
add(optScale);
|
||||
}
|
||||
|
||||
|
@ -210,18 +271,29 @@ public class WndSettings extends WndTabbed {
|
|||
bottom = optScale.bottom();
|
||||
}
|
||||
|
||||
if (chkSaver != null){
|
||||
chkSaver.setRect( 0, bottom + GAP_TINY, width, BTN_HEIGHT );
|
||||
bottom = chkSaver.bottom();
|
||||
}
|
||||
|
||||
if (btnOrientation != null){
|
||||
btnOrientation.setRect( 0, bottom + GAP_TINY, width, BTN_HEIGHT );
|
||||
if (width > 200 && chkSaver != null && btnOrientation != null) {
|
||||
chkSaver.setRect(0, bottom + GAP_TINY, width/2-1, BTN_HEIGHT);
|
||||
btnOrientation.setRect(chkSaver.right()+GAP_TINY, bottom + GAP_TINY, width/2-1, BTN_HEIGHT);
|
||||
bottom = btnOrientation.bottom();
|
||||
} else {
|
||||
if (chkSaver != null) {
|
||||
chkSaver.setRect(0, bottom + GAP_TINY, width, BTN_HEIGHT);
|
||||
bottom = chkSaver.bottom();
|
||||
}
|
||||
|
||||
if (btnOrientation != null) {
|
||||
btnOrientation.setRect(0, bottom + GAP_TINY, width, BTN_HEIGHT);
|
||||
bottom = btnOrientation.bottom();
|
||||
}
|
||||
}
|
||||
|
||||
optBrightness.setRect(0, bottom + GAP_LRG, width, SLIDER_HEIGHT);
|
||||
optVisGrid.setRect(0, optBrightness.bottom() + GAP_TINY, width, SLIDER_HEIGHT);
|
||||
if (width > 200){
|
||||
optBrightness.setRect(0, bottom + GAP_LRG, width/2-1, SLIDER_HEIGHT);
|
||||
optVisGrid.setRect(optBrightness.right() + GAP_TINY, optBrightness.top(), width/2-1, SLIDER_HEIGHT);
|
||||
} else {
|
||||
optBrightness.setRect(0, bottom + GAP_LRG, width, SLIDER_HEIGHT);
|
||||
optVisGrid.setRect(0, optBrightness.bottom() + GAP_TINY, width, SLIDER_HEIGHT);
|
||||
}
|
||||
|
||||
height = optVisGrid.bottom();
|
||||
}
|
||||
|
@ -349,12 +421,19 @@ public class WndSettings extends WndTabbed {
|
|||
btnGrouped.setRect(btnSplit.right()+GAP_TINY, btnSplit.top(), btnWidth, 16);
|
||||
btnCentered.setRect(btnGrouped.right()+GAP_TINY, btnSplit.top(), btnWidth, 16);
|
||||
|
||||
chkFlipToolbar.setRect(0, btnGrouped.bottom() + GAP_TINY, width, BTN_HEIGHT);
|
||||
chkFlipTags.setRect(0, chkFlipToolbar.bottom() + GAP_TINY, width, BTN_HEIGHT);
|
||||
if (width > 200) {
|
||||
chkFlipToolbar.setRect(0, btnGrouped.bottom() + GAP_TINY, width/2 - 1, BTN_HEIGHT);
|
||||
chkFlipTags.setRect(chkFlipToolbar.right() + GAP_TINY, chkFlipToolbar.top(), width/2 -1, BTN_HEIGHT);
|
||||
|
||||
chkFullscreen.setRect(0, chkFlipTags.bottom() + GAP_SML, width, BTN_HEIGHT);
|
||||
chkFullscreen.setRect(0, chkFlipTags.bottom() + GAP_SML, width/2 - 1, BTN_HEIGHT);
|
||||
chkFont.setRect(chkFullscreen.right() + GAP_TINY, chkFullscreen.top(), width/2 - 1, BTN_HEIGHT);
|
||||
} else {
|
||||
chkFlipToolbar.setRect(0, btnGrouped.bottom() + GAP_TINY, width, BTN_HEIGHT);
|
||||
chkFlipTags.setRect(0, chkFlipToolbar.bottom() + GAP_TINY, width, BTN_HEIGHT);
|
||||
|
||||
chkFont.setRect(0, chkFullscreen.bottom() + GAP_TINY, width, BTN_HEIGHT);
|
||||
chkFullscreen.setRect(0, chkFlipTags.bottom() + GAP_SML, width, BTN_HEIGHT);
|
||||
chkFont.setRect(0, chkFullscreen.bottom() + GAP_TINY, width, BTN_HEIGHT);
|
||||
}
|
||||
|
||||
if (btnKeyBindings != null){
|
||||
btnKeyBindings.setRect(0, chkFont.bottom() + GAP_SML, width, BTN_HEIGHT);
|
||||
|
@ -438,4 +517,222 @@ public class WndSettings extends WndTabbed {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
private class LangsTab extends Component{
|
||||
|
||||
final static int COLS_P = 3;
|
||||
final static int COLS_L = 4;
|
||||
|
||||
final static int BTN_HEIGHT = 12;
|
||||
|
||||
RenderedTextBlock txtLangName;
|
||||
RenderedTextBlock txtLangInfo;
|
||||
|
||||
ColorBlock sep1;
|
||||
|
||||
RedButton[] lanBtns;
|
||||
|
||||
ColorBlock sep2;
|
||||
|
||||
RenderedTextBlock txtTranifex;
|
||||
RedButton btnCredits;
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
final ArrayList<Languages> langs = new ArrayList<>(Arrays.asList(Languages.values()));
|
||||
|
||||
Languages nativeLang = Languages.matchLocale(Locale.getDefault());
|
||||
langs.remove(nativeLang);
|
||||
//move the native language to the top.
|
||||
langs.add(0, nativeLang);
|
||||
|
||||
final Languages currLang = Messages.lang();
|
||||
|
||||
txtLangName = PixelScene.renderTextBlock( Messages.titleCase(currLang.nativeName()) , 9 );
|
||||
txtLangName.hardlight(TITLE_COLOR);
|
||||
add(txtLangName);
|
||||
|
||||
txtLangInfo = PixelScene.renderTextBlock(6);
|
||||
if (currLang == Languages.ENGLISH) txtLangInfo.text("This is the source language, written by the developer.");
|
||||
else if (currLang.status() == Languages.Status.REVIEWED) txtLangInfo.text(Messages.get(this, "completed"));
|
||||
else if (currLang.status() == Languages.Status.UNREVIEWED) txtLangInfo.text(Messages.get(this, "unreviewed"));
|
||||
else if (currLang.status() == Languages.Status.INCOMPLETE) txtLangInfo.text(Messages.get(this, "unfinished"));
|
||||
if (currLang.status() == Languages.Status.UNREVIEWED) txtLangInfo.setHightlighting(true, CharSprite.WARNING);
|
||||
else if (currLang.status() == Languages.Status.INCOMPLETE) txtLangInfo.setHightlighting(true, CharSprite.NEGATIVE);
|
||||
add(txtLangInfo);
|
||||
|
||||
sep1 = new ColorBlock(1, 1, 0xFF000000);
|
||||
add(sep1);
|
||||
|
||||
lanBtns = new RedButton[langs.size()];
|
||||
for (int i = 0; i < langs.size(); i++){
|
||||
final int langIndex = i;
|
||||
RedButton btn = new RedButton(Messages.titleCase(langs.get(i).nativeName()), 8){
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
Messages.setup(langs.get(langIndex));
|
||||
ShatteredPixelDungeon.seamlessResetScene(new Game.SceneChangeCallback() {
|
||||
@Override
|
||||
public void beforeCreate() {
|
||||
SPDSettings.language(langs.get(langIndex));
|
||||
GameLog.wipe();
|
||||
Game.platform.resetGenerators();
|
||||
}
|
||||
@Override
|
||||
public void afterCreate() {
|
||||
//do nothing
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
if (currLang == langs.get(i)){
|
||||
btn.textColor(TITLE_COLOR);
|
||||
} else {
|
||||
switch (langs.get(i).status()) {
|
||||
case INCOMPLETE:
|
||||
btn.textColor(0x888888);
|
||||
break;
|
||||
case UNREVIEWED:
|
||||
btn.textColor(0xBBBBBB);
|
||||
break;
|
||||
}
|
||||
}
|
||||
lanBtns[i] = btn;
|
||||
add(btn);
|
||||
}
|
||||
|
||||
sep2 = new ColorBlock(1, 1, 0xFF000000);
|
||||
add(sep2);
|
||||
|
||||
txtTranifex = PixelScene.renderTextBlock(6);
|
||||
txtTranifex.text(Messages.get(this, "transifex"));
|
||||
add(txtTranifex);
|
||||
|
||||
if (currLang != Languages.ENGLISH) {
|
||||
String credText = Messages.titleCase(Messages.get(this, "credits"));
|
||||
btnCredits = new RedButton(credText, credText.length() > 9 ? 6 : 9) {
|
||||
@Override
|
||||
protected void onClick() {
|
||||
super.onClick();
|
||||
String creds = "";
|
||||
String creds2 = "";
|
||||
String[] reviewers = currLang.reviewers();
|
||||
String[] translators = currLang.translators();
|
||||
|
||||
ArrayList<String> total = new ArrayList<>();
|
||||
total.addAll(Arrays.asList(reviewers));
|
||||
total.addAll(Arrays.asList(reviewers));
|
||||
total.addAll(Arrays.asList(translators));
|
||||
int translatorIdx = reviewers.length;
|
||||
|
||||
//we have 2 columns in wide mode
|
||||
boolean wide = (2 * reviewers.length + translators.length) > (PixelScene.landscape() ? 15 : 30);
|
||||
|
||||
int i;
|
||||
if (reviewers.length > 0) {
|
||||
creds += Messages.titleCase(Messages.get(LangsTab.this, "reviewers"));
|
||||
creds2 += "";
|
||||
boolean col2 = false;
|
||||
for (i = 0; i < total.size(); i++) {
|
||||
if (i == translatorIdx){
|
||||
creds += "\n\n" + Messages.titleCase(Messages.get(LangsTab.this, "translators"));
|
||||
creds2 += "\n\n";
|
||||
if (col2) creds2 += "\n";
|
||||
col2 = false;
|
||||
}
|
||||
if (wide && col2) {
|
||||
creds2 += "\n-" + total.get(i);
|
||||
} else {
|
||||
creds += "\n-" + total.get(i);
|
||||
}
|
||||
col2 = !col2 && wide;
|
||||
}
|
||||
}
|
||||
|
||||
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(LangsTab.this, "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() + 6);
|
||||
credits.add(rightColumn);
|
||||
}
|
||||
|
||||
credits.resize(w, (int) text.bottom() + 2);
|
||||
ShatteredPixelDungeon.scene().addToFront(credits);
|
||||
}
|
||||
};
|
||||
add(btnCredits);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void layout() {
|
||||
txtLangName.setPos( (width - txtLangName.width())/2f, 2 );
|
||||
PixelScene.align(txtLangName);
|
||||
|
||||
txtLangInfo.setPos(0, txtLangName.bottom() + 4);
|
||||
txtLangInfo.maxWidth((int)width);
|
||||
|
||||
int y = PixelScene.landscape() ? 26 : 32;
|
||||
y = Math.max(y, (int)Math.ceil(txtLangInfo.bottom()+1));
|
||||
int x = 0;
|
||||
|
||||
sep1.size(width, 1);
|
||||
sep1.y = y;
|
||||
y += 2;
|
||||
|
||||
int cols = PixelScene.landscape() ? COLS_L : COLS_P;
|
||||
int btnWidth = (int)Math.floor((width - (cols-1)) / cols);
|
||||
for (RedButton btn : lanBtns){
|
||||
btn.setRect(x, y, btnWidth, BTN_HEIGHT);
|
||||
btn.setPos(x, y);
|
||||
x += btnWidth+1;
|
||||
if (x + btnWidth > width){
|
||||
x = 0;
|
||||
y += BTN_HEIGHT+1;
|
||||
}
|
||||
}
|
||||
if (x > 0){
|
||||
y += BTN_HEIGHT+1;
|
||||
}
|
||||
|
||||
sep2.size(width, 1);
|
||||
sep2.y = y;
|
||||
y += 2;
|
||||
|
||||
if (btnCredits != null){
|
||||
btnCredits.setSize(btnCredits.reqWidth() + 2, 16);
|
||||
btnCredits.setPos(width - btnCredits.width(), y);
|
||||
|
||||
txtTranifex.setPos(0, y);
|
||||
txtTranifex.maxWidth((int)btnCredits.left());
|
||||
|
||||
height = Math.max(btnCredits.bottom(), txtTranifex.bottom());
|
||||
} else {
|
||||
txtTranifex.setPos(0, y);
|
||||
txtTranifex.maxWidth((int)width);
|
||||
|
||||
height = txtTranifex.bottom();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -233,7 +233,7 @@ public class WndTabbed extends Window {
|
|||
|
||||
protected class IconTab extends Tab {
|
||||
|
||||
private Image icon;
|
||||
protected Image icon;
|
||||
private RectF defaultFrame;
|
||||
|
||||
public IconTab( Image icon ){
|
||||
|
|
Loading…
Reference in New Issue
Block a user