public interface InteractionDialogPlugin
BaseCampaignPlugin and implement the logic in the pickInteractionDialogPlugin
method.
Example
// This is a simple dialog with some text, an image and an option.
// Note: For simplicity sake, error handling and null-checking is omitted in this example
class MyDialog implements InteractionDialogPlugin{
interface ExecutableOptionData{
void execute();
}
private InteractionDialogAPI dialog = null;
@Override
void init(InteractionDialogAPI dialog){
this.dialog = dialog;
dialog.getTextPanel().addParagraph("Some text")
dialog.getOptionPanel().addOption(
"OptionName",
new ExecutableOptionData(){
@Override
void execute(){
// implementation of what the option should do when clicked
// For instance, for a leave option:
dialog.dismiss();
// If your GUI e.g. moves to another stage after this, you should clear the options and
// create new options in here. It might also make sense to move this ExecutableOptionData
// to another file, if the implementation gets too long.
}
}
);
String spriteName = Global.getSettings().getSpriteName("spriteCategory", "mySpriteName");
dialog.getVisualPanel().showImageVisual(
spriteName,
Global.getSettings().getSprite(spriteName).width
Global.getSettings().getSprite(spriteName).height
);
}
@Override
void optionSelected(String optionText, Object optionData){
ExecutableOptionData option = (ExecutableOptionData)optionData;
if(option == null){ return; }
option.execute();
}
// Override the remaining methods (Ctrl+O in IntelliJ), but leave their implementation empty if their
// return type is void, or return null otherwise.
}
| Modifier and Type | Method and Description |
|---|---|
void |
advance(float amount)
Get's called every frame.
|
void |
backFromEngagement(EngagementResultAPI battleResult)
Get's called after a fleet battle connected to this dialog ends.
|
java.lang.Object |
getContext()
Usually, simply returning null is fine
|
java.util.Map<java.lang.String,MemoryAPI> |
getMemoryMap()
Usually, simply returning null or an empty map is fine.
|
void |
init(InteractionDialogAPI dialog)
Initialize your GUI in here, by populating options, texts and images *
|
void |
optionMousedOver(java.lang.String optionText,
java.lang.Object optionData)
Get's called when the player hovers over an option.
|
void |
optionSelected(java.lang.String optionText,
java.lang.Object optionData)
This gets called when the player clicks on an option.
|
void init(InteractionDialogAPI dialog)
dialog - entry point for interacting with the dialog. You should probably store this in a member variablevoid optionSelected(java.lang.String optionText, java.lang.Object optionData)
optionText - the name of the option, i.e. the first argument passed to addOptionoptionData - the data/identifier of the selected option. Cast this to the correct type. Don't forget to
null-check the result of the cast.void optionMousedOver(java.lang.String optionText, java.lang.Object optionData)
optionText - optionData - void advance(float amount)
amount - void backFromEngagement(EngagementResultAPI battleResult)
battleResult - java.lang.Object getContext()
java.util.Map<java.lang.String,MemoryAPI> getMemoryMap()