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!: remove multi-world support #5116

Merged
merged 25 commits into from
Jul 17, 2023
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
801b001
remove PreviewWorldScreen
skaldarnar Jul 10, 2023
8c5ce9b
refactor: remove WorldSetupWrapper list from StartPlayingScreen logic
jdrueckert Jul 10, 2023
8913414
refactor: selectedWorld as WorldSetupWrapper instead of String
jdrueckert Jul 10, 2023
201fb73
refactor: remove world list from WorldPreGenerationScreen.java
jdrueckert Jul 10, 2023
51bff50
refactor: disallow adding more than one world
jdrueckert Jul 10, 2023
2c40421
refactor: replace world list with single WorldSetupWrapper
jdrueckert Jul 10, 2023
c95ecf8
refactor: remove world counter
jdrueckert Jul 10, 2023
5ec2b07
refactor: world into selectedWorld
jdrueckert Jul 10, 2023
a98f478
refactor: remove copyOfSelectedWorld
jdrueckert Jul 10, 2023
3f091ba
refactor: remove 'add' and 'config' logic from Universe Setup Screen
skaldarnar Jul 13, 2023
94b9c54
refactor(ui): remove unused elements via NUI editor
skaldarnar Jul 13, 2023
d5767c7
ui: remove multi-world warning
jdrueckert Jul 13, 2023
478d589
ui: adjust universe setup description message
jdrueckert Jul 13, 2023
60a0a4b
refactor: mark UniverseSetupScreen#worldNames as deprecated
skaldarnar Jul 13, 2023
5527f6f
refactor: remove worlds dropdowns from WorldPreGeneration and WorldSe…
skaldarnar Jul 13, 2023
1a24962
ui: adjust world pregeneration screen description message
jdrueckert Jul 13, 2023
b36e329
i18n: internationalize world name label in world setup screen
jdrueckert Jul 13, 2023
20782e3
chore: remove unused method UniverseSetupScreen#refreshWorldDropdown
skaldarnar Jul 13, 2023
292ee8c
fix: prevent 'CoreWorlds:heightMap' from being added to the list of w…
skaldarnar Jul 13, 2023
4ed5616
chore: fix checkstyle findings
jdrueckert Jul 13, 2023
0d097d3
Merge branch 'develop' into refactor/remove-multi-world
jdrueckert Jul 13, 2023
685f97a
chore: fix checkstyle warning
jdrueckert Jul 13, 2023
05ef068
Merge branch 'develop' into refactor/remove-multi-world
jdrueckert Jul 16, 2023
f9065c5
chore: remove no-longer used deprecated method
jdrueckert Jul 16, 2023
ae6e043
Merge branch 'develop' into refactor/remove-multi-world
jdrueckert Jul 16, 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 @@ -68,7 +68,7 @@
public class UniverseSetupScreen extends CoreScreenLayer {
public static final ResourceUrn ASSET_URI = new ResourceUrn("engine:universeSetupScreen");

private static final Logger logger = LoggerFactory.getLogger(UniverseSetupScreen.class);

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

View check run for this annotation

Terasology Jenkins.io / PMD

UnusedPrivateField

NORMAL: Avoid unused private fields such as 'logger'.
Raw output
Detects when a private field is declared and/or assigned a value, but not used. Since PMD 6.50.0 private fields are ignored, if the fields are annotated with any annotation or the enclosing class has any annotation. Annotations often enable a framework (such as dependency injection, mocking or e.g. Lombok) which use the fields by reflection or other means. This usage can't be detected by static code analysis. Previously these frameworks where explicitly allowed by listing their annotations in the property "ignoredAnnotations", but that turned out to be prone of false positive for any not explicitly considered framework. <pre> <code> public class Something { private static int FOO = 2; // Unused private int i = 5; // Unused private int j = 6; public int addOne() { return j++; } } </code> </pre> <a href="https://pmd.github.io/pmd-6.53.0/pmd_rules_java_bestpractices.html#unusedprivatefield"> See PMD documentation. </a>

@In
private WorldGeneratorManager worldGeneratorManager;
Expand Down Expand Up @@ -144,61 +144,15 @@
}
});
}
final UIDropdownScrollable worldsDropdown = find("worlds", UIDropdownScrollable.class);
worldsDropdown.bindSelection(new Binding<String>() {
@Override
public String get() {
if (selectedWorld != null) {
return selectedWorld.getWorldName().toString();
} else {
return "";
}
}

@Override
public void set(String value) {
selectedWorld.setWorldName(new Name(value));
}
});

