mirror of
https://github.com/OMGeeky/ATCS.git
synced 2025-12-27 14:58:55 +01:00
Initial commit
This commit is contained in:
60
src/com/gpl/rpg/atcontentstudio/model/maps/ScriptArea.java
Normal file
60
src/com/gpl/rpg/atcontentstudio/model/maps/ScriptArea.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||
|
||||
import java.awt.Image;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Dialogue;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
public class ScriptArea extends MapObject {
|
||||
|
||||
public Dialogue dialogue = null;
|
||||
public EvaluationTrigger trigger_type = null;
|
||||
|
||||
public enum EvaluationTrigger {
|
||||
enter,
|
||||
step,
|
||||
round,
|
||||
always
|
||||
}
|
||||
|
||||
public ScriptArea(tiled.core.MapObject obj) {
|
||||
String triggerTypeId = obj.getProperties().getProperty("when");
|
||||
if (triggerTypeId != null) {
|
||||
trigger_type = EvaluationTrigger.valueOf(triggerTypeId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (name != null) dialogue = parentMap.getProject().getDialogue(name);
|
||||
if (dialogue != null) {
|
||||
dialogue.addBacklink(parentMap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getIcon() {
|
||||
if (dialogue != null) return DefaultIcons.getScriptIcon();
|
||||
else return DefaultIcons.getNullifyIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementChanged(GameDataElement oldOne, GameDataElement newOne) {
|
||||
if (oldOne == dialogue) {
|
||||
dialogue = (Dialogue) newOne;
|
||||
newOne.addBacklink(parentMap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePropertiesInTmxObject(tiled.core.MapObject tmxObject) {
|
||||
if (dialogue != null) {
|
||||
tmxObject.setName(dialogue.id);
|
||||
}
|
||||
if (trigger_type != null) {
|
||||
tmxObject.getProperties().setProperty("when", trigger_type.toString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user