Everything Excpeti polishing and options
-Added LayerTitle class that is the title menu -Edited the launcher and proxy so it only starts the game when it needs to -Made buttons work with MutableString objects
This commit is contained in:
parent
eace6733ce
commit
a9ca5f6b17
@ -18,18 +18,38 @@
|
|||||||
|
|
||||||
package ru.windcorp.progressia;
|
package ru.windcorp.progressia;
|
||||||
|
|
||||||
|
import ru.windcorp.progressia.client.ClientProxy;
|
||||||
|
import ru.windcorp.progressia.client.graphics.GUI;
|
||||||
|
import ru.windcorp.progressia.client.graphics.backend.GraphicsBackend;
|
||||||
|
import ru.windcorp.progressia.client.graphics.backend.RenderTaskQueue;
|
||||||
|
import ru.windcorp.progressia.client.graphics.flat.FlatRenderProgram;
|
||||||
|
import ru.windcorp.progressia.client.graphics.font.GNUUnifontLoader;
|
||||||
|
import ru.windcorp.progressia.client.graphics.font.Typefaces;
|
||||||
|
import ru.windcorp.progressia.client.graphics.world.WorldRenderProgram;
|
||||||
|
import ru.windcorp.progressia.client.localization.Localizer;
|
||||||
|
import ru.windcorp.progressia.common.resource.ResourceManager;
|
||||||
import ru.windcorp.progressia.common.util.crash.CrashReports;
|
import ru.windcorp.progressia.common.util.crash.CrashReports;
|
||||||
import ru.windcorp.progressia.common.util.crash.analyzers.OutOfMemoryAnalyzer;
|
import ru.windcorp.progressia.common.util.crash.analyzers.OutOfMemoryAnalyzer;
|
||||||
import ru.windcorp.progressia.common.util.crash.providers.*;
|
import ru.windcorp.progressia.common.util.crash.providers.*;
|
||||||
|
import ru.windcorp.progressia.test.LayerTitle;
|
||||||
|
|
||||||
public class ProgressiaLauncher {
|
public class ProgressiaLauncher {
|
||||||
|
|
||||||
public static String[] arguments;
|
public static String[] arguments;
|
||||||
|
private static ClientProxy proxy;
|
||||||
|
|
||||||
public static void launch(String[] args, Proxy proxy) {
|
public static void launch(String[] args, ClientProxy inProxy) {
|
||||||
arguments = args.clone();
|
arguments = args.clone();
|
||||||
setupCrashReports();
|
setupCrashReports();
|
||||||
proxy.initialize();
|
|
||||||
|
inProxy.initialize();
|
||||||
|
proxy = inProxy;
|
||||||
|
GUI.addTopLayer(new LayerTitle("Title"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void play()
|
||||||
|
{
|
||||||
|
proxy.setupServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setupCrashReports() {
|
private static void setupCrashReports() {
|
||||||
|
@ -38,7 +38,9 @@ public class ClientProxy implements Proxy {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
|
|
||||||
GraphicsBackend.initialize();
|
GraphicsBackend.initialize();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RenderTaskQueue.waitAndInvoke(FlatRenderProgram::init);
|
RenderTaskQueue.waitAndInvoke(FlatRenderProgram::init);
|
||||||
RenderTaskQueue.waitAndInvoke(WorldRenderProgram::init);
|
RenderTaskQueue.waitAndInvoke(WorldRenderProgram::init);
|
||||||
@ -47,21 +49,26 @@ public class ClientProxy implements Proxy {
|
|||||||
.setDefault(GNUUnifontLoader.load(ResourceManager.getResource("assets/unifont-13.0.03.hex.gz")))
|
.setDefault(GNUUnifontLoader.load(ResourceManager.getResource("assets/unifont-13.0.03.hex.gz")))
|
||||||
);
|
);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
throw CrashReports.report(e, "ClientProxy failed");
|
throw CrashReports.report(e, "Menu launch failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
Localizer.getInstance().setLanguage("en-US");
|
Localizer.getInstance().setLanguage("en-US");
|
||||||
|
|
||||||
TestContent.registerContent();
|
TestContent.registerContent();
|
||||||
|
|
||||||
Atlases.loadAllAtlases();
|
Atlases.loadAllAtlases();
|
||||||
|
|
||||||
AudioSystem.initialize();
|
AudioSystem.initialize();
|
||||||
|
|
||||||
ServerState.startServer();
|
|
||||||
ClientState.connectToLocalServer();
|
|
||||||
|
|
||||||
TestMusicPlayer.start();
|
TestMusicPlayer.start();
|
||||||
|
|
||||||
|
//setupServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setupServer()
|
||||||
|
{
|
||||||
|
ServerState.startServer();
|
||||||
|
ClientState.connectToLocalServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,10 +42,10 @@ public abstract class BasicButton extends Component {
|
|||||||
|
|
||||||
private boolean isPressed = false;
|
private boolean isPressed = false;
|
||||||
private final Collection<Consumer<BasicButton>> actions = Collections.synchronizedCollection(new ArrayList<>());
|
private final Collection<Consumer<BasicButton>> actions = Collections.synchronizedCollection(new ArrayList<>());
|
||||||
|
|
||||||
public BasicButton(String name, String label, Font labelFont) {
|
public BasicButton(String name, Label label) {
|
||||||
super(name);
|
super(name);
|
||||||
this.label = new Label(name + ".Label", labelFont, label);
|
this.label = label;
|
||||||
|
|
||||||
setLayout(new LayoutAlign(10));
|
setLayout(new LayoutAlign(10));
|
||||||
addChild(this.label);
|
addChild(this.label);
|
||||||
@ -103,6 +103,11 @@ public abstract class BasicButton extends Component {
|
|||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BasicButton(String name, String label, Font labelFont)
|
||||||
|
{
|
||||||
|
this(name, new Label(name + ".Label", labelFont, label));
|
||||||
|
}
|
||||||
|
|
||||||
public BasicButton(String name, String label) {
|
public BasicButton(String name, String label) {
|
||||||
this(name, label, new Font());
|
this(name, label, new Font());
|
||||||
|
@ -29,6 +29,10 @@ public class Button extends BasicButton {
|
|||||||
super(name, label, labelFont);
|
super(name, label, labelFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Button(String name, Label label) {
|
||||||
|
super(name, label);
|
||||||
|
}
|
||||||
|
|
||||||
public Button(String name, String label) {
|
public Button(String name, String label) {
|
||||||
this(name, label, new Font());
|
this(name, label, new Font());
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,10 @@
|
|||||||
*/
|
*/
|
||||||
package ru.windcorp.progressia.test;
|
package ru.windcorp.progressia.test;
|
||||||
|
|
||||||
|
import ru.windcorp.progressia.client.ClientState;
|
||||||
import ru.windcorp.progressia.client.graphics.Colors;
|
import ru.windcorp.progressia.client.graphics.Colors;
|
||||||
|
import ru.windcorp.progressia.client.graphics.GUI;
|
||||||
|
import ru.windcorp.progressia.client.graphics.Layer;
|
||||||
import ru.windcorp.progressia.client.graphics.font.Font;
|
import ru.windcorp.progressia.client.graphics.font.Font;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.Button;
|
import ru.windcorp.progressia.client.graphics.gui.Button;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.Checkbox;
|
import ru.windcorp.progressia.client.graphics.gui.Checkbox;
|
||||||
@ -25,6 +28,7 @@ import ru.windcorp.progressia.client.graphics.gui.Label;
|
|||||||
import ru.windcorp.progressia.client.graphics.gui.RadioButton;
|
import ru.windcorp.progressia.client.graphics.gui.RadioButton;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.RadioButtonGroup;
|
import ru.windcorp.progressia.client.graphics.gui.RadioButtonGroup;
|
||||||
import ru.windcorp.progressia.client.graphics.gui.menu.MenuLayer;
|
import ru.windcorp.progressia.client.graphics.gui.menu.MenuLayer;
|
||||||
|
import ru.windcorp.progressia.server.ServerState;
|
||||||
|
|
||||||
public class LayerButtonTest extends MenuLayer {
|
public class LayerButtonTest extends MenuLayer {
|
||||||
|
|
||||||
@ -60,8 +64,16 @@ public class LayerButtonTest extends MenuLayer {
|
|||||||
getCloseAction().run();
|
getCloseAction().run();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
getContent().addChild(new Button("Quit", "Quit").addAction(b -> {
|
getContent().addChild(new Button("Menu", "Menu").addAction(b -> {
|
||||||
System.exit(0);
|
//System.exit(0);
|
||||||
|
for (Layer layer : GUI.getLayers())
|
||||||
|
{
|
||||||
|
GUI.removeLayer(layer);
|
||||||
|
}
|
||||||
|
GUI.addTopLayer(new LayerTitle("Title"));
|
||||||
|
//ClientState.getInstance().;
|
||||||
|
|
||||||
|
//ServerState.getInstance().shutdown("Safe Exit");
|
||||||
}));
|
}));
|
||||||
|
|
||||||
getContent().takeFocus();
|
getContent().takeFocus();
|
||||||
|
35
src/main/java/ru/windcorp/progressia/test/LayerTitle.java
Normal file
35
src/main/java/ru/windcorp/progressia/test/LayerTitle.java
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package ru.windcorp.progressia.test;
|
||||||
|
|
||||||
|
import ru.windcorp.progressia.ProgressiaLauncher;
|
||||||
|
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.Button;
|
||||||
|
import ru.windcorp.progressia.client.graphics.gui.GUILayer;
|
||||||
|
import ru.windcorp.progressia.client.graphics.gui.Label;
|
||||||
|
import ru.windcorp.progressia.client.graphics.gui.layout.LayoutVertical;
|
||||||
|
import ru.windcorp.progressia.client.localization.MutableString;
|
||||||
|
import ru.windcorp.progressia.client.localization.MutableStringLocalized;
|
||||||
|
|
||||||
|
public class LayerTitle extends GUILayer {
|
||||||
|
|
||||||
|
public LayerTitle(String name) {
|
||||||
|
super(name, new LayoutVertical(20,10));
|
||||||
|
|
||||||
|
MutableString title = new MutableStringLocalized("Layer"+name+".Title");
|
||||||
|
Font titleFont = new Font().deriveBold().withColor(Colors.BLACK).withAlign(0.5f);
|
||||||
|
getRoot().addChild(new Label(name+".Title", titleFont, title));
|
||||||
|
|
||||||
|
Font buttonFont = titleFont;
|
||||||
|
MutableString playText = new MutableStringLocalized("Layer"+name+".Play");
|
||||||
|
getRoot().addChild(new Button(name+".Play", new Label(name+".Play", buttonFont, playText)).addAction(b -> {
|
||||||
|
GUI.removeLayer(this);
|
||||||
|
ProgressiaLauncher.play();}));
|
||||||
|
|
||||||
|
MutableString quitText = new MutableStringLocalized("Layer"+name+".Quit");
|
||||||
|
getRoot().addChild(new Button(name+"Quit", new Label(name+".Quit", buttonFont, quitText)).addAction(b -> {
|
||||||
|
System.exit(0);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -22,4 +22,9 @@ LayerTestGUI.PlacementModeHint = (Blocks %s Tiles: Ctrl + Mouse Wheel)
|
|||||||
LayerTestGUI.IsFullscreen = Fullscreen: %5s (F11)
|
LayerTestGUI.IsFullscreen = Fullscreen: %5s (F11)
|
||||||
LayerTestGUI.IsVSync = VSync: %5s (F12)
|
LayerTestGUI.IsVSync = VSync: %5s (F12)
|
||||||
|
|
||||||
LayerButtonTest.Title = Button Test
|
LayerButtonTest.Title = Button Test
|
||||||
|
|
||||||
|
LayerTitle.Title = Progressia
|
||||||
|
LayerTitle.Play = Play World
|
||||||
|
LayerTitle.Options = Options
|
||||||
|
LayerTitle.Quit = Quit
|
@ -22,4 +22,9 @@ LayerTestGUI.PlacementModeHint = (Блок %s плитки: Ctrl + прокру
|
|||||||
LayerTestGUI.IsFullscreen = Полный экран: %5s (F11)
|
LayerTestGUI.IsFullscreen = Полный экран: %5s (F11)
|
||||||
LayerTestGUI.IsVSync = Верт. синхр.: %5s (F12)
|
LayerTestGUI.IsVSync = Верт. синхр.: %5s (F12)
|
||||||
|
|
||||||
LayerButtonTest.Title = Тест Кнопок
|
LayerButtonTest.Title = Тест Кнопок
|
||||||
|
|
||||||
|
LayerTitle.Title = Прогрессия
|
||||||
|
LayerTitle.Play = ???????
|
||||||
|
LayerTitle.Options = ????????
|
||||||
|
LayerTitle.Quit = ????????
|
Reference in New Issue
Block a user