use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.
the class SortOrderSystem method postBegin.
/**
* Initializes sort order.
*/
public void postBegin() {
initialized = true;
controlPressed = false;
Map<Integer, BindableButton> keys = bindsManager.getKeyBinds();
BindButtonSubscriber controlSubscriber = new BindButtonSubscriber() {
@Override
public boolean onPress(float delta, EntityRef target) {
if (!containsConsole()) {
controlPressed = true;
} else {
controlPressed = false;
}
return false;
}
@Override
public boolean onRepeat(float delta, EntityRef target) {
return false;
}
@Override
public boolean onRelease(float delta, EntityRef target) {
controlPressed = false;
return false;
}
};
BindButtonSubscriber tabSubscriber = new BindButtonSubscriber() {
@Override
public boolean onPress(float delta, EntityRef target) {
if (controlPressed) {
target.send(new FocusChangedEvent());
}
return false;
}
@Override
public boolean onRepeat(float delta, EntityRef target) {
if (controlPressed) {
target.send(new FocusChangedEvent());
}
return false;
}
@Override
public boolean onRelease(float delta, EntityRef target) {
return false;
}
};
if (keys.containsKey(Keyboard.Key.RIGHT_CTRL.getId())) {
keys.get(Keyboard.Key.RIGHT_CTRL.getId()).subscribe(controlSubscriber);
} else {
keys.put(Keyboard.Key.RIGHT_CTRL.getId(), new BindableButtonImpl(new SimpleUri("ctrlMod"), "Control Modifier", new BindButtonEvent()));
keys.get(Keyboard.Key.RIGHT_CTRL.getId()).subscribe(controlSubscriber);
}
if (keys.containsKey(Keyboard.Key.LEFT_CTRL.getId())) {
keys.get(Keyboard.Key.LEFT_CTRL.getId()).subscribe(controlSubscriber);
} else {
keys.put(Keyboard.Key.LEFT_CTRL.getId(), new BindableButtonImpl(new SimpleUri("ctrlMod"), "Control Modifier", new BindButtonEvent()));
keys.get(Keyboard.Key.LEFT_CTRL.getId()).subscribe(controlSubscriber);
}
if (keys.containsKey(Keyboard.Key.TAB.getId())) {
keys.get(Keyboard.Key.TAB.getId()).subscribe(tabSubscriber);
} else {
keys.put(Keyboard.Key.TAB.getId(), new BindableButtonImpl(new SimpleUri("changeFocus"), "Change Focus", new BindButtonEvent()));
keys.get(Keyboard.Key.TAB.getId()).subscribe(tabSubscriber);
}
current = 0;
index = 0;
layersFilled = new ArrayList<>();
enabledWidgets = new ArrayList<>();
used = new ArrayList<>();
inSortOrder = false;
}
use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.
the class AdvancedGameSetupScreen method saveConfiguration.
private void saveConfiguration() {
// moduleConfig passes the module collection to other screens
ModuleConfig moduleConfig = config.getDefaultModSelection();
moduleConfig.clear();
// Fetch all the selected/activated modules using allSortedModules
// instead of fetching only selected/activated modules from filtered collection
// of modules using sortedModules
allSortedModules.stream().filter(info -> info.isSelected() && info.isExplicitSelection()).forEach(info -> moduleConfig.addModule(info.getMetadata().getId()));
SimpleUri defaultGenerator = config.getWorldGeneration().getDefaultGenerator();
ModuleSelectionInfo info = modulesLookup.get(defaultGenerator.getModuleName());
if (info != null && !info.isSelected()) {
config.getWorldGeneration().setDefaultGenerator(new SimpleUri());
}
worldGenManager.refresh();
config.save();
}
use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.
the class PreviewWorldScreen method setEnvironment.
public void setEnvironment() throws Exception {
// TODO: pass world gen and module list directly rather than using the config
SimpleUri worldGenUri = config.getWorldGeneration().getDefaultGenerator();
DependencyResolver resolver = new DependencyResolver(moduleManager.getRegistry());
ResolutionResult result = resolver.resolve(config.getDefaultModSelection().listModules());
if (result.isSuccess()) {
subContext = new ContextImpl(context);
CoreRegistry.setContext(subContext);
environment = moduleManager.loadEnvironment(result.getModules(), false);
subContext.put(WorldGeneratorPluginLibrary.class, new TempWorldGeneratorPluginLibrary(environment, subContext));
EnvironmentSwitchHandler environmentSwitchHandler = context.get(EnvironmentSwitchHandler.class);
environmentSwitchHandler.handleSwitchToPreviewEnvironment(subContext, environment);
genTexture();
worldGenerator = WorldGeneratorManager.createWorldGenerator(worldGenUri, subContext, environment);
worldGenerator.setWorldSeed(seed.getText());
List<Zone> previewZones = Lists.newArrayList(worldGenerator.getZones()).stream().filter(z -> !z.getPreviewLayers().isEmpty()).collect(Collectors.toList());
if (previewZones.isEmpty()) {
zoneSelector.setVisible(false);
previewGen = new FacetLayerPreview(environment, worldGenerator);
} else {
zoneSelector.setVisible(true);
zoneSelector.setOptions(previewZones);
zoneSelector.setSelection(previewZones.get(0));
}
configureProperties();
} else {
throw new UnresolvedDependencyException("Unable to resolve dependencies for " + worldGenUri);
}
}
use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.
the class StartPlayingScreen method initialise.
@Override
public void initialise() {
setAnimationSystem(MenuAnimationSystems.createDefaultSwipeAnimation());
WidgetUtil.trySubscribe(this, "close", button -> triggerBackAnimation());
WidgetUtil.trySubscribe(this, "play", button -> {
universeWrapper.setTargetWorld(targetWorld);
final GameManifest gameManifest = GameManifestProvider.createGameManifest(universeWrapper, moduleManager, config);
if (gameManifest != null) {
gameEngine.changeState(new StateLoading(gameManifest, (universeWrapper.getLoadingAsServer()) ? NetworkMode.DEDICATED_SERVER : NetworkMode.NONE));
} else {
getManager().createScreen(MessagePopup.ASSET_URI, MessagePopup.class).setMessage("Error", "Can't create new game!");
}
SimpleUri uri;
WorldInfo worldInfo;
// gameManifest.addWorld(worldInfo);
int i = 0;
for (WorldSetupWrapper world : worldSetupWrappers) {
if (world != targetWorld) {
i++;
uri = world.getWorldGeneratorInfo().getUri();
worldInfo = new WorldInfo(TerasologyConstants.MAIN_WORLD + i, world.getWorldName().toString(), world.getWorldGenerator().getWorldSeed(), (long) (WorldTime.DAY_LENGTH * WorldTime.NOON_OFFSET), uri);
gameManifest.addWorld(worldInfo);
config.getUniverseConfig().addWorldManager(worldInfo);
}
}
gameEngine.changeState(new StateLoading(gameManifest, (universeWrapper.getLoadingAsServer()) ? NetworkMode.DEDICATED_SERVER : NetworkMode.NONE));
});
WidgetUtil.trySubscribe(this, "mainMenu", button -> {
getManager().pushScreen("engine:mainMenuScreen");
});
WidgetUtil.trySubscribe(this, "renderingSettings", button -> {
RenderingModuleSettingScreen renderingModuleSettingScreen = (RenderingModuleSettingScreen) getManager().getScreen(RenderingModuleSettingScreen.ASSET_URI);
if (renderingModuleSettingScreen == null) {
renderingModuleSettingScreen = getManager().createScreen(RenderingModuleSettingScreen.ASSET_URI, RenderingModuleSettingScreen.class);
renderingModuleSettingScreen.setSubContext(this.subContext);
renderingModuleSettingScreen.postInit();
}
triggerForwardAnimation(renderingModuleSettingScreen);
});
}
use of org.terasology.engine.core.SimpleUri in project Terasology by MovingBlocks.
the class ImmutableFbo method request.
@Override
public FBO request(FboConfig fboConfig) {
FBO fbo;
SimpleUri fboName = fboConfig.getName();
if (fboConfigs.containsKey(fboName)) {
if (!fboConfig.equals(fboConfigs.get(fboName))) {
throw new IllegalArgumentException("Requested FBO is already available with different configuration");
}
fbo = fboLookup.get(fboConfig.getName());
} else {
fbo = generateWithDimensions(fboConfig, fboConfig.getDimensions());
}
retain(fboName);
return fbo;
}
Aggregations