Enable setting the visual via argument

This commit is contained in:
2020-07-20 11:22:55 +02:00
parent 87a53149c9
commit e57aa23c8e
2 changed files with 22 additions and 3 deletions

View File

@@ -2,6 +2,8 @@ package de.siphalor.was;
import de.siphalor.was.content.lang.I18n;
import de.siphalor.was.util.Util;
import de.siphalor.was.visual.ConsoleVisual;
import de.siphalor.was.visual.JFXVisual;
import java.util.logging.Level;
@@ -9,6 +11,16 @@ public class Start {
public static void main(String[] args) {
WhatAStorage was = WhatAStorage.getInstance();
was.reload();
if (args.length > 0) {
switch (args[0]) {
case "jfx" -> was.setVisual(new JFXVisual());
case "console" -> was.setVisual(new ConsoleVisual());
}
} else {
was.setVisual(new JFXVisual());
}
was.setup();
Util.LOGGER.log(Level.INFO, I18n.getInstance().getString("test.hello-world"));

View File

@@ -10,11 +10,13 @@ import de.siphalor.was.content.quest.Quest;
import de.siphalor.was.content.quest.QuestGenerator;
import de.siphalor.was.content.quest.QuestManager;
import de.siphalor.was.content.quest.RandomQuestGenerator;
import de.siphalor.was.game.*;
import de.siphalor.was.game.Balance;
import de.siphalor.was.game.Options;
import de.siphalor.was.game.Storage;
import de.siphalor.was.game.Transaction;
import de.siphalor.was.util.Pair;
import de.siphalor.was.util.Util;
import de.siphalor.was.visual.ConsoleVisual;
import de.siphalor.was.visual.JFXVisual;
import de.siphalor.was.visual.Visual;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -59,8 +61,10 @@ public class WhatAStorage {
productManager = new ProductManager();
questManager = new QuestManager();
options = new Options();
}
visual = new ConsoleVisual();
public void setVisual(Visual visual) {
this.visual = visual;
}
public ContentManager getContentManager() {
@@ -103,6 +107,9 @@ public class WhatAStorage {
}
public void setup() {
if (visual == null) {
throw new IllegalStateException("No visual set for WhatAStorage!");
}
visual.setup(this);
}