WidgetUtil.trySubscribe(this, "close", button ->
triggerBackAnimation()
);

WidgetUtil.trySubscribe(this, "worldConfig", button -> {
final WorldSetupScreen worldSetupScreen = getManager().createScreen(WorldSetupScreen.ASSET_URI, WorldSetupScreen.class);
try {
if (selectedWorld != null || !selectedWorld.getWorldName().isEmpty()) {
worldSetupScreen.setWorld(context, selectedWorld, worldsDropdown);
triggerForwardAnimation(worldSetupScreen);
} else {
getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class)
.setMessage("Worlds List Empty!", "No world found to configure.");
}
} catch (UnresolvedWorldGeneratorException e) {
logger.error("Can't configure the world! due to {}", e.getMessage());
}
});

WidgetUtil.trySubscribe(this, "addGenerator", button -> {
//TODO: there should not be a reference from the engine to some module - the engine must be agnostic to what
// modules may do
if (worldGenerator.getSelection().getUri().toString().equals("CoreWorlds:heightMap")) {
getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class)
.setMessage("HeightMap not supported",
"HeightMap is not supported for advanced setup right now, a game template will be introduced soon.");
} else if (selectedWorld != null) {
getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class)
.setMessage("World Already Created", "You can only add one world.");
} else {
addNewWorld(worldGenerator.getSelection());
worldsDropdown.setOptions(worldNames());
}
});

WidgetUtil.trySubscribe(this, "continue", button -> {
final WorldPreGenerationScreen worldPreGenerationScreen =
getManager().createScreen(WorldPreGenerationScreen.ASSET_URI, WorldPreGenerationScreen.class);
addNewWorld(worldGenerator.getSelection());
if (selectedWorld != null) {
final WaitPopup<Boolean> loadPopup = getManager().pushScreen(WaitPopup.ASSET_URI, WaitPopup.class);
loadPopup.setMessage("Loading", "please wait ...");
Expand All @@ -212,11 +166,11 @@
});
loadPopup.startOperation(() -> {
try {
worldPreGenerationScreen.setEnvironment(context);
} catch (UnresolvedWorldGeneratorException e) {
return false;
}
return true;

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

View check run for this annotation

Terasology Jenkins.io / SpotBugs

THROWS_METHOD_THROWS_CLAUSE_BASIC_EXCEPTION

LOW: Method lists Exception in its throws clause.
Raw output
no message found
}, true);
} else {
getManager().pushScreen(MessagePopup.ASSET_URI, MessagePopup.class)
Expand All @@ -233,11 +187,7 @@
public void onOpened() {
super.onOpened();

selectedWorld = null;
final UIDropdownScrollable worldsDropdown = find("worlds", UIDropdownScrollable.class);
if (worldsDropdown != null) {
worldsDropdown.setOptions(worldNames());
}
selectedWorld = null;
}

private Set<Name> getAllEnabledModuleNames() {
Expand Down Expand Up @@ -275,8 +225,9 @@
* This method refreshes the worlds drop-down menu when world name is changed and updates variable selectedWorld.
* @param worldsDropdown the drop-down to work on
*/
@Deprecated

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

View check run for this annotation

Terasology Jenkins.io / CheckStyle

MissingDeprecatedCheck

NORMAL: Must include both @java.lang.Deprecated annotation and @deprecated Javadoc tag with description.
Raw output
<p>Since Checkstyle 5.0</p><p> Verifies that both the java.lang.Deprecated annotation is present and the @deprecated Javadoc tag is present when either is present.</p>
public void refreshWorldDropdown(UIDropdownScrollable worldsDropdown) {
worldsDropdown.setOptions(worldNames());
// no-op
jdrueckert marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down Expand Up @@ -352,7 +303,7 @@
* @return the selected world in the drop-down.
*/
public WorldSetupWrapper getSelectedWorld() {
return selectedWorld;

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

View check run for this annotation

Terasology Jenkins.io / SpotBugs

EI_EXPOSE_REP

LOW: org.terasology.engine.rendering.nui.layers.mainMenu.UniverseSetupScreen.getSelectedWorld() may expose internal representation by returning UniverseSetupScreen.selectedWorld
Raw output
<p> Returning a reference to a mutable object value stored in one of the object's fields exposes the internal representation of the object.&nbsp; If instances are accessed by untrusted code, and unchecked changes to the mutable object would compromise security or other important properties, you will need to do something different. Returning a new copy of the object is better approach in many situations.</p>
}

@Override
Expand Down
Loading