mirror of
https://github.com/OMGeeky/ATCS.git
synced 2025-12-27 14:58:55 +01:00
refactor: encapsulate death effect panel creation in CommonEditor
This commit is contained in:
@@ -252,17 +252,13 @@ public class ItemEditor extends JSONElementEditor {
|
||||
equipEffectPane.collapse();
|
||||
}
|
||||
|
||||
hitEffectPane = new CollapsiblePanel("Effect on every hit: ");
|
||||
hitEffectPane.setLayout(new JideBoxLayout(hitEffectPane, JideBoxLayout.PAGE_AXIS));
|
||||
if (item.hit_effect == null) {
|
||||
hitEffect = new Common.HitEffect();
|
||||
} else {
|
||||
hitEffect = item.hit_effect;
|
||||
}
|
||||
hitHPMin = addIntegerField(hitEffectPane, "HP bonus min: ", hitEffect.hp_boost_min, true, item.writable, listener);
|
||||
hitHPMax = addIntegerField(hitEffectPane, "HP bonus max: ", hitEffect.hp_boost_max, true, item.writable, listener);
|
||||
hitAPMin = addIntegerField(hitEffectPane, "AP bonus min: ", hitEffect.ap_boost_min, true, item.writable, listener);
|
||||
hitAPMax = addIntegerField(hitEffectPane, "AP bonus max: ", hitEffect.ap_boost_max, true, item.writable, listener);
|
||||
CommonEditor.CreateDeathEffectPanelResult hitEffectPanelResult = CommonEditor.createDeathEffectPanel(item.hit_effect, item.writable, listener, "Effect on every hit: ");
|
||||
hitEffectPane = hitEffectPanelResult.panel;
|
||||
hitHPMin = hitEffectPanelResult.HPMin;
|
||||
hitHPMax = hitEffectPanelResult.HPMax;
|
||||
hitAPMax = hitEffectPanelResult.APMax;
|
||||
hitAPMin = hitEffectPanelResult.APMin;
|
||||
|
||||
String hitSourceTitle = "Actor Conditions applied to the source: ";
|
||||
TimedConditionsCellRenderer hitSourceCellRenderer = new TimedConditionsCellRenderer();
|
||||
hitSourceConditionsModel = new SourceTimedConditionsListModel(hitEffect);
|
||||
@@ -315,18 +311,19 @@ public class ItemEditor extends JSONElementEditor {
|
||||
pane.add(hitEffectPane, JideBoxLayout.FIX);
|
||||
|
||||
|
||||
|
||||
killEffectPane = new CollapsiblePanel(killLabel);
|
||||
killEffectPane.setLayout(new JideBoxLayout(killEffectPane, JideBoxLayout.PAGE_AXIS));
|
||||
if (item.kill_effect == null) {
|
||||
killEffect = new Common.DeathEffect();
|
||||
} else {
|
||||
killEffect = item.kill_effect;
|
||||
}
|
||||
killHPMin = addIntegerField(killEffectPane, "HP bonus min: ", killEffect.hp_boost_min, true, item.writable, listener);
|
||||
killHPMax = addIntegerField(killEffectPane, "HP bonus max: ", killEffect.hp_boost_max, true, item.writable, listener);
|
||||
killAPMin = addIntegerField(killEffectPane, "AP bonus min: ", killEffect.ap_boost_min, true, item.writable, listener);
|
||||
killAPMax = addIntegerField(killEffectPane, "AP bonus max: ", killEffect.ap_boost_max, true, item.writable, listener);
|
||||
|
||||
CommonEditor.CreateDeathEffectPanelResult x = CommonEditor.createDeathEffectPanel(killEffect, item.writable, listener, killLabel);
|
||||
killEffectPane = x.panel;
|
||||
killHPMin = x.HPMin;
|
||||
killHPMax = x.HPMax;
|
||||
killAPMin = x.APMin;
|
||||
killAPMax = x.APMax;
|
||||
|
||||
String killSourceTitle = "Actor Conditions applied to the source: ";
|
||||
TimedConditionsCellRenderer killSourceCellRenderer = new TimedConditionsCellRenderer();
|
||||
killSourceConditionsModel = new SourceTimedConditionsListModel(killEffect);
|
||||
@@ -356,13 +353,14 @@ public class ItemEditor extends JSONElementEditor {
|
||||
pane.add(killEffectPane, JideBoxLayout.FIX);
|
||||
|
||||
|
||||
hitReceivedEffectPane = new CollapsiblePanel("Effect on every hit received: ");
|
||||
hitReceivedEffectPane.setLayout(new JideBoxLayout(hitReceivedEffectPane, JideBoxLayout.PAGE_AXIS));
|
||||
if (item.hit_received_effect == null) {
|
||||
hitReceivedEffect = new Common.HitReceivedEffect();
|
||||
} else {
|
||||
hitReceivedEffect = item.hit_received_effect;
|
||||
}
|
||||
String titleHitReceived = "Effect on every hit received: ";
|
||||
hitReceivedEffectPane = new CollapsiblePanel(titleHitReceived);
|
||||
hitReceivedEffectPane.setLayout(new JideBoxLayout(hitReceivedEffectPane, JideBoxLayout.PAGE_AXIS));
|
||||
hitReceivedHPMin = addIntegerField(hitReceivedEffectPane, "Player HP bonus min: ", hitReceivedEffect.hp_boost_min, true, item.writable, listener);
|
||||
hitReceivedHPMax = addIntegerField(hitReceivedEffectPane, "Player HP bonus max: ", hitReceivedEffect.hp_boost_max, true, item.writable, listener);
|
||||
hitReceivedAPMin = addIntegerField(hitReceivedEffectPane, "Player AP bonus min: ", hitReceivedEffect.ap_boost_min, true, item.writable, listener);
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.gpl.rpg.atcontentstudio.ui.tools;
|
||||
|
||||
import com.gpl.rpg.atcontentstudio.ATContentStudio;
|
||||
import com.gpl.rpg.atcontentstudio.model.GameDataElement;
|
||||
import com.gpl.rpg.atcontentstudio.model.gamedata.Common;
|
||||
import com.gpl.rpg.atcontentstudio.ui.CollapsiblePanel;
|
||||
import com.gpl.rpg.atcontentstudio.ui.DefaultIcons;
|
||||
import com.gpl.rpg.atcontentstudio.ui.Editor;
|
||||
import com.gpl.rpg.atcontentstudio.ui.FieldUpdateListener;
|
||||
import com.gpl.rpg.atcontentstudio.utils.lambda.CallWithReturn;
|
||||
import com.gpl.rpg.atcontentstudio.utils.lambda.CallWithSingleArg;
|
||||
@@ -147,6 +149,25 @@ public final class CommonEditor {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static class CreateDeathEffectPanelResult {
|
||||
public CollapsiblePanel panel;
|
||||
public JSpinner HPMin;
|
||||
public JSpinner HPMax;
|
||||
public JSpinner APMin;
|
||||
public JSpinner APMax;
|
||||
}
|
||||
public static CreateDeathEffectPanelResult createDeathEffectPanel(Common.DeathEffect hitEffect, boolean writable, FieldUpdateListener listener, String title){
|
||||
CreateDeathEffectPanelResult result = new CreateDeathEffectPanelResult();
|
||||
result.panel = new CollapsiblePanel(title);
|
||||
result.panel.setLayout(new JideBoxLayout(result.panel, JideBoxLayout.PAGE_AXIS));
|
||||
result.HPMin = Editor.addIntegerField(result.panel, "HP bonus min: ", hitEffect.hp_boost_min, true, writable, listener);
|
||||
result.HPMax = Editor.addIntegerField(result.panel, "HP bonus max: ", hitEffect.hp_boost_max, true, writable, listener);
|
||||
result.APMin = Editor.addIntegerField(result.panel, "AP bonus min: ", hitEffect.ap_boost_min, true, writable, listener);
|
||||
result.APMax = Editor.addIntegerField(result.panel, "AP bonus max: ", hitEffect.ap_boost_max, true, writable, listener);
|
||||
|
||||
return result;
|
||||
}
|
||||
public static String wordWrap(String in, int length) {
|
||||
if (in == null) return null;
|
||||
final String newline = "\n";
|
||||
|
||||
Reference in New Issue
Block a user