Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: merge universe setup into world pregen screen #5122

Merged
merged 45 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
fcf8723
refactor: merge StartPlaying screen into WorldPreGeneration screen
jdrueckert Jul 13, 2023
b02c473
remove unused code
skaldarnar Jul 18, 2023
dc0b5a5
ui: merge world pregen screen elements into universe setup screen
jdrueckert Jul 17, 2023
c96c4c6
refactor: move code from WorldPreGenerationScreen to UniverseSetupScreen
jdrueckert Jul 17, 2023
55ab06b
ui: add seed field
jdrueckert Jul 17, 2023
a883a24
refactor: reuse universe seed for world, properly randomize on re-roll
jdrueckert Jul 17, 2023
3f52956
refactor: create new WorldSetupWrapper on world generator selection
jdrueckert Jul 17, 2023
df3f0f9
refactor: get/set seed always from/in universe wrapper
jdrueckert Jul 17, 2023
afc1eb8
refactor: get/set selected world from/in universe wrapper
jdrueckert Jul 17, 2023
06217b5
chore: only do something if different world generator selected
jdrueckert Jul 17, 2023
0f2082b
set world info initially and remove unncessary preview gen code from …
skaldarnar Jul 20, 2023
55073dc
chore: remove unused imports
jdrueckert Jul 20, 2023
89e1f8f
refactor: always set world generator when setting target world
jdrueckert Jul 20, 2023
fbc0757
chore: remove no longer used worldpregen screen and ui
jdrueckert Jul 20, 2023
17d911e
chore: remove unnecessary world generator check and duplicated previe…
jdrueckert Jul 20, 2023
0a26c4d
refactor: remove worldGeneratorInfo from worldSetupWrapper
jdrueckert Jul 20, 2023
bb7fab6
refactor: merge WorldSetupWrapper into UniverseWrapper
jdrueckert Jul 20, 2023
2102121
fix: auto-completion typo
jdrueckert Jul 20, 2023
4b15e6d
refactor: remove custom title from WorldInfo
jdrueckert Jul 20, 2023
c0ac3d7
refactor: remove world name UI elements
jdrueckert Jul 20, 2023
1e8e5f9
refactor: remove worldName from universeWrapper
jdrueckert Jul 20, 2023
97f180b
refactor: extract setSeed method
jdrueckert Jul 26, 2023
8c45a23
Merge remote-tracking branch 'origin/develop' into refactor/merge-uni…
jdrueckert Aug 9, 2023
7234d46
refactor: create context earlier and store universe wrapper in it
jdrueckert Aug 9, 2023
d27bdb6
fix: put UniverseWrapper into CoreRegistry instead of context
jdrueckert Oct 15, 2023
3632055
refactor: return empty string if seed is null
jdrueckert Oct 15, 2023
a0ccb20
feat: save modified seed when going back to AGS screen
jdrueckert Oct 15, 2023
194f87d
feat: update preview on manual seed change
jdrueckert Oct 15, 2023
617dd1f
feat: update preview on opening screen
jdrueckert Oct 15, 2023
0701a8e
Merge branch 'develop' into refactor/merge-universe-into-world-pregen…
jdrueckert Oct 15, 2023
3cd4817
checkstyle: remove unused imports
jdrueckert Oct 15, 2023
83d0a25
Merge remote-tracking branch 'origin/refactor/merge-universe-into-wor…
jdrueckert Oct 15, 2023
8c870ec
checkstyle: fix long line finding
jdrueckert Oct 15, 2023
656098c
Merge branch 'develop' into refactor/merge-universe-into-world-pregen…
jdrueckert Oct 16, 2023
a0b7f35
refactor: minor cleanups
jdrueckert Oct 16, 2023
ff41975
Merge remote-tracking branch 'origin/refactor/merge-universe-into-wor…
jdrueckert Oct 16, 2023
2386627
Merge branch 'develop' into refactor/merge-universe-into-world-pregen…
jdrueckert Oct 18, 2023
c3a0bd2
qa: remove unnecessary local before return
jdrueckert Oct 22, 2023
e5f023c
Merge branch 'develop' into refactor/merge-universe-into-world-pregen…
jdrueckert Oct 22, 2023
5c2cb32
qa: if statement nesting not necessary
jdrueckert Oct 22, 2023
f1431ca
qa: remove unused local variable
jdrueckert Oct 22, 2023
6ae1c68
qa: remove unused local variable
jdrueckert Oct 22, 2023
cd21b6f
refactor: address review comments
jdrueckert Oct 30, 2023
d48ae6d
Merge branch 'develop' into refactor/merge-universe-into-world-pregen…
jdrueckert Nov 6, 2023
3ff1e7c
Merge branch 'develop' into refactor/merge-universe-into-world-pregen…
jdrueckert Nov 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public GameManifest createGameManifest() {

gameManifest.setTitle(worldGenConfig.getWorldTitle());
gameManifest.setSeed(worldGenConfig.getDefaultSeed());
WorldInfo worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD, worldGenConfig.getWorldTitle(), gameManifest.getSeed(),
WorldInfo worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD, gameManifest.getSeed(),
(long) (WorldTime.DAY_LENGTH * WorldTime.NOON_OFFSET), worldGeneratorUri);
gameManifest.addWorld(worldInfo);
return gameManifest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0
package org.terasology.engine.rendering.nui.layers.mainMenu;

import com.google.common.collect.Maps;
import org.codehaus.plexus.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -13,16 +12,14 @@
import org.terasology.engine.game.GameManifest;
import org.terasology.engine.registry.In;
import org.terasology.engine.rendering.nui.layers.mainMenu.savedGames.GameProvider;
import org.terasology.engine.rendering.world.WorldSetupWrapper;
import org.terasology.engine.world.generator.WorldConfigurator;
import org.terasology.engine.world.generator.WorldGenerator;
import org.terasology.engine.world.internal.WorldInfo;
import org.terasology.engine.world.time.WorldTime;
import org.terasology.gestalt.entitysystem.component.Component;
import org.terasology.gestalt.module.Module;
import org.terasology.gestalt.module.dependencyresolution.DependencyResolver;
import org.terasology.gestalt.module.dependencyresolution.ResolutionResult;

import java.util.Map;

/**
* Generates new games manifest according to input data.
*/
Expand All @@ -39,7 +36,7 @@
/**
* Generates game manifest with default settings (title, seed) if not specified.
* Uses default world generator, and modules selection.
* TODO: rewrite/fix it when code will be more stable

Check warning on line 39 in engine/src/main/java/org/terasology/engine/rendering/nui/layers/mainMenu/GameManifestProvider.java

View check run for this annotation

Terasology Jenkins.io / Open Tasks Scanner

TODO

NORMAL: rewrite/fix it when code will be more stable
*
* @param universeWrapper contains the universe level properties
* @param moduleManager resolves modules
Expand Down Expand Up @@ -67,30 +64,25 @@

SimpleUri uri;
String seed;
WorldSetupWrapper worldSetup = universeWrapper.getTargetWorld();
if (worldSetup != null) {
uri = worldSetup.getWorldGenerator().getUri();
seed = worldSetup.getWorldGenerator().getWorldSeed();
WorldGenerator worldGenerator = universeWrapper.getWorldGenerator();
if (worldGenerator != null) {
uri = worldGenerator.getUri();
seed = worldGenerator.getWorldSeed();
} else {
uri = config.getWorldGeneration().getDefaultGenerator();
seed = universeWrapper.getSeed();
}
gameManifest.setSeed(seed);

String targetWorldName = "";
Map<String, Component> worldConfig = Maps.newHashMap();
if (worldSetup != null) {
targetWorldName = worldSetup.getWorldName().toString();
if (worldSetup.getWorldConfigurator() != null) {

// horrible hack to get configs into manifest.
// config driven by CreateWorldEntity.
// world config set somewhere else as well no clear drive from config --> world
gameManifest.setModuleConfigs(uri, worldSetup.getWorldConfigurator().getProperties());
}
WorldConfigurator worldConfigurator = universeWrapper.getWorldConfigurator();
if (worldConfigurator != null) {
// horrible hack to get configs into manifest.
// config driven by CreateWorldEntity.
// world config set somewhere else as well no clear drive from config --> world
gameManifest.setModuleConfigs(uri, worldConfigurator.getProperties());
}
// This is multiplied by the number of seconds in a day (86400000) to determine the exact millisecond at which the game will start.
WorldInfo worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD, targetWorldName, seed,
WorldInfo worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD, seed,
(long) (WorldTime.DAY_LENGTH * WorldTime.SUNRISE_OFFSET), uri);

gameManifest.addWorld(worldInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public String get() {
AdvancedGameSetupScreen advancedSetupGameScreen = getManager().createScreen(AdvancedGameSetupScreen.ASSET_URI, AdvancedGameSetupScreen.class);
WidgetUtil.trySubscribe(this, "advancedSetup", button -> {
universeWrapper.setGameName(gameName.getText());
advancedSetupGameScreen.setUniverseWrapper(universeWrapper);
advancedSetupGameScreen.setEnvironment(universeWrapper);
triggerForwardAnimation(advancedSetupGameScreen);
});

Expand Down Expand Up @@ -281,12 +281,10 @@ public void setUniverseWrapper(UniverseWrapper wrapper) {

@Override
public boolean onKeyEvent(NUIKeyEvent event) {
if (event.isDown() && event.getKey() == Keyboard.Key.ESCAPE) {
if (GameProvider.isSavesFolderEmpty()) {
// skip selectGameScreen and get back directly to main screen
getManager().pushScreen("engine:mainMenuScreen");
return true;
}
if (event.isDown() && event.getKey() == Keyboard.Key.ESCAPE && GameProvider.isSavesFolderEmpty()) {
// skip selectGameScreen and get back directly to main screen
getManager().pushScreen("engine:mainMenuScreen");
return true;
}
return super.onKeyEvent(event);
}
Expand Down
Loading
Loading