Fixed issue
Dependencies are now checked for gameplay templates in the 'Create Game' screen and the UI is updated accordingly.
import org.terasology.naming.Name;
import org.terasology.network.NetworkMode;
import org.terasology.registry.In;
+import org.terasology.rendering.nui.Canvas;
+import org.terasology.rendering.nui.Color;
import org.terasology.rendering.nui.CoreScreenLayer;
import org.terasology.rendering.nui.WidgetUtil;
import org.terasology.rendering.nui.animation.MenuAnimationSystems;
import org.terasology.rendering.nui.itemRendering.StringTextRenderer;
import org.terasology.rendering.nui.layers.mainMenu.savedGames.GameInfo;
import org.terasology.rendering.nui.layers.mainMenu.savedGames.GameProvider;
+//import org.terasology.rendering.nui.layers.mainMenu.selectModulesScreen.ModuleSelectionInfo;
import org.terasology.rendering.nui.layers.mainMenu.selectModulesScreen.SelectModulesScreen;
import org.terasology.rendering.nui.widgets.UIButton;
import org.terasology.rendering.nui.widgets.UIDropdown;
@@ -109,7 +112,6 @@ public String get() {
});
}
-
final UIText worldName = find("worldName", UIText.class);
setGameName(worldName);
@@ -140,6 +142,16 @@ public void set(Module value) {
public String getString(Module value) {
return value.getMetadata().getDisplayName().value();
}
+
+ @Override
+ public void draw(Module value, Canvas canvas)
+ {
+ canvas.getCurrentStyle().setTextColor(
+ validateModuleDependencies(value.getId())
+ ? Color.WHITE : Color.RED);
+ super.draw(value, canvas);
+ canvas.getCurrentStyle().setTextColor(Color.WHITE);
+ }
});
UILabel gameplayDescription = find("gameplayDescription", UILabel.class);
@@ -152,7 +164,6 @@ public String get() {
} else {
return "";
}
-
}
});
@@ -211,8 +222,20 @@ public String getString(WorldGeneratorInfo value) {
return "";
}
});
+
+ final UIButton playButton = find("play", UIButton.class);
+ playButton.bindEnabled(new Binding<Boolean>() {
+ @Override
+ public Boolean get() {
+ return validateModuleDependencies(gameplay.getSelection().getId());
}
+ @Override
+ public void set(Boolean value) {
+ playButton.setEnabled(value);
+ }
+ });
+ }
WidgetUtil.trySubscribe(this, "close", button -> triggerBackAnimation());
@@ -353,6 +376,11 @@ private void recursivelyAddModuleDependencies(Set<Name> modules, Name moduleName
}
}
+ private boolean validateModuleDependencies(Name moduleName) {
+ DependencyResolver resolver = new DependencyResolver(moduleManager.getRegistry());
+ return resolver.resolve(moduleName).isSuccess();
+ }
+
private void setSelectedGameplayModule(Module module) {
ModuleConfig moduleConfig = config.getDefaultModSelection();
if (moduleConfig.getDefaultGameplayModuleName().equals(module.getId().toString())) {
