Added Options
-Added options menu -You can move from options to title and back -Added language change button *Double check the Russian, I just copied and pasted from other files
This commit is contained in:
parent
c6de19cf19
commit
22a744f65a
53
src/main/java/ru/windcorp/progressia/test/LayerOptions.java
Normal file
53
src/main/java/ru/windcorp/progressia/test/LayerOptions.java
Normal file
@ -0,0 +1,53 @@
|
||||
package ru.windcorp.progressia.test;
|
||||
|
||||
import ru.windcorp.progressia.client.graphics.Colors;
|
||||
import ru.windcorp.progressia.client.graphics.GUI;
|
||||
import ru.windcorp.progressia.client.graphics.font.Font;
|
||||
import ru.windcorp.progressia.client.graphics.gui.*;
|
||||
import ru.windcorp.progressia.client.graphics.gui.layout.LayoutAlign;
|
||||
import ru.windcorp.progressia.client.graphics.gui.layout.LayoutVertical;
|
||||
import ru.windcorp.progressia.client.graphics.texture.SimpleTextures;
|
||||
import ru.windcorp.progressia.client.localization.Localizer;
|
||||
import ru.windcorp.progressia.client.localization.MutableString;
|
||||
import ru.windcorp.progressia.client.localization.MutableStringLocalized;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LayerOptions extends Background {
|
||||
public LayerOptions(String name) {
|
||||
super(name, new LayoutAlign(0, 1f, 15), SimpleTextures.get("title/background"));
|
||||
|
||||
Group content = new Group("Layer" + name + ".Group", new LayoutVertical(15));
|
||||
|
||||
Font font = new Font().withColor(Colors.BLUE).withAlign(0.5f);
|
||||
|
||||
MutableString languageText = new MutableStringLocalized("Layer" + name + ".Language");
|
||||
content.addChild(new Button(name + ".Language", new Label(name + ".Language", font, languageText)).addAction(this::toggleLanguage));
|
||||
|
||||
MutableString playText = new MutableStringLocalized("Layer" + name + ".Return");
|
||||
content.addChild(new Button(name + ".Return", new Label(name + ".Return", font, playText)).addAction(this::openTitle));
|
||||
|
||||
getRoot().addChild(content);
|
||||
}
|
||||
|
||||
private void openTitle(BasicButton basicButton) {
|
||||
GUI.removeLayer(this);
|
||||
GUI.addTopLayer(new LayerTitle("Title"));
|
||||
}
|
||||
|
||||
private void toggleLanguage(BasicButton basicButton)
|
||||
{
|
||||
String curLang = Localizer.getInstance().getLanguage();
|
||||
List<String> allLangs = Localizer.getInstance().getLanguages();
|
||||
int pos = allLangs.indexOf(curLang);
|
||||
pos++;
|
||||
if (pos >= allLangs.size())
|
||||
{
|
||||
Localizer.getInstance().setLanguage(allLangs.get(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
Localizer.getInstance().setLanguage(allLangs.get(pos));
|
||||
}
|
||||
}
|
||||
}
|
@ -42,10 +42,10 @@ public class LayerTitle extends Background {
|
||||
content.addChild(new TextureComponent(name + ".Title", SimpleTextures.get("title/progressia")));
|
||||
|
||||
info.addChild(new Label(
|
||||
"About",
|
||||
titleFont,
|
||||
new MutableStringLocalized("LayerAbout.Title")
|
||||
)
|
||||
"About",
|
||||
titleFont,
|
||||
new MutableStringLocalized("LayerAbout.Title")
|
||||
)
|
||||
);
|
||||
|
||||
info.addChild(
|
||||
@ -67,6 +67,9 @@ public class LayerTitle extends Background {
|
||||
|
||||
updateResetButton();
|
||||
|
||||
MutableString settingsText = new MutableStringLocalized("Layer" + name + ".Options");
|
||||
buttonContent.addChild(new Button(name + ".Options", new Label(name + ".Options", buttonFont, settingsText)).addAction(this::openOptions));
|
||||
|
||||
MutableString quitText = new MutableStringLocalized("Layer" + name + ".Quit");
|
||||
buttonContent.addChild(new Button(name + "Quit", new Label(name + ".Quit", buttonFont, quitText)).addAction(b -> System.exit(0)));
|
||||
|
||||
@ -117,4 +120,9 @@ public class LayerTitle extends Background {
|
||||
updateResetButton();
|
||||
}
|
||||
|
||||
private void openOptions(BasicButton basicButton) {
|
||||
GUI.removeLayer(this);
|
||||
GUI.addTopLayer(new LayerOptions("Options"));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,5 +24,8 @@ LayerTitle.Reset = Reset World
|
||||
LayerTitle.Options = Options
|
||||
LayerTitle.Quit = Quit
|
||||
|
||||
LayerOptions.Return = Back To Menu
|
||||
LayerOptions.Language = US English
|
||||
|
||||
LayerText.Load = Loading...
|
||||
LayerText.Save = Saving...
|
@ -24,5 +24,8 @@ LayerTitle.Reset = Сбросить мир
|
||||
LayerTitle.Options = Настройки
|
||||
LayerTitle.Quit = Выход
|
||||
|
||||
LayerOptions.Return = Главное меню
|
||||
LayerOptions.Language = Русский
|
||||
|
||||
LayerText.Load = Загрузка...
|
||||
LayerText.Save = Сохранение...
|
Reference in New Issue
Block a user