mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/jpexs-decompiler.git
synced 2026-05-31 04:05:14 +00:00
Color skins
Basic skin set to new Oceanic Error log Frame now skinned
This commit is contained in:
@@ -21,10 +21,15 @@ import com.jpexs.decompiler.flash.configuration.ConfigurationCategory;
|
||||
import com.jpexs.decompiler.flash.configuration.ConfigurationItem;
|
||||
import com.jpexs.decompiler.flash.gui.helpers.SpringUtilities;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -39,17 +44,27 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.Icon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTabbedPane;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.SpringLayout;
|
||||
import javax.swing.SwingConstants;
|
||||
import javax.swing.table.DefaultTableModel;
|
||||
import org.pushingpixels.substance.api.ColorSchemeAssociationKind;
|
||||
import org.pushingpixels.substance.api.ComponentState;
|
||||
import org.pushingpixels.substance.api.DecorationAreaType;
|
||||
import org.pushingpixels.substance.api.SubstanceLookAndFeel;
|
||||
import org.pushingpixels.substance.api.SubstanceSkin;
|
||||
import org.pushingpixels.substance.api.renderers.SubstanceDefaultListCellRenderer;
|
||||
import org.pushingpixels.substance.api.skin.SkinInfo;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -99,6 +114,27 @@ public class AdvancedSettingsDialog extends AppDialog implements ActionListener
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static class SkinSelect {
|
||||
private String name;
|
||||
private String className;
|
||||
|
||||
public SkinSelect(String name, String className) {
|
||||
this.name = name;
|
||||
this.className = className;
|
||||
}
|
||||
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void initComponents() {
|
||||
okButton = new JButton();
|
||||
@@ -159,6 +195,65 @@ public class AdvancedSettingsDialog extends AppDialog implements ActionListener
|
||||
|
||||
JTabbedPane tabPane = new JTabbedPane();
|
||||
Map<String, Component> tabs = new HashMap<>();
|
||||
|
||||
JComboBox<SkinSelect> skinComboBox=new JComboBox<>();
|
||||
skinComboBox.setRenderer(new SubstanceDefaultListCellRenderer(){
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||
SubstanceDefaultListCellRenderer cmp= (SubstanceDefaultListCellRenderer)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); //To change body of generated methods, choose Tools | Templates.
|
||||
final SkinSelect ss=(SkinSelect)value;
|
||||
cmp.setIcon(new Icon() {
|
||||
|
||||
@Override
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||
g2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
|
||||
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
try {
|
||||
Class<?> act = Class.forName(ss.getClassName());
|
||||
SubstanceSkin skin = (SubstanceSkin)act.newInstance();
|
||||
Color fill = skin.getColorScheme(DecorationAreaType.GENERAL,ColorSchemeAssociationKind.FILL,ComponentState.ENABLED).getBackgroundFillColor();
|
||||
Color hilight=skin.getColorScheme(DecorationAreaType.GENERAL,ColorSchemeAssociationKind.FILL,ComponentState.ROLLOVER_SELECTED).getBackgroundFillColor();
|
||||
Color border = skin.getColorScheme(DecorationAreaType.GENERAL,ColorSchemeAssociationKind.BORDER,ComponentState.ENABLED).getDarkColor();
|
||||
g2.setColor(fill);
|
||||
g2.fillOval(0, 0, 16, 16);
|
||||
g2.setColor(hilight);
|
||||
g2.fillArc(0, 0, 16, 16, -45, 90);
|
||||
g2.setColor(border);
|
||||
g2.drawOval(0, 0, 16, 16);
|
||||
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
|
||||
//no icon
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconWidth() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIconHeight() {
|
||||
return 16;
|
||||
}
|
||||
});
|
||||
return cmp;
|
||||
}
|
||||
|
||||
});
|
||||
skinComboBox.addItem(new SkinSelect(OceanicSkin.NAME, OceanicSkin.class.getName()));
|
||||
Map<String,SkinInfo> skins = SubstanceLookAndFeel.getAllSkins();
|
||||
for(String skinKey:skins.keySet()){
|
||||
SkinInfo skin=skins.get(skinKey);
|
||||
skinComboBox.addItem(new SkinSelect(skin.getDisplayName(), skin.getClassName()));
|
||||
if(skin.getClassName().equals(Configuration.guiSkin.get())){
|
||||
skinComboBox.setSelectedIndex(skinComboBox.getItemCount()-1);
|
||||
}
|
||||
}
|
||||
|
||||
for (String cat : categorized.keySet()) {
|
||||
JPanel configPanel = new JPanel(new SpringLayout());
|
||||
for (String name : categorized.get(cat).keySet()) {
|
||||
@@ -172,23 +267,33 @@ public class AdvancedSettingsDialog extends AppDialog implements ActionListener
|
||||
|
||||
ParameterizedType listType = (ParameterizedType) field.getGenericType();
|
||||
Class itemType = (Class<?>) listType.getActualTypeArguments()[0];
|
||||
/*String description = Configuration.getDescription(field);
|
||||
if (description == null) {
|
||||
description = "";
|
||||
}*/
|
||||
|
||||
String description = translate("config.description." + name);
|
||||
|
||||
Object defaultValue = Configuration.getDefaultValue(field);
|
||||
if(name.equals("gui.skin")){
|
||||
Class c;
|
||||
try {
|
||||
c = Class.forName((String)defaultValue);
|
||||
defaultValue = c.getField("NAME").get(c);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | SecurityException ex) {
|
||||
Logger.getLogger(AdvancedSettingsDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
}
|
||||
if (defaultValue != null) {
|
||||
description += " (" + translate("default") + ": " + defaultValue + ")";
|
||||
}
|
||||
//model.addRow(new Object[]{locName, item.get(), description});
|
||||
|
||||
|
||||
JLabel l = new JLabel(locName, JLabel.TRAILING);
|
||||
l.setToolTipText(description);
|
||||
configPanel.add(l);
|
||||
Component c = null;
|
||||
if ((itemType == String.class) || (itemType == Integer.class) || (itemType == Long.class) || (itemType == Double.class) || (itemType == Float.class) || (itemType == Calendar.class)) {
|
||||
if(name.equals("gui.skin")){
|
||||
skinComboBox.setToolTipText(description);
|
||||
skinComboBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, skinComboBox.getPreferredSize().height));
|
||||
c = skinComboBox;
|
||||
} else if ((itemType == String.class) || (itemType == Integer.class) || (itemType == Long.class) || (itemType == Double.class) || (itemType == Float.class) || (itemType == Calendar.class)) {
|
||||
JTextField tf = new JTextField();
|
||||
Object val = item.get();
|
||||
if (val == null) {
|
||||
@@ -298,7 +403,10 @@ public class AdvancedSettingsDialog extends AppDialog implements ActionListener
|
||||
|
||||
ParameterizedType listType = (ParameterizedType) fields.get(name).getGenericType();
|
||||
Class itemType = (Class<?>) listType.getActualTypeArguments()[0];
|
||||
if (itemType == String.class) {
|
||||
if(name.equals("gui.skin")){
|
||||
value = ((SkinSelect)((JComboBox<SkinSelect>)c).getSelectedItem()).className;
|
||||
}
|
||||
else if (itemType == String.class) {
|
||||
value = ((JTextField) c).getText();
|
||||
}
|
||||
if (itemType == Boolean.class) {
|
||||
|
||||
Reference in New Issue
Block a user