improve *EffectPane initialisation

This commit is contained in:
OMGeeky
2025-06-24 16:39:46 +02:00
parent 652da07cc8
commit 93e44a2b50
2 changed files with 10 additions and 23 deletions

View File

@@ -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);

View File

@@ -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;
}