move ConditionsCellRenderer to CommonEditor

This commit is contained in:
OMGeeky
2025-06-23 17:35:46 +02:00
parent 488dd92893
commit 63e381a804
2 changed files with 26 additions and 26 deletions

View File

@@ -43,4 +43,29 @@ public class CommonEditor {
return c;
}
}
public static class ConditionsCellRenderer extends DefaultListCellRenderer {
private static final long serialVersionUID = 7987880146189575234L;
@Override
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
JLabel label = ((JLabel) c);
Common.ActorConditionEffect effect = (Common.ActorConditionEffect) value;
if (effect.condition != null) {
if (effect.magnitude == ActorCondition.MAGNITUDE_CLEAR) {
label.setIcon(new OverlayIcon(effect.condition.getIcon(), DefaultIcons.getImmunityIcon()));
label.setText("Immune to actor condition " + effect.condition.getDesc());
} else {
label.setIcon(new ImageIcon(effect.condition.getIcon()));
label.setText("Give actor condition " + effect.condition.getDesc() + " x" + effect.magnitude);
}
} else {
label.setText("New, undefined actor condition effect.");
}
}
return c;
}
}
}

View File

@@ -211,7 +211,7 @@ public class ItemEditor extends JSONElementEditor {
String titleEquipConditions = "Actor Conditions applied when equipped: ";
equipConditionsModel = new ConditionsListModel(equipEffect);
ConditionsCellRenderer cellRendererEquipConditions = new ConditionsCellRenderer();
CommonEditor.ConditionsCellRenderer cellRendererEquipConditions = new CommonEditor.ConditionsCellRenderer();
BasicLambdaWithArg<Common.ActorConditionEffect> selectedSetEquipConditions = (value)->selectedEquipEffectCondition = value;
BasicLambdaWithReturn<Common.ActorConditionEffect> selectedGetEquipConditions = ()->selectedEquipEffectCondition ;
BasicLambda selectedResetEquipConditions = ()->selectedEquipEffectCondition = null;
@@ -1033,31 +1033,6 @@ public class ItemEditor extends JSONElementEditor {
}
}
public static class ConditionsCellRenderer extends DefaultListCellRenderer {
private static final long serialVersionUID = 7987880146189575234L;
@Override
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (c instanceof JLabel) {
JLabel label = ((JLabel) c);
Common.ActorConditionEffect effect = (Common.ActorConditionEffect) value;
if (effect.condition != null) {
if (effect.magnitude == ActorCondition.MAGNITUDE_CLEAR) {
label.setIcon(new OverlayIcon(effect.condition.getIcon(), DefaultIcons.getImmunityIcon()));
label.setText("Immune to actor condition " + effect.condition.getDesc());
} else {
label.setIcon(new ImageIcon(effect.condition.getIcon()));
label.setText("Give actor condition " + effect.condition.getDesc() + " x" + effect.magnitude);
}
} else {
label.setText("New, undefined actor condition effect.");
}
}
return c;
}
}
public static boolean isNull(Item.EquipEffect effect) {
if (effect.conditions != null) return false;