why does the ui crash

This commit is contained in:
huangyuhui
2015-12-27 10:59:03 +08:00
parent b1c6c3549f
commit 07357db42d
536 changed files with 1562 additions and 776 deletions

4
MetroLookAndFeel/build.gradle Normal file → Executable file
View File

@@ -34,6 +34,10 @@ buildscript {
}
}
dependencies {
compile project(":HMCLAPI")
}
retrolambda {
javaVersion = JavaVersion.VERSION_1_6
}

View File

@@ -1,23 +1,32 @@
/*
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
*
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program.
*/
package org.jackhuang.hellominecraft.lookandfeel;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.util.Map;
import javax.swing.UIDefaults;
import javax.swing.plaf.ColorUIResource;
import javax.swing.plaf.synth.SynthLookAndFeel;
import org.jackhuang.hellominecraft.utils.NetUtils;
import sun.swing.DefaultLookup;
/**
*
@@ -25,12 +34,45 @@ import javax.swing.plaf.synth.SynthLookAndFeel;
*/
public class HelloMinecraftLookAndFeel extends SynthLookAndFeel {
public static final Map<String, String> DEFAULT_SETTINGS = Theme.BLUE.settings;
/**
* Creates a new instance of NimbusLookAndFeel
* @throws java.text.ParseException error parsing the xml, it must not happen.
*
* @throws java.text.ParseException error parsing the xml, it must not
* happen.
*/
public HelloMinecraftLookAndFeel() throws ParseException {
load(HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth.xml"), HelloMinecraftLookAndFeel.class);
this(DEFAULT_SETTINGS);
}
public HelloMinecraftLookAndFeel(Map<String, String> settings) throws ParseException {
try {
String s = NetUtils.getStreamContent(HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth.xml"));
for (String ss : settings.keySet())
s = s.replace("${" + ss + "}", settings.get(ss));
load(new ByteArrayInputStream(s.getBytes()), HelloMinecraftLookAndFeel.class);
} catch (IOException ex) {
ex.printStackTrace();
throw new ParseException("FUCKING BUG", 0);
}
}
UIDefaults uiDefaults;
@Override
public UIDefaults getDefaults() {
if (uiDefaults != null)
return uiDefaults;
uiDefaults = super.getDefaults();
//ui.put("Table.selectionForeground", new ColorUIResource(Color.red));
//ui.put("Table.focusCellForeground", new ColorUIResource(Color.red));
//ui.put("TabbedPane.isTabRollover", false);
//ui.put("ComboBox.selectionBackground", new ColorUIResource(Color.red));
//ui.put("List.background", new ColorUIResource(Color.red));
//uiDefaults.put("TabbedPane.selectedLabelShift", 0);
uiDefaults.put("Table.selectionBackground", Color.red);
return uiDefaults;
}
/**

View File

@@ -0,0 +1,85 @@
/*
* Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see {http://www.gnu.org/licenses/}.
*/
package org.jackhuang.hellominecraft.lookandfeel;
import java.util.HashMap;
import java.util.Map;
import org.jackhuang.hellominecraft.C;
/**
*
* @author huangyuhui
*/
public enum Theme {
BLUE(C.i18n("color.blue"), new HashMap<String, String>() {
{
put("Customized.TabbedPaneTab.selected_foreground", "#106CA3");
put("Customized.ComboBox.selected_background", "#A0D8F0");
put("Customized.MainFrame.background", "#106CA3");
put("Customized.MainFrame.selected_background", "#0C5E91");
}
}),
GREEN(C.i18n("color.green"), new HashMap<String, String>() {
{
put("Customized.TabbedPaneTab.selected_foreground", "#1ABC9C");
put("Customized.ComboBox.selected_background", "#1ABC9C");
put("Customized.MainFrame.background", "#1ABC9C");
put("Customized.MainFrame.selected_background", "#16A085");
}
}),
PURPLE(C.i18n("color.purple"), new HashMap<String, String>() {
{
put("Customized.TabbedPaneTab.selected_foreground", "#9B59B6");
put("Customized.ComboBox.selected_background", "#9B59B6");
put("Customized.MainFrame.background", "#9B59B6");
put("Customized.MainFrame.selected_background", "#8E44AD");
}
}),
DARKER_BLUE(C.i18n("color.dark_blue"), new HashMap<String, String>() {
{
put("Customized.TabbedPaneTab.selected_foreground", "#34495E");
put("Customized.ComboBox.selected_background", "#34495E");
put("Customized.MainFrame.background", "#34495E");
put("Customized.MainFrame.selected_background", "#2C3E50");
}
}),
ORANGE(C.i18n("color.orange"), new HashMap<String, String>() {
{
put("Customized.TabbedPaneTab.selected_foreground", "#E67E22");
put("Customized.ComboBox.selected_background", "#F39C12");
put("Customized.MainFrame.background", "#E67E22");
put("Customized.MainFrame.selected_background", "#D35400");
}
}),
RED(C.i18n("color.red"), new HashMap<String, String>() {
{
put("Customized.TabbedPaneTab.selected_foreground", "#E74C3C");
put("Customized.ComboBox.selected_background", "#E74C3C");
put("Customized.MainFrame.background", "#E74C3C");
put("Customized.MainFrame.selected_background", "#C0392B");
}
});
public final String localizedName;
public final Map<String, String> settings;
private Theme(String localizedName, Map<String, String> settings) {
this.localizedName = localizedName;
this.settings = settings;
}
}

View File

@@ -37,23 +37,13 @@ import java.awt.LinearGradientPaint;
*/
public class ProgressPainter extends SynthPainter {
private static final float[] NORMAL_BG_PTS = new float[]{0, 1};
private static final Color[] NORMAL_BG = new Color[]{
private static final float[] NORMAL_BG_PTS = new float[] {0, 1};
private static final Color[] NORMAL_BG = new Color[] {
GraphicsUtils.getWebColor("c6c6c6"),
GraphicsUtils.getWebColor("c6c6c6")
};
private static final float[] NORMAL_FG_PTS = new float[]{0, 1};
private static final Color[] NORMAL_FG = new Color[]{
GraphicsUtils.getWebColor("c6c6c6"),
GraphicsUtils.getWebColor("c6c6c6")
};
private static final float[] BAR_BG_PTS = new float[]{0, 1};
private static final Color[] BAR_BG = new Color[]{
GraphicsUtils.getWebColor("41B1E1"),
GraphicsUtils.getWebColor("41B1E1")
};
private static final float[] BAR_FG_PTS = new float[]{0, 1};
private static final Color[] BAR_FG = new Color[]{
private static final float[] BAR_FG_PTS = new float[] {0, 1};
private static final Color[] BAR_FG = new Color[] {
GraphicsUtils.getWebColor("41B1E1"),
GraphicsUtils.getWebColor("41B1E1")
};
@@ -61,39 +51,31 @@ public class ProgressPainter extends SynthPainter {
/**
* {@inheritDoc}
*/
@Override
public void paintProgressBarBackground(SynthContext context, Graphics g, int x, int y, int w, int h,
int orientation) {
int orientation) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setPaint(new LinearGradientPaint(x, y + 3, x, y + h - 4, NORMAL_BG_PTS, NORMAL_BG));
if (x + 2 < w - 5 && y + 2 < h - 5) {
g2.setPaint(new LinearGradientPaint(x, y + 2, x, y + h - 4, NORMAL_BG_PTS, NORMAL_BG));
if (x + 2 < w - 5 && y + 2 < h - 5)
g2.fillRect(x + 2, y + 2, w - 5, h - 5);
}
g2.setPaint(new LinearGradientPaint(x, y + 2, x, y + h - 5, NORMAL_FG_PTS, NORMAL_FG));
if (x + 2 < w - 5 && y + 2 < h - 5) {
g2.drawRect(x + 2, y + 2, w - 5, h - 5);
}
}
/**
* {@inheritDoc}
*/
@Override
public void paintProgressBarForeground(SynthContext context, Graphics g, int x, int y, int w, int h,
int orientation) {
int orientation) {
Graphics2D g2 = (Graphics2D) g.create();
g2.setPaint(new LinearGradientPaint(x, y + 3, x, y + h - 4, BAR_BG_PTS, BAR_BG));
if (x + 2 < w - 5 && y + 2 < h - 5) {
g2.fillRect(x + 2, y + 2, w - 5, h - 5);
}
g2.setPaint(new LinearGradientPaint(x, y + 2, x, y + h - 2, BAR_FG_PTS, BAR_FG));
if (x + 2 < w - 5 && y + 2 < h - 5) {
if (x + 2 < w - 5 && y + 2 < h - 5)
g2.drawRect(x + 2, y + 2, w - 5, h - 5);
}
}
/**
* {@inheritDoc}
*/
@Override
public void paintProgressBarBorder(SynthContext context, Graphics g, int x, int y, int w, int h, int orientation) {
}
}

View File

@@ -17,7 +17,7 @@
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
*/
package org.jackhuang.hellominecraft.lookandfeel.ui;
import javax.swing.DefaultListCellRenderer;
@@ -33,8 +33,9 @@ import java.awt.Component;
*/
public class ListCellRender extends DefaultListCellRenderer {
@Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
setOpaque(true);
setBackground(Color.magenta);
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

View File

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 141 B

View File

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 141 B

View File

Before

Width:  |  Height:  |  Size: 141 B

After

Width:  |  Height:  |  Size: 141 B

View File

Before

Width:  |  Height:  |  Size: 143 B

After

Width:  |  Height:  |  Size: 143 B

View File

Before

Width:  |  Height:  |  Size: 436 B

After

Width:  |  Height:  |  Size: 436 B

View File

Before

Width:  |  Height:  |  Size: 324 B

After

Width:  |  Height:  |  Size: 324 B

View File

Before

Width:  |  Height:  |  Size: 415 B

After

Width:  |  Height:  |  Size: 415 B

View File

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 327 B

View File

Before

Width:  |  Height:  |  Size: 224 B

After

Width:  |  Height:  |  Size: 224 B

View File

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 241 B

View File

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 230 B

View File

Before

Width:  |  Height:  |  Size: 273 B

After

Width:  |  Height:  |  Size: 273 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 433 B

After

Width:  |  Height:  |  Size: 433 B

View File

Before

Width:  |  Height:  |  Size: 457 B

After

Width:  |  Height:  |  Size: 457 B

View File

Before

Width:  |  Height:  |  Size: 590 B

After

Width:  |  Height:  |  Size: 590 B

View File

Before

Width:  |  Height:  |  Size: 491 B

After

Width:  |  Height:  |  Size: 491 B

View File

Before

Width:  |  Height:  |  Size: 534 B

After

Width:  |  Height:  |  Size: 534 B

View File

Before

Width:  |  Height:  |  Size: 578 B

After

Width:  |  Height:  |  Size: 578 B

View File

Before

Width:  |  Height:  |  Size: 632 B

After

Width:  |  Height:  |  Size: 632 B

View File

Before

Width:  |  Height:  |  Size: 664 B

After

Width:  |  Height:  |  Size: 664 B

View File

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 243 B

View File

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 241 B

View File

Before

Width:  |  Height:  |  Size: 243 B

After

Width:  |  Height:  |  Size: 243 B

View File

Before

Width:  |  Height:  |  Size: 147 B

After

Width:  |  Height:  |  Size: 147 B

View File

Before

Width:  |  Height:  |  Size: 151 B

After

Width:  |  Height:  |  Size: 151 B

View File

Before

Width:  |  Height:  |  Size: 252 B

After

Width:  |  Height:  |  Size: 252 B

View File

Before

Width:  |  Height:  |  Size: 236 B

After

Width:  |  Height:  |  Size: 236 B

View File

Before

Width:  |  Height:  |  Size: 252 B

After

Width:  |  Height:  |  Size: 252 B

View File

Before

Width:  |  Height:  |  Size: 200 B

After

Width:  |  Height:  |  Size: 200 B

View File

Before

Width:  |  Height:  |  Size: 200 B

After

Width:  |  Height:  |  Size: 200 B

View File

Before

Width:  |  Height:  |  Size: 200 B

After

Width:  |  Height:  |  Size: 200 B

View File

@@ -238,7 +238,7 @@
<!-- ########################################################################################################### -->
<style id="progress">
<object id="ProgressPainter" class="org.jackhuang.hellominecraft.lookandfeel.painters.ProgressPainter"/>
<object id="ProgressPainter" class="org.jackhuang.hellominecraft.lookandfeel.painters.ProgressPainter" />
<painter idref="ProgressPainter"/>
<property key="ProgressBar.horizontalSize" type="dimension" value="50 20"/>
<property key="ProgressBar.vertictalSize" type="dimension" value="20 50"/>
@@ -253,10 +253,10 @@
<insets top="4" left="8" right="8" bottom="4"/>
<state>
<font name="微软雅黑" size="14" />
<color type="TEXT_FOREGROUND" value="#000000" />
<color type="TEXT_FOREGROUND" value="#000000" /> <!-- #000000 -->
</state>
<state value="SELECTED">
<color type="TEXT_FOREGROUND" value="#106CA3" />
<color type="TEXT_FOREGROUND" value="${Customized.TabbedPaneTab.selected_foreground}" /> <!-- #106CA3 -->
</state>
</style>
<bind style="TabbedPaneTab" type="region" key="TabbedPaneTab"/>
@@ -264,47 +264,27 @@
<insets top="3" left="10" right="10" bottom="5"/>
</style>
<bind style="TabbedPaneTabArea" type="region" key="TabbedPaneTabArea"/>
<int id="TabbedPane.selectedLabelShift">0</int>
<int id="TabbedPane.labelShift">0</int>
<boolean id="TabbedPane.nudgeSelectedLabel">false</boolean>
<defaultsProperty key="TabbedPane.selectedLabelShift" type="idref" value="TabbedPane.selectedLabelShift" />
<defaultsProperty key="TabbedPane.labelShift" type="idref" value="TabbedPane.labelShift" />
<defaultsProperty key="TabbedPane.nudgeSelectedLabel" type="idref" value="TabbedPane.nudgeSelectedLabel" />
<!-- ########################################################################################################### -->
<!-- COMBO BOX -->
<!-- ########################################################################################################### -->
<object class="javax.swing.plaf.ColorUIResource" id="ComboBox.background">
<int>237</int>
<int>239</int>
<int>242</int>
</object>
<color id = "ComboBox.background" value="#EDEFF2" />
<defaultsProperty key="ComboBox.background" type="idref" value="ComboBox.background"/>
<object class="javax.swing.plaf.ColorUIResource" id="ComboBox.selectionForeground">
<int>0</int>
<int>0</int>
<int>0</int>
</object>
<color id = "ComboBox.selectionForeground" value="#000000" />
<defaultsProperty key="ComboBox.selectionForeground" type="idref" value="ComboBox.selectionForeground"/>
<object class="javax.swing.plaf.ColorUIResource" id="ComboBox.selectionBackground">
<int>160</int>
<int>216</int>
<int>240</int>
</object>
<color id = "ComboBox.selectionBackground" value="${Customized.ComboBox.selected_background}" /> <!-- #A0D8F0 -->
<defaultsProperty key="ComboBox.selectionBackground" type="idref" value="ComboBox.selectionBackground"/>
<object class="javax.swing.plaf.ColorUIResource" id="ComboBox.foreground">
<int>35</int>
<int>35</int>
<int>36</int>
</object>
<color id = "ComboBox.foreground" value="#232324" />
<defaultsProperty key="ComboBox.foreground" type="idref" value="ComboBox.foreground"/>
<style id="combobox">
<state value="SELECTED">
<color type="BACKGROUND" value="#A0D8F0" />
<color type="TEXT_FOREGROUND" value="#70C5E9" />
</state>
<state>
<color type="BACKGROUND" value="#A0D8F0" />
<color type="TEXT_FOREGROUND" value="#70C5E9" />
</state>
<property key="ComboBox.rendererUseListColors" type="boolean" value="false"/>
</style>
<style id="Combo listRenderer">
<insets top="2" left="2" bottom="3" right="2"/>
<opaque value="true"/>
@@ -321,7 +301,7 @@
<color type="TEXT_FOREGROUND" value="#70C5E9" />
</state>
</style>
<bind style="combobox" type="region" key="ComboBox" />
<!--bind style="combobox" type="region" key="ComboBox" /-->
<bind style="Combo listRenderer" type="name" key="ComboBox.listRenderer"/>
<defaultsProperty key="ComboBoxUI" type="string" value="org.jackhuang.hellominecraft.lookandfeel.ui.ComboBoxUI"/>
@@ -367,29 +347,13 @@
<bind style="List listRenderer" type="name" key="List.listRenderer"/>
<object class="javax.swing.plaf.ColorUIResource" id="List.background">
<int>237</int>
<int>239</int>
<int>242</int>
</object>
<color id="List.background" value="#EDEFF2" />
<defaultsProperty key="List.background" type="idref" value="List.background"/>
<object class="javax.swing.plaf.ColorUIResource" id="List.selectionForeground">
<int>255</int>
<int>255</int>
<int>255</int>
</object>
<color id="List.selectionForeground" value="#FFFFFF" />
<defaultsProperty key="List.selectionForeground" type="idref" value="List.selectionForeground"/>
<object class="javax.swing.plaf.ColorUIResource" id="ListSelectionBackground">
<int>0</int>
<int>0</int>
<int>255</int>
</object>
<color id="ListSelectionBackground" value="#0000FF" />
<defaultsProperty key="List.selectionBackground" type="idref" value="ListSelectionBackground"/>
<object class="javax.swing.plaf.ColorUIResource" id="List.foreground">
<int>35</int>
<int>35</int>
<int>36</int>
</object>
<color id="List.foreground" value="#232324" />
<defaultsProperty key="List.foreground" type="idref" value="List.foreground"/>
<defaultsProperty key="List.rendererUseListColors" type="boolean" value="false"/>
@@ -413,20 +377,9 @@
<bind style="OptionPane" type="region" key="OptionPane"/>
<style id="table">
<object class="javax.swing.plaf.ColorUIResource" id="color">
<int>255</int>
<int>0</int>
<int>0</int>
</object>
<defaultsProperty key="Table.focusCellForeground" type="idref" value="color"/>
<object class="javax.swing.plaf.ColorUIResource" id="gridColor">
<int>30</int>
<int>123</int>
<int>135</int>
</object>
<defaultsProperty key="Table.gridColor" type="idref" value="gridColor"/>
<defaultsProperty key="Table.selectionBackground" type="idref" value="gridColor"/>
<defaultsProperty key="Table.selectionForeground" type="idref" value="gridColor"/>
<color id="color" value="#FF0000" />
<color id="gridColor" value="#1E7B87" />
<defaultsProperty key="Table.gridColor" type="idref" value="gridColor"/>
<defaultsProperty key="Table.background" type="idref" value="gridColor"/>
</style>
<bind style="table" type="region" key="Table"/>