mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-08-20 08:29:27 +00:00
Application state is now an OSGi concern and SCR has been fully integrated to simplify plugin registration
This commit is contained in:
parent
bb0a9339fe
commit
18ed359af0
@ -7,10 +7,12 @@
|
|||||||
<version>0.1</version>
|
<version>0.1</version>
|
||||||
<packaging>bundle</packaging>
|
<packaging>bundle</packaging>
|
||||||
|
|
||||||
<name>OutlawPluginExample OSGi Bundle</name>
|
<name>Outlaw Plugin Example</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -22,24 +24,36 @@
|
|||||||
<extensions>true</extensions>
|
<extensions>true</extensions>
|
||||||
<configuration>
|
<configuration>
|
||||||
<instructions>
|
<instructions>
|
||||||
<Import-Package>org.osgi.framework,org.badvision.outlaweditor.api,org.badvision.outlaweditor.data,org.badvision.outlaweditor.data.xml,org.badvision.outlaweditor.ui</Import-Package>
|
<Export-Package>org.badvision.outlaw.plugin.example</Export-Package>
|
||||||
<Export-Package>org.badvision.outlaw.plugin.example.*</Export-Package>
|
|
||||||
<Bundle-Activator>org.badvision.outlaw.plugin.example.Activator</Bundle-Activator>
|
<Bundle-Activator>org.badvision.outlaw.plugin.example.Activator</Bundle-Activator>
|
||||||
|
<Export-Service>*</Export-Service>
|
||||||
</instructions>
|
</instructions>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>maven-scr-plugin</artifactId>
|
||||||
|
<version>1.22.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>generate-scr-scrdescriptor</id>
|
||||||
|
<goals>
|
||||||
|
<goal>scr</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<properties>
|
||||||
|
<service.vendor>8-Bit Bunch</service.vendor>
|
||||||
|
</properties>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.felix</groupId>
|
<groupId>org.badvision</groupId>
|
||||||
<artifactId>org.apache.felix.framework</artifactId>
|
|
||||||
<version>5.4.0</version>
|
|
||||||
<type>jar</type>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>OutlawEditor</artifactId>
|
<artifactId>OutlawEditor</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -48,5 +62,10 @@
|
|||||||
<artifactId>org.apache.felix.scr.annotations</artifactId>
|
<artifactId>org.apache.felix.scr.annotations</artifactId>
|
||||||
<version>1.10.0</version>
|
<version>1.10.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>org.apache.felix.main</artifactId>
|
||||||
|
<version>5.4.0</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,33 +1,47 @@
|
|||||||
package org.badvision.outlaw.plugin.example;
|
package org.badvision.outlaw.plugin.example;
|
||||||
|
|
||||||
import org.apache.felix.scr.annotations.Reference;
|
|
||||||
import org.apache.felix.scr.annotations.ReferenceCardinality;
|
|
||||||
import org.badvision.outlaweditor.api.ApplicationState;
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
import org.osgi.framework.BundleActivator;
|
import org.osgi.framework.BundleActivator;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* This is an example activator class, provided to demonstrate basic bundle lifecycle events.
|
||||||
|
* Since we're using declarative servies (Felix SCR), all the messy bits of service registration
|
||||||
|
* and reference passing are managed for us. Otherwise we'd be doing that here. Fortunately,
|
||||||
|
* we don't have to do all that.
|
||||||
|
*
|
||||||
|
* Still, this is a useful mechanism if you have some one-time setup or shutdown concerns that apply
|
||||||
|
* to your whole bundle, such as reading configuration data from a file or whatever.
|
||||||
|
*
|
||||||
* @author blurry
|
* @author blurry
|
||||||
*/
|
*/
|
||||||
public class Activator implements BundleActivator {
|
public class Activator implements BundleActivator {
|
||||||
|
@Override
|
||||||
|
|
||||||
public void start(BundleContext bc) throws Exception {
|
public void start(BundleContext bc) throws Exception {
|
||||||
System.out.println("Hello, world!");
|
System.out.println("Hello, plugin!");
|
||||||
ApplicationState app = bc.getService(bc.getServiceReference(ApplicationState.class));
|
checkReferences();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void stop(BundleContext bc) throws Exception {
|
||||||
|
System.out.println("Goodbye, plugin!");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkReferences() {
|
||||||
|
// Note that our activator is not a component, so we can't use the @Reference
|
||||||
|
// annotation to inject app automatically. ApplicationState has a convenience
|
||||||
|
// method to get around this in just such events, but it's a hack.
|
||||||
|
// Ultimately it's not a good idea to rely on this too much as it follows
|
||||||
|
// some bad practices behind the scene that leave unclosed references, etc.
|
||||||
|
// I'll have to come up with a safer way to inject dependencies without
|
||||||
|
// causing housekeeping issues for OSGi.
|
||||||
|
ApplicationState app = ApplicationState.getInstance();
|
||||||
if (app == null) {
|
if (app == null) {
|
||||||
System.out.println("App is null?!?!");
|
System.out.println("App is null?!?!");
|
||||||
|
} else if (app.getCurrentPlatform() == null) {
|
||||||
|
System.out.println("Current platform is null?");
|
||||||
} else {
|
} else {
|
||||||
if (app.getCurrentPlatform() == null) {
|
System.out.println("Current platform is " + app.getCurrentPlatform());
|
||||||
System.out.println("Current platform is null?");
|
}
|
||||||
} else {
|
|
||||||
System.out.println("Current platform is "+app.getCurrentPlatform());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop(BundleContext bc) throws Exception {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
package org.badvision.outlaw.plugin.example;
|
||||||
|
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import org.apache.felix.scr.annotations.Activate;
|
||||||
|
import org.apache.felix.scr.annotations.Component;
|
||||||
|
import org.apache.felix.scr.annotations.Deactivate;
|
||||||
|
import org.apache.felix.scr.annotations.Reference;
|
||||||
|
import org.apache.felix.scr.annotations.Service;
|
||||||
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
|
import org.badvision.outlaweditor.api.MenuAction;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This
|
||||||
|
* @author blurry
|
||||||
|
*/
|
||||||
|
@Component(immediate = true)
|
||||||
|
@Service(MenuAction.class)
|
||||||
|
public class ExamplePlugin implements MenuAction {
|
||||||
|
|
||||||
|
// Note: Because ApplicationState is already a defined service, this will automatically be bound.
|
||||||
|
// Hence, it is not necessary to worry about passing it it.
|
||||||
|
@Reference
|
||||||
|
ApplicationState app;
|
||||||
|
|
||||||
|
// This is called when our plugin is starting
|
||||||
|
@Activate
|
||||||
|
public void activate() throws Exception {
|
||||||
|
System.out.println("Hello, menu!");
|
||||||
|
checkReferences();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is called when our plugin is stopping
|
||||||
|
@Deactivate
|
||||||
|
public void stop(BundleContext bc) throws Exception {
|
||||||
|
System.out.println("Goodbye, menu!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// This identifies the menu item label
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Example action";
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method is called when the user selects the menu item
|
||||||
|
@Override
|
||||||
|
public void handle(ActionEvent event) {
|
||||||
|
System.out.println("Clicked!");
|
||||||
|
checkReferences();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkReferences() {
|
||||||
|
// app = ApplicationState.getInstance();
|
||||||
|
if (app == null) {
|
||||||
|
System.out.println("App is null?!?!");
|
||||||
|
} else {
|
||||||
|
if (app.getCurrentPlatform() == null) {
|
||||||
|
System.out.println("Current platform is null?");
|
||||||
|
} else {
|
||||||
|
System.out.println("Current platform is "+app.getCurrentPlatform());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<mainClass>org.badvision.outlaweditor.Application</mainClass>
|
<mainClass>org.badvision.outlaweditor.Application</mainClass>
|
||||||
|
<!--<mainClass>org.apache.felix.main.Main</mainClass>-->
|
||||||
<netbeans.hint.license>apache20</netbeans.hint.license>
|
<netbeans.hint.license>apache20</netbeans.hint.license>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -23,6 +24,19 @@
|
|||||||
<groupId>org.apache.felix</groupId>
|
<groupId>org.apache.felix</groupId>
|
||||||
<artifactId>maven-scr-plugin</artifactId>
|
<artifactId>maven-scr-plugin</artifactId>
|
||||||
<version>1.22.0</version>
|
<version>1.22.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>generate-scr-scrdescriptor</id>
|
||||||
|
<goals>
|
||||||
|
<goal>scr</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<properties>
|
||||||
|
<service.vendor>8-Bit Bunch</service.vendor>
|
||||||
|
</properties>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.felix</groupId>
|
<groupId>org.apache.felix</groupId>
|
||||||
@ -158,15 +172,15 @@
|
|||||||
<artifactId>org.apache.felix.main</artifactId>
|
<artifactId>org.apache.felix.main</artifactId>
|
||||||
<version>5.4.0</version>
|
<version>5.4.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.osgi</groupId>
|
|
||||||
<artifactId>org.osgi.core</artifactId>
|
|
||||||
<version>4.3.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.felix</groupId>
|
<groupId>org.apache.felix</groupId>
|
||||||
<artifactId>org.apache.felix.scr.annotations</artifactId>
|
<artifactId>org.apache.felix.scr.annotations</artifactId>
|
||||||
<version>1.10.0</version>
|
<version>1.10.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.felix</groupId>
|
||||||
|
<artifactId>org.apache.felix.scr</artifactId>
|
||||||
|
<version>2.0.2</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -11,71 +11,98 @@ package org.badvision.outlaweditor;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
import javafx.scene.canvas.Canvas;
|
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import javafx.stage.WindowEvent;
|
import javafx.stage.WindowEvent;
|
||||||
import org.apache.felix.framework.Felix;
|
import org.apache.felix.framework.Felix;
|
||||||
|
import org.apache.felix.framework.util.FelixConstants;
|
||||||
import org.apache.felix.main.AutoProcessor;
|
import org.apache.felix.main.AutoProcessor;
|
||||||
import org.apache.felix.scr.annotations.Component;
|
import org.apache.felix.scr.annotations.Component;
|
||||||
|
import org.apache.felix.scr.annotations.Service;
|
||||||
|
import org.apache.felix.scr.impl.Activator;
|
||||||
import org.badvision.outlaweditor.api.ApplicationState;
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
|
import org.badvision.outlaweditor.api.MenuAction;
|
||||||
import org.badvision.outlaweditor.api.Platform;
|
import org.badvision.outlaweditor.api.Platform;
|
||||||
import org.badvision.outlaweditor.data.xml.GameData;
|
import org.badvision.outlaweditor.data.xml.GameData;
|
||||||
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||||
|
import org.osgi.framework.BundleActivator;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
import org.osgi.framework.BundleException;
|
import org.osgi.framework.BundleException;
|
||||||
|
import org.osgi.framework.ServiceEvent;
|
||||||
|
import org.osgi.framework.launch.Framework;
|
||||||
|
import org.osgi.util.tracker.ServiceTracker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author brobert
|
* @author brobert
|
||||||
*/
|
*/
|
||||||
@Component(name = "org.badvision.outlaweditor.api.ApplicationState")
|
@Component
|
||||||
public class Application extends javafx.application.Application implements ApplicationState {
|
@Service(org.badvision.outlaweditor.api.ApplicationState.class)
|
||||||
|
public class Application extends javafx.application.Application implements ApplicationState, BundleActivator {
|
||||||
|
|
||||||
public static GameData gameData = new GameData();
|
public static Framework felix;
|
||||||
public static Platform currentPlatform = Platform.AppleII;
|
private GameData gameData = new GameData();
|
||||||
static Application instance;
|
private Platform currentPlatform = Platform.AppleII;
|
||||||
|
private ApplicationUIController controller;
|
||||||
public static Application getInstance() {
|
private Stage primaryStage;
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void shutdown() {
|
public static void shutdown() {
|
||||||
try {
|
try {
|
||||||
instance.pluginContainer.stop();
|
felix.stop();
|
||||||
instance.pluginContainer.waitForStop(0L);
|
felix.waitForStop(0L);
|
||||||
} catch (BundleException | InterruptedException ex) {
|
} catch (BundleException | InterruptedException ex) {
|
||||||
Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ApplicationUIController controller;
|
@Override
|
||||||
private Felix pluginContainer;
|
public GameData getGameData() {
|
||||||
|
return gameData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ApplicationUIController getApplicationUI() {
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Platform getCurrentPlatform() {
|
||||||
|
return currentPlatform;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGameData(GameData newData) {
|
||||||
|
gameData = newData;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCurrentPlatform(Platform newPlatform) {
|
||||||
|
currentPlatform = newPlatform;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public ApplicationUIController getController() {
|
public ApplicationUIController getController() {
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Stage primaryStage;
|
@Override
|
||||||
|
public Stage getPrimaryStage() {
|
||||||
public static Stage getPrimaryStage() {
|
return primaryStage;
|
||||||
return instance.primaryStage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage) {
|
public void start(Stage primaryStage) {
|
||||||
instance = this;
|
|
||||||
this.primaryStage = primaryStage;
|
this.primaryStage = primaryStage;
|
||||||
javafx.application.Platform.setImplicitExit(true);
|
javafx.application.Platform.setImplicitExit(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
startPluginContainer();
|
startPluginContainer();
|
||||||
} catch (BundleException ex) {
|
} catch (Exception ex) {
|
||||||
Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(Application.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
throw new RuntimeException(ex);
|
throw new RuntimeException(ex);
|
||||||
}
|
}
|
||||||
@ -96,7 +123,6 @@ public class Application extends javafx.application.Application implements Appli
|
|||||||
});
|
});
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
}
|
}
|
||||||
Canvas tilePreview;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main() method is ignored in correctly deployed JavaFX application.
|
* The main() method is ignored in correctly deployed JavaFX application.
|
||||||
@ -110,35 +136,36 @@ public class Application extends javafx.application.Application implements Appli
|
|||||||
launch(args);
|
launch(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startPluginContainer() throws BundleException {
|
ServiceTracker tracker;
|
||||||
Map<String, String> pluginConfiguration = new HashMap<>();
|
private void startPluginContainer() throws BundleException, Exception {
|
||||||
pluginConfiguration.put("felix.cache.locking", "false");
|
Map<String, String> config = new HashMap<>();
|
||||||
pluginConfiguration.put("felix.auto.deploy.action", "install,start");
|
config.put(FelixConstants.ACTIVATION_LAZY, "false");
|
||||||
pluginConfiguration.put("felix.auto.deploy.dir", "install");
|
config.put("felix.cache.locking", "false");
|
||||||
pluginConfiguration.put("org.osgi.framework.system.packages.extra",
|
config.put("felix.auto.deploy.dir", "install");
|
||||||
"org.badvision.outlaweditor.api,"
|
config.put("felix.auto.deploy.action", "install,start");
|
||||||
+ "org.badvision.outlaweditor.data,"
|
config.put("org.osgi.framework.system.packages.extra",
|
||||||
+ "org.badvision.outlaweditor.data.xml,"
|
"javafx.event,"
|
||||||
+ "org.badvision.outlaweditor.ui,"
|
+ "org.badvision.outlaweditor.api,"
|
||||||
+ "org.osgi.framework");
|
+ "org.badvision.outlaweditor.data,"
|
||||||
pluginContainer = new Felix(pluginConfiguration);
|
+ "org.badvision.outlaweditor.data.xml,"
|
||||||
pluginContainer.start();
|
+ "org.badvision.outlaweditor.ui,"
|
||||||
pluginContainer.getBundleContext().registerService(ApplicationState.class, this, new Hashtable<>());
|
+ "org.osgi.framework");
|
||||||
AutoProcessor.process(pluginConfiguration, pluginContainer.getBundleContext());
|
felix = new Felix(config);
|
||||||
|
felix.start();
|
||||||
|
felix.getBundleContext().registerService(ApplicationState.class, this, null);
|
||||||
|
tracker = new ServiceTracker(felix.getBundleContext(), MenuAction.class, null);
|
||||||
|
tracker.open();
|
||||||
|
Activator scrActivator = new Activator();
|
||||||
|
scrActivator.start(felix.getBundleContext());
|
||||||
|
AutoProcessor.process(config, felix.getBundleContext());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void start(BundleContext bc) throws Exception {
|
||||||
|
launch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameData getGameData() {
|
public void stop(BundleContext bc) throws Exception {
|
||||||
return gameData;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ApplicationUIController getApplicationUI() {
|
|
||||||
return controller;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Platform getCurrentPlatform() {
|
|
||||||
return currentPlatform;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import java.util.zip.DataFormatException;
|
|||||||
import java.util.zip.Deflater;
|
import java.util.zip.Deflater;
|
||||||
import java.util.zip.Inflater;
|
import java.util.zip.Inflater;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -67,7 +68,7 @@ public class FileUtils {
|
|||||||
f.getExtensionFilters().add(e.getExtensionFilter());
|
f.getExtensionFilters().add(e.getExtensionFilter());
|
||||||
}
|
}
|
||||||
if (create) {
|
if (create) {
|
||||||
File file = f.showSaveDialog(Application.getPrimaryStage());
|
File file = f.showSaveDialog(ApplicationState.getInstance().getPrimaryStage());
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -77,7 +78,7 @@ public class FileUtils {
|
|||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return f.showOpenDialog(Application.getPrimaryStage());
|
return f.showOpenDialog(ApplicationState.getInstance().getPrimaryStage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
package org.badvision.outlaweditor;
|
package org.badvision.outlaweditor;
|
||||||
|
|
||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
|
import org.badvision.outlaweditor.data.xml.GameData;
|
||||||
import org.badvision.outlaweditor.data.xml.Global;
|
import org.badvision.outlaweditor.data.xml.Global;
|
||||||
import org.badvision.outlaweditor.data.xml.Script;
|
import org.badvision.outlaweditor.data.xml.Script;
|
||||||
import org.badvision.outlaweditor.data.xml.Scripts;
|
import org.badvision.outlaweditor.data.xml.Scripts;
|
||||||
@ -19,17 +21,18 @@ public class GlobalEditor extends Editor<Global, Void>{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addScript(Script script) {
|
public void addScript(Script script) {
|
||||||
Scripts scripts = Application.gameData.getGlobal().getScripts();
|
GameData gameData = getGameData();
|
||||||
|
Scripts scripts = gameData.getGlobal().getScripts();
|
||||||
if (scripts == null) {
|
if (scripts == null) {
|
||||||
Application.gameData.getGlobal().setScripts(new Scripts());
|
gameData.getGlobal().setScripts(new Scripts());
|
||||||
scripts = Application.gameData.getGlobal().getScripts();
|
scripts = gameData.getGlobal().getScripts();
|
||||||
}
|
}
|
||||||
scripts.getScript().add(script);
|
scripts.getScript().add(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void removeScript(Script script) {
|
public void removeScript(Script script) {
|
||||||
Scripts scripts = Application.gameData.getGlobal().getScripts();
|
Scripts scripts = getGameData().getGlobal().getScripts();
|
||||||
scripts.getScript().remove(script);
|
scripts.getScript().remove(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,5 +85,9 @@ public class GlobalEditor extends Editor<Global, Void>{
|
|||||||
public void observedObjectChanged(Global object) {
|
public void observedObjectChanged(Global object) {
|
||||||
throw new UnsupportedOperationException("Not supported."); //To change body of generated methods, choose Tools | Templates.
|
throw new UnsupportedOperationException("Not supported."); //To change body of generated methods, choose Tools | Templates.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private GameData getGameData() {
|
||||||
|
return ApplicationState.getInstance().getGameData();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.badvision.outlaweditor;
|
package org.badvision.outlaweditor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -43,7 +42,7 @@ import javafx.scene.layout.Pane;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
import static org.badvision.outlaweditor.Application.currentPlatform;
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
import org.badvision.outlaweditor.data.TileMap;
|
import org.badvision.outlaweditor.data.TileMap;
|
||||||
import org.badvision.outlaweditor.data.TileUtils;
|
import org.badvision.outlaweditor.data.TileUtils;
|
||||||
import org.badvision.outlaweditor.data.xml.Map;
|
import org.badvision.outlaweditor.data.xml.Map;
|
||||||
@ -67,8 +66,8 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
|||||||
double zoom = 1.0;
|
double zoom = 1.0;
|
||||||
DrawMode drawMode = DrawMode.Pencil1px;
|
DrawMode drawMode = DrawMode.Pencil1px;
|
||||||
TileMap currentMap;
|
TileMap currentMap;
|
||||||
double tileWidth = currentPlatform.tileRenderer.getWidth() * zoom;
|
double tileWidth = getCurrentPlatform().tileRenderer.getWidth() * zoom;
|
||||||
double tileHeight = currentPlatform.tileRenderer.getHeight() * zoom;
|
double tileHeight = getCurrentPlatform().tileRenderer.getHeight() * zoom;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onEntityUpdated() {
|
protected void onEntityUpdated() {
|
||||||
@ -115,7 +114,7 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
|||||||
@Override
|
@Override
|
||||||
public void buildEditorUI(Pane tileEditorAnchorPane) {
|
public void buildEditorUI(Pane tileEditorAnchorPane) {
|
||||||
anchorPane = tileEditorAnchorPane;
|
anchorPane = tileEditorAnchorPane;
|
||||||
Application.getPrimaryStage().getScene().addEventHandler(KeyEvent.KEY_PRESSED, this::keyPressed);
|
ApplicationState.getInstance().getPrimaryStage().getScene().addEventHandler(KeyEvent.KEY_PRESSED, this::keyPressed);
|
||||||
initCanvas();
|
initCanvas();
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
@ -127,7 +126,7 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
|||||||
if (currentTile != null) {
|
if (currentTile != null) {
|
||||||
category = currentTile.getCategory();
|
category = currentTile.getCategory();
|
||||||
}
|
}
|
||||||
if (this.equals(Application.getInstance().getController().getVisibleEditor())) {
|
if (this.equals(ApplicationState.getInstance().getController().getVisibleEditor())) {
|
||||||
UIAction.showTileSelectModal(anchorPane, category, this::setCurrentTile);
|
UIAction.showTileSelectModal(anchorPane, category, this::setCurrentTile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,8 +137,8 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
|||||||
anchorPane.getChildren().remove(drawCanvas);
|
anchorPane.getChildren().remove(drawCanvas);
|
||||||
}
|
}
|
||||||
drawCanvas = new Canvas();
|
drawCanvas = new Canvas();
|
||||||
drawCanvas.heightProperty().bind(Application.getPrimaryStage().heightProperty().subtract(120));
|
drawCanvas.heightProperty().bind(ApplicationState.getInstance().getPrimaryStage().heightProperty().subtract(120));
|
||||||
drawCanvas.widthProperty().bind(Application.getPrimaryStage().widthProperty().subtract(200));
|
drawCanvas.widthProperty().bind(ApplicationState.getInstance().getPrimaryStage().widthProperty().subtract(200));
|
||||||
// drawCanvas.widthProperty().bind(anchorPane.widthProperty());
|
// drawCanvas.widthProperty().bind(anchorPane.widthProperty());
|
||||||
drawCanvas.widthProperty().addListener((ObservableValue<? extends Number> ov, Number t, Number t1) -> {
|
drawCanvas.widthProperty().addListener((ObservableValue<? extends Number> ov, Number t, Number t1) -> {
|
||||||
redraw();
|
redraw();
|
||||||
@ -226,8 +225,8 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
|||||||
//
|
//
|
||||||
// double newLeft = (left + pointerX) * ratio - pointerX;
|
// double newLeft = (left + pointerX) * ratio - pointerX;
|
||||||
// double newTop = (top + pointerY) * ratio - pointerY;
|
// double newTop = (top + pointerY) * ratio - pointerY;
|
||||||
tileWidth = currentPlatform.tileRenderer.getWidth() * zoom;
|
tileWidth = getCurrentPlatform().tileRenderer.getWidth() * zoom;
|
||||||
tileHeight = currentPlatform.tileRenderer.getHeight() * zoom;
|
tileHeight = getCurrentPlatform().tileRenderer.getHeight() * zoom;
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +299,7 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
|||||||
double xx = x * tileWidth;
|
double xx = x * tileWidth;
|
||||||
double yy = y * tileHeight;
|
double yy = y * tileHeight;
|
||||||
if (tile != null) {
|
if (tile != null) {
|
||||||
drawCanvas.getGraphicsContext2D().drawImage(TileUtils.getImage(tile, currentPlatform), xx, yy, tileWidth, tileHeight);
|
drawCanvas.getGraphicsContext2D().drawImage(TileUtils.getImage(tile, getCurrentPlatform()), xx, yy, tileWidth, tileHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,7 +397,7 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
|||||||
drawCanvas.heightProperty().unbind();
|
drawCanvas.heightProperty().unbind();
|
||||||
anchorPane.getChildren().remove(drawCanvas);
|
anchorPane.getChildren().remove(drawCanvas);
|
||||||
currentMap.updateBackingMap();
|
currentMap.updateBackingMap();
|
||||||
Application.getPrimaryStage().getScene().removeEventHandler(KeyEvent.KEY_PRESSED, this::keyPressed);
|
ApplicationState.getInstance().getPrimaryStage().getScene().removeEventHandler(KeyEvent.KEY_PRESSED, this::keyPressed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -417,14 +416,14 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
|||||||
drawMode = DrawMode.Pencil1px;
|
drawMode = DrawMode.Pencil1px;
|
||||||
}
|
}
|
||||||
this.currentTile = currentTile;
|
this.currentTile = currentTile;
|
||||||
ImageCursor cursor = new ImageCursor(TileUtils.getImage(currentTile, currentPlatform), 2, 2);
|
ImageCursor cursor = new ImageCursor(TileUtils.getImage(currentTile, getCurrentPlatform()), 2, 2);
|
||||||
drawCanvas.setCursor(cursor);
|
drawCanvas.setCursor(cursor);
|
||||||
return currentTile;
|
return currentTile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void showPreview() {
|
public void showPreview() {
|
||||||
byte[] data = currentPlatform.imageRenderer.renderPreview(currentMap, posX, posY, currentPlatform.maxImageWidth, currentPlatform.maxImageHeight);
|
byte[] data = getCurrentPlatform().imageRenderer.renderPreview(currentMap, posX, posY, getCurrentPlatform().maxImageWidth, getCurrentPlatform().maxImageHeight);
|
||||||
WritableImage img = currentPlatform.imageRenderer.renderImage(null, data, currentPlatform.maxImageWidth, currentPlatform.maxImageHeight);
|
WritableImage img = getCurrentPlatform().imageRenderer.renderImage(null, data, getCurrentPlatform().maxImageWidth, getCurrentPlatform().maxImageHeight);
|
||||||
Stage stage = new Stage();
|
Stage stage = new Stage();
|
||||||
stage.setTitle("Preview");
|
stage.setTitle("Preview");
|
||||||
ImageView imgView = new ImageView(img);
|
ImageView imgView = new ImageView(img);
|
||||||
@ -435,12 +434,12 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void copy() {
|
public void copy() {
|
||||||
byte[] data = currentPlatform.imageRenderer.renderPreview(currentMap, posX, posY, currentPlatform.maxImageWidth, currentPlatform.maxImageHeight);
|
byte[] data = getCurrentPlatform().imageRenderer.renderPreview(currentMap, posX, posY, getCurrentPlatform().maxImageWidth, getCurrentPlatform().maxImageHeight);
|
||||||
WritableImage img = currentPlatform.imageRenderer.renderImage(null, data, currentPlatform.maxImageWidth, currentPlatform.maxImageHeight);
|
WritableImage img = getCurrentPlatform().imageRenderer.renderImage(null, data, getCurrentPlatform().maxImageWidth, getCurrentPlatform().maxImageHeight);
|
||||||
java.util.Map<DataFormat, Object> clip = new HashMap<>();
|
java.util.Map<DataFormat, Object> clip = new HashMap<>();
|
||||||
clip.put(DataFormat.IMAGE, img);
|
clip.put(DataFormat.IMAGE, img);
|
||||||
if (drawMode != DrawMode.Select || startX >= 0) {
|
if (drawMode != DrawMode.Select || startX >= 0) {
|
||||||
clip.put(DataFormat.PLAIN_TEXT, "selection/map/" + Application.gameData.getMap().indexOf(getEntity()) + "/" + getSelectionInfo());
|
clip.put(DataFormat.PLAIN_TEXT, "selection/map/" + ApplicationState.getInstance().getGameData().getMap().indexOf(getEntity()) + "/" + getSelectionInfo());
|
||||||
}
|
}
|
||||||
Clipboard.getSystemClipboard().setContent(clip);
|
Clipboard.getSystemClipboard().setContent(clip);
|
||||||
clearSelection();
|
clearSelection();
|
||||||
@ -460,7 +459,7 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
|||||||
java.util.Map<String, Integer> selection = TransferHelper.getSelectionDetails(clipboardInfo);
|
java.util.Map<String, Integer> selection = TransferHelper.getSelectionDetails(clipboardInfo);
|
||||||
if (selection.containsKey("map")) {
|
if (selection.containsKey("map")) {
|
||||||
trackState();
|
trackState();
|
||||||
Map sourceMap = Application.gameData.getMap().get(selection.get("map"));
|
Map sourceMap = ApplicationState.getInstance().getGameData().getMap().get(selection.get("map"));
|
||||||
TileMap source = getCurrentMap();
|
TileMap source = getCurrentMap();
|
||||||
if (!sourceMap.equals(getCurrentMap().getBackingMap())) {
|
if (!sourceMap.equals(getCurrentMap().getBackingMap())) {
|
||||||
source = new TileMap(sourceMap);
|
source = new TileMap(sourceMap);
|
||||||
@ -507,6 +506,10 @@ public class MapEditor extends Editor<Map, MapEditor.DrawMode> implements EventH
|
|||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private org.badvision.outlaweditor.api.Platform getCurrentPlatform() {
|
||||||
|
return ApplicationState.getInstance().getCurrentPlatform();
|
||||||
|
}
|
||||||
|
|
||||||
public static enum DrawMode {
|
public static enum DrawMode {
|
||||||
|
|
||||||
Pencil1px, Pencil3px, Pencil5px, FilledRect, Eraser(false), Select(false);
|
Pencil1px, Pencil3px, Pencil5px, FilledRect, Eraser(false), Select(false);
|
||||||
|
@ -35,6 +35,7 @@ import javax.xml.namespace.QName;
|
|||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
import org.badvision.outlaweditor.data.xml.Block;
|
import org.badvision.outlaweditor.data.xml.Block;
|
||||||
import org.badvision.outlaweditor.data.xml.Global;
|
import org.badvision.outlaweditor.data.xml.Global;
|
||||||
import org.badvision.outlaweditor.data.xml.Mutation;
|
import org.badvision.outlaweditor.data.xml.Mutation;
|
||||||
@ -192,7 +193,7 @@ public class MythosEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Scope getGlobalScope() {
|
public static Scope getGlobalScope() {
|
||||||
return Application.gameData.getGlobal();
|
return ApplicationState.getInstance().getGameData().getGlobal();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isGlobalScope() {
|
private boolean isGlobalScope() {
|
||||||
|
@ -15,16 +15,43 @@
|
|||||||
*/
|
*/
|
||||||
package org.badvision.outlaweditor.api;
|
package org.badvision.outlaweditor.api;
|
||||||
|
|
||||||
|
import javafx.stage.Stage;
|
||||||
|
import org.badvision.outlaweditor.Application;
|
||||||
import org.badvision.outlaweditor.data.xml.GameData;
|
import org.badvision.outlaweditor.data.xml.GameData;
|
||||||
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
import org.osgi.framework.FrameworkUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author blurry
|
* @author blurry
|
||||||
*/
|
*/
|
||||||
public interface ApplicationState {
|
public interface ApplicationState {
|
||||||
public GameData getGameData();
|
public GameData getGameData();
|
||||||
|
|
||||||
|
public void setGameData(GameData newData);
|
||||||
|
|
||||||
public ApplicationUIController getApplicationUI();
|
public ApplicationUIController getApplicationUI();
|
||||||
|
|
||||||
public Platform getCurrentPlatform();
|
public Platform getCurrentPlatform();
|
||||||
|
|
||||||
|
public void setCurrentPlatform(Platform p);
|
||||||
|
|
||||||
|
public ApplicationUIController getController();
|
||||||
|
|
||||||
|
public Stage getPrimaryStage();
|
||||||
|
|
||||||
|
static public BundleContext getBundleContext() {
|
||||||
|
if (Application.felix != null) {
|
||||||
|
return Application.felix.getBundleContext();
|
||||||
|
} else {
|
||||||
|
return FrameworkUtil.getBundle(ApplicationState.class).getBundleContext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ApplicationState getInstance() {
|
||||||
|
BundleContext bc = getBundleContext();
|
||||||
|
return bc.getService(bc.getServiceReference(ApplicationState.class));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2016 org.badvision.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.badvision.outlaweditor.api;
|
||||||
|
|
||||||
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.event.EventHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Any ser
|
||||||
|
* @author blurry
|
||||||
|
*/
|
||||||
|
public interface MenuAction extends EventHandler<ActionEvent> {
|
||||||
|
public String getName();
|
||||||
|
|
||||||
|
default public String getDescription() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
}
|
@ -28,11 +28,11 @@ import javafx.scene.input.MouseEvent;
|
|||||||
import javafx.scene.layout.Pane;
|
import javafx.scene.layout.Pane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
import org.badvision.outlaweditor.Application;
|
|
||||||
import org.badvision.outlaweditor.FileUtils;
|
import org.badvision.outlaweditor.FileUtils;
|
||||||
import org.badvision.outlaweditor.ImageEditor;
|
import org.badvision.outlaweditor.ImageEditor;
|
||||||
import org.badvision.outlaweditor.api.Platform;
|
|
||||||
import org.badvision.outlaweditor.TransferHelper;
|
import org.badvision.outlaweditor.TransferHelper;
|
||||||
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
|
import org.badvision.outlaweditor.api.Platform;
|
||||||
import org.badvision.outlaweditor.data.TileMap;
|
import org.badvision.outlaweditor.data.TileMap;
|
||||||
import org.badvision.outlaweditor.data.xml.Image;
|
import org.badvision.outlaweditor.data.xml.Image;
|
||||||
import org.badvision.outlaweditor.data.xml.PlatformData;
|
import org.badvision.outlaweditor.data.xml.PlatformData;
|
||||||
@ -435,7 +435,7 @@ public class AppleImageEditor extends ImageEditor implements EventHandler<MouseE
|
|||||||
public void copy() {
|
public void copy() {
|
||||||
java.util.Map<DataFormat, Object> clip = new HashMap<>();
|
java.util.Map<DataFormat, Object> clip = new HashMap<>();
|
||||||
clip.put(DataFormat.IMAGE, currentImage);
|
clip.put(DataFormat.IMAGE, currentImage);
|
||||||
clip.put(DataFormat.PLAIN_TEXT, "selection/image/" + Application.gameData.getImage().indexOf(getEntity()) + "/" + getSelectionInfo());
|
clip.put(DataFormat.PLAIN_TEXT, "selection/image/" + ApplicationState.getInstance().getGameData().getImage().indexOf(getEntity()) + "/" + getSelectionInfo());
|
||||||
Clipboard.getSystemClipboard().setContent(clip);
|
Clipboard.getSystemClipboard().setContent(clip);
|
||||||
copyData = Arrays.copyOf(getImageData(), getImageData().length);
|
copyData = Arrays.copyOf(getImageData(), getImageData().length);
|
||||||
}
|
}
|
||||||
@ -460,7 +460,7 @@ public class AppleImageEditor extends ImageEditor implements EventHandler<MouseE
|
|||||||
System.out.println("Clipboard >> " + contentPath);
|
System.out.println("Clipboard >> " + contentPath);
|
||||||
Map<String, Integer> selection = TransferHelper.getSelectionDetails(contentPath);
|
Map<String, Integer> selection = TransferHelper.getSelectionDetails(contentPath);
|
||||||
if (selection.containsKey("map")) {
|
if (selection.containsKey("map")) {
|
||||||
TileMap map = new TileMap(Application.gameData.getMap().get(selection.get("map")));
|
TileMap map = new TileMap(ApplicationState.getInstance().getGameData().getMap().get(selection.get("map")));
|
||||||
byte[] buf = getPlatform().imageRenderer.renderPreview(
|
byte[] buf = getPlatform().imageRenderer.renderPreview(
|
||||||
map,
|
map,
|
||||||
selection.get("x1"),
|
selection.get("x1"),
|
||||||
@ -471,7 +471,7 @@ public class AppleImageEditor extends ImageEditor implements EventHandler<MouseE
|
|||||||
redraw();
|
redraw();
|
||||||
return true;
|
return true;
|
||||||
} else if (selection.containsKey("image")) {
|
} else if (selection.containsKey("image")) {
|
||||||
Image sourceImage = Application.gameData.getImage().get(selection.get("image"));
|
Image sourceImage = ApplicationState.getInstance().getGameData().getImage().get(selection.get("image"));
|
||||||
byte[] sourceData;
|
byte[] sourceData;
|
||||||
if (sourceImage.equals(getEntity())) {
|
if (sourceImage.equals(getEntity())) {
|
||||||
sourceData = copyData;
|
sourceData = copyData;
|
||||||
|
@ -15,7 +15,7 @@ import java.util.Collection;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.badvision.outlaweditor.Application;
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
import org.badvision.outlaweditor.data.xml.Field;
|
import org.badvision.outlaweditor.data.xml.Field;
|
||||||
import org.badvision.outlaweditor.data.xml.Global;
|
import org.badvision.outlaweditor.data.xml.Global;
|
||||||
import org.badvision.outlaweditor.data.xml.Map;
|
import org.badvision.outlaweditor.data.xml.Map;
|
||||||
@ -28,8 +28,8 @@ public class DataUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void ensureGlobalExists() {
|
public static void ensureGlobalExists() {
|
||||||
if (Application.gameData.getGlobal() == null) {
|
if (ApplicationState.getInstance().getGameData().getGlobal() == null) {
|
||||||
Application.gameData.setGlobal(new Global());
|
ApplicationState.getInstance().getGameData().setGlobal(new Global());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,8 +101,8 @@ public class DataUtilities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void cleanupAllScriptNames() {
|
public static void cleanupAllScriptNames() {
|
||||||
cleanupScriptNames(Application.gameData.getGlobal());
|
cleanupScriptNames(ApplicationState.getInstance().getGameData().getGlobal());
|
||||||
Application.gameData.getMap().forEach(DataUtilities::cleanupScriptNames);
|
ApplicationState.getInstance().getGameData().getMap().forEach(DataUtilities::cleanupScriptNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------ String comparators
|
//------------------------------ String comparators
|
||||||
|
@ -22,6 +22,7 @@ import javafx.scene.image.WritableImage;
|
|||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javax.xml.bind.JAXBElement;
|
import javax.xml.bind.JAXBElement;
|
||||||
import org.badvision.outlaweditor.Application;
|
import org.badvision.outlaweditor.Application;
|
||||||
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
import org.badvision.outlaweditor.api.Platform;
|
import org.badvision.outlaweditor.api.Platform;
|
||||||
import org.badvision.outlaweditor.data.xml.Map;
|
import org.badvision.outlaweditor.data.xml.Map;
|
||||||
import org.badvision.outlaweditor.data.xml.Map.Chunk;
|
import org.badvision.outlaweditor.data.xml.Map.Chunk;
|
||||||
@ -89,7 +90,7 @@ public class TileMap extends ArrayList<ArrayList<Tile>> implements Serializable
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
locationScripts.remove(loc);
|
locationScripts.remove(loc);
|
||||||
Application.getInstance().getController().redrawScripts();
|
ApplicationState.getInstance().getController().redrawScripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerLocationScript(int x, int y, Script s) {
|
private void registerLocationScript(int x, int y, Script s) {
|
||||||
@ -104,7 +105,7 @@ public class TileMap extends ArrayList<ArrayList<Tile>> implements Serializable
|
|||||||
locationScripts.put(loc, list);
|
locationScripts.put(loc, list);
|
||||||
}
|
}
|
||||||
list.add(s);
|
list.add(s);
|
||||||
Application.getInstance().getController().redrawScripts();
|
ApplicationState.getInstance().getController().redrawScripts();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getMortonNumber(int x, int y) {
|
private int getMortonNumber(int x, int y) {
|
||||||
@ -195,7 +196,7 @@ public class TileMap extends ArrayList<ArrayList<Tile>> implements Serializable
|
|||||||
if (t == null) {
|
if (t == null) {
|
||||||
t = new Tile();
|
t = new Tile();
|
||||||
unknownTiles.add(t);
|
unknownTiles.add(t);
|
||||||
Platform p = Application.currentPlatform;
|
Platform p = ApplicationState.getInstance().getCurrentPlatform();
|
||||||
WritableImage img = UIAction.getBadImage(p.tileRenderer.getWidth(), p.tileRenderer.getHeight());
|
WritableImage img = UIAction.getBadImage(p.tileRenderer.getWidth(), p.tileRenderer.getHeight());
|
||||||
TileUtils.setImage(t, p, img);
|
TileUtils.setImage(t, p, img);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ package org.badvision.outlaweditor.data;
|
|||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.badvision.outlaweditor.Application;
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
import org.badvision.outlaweditor.data.xml.Tile;
|
import org.badvision.outlaweditor.data.xml.Tile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,18 +27,18 @@ public class TilesetUtils implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean add(Tile e) {
|
public static boolean add(Tile e) {
|
||||||
boolean output = Application.gameData.getTile().add(e);
|
boolean output = ApplicationState.getInstance().getGameData().getTile().add(e);
|
||||||
DataProducer.notifyObservers(TilesetUtils.class);
|
DataProducer.notifyObservers(TilesetUtils.class);
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clear() {
|
public static void clear() {
|
||||||
Application.gameData.getTile().clear();
|
ApplicationState.getInstance().getGameData().getTile().clear();
|
||||||
DataProducer.notifyObservers(TilesetUtils.class);
|
DataProducer.notifyObservers(TilesetUtils.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void remove(Tile t) {
|
public static void remove(Tile t) {
|
||||||
Application.gameData.getTile().remove(t);
|
ApplicationState.getInstance().getGameData().getTile().remove(t);
|
||||||
DataProducer.notifyObservers(TilesetUtils.class);
|
DataProducer.notifyObservers(TilesetUtils.class);
|
||||||
}
|
}
|
||||||
// The tileset should have been a map in retrospect but now it has to
|
// The tileset should have been a map in retrospect but now it has to
|
||||||
@ -48,7 +48,7 @@ public class TilesetUtils implements Serializable {
|
|||||||
public static Tile getTileById(String tileId) {
|
public static Tile getTileById(String tileId) {
|
||||||
if (lookup == null || (lookup.get(tileId) == null && !lookup.containsKey(tileId))) {
|
if (lookup == null || (lookup.get(tileId) == null && !lookup.containsKey(tileId))) {
|
||||||
lookup = new HashMap<>();
|
lookup = new HashMap<>();
|
||||||
for (Tile t : Application.gameData.getTile()) {
|
for (Tile t : ApplicationState.getInstance().getGameData().getTile()) {
|
||||||
lookup.put(TileUtils.getId(t), t);
|
lookup.put(TileUtils.getId(t), t);
|
||||||
}
|
}
|
||||||
if (lookup.get(tileId) == null) {
|
if (lookup.get(tileId) == null) {
|
||||||
@ -57,4 +57,7 @@ public class TilesetUtils implements Serializable {
|
|||||||
}
|
}
|
||||||
return lookup.get(tileId);
|
return lookup.get(tileId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private TilesetUtils() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ package org.badvision.outlaweditor.ui;
|
|||||||
|
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
|
import javafx.scene.control.Menu;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -19,6 +20,9 @@ import javafx.fxml.FXML;
|
|||||||
*/
|
*/
|
||||||
public abstract class ApplicationMenuController {
|
public abstract class ApplicationMenuController {
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
protected Menu extraMenu;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
abstract public void onChangePlatformAppleDHGRSolid(ActionEvent event);
|
abstract public void onChangePlatformAppleDHGRSolid(ActionEvent event);
|
||||||
|
|
||||||
@ -60,5 +64,6 @@ public abstract class ApplicationMenuController {
|
|||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
abstract public void performUndo(ActionEvent event);
|
abstract public void performUndo(ActionEvent event);
|
||||||
|
|
||||||
|
abstract public void initalize();
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,13 @@ import java.net.URL;
|
|||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
import javafx.event.Event;
|
import javafx.event.Event;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import org.badvision.outlaweditor.Application;
|
|
||||||
import org.badvision.outlaweditor.Editor;
|
import org.badvision.outlaweditor.Editor;
|
||||||
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
|
|
||||||
public abstract class ApplicationUIController {
|
public abstract class ApplicationUIController {
|
||||||
|
|
||||||
public static ApplicationUIController getController() {
|
public static ApplicationUIController getController() {
|
||||||
return Application.getInstance().getController();
|
return ApplicationState.getInstance().getController();
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public void rebuildTileSelectors();
|
abstract public void rebuildTileSelectors();
|
||||||
|
@ -62,10 +62,10 @@ import javafx.util.Duration;
|
|||||||
import javafx.util.converter.DefaultStringConverter;
|
import javafx.util.converter.DefaultStringConverter;
|
||||||
import javax.xml.bind.JAXB;
|
import javax.xml.bind.JAXB;
|
||||||
import org.badvision.outlaweditor.Application;
|
import org.badvision.outlaweditor.Application;
|
||||||
import static org.badvision.outlaweditor.Application.currentPlatform;
|
|
||||||
import org.badvision.outlaweditor.FileUtils;
|
import org.badvision.outlaweditor.FileUtils;
|
||||||
import org.badvision.outlaweditor.MythosEditor;
|
import org.badvision.outlaweditor.MythosEditor;
|
||||||
import org.badvision.outlaweditor.SheetEditor;
|
import org.badvision.outlaweditor.SheetEditor;
|
||||||
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
import org.badvision.outlaweditor.apple.ImageDitherEngine;
|
import org.badvision.outlaweditor.apple.ImageDitherEngine;
|
||||||
import org.badvision.outlaweditor.data.DataUtilities;
|
import org.badvision.outlaweditor.data.DataUtilities;
|
||||||
import org.badvision.outlaweditor.data.TileUtils;
|
import org.badvision.outlaweditor.data.TileUtils;
|
||||||
@ -131,7 +131,7 @@ public class UIAction {
|
|||||||
GameData newData = JAXB.unmarshal(currentSaveFile, GameData.class);
|
GameData newData = JAXB.unmarshal(currentSaveFile, GameData.class);
|
||||||
ApplicationUIController.getController().clearData();
|
ApplicationUIController.getController().clearData();
|
||||||
TilesetUtils.clear();
|
TilesetUtils.clear();
|
||||||
Application.gameData = newData;
|
ApplicationState.getInstance().setGameData(newData);
|
||||||
DataUtilities.ensureGlobalExists();
|
DataUtilities.ensureGlobalExists();
|
||||||
DataUtilities.cleanupAllScriptNames();
|
DataUtilities.cleanupAllScriptNames();
|
||||||
ApplicationUIController.getController().updateSelectors();
|
ApplicationUIController.getController().updateSelectors();
|
||||||
@ -151,7 +151,7 @@ public class UIAction {
|
|||||||
}
|
}
|
||||||
if (currentSaveFile != null) {
|
if (currentSaveFile != null) {
|
||||||
currentSaveFile.delete();
|
currentSaveFile.delete();
|
||||||
JAXB.marshal(Application.gameData, currentSaveFile);
|
JAXB.marshal(ApplicationState.getInstance().getGameData(), currentSaveFile);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -299,10 +299,10 @@ public class UIAction {
|
|||||||
public static void createAndEditUserType() throws IntrospectionException {
|
public static void createAndEditUserType() throws IntrospectionException {
|
||||||
UserType type = new UserType();
|
UserType type = new UserType();
|
||||||
if (editAndGetUserType(type).isPresent()) {
|
if (editAndGetUserType(type).isPresent()) {
|
||||||
if (Application.gameData.getGlobal().getUserTypes() == null) {
|
if (ApplicationState.getInstance().getGameData().getGlobal().getUserTypes() == null) {
|
||||||
Application.gameData.getGlobal().setUserTypes(new Global.UserTypes());
|
ApplicationState.getInstance().getGameData().getGlobal().setUserTypes(new Global.UserTypes());
|
||||||
}
|
}
|
||||||
Application.gameData.getGlobal().getUserTypes().getUserType().add(type);
|
ApplicationState.getInstance().getGameData().getGlobal().getUserTypes().getUserType().add(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -345,10 +345,10 @@ public class UIAction {
|
|||||||
public static Sheet createAndEditSheet() throws IntrospectionException {
|
public static Sheet createAndEditSheet() throws IntrospectionException {
|
||||||
Sheet sheet = new Sheet();
|
Sheet sheet = new Sheet();
|
||||||
sheet.setName("New Sheet");
|
sheet.setName("New Sheet");
|
||||||
if (Application.gameData.getGlobal().getSheets() == null) {
|
if (ApplicationState.getInstance().getGameData().getGlobal().getSheets() == null) {
|
||||||
Application.gameData.getGlobal().setSheets(new Global.Sheets());
|
ApplicationState.getInstance().getGameData().getGlobal().setSheets(new Global.Sheets());
|
||||||
}
|
}
|
||||||
Application.gameData.getGlobal().getSheets().getSheet().add(sheet);
|
ApplicationState.getInstance().getGameData().getGlobal().getSheets().getSheet().add(sheet);
|
||||||
return editSheet(sheet);
|
return editSheet(sheet);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,10 +392,10 @@ public class UIAction {
|
|||||||
}
|
}
|
||||||
currentTileSelector = new AnchorPane();
|
currentTileSelector = new AnchorPane();
|
||||||
|
|
||||||
int TILE_WIDTH = Application.currentPlatform.tileRenderer.getWidth();
|
int TILE_WIDTH = ApplicationState.getInstance().getCurrentPlatform().tileRenderer.getWidth();
|
||||||
int TILE_HEIGHT = Application.currentPlatform.tileRenderer.getHeight();
|
int TILE_HEIGHT = ApplicationState.getInstance().getCurrentPlatform().tileRenderer.getHeight();
|
||||||
|
|
||||||
List<Tile> tiles = Application.gameData.getTile().stream().filter((Tile t) -> {
|
List<Tile> tiles = ApplicationState.getInstance().getGameData().getTile().stream().filter((Tile t) -> {
|
||||||
return category == null || t.getCategory().equals(category);
|
return category == null || t.getCategory().equals(category);
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
|
||||||
@ -406,7 +406,7 @@ public class UIAction {
|
|||||||
currentTileSelector.setPrefHeight(Math.min(numRows * (TILE_HEIGHT + GRID_SPACING) + GRID_SPACING, prefWidth));
|
currentTileSelector.setPrefHeight(Math.min(numRows * (TILE_HEIGHT + GRID_SPACING) + GRID_SPACING, prefWidth));
|
||||||
for (int i = 0; i < tiles.size(); i++) {
|
for (int i = 0; i < tiles.size(); i++) {
|
||||||
final Tile tile = tiles.get(i);
|
final Tile tile = tiles.get(i);
|
||||||
ImageView tileIcon = new ImageView(TileUtils.getImage(tile, currentPlatform));
|
ImageView tileIcon = new ImageView(TileUtils.getImage(tile, ApplicationState.getInstance().getCurrentPlatform()));
|
||||||
currentTileSelector.getChildren().add(tileIcon);
|
currentTileSelector.getChildren().add(tileIcon);
|
||||||
tileIcon.setOnMouseClicked((e) -> {
|
tileIcon.setOnMouseClicked((e) -> {
|
||||||
e.consume();
|
e.consume();
|
||||||
@ -442,8 +442,8 @@ public class UIAction {
|
|||||||
null)));
|
null)));
|
||||||
currentTileSelector.setEffect(new DropShadow(5.0, 1.0, 1.0, Color.BLACK));
|
currentTileSelector.setEffect(new DropShadow(5.0, 1.0, 1.0, Color.BLACK));
|
||||||
anchorPane.getChildren().add(currentTileSelector);
|
anchorPane.getChildren().add(currentTileSelector);
|
||||||
Application.getPrimaryStage().getScene().addEventHandler(KeyEvent.KEY_PRESSED, cancelTileSelectKeyHandler);
|
ApplicationState.getInstance().getPrimaryStage().getScene().addEventHandler(KeyEvent.KEY_PRESSED, cancelTileSelectKeyHandler);
|
||||||
Application.getPrimaryStage().getScene().addEventFilter(MouseEvent.MOUSE_PRESSED, cancelTileSelectMouseHandler);
|
ApplicationState.getInstance().getPrimaryStage().getScene().addEventFilter(MouseEvent.MOUSE_PRESSED, cancelTileSelectMouseHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final EventHandler<MouseEvent> cancelTileSelectMouseHandler = (MouseEvent e) -> {
|
private static final EventHandler<MouseEvent> cancelTileSelectMouseHandler = (MouseEvent e) -> {
|
||||||
@ -460,8 +460,8 @@ public class UIAction {
|
|||||||
};
|
};
|
||||||
|
|
||||||
public static void closeCurrentTileSelector() {
|
public static void closeCurrentTileSelector() {
|
||||||
Application.getPrimaryStage().getScene().removeEventHandler(KeyEvent.KEY_PRESSED, cancelTileSelectKeyHandler);
|
ApplicationState.getInstance().getPrimaryStage().getScene().removeEventHandler(KeyEvent.KEY_PRESSED, cancelTileSelectKeyHandler);
|
||||||
Application.getPrimaryStage().getScene().removeEventFilter(MouseEvent.MOUSE_PRESSED, cancelTileSelectMouseHandler);
|
ApplicationState.getInstance().getPrimaryStage().getScene().removeEventFilter(MouseEvent.MOUSE_PRESSED, cancelTileSelectMouseHandler);
|
||||||
|
|
||||||
fadeOut(currentTileSelector, (ActionEvent ev) -> {
|
fadeOut(currentTileSelector, (ActionEvent ev) -> {
|
||||||
if (currentTileSelector != null) {
|
if (currentTileSelector != null) {
|
||||||
|
@ -14,45 +14,54 @@ import java.io.IOException;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
|
import javafx.scene.control.MenuItem;
|
||||||
import org.badvision.outlaweditor.Application;
|
import org.badvision.outlaweditor.Application;
|
||||||
import org.badvision.outlaweditor.Editor;
|
import org.badvision.outlaweditor.Editor;
|
||||||
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
|
import org.badvision.outlaweditor.api.MenuAction;
|
||||||
import org.badvision.outlaweditor.api.Platform;
|
import org.badvision.outlaweditor.api.Platform;
|
||||||
import org.badvision.outlaweditor.apple.AppleTileRenderer;
|
import org.badvision.outlaweditor.apple.AppleTileRenderer;
|
||||||
import org.badvision.outlaweditor.ui.ApplicationMenuController;
|
import org.badvision.outlaweditor.ui.ApplicationMenuController;
|
||||||
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||||
import org.badvision.outlaweditor.ui.UIAction;
|
import org.badvision.outlaweditor.ui.UIAction;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
import org.osgi.framework.InvalidSyntaxException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author blurry
|
* @author blurry
|
||||||
*/
|
*/
|
||||||
public class ApplicationMenuControllerImpl extends ApplicationMenuController {
|
public class ApplicationMenuControllerImpl extends ApplicationMenuController {
|
||||||
|
@Override
|
||||||
|
public void initalize() {
|
||||||
|
setupPluginMenu();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChangePlatformAppleSolid(ActionEvent event) {
|
public void onChangePlatformAppleSolid(ActionEvent event) {
|
||||||
AppleTileRenderer.useSolidPalette = true;
|
AppleTileRenderer.useSolidPalette = true;
|
||||||
Application.currentPlatform = Platform.AppleII;
|
ApplicationState.getInstance().setCurrentPlatform(Platform.AppleII);
|
||||||
ApplicationUIController.getController().platformChange();
|
ApplicationUIController.getController().platformChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChangePlatformAppleText(ActionEvent event) {
|
public void onChangePlatformAppleText(ActionEvent event) {
|
||||||
AppleTileRenderer.useSolidPalette = false;
|
AppleTileRenderer.useSolidPalette = false;
|
||||||
Application.currentPlatform = Platform.AppleII;
|
ApplicationState.getInstance().setCurrentPlatform(Platform.AppleII);
|
||||||
ApplicationUIController.getController().platformChange();
|
ApplicationUIController.getController().platformChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChangePlatformAppleDHGRSolid(ActionEvent event) {
|
public void onChangePlatformAppleDHGRSolid(ActionEvent event) {
|
||||||
AppleTileRenderer.useSolidPalette = true;
|
AppleTileRenderer.useSolidPalette = true;
|
||||||
Application.currentPlatform = Platform.AppleII_DHGR;
|
ApplicationState.getInstance().setCurrentPlatform(Platform.AppleII_DHGR);
|
||||||
ApplicationUIController.getController().platformChange();
|
ApplicationUIController.getController().platformChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChangePlatformAppleDHGRText(ActionEvent event) {
|
public void onChangePlatformAppleDHGRText(ActionEvent event) {
|
||||||
AppleTileRenderer.useSolidPalette = false;
|
AppleTileRenderer.useSolidPalette = false;
|
||||||
Application.currentPlatform = Platform.AppleII_DHGR;
|
ApplicationState.getInstance().setCurrentPlatform(Platform.AppleII_DHGR);
|
||||||
ApplicationUIController.getController().platformChange();
|
ApplicationUIController.getController().platformChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,4 +145,19 @@ public class ApplicationMenuControllerImpl extends ApplicationMenuController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupPluginMenu() {
|
||||||
|
System.out.println("Setting up extras menu");
|
||||||
|
|
||||||
|
BundleContext bc = ApplicationState.getBundleContext();
|
||||||
|
try {
|
||||||
|
bc.getServiceReferences(MenuAction.class, null).stream().map(bc::getService).forEach((MenuAction a) -> {
|
||||||
|
System.out.println("Adding menu item " + a.getName());
|
||||||
|
MenuItem item = new MenuItem(a.getName());
|
||||||
|
item.setOnAction(a);
|
||||||
|
extraMenu.getItems().add(item);
|
||||||
|
});
|
||||||
|
} catch (InvalidSyntaxException ex) {
|
||||||
|
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,8 @@ package org.badvision.outlaweditor.ui.impl;
|
|||||||
|
|
||||||
import javafx.event.Event;
|
import javafx.event.Event;
|
||||||
import javafx.scene.input.DataFormat;
|
import javafx.scene.input.DataFormat;
|
||||||
import org.badvision.outlaweditor.Application;
|
|
||||||
import org.badvision.outlaweditor.Editor;
|
import org.badvision.outlaweditor.Editor;
|
||||||
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
import org.badvision.outlaweditor.data.TileUtils;
|
import org.badvision.outlaweditor.data.TileUtils;
|
||||||
import org.badvision.outlaweditor.data.TilesetUtils;
|
import org.badvision.outlaweditor.data.TilesetUtils;
|
||||||
import org.badvision.outlaweditor.data.xml.Tile;
|
import org.badvision.outlaweditor.data.xml.Tile;
|
||||||
@ -30,18 +30,19 @@ public class ApplicationUIControllerImpl extends ApplicationUIController {
|
|||||||
public void initialize() {
|
public void initialize() {
|
||||||
super.initialize();
|
super.initialize();
|
||||||
|
|
||||||
TilesetUtils.addObserver((org.badvision.outlaweditor.data.DataObserver) (Object object) -> {
|
TilesetUtils.addObserver((Object object) -> {
|
||||||
rebuildTileSelectors();
|
rebuildTileSelectors();
|
||||||
});
|
});
|
||||||
tileController.initalize();
|
tileController.initalize();
|
||||||
mapController.initalize();
|
mapController.initalize();
|
||||||
imageController.initalize();
|
imageController.initalize();
|
||||||
globalController.initialize();
|
globalController.initialize();
|
||||||
|
menuController.initalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void platformChange() {
|
public void platformChange() {
|
||||||
Application.gameData.getTile().stream().forEach((t) -> {
|
ApplicationState.getInstance().getGameData().getTile().stream().forEach((t) -> {
|
||||||
TileUtils.redrawTile(t);
|
TileUtils.redrawTile(t);
|
||||||
});
|
});
|
||||||
Tile tile = tileController.getCurrentTile();
|
Tile tile = tileController.getCurrentTile();
|
||||||
|
@ -19,8 +19,8 @@ import javafx.scene.control.Tooltip;
|
|||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
import javafx.scene.text.FontWeight;
|
import javafx.scene.text.FontWeight;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import org.badvision.outlaweditor.Application;
|
|
||||||
import org.badvision.outlaweditor.TransferHelper;
|
import org.badvision.outlaweditor.TransferHelper;
|
||||||
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
import org.badvision.outlaweditor.data.DataUtilities;
|
import org.badvision.outlaweditor.data.DataUtilities;
|
||||||
import org.badvision.outlaweditor.data.xml.Script;
|
import org.badvision.outlaweditor.data.xml.Script;
|
||||||
import org.badvision.outlaweditor.data.xml.Sheet;
|
import org.badvision.outlaweditor.data.xml.Sheet;
|
||||||
@ -52,7 +52,7 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startEdit() {
|
public void startEdit() {
|
||||||
UIAction.editVariable(getItem(), Application.gameData.getGlobal());
|
UIAction.editVariable(getItem(), ApplicationState.getInstance().getGameData().getGlobal());
|
||||||
cancelEdit();
|
cancelEdit();
|
||||||
updateItem(getItem(), false);
|
updateItem(getItem(), false);
|
||||||
}
|
}
|
||||||
@ -71,7 +71,7 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startEdit() {
|
public void startEdit() {
|
||||||
UIAction.editScript(getItem(), Application.gameData.getGlobal());
|
UIAction.editScript(getItem(), ApplicationState.getInstance().getGameData().getGlobal());
|
||||||
cancelEdit();
|
cancelEdit();
|
||||||
updateItem(getItem(), false);
|
updateItem(getItem(), false);
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onScriptAddPressed(ActionEvent event) {
|
protected void onScriptAddPressed(ActionEvent event) {
|
||||||
UIAction.createAndEditScript(Application.gameData.getGlobal());
|
UIAction.createAndEditScript(ApplicationState.getInstance().getGameData().getGlobal());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -153,7 +153,7 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
Script script = TransferHelper.cloneObject(source, Script.class, "script");
|
Script script = TransferHelper.cloneObject(source, Script.class, "script");
|
||||||
script.setName(source.getName() + " CLONE");
|
script.setName(source.getName() + " CLONE");
|
||||||
getCurrentEditor().addScript(script);
|
getCurrentEditor().addScript(script);
|
||||||
editScript(script, Application.gameData.getGlobal());
|
editScript(script, ApplicationState.getInstance().getGameData().getGlobal());
|
||||||
} catch (JAXBException ex) {
|
} catch (JAXBException ex) {
|
||||||
Logger.getLogger(MapEditorTabControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(MapEditorTabControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
UIAction.alert("Error occured when attempting clone operation:\n" + ex.getMessage());
|
UIAction.alert("Error occured when attempting clone operation:\n" + ex.getMessage());
|
||||||
@ -180,7 +180,7 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
+ type.getName()
|
+ type.getName()
|
||||||
+ "? There is no undo for this!",
|
+ "? There is no undo for this!",
|
||||||
() -> {
|
() -> {
|
||||||
Application.gameData.getGlobal().getUserTypes().getUserType().remove(type);
|
ApplicationState.getInstance().getGameData().getGlobal().getUserTypes().getUserType().remove(type);
|
||||||
redrawGlobalDataTypes();
|
redrawGlobalDataTypes();
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
@ -197,7 +197,7 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
UserType newType = TransferHelper.cloneObject(source, UserType.class, "userType");
|
UserType newType = TransferHelper.cloneObject(source, UserType.class, "userType");
|
||||||
newType.setName(source.getName() + " CLONE");
|
newType.setName(source.getName() + " CLONE");
|
||||||
if (UIAction.editAndGetUserType(newType) != null) {
|
if (UIAction.editAndGetUserType(newType) != null) {
|
||||||
Application.gameData.getGlobal().getUserTypes().getUserType().add(newType);
|
ApplicationState.getInstance().getGameData().getGlobal().getUserTypes().getUserType().add(newType);
|
||||||
redrawGlobalDataTypes();
|
redrawGlobalDataTypes();
|
||||||
}
|
}
|
||||||
} catch (JAXBException ex) {
|
} catch (JAXBException ex) {
|
||||||
@ -229,7 +229,7 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
+ sheet.getName()
|
+ sheet.getName()
|
||||||
+ "? There is no undo for this!",
|
+ "? There is no undo for this!",
|
||||||
() -> {
|
() -> {
|
||||||
Application.gameData.getGlobal().getSheets().getSheet().remove(sheet);
|
ApplicationState.getInstance().getGameData().getGlobal().getSheets().getSheet().remove(sheet);
|
||||||
redrawGlobalSheets();
|
redrawGlobalSheets();
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
@ -246,7 +246,7 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
Sheet sheet = TransferHelper.cloneObject(source, Sheet.class, "sheet");
|
Sheet sheet = TransferHelper.cloneObject(source, Sheet.class, "sheet");
|
||||||
sheet.setName(source.getName() + " CLONE");
|
sheet.setName(source.getName() + " CLONE");
|
||||||
Sheet newVar = UIAction.editSheet(sheet);
|
Sheet newVar = UIAction.editSheet(sheet);
|
||||||
Application.gameData.getGlobal().getSheets().getSheet().add(newVar);
|
ApplicationState.getInstance().getGameData().getGlobal().getSheets().getSheet().add(newVar);
|
||||||
redrawGlobalSheets();
|
redrawGlobalSheets();
|
||||||
} catch (JAXBException ex) {
|
} catch (JAXBException ex) {
|
||||||
Logger.getLogger(GlobalEditorTabControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(GlobalEditorTabControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
@ -258,7 +258,7 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
@Override
|
@Override
|
||||||
protected void onVariableAddPressed(ActionEvent event) {
|
protected void onVariableAddPressed(ActionEvent event) {
|
||||||
try {
|
try {
|
||||||
UIAction.createAndEditVariable(Application.gameData.getGlobal());
|
UIAction.createAndEditVariable(ApplicationState.getInstance().getGameData().getGlobal());
|
||||||
redrawGlobalVariables();
|
redrawGlobalVariables();
|
||||||
} catch (IntrospectionException ex) {
|
} catch (IntrospectionException ex) {
|
||||||
Logger.getLogger(GlobalEditorTabControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(GlobalEditorTabControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
@ -274,7 +274,7 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
+ var.getName()
|
+ var.getName()
|
||||||
+ "? There is no undo for this!",
|
+ "? There is no undo for this!",
|
||||||
() -> {
|
() -> {
|
||||||
Application.gameData.getGlobal().getVariables().getVariable().remove(var);
|
ApplicationState.getInstance().getGameData().getGlobal().getVariables().getVariable().remove(var);
|
||||||
redrawGlobalVariables();
|
redrawGlobalVariables();
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
@ -292,7 +292,7 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
variable.setName(source.getName() + " CLONE");
|
variable.setName(source.getName() + " CLONE");
|
||||||
Optional<Variable> newVar = UIAction.editAndGetVariable(variable);
|
Optional<Variable> newVar = UIAction.editAndGetVariable(variable);
|
||||||
if (newVar.isPresent()) {
|
if (newVar.isPresent()) {
|
||||||
Application.gameData.getGlobal().getVariables().getVariable().add(newVar.get());
|
ApplicationState.getInstance().getGameData().getGlobal().getVariables().getVariable().add(newVar.get());
|
||||||
redrawGlobalVariables();
|
redrawGlobalVariables();
|
||||||
}
|
}
|
||||||
} catch (JAXBException ex) {
|
} catch (JAXBException ex) {
|
||||||
@ -307,9 +307,9 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
@Override
|
@Override
|
||||||
public void redrawGlobalScripts() {
|
public void redrawGlobalScripts() {
|
||||||
DataUtilities.ensureGlobalExists();
|
DataUtilities.ensureGlobalExists();
|
||||||
if (globalScriptList.getItems() != null && Application.gameData.getGlobal().getScripts() != null) {
|
if (globalScriptList.getItems() != null && ApplicationState.getInstance().getGameData().getGlobal().getScripts() != null) {
|
||||||
DataUtilities.sortNamedEntities(Application.gameData.getGlobal().getScripts().getScript());
|
DataUtilities.sortNamedEntities(ApplicationState.getInstance().getGameData().getGlobal().getScripts().getScript());
|
||||||
globalScriptList.getItems().setAll(Application.gameData.getGlobal().getScripts().getScript());
|
globalScriptList.getItems().setAll(ApplicationState.getInstance().getGameData().getGlobal().getScripts().getScript());
|
||||||
} else {
|
} else {
|
||||||
globalScriptList.getItems().clear();
|
globalScriptList.getItems().clear();
|
||||||
}
|
}
|
||||||
@ -318,9 +318,9 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
@Override
|
@Override
|
||||||
public void redrawGlobalVariables() {
|
public void redrawGlobalVariables() {
|
||||||
DataUtilities.ensureGlobalExists();
|
DataUtilities.ensureGlobalExists();
|
||||||
if (variableList.getItems() != null && Application.gameData.getGlobal().getVariables() != null) {
|
if (variableList.getItems() != null && ApplicationState.getInstance().getGameData().getGlobal().getVariables() != null) {
|
||||||
DataUtilities.sortNamedEntities(Application.gameData.getGlobal().getVariables().getVariable());
|
DataUtilities.sortNamedEntities(ApplicationState.getInstance().getGameData().getGlobal().getVariables().getVariable());
|
||||||
variableList.getItems().setAll(Application.gameData.getGlobal().getVariables().getVariable());
|
variableList.getItems().setAll(ApplicationState.getInstance().getGameData().getGlobal().getVariables().getVariable());
|
||||||
} else {
|
} else {
|
||||||
variableList.getItems().clear();
|
variableList.getItems().clear();
|
||||||
}
|
}
|
||||||
@ -329,9 +329,9 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
@Override
|
@Override
|
||||||
public void redrawGlobalDataTypes() {
|
public void redrawGlobalDataTypes() {
|
||||||
DataUtilities.ensureGlobalExists();
|
DataUtilities.ensureGlobalExists();
|
||||||
if (dataTypeList.getItems() != null && Application.gameData.getGlobal().getUserTypes() != null) {
|
if (dataTypeList.getItems() != null && ApplicationState.getInstance().getGameData().getGlobal().getUserTypes() != null) {
|
||||||
DataUtilities.sortNamedEntities(Application.gameData.getGlobal().getUserTypes().getUserType());
|
DataUtilities.sortNamedEntities(ApplicationState.getInstance().getGameData().getGlobal().getUserTypes().getUserType());
|
||||||
dataTypeList.getItems().setAll(Application.gameData.getGlobal().getUserTypes().getUserType());
|
dataTypeList.getItems().setAll(ApplicationState.getInstance().getGameData().getGlobal().getUserTypes().getUserType());
|
||||||
} else {
|
} else {
|
||||||
dataTypeList.getItems().clear();
|
dataTypeList.getItems().clear();
|
||||||
}
|
}
|
||||||
@ -340,9 +340,9 @@ public class GlobalEditorTabControllerImpl extends GlobalEditorTabController {
|
|||||||
@Override
|
@Override
|
||||||
public void redrawGlobalSheets() {
|
public void redrawGlobalSheets() {
|
||||||
DataUtilities.ensureGlobalExists();
|
DataUtilities.ensureGlobalExists();
|
||||||
if (sheetList.getItems() != null && Application.gameData.getGlobal().getSheets() != null) {
|
if (sheetList.getItems() != null && ApplicationState.getInstance().getGameData().getGlobal().getSheets() != null) {
|
||||||
DataUtilities.sortNamedEntities(Application.gameData.getGlobal().getSheets().getSheet());
|
DataUtilities.sortNamedEntities(ApplicationState.getInstance().getGameData().getGlobal().getSheets().getSheet());
|
||||||
sheetList.getItems().setAll(Application.gameData.getGlobal().getSheets().getSheet());
|
sheetList.getItems().setAll(ApplicationState.getInstance().getGameData().getGlobal().getSheets().getSheet());
|
||||||
} else {
|
} else {
|
||||||
sheetList.getItems().clear();
|
sheetList.getItems().clear();
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@ import javafx.scene.control.ListView;
|
|||||||
import javafx.util.StringConverter;
|
import javafx.util.StringConverter;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import org.badvision.outlaweditor.Application;
|
import org.badvision.outlaweditor.Application;
|
||||||
import static org.badvision.outlaweditor.Application.currentPlatform;
|
|
||||||
import org.badvision.outlaweditor.Editor;
|
import org.badvision.outlaweditor.Editor;
|
||||||
import org.badvision.outlaweditor.ImageEditor;
|
import org.badvision.outlaweditor.ImageEditor;
|
||||||
import org.badvision.outlaweditor.TransferHelper;
|
import org.badvision.outlaweditor.TransferHelper;
|
||||||
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
import static org.badvision.outlaweditor.data.PropertyHelper.bind;
|
import static org.badvision.outlaweditor.data.PropertyHelper.bind;
|
||||||
import static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
|
import static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
|
||||||
import org.badvision.outlaweditor.data.xml.Image;
|
import org.badvision.outlaweditor.data.xml.Image;
|
||||||
@ -149,7 +149,7 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
|||||||
}
|
}
|
||||||
Image clone = TransferHelper.cloneObject(getCurrentImage(), Image.class, "image");
|
Image clone = TransferHelper.cloneObject(getCurrentImage(), Image.class, "image");
|
||||||
clone.setName(clone.getName()+" clone");
|
clone.setName(clone.getName()+" clone");
|
||||||
Application.gameData.getImage().add(clone);
|
ApplicationState.getInstance().getGameData().getImage().add(clone);
|
||||||
setCurrentImage(clone);
|
setCurrentImage(clone);
|
||||||
rebuildImageSelector();
|
rebuildImageSelector();
|
||||||
} catch (JAXBException ex) {
|
} catch (JAXBException ex) {
|
||||||
@ -161,7 +161,7 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
|||||||
public void onImageCreatePressed(ActionEvent event) {
|
public void onImageCreatePressed(ActionEvent event) {
|
||||||
Image i = new Image();
|
Image i = new Image();
|
||||||
i.setName("Untitled");
|
i.setName("Untitled");
|
||||||
Application.gameData.getImage().add(i);
|
ApplicationState.getInstance().getGameData().getImage().add(i);
|
||||||
setCurrentImage(i);
|
setCurrentImage(i);
|
||||||
rebuildImageSelector();
|
rebuildImageSelector();
|
||||||
}
|
}
|
||||||
@ -174,7 +174,7 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
|||||||
confirm("Delete image '" + currentImage.getName() + "'. Are you sure?", () -> {
|
confirm("Delete image '" + currentImage.getName() + "'. Are you sure?", () -> {
|
||||||
Image del = currentImage;
|
Image del = currentImage;
|
||||||
setCurrentImage(null);
|
setCurrentImage(null);
|
||||||
Application.gameData.getImage().remove(del);
|
ApplicationState.getInstance().getGameData().getImage().remove(del);
|
||||||
rebuildImageSelector();
|
rebuildImageSelector();
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
|||||||
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
currentImageEditor = currentPlatform.imageEditor.newInstance();
|
currentImageEditor = ApplicationState.getInstance().getCurrentPlatform().imageEditor.newInstance();
|
||||||
} catch (InstantiationException | IllegalAccessException ex) {
|
} catch (InstantiationException | IllegalAccessException ex) {
|
||||||
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
Logger.getLogger(ApplicationUIControllerImpl.class.getName()).log(Level.SEVERE, null, ex);
|
||||||
}
|
}
|
||||||
@ -262,7 +262,7 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
|
|||||||
public void rebuildImageSelector() {
|
public void rebuildImageSelector() {
|
||||||
Image i = getCurrentImage();
|
Image i = getCurrentImage();
|
||||||
imageSelector.getItems().clear();
|
imageSelector.getItems().clear();
|
||||||
List<Image> allImages = Application.gameData.getImage();
|
List<Image> allImages = ApplicationState.getInstance().getGameData().getImage();
|
||||||
allImages.sort((Image o1, Image o2) -> {
|
allImages.sort((Image o1, Image o2) -> {
|
||||||
int c1 = String.valueOf(o1.getCategory()).compareTo(String.valueOf(o2.getCategory()));
|
int c1 = String.valueOf(o1.getCategory()).compareTo(String.valueOf(o2.getCategory()));
|
||||||
if (c1 != 0) {
|
if (c1 != 0) {
|
||||||
|
@ -26,10 +26,9 @@ import javafx.scene.text.Font;
|
|||||||
import javafx.scene.text.FontWeight;
|
import javafx.scene.text.FontWeight;
|
||||||
import javax.xml.bind.JAXBException;
|
import javax.xml.bind.JAXBException;
|
||||||
import org.badvision.outlaweditor.Application;
|
import org.badvision.outlaweditor.Application;
|
||||||
import static org.badvision.outlaweditor.Application.currentPlatform;
|
|
||||||
import static org.badvision.outlaweditor.Application.gameData;
|
|
||||||
import org.badvision.outlaweditor.MapEditor;
|
import org.badvision.outlaweditor.MapEditor;
|
||||||
import org.badvision.outlaweditor.TransferHelper;
|
import org.badvision.outlaweditor.TransferHelper;
|
||||||
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
import org.badvision.outlaweditor.data.DataUtilities;
|
import org.badvision.outlaweditor.data.DataUtilities;
|
||||||
import static org.badvision.outlaweditor.data.PropertyHelper.bind;
|
import static org.badvision.outlaweditor.data.PropertyHelper.bind;
|
||||||
import static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
|
import static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
|
||||||
@ -121,7 +120,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
|||||||
m.setName("Untitled");
|
m.setName("Untitled");
|
||||||
m.setWidth(512);
|
m.setWidth(512);
|
||||||
m.setHeight(512);
|
m.setHeight(512);
|
||||||
gameData.getMap().add(m);
|
ApplicationState.getInstance().getGameData().getMap().add(m);
|
||||||
rebuildMapSelectors();
|
rebuildMapSelectors();
|
||||||
setCurrentMap(m);
|
setCurrentMap(m);
|
||||||
}
|
}
|
||||||
@ -135,7 +134,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
|||||||
confirm("Delete map '" + currentMap.getName() + "'. Are you sure?", () -> {
|
confirm("Delete map '" + currentMap.getName() + "'. Are you sure?", () -> {
|
||||||
org.badvision.outlaweditor.data.xml.Map del = currentMap;
|
org.badvision.outlaweditor.data.xml.Map del = currentMap;
|
||||||
setCurrentMap(null);
|
setCurrentMap(null);
|
||||||
Application.gameData.getMap().remove(del);
|
ApplicationState.getInstance().getGameData().getMap().remove(del);
|
||||||
rebuildMapSelectors();
|
rebuildMapSelectors();
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
@ -337,8 +336,8 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
|||||||
public void rebuildMapSelectors() {
|
public void rebuildMapSelectors() {
|
||||||
Map m = mapSelect.getSelectionModel().getSelectedItem();
|
Map m = mapSelect.getSelectionModel().getSelectedItem();
|
||||||
mapSelect.getItems().clear();
|
mapSelect.getItems().clear();
|
||||||
DataUtilities.sortMaps(Application.gameData.getMap());
|
DataUtilities.sortMaps(ApplicationState.getInstance().getGameData().getMap());
|
||||||
mapSelect.getItems().addAll(Application.gameData.getMap());
|
mapSelect.getItems().addAll(ApplicationState.getInstance().getGameData().getMap());
|
||||||
mapSelect.getSelectionModel().select(m);
|
mapSelect.getSelectionModel().select(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,8 +374,8 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
|||||||
|
|
||||||
ToggleGroup tileGroup = new ToggleGroup();
|
ToggleGroup tileGroup = new ToggleGroup();
|
||||||
HashMap<String, Menu> submenus = new HashMap<>();
|
HashMap<String, Menu> submenus = new HashMap<>();
|
||||||
Application.gameData.getTile().stream().forEach((Tile t) -> {
|
ApplicationState.getInstance().getGameData().getTile().stream().forEach((Tile t) -> {
|
||||||
WritableImage img = TileUtils.getImage(t, currentPlatform);
|
WritableImage img = TileUtils.getImage(t, ApplicationState.getInstance().getCurrentPlatform());
|
||||||
ImageView iv = new ImageView(img);
|
ImageView iv = new ImageView(img);
|
||||||
String category = String.valueOf(t.getCategory());
|
String category = String.valueOf(t.getCategory());
|
||||||
Menu categoryMenu = submenus.get(category);
|
Menu categoryMenu = submenus.get(category);
|
||||||
@ -391,7 +390,7 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
|
|||||||
tileGroup.selectToggle(tileSelection);
|
tileGroup.selectToggle(tileSelection);
|
||||||
theMenu.setStyle("-fx-font-weight:bold; -fx-text-fill:blue");
|
theMenu.setStyle("-fx-font-weight:bold; -fx-text-fill:blue");
|
||||||
}
|
}
|
||||||
tileSelection.setGraphic(new ImageView(TileUtils.getImage(t, currentPlatform)));
|
tileSelection.setGraphic(new ImageView(TileUtils.getImage(t, ApplicationState.getInstance().getCurrentPlatform())));
|
||||||
tileSelection.setOnAction((event) -> {
|
tileSelection.setOnAction((event) -> {
|
||||||
if (getCurrentEditor() != null) {
|
if (getCurrentEditor() != null) {
|
||||||
getCurrentEditor().setCurrentTile(t);
|
getCurrentEditor().setCurrentTile(t);
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
package org.badvision.outlaweditor.ui.impl;
|
package org.badvision.outlaweditor.ui.impl;
|
||||||
|
|
||||||
import org.badvision.outlaweditor.ui.EntitySelectorCell;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -23,7 +22,7 @@ import javafx.scene.image.ImageView;
|
|||||||
import javafx.util.StringConverter;
|
import javafx.util.StringConverter;
|
||||||
import org.badvision.outlaweditor.Application;
|
import org.badvision.outlaweditor.Application;
|
||||||
import org.badvision.outlaweditor.TileEditor;
|
import org.badvision.outlaweditor.TileEditor;
|
||||||
import static org.badvision.outlaweditor.ui.UIAction.confirm;
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
import static org.badvision.outlaweditor.data.PropertyHelper.bind;
|
import static org.badvision.outlaweditor.data.PropertyHelper.bind;
|
||||||
import static org.badvision.outlaweditor.data.PropertyHelper.boolProp;
|
import static org.badvision.outlaweditor.data.PropertyHelper.boolProp;
|
||||||
import static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
|
import static org.badvision.outlaweditor.data.PropertyHelper.stringProp;
|
||||||
@ -32,7 +31,9 @@ import org.badvision.outlaweditor.data.TilesetUtils;
|
|||||||
import org.badvision.outlaweditor.data.xml.PlatformData;
|
import org.badvision.outlaweditor.data.xml.PlatformData;
|
||||||
import org.badvision.outlaweditor.data.xml.Tile;
|
import org.badvision.outlaweditor.data.xml.Tile;
|
||||||
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||||
|
import org.badvision.outlaweditor.ui.EntitySelectorCell;
|
||||||
import org.badvision.outlaweditor.ui.TileEditorTabController;
|
import org.badvision.outlaweditor.ui.TileEditorTabController;
|
||||||
|
import static org.badvision.outlaweditor.ui.UIAction.confirm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FXML Controller class for tile editor tab
|
* FXML Controller class for tile editor tab
|
||||||
@ -95,7 +96,7 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
|||||||
confirm("Delete tile '" + getCurrentTile().getName() + "'. Are you sure?", () -> {
|
confirm("Delete tile '" + getCurrentTile().getName() + "'. Are you sure?", () -> {
|
||||||
Tile del = getCurrentTile();
|
Tile del = getCurrentTile();
|
||||||
setCurrentTile(null);
|
setCurrentTile(null);
|
||||||
Application.gameData.getTile().remove(del);
|
ApplicationState.getInstance().getGameData().getTile().remove(del);
|
||||||
mainController.rebuildTileSelectors();
|
mainController.rebuildTileSelectors();
|
||||||
}, null);
|
}, null);
|
||||||
}
|
}
|
||||||
@ -150,7 +151,7 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
|||||||
return new EntitySelectorCell<Tile>(tileNameField, tileCategoryField) {
|
return new EntitySelectorCell<Tile>(tileNameField, tileCategoryField) {
|
||||||
@Override
|
@Override
|
||||||
public void finishUpdate(Tile item) {
|
public void finishUpdate(Tile item) {
|
||||||
setGraphic(new ImageView(TileUtils.getImage(item, Application.currentPlatform)));
|
setGraphic(new ImageView(TileUtils.getImage(item, ApplicationState.getInstance().getCurrentPlatform())));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -223,7 +224,7 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
|||||||
bind(tileSpriteField.selectedProperty(), boolProp(t, "sprite"));
|
bind(tileSpriteField.selectedProperty(), boolProp(t, "sprite"));
|
||||||
bind(tileBlockerField.selectedProperty(), boolProp(t, "blocker"));
|
bind(tileBlockerField.selectedProperty(), boolProp(t, "blocker"));
|
||||||
bind(tileNameField.textProperty(), stringProp(t, "name"));
|
bind(tileNameField.textProperty(), stringProp(t, "name"));
|
||||||
TileEditor editor = Application.currentPlatform.tileEditor.newInstance();
|
TileEditor editor = ApplicationState.getInstance().getCurrentPlatform().tileEditor.newInstance();
|
||||||
editor.setEntity(t);
|
editor.setEntity(t);
|
||||||
setCurrentTileEditor(editor);
|
setCurrentTileEditor(editor);
|
||||||
tileNameField.textProperty().addListener(rebuildListener);
|
tileNameField.textProperty().addListener(rebuildListener);
|
||||||
@ -241,7 +242,7 @@ public class TileEditorTabControllerImpl extends TileEditorTabController {
|
|||||||
public void rebuildTileSelectors() {
|
public void rebuildTileSelectors() {
|
||||||
Tile t = getCurrentTile();
|
Tile t = getCurrentTile();
|
||||||
tileSelector.getItems().clear();
|
tileSelector.getItems().clear();
|
||||||
List<Tile> allTiles = Application.gameData.getTile();
|
List<Tile> allTiles = ApplicationState.getInstance().getGameData().getTile();
|
||||||
allTiles.sort((Tile o1, Tile o2) -> {
|
allTiles.sort((Tile o1, Tile o2) -> {
|
||||||
int c1 = String.valueOf(o1.getCategory()).compareTo(String.valueOf(o2.getCategory()));
|
int c1 = String.valueOf(o1.getCategory()).compareTo(String.valueOf(o2.getCategory()));
|
||||||
if (c1 != 0) {
|
if (c1 != 0) {
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<?import javafx.scene.input.*?>
|
<?import javafx.scene.control.Menu?>
|
||||||
<?import java.lang.*?>
|
<?import javafx.scene.control.MenuBar?>
|
||||||
<?import java.util.*?>
|
<?import javafx.scene.control.MenuItem?>
|
||||||
<?import javafx.scene.*?>
|
<?import javafx.scene.input.KeyCodeCombination?>
|
||||||
<?import javafx.scene.control.*?>
|
|
||||||
<?import javafx.scene.layout.*?>
|
|
||||||
|
|
||||||
<MenuBar styleClass="menu" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.badvision.outlaweditor.ui.impl.ApplicationMenuControllerImpl">
|
<MenuBar styleClass="menu" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.badvision.outlaweditor.ui.impl.ApplicationMenuControllerImpl">
|
||||||
<menus>
|
<menus>
|
||||||
<Menu mnemonicParsing="false" text="File">
|
<Menu mnemonicParsing="false" text="File">
|
||||||
<items>
|
<items>
|
||||||
@ -38,6 +36,7 @@
|
|||||||
</Menu>
|
</Menu>
|
||||||
</items>
|
</items>
|
||||||
</Menu>
|
</Menu>
|
||||||
|
<Menu fx:id="extraMenu" mnemonicParsing="false" text="Extras" />
|
||||||
<Menu mnemonicParsing="false" text="Help">
|
<Menu mnemonicParsing="false" text="Help">
|
||||||
<items>
|
<items>
|
||||||
<MenuItem mnemonicParsing="false" onAction="#onHelpAbout" text="About" />
|
<MenuItem mnemonicParsing="false" onAction="#onHelpAbout" text="About" />
|
||||||
|
Loading…
Reference in New Issue
Block a user