mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-09-25 07:41:07 +00:00
Icons for tags in replace character dialog
This commit is contained in:
@@ -17,17 +17,21 @@
|
||||
package com.jpexs.decompiler.flash.gui;
|
||||
|
||||
import com.jpexs.decompiler.flash.SWF;
|
||||
import com.jpexs.decompiler.flash.gui.tagtree.AbstractTagTree;
|
||||
import com.jpexs.decompiler.flash.tags.base.CharacterTag;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.util.Map;
|
||||
import javax.swing.DefaultListCellRenderer;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
@@ -40,7 +44,7 @@ public class ReplaceCharacterDialog extends AppDialog {
|
||||
|
||||
private final JButton cancelButton = new JButton(translate("button.cancel"));
|
||||
|
||||
private final JComboBox<ComboBoxItem<Integer>> charactersComboBox = new JComboBox<>();
|
||||
private final JComboBox<ComboBoxItem<CharacterTag>> charactersComboBox = new JComboBox<>();
|
||||
|
||||
private int result = ERROR_OPTION;
|
||||
|
||||
@@ -53,6 +57,9 @@ public class ReplaceCharacterDialog extends AppDialog {
|
||||
|
||||
charactersComboBox.setPreferredSize(new Dimension(400, charactersComboBox.getPreferredSize().height));
|
||||
add(charactersComboBox, BorderLayout.CENTER);
|
||||
|
||||
charactersComboBox.setRenderer(new CharacterTagListCellRenderer());
|
||||
|
||||
|
||||
JPanel panButtons = new JPanel(new FlowLayout());
|
||||
okButton.addActionListener(this::okButtonActionPerformed);
|
||||
@@ -86,8 +93,8 @@ public class ReplaceCharacterDialog extends AppDialog {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ComboBoxItem<Integer> item = (ComboBoxItem<Integer>) charactersComboBox.getSelectedItem();
|
||||
return item.getValue();
|
||||
ComboBoxItem<CharacterTag> item = (ComboBoxItem<CharacterTag>) charactersComboBox.getSelectedItem();
|
||||
return item.getValue().getCharacterId();
|
||||
}
|
||||
|
||||
public int showDialog(SWF swf, int selectedCharacterId) {
|
||||
@@ -96,7 +103,7 @@ public class ReplaceCharacterDialog extends AppDialog {
|
||||
CharacterTag character = characters.get(key);
|
||||
int characterId = character.getCharacterId();
|
||||
if (characterId != selectedCharacterId) {
|
||||
charactersComboBox.addItem(new ComboBoxItem<>(character.getName(), characterId));
|
||||
charactersComboBox.addItem(new ComboBoxItem<>(character.getName(), character));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,3 +111,17 @@ public class ReplaceCharacterDialog extends AppDialog {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
class CharacterTagListCellRenderer extends DefaultListCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||
if (component instanceof JLabel) {
|
||||
JLabel label = (JLabel) component;
|
||||
ComboBoxItem<CharacterTag> comboboxItem = (ComboBoxItem<CharacterTag>) value;
|
||||
label.setIcon(AbstractTagTree.getIconForType(AbstractTagTree.getTreeNodeType(comboboxItem.getValue())));
|
||||
}
|
||||
return component;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user