This commit is contained in:
huangyuhui
2017-02-15 20:28:01 +08:00
parent 55b36e734d
commit f836afa2ea
439 changed files with 1943 additions and 21556 deletions

View File

@@ -14,10 +14,10 @@
* You should have received a copy of the GNU General Public License
* along with this program.
*/
package org.jackhuang.hellominecraft.lookandfeel;
package org.jackhuang.hmcl.laf;
import java.awt.Color;
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
import org.jackhuang.hmcl.util.ui.GraphicsUtils;
/**
*

View File

@@ -14,17 +14,20 @@
* You should have received a copy of the GNU General Public License
* along with this program.
*/
package org.jackhuang.hellominecraft.lookandfeel;
package org.jackhuang.hmcl.laf;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.text.ParseException;
import java.util.Map;
import javax.imageio.ImageIO;
import javax.swing.UIDefaults;
import javax.swing.plaf.synth.SynthLookAndFeel;
import org.jackhuang.hellominecraft.util.log.HMCLog;
import org.jackhuang.hellominecraft.util.sys.IOUtils;
import org.jackhuang.hmcl.api.HMCLog;
import org.jackhuang.hmcl.util.sys.IOUtils;
import org.jackhuang.hmcl.util.ui.GraphicsUtils;
/**
*
@@ -32,7 +35,7 @@ import org.jackhuang.hellominecraft.util.sys.IOUtils;
*/
public class HelloMinecraftLookAndFeel extends SynthLookAndFeel {
public static final Map<String, String> DEFAULT_SETTINGS = Theme.BLUE.settings;
public static final Map<String, String> DEFAULT_SETTINGS = LAFTheme.BLUE.settings;
/**
* Creates a new instance of NimbusLookAndFeel
@@ -46,7 +49,7 @@ public class HelloMinecraftLookAndFeel extends SynthLookAndFeel {
public HelloMinecraftLookAndFeel(Map<String, String> settings) throws ParseException {
try {
try (InputStream is = HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth.xml")) {
try (InputStream is = HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hmcl/laf/synth.xml")) {
String s = IOUtils.toString(is, "UTF-8");
for (Map.Entry<String, String> ss : settings.entrySet())
s = s.replace("${" + ss.getKey() + "}", ss.getValue());
@@ -55,7 +58,7 @@ public class HelloMinecraftLookAndFeel extends SynthLookAndFeel {
} catch (Throwable ex) {
HMCLog.err("This fucking exception should not happen. Retry backup solution.", ex);
try {
try (InputStream is = HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hellominecraft/lookandfeel/synth_backup.xml")) {
try (InputStream is = HelloMinecraftLookAndFeel.class.getResourceAsStream("/org/jackhuang/hmcl/laf/synth_backup.xml")) {
load(is, HelloMinecraftLookAndFeel.class);
}
} catch (Throwable e) {
@@ -110,4 +113,23 @@ public class HelloMinecraftLookAndFeel extends SynthLookAndFeel {
public String getDescription() {
return "HelloMinecraftLookAndFeel";
}
/**
* Load an image using ImageIO from resource in
* org.jdesktop.swingx.plaf.nimbus.images. Catches and prints all Exceptions
* so that it can safely be used in a static context.
*
* @param imgName The name of the image to load, eg. "border.png"
*
* @return The loaded image
*/
public static BufferedImage loadImage(String imgName) {
try {
return ImageIO.read(GraphicsUtils.class.getClassLoader().getResource("org/jackhuang/hmcl/laf/images/" + imgName));
} catch (Exception e) {
System.err.println("Error loading image \"org/jackhuang/hmcl/laf/images/" + imgName + "\"");
e.printStackTrace();
}
return null;
}
}

View File

@@ -15,19 +15,18 @@
* 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;
package org.jackhuang.hmcl.laf;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import org.jackhuang.hellominecraft.util.C;
import org.jackhuang.hmcl.api.ui.Theme;
import org.jackhuang.hmcl.util.C;
/**
*
* @author huangyuhui
*/
public enum Theme {
BLUE(C.i18n("color.blue"), new HashMap<String, String>() {
public final class LAFTheme {
public static final Theme BLUE = new Theme("blue", C.i18n("color.blue"), new HashMap<String, String>() {
{
put("Customized.TabbedPaneTab.selected_foreground", "#106CA3");
put("Customized.ComboBox.selected_background", "#A0D8F0");
@@ -35,8 +34,8 @@ public enum Theme {
put("Customized.MainFrame.selected_background", "#0C5E91");
put("Customized.MainFrame.background_image", "background.jpg");
}
}),
GREEN(C.i18n("color.green"), new HashMap<String, String>() {
});
public static final Theme GREEN = new Theme("green", C.i18n("color.green"), new HashMap<String, String>() {
{
put("Customized.TabbedPaneTab.selected_foreground", "#1ABC9C");
put("Customized.ComboBox.selected_background", "#1ABC9C");
@@ -44,8 +43,8 @@ public enum Theme {
put("Customized.MainFrame.selected_background", "#16A085");
put("Customized.MainFrame.background_image", "background.jpg");
}
}),
PURPLE(C.i18n("color.purple"), new HashMap<String, String>() {
});
public static final Theme PURPLE = new Theme("purple", C.i18n("color.purple"), new HashMap<String, String>() {
{
put("Customized.TabbedPaneTab.selected_foreground", "#9B59B6");
put("Customized.ComboBox.selected_background", "#9B59B6");
@@ -53,8 +52,8 @@ public enum Theme {
put("Customized.MainFrame.selected_background", "#8E44AD");
put("Customized.MainFrame.background_image", "background.jpg");
}
}),
DARKER_BLUE(C.i18n("color.dark_blue"), new HashMap<String, String>() {
});
public static final Theme DARKER_BLUE = new Theme("darker_blue", C.i18n("color.dark_blue"), new HashMap<String, String>() {
{
put("Customized.TabbedPaneTab.selected_foreground", "#34495E");
put("Customized.ComboBox.selected_background", "#34495E");
@@ -62,8 +61,8 @@ public enum Theme {
put("Customized.MainFrame.selected_background", "#2C3E50");
put("Customized.MainFrame.background_image", "background.jpg");
}
}),
ORANGE(C.i18n("color.orange"), new HashMap<String, String>() {
});
public static final Theme ORANGE = new Theme("orange", C.i18n("color.orange"), new HashMap<String, String>() {
{
put("Customized.TabbedPaneTab.selected_foreground", "#E67E22");
put("Customized.ComboBox.selected_background", "#F39C12");
@@ -71,8 +70,8 @@ public enum Theme {
put("Customized.MainFrame.selected_background", "#D35400");
put("Customized.MainFrame.background_image", "background.jpg");
}
}),
RED(C.i18n("color.red"), new HashMap<String, String>() {
});
public static final Theme RED = new Theme("red", C.i18n("color.red"), new HashMap<String, String>() {
{
put("Customized.TabbedPaneTab.selected_foreground", "#E74C3C");
put("Customized.ComboBox.selected_background", "#E74C3C");
@@ -81,12 +80,5 @@ public enum Theme {
put("Customized.MainFrame.background_image", "background.jpg");
}
});
public final String localizedName;
public final Map<String, String> settings;
private Theme(String localizedName, Map<String, String> settings) {
this.localizedName = localizedName;
this.settings = Objects.requireNonNull(settings, "Theme settings map may not be null.");
}
public static final Theme[] THEMES = new Theme[] {BLUE, GREEN, PURPLE, DARKER_BLUE, ORANGE, RED};
}

View File

@@ -18,7 +18,7 @@
* 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.painter;
package org.jackhuang.hmcl.laf.painter;
import java.awt.Color;
import java.awt.Graphics;
@@ -30,8 +30,8 @@ import javax.swing.Timer;
import javax.swing.plaf.synth.SynthConstants;
import javax.swing.plaf.synth.SynthContext;
import javax.swing.plaf.synth.SynthPainter;
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
import org.jackhuang.hellominecraft.lookandfeel.ConstomButton;
import org.jackhuang.hmcl.util.ui.GraphicsUtils;
import org.jackhuang.hmcl.laf.ConstomButton;
/**
* ButtonPainter - handles painting Nimbus style buttons with Java2D

View File

@@ -18,9 +18,9 @@
* 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.painter;
package org.jackhuang.hmcl.laf.painter;
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
import org.jackhuang.hmcl.util.ui.GraphicsUtils;
import javax.swing.plaf.synth.SynthContext;
import javax.swing.plaf.synth.SynthPainter;

View File

@@ -18,14 +18,14 @@
* 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.painter;
package org.jackhuang.hmcl.laf.painter;
import javax.swing.plaf.synth.SynthContext;
import javax.swing.plaf.synth.SynthPainter;
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.plaf.synth.SynthConstants;
import org.jackhuang.hellominecraft.util.ui.GraphicsUtils;
import org.jackhuang.hmcl.util.ui.GraphicsUtils;
/**
* TextFieldPainter

View File

@@ -1,6 +1,6 @@
package org.jackhuang.hellominecraft.lookandfeel.ui;
package org.jackhuang.hmcl.laf.ui;
import static org.jackhuang.hellominecraft.util.ui.GraphicsUtils.loadImage;
import static org.jackhuang.hmcl.laf.HelloMinecraftLookAndFeel.loadImage;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicComboBoxUI;
@@ -134,8 +134,9 @@ public class ComboBoxUI extends BasicComboBoxUI implements MouseListener {
((JComponent) renderer).setForeground(comboBox.getForeground());
}
paintCurrentValue(g, rectangleForCurrentValue(), false);
if (renderer instanceof JComponent)
if (renderer instanceof JComponent) {
((JComponent) renderer).setOpaque(true);
}
}
}

View File

@@ -18,7 +18,7 @@
* 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;
package org.jackhuang.hmcl.laf.ui;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;

View File

@@ -2,9 +2,9 @@
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jackhuang.hellominecraft.lookandfeel.ui;
package org.jackhuang.hmcl.laf.ui;
import static org.jackhuang.hellominecraft.util.ui.GraphicsUtils.loadImage;
import static org.jackhuang.hmcl.laf.HelloMinecraftLookAndFeel.loadImage;
import javax.swing.JButton;
import javax.swing.JComponent;

View File

@@ -18,7 +18,7 @@
* 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;
package org.jackhuang.hmcl.laf.ui;
import javax.swing.plaf.metal.MetalScrollButton;
import java.awt.Dimension;

View File

@@ -26,7 +26,7 @@
<color value="#9CC5D8" type="TEXT_BACKGROUND"/>
<font name="微软雅黑" size="12" />
</state>
<object id="GraphicsUtils" class="org.jackhuang.hellominecraft.util.ui.GraphicsUtils"/>
<object id="GraphicsUtils" class="org.jackhuang.hmcl.util.ui.GraphicsUtils"/>
<graphicsUtils idref="GraphicsUtils"/>
</style>
<bind style="default" type="region" key=".*"/>
@@ -43,7 +43,7 @@
<!-- SCROLL BARS & VIEW PORT -->
<!-- ########################################################################################################### -->
<defaultsProperty key="ScrollBarUI" type="string" value="org.jackhuang.hellominecraft.lookandfeel.ui.ScrollBarUI"/>
<defaultsProperty key="ScrollBarUI" type="string" value="org.jackhuang.hmcl.laf.ui.ScrollBarUI"/>
<defaultsProperty key="ScrollBar.width" type="integer" value="15"/>
<defaultsProperty key="ScrollBar.minimumThumbSize" type="dimension" value="29 29"/>
<defaultsProperty key="ScrollBar.maximumThumbSize" type="dimension" value="1000 1000"/>
@@ -58,7 +58,7 @@
<!-- ########################################################################################################### -->
<style id="button">
<object id="ButtonPainter" class="org.jackhuang.hellominecraft.lookandfeel.painter.ButtonPainter"/>
<object id="ButtonPainter" class="org.jackhuang.hmcl.laf.painter.ButtonPainter"/>
<painter idref="ButtonPainter"/>
<state value="DISABLED">
<color value="#ACAEB2" type="TEXT_FOREGROUND"/>
@@ -70,7 +70,7 @@
</style>
<bind style="button" type="region" key="Button"/>
<style id="togglebutton">
<object id="ButtonPainter" class="org.jackhuang.hellominecraft.lookandfeel.painter.ButtonPainter"/>
<object id="ButtonPainter" class="org.jackhuang.hmcl.laf.painter.ButtonPainter"/>
<painter idref="ButtonPainter"/>
<state value="DISABLED">
<color value="#ACAEB2" type="TEXT_FOREGROUND"/>
@@ -160,7 +160,7 @@
<!-- ########################################################################################################### -->
<style id="textfield">
<object id="TextFieldPainter" class="org.jackhuang.hellominecraft.lookandfeel.painter.TextFieldPainter"/>
<object id="TextFieldPainter" class="org.jackhuang.hmcl.laf.painter.TextFieldPainter"/>
<painter idref="TextFieldPainter"/>
<state>
<font name="微软雅黑" size="12" />
@@ -177,7 +177,7 @@
<!-- ########################################################################################################### -->
<style id="scrollpane">
<object id="TextFieldPainter" class="org.jackhuang.hellominecraft.lookandfeel.painter.TextFieldPainter"/>
<object id="TextFieldPainter" class="org.jackhuang.hmcl.laf.painter.TextFieldPainter"/>
<painter idref="TextFieldPainter"/>
<insets top="4" left="6" bottom="4" right="6"/>
</style>
@@ -238,7 +238,7 @@
<!-- ########################################################################################################### -->
<style id="progress">
<object id="ProgressPainter" class="org.jackhuang.hellominecraft.lookandfeel.painter.ProgressPainter" />
<object id="ProgressPainter" class="org.jackhuang.hmcl.laf.painter.ProgressPainter" />
<painter idref="ProgressPainter"/>
<property key="ProgressBar.horizontalSize" type="dimension" value="50 20"/>
<property key="ProgressBar.vertictalSize" type="dimension" value="20 50"/>
@@ -304,7 +304,7 @@
<!--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"/>
<defaultsProperty key="ComboBoxUI" type="string" value="org.jackhuang.hmcl.laf.ui.ComboBoxUI"/>
<!-- ########################################################################################################### -->
<!-- LIST -->

View File

@@ -26,7 +26,7 @@
<color value="#9CC5D8" type="TEXT_BACKGROUND"/>
<font name="微软雅黑" size="12" />
</state>
<object id="GraphicsUtils" class="org.jackhuang.hellominecraft.util.ui.GraphicsUtils"/>
<object id="GraphicsUtils" class="org.jackhuang.hmcl.util.ui.GraphicsUtils"/>
<graphicsUtils idref="GraphicsUtils"/>
</style>
<bind style="default" type="region" key=".*"/>
@@ -43,7 +43,7 @@
<!-- SCROLL BARS & VIEW PORT -->
<!-- ########################################################################################################### -->
<defaultsProperty key="ScrollBarUI" type="string" value="org.jackhuang.hellominecraft.lookandfeel.ui.ScrollBarUI"/>
<defaultsProperty key="ScrollBarUI" type="string" value="org.jackhuang.hmcl.laf.ui.ScrollBarUI"/>
<defaultsProperty key="ScrollBar.width" type="integer" value="15"/>
<defaultsProperty key="ScrollBar.minimumThumbSize" type="dimension" value="29 29"/>
<defaultsProperty key="ScrollBar.maximumThumbSize" type="dimension" value="1000 1000"/>
@@ -58,7 +58,7 @@
<!-- ########################################################################################################### -->
<style id="button">
<object id="ButtonPainter" class="org.jackhuang.hellominecraft.lookandfeel.painter.ButtonPainter"/>
<object id="ButtonPainter" class="org.jackhuang.hmcl.laf.painter.ButtonPainter"/>
<painter idref="ButtonPainter"/>
<state value="DISABLED">
<color value="#ACAEB2" type="TEXT_FOREGROUND"/>
@@ -70,7 +70,7 @@
</style>
<bind style="button" type="region" key="Button"/>
<style id="togglebutton">
<object id="ButtonPainter" class="org.jackhuang.hellominecraft.lookandfeel.painter.ButtonPainter"/>
<object id="ButtonPainter" class="org.jackhuang.hmcl.laf.painter.ButtonPainter"/>
<painter idref="ButtonPainter"/>
<state value="DISABLED">
<color value="#ACAEB2" type="TEXT_FOREGROUND"/>
@@ -160,7 +160,7 @@
<!-- ########################################################################################################### -->
<style id="textfield">
<object id="TextFieldPainter" class="org.jackhuang.hellominecraft.lookandfeel.painter.TextFieldPainter"/>
<object id="TextFieldPainter" class="org.jackhuang.hmcl.laf.painter.TextFieldPainter"/>
<painter idref="TextFieldPainter"/>
<state>
<font name="微软雅黑" size="12" />
@@ -177,7 +177,7 @@
<!-- ########################################################################################################### -->
<style id="scrollpane">
<object id="TextFieldPainter" class="org.jackhuang.hellominecraft.lookandfeel.painter.TextFieldPainter"/>
<object id="TextFieldPainter" class="org.jackhuang.hmcl.laf.painter.TextFieldPainter"/>
<painter idref="TextFieldPainter"/>
<insets top="4" left="6" bottom="4" right="6"/>
</style>
@@ -238,7 +238,7 @@
<!-- ########################################################################################################### -->
<style id="progress">
<object id="ProgressPainter" class="org.jackhuang.hellominecraft.lookandfeel.painter.ProgressPainter" />
<object id="ProgressPainter" class="org.jackhuang.hmcl.laf.painter.ProgressPainter" />
<painter idref="ProgressPainter"/>
<property key="ProgressBar.horizontalSize" type="dimension" value="50 20"/>
<property key="ProgressBar.vertictalSize" type="dimension" value="20 50"/>
@@ -304,7 +304,7 @@
<!--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"/>
<defaultsProperty key="ComboBoxUI" type="string" value="org.jackhuang.hmcl.laf.ui.ComboBoxUI"/>
<!-- ########################################################################################################### -->
<!-- LIST -->