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

New create game flow backend | Part 2 #3383

Merged
merged 22 commits into from
Jun 7, 2018

Conversation

TheFlash98
Copy link
Member

@TheFlash98 TheFlash98 commented Jun 5, 2018

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 the WorldPreGenerationScreen. You have the option to configure and change the properties of your world in both UniverseSetupScreen and WorldPreGenerationScreen. There is a configure button which leads you to the WorldSetupScreen where properties can be edited and the changes are successfully previewed in the WorldPreGenerationScreen.

Outstanding before merging

  • Making a world with Height Map causes a crash.
  • Game title (?)

A video of what's done: https://www.youtube.com/watch?v=qhKGQjEONmA

@TheFlash98 TheFlash98 changed the title New create game New create game flow backend | Part 2 Jun 5, 2018
@GooeyHub
Copy link
Member

GooeyHub commented Jun 5, 2018

Hooray Jenkins reported success with all tests good!

@GooeyHub
Copy link
Member

GooeyHub commented Jun 7, 2018

Hooray Jenkins reported success with all tests good!

@GooeyHub
Copy link
Member

GooeyHub commented Jun 7, 2018

Hooray Jenkins reported success with all tests good!

@GooeyHub
Copy link
Member

GooeyHub commented Jun 7, 2018

Hooray Jenkins reported success with all tests good!

Copy link
Member

@Cervator Cervator left a 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;
Copy link
Member

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;
Copy link
Member

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.
Copy link
Member

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();
Copy link
Member

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.
Copy link
Member

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 {
Copy link
Member

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() {
Copy link
Member

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;
Copy link
Member

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

Copy link
Contributor

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
Copy link
Member

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,
Copy link
Member

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

@GooeyHub
Copy link
Member

GooeyHub commented Jun 7, 2018

Hooray Jenkins reported success with all tests good!

@GooeyHub
Copy link
Member

GooeyHub commented Jun 7, 2018

Hooray Jenkins reported success with all tests good!

@Cervator Cervator merged commit 8830a3d into MovingBlocks:create-game-v2 Jun 7, 2018
@Cervator Cervator added this to the v3.0.0 milestone Jun 7, 2018
Copy link
Contributor

@vampcat vampcat left a 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.
Copy link
Contributor

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;
Copy link
Contributor

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.

Copy link
Member Author

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;
Copy link
Contributor

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();
Copy link
Contributor

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;

Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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;
Copy link
Contributor

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
Copy link
Contributor

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.
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an object

@TheFlash98
Copy link
Member Author

theflash98 & multi-world

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants