From 93e44a2b502fbbd342dcf3fc6a38d4c5bde82f1f Mon Sep 17 00:00:00 2001 From: OMGeeky Date: Tue, 24 Jun 2025 16:39:46 +0200 Subject: [PATCH] improve *EffectPane initialisation --- .../ui/gamedataeditors/ItemEditor.java | 12 +++-------- .../ui/gamedataeditors/NPCEditor.java | 21 +++++++------------ 2 files changed, 10 insertions(+), 23 deletions(-) diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java index b2686c7..d1b2698 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/ItemEditor.java @@ -68,9 +68,9 @@ public class ItemEditor extends JSONElementEditor { private JRadioButton equipConditionImmunity; private JSpinner equipConditionMagnitude; - private CommonEditor.HitEffectPane hitEffectPane; - private CommonEditor.DeathEffectPane killEffectPane; - private CommonEditor.HitRecievedEffectPane hitReceivedEffectPane; + private CommonEditor.HitEffectPane hitEffectPane = new CommonEditor.HitEffectPane("Effect on every hit: ", Common.TimedActorConditionEffect::new, this, null, null); + private CommonEditor.DeathEffectPane killEffectPane = new CommonEditor.DeathEffectPane(killLabel, Common.TimedActorConditionEffect::new, this, null); + private CommonEditor.HitRecievedEffectPane hitReceivedEffectPane = new CommonEditor.HitRecievedEffectPane("Effect on every hit received: ", Common.TimedActorConditionEffect::new, this, null, null); public ItemEditor(Item item) { super(item, item.getDesc(), item.getIcon()); @@ -159,8 +159,6 @@ public class ItemEditor extends JSONElementEditor { } else { hitEffect = item.hit_effect; } - if (hitEffectPane == null) - hitEffectPane = new CommonEditor.HitEffectPane("Effect on every hit: ", Common.TimedActorConditionEffect::new, this, null, null); hitEffectPane.createHitEffectPaneContent(listener, item.writable, hitEffect, new CommonEditor.SourceTimedConditionsListModel(hitEffect), new CommonEditor.TargetTimedConditionsListModel(hitEffect)); pane.add(hitEffectPane.effectPane, JideBoxLayout.FIX); @@ -170,8 +168,6 @@ public class ItemEditor extends JSONElementEditor { } else { killEffect = item.kill_effect; } - if (killEffectPane == null) - killEffectPane = new CommonEditor.DeathEffectPane(killLabel, Common.TimedActorConditionEffect::new, this, null); killEffectPane.createDeathEffectPaneContent(listener, item.writable, killEffect, new CommonEditor.SourceTimedConditionsListModel(killEffect)); pane.add(killEffectPane.effectPane, JideBoxLayout.FIX); @@ -181,8 +177,6 @@ public class ItemEditor extends JSONElementEditor { } else { hitReceivedEffect = item.hit_received_effect; } - if (hitReceivedEffectPane == null) - hitReceivedEffectPane = new CommonEditor.HitRecievedEffectPane("Effect on every hit received: ", Common.TimedActorConditionEffect::new, this, null, null); hitReceivedEffectPane.createHitReceivedEffectPaneContent(listener, item.writable, hitReceivedEffect, new CommonEditor.SourceTimedConditionsListModel(hitReceivedEffect), new CommonEditor.TargetTimedConditionsListModel(hitReceivedEffect)); pane.add(killEffectPane.effectPane, JideBoxLayout.FIX); diff --git a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java index 32fe94b..1f74ec5 100644 --- a/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java +++ b/src/com/gpl/rpg/atcontentstudio/ui/gamedataeditors/NPCEditor.java @@ -53,9 +53,9 @@ public class NPCEditor extends JSONElementEditor { private JSpinner blockChance; private JSpinner dmgRes; - private CommonEditor.HitEffectPane hitEffectPane; - private CommonEditor.HitRecievedEffectPane hitReceivedEffectPane; - private CommonEditor.DeathEffectPane deathEffectPane; + private CommonEditor.HitEffectPane hitEffectPane = new CommonEditor.HitEffectPane("Effect on every hit: ", Common.TimedActorConditionEffect::new, this, null, null); + private CommonEditor.HitRecievedEffectPane hitReceivedEffectPane = new CommonEditor.HitRecievedEffectPane("Effect on every hit received: ", Common.TimedActorConditionEffect::new, this, "NPC", "Attacker"); + private CommonEditor.DeathEffectPane deathEffectPane = new CommonEditor.DeathEffectPane("Effect when killed: ", Common.TimedActorConditionEffect::new, this, "Killer"); private JPanel dialogueGraphPane; private DialogueGraphView dialogueGraphView; @@ -149,8 +149,6 @@ public class NPCEditor extends JSONElementEditor { } else { hitEffect = npc.hit_effect; } - if (hitEffectPane == null) - hitEffectPane = new CommonEditor.HitEffectPane("Effect on every hit: ", Common.TimedActorConditionEffect::new, this, null, null); hitEffectPane.createHitEffectPaneContent(listener, npc.writable, hitEffect, new CommonEditor.SourceTimedConditionsListModel(hitEffect), new CommonEditor.TargetTimedConditionsListModel(hitEffect)); combatTraitPane.add(hitEffectPane.effectPane, JideBoxLayout.FIX); @@ -160,8 +158,6 @@ public class NPCEditor extends JSONElementEditor { } else { hitReceivedEffect = npc.hit_received_effect; } - if (hitReceivedEffectPane == null) - hitReceivedEffectPane = new CommonEditor.HitRecievedEffectPane("Effect on every hit received: ", Common.TimedActorConditionEffect::new, this, "NPC", "Attacker"); hitReceivedEffectPane.createHitReceivedEffectPaneContent(listener, npc.writable, hitReceivedEffect, new CommonEditor.SourceTimedConditionsListModel(hitReceivedEffect), new CommonEditor.TargetTimedConditionsListModel(hitReceivedEffect)); combatTraitPane.add(hitReceivedEffectPane.effectPane, JideBoxLayout.FIX); @@ -171,10 +167,7 @@ public class NPCEditor extends JSONElementEditor { } else { deathEffect = npc.death_effect; } - if (deathEffectPane == null) - deathEffectPane = new CommonEditor.DeathEffectPane("Effect when killed: ", Common.TimedActorConditionEffect::new, this, "Killer"); - deathEffectPane.createDeathEffectPaneContent(listener, npc.writable, deathEffect, new CommonEditor.SourceTimedConditionsListModel(deathEffect) - ); + deathEffectPane.createDeathEffectPaneContent(listener, npc.writable, deathEffect, new CommonEditor.SourceTimedConditionsListModel(deathEffect)); combatTraitPane.add(deathEffectPane.effectPane, JideBoxLayout.FIX); pane.add(combatTraitPane, JideBoxLayout.FIX); @@ -274,11 +267,11 @@ public class NPCEditor extends JSONElementEditor { npc.block_chance = (Integer) value; } else if (source == dmgRes) { npc.damage_resistance = (Integer) value; - } else if(hitEffectPane != null &&hitEffectPane.valueChanged(source, value, npc)) { + } else if(hitEffectPane.valueChanged(source, value, npc)) { updateHit = true; - } else if (hitReceivedEffectPane != null && hitReceivedEffectPane.valueChanged(source, value, npc)) { + } else if (hitReceivedEffectPane.valueChanged(source, value, npc)) { updateHitReceived = true; - } else if (deathEffectPane != null && deathEffectPane.valueChanged(source, value, npc)) { + } else if (deathEffectPane.valueChanged(source, value, npc)) { updateDeath = true; }