Skip to content

Commit 021b7c2

Browse files
MpcsNicholasBatesNZ
authored andcommitted
Move ParameterAdapterManager to SolApplication
1 parent 9982401 commit 021b7c2

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

engine/src/main/java/org/destinationsol/SolApplication.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.destinationsol.game.SaveManager;
3131
import org.destinationsol.game.SolGame;
3232
import org.destinationsol.game.WorldConfig;
33+
import org.destinationsol.game.console.adapter.ParameterAdapterManager;
3334
import org.destinationsol.game.context.Context;
3435
import org.destinationsol.game.context.internal.ContextImpl;
3536
import org.destinationsol.menu.MenuScreens;
@@ -76,6 +77,7 @@ public class SolApplication implements ApplicationListener {
7677
private String fatalErrorMsg;
7778
private String fatalErrorTrace;
7879
private SolGame solGame;
80+
private ParameterAdapterManager parameterAdapterManager;
7981
private Context context;
8082

8183
private WorldConfig worldConfig;
@@ -125,6 +127,7 @@ public void create() {
125127
menuScreens = new MenuScreens(layouts, isMobile(), options);
126128

127129
inputManager.setScreen(this, menuScreens.main);
130+
parameterAdapterManager = ParameterAdapterManager.createCore(this);
128131
}
129132

130133
@Override
@@ -250,7 +253,6 @@ public void play(boolean tut, String shipName, boolean isNewGame) {
250253

251254
FactionInfo factionInfo = new FactionInfo();
252255
solGame = new SolGame(shipName, tut, isNewGame, commonDrawer, context, worldConfig);
253-
solGame.createParameterAdapter();
254256
factionDisplay = new FactionDisplay(solGame, factionInfo);
255257
inputManager.setScreen(this, solGame.getScreens().mainGameScreen);
256258
}
@@ -277,6 +279,10 @@ public SolGame getGame() {
277279
return solGame;
278280
}
279281

282+
public ParameterAdapterManager getParameterAdapterManager() {
283+
return parameterAdapterManager;
284+
}
285+
280286
public SolLayouts getLayouts() {
281287
return layouts;
282288
}

engine/src/main/java/org/destinationsol/game/SolGame.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
import org.destinationsol.game.asteroid.AsteroidBuilder;
3333
import org.destinationsol.game.attributes.RegisterUpdateSystem;
3434
import org.destinationsol.game.chunk.ChunkManager;
35-
import org.destinationsol.game.console.adapter.ParameterAdapterManager;
3635
import org.destinationsol.game.context.Context;
37-
import org.destinationsol.game.context.internal.ContextImpl;
3836
import org.destinationsol.game.drawables.DrawableDebugger;
3937
import org.destinationsol.game.drawables.DrawableManager;
4038
import org.destinationsol.game.farBg.FarBackgroundManagerOld;
@@ -97,7 +95,6 @@ public class SolGame {
9795
private final MountDetectDrawer mountDetectDrawer;
9896
private final TutorialManager tutorialManager;
9997
private final GalaxyFiller galaxyFiller;
100-
private ParameterAdapterManager parameterAdapterManager;
10198
private Hero hero;
10299
private float timeStep;
103100
private float time;
@@ -249,9 +246,6 @@ private void createAndSpawnMercenariesFromSave() {
249246
}
250247
}
251248

252-
public void createParameterAdapter() {
253-
parameterAdapterManager = ParameterAdapterManager.createCore(this.solApplication);
254-
}
255249
public void onGameEnd(Context context) {
256250
// If the hero tries to exit while dead, respawn them first, then save
257251
if (hero.isDead()) {
@@ -557,10 +551,4 @@ public HullConfigManager getHullConfigManager() {
557551
return hullConfigManager;
558552
}
559553

560-
public ParameterAdapterManager getParameterAdapterManager() {
561-
if (parameterAdapterManager == null) {
562-
parameterAdapterManager = ParameterAdapterManager.createCore(this.solApplication);
563-
}
564-
return parameterAdapterManager;
565-
}
566554
}

engine/src/main/java/org/destinationsol/game/console/CommandParameter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static <T> CommandParameter single(String name, Class<T> type, boolean re
7878
if (type.isArray()) {
7979
throw new IllegalArgumentException("The type of a simple CommandParameterDefinition must not be an array!");
8080
}
81-
ParameterAdapterManager parameterAdapterManager = ParameterAdapterManager.createCore(context.get(SolApplication.class));
81+
ParameterAdapterManager parameterAdapterManager = context.get(SolApplication.class).getParameterAdapterManager();
8282
return new CommandParameter(name, type, required, suggester, parameterAdapterManager, context);
8383
}
8484

@@ -112,7 +112,7 @@ public static <T> CommandParameter array(String name, Class<T> childType, Charac
112112
}
113113

114114
Class<?> type = getArrayClass(childType);
115-
ParameterAdapterManager parameterAdapterManager = ParameterAdapterManager.createCore(context.get(SolApplication.class));
115+
ParameterAdapterManager parameterAdapterManager = context.get(SolApplication.class).getParameterAdapterManager();
116116
return new CommandParameter(name, type, required, suggester, parameterAdapterManager, context);
117117
}
118118

0 commit comments

Comments
 (0)