mirror of
https://github.com/OMGeeky/ATCS.git
synced 2025-12-27 23:07:41 +01:00
Initial commit
This commit is contained in:
57
src/com/gpl/rpg/atcontentstudio/model/maps/MapChange.java
Normal file
57
src/com/gpl/rpg/atcontentstudio/model/maps/MapChange.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package com.gpl.rpg.atcontentstudio.model.maps;
|
||||
|
||||
import java.awt.Image;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
|
||||
|
||||
|
||||
public class MapChange extends MapObject {
|
||||
|
||||
public String map_id = null;
|
||||
public TMXMap map = null;
|
||||
public String place_id = null;
|
||||
|
||||
public MapChange(tiled.core.MapObject obj) {
|
||||
this.map_id = obj.getProperties().getProperty("map");
|
||||
this.place_id = obj.getProperties().getProperty("place");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void link() {
|
||||
if (map_id != null) this.map = parentMap.getProject().getMap(map_id);
|
||||
if (map != null) {
|
||||
map.addBacklink(parentMap);
|
||||
}
|
||||
//TODO reinstate this if data validation system ever exist.
|
||||
// else Notification.addWarn("Incomplete mapchange area \""+name+"\" in map \""+parentMap.id+"\". This is OK if it's an arrival only (no exit through this point).");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getIcon() {
|
||||
if (name != null) return DefaultIcons.getTiledIconIcon();
|
||||
else return DefaultIcons.getNullifyIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void elementChanged(GameDataElement oldOne, GameDataElement newOne) {
|
||||
if (oldOne == map) {
|
||||
map = (TMXMap) newOne;
|
||||
newOne.addBacklink(parentMap);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void savePropertiesInTmxObject(tiled.core.MapObject tmxObject) {
|
||||
if (map != null) {
|
||||
tmxObject.getProperties().setProperty("map", map.id);
|
||||
} else if (map_id != null) {
|
||||
tmxObject.getProperties().setProperty("map", map_id);
|
||||
}
|
||||
if (place_id != null) {
|
||||
tmxObject.getProperties().setProperty("place", place_id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user