use of de.gurkenlabs.litiengine.GameData in project litiengine by gurkenlabs.
the class EditorScreen method create.
public void create() {
JFileChooser chooser;
try {
chooser = new JFileChooser(new File(".").getCanonicalPath());
chooser.setDialogTitle(Resources.get("input_select_project_folder"));
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
if (chooser.showOpenDialog(Game.getScreenManager().getRenderComponent()) != JFileChooser.APPROVE_OPTION) {
return;
}
if (Game.getEnvironment() != null) {
Game.loadEnvironment(null);
}
// set up project settings
this.setProjectPath(chooser.getSelectedFile().getCanonicalPath());
// load all maps in the directory
this.mapComponent.loadMaps(this.getProjectPath());
this.currentResourceFile = null;
this.gameFile = new GameData();
// add sprite sheets by tile sets of all maps in the project director
for (Map map : this.mapComponent.getMaps()) {
this.loadSpriteSheets(map);
}
Program.getAssetTree().forceUpdate();
// load custom emitter files
this.loadCustomEmitters(this.getGameFile().getEmitters());
// update new game file by the loaded information
this.updateGameFileMaps();
// display first available map after loading all stuff
if (!this.mapComponent.getMaps().isEmpty()) {
this.mapComponent.loadEnvironment(this.mapComponent.getMaps().get(0));
this.changeComponent(ComponentType.MAP);
}
} catch (IOException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
this.setCurrentStatus("created new project");
}
Aggregations