diff --git a/.travis.yml b/.travis.yml index 9fce3d616..4b6cbcf3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,9 +17,6 @@ deploy: - HMCL/build/libs/HMCL-${HMCL_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.jar - HMCL/build/libs/HMCL-${HMCL_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.exe - HMCL/build/libs/HMCL-${HMCL_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}-MacOSApp.zip - - HMCSM/build/libs/HMCSM-${HMCSM_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.jar - - HMCSM/build/libs/HMCSM-${HMCSM_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}.exe - - HMCSM/build/libs/HMCSM-${HMCSM_VERSION_ROOT}.${TRAVIS_BUILD_NUMBER}-MacOSApp.zip on: repo: huanghongxun/HMCL tags: false diff --git a/HMCL/build.gradle b/HMCL/build.gradle index ce980544b..9e388e0d5 100755 --- a/HMCL/build.gradle +++ b/HMCL/build.gradle @@ -46,7 +46,7 @@ def buildnumber = System.getenv("TRAVIS_BUILD_NUMBER") if (buildnumber == null) buildnumber = System.getenv("BUILD_NUMBER") if (buildnumber == null) - buildnumber = "1" + buildnumber = "2" def versionroot = System.getenv("VERSION_ROOT") if (versionroot == null) diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Main.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Main.java index d570d6811..05868d6e3 100644 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Main.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/Main.java @@ -77,21 +77,6 @@ public final class Main implements Runnable { }; private static final HostnameVerifier HNV = (hostname, session) -> true; - static { - SSLContext sslContext = null; - - try { - sslContext = SSLContext.getInstance("TLS"); - X509TrustManager[] xtmArray = new X509TrustManager[] { XTM }; - sslContext.init(null, xtmArray, new java.security.SecureRandom()); - } catch (GeneralSecurityException gse) { - } - if (sslContext != null) - HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory()); - - HttpsURLConnection.setDefaultHostnameVerifier(HNV); - } - public static final String LAUNCHER_NAME = "Hello Minecraft! Launcher"; public static final String LAUNCHER_VERSION = "@HELLO_MINECRAFT_LAUNCHER_VERSION_FOR_GRADLE_REPLACING@"; public static final int MINIMUM_LAUNCHER_VERSION = 16; @@ -129,6 +114,16 @@ public final class Main implements Runnable { System.setProperty("swing.aatext", "true"); System.setProperty("sun.java2d.noddraw", "true"); System.setProperty("sun.java2d.dpiaware", "false"); + System.setProperty("https.protocols", "SSLv3,TLSv1"); + + try { + SSLContext c = SSLContext.getInstance("SSL"); + c.init(null, new X509TrustManager[] { XTM }, new java.security.SecureRandom()); + HttpsURLConnection.setDefaultSSLSocketFactory(c.getSocketFactory()); + } catch (GeneralSecurityException ignore) { + } + HttpsURLConnection.setDefaultHostnameVerifier(HNV); + Thread.setDefaultUncaughtExceptionHandler(new CrashReporter(true)); try { diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/setting/Config.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/setting/Config.java index 3c1f0057b..13ba76e8b 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/setting/Config.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/setting/Config.java @@ -53,6 +53,8 @@ public final class Config implements Cloneable { private String proxyPassword; @SerializedName("enableShadow") private boolean enableShadow; + @SerializedName("enableBlur") + private boolean enableBlur; @SerializedName("decorated") private boolean decorated; @SerializedName("theme") @@ -108,6 +110,15 @@ public final class Config implements Cloneable { Settings.save(); } + public boolean isEnableBlur() { + return enableBlur; + } + + public void setEnableBlur(boolean enableBlur) { + this.enableBlur = enableBlur; + Settings.save(); + } + public String getLast() { if (last == null) last = Settings.DEFAULT_PROFILE; @@ -183,7 +194,7 @@ public final class Config implements Cloneable { public Config() { clientToken = UUID.randomUUID().toString(); logintype = downloadtype = 0; - enableShadow = false; + enableBlur = enableShadow = true; theme = 4; decorated = OS.os() == OS.LINUX; auth = new HashMap<>(); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/GaussionPage.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/GaussionPage.java new file mode 100644 index 000000000..2c672726e --- /dev/null +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/GaussionPage.java @@ -0,0 +1,86 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui + * + * 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.launcher.ui; + +import java.awt.AlphaComposite; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Rectangle; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.List; +import javax.swing.JPanel; +import org.jackhuang.hellominecraft.util.ui.StackBlurFilter; + +/** + * + * @author huangyuhui + */ +public class GaussionPage extends Page { + + private transient BufferedImage aeroBuffer; // 模糊缓存 + private transient Image backgroundImage; + private final List aeroObject = new ArrayList<>(); + private transient Graphics2D aeroGraphics; // 模糊对象 + private static final int RADIUS = 10; // 模糊半径 + private transient final StackBlurFilter stackBlurFilter = new StackBlurFilter(RADIUS); + private transient BufferedImage cache = null; + + public void setBackgroundImage(Image backgroundImage) { + this.backgroundImage = backgroundImage; + } + + public void addAeroObject(JPanel aeroObject) { + this.aeroObject.add(aeroObject); + cache = null; + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + if (backgroundImage == null) + return; + + if (cache == null || getWidth() != cache.getWidth() || getHeight() != cache.getHeight()) { + cache = new BufferedImage(getWidth(), getHeight(), 2); + Graphics2D g2 = cache.createGraphics(); + g2.drawImage(backgroundImage, 0, 0, getWidth(), getHeight(), null); + for (JPanel panel : aeroObject) { + Rectangle aeroRect = panel.getBounds(); + if (aeroBuffer == null || aeroBuffer.getWidth() != aeroRect.width + RADIUS || aeroBuffer.getHeight() != aeroRect.height + RADIUS) { + if (aeroBuffer != null && aeroGraphics != null) { + aeroBuffer.flush(); + aeroGraphics.dispose(); + } + aeroBuffer = new BufferedImage(aeroRect.width + RADIUS, aeroRect.height + RADIUS, BufferedImage.TRANSLUCENT); + } + + aeroGraphics = aeroBuffer.createGraphics(); + aeroGraphics.setComposite(AlphaComposite.Src); + aeroGraphics.drawImage(backgroundImage, 0, 0, aeroBuffer.getWidth(), aeroBuffer.getHeight(), aeroRect.x, aeroRect.y, aeroRect.x + aeroRect.width, aeroRect.y + aeroRect.height, null); + aeroBuffer = stackBlurFilter.filter(aeroBuffer, null); + g2.drawImage(aeroBuffer, aeroRect.x, aeroRect.y, aeroRect.x + aeroRect.width, aeroRect.y + aeroRect.height, RADIUS / 2, RADIUS / 2, RADIUS / 2 + aeroRect.width, RADIUS / 2 + aeroRect.height, null); + } + g2.dispose(); + } + g.drawImage(cache, 0, 0, getWidth(), getHeight(), null); + } + +} diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/IRepaint.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/IRepaint.java new file mode 100644 index 000000000..2182a0113 --- /dev/null +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/IRepaint.java @@ -0,0 +1,34 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui + * + * 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.launcher.ui; + +import java.awt.Rectangle; +import java.awt.Window; +import java.util.Collection; +import javax.swing.JComponent; + +/** + * + * @author huang + */ +public interface IRepaint { + JComponent getRepaintComponent(); + Window getRepaintWindow(); + + Collection getRepaintRects(); +} diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/LauncherSettingsPanel.form b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/LauncherSettingsPanel.form index c0c3a6cb8..441e7dd3e 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/LauncherSettingsPanel.form +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/LauncherSettingsPanel.form @@ -72,6 +72,8 @@ + + @@ -120,6 +122,7 @@ + @@ -341,5 +344,15 @@ + + + + + + + + + + diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/LauncherSettingsPanel.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/LauncherSettingsPanel.java index 61e95c964..b09e42091 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/LauncherSettingsPanel.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/LauncherSettingsPanel.java @@ -72,6 +72,7 @@ public class LauncherSettingsPanel extends RepaintPage { cboDownloadSource.setSelectedIndex(Settings.getInstance().getDownloadType()); cboTheme.setSelectedIndex(Settings.getInstance().getTheme().ordinal()); chkEnableShadow.setSelected(Settings.getInstance().isEnableShadow()); + chkEnableBlur.setSelected(Settings.getInstance().isEnableBlur()); chkDecorated.setSelected(Settings.getInstance().isDecorated()); } @@ -115,6 +116,7 @@ public class LauncherSettingsPanel extends RepaintPage { lblLang = new javax.swing.JLabel(); lblRestart = new javax.swing.JLabel(); btnMCBBS = new javax.swing.JButton(); + chkEnableBlur = new javax.swing.JCheckBox(); cboDownloadSource.addItemListener(new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { @@ -235,6 +237,14 @@ public class LauncherSettingsPanel extends RepaintPage { } }); + java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("org/jackhuang/hellominecraft/lang/I18N"); // NOI18N + chkEnableBlur.setText(bundle.getString("launcher.enable_blur")); // NOI18N + chkEnableBlur.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + chkEnableBlurItemStateChanged(evt); + } + }); + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( @@ -287,6 +297,8 @@ public class LauncherSettingsPanel extends RepaintPage { .addGap(0, 0, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() .addComponent(chkEnableShadow) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(chkEnableBlur) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(chkDecorated))) .addContainerGap()) @@ -325,7 +337,8 @@ public class LauncherSettingsPanel extends RepaintPage { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(chkEnableShadow) - .addComponent(chkDecorated)) + .addComponent(chkDecorated) + .addComponent(chkEnableBlur)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnCheckUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) @@ -416,6 +429,10 @@ public class LauncherSettingsPanel extends RepaintPage { SwingUtils.openLink(C.URL_PUBLISH); }//GEN-LAST:event_btnMCBBSActionPerformed + private void chkEnableBlurItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkEnableBlurItemStateChanged + Settings.getInstance().setEnableBlur(chkEnableBlur.isSelected()); + }//GEN-LAST:event_chkEnableBlurItemStateChanged + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnCheckUpdate; private javax.swing.JButton btnMCBBS; @@ -424,6 +441,7 @@ public class LauncherSettingsPanel extends RepaintPage { private javax.swing.JComboBox cboLang; private javax.swing.JComboBox cboTheme; private javax.swing.JCheckBox chkDecorated; + private javax.swing.JCheckBox chkEnableBlur; private javax.swing.JCheckBox chkEnableShadow; private javax.swing.JLabel lblAbout; private javax.swing.JLabel lblBackground; diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/MainPagePanel.form b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/MainPagePanel.form index 3f2e3ff62..3dbd3d0f8 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/MainPagePanel.form +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/MainPagePanel.form @@ -285,4 +285,4 @@ - \ No newline at end of file + diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/MainPagePanel.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/MainPagePanel.java index 892f6fe05..03c019bee 100755 --- a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/MainPagePanel.java +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/MainPagePanel.java @@ -90,7 +90,8 @@ public class MainPagePanel extends GaussionPage { prepareAuths(); - addAeroObject(pnlMore); + if (Settings.getInstance().isEnableBlur()) + addAeroObject(pnlMore); setBackgroundImage(MainFrame.INSTANCE.background.getImage()); ((RepaintPage) pnlMore).setRepainter(this); diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/MyRepaintManager.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/MyRepaintManager.java new file mode 100644 index 000000000..5f4466508 --- /dev/null +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/MyRepaintManager.java @@ -0,0 +1,48 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui + * + * 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.launcher.ui; + +import java.awt.Container; +import java.awt.Rectangle; +import java.awt.Window; +import javax.swing.JComponent; +import javax.swing.RepaintManager; + +/** + * + * @author huangyuhui + */ +public class MyRepaintManager extends RepaintManager { + + @Override + public void addDirtyRegion(JComponent c, int x, int y, int w, int h) { + super.addDirtyRegion(c, x, y, w, h); + + for (Container parent = c.getParent(); (parent instanceof JComponent || parent instanceof Window) && parent.isVisible(); parent = parent.getParent()) { + if (parent instanceof IRepaint) { + IRepaint d = (IRepaint) parent; + for (Rectangle r : d.getRepaintRects()) { + if (d.getRepaintComponent() != null) + super.addDirtyRegion(d.getRepaintComponent(), r.x, r.y, r.width, r.height); + if (d.getRepaintWindow() != null) + super.addDirtyRegion(d.getRepaintWindow(), r.x, r.y, r.width, r.height); + } + } + } + } +} diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/RepaintPage.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/RepaintPage.java new file mode 100644 index 000000000..b8c8bd0be --- /dev/null +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/RepaintPage.java @@ -0,0 +1,56 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui + * + * 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.launcher.ui; + +import java.awt.Rectangle; +import java.awt.Window; +import java.util.Arrays; +import java.util.Collection; +import javax.swing.JComponent; + +/** + * + * @author huang + */ +public class RepaintPage extends Page implements IRepaint { + + public RepaintPage() { + super(); + } + + JComponent repainter; + + @Override + public JComponent getRepaintComponent() { + return repainter; + } + + public void setRepainter(JComponent repainter) { + this.repainter = repainter; + } + + @Override + public Collection getRepaintRects() { + return Arrays.asList(this.getBounds()); + } + + @Override + public Window getRepaintWindow() { + return null; + } +} diff --git a/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/WideComboBox.java b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/WideComboBox.java new file mode 100644 index 000000000..3eebbef7d --- /dev/null +++ b/HMCL/src/main/java/org/jackhuang/hellominecraft/launcher/ui/WideComboBox.java @@ -0,0 +1,52 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui + * + * 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.launcher.ui; + +import java.awt.Dimension; +import javax.swing.JComboBox; + +/** + * + * @author huang + */ +public class WideComboBox extends JComboBox { + + public WideComboBox() { + } + + private boolean layingOut = false; + public int customzedMinimumWidth = 300; + + @Override + public void doLayout() { + try { + layingOut = true; + super.doLayout(); + } finally { + layingOut = false; + } + } + + @Override + public Dimension getSize() { + Dimension dim = super.getSize(); + if (!layingOut) + dim.width = Math.max(dim.width, customzedMinimumWidth); + return dim; + } +} diff --git a/HMCUtils/src/main/java/org/jackhuang/hellominecraft/util/ui/AlwaysDirty.java b/HMCUtils/src/main/java/org/jackhuang/hellominecraft/util/ui/AlwaysDirty.java new file mode 100644 index 000000000..1e7f0ed92 --- /dev/null +++ b/HMCUtils/src/main/java/org/jackhuang/hellominecraft/util/ui/AlwaysDirty.java @@ -0,0 +1,26 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui + * + * 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.util.ui; + +/** + * + * @author huang + */ +public interface AlwaysDirty { + +} diff --git a/HMCUtils/src/main/java/org/jackhuang/hellominecraft/util/ui/JSystemFileChooser.java b/HMCUtils/src/main/java/org/jackhuang/hellominecraft/util/ui/JSystemFileChooser.java new file mode 100644 index 000000000..be74b8d71 --- /dev/null +++ b/HMCUtils/src/main/java/org/jackhuang/hellominecraft/util/ui/JSystemFileChooser.java @@ -0,0 +1,63 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui + * + * 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.util.ui; + +import java.awt.Color; +import java.io.File; +import javax.swing.JFileChooser; +import javax.swing.LookAndFeel; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + +/** + * + * @author huangyuhui + */ +public class JSystemFileChooser extends JFileChooser { + + public JSystemFileChooser() { + super(); + } + + public JSystemFileChooser(File f) { + super(f); + } + + @Override + public void updateUI() { + LookAndFeel old = UIManager.getLookAndFeel(); + try { + UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); + } catch (ClassNotFoundException | IllegalAccessException | InstantiationException | UnsupportedLookAndFeelException ignored) { + old = null; + } + + super.updateUI(); + + if (old != null) { + Color background = UIManager.getColor("Label.background"); + setBackground(background); + setOpaque(true); + + try { + UIManager.setLookAndFeel(old); + } catch (UnsupportedLookAndFeelException ignored) { + } + } + } +} diff --git a/HMCUtils/src/main/java/org/jackhuang/hellominecraft/util/ui/StackBlurFilter.java b/HMCUtils/src/main/java/org/jackhuang/hellominecraft/util/ui/StackBlurFilter.java new file mode 100644 index 000000000..4156f6b07 --- /dev/null +++ b/HMCUtils/src/main/java/org/jackhuang/hellominecraft/util/ui/StackBlurFilter.java @@ -0,0 +1,149 @@ +package org.jackhuang.hellominecraft.util.ui; + +/* + * Copyright (c) 2007, Romain Guy + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * * Neither the name of the TimingFramework project nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.awt.image.BufferedImage; + +/** + *

A stack blur filter can be used to create an approximation of a + * gaussian blur. The approximation is controlled by the number of times the + * {@link org.jdesktop.swingx.image.FastBlurFilter} is applied onto the source + * picture. The default number of iterations, 3, provides a decent compromise + * between speed and rendering quality.

+ *

The force of the blur can be controlled with a radius and the + * default radius is 3. Since the blur clamps values on the edges of the + * source picture, you might need to provide a picture with empty borders + * to avoid artifacts at the edges. The performance of this filter are + * independant from the radius.

+ * + * @author Romain Guy +*/ +public class StackBlurFilter extends AbstractFilter { + private final int radius; + private final int iterations; + + /** + *

Creates a new blur filter with a default radius of 3 and 3 iterations.

+ */ + public StackBlurFilter() { + this(3, 3); + } + + /** + *

Creates a new blur filter with the specified radius and 3 iterations. + * If the radius is lower than 1, a radius of 1 will be used automatically.

+ * + * @param radius the radius, in pixels, of the blur + */ + public StackBlurFilter(int radius) { + this(radius, 3); + } + + /** + *

Creates a new blur filter with the specified radius. If the radius + * is lower than 1, a radius of 1 will be used automatically. The number + * of iterations controls the approximation to a gaussian blur. If the + * number of iterations is lower than 1, one iteration will be used + * automatically.

+ * + * @param radius the radius, in pixels, of the blur + * @param iterations the number of iterations to approximate a gaussian blur + */ + public StackBlurFilter(int radius, int iterations) { + if (radius < 1) { + radius = 1; + } + if (iterations < 1) { + iterations = 1; + } + + this.radius = radius; + this.iterations = iterations; + } + + /** + *

Returns the effective radius of the stack blur. If the radius of the + * blur is 1 and the stack iterations count is 3, then the effective blur + * radius is 1 * 3 = 3.

+ * @return the number of iterations times the blur radius + */ + public int getEffectiveRadius() { + return getIterations() * getRadius(); + } + + /** + *

Returns the radius used by this filter, in pixels.

+ * + * @return the radius of the blur + */ + public int getRadius() { + return radius; + } + + /** + *

Returns the number of iterations used to approximate a gaussian + * blur.

+ * + * @return the number of iterations used by this blur + */ + public int getIterations() { + return iterations; + } + + /** + * {@inheritDoc} + */ + @Override + public BufferedImage filter(BufferedImage src, BufferedImage dst) { + int width = src.getWidth(); + int height = src.getHeight(); + + if (dst == null) { + dst = createCompatibleDestImage(src, null); + } + + int[] srcPixels = new int[width * height]; + int[] dstPixels = new int[width * height]; + + GraphicsUtils.getPixels(src, 0, 0, width, height, srcPixels); + for (int i = 0; i < iterations; i++) { + // horizontal pass + FastBlurFilter.blur(srcPixels, dstPixels, width, height, radius); + // vertical pass + FastBlurFilter.blur(dstPixels, srcPixels, height, width, radius); + } + // the result is now stored in srcPixels due to the 2nd pass + GraphicsUtils.setPixels(dst, 0, 0, width, height, srcPixels); + + return dst; + } +} diff --git a/HMCUtils/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/spi/AbstractWizard.java b/HMCUtils/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/spi/AbstractWizard.java new file mode 100644 index 000000000..0742dddf6 --- /dev/null +++ b/HMCUtils/src/main/java/org/jackhuang/hellominecraft/util/ui/wizard/spi/AbstractWizard.java @@ -0,0 +1,41 @@ +/* + * Hello Minecraft! Launcher. + * Copyright (C) 2013 huangyuhui + * + * 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.util.ui.wizard.spi; + +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import org.jackhuang.hellominecraft.util.func.Consumer; + +/** + * + * @author huang + */ +public abstract class AbstractWizard implements WizardImplementation { + + protected final List listenerList = Collections.synchronizedList(new LinkedList()); + + protected void fireChanged(Consumer r) { + WizardObserver[] listeners = (WizardObserver[]) listenerList.toArray(new WizardObserver[listenerList.size()]); + + for (int i = listeners.length - 1; i >= 0; i--) { + WizardObserver l = (WizardObserver) listeners[i]; + r.accept(l); + } + } +} diff --git a/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N.lang b/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N.lang index f87aaf988..834bf35bf 100755 --- a/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N.lang +++ b/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N.lang @@ -310,11 +310,12 @@ launcher.choose_bgpath=选择背景路径 launcher.background_tooltip=启动器默认使用自带的背景
如果当前目录有background.png,则会使用该文件作为背景
如果当前目录有bg子目录,则会随机使用里面的一张图作为背景
如果该背景地址被修改,则会使用背景地址里的一张图作为背景
背景地址允许有多个地址,使用半角分号";"(不包含双引号)分隔 launcher.update_launcher=检查更新 launcher.enable_shadow=启用窗口阴影 +launcher.enable_animation=启用动态效果 +launcher.enable_blur=启用主界面模糊 launcher.theme=主题 launcher.proxy=代理 launcher.decorated=启用窗口边框(Linux下可解决程序界面全灰问题) launcher.modpack=整合包作者帮助 -launcher.enable_animation=启用动态效果 launcher.lang=语言 launcher.restart=本界面选项需要重启本启动器生效 diff --git a/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N.properties b/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N.properties index a099179f4..f042c5bd9 100755 --- a/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N.properties +++ b/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N.properties @@ -310,11 +310,12 @@ launcher.choose_bgpath=\u9009\u62e9\u80cc\u666f\u8def\u5f84 launcher.background_tooltip=\u542f\u52a8\u5668\u9ed8\u8ba4\u4f7f\u7528\u81ea\u5e26\u7684\u80cc\u666f
\u5982\u679c\u5f53\u524d\u76ee\u5f55\u6709background.png\uff0c\u5219\u4f1a\u4f7f\u7528\u8be5\u6587\u4ef6\u4f5c\u4e3a\u80cc\u666f
\u5982\u679c\u5f53\u524d\u76ee\u5f55\u6709bg\u5b50\u76ee\u5f55\uff0c\u5219\u4f1a\u968f\u673a\u4f7f\u7528\u91cc\u9762\u7684\u4e00\u5f20\u56fe\u4f5c\u4e3a\u80cc\u666f
\u5982\u679c\u8be5\u80cc\u666f\u5730\u5740\u88ab\u4fee\u6539\uff0c\u5219\u4f1a\u4f7f\u7528\u80cc\u666f\u5730\u5740\u91cc\u7684\u4e00\u5f20\u56fe\u4f5c\u4e3a\u80cc\u666f
\u80cc\u666f\u5730\u5740\u5141\u8bb8\u6709\u591a\u4e2a\u5730\u5740\uff0c\u4f7f\u7528\u534a\u89d2\u5206\u53f7";"(\u4e0d\u5305\u542b\u53cc\u5f15\u53f7)\u5206\u9694 launcher.update_launcher=\u68c0\u67e5\u66f4\u65b0 launcher.enable_shadow=\u542f\u7528\u7a97\u53e3\u9634\u5f71 +launcher.enable_animation=\u542f\u7528\u52a8\u6001\u6548\u679c +launcher.enable_blur=\u542f\u7528\u4e3b\u754c\u9762\u6a21\u7cca launcher.theme=\u4e3b\u9898 launcher.proxy=\u4ee3\u7406 launcher.decorated=\u542f\u7528\u7a97\u53e3\u8fb9\u6846(Linux\u4e0b\u53ef\u89e3\u51b3\u7a0b\u5e8f\u754c\u9762\u5168\u7070\u95ee\u9898) launcher.modpack=\u6574\u5408\u5305\u4f5c\u8005\u5e2e\u52a9 -launcher.enable_animation=\u542f\u7528\u52a8\u6001\u6548\u679c launcher.lang=\u8bed\u8a00 launcher.restart=\u672c\u754c\u9762\u9009\u9879\u9700\u8981\u91cd\u542f\u672c\u542f\u52a8\u5668\u751f\u6548 diff --git a/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_en.lang b/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_en.lang index 14e9922a8..54fea93de 100755 --- a/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_en.lang +++ b/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_en.lang @@ -310,11 +310,12 @@ launcher.choose_bgpath=Choose background path. launcher.background_tooltip=This app uses the default background at first.
If there is background.png in the directory, it will be used.
If there is "bg" subdirectory, this app will chooses one picture in "bgskin" randomly.
If you set the background setting, this app will use it. launcher.update_launcher=Check for update launcher.enable_shadow=Enable Window Shadow +launcher.enable_animation=Enable Animation +launcher.enable_blur=Enable Blur launcher.theme=Theme launcher.proxy=Proxy launcher.decorated=Enable system window border(in order to fix the problem that the ui become all gray in Linux OS) launcher.modpack=Documentations for modpacks. -launcher.enable_animation=Enable Animation launcher.lang=Language launcher.restart=Options will be in operations only if restart this app. diff --git a/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_en.properties b/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_en.properties index 14e9922a8..54fea93de 100755 --- a/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_en.properties +++ b/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_en.properties @@ -310,11 +310,12 @@ launcher.choose_bgpath=Choose background path. launcher.background_tooltip=This app uses the default background at first.
If there is background.png in the directory, it will be used.
If there is "bg" subdirectory, this app will chooses one picture in "bgskin" randomly.
If you set the background setting, this app will use it. launcher.update_launcher=Check for update launcher.enable_shadow=Enable Window Shadow +launcher.enable_animation=Enable Animation +launcher.enable_blur=Enable Blur launcher.theme=Theme launcher.proxy=Proxy launcher.decorated=Enable system window border(in order to fix the problem that the ui become all gray in Linux OS) launcher.modpack=Documentations for modpacks. -launcher.enable_animation=Enable Animation launcher.lang=Language launcher.restart=Options will be in operations only if restart this app. diff --git a/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_zh_TW.lang b/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_zh_TW.lang index ac0ddf880..c308c276b 100755 --- a/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_zh_TW.lang +++ b/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_zh_TW.lang @@ -309,12 +309,13 @@ launcher.versions_json_not_formatted=版本%s信息資料格式错误,是否 launcher.choose_bgpath=選擇背景路徑 launcher.background_tooltip=啟動器默認使用自帶的背景
如果當前目錄有background.png,則會使用該資料作為背景
如果當前目錄有bg子目錄,則會隨機使用裡面的一張圖作為背景
如果該背景地址被修改,則會使用背景地址裡的一張圖作為背景
背景地址允許有多個地址,使用半角分號";"(不包含雙引號)分隔 launcher.update_launcher=检查更新 -launcher.enable_shadow=启用窗口阴影 +launcher.enable_shadow=啟用窗口陰影 +launcher.enable_animation=啟用動態效果 +launcher.enable_blur=啟用主界面模糊 launcher.theme=主题 launcher.proxy=代理 launcher.decorated=啟用窗口邊框(Linux下可解決程序界面全灰問題) launcher.modpack=整合包作者帮助 -launcher.enable_animation=啟用動態效果 launcher.lang=語言 launcher.restart=本界面選項需要重啟本啟動器生效 diff --git a/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_zh_TW.properties b/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_zh_TW.properties index a6c81f694..4e2e958e0 100755 --- a/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_zh_TW.properties +++ b/HMCUtils/src/main/resources/org/jackhuang/hellominecraft/lang/I18N_zh_TW.properties @@ -309,12 +309,13 @@ launcher.versions_json_not_formatted=\u7248\u672c%s\u4fe1\u606f\u8cc7\u6599\u683 launcher.choose_bgpath=\u9078\u64c7\u80cc\u666f\u8def\u5f91 launcher.background_tooltip=\u555f\u52d5\u5668\u9ed8\u8a8d\u4f7f\u7528\u81ea\u5e36\u7684\u80cc\u666f
\u5982\u679c\u7576\u524d\u76ee\u9304\u6709background.png\uff0c\u5247\u6703\u4f7f\u7528\u8a72\u8cc7\u6599\u4f5c\u70ba\u80cc\u666f
\u5982\u679c\u7576\u524d\u76ee\u9304\u6709bg\u5b50\u76ee\u9304\uff0c\u5247\u6703\u96a8\u6a5f\u4f7f\u7528\u88e1\u9762\u7684\u4e00\u5f35\u5716\u4f5c\u70ba\u80cc\u666f
\u5982\u679c\u8a72\u80cc\u666f\u5730\u5740\u88ab\u4fee\u6539\uff0c\u5247\u6703\u4f7f\u7528\u80cc\u666f\u5730\u5740\u88e1\u7684\u4e00\u5f35\u5716\u4f5c\u70ba\u80cc\u666f
\u80cc\u666f\u5730\u5740\u5141\u8a31\u6709\u591a\u500b\u5730\u5740\uff0c\u4f7f\u7528\u534a\u89d2\u5206\u865f";"(\u4e0d\u5305\u542b\u96d9\u5f15\u865f)\u5206\u9694 launcher.update_launcher=\u68c0\u67e5\u66f4\u65b0 -launcher.enable_shadow=\u542f\u7528\u7a97\u53e3\u9634\u5f71 +launcher.enable_shadow=\u555f\u7528\u7a97\u53e3\u9670\u5f71 +launcher.enable_animation=\u555f\u7528\u52d5\u614b\u6548\u679c +launcher.enable_blur=\u555f\u7528\u4e3b\u754c\u9762\u6a21\u7cca launcher.theme=\u4e3b\u9898 launcher.proxy=\u4ee3\u7406 launcher.decorated=\u555f\u7528\u7a97\u53e3\u908a\u6846(Linux\u4e0b\u53ef\u89e3\u6c7a\u7a0b\u5e8f\u754c\u9762\u5168\u7070\u554f\u984c) launcher.modpack=\u6574\u5408\u5305\u4f5c\u8005\u5e2e\u52a9 -launcher.enable_animation=\u555f\u7528\u52d5\u614b\u6548\u679c launcher.lang=\u8a9e\u8a00 launcher.restart=\u672c\u754c\u9762\u9078\u9805\u9700\u8981\u91cd\u555f\u672c\u555f\u52d5\u5668\u751f\u6548