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:
opfromthestart 2021-08-03 19:42:04 -04:00
parent eace6733ce
commit a9ca5f6b17
8 changed files with 108 additions and 15 deletions

View File

@ -18,18 +18,38 @@
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.analyzers.OutOfMemoryAnalyzer;
import ru.windcorp.progressia.common.util.crash.providers.*;
import ru.windcorp.progressia.test.LayerTitle;
public class ProgressiaLauncher {
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();
setupCrashReports();
proxy.initialize();
inProxy.initialize();
proxy = inProxy;
GUI.addTopLayer(new LayerTitle("Title"));
}
public static void play()
{
proxy.setupServer();
}
private static void setupCrashReports() {

View File

@ -38,7 +38,9 @@ public class ClientProxy implements Proxy {
@Override
public void initialize() {
GraphicsBackend.initialize();
try {
RenderTaskQueue.waitAndInvoke(FlatRenderProgram::init);
RenderTaskQueue.waitAndInvoke(WorldRenderProgram::init);
@ -47,7 +49,7 @@ public class ClientProxy implements Proxy {
.setDefault(GNUUnifontLoader.load(ResourceManager.getResource("assets/unifont-13.0.03.hex.gz")))
);
} catch (InterruptedException e) {
throw CrashReports.report(e, "ClientProxy failed");
throw CrashReports.report(e, "Menu launch failed");
}
Localizer.getInstance().setLanguage("en-US");
@ -58,10 +60,15 @@ public class ClientProxy implements Proxy {
AudioSystem.initialize();
TestMusicPlayer.start();
//setupServer();
}
public void setupServer()
{
ServerState.startServer();
ClientState.connectToLocalServer();
TestMusicPlayer.start();
}
}

View File

@ -43,9 +43,9 @@ public abstract class BasicButton extends Component {
private boolean isPressed = false;
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);
this.label = new Label(name + ".Label", labelFont, label);
this.label = label;
setLayout(new LayoutAlign(10));
addChild(this.label);
@ -104,6 +104,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) {
this(name, label, new Font());
}

View File

@ -29,6 +29,10 @@ public class Button extends BasicButton {
super(name, label, labelFont);
}
public Button(String name, Label label) {
super(name, label);
}
public Button(String name, String label) {
this(name, label, new Font());
}

View File

@ -17,7 +17,10 @@
*/
package ru.windcorp.progressia.test;
import ru.windcorp.progressia.client.ClientState;
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.gui.Button;
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.RadioButtonGroup;
import ru.windcorp.progressia.client.graphics.gui.menu.MenuLayer;
import ru.windcorp.progressia.server.ServerState;
public class LayerButtonTest extends MenuLayer {
@ -60,8 +64,16 @@ public class LayerButtonTest extends MenuLayer {
getCloseAction().run();
}));
getContent().addChild(new Button("Quit", "Quit").addAction(b -> {
System.exit(0);
getContent().addChild(new Button("Menu", "Menu").addAction(b -> {
//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();

View 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);
}));
}
}

View File

@ -23,3 +23,8 @@ LayerTestGUI.IsFullscreen = Fullscreen: %5s (F11)
LayerTestGUI.IsVSync = VSync: %5s (F12)
LayerButtonTest.Title = Button Test
LayerTitle.Title = Progressia
LayerTitle.Play = Play World
LayerTitle.Options = Options
LayerTitle.Quit = Quit

View File

@ -23,3 +23,8 @@ LayerTestGUI.IsFullscreen = Полный экран: %5s (F11)
LayerTestGUI.IsVSync = Верт. синхр.: %5s (F12)
LayerButtonTest.Title = Тест Кнопок
LayerTitle.Title = Прогрессия
LayerTitle.Play = ???????
LayerTitle.Options = ????????
LayerTitle.Quit = ????????