mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-06-26 00:29:30 +00:00
First step in having an API: The global application state is now an OSGi component and can be accessed by the plugins.
This commit is contained in:
parent
485776902e
commit
594fb0e10e
|
@ -22,6 +22,7 @@
|
|||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<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>
|
||||
<Bundle-Activator>org.badvision.outlaw.plugin.example.Activator</Bundle-Activator>
|
||||
</instructions>
|
||||
|
@ -30,131 +31,6 @@
|
|||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>build-for-felix</id>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.main</artifactId>
|
||||
<version>5.4.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- To include a shell:
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.gogo.shell</artifactId>
|
||||
<version>0.10.0</version>
|
||||
</dependency>
|
||||
-->
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.8</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<target>
|
||||
<pathconvert property="plugins.jars" pathsep="${path.separator}">
|
||||
<path refid="maven.runtime.classpath"/>
|
||||
<map from="${project.build.directory}${file.separator}classes" to=""/>
|
||||
</pathconvert>
|
||||
<pathconvert pathsep=" " property="bundles">
|
||||
<path path="${plugins.jars}"/>
|
||||
<mapper>
|
||||
<chainedmapper>
|
||||
<flattenmapper/>
|
||||
<globmapper from="*" to="file:modules/*" casesensitive="no"/>
|
||||
</chainedmapper>
|
||||
</mapper>
|
||||
</pathconvert>
|
||||
<propertyfile file="${project.build.directory}/config.properties">
|
||||
<entry key="felix.auto.start" value="${bundles} file:modules/${project.build.finalName}.jar"/>
|
||||
<entry key="org.osgi.framework.bootdelegation" value="*"/>
|
||||
</propertyfile>
|
||||
<copy file="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}" tofile="${project.build.directory}/felix.jar"/>
|
||||
</target>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>create-executable-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>${basedir}/src/main/assembly/felix.xml</descriptor>
|
||||
</descriptors>
|
||||
<finalName>${project.build.finalName}</finalName>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>run-on-felix</id>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.main</artifactId>
|
||||
<version>5.4.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- org.apache.felix:org.apache.felix.gogo.shell:0.6.1 useless from Maven since stdin is swallowed -->
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.8</version>
|
||||
<configuration>
|
||||
<target>
|
||||
<property name="vm.args" value=""/>
|
||||
<pathconvert property="plugins.jars" pathsep="${path.separator}">
|
||||
<path refid="maven.runtime.classpath"/>
|
||||
<map from="${project.build.directory}${file.separator}classes" to=""/>
|
||||
</pathconvert>
|
||||
<makeurl property="urls" separator=" ">
|
||||
<path path="${plugins.jars}"/>
|
||||
<path location="${project.build.directory}/${project.build.finalName}.jar"/>
|
||||
</makeurl>
|
||||
<propertyfile file="${project.build.directory}/run.properties">
|
||||
<entry key="felix.auto.start" value="${urls}"/>
|
||||
<entry key="felix.auto.deploy.action" value="uninstall,install,update,start"/>
|
||||
<entry key="org.osgi.framework.storage" value="${project.build.directory}${file.separator}felix-cache"/>
|
||||
<entry key="org.osgi.framework.bootdelegation" value="*"/>
|
||||
</propertyfile>
|
||||
<makeurl property="run.properties.url" file="${project.build.directory}/run.properties"/>
|
||||
<java fork="true" jar="${maven.dependency.org.apache.felix.org.apache.felix.main.jar.path}">
|
||||
<sysproperty key="felix.config.properties" value="${run.properties.url}"/>
|
||||
<jvmarg line="${vm.args}"/>
|
||||
</java>
|
||||
</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
|
@ -162,5 +38,15 @@
|
|||
<version>5.4.0</version>
|
||||
<type>jar</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>OutlawEditor</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.scr.annotations</artifactId>
|
||||
<version>1.10.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
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.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
|
@ -9,8 +12,19 @@ import org.osgi.framework.BundleContext;
|
|||
*/
|
||||
public class Activator implements BundleActivator {
|
||||
|
||||
|
||||
public void start(BundleContext bc) throws Exception {
|
||||
System.out.println("Hello, world!");
|
||||
ApplicationState app = bc.getService(bc.getServiceReference(ApplicationState.class));
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void stop(BundleContext bc) throws Exception {
|
||||
|
|
|
@ -19,6 +19,23 @@
|
|||
<build>
|
||||
<finalName>OutlawEditor</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
<version>1.22.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Private-Package>org.badvision.outlaweditor,org.badvision.outlaweditor.ui.impl,org.badvision.outlaweditor.ui.apple</Private-Package>
|
||||
<Export-Package>org.badvision.outlaweditor.api,org.badvision.outlaweditor.data.xml,org.badvision.outlaweditor.data,org.badvision.outlaweditor.ui</Export-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
|
@ -146,5 +163,10 @@
|
|||
<artifactId>org.osgi.core</artifactId>
|
||||
<version>4.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.scr.annotations</artifactId>
|
||||
<version>1.10.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -11,6 +11,7 @@ package org.badvision.outlaweditor;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Hashtable;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -22,6 +23,9 @@ import javafx.stage.Stage;
|
|||
import javafx.stage.WindowEvent;
|
||||
import org.apache.felix.framework.Felix;
|
||||
import org.apache.felix.main.AutoProcessor;
|
||||
import org.apache.felix.scr.annotations.Component;
|
||||
import org.badvision.outlaweditor.api.ApplicationState;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.data.xml.GameData;
|
||||
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||
import org.osgi.framework.BundleException;
|
||||
|
@ -30,7 +34,8 @@ import org.osgi.framework.BundleException;
|
|||
*
|
||||
* @author brobert
|
||||
*/
|
||||
public class Application extends javafx.application.Application {
|
||||
@Component(name = "org.badvision.outlaweditor.api.ApplicationState")
|
||||
public class Application extends javafx.application.Application implements ApplicationState {
|
||||
|
||||
public static GameData gameData = new GameData();
|
||||
public static Platform currentPlatform = Platform.AppleII;
|
||||
|
@ -110,8 +115,30 @@ public class Application extends javafx.application.Application {
|
|||
pluginConfiguration.put("felix.cache.locking", "false");
|
||||
pluginConfiguration.put("felix.auto.deploy.action", "install,start");
|
||||
pluginConfiguration.put("felix.auto.deploy.dir", "install");
|
||||
pluginConfiguration.put("org.osgi.framework.system.packages.extra",
|
||||
"org.badvision.outlaweditor.api,"
|
||||
+ "org.badvision.outlaweditor.data,"
|
||||
+ "org.badvision.outlaweditor.data.xml,"
|
||||
+ "org.badvision.outlaweditor.ui,"
|
||||
+ "org.osgi.framework");
|
||||
pluginContainer = new Felix(pluginConfiguration);
|
||||
pluginContainer.start();
|
||||
pluginContainer.getBundleContext().registerService(ApplicationState.class, this, new Hashtable<>());
|
||||
AutoProcessor.process(pluginConfiguration, pluginContainer.getBundleContext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameData getGameData() {
|
||||
return gameData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationUIController getApplicationUI() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Platform getCurrentPlatform() {
|
||||
return currentPlatform;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
package org.badvision.outlaweditor;
|
||||
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import org.badvision.outlaweditor.data.xml.Image;
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
package org.badvision.outlaweditor;
|
||||
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import java.util.EnumMap;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* 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 org.badvision.outlaweditor.data.xml.GameData;
|
||||
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author blurry
|
||||
*/
|
||||
public interface ApplicationState {
|
||||
public GameData getGameData();
|
||||
public ApplicationUIController getApplicationUI();
|
||||
public Platform getCurrentPlatform();
|
||||
|
||||
}
|
|
@ -8,8 +8,12 @@
|
|||
* governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.badvision.outlaweditor;
|
||||
package org.badvision.outlaweditor.api;
|
||||
|
||||
import org.badvision.outlaweditor.ImageEditor;
|
||||
import org.badvision.outlaweditor.ImageRenderer;
|
||||
import org.badvision.outlaweditor.TileEditor;
|
||||
import org.badvision.outlaweditor.TileRenderer;
|
||||
import org.badvision.outlaweditor.apple.AppleImageEditor;
|
||||
import org.badvision.outlaweditor.apple.AppleTileEditor;
|
||||
import org.badvision.outlaweditor.apple.AppleTileRenderer;
|
|
@ -31,7 +31,7 @@ import javafx.scene.shape.Rectangle;
|
|||
import org.badvision.outlaweditor.Application;
|
||||
import org.badvision.outlaweditor.FileUtils;
|
||||
import org.badvision.outlaweditor.ImageEditor;
|
||||
import org.badvision.outlaweditor.Platform;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.TransferHelper;
|
||||
import org.badvision.outlaweditor.data.TileMap;
|
||||
import org.badvision.outlaweditor.data.xml.Image;
|
||||
|
|
|
@ -14,7 +14,7 @@ import javafx.scene.image.PixelWriter;
|
|||
import static org.badvision.outlaweditor.apple.AppleNTSCGraphics.*;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import org.badvision.outlaweditor.ImageRenderer;
|
||||
import org.badvision.outlaweditor.Platform;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.data.TileMap;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
import org.badvision.outlaweditor.data.xml.Tile;
|
||||
|
|
|
@ -19,7 +19,7 @@ import javafx.scene.layout.Pane;
|
|||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import javafx.scene.shape.Shape;
|
||||
import org.badvision.outlaweditor.Platform;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.TileEditor;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
import org.badvision.outlaweditor.data.xml.Tile;
|
||||
|
|
|
@ -19,7 +19,7 @@ import javafx.scene.control.Menu;
|
|||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import org.badvision.outlaweditor.Platform;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import static org.badvision.outlaweditor.apple.AppleNTSCGraphics.hgrToDhgr;
|
||||
import org.badvision.outlaweditor.data.DataObserver;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
|
|
|
@ -23,7 +23,7 @@ import javafx.scene.image.PixelReader;
|
|||
import javafx.scene.image.PixelWriter;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import javafx.scene.paint.Color;
|
||||
import org.badvision.outlaweditor.Platform;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import static org.badvision.outlaweditor.apple.AppleNTSCGraphics.hgrToDhgr;
|
||||
|
||||
/* Copyright (c) 2013 the authors listed at the following URL, and/or
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.badvision.outlaweditor.apple.*;
|
|||
import javafx.event.EventHandler;
|
||||
import javafx.scene.control.Menu;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import org.badvision.outlaweditor.Platform;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.data.DataObserver;
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,7 +12,7 @@ package org.badvision.outlaweditor.apple.dhgr;
|
|||
|
||||
import org.badvision.outlaweditor.apple.*;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import org.badvision.outlaweditor.Platform;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.data.TileMap;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
import org.badvision.outlaweditor.data.xml.Tile;
|
||||
|
|
|
@ -19,7 +19,7 @@ import javafx.scene.layout.Pane;
|
|||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import javafx.scene.shape.Shape;
|
||||
import org.badvision.outlaweditor.Platform;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.TileEditor;
|
||||
import org.badvision.outlaweditor.data.xml.Tile;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
|
|
|
@ -19,7 +19,7 @@ import javafx.scene.control.Menu;
|
|||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.image.WritableImage;
|
||||
import org.badvision.outlaweditor.Platform;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.data.DataObserver;
|
||||
import org.badvision.outlaweditor.data.TileUtils;
|
||||
import org.badvision.outlaweditor.data.xml.Tile;
|
||||
|
|
|
@ -22,7 +22,7 @@ import javafx.scene.image.WritableImage;
|
|||
import javafx.scene.paint.Color;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import org.badvision.outlaweditor.Application;
|
||||
import org.badvision.outlaweditor.Platform;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.data.xml.Map;
|
||||
import org.badvision.outlaweditor.data.xml.Map.Chunk;
|
||||
import org.badvision.outlaweditor.data.xml.ObjectFactory;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
package org.badvision.outlaweditor.data;
|
||||
|
||||
import org.badvision.outlaweditor.Platform;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
|
|
@ -16,7 +16,7 @@ import java.util.logging.Logger;
|
|||
import javafx.event.ActionEvent;
|
||||
import org.badvision.outlaweditor.Application;
|
||||
import org.badvision.outlaweditor.Editor;
|
||||
import org.badvision.outlaweditor.Platform;
|
||||
import org.badvision.outlaweditor.api.Platform;
|
||||
import org.badvision.outlaweditor.apple.AppleTileRenderer;
|
||||
import org.badvision.outlaweditor.ui.ApplicationMenuController;
|
||||
import org.badvision.outlaweditor.ui.ApplicationUIController;
|
||||
|
|
|
@ -49,9 +49,9 @@ public class ImageDitheringTest {
|
|||
@Before
|
||||
public void setUp() {
|
||||
AppleTileRenderer.useSolidPalette = false;
|
||||
hgrDither = new ImageDitherEngine(org.badvision.outlaweditor.Platform.AppleII);
|
||||
hgrDither = new ImageDitherEngine(org.badvision.outlaweditor.api.Platform.AppleII);
|
||||
hgrDither.setOutputDimensions(40, 192);
|
||||
dhgrDither = new ImageDitherEngine(org.badvision.outlaweditor.Platform.AppleII_DHGR);
|
||||
dhgrDither = new ImageDitherEngine(org.badvision.outlaweditor.api.Platform.AppleII_DHGR);
|
||||
dhgrDither.setOutputDimensions(80, 192);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user