-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
New create game flow backend | Part 2 #3383
New create game flow backend | Part 2 #3383
Conversation
Hooray Jenkins reported success with all tests good! |
Hooray Jenkins reported success with all tests good! |
Hooray Jenkins reported success with all tests good! |
Hooray Jenkins reported success with all tests good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done. I'm having trouble finding anything not trivial :-)
@@ -90,6 +90,7 @@ | |||
private Config config; | |||
|
|||
private boolean loadingAsServer; | |||
private UniverseWrapper universeWrapper; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a good candidate for some quick field javadoc
} | ||
|
||
SimpleUri uri = world.getWorldGeneratorInfo().getUri(); | ||
float timeOffset = 0.25f + 0.025f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Magic numbers? Might be an idea to extract info a constant that could also explain what the number means
* in which the player is about to spawn. | ||
* @param targetWorld The world in which the player is going to spawn. | ||
* @param targetWorldTexture The world texture generated in {@link WorldPreGenerationScreen} to be displayed on this | ||
* screen. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably just throw this one word back on the main line to keep it a one liner. I sometimes finding myself rewriting javadoc slightly to make more one liners for how nicely it lines up stuff :-)
public class UniverseSetupScreen extends CoreScreenLayer { | ||
|
||
public static final ResourceUrn ASSET_URI = new ResourceUrn("engine:universeSetupScreen"); | ||
List<WorldSetupWrapper> worlds = Lists.newArrayList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the intended access modifier for these two vars, or did you forgot to add in public
or private
?
@@ -188,10 +243,118 @@ private void recursivelyAddModuleDependencies(Set<Name> modules, Name moduleName | |||
} | |||
} | |||
|
|||
/** | |||
* Called whenever the user decides to create a new world. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"create" -> "add" ? Might be a subtle difference or a subjective call. Adding a new entry to a list vs creating a new entry to a list.
*/ | ||
package org.terasology.rendering.nui.layers.mainMenu; | ||
|
||
public class UniverseWrapper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one could definitely use some quick class level javadoc, although I do think the concept is readily understandable :-)
private int seedNumber = 0; | ||
|
||
|
||
public WorldPreGenerationScreen() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you actually need this constructor? Utility classes usually have a private default constructor to disallow instantiation, but this seems a normal class and you get that constructor for free
* Generates a texture and set's to the image view, thus previewing the world. | ||
*/ | ||
private void genTexture() { | ||
int imgWidth = 384; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the size be variable in case the user resizes the window? If not maybe extract to a constant or two.
Resizing support could be added later, not important right now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set's -> sets
..sets it to..
You really need to be careful with your apostrophes.
Class<? extends Component> clazz = params.get(key).getClass(); | ||
Component comp = config.getModuleConfig(worldGenerator.getUri(), key, clazz); | ||
if (comp != null) { | ||
worldConfig.setProperty(key, comp); // use the data from the config instead of defaults |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally I try to put comments above a line instead of later on the line. That might be personal preference and situational however.
protected WorldConfigNumberBinding(WorldConfigurator config, String label, ComponentLibrary compLib, FieldMetadata<Object, ?> field) { | ||
Class<?> type = field.getType(); | ||
if (type == Integer.TYPE || type == Integer.class) { | ||
this.binding = new WorldSetupScreen.WorldConfigBinding<>(config, label, compLib, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't really need to include a line break here, on a single line this is 138 chars, not too bad, our style warning is at 175 IIRC. Again somewhat personal/situational
Hooray Jenkins reported success with all tests good! |
Hooray Jenkins reported success with all tests good! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly minor style/jd changes.
@@ -91,6 +91,11 @@ | |||
|
|||
private boolean loadingAsServer; | |||
|
|||
/** | |||
* A UniverseWrapper object used here to determine if the game is single player or multi-player. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency. Either use single-player
or multi player
, but not both - and specially not in the same line.
public static final ResourceUrn ASSET_URI = new ResourceUrn("engine:startPlayingScreen"); | ||
private Texture texture; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, let's try to maintain with the codebase at large. Almost everywhere we start with public static final variables at top, followed by public and private variables. So let's move ASSET_URI to the top.
Also, not a huge fan of "ASSET_URI" - it does not really tell me what the asset is. See if you can come up with a better name for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every screen's urn in the game has been given the name "ASSET_URI". So I used the same on all my screens, for keeping it uniform. :-)
|
||
SimpleUri uri = world.getWorldGeneratorInfo().getUri(); | ||
// This is multiplied by the number of seconds in a day (86400000) to determine the exact millisecond at which the game will start. | ||
float timeOffset = 0.50f; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason to not make timeOffset final?
public class UniverseSetupScreen extends CoreScreenLayer { | ||
|
||
public static final ResourceUrn ASSET_URI = new ResourceUrn("engine:universeSetupScreen"); | ||
private List<WorldSetupWrapper> worlds = Lists.newArrayList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sigh, the "ASSET_URI" seems to be way too common in this part of the codebase.
@In | ||
private ModuleManager moduleManager; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that everywhere in TS code base (including the other class you modified in this PR) you leave a newline b/w two consecutive @in variables. Revert these deletions.
|
||
/** | ||
* Updates the preview according to any changes to made the configurator. | ||
* Also pops up a message and keeps track of percentage world preview prepared. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..made to the configurator..
/** | ||
* This method takes the name of the selected world as String and return the corresponding | ||
* WorldSetupWrapper object. | ||
* @return {@link WorldSetupWrapper} object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not helpful.
@In | ||
private WorldGeneratorManager worldGeneratorManager; | ||
@In | ||
private Config config; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So two In variables have no newline, but one does? Wut?
/** | ||
* This method sets the world whose properties are to changed. This function is called before the screen comes | ||
* to the forefront. | ||
* @param subContext As there is a new environment created in the {@link UniverseSetupScreen}, it's passed to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See previous comment.
/** | ||
* This class only has significance during the create game phase. | ||
* Every world is a object of this class. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an object
Contains
The backend of the new create game flow. The player can now select different world generators and add a number of worlds to the game. Each world has a unique seed and the seed you see on the
AdvanceGameSetupScreen
is for the Universe. Each world is previewable individually on theWorldPreGenerationScreen
. You have the option to configure and change the properties of your world in bothUniverseSetupScreen
andWorldPreGenerationScreen
. There is a configure button which leads you to theWorldSetupScreen
where properties can be edited and the changes are successfully previewed in theWorldPreGenerationScreen
.Outstanding before merging
A video of what's done: https://www.youtube.com/watch?v=qhKGQjEONmA