From 025a63af281d5291469d84832b33d6778fd38dee Mon Sep 17 00:00:00 2001 From: Zukero Date: Mon, 21 Aug 2017 18:32:11 +0200 Subject: [PATCH] Visual effect widget is now a combo box, as the data is an Enum in the game. --- .../rpg/atcontentstudio/model/Project.java | 3 +- .../model/gamedata/ActorCondition.java | 29 +++++++++++++++---- .../gamedataeditors/ActorConditionEditor.java | 18 +++++++----- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/com/gpl/rpg/atcontentstudio/model/Project.java b/src/com/gpl/rpg/atcontentstudio/model/Project.java index 44f931f..69ea424 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/Project.java +++ b/src/com/gpl/rpg/atcontentstudio/model/Project.java @@ -222,6 +222,8 @@ public class Project implements ProjectTreeNode, Serializable { public void refreshTransients(Workspace w) { this.parent = w; + projectElementListeners = new HashMap, List>(); + try { knownSpritesheetsProperties = new Properties(); knownSpritesheetsProperties.load(Project.class.getResourceAsStream("/spritesheets.properties")); @@ -254,7 +256,6 @@ public class Project implements ProjectTreeNode, Serializable { linkAll(); - projectElementListeners = new HashMap, List>(); } public void linkAll() { diff --git a/src/com/gpl/rpg/atcontentstudio/model/gamedata/ActorCondition.java b/src/com/gpl/rpg/atcontentstudio/model/gamedata/ActorCondition.java index fd979f5..7a534ed 100644 --- a/src/com/gpl/rpg/atcontentstudio/model/gamedata/ActorCondition.java +++ b/src/com/gpl/rpg/atcontentstudio/model/gamedata/ActorCondition.java @@ -43,9 +43,16 @@ public class ActorCondition extends JSONElement { blood } + public static enum VisualEffectID { + redSplash + ,blueSwirl + ,greenSplash + ,miss + } + public static class RoundEffect implements Cloneable { // Available from parsed state - public String visual_effect = null; + public VisualEffectID visual_effect = null; public Integer hp_boost_min = null; public Integer hp_boost_max = null; public Integer ap_boost_min = null; @@ -180,7 +187,13 @@ public class ActorCondition extends JSONElement { this.round_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map)roundEffect.get("increaseCurrentAP")).get("max"))); this.round_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map)roundEffect.get("increaseCurrentAP")).get("min"))); } - this.round_effect.visual_effect = (String) roundEffect.get("visualEffectID"); + String vfx = (String) roundEffect.get("visualEffectID"); + this.round_effect.visual_effect = null; + if (vfx != null) { + try { + this.round_effect.visual_effect = VisualEffectID.valueOf(vfx); + } catch(IllegalArgumentException e) {} + } } Map fullRoundEffect = (Map) aCondJson.get("fullRoundEffect"); if (fullRoundEffect != null) { @@ -193,7 +206,13 @@ public class ActorCondition extends JSONElement { this.full_round_effect.ap_boost_max = JSONElement.getInteger((Number) (((Map)fullRoundEffect.get("increaseCurrentAP")).get("max"))); this.full_round_effect.ap_boost_min = JSONElement.getInteger((Number) (((Map)fullRoundEffect.get("increaseCurrentAP")).get("min"))); } - this.full_round_effect.visual_effect = (String) fullRoundEffect.get("visualEffectID"); + String vfx = (String) roundEffect.get("visualEffectID"); + this.full_round_effect.visual_effect = null; + if (vfx != null) { + try { + this.full_round_effect.visual_effect = VisualEffectID.valueOf(vfx); + } catch(IllegalArgumentException e) {} + } } this.state = State.parsed; @@ -278,7 +297,7 @@ public class ActorCondition extends JSONElement { if (this.stacking != null && this.stacking == 1) jsonAC.put("isStacking", this.stacking); if (this.round_effect != null) { Map jsonRound = new LinkedHashMap(); - if (this.round_effect.visual_effect != null) jsonRound.put("visualEffectID", this.round_effect.visual_effect); + if (this.round_effect.visual_effect != null) jsonRound.put("visualEffectID", this.round_effect.visual_effect.toString()); if (this.round_effect.hp_boost_min != null || this.round_effect.hp_boost_max != null) { Map jsonHP = new LinkedHashMap(); if (this.round_effect.hp_boost_min != null) jsonHP.put("min", this.round_effect.hp_boost_min); @@ -299,7 +318,7 @@ public class ActorCondition extends JSONElement { } if (this.full_round_effect != null) { Map jsonFullRound = new LinkedHashMap(); - if (this.full_round_effect.visual_effect != null) jsonFullRound.put("visualEffectID", this.full_round_effect.visual_effect); + if (this.full_round_effect.visual_effect != null) jsonFullRound.put("visualEffectID", this.full_round_effect.visual_effect.toString()); if (this.full_round_effect.hp_boost_min != null || this.full_round_effect.hp_boost_max != null) { Map jsonHP = new LinkedHashMap(); if (this.full_round_effect.hp_boost_min != null) jsonHP.put("min", this.full_round_effect.hp_boost_min); diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ActorConditionEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ActorConditionEditor.java index fda7f13..266de5b 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ActorConditionEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ActorConditionEditor.java @@ -35,13 +35,15 @@ public class ActorConditionEditor extends JSONElementEditor { private IntegerBasedCheckBox positiveBox; private IntegerBasedCheckBox stackingBox; - private JTextField roundVisualField; + //private JTextField roundVisualField; + private JComboBox roundVisualField; private JSpinner roundHpMinField; private JSpinner roundHpMaxField; private JSpinner roundApMinField; private JSpinner roundApMaxField; - private JTextField fullRoundVisualField; + //private JTextField fullRoundVisualField; + private JComboBox fullRoundVisualField; private JSpinner fullRoundHpMinField; private JSpinner fullRoundHpMaxField; private JSpinner fullRoundApMinField; @@ -82,7 +84,7 @@ public class ActorConditionEditor extends JSONElementEditor { stackingBox = addIntegerBasedCheckBox(pane, "Stacking", ac.stacking, ac.writable, listener); - CollapsiblePanel roundEffectPane = new CollapsiblePanel("Effect every round (4s): "); + CollapsiblePanel roundEffectPane = new CollapsiblePanel("Effect every round (6s): "); roundEffectPane.setLayout(new JideBoxLayout(roundEffectPane, JideBoxLayout.PAGE_AXIS)); final ActorCondition.RoundEffect roundEffect; if (ac.round_effect != null) { @@ -90,7 +92,7 @@ public class ActorConditionEditor extends JSONElementEditor { } else { roundEffect = new ActorCondition.RoundEffect(); } - roundVisualField = addTextField(roundEffectPane, "Visual effect ID: ", roundEffect.visual_effect, ac.writable, listener); + roundVisualField = addEnumValueBox(roundEffectPane, "Visual effect ID:", ActorCondition.VisualEffectID.values(), roundEffect.visual_effect, ac.writable, listener);//addTextField(roundEffectPane, "Visual effect ID: ", roundEffect.visual_effect, ac.writable, listener); roundHpMinField = addIntegerField(roundEffectPane, "HP Bonus Min: ", roundEffect.hp_boost_min, true, ac.writable, listener); roundHpMaxField = addIntegerField(roundEffectPane, "HP Bonus Max: ", roundEffect.hp_boost_max, true, ac.writable, listener); roundApMinField = addIntegerField(roundEffectPane, "AP Bonus Min: ", roundEffect.ap_boost_min, true, ac.writable, listener); @@ -99,7 +101,7 @@ public class ActorConditionEditor extends JSONElementEditor { pane.add(roundEffectPane, JideBoxLayout.FIX); - CollapsiblePanel fullRoundEffectPane = new CollapsiblePanel("Effect every full round (20s): "); + CollapsiblePanel fullRoundEffectPane = new CollapsiblePanel("Effect every full round (25s): "); fullRoundEffectPane.setLayout(new JideBoxLayout(fullRoundEffectPane, JideBoxLayout.PAGE_AXIS)); final ActorCondition.RoundEffect fullRoundEffect; if (ac.full_round_effect != null) { @@ -107,7 +109,7 @@ public class ActorConditionEditor extends JSONElementEditor { } else { fullRoundEffect = new ActorCondition.RoundEffect(); } - fullRoundVisualField = addTextField(fullRoundEffectPane, "Visual effect ID: ", fullRoundEffect.visual_effect, ac.writable, listener); + fullRoundVisualField = addEnumValueBox(fullRoundEffectPane, "Visual effect ID:", ActorCondition.VisualEffectID.values(), fullRoundEffect.visual_effect, ac.writable, listener);//addTextField(fullRoundEffectPane, "Visual effect ID: ", fullRoundEffect.visual_effect, ac.writable, listener); fullRoundHpMinField = addIntegerField(fullRoundEffectPane, "HP Bonus min: ", fullRoundEffect.hp_boost_min, true, ac.writable, listener); fullRoundHpMaxField = addIntegerField(fullRoundEffectPane, "HP Bonus max: ", fullRoundEffect.hp_boost_max, true, ac.writable, listener); fullRoundApMinField = addIntegerField(fullRoundEffectPane, "AP Bonus min: ", fullRoundEffect.ap_boost_min, true, ac.writable, listener); @@ -194,7 +196,7 @@ public class ActorConditionEditor extends JSONElementEditor { if (aCond.round_effect == null) { aCond.round_effect = new ActorCondition.RoundEffect(); } - aCond.round_effect.visual_effect = (String) value; + aCond.round_effect.visual_effect = (ActorCondition.VisualEffectID) value; } } else if (source == roundHpMinField) { if (value == null) { @@ -264,7 +266,7 @@ public class ActorConditionEditor extends JSONElementEditor { if (aCond.full_round_effect == null) { aCond.full_round_effect = new ActorCondition.RoundEffect(); } - aCond.full_round_effect.visual_effect = (String) value; + aCond.full_round_effect.visual_effect = (ActorCondition.VisualEffectID) value; } } else if (source == fullRoundHpMinField) { if (value == null) {