mirror of
https://github.com/badvision/lawless-legends.git
synced 2024-11-18 23:07:53 +00:00
Added example interaction to plugin
This commit is contained in:
parent
a521b66045
commit
5e1e01e896
@ -9,25 +9,26 @@ import org.apache.felix.scr.annotations.Reference;
|
|||||||
import org.apache.felix.scr.annotations.Service;
|
import org.apache.felix.scr.annotations.Service;
|
||||||
import org.badvision.outlaweditor.api.ApplicationState;
|
import org.badvision.outlaweditor.api.ApplicationState;
|
||||||
import org.badvision.outlaweditor.api.MenuAction;
|
import org.badvision.outlaweditor.api.MenuAction;
|
||||||
|
import org.badvision.outlaweditor.ui.UIAction;
|
||||||
import org.osgi.framework.BundleContext;
|
import org.osgi.framework.BundleContext;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This registers a simple plugin that does nothing more than print a message
|
* This registers a simple plugin that does nothing more than print a message to
|
||||||
* to the console when executed. However, this plugin also demonstrates how
|
* the console when executed. However, this plugin also demonstrates how to
|
||||||
* to inject dependencies to more useful features, specifically the ApplicationState
|
* inject dependencies to more useful features, specifically the
|
||||||
* which in turn provides all game data, etc.
|
* ApplicationState which in turn provides all game data, etc.
|
||||||
|
*
|
||||||
* @author blurry
|
* @author blurry
|
||||||
*/
|
*/
|
||||||
@Component(immediate = true)
|
@Component(immediate = true)
|
||||||
@Service(MenuAction.class)
|
@Service(MenuAction.class)
|
||||||
public class ExamplePlugin implements MenuAction {
|
public class ExamplePlugin implements MenuAction {
|
||||||
|
|
||||||
// Note: Because ApplicationState is already a defined service, this will automatically be bound.
|
// Note: Because ApplicationState is already a defined service, this will automatically be bound.
|
||||||
// Hence, it is not necessary to worry about passing it it.
|
// Hence, it is not necessary to worry about passing it it.
|
||||||
@Reference
|
@Reference
|
||||||
ApplicationState app;
|
ApplicationState app;
|
||||||
|
|
||||||
// This is called when our plugin is starting
|
// This is called when our plugin is starting
|
||||||
@Activate
|
@Activate
|
||||||
public void activate() throws Exception {
|
public void activate() throws Exception {
|
||||||
@ -53,18 +54,19 @@ public class ExamplePlugin implements MenuAction {
|
|||||||
System.out.println("Clicked!");
|
System.out.println("Clicked!");
|
||||||
JAXB.marshal(ApplicationState.getInstance().getGameData(), System.out);
|
JAXB.marshal(ApplicationState.getInstance().getGameData(), System.out);
|
||||||
checkReferences();
|
checkReferences();
|
||||||
|
UIAction.confirm("Did you mean to click that?",
|
||||||
|
() -> UIAction.alert("Well isn't that special?"),
|
||||||
|
() -> UIAction.alert("You should be more careful next time then."));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkReferences() {
|
private void checkReferences() {
|
||||||
// app = ApplicationState.getInstance();
|
// 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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user