From faa806fc9f8fb0ad0b50d9e3a2297e2613bd0188 Mon Sep 17 00:00:00 2001 From: huangyuhui Date: Sun, 11 Jun 2017 12:17:41 +0800 Subject: [PATCH] New console font options --- HMCL/build.gradle | 2 +- .../org/jackhuang/hmcl/setting/Config.java | 33 + .../hmcl/ui/LauncherSettingsPanel.form | 866 +++++++++++------- .../hmcl/ui/LauncherSettingsPanel.java | 524 +++++++---- .../java/org/jackhuang/hmcl/ui/LogWindow.java | 9 +- HMCLAPI/build.gradle | 2 +- HMCLCore/build.gradle | 2 +- .../org/jackhuang/hmcl/util/log/Level.java | 1 + .../jackhuang/hmcl/util/ui/JFontComboBox.java | 71 ++ .../org/jackhuang/hmcl/lang/I18N.lang | 1 + .../org/jackhuang/hmcl/lang/I18N.properties | 1 + .../org/jackhuang/hmcl/lang/I18N_vi.lang | 1 + .../jackhuang/hmcl/lang/I18N_vi.properties | 1 + .../org/jackhuang/hmcl/lang/I18N_zh.lang | 1 + .../jackhuang/hmcl/lang/I18N_zh.properties | 1 + .../org/jackhuang/hmcl/lang/I18N_zh_CN.lang | 1 + .../jackhuang/hmcl/lang/I18N_zh_CN.properties | 1 + HMCLaF/build.gradle | 2 +- build/kotlin-build/caches/version.txt | 1 + 19 files changed, 960 insertions(+), 561 deletions(-) create mode 100644 HMCLCore/src/main/java/org/jackhuang/hmcl/util/ui/JFontComboBox.java create mode 100644 build/kotlin-build/caches/version.txt diff --git a/HMCL/build.gradle b/HMCL/build.gradle index 6524be474..980b3ac86 100755 --- a/HMCL/build.gradle +++ b/HMCL/build.gradle @@ -27,7 +27,7 @@ plugins { id "edu.sc.seis.macAppBundle" version "2.1.6" id "me.tatarka.retrolambda" version "3.5.0" id 'edu.sc.seis.launch4j' version '2.3.0' - id "org.jetbrains.kotlin.jvm" version "1.1.2-2" + //id "org.jetbrains.kotlin.jvm" version "1.1.2-2" } if (!hasProperty('mainClass')) { diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java b/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java index 7dd722889..2e099895d 100755 --- a/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/setting/Config.java @@ -19,6 +19,7 @@ package org.jackhuang.hmcl.setting; import org.jackhuang.hmcl.core.download.DownloadType; import com.google.gson.annotations.SerializedName; +import java.awt.Font; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -81,6 +82,10 @@ public final class Config implements Cloneable { private TreeMap configurations; @SerializedName("auth") private Map auth; + @SerializedName("fontFamily") + private String fontFamily; + @SerializedName("fontSize") + private int fontSize; public List getJava() { return java == null ? java = new ArrayList<>() : java; @@ -224,6 +229,12 @@ public final class Config implements Cloneable { theme = LAFTheme.BLUE.id; decorated = OS.os() == OS.LINUX; auth = new HashMap<>(); + Font font = Font.decode("Consolas"); + if (font == null) + font = Font.decode("Monospace"); + if (font != null) + fontFamily = font.getFamily(); + fontSize = 12; commonpath = MCUtils.getLocation().getPath(); } @@ -271,6 +282,28 @@ public final class Config implements Cloneable { Settings.save(); } + public int getFontSize() { + return fontSize; + } + + public void setFontSize(int fontSize) { + this.fontSize = fontSize; + Settings.save(); + } + + public Font getConsoleFont() { + return Font.decode(fontFamily + "-" + fontSize); + } + + public String getFontFamily() { + return Font.decode(fontFamily).getFamily(); + } + + public void setFontFamily(String fontFamily) { + this.fontFamily = Font.decode(fontFamily).getFamily(); // avoid invalid font family + Settings.save(); + } + public String getLocalization() { return localization; } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LauncherSettingsPanel.form b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LauncherSettingsPanel.form index a48c14e64..4139c85a5 100755 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LauncherSettingsPanel.form +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LauncherSettingsPanel.form @@ -17,299 +17,30 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -323,23 +54,6 @@ - - - - - - - - - - - - - - - - - @@ -347,61 +61,513 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LauncherSettingsPanel.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LauncherSettingsPanel.java index ddaa1e9c3..0c2b9d2e8 100755 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LauncherSettingsPanel.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LauncherSettingsPanel.java @@ -17,6 +17,7 @@ */ package org.jackhuang.hmcl.ui; +import java.awt.Font; import java.io.IOException; import javax.swing.DefaultComboBoxModel; import javax.swing.filechooser.FileNameExtensionFilter; @@ -25,10 +26,13 @@ import org.jackhuang.hmcl.api.HMCLog; import org.jackhuang.hmcl.api.ui.Theme; import org.jackhuang.hmcl.setting.Settings; import org.jackhuang.hmcl.core.download.DownloadType; +import org.jackhuang.hmcl.util.MathUtils; import org.jackhuang.hmcl.util.sys.IOUtils; import org.jackhuang.hmcl.util.MessageBox; import org.jackhuang.hmcl.util.lang.SupportedLocales; +import org.jackhuang.hmcl.util.ui.JFontComboBox; import org.jackhuang.hmcl.util.ui.JSystemFileChooser; +import org.jackhuang.hmcl.util.ui.Page; import org.jackhuang.hmcl.util.ui.SwingUtils; /** @@ -72,6 +76,8 @@ public class LauncherSettingsPanel extends RepaintPage { txtProxyPort.setText(Settings.getInstance().getProxyPort()); txtProxyUsername.setText(Settings.getInstance().getProxyUserName()); txtProxyPassword.setText(Settings.getInstance().getProxyPassword()); + spinnerFontSize.setValue(Settings.getInstance().getFontSize()); + cboFontFamily.setSelectedItem(Settings.getInstance().getFontFamily()); cboDownloadSource.setSelectedIndex(Settings.getInstance().getDownloadType()); cboTheme.setSelectedItem(Settings.getInstance().getTheme()); chkEnableShadow.setSelected(Settings.getInstance().isEnableShadow()); @@ -95,127 +101,44 @@ public class LauncherSettingsPanel extends RepaintPage { // //GEN-BEGIN:initComponents private void initComponents() { - cboDownloadSource = new javax.swing.JComboBox(); - lblAbout = new javax.swing.JLabel(); - btnSelBackgroundPath = new javax.swing.JButton(); - lblBackground = new javax.swing.JLabel(); - txtBackgroundPath = new javax.swing.JTextField(); - lblDownloadSource = new javax.swing.JLabel(); - btnCheckUpdate = new javax.swing.JButton(); - chkEnableShadow = new javax.swing.JCheckBox(); - lblTheme = new javax.swing.JLabel(); - cboTheme = new javax.swing.JComboBox(); + lblModpack = new javax.swing.JLabel(); + lblRestart = new javax.swing.JLabel(); + tabLauncherSettings = new javax.swing.JTabbedPane(); + pnlGeneral = new Page().setAnimationEnabled(Settings.getInstance().isEnableAnimation()); lblProxy = new javax.swing.JLabel(); - txtProxyHost = new javax.swing.JTextField(); lblProxyHost = new javax.swing.JLabel(); - txtProxyPort = new javax.swing.JTextField(); + txtProxyHost = new javax.swing.JTextField(); lblProxyPort = new javax.swing.JLabel(); + txtProxyPort = new javax.swing.JTextField(); lblProxyUserName = new javax.swing.JLabel(); txtProxyUsername = new javax.swing.JTextField(); - txtProxyPassword = new javax.swing.JTextField(); lblProxyPassword = new javax.swing.JLabel(); - chkDecorated = new javax.swing.JCheckBox(); - lblModpack = new javax.swing.JLabel(); - cboLang = new javax.swing.JComboBox(); - lblLang = new javax.swing.JLabel(); - lblRestart = new javax.swing.JLabel(); - btnMCBBS = new javax.swing.JButton(); - chkEnableBlur = new javax.swing.JCheckBox(); - chkEnableAnimation = new javax.swing.JCheckBox(); + txtProxyPassword = new javax.swing.JTextField(); + cboDownloadSource = new javax.swing.JComboBox(); + lblDownloadSource = new javax.swing.JLabel(); lblCommonPath = new javax.swing.JLabel(); txtCommonPath = new javax.swing.JTextField(); btnSetCommonPath = new javax.swing.JButton(); - - cboDownloadSource.addItemListener(new java.awt.event.ItemListener() { - public void itemStateChanged(java.awt.event.ItemEvent evt) { - cboDownloadSourceItemStateChanged(evt); - } - }); - - lblAbout.setText(C.i18n("launcher.about")); // NOI18N - lblAbout.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); - - btnSelBackgroundPath.setText(C.i18n("ui.button.explore")); // NOI18N - btnSelBackgroundPath.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnSelBackgroundPathActionPerformed(evt); - } - }); - - lblBackground.setText(C.i18n("launcher.background_location")); // NOI18N - lblBackground.setToolTipText(""); - - txtBackgroundPath.setToolTipText(C.i18n("launcher.background_tooltip")); // NOI18N - txtBackgroundPath.addFocusListener(new java.awt.event.FocusAdapter() { - public void focusLost(java.awt.event.FocusEvent evt) { - txtBackgroundPathFocusLost(evt); - } - }); - - lblDownloadSource.setText(C.i18n("launcher.download_source")); // NOI18N - - btnCheckUpdate.setText(C.i18n("launcher.update_launcher")); // NOI18N - btnCheckUpdate.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnCheckUpdateActionPerformed(evt); - } - }); - - chkEnableShadow.setText(C.i18n("launcher.enable_shadow")); // NOI18N - chkEnableShadow.addItemListener(new java.awt.event.ItemListener() { - public void itemStateChanged(java.awt.event.ItemEvent evt) { - chkEnableShadowItemStateChanged(evt); - } - }); - - lblTheme.setText(C.i18n("launcher.theme")); // NOI18N - - cboTheme.addItemListener(new java.awt.event.ItemListener() { - public void itemStateChanged(java.awt.event.ItemEvent evt) { - cboThemeItemStateChanged(evt); - } - }); - - lblProxy.setText(C.i18n("launcher.proxy")); // NOI18N - - txtProxyHost.addFocusListener(new java.awt.event.FocusAdapter() { - public void focusLost(java.awt.event.FocusEvent evt) { - txtProxyHostFocusLost(evt); - } - }); - - lblProxyHost.setText(C.i18n("proxy.host")); // NOI18N - - txtProxyPort.addFocusListener(new java.awt.event.FocusAdapter() { - public void focusLost(java.awt.event.FocusEvent evt) { - txtProxyPortFocusLost(evt); - } - }); - - lblProxyPort.setText(C.i18n("proxy.port")); // NOI18N - - lblProxyUserName.setText(C.i18n("proxy.username")); // NOI18N - - txtProxyUsername.addFocusListener(new java.awt.event.FocusAdapter() { - public void focusLost(java.awt.event.FocusEvent evt) { - txtProxyUsernameFocusLost(evt); - } - }); - - txtProxyPassword.addFocusListener(new java.awt.event.FocusAdapter() { - public void focusLost(java.awt.event.FocusEvent evt) { - txtProxyPasswordFocusLost(evt); - } - }); - - lblProxyPassword.setText(C.i18n("proxy.password")); // NOI18N - - chkDecorated.setText(C.i18n("launcher.decorated")); // NOI18N - chkDecorated.addItemListener(new java.awt.event.ItemListener() { - public void itemStateChanged(java.awt.event.ItemEvent evt) { - chkDecoratedItemStateChanged(evt); - } - }); + btnCheckUpdate = new javax.swing.JButton(); + btnMCBBS = new javax.swing.JButton(); + cboLang = new javax.swing.JComboBox(); + lblLang = new javax.swing.JLabel(); + pnlUI = new Page().setAnimationEnabled(Settings.getInstance().isEnableAnimation()); + lblTheme = new javax.swing.JLabel(); + cboTheme = new javax.swing.JComboBox(); + lblBackground = new javax.swing.JLabel(); + txtBackgroundPath = new javax.swing.JTextField(); + chkEnableShadow = new javax.swing.JCheckBox(); + chkEnableBlur = new javax.swing.JCheckBox(); + chkEnableAnimation = new javax.swing.JCheckBox(); + chkDecorated = new javax.swing.JCheckBox(); + btnSelBackgroundPath = new javax.swing.JButton(); + cboFontFamily = new JFontComboBox(); + lblFont = new javax.swing.JLabel(); + spinnerFontSize = new javax.swing.JSpinner(); + lblExample = new javax.swing.JLabel(); + pnlAbout = new Page().setAnimationEnabled(Settings.getInstance().isEnableAnimation()); + lblAbout = new javax.swing.JLabel(); lblModpack.setText(C.i18n("launcher.modpack")); // NOI18N lblModpack.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR)); @@ -225,39 +148,50 @@ public class LauncherSettingsPanel extends RepaintPage { } }); - cboLang.setModel(new DefaultComboBoxModel(new String[]{C.i18n("color.blue"),C.i18n("color.green"),C.i18n("color.purple"),C.i18n("color.dark_blue"),C.i18n("color.orange"),C.i18n("color.red")})); - cboLang.addItemListener(new java.awt.event.ItemListener() { - public void itemStateChanged(java.awt.event.ItemEvent evt) { - cboLangItemStateChanged(evt); - } - }); - - lblLang.setText(C.i18n("launcher.lang")); // NOI18N - lblRestart.setText(C.i18n("launcher.restart")); // NOI18N - btnMCBBS.setText("MCBBS"); - btnMCBBS.setToolTipText(""); - btnMCBBS.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - btnMCBBSActionPerformed(evt); + lblProxy.setText(C.i18n("launcher.proxy")); // NOI18N + + lblProxyHost.setText(C.i18n("proxy.host")); // NOI18N + + txtProxyHost.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + txtProxyHostFocusLost(evt); } }); - chkEnableBlur.setText(C.i18n("launcher.enable_blur")); // NOI18N - chkEnableBlur.addItemListener(new java.awt.event.ItemListener() { - public void itemStateChanged(java.awt.event.ItemEvent evt) { - chkEnableBlurItemStateChanged(evt); + lblProxyPort.setText(C.i18n("proxy.port")); // NOI18N + + txtProxyPort.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + txtProxyPortFocusLost(evt); } }); - chkEnableAnimation.setText(C.i18n("launcher.enable_animation")); // NOI18N - chkEnableAnimation.addItemListener(new java.awt.event.ItemListener() { - public void itemStateChanged(java.awt.event.ItemEvent evt) { - chkEnableAnimationItemStateChanged(evt); + lblProxyUserName.setText(C.i18n("proxy.username")); // NOI18N + + txtProxyUsername.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + txtProxyUsernameFocusLost(evt); } }); + lblProxyPassword.setText(C.i18n("proxy.password")); // NOI18N + + txtProxyPassword.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + txtProxyPasswordFocusLost(evt); + } + }); + + cboDownloadSource.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + cboDownloadSourceItemStateChanged(evt); + } + }); + + lblDownloadSource.setText(C.i18n("launcher.download_source")); // NOI18N + lblCommonPath.setText(C.i18n("launcher.common_location")); // NOI18N txtCommonPath.setToolTipText(C.i18n("launcher.commpath_tooltip")); // NOI18N @@ -274,14 +208,43 @@ public class LauncherSettingsPanel extends RepaintPage { } }); - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() + btnCheckUpdate.setText(C.i18n("launcher.update_launcher")); // NOI18N + btnCheckUpdate.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCheckUpdateActionPerformed(evt); + } + }); + + btnMCBBS.setText("MCBBS"); + btnMCBBS.setToolTipText(""); + btnMCBBS.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnMCBBSActionPerformed(evt); + } + }); + + cboLang.setModel(new DefaultComboBoxModel(new String[]{C.i18n("color.blue"),C.i18n("color.green"),C.i18n("color.purple"),C.i18n("color.dark_blue"),C.i18n("color.orange"),C.i18n("color.red")})); + cboLang.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + cboLangItemStateChanged(evt); + } + }); + + lblLang.setText(C.i18n("launcher.lang")); // NOI18N + + javax.swing.GroupLayout pnlGeneralLayout = new javax.swing.GroupLayout(pnlGeneral); + pnlGeneral.setLayout(pnlGeneralLayout); + pnlGeneralLayout.setHorizontalGroup( + pnlGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnlGeneralLayout.createSequentialGroup() .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(pnlGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnlGeneralLayout.createSequentialGroup() + .addComponent(btnCheckUpdate) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(btnMCBBS) + .addGap(0, 418, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, pnlGeneralLayout.createSequentialGroup() .addComponent(lblProxy) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(lblProxyHost) @@ -299,72 +262,39 @@ public class LauncherSettingsPanel extends RepaintPage { .addComponent(lblProxyPassword) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(txtProxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(chkDecorated) - .addGroup(layout.createSequentialGroup() - .addComponent(chkEnableShadow) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(chkEnableBlur) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(chkEnableAnimation)) - .addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(layout.createSequentialGroup() - .addComponent(btnCheckUpdate) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(btnMCBBS)) - .addComponent(lblModpack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(lblRestart)) - .addGap(0, 0, Short.MAX_VALUE)) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnlGeneralLayout.createSequentialGroup() + .addGroup(pnlGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(lblDownloadSource) - .addComponent(lblTheme) - .addComponent(lblBackground) - .addComponent(lblLang) - .addComponent(lblCommonPath)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() + .addComponent(lblCommonPath) + .addComponent(lblLang)) + .addGap(28, 28, 28) + .addGroup(pnlGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(cboLang, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(pnlGeneralLayout.createSequentialGroup() .addComponent(txtCommonPath) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnSetCommonPath)) - .addComponent(cboLang, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(txtBackgroundPath, javax.swing.GroupLayout.DEFAULT_SIZE, 585, Short.MAX_VALUE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(btnSelBackgroundPath)) - .addComponent(cboDownloadSource, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(cboTheme, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + .addComponent(cboDownloadSource, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) .addContainerGap()) ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() + pnlGeneralLayout.setVerticalGroup( + pnlGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnlGeneralLayout.createSequentialGroup() .addContainerGap() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addGroup(pnlGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblCommonPath) .addComponent(txtCommonPath, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnSetCommonPath, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(lblBackground) - .addComponent(btnSelBackgroundPath, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(txtBackgroundPath, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addGroup(pnlGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(lblDownloadSource) .addComponent(cboDownloadSource, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(lblTheme) - .addComponent(cboTheme, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(pnlGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(cboLang, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblLang)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(lblLang) - .addComponent(cboLang, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addGroup(pnlGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtProxyHost, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblProxy) .addComponent(lblProxyHost) @@ -374,27 +304,199 @@ public class LauncherSettingsPanel extends RepaintPage { .addComponent(lblProxyUserName) .addComponent(txtProxyPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(lblProxyPassword)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 69, Short.MAX_VALUE) + .addGroup(pnlGeneralLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnCheckUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(btnMCBBS, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + tabLauncherSettings.addTab("General", pnlGeneral); + + lblTheme.setText(C.i18n("launcher.theme")); // NOI18N + + cboTheme.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + cboThemeItemStateChanged(evt); + } + }); + + lblBackground.setText(C.i18n("launcher.background_location")); // NOI18N + lblBackground.setToolTipText(""); + + txtBackgroundPath.setToolTipText(C.i18n("launcher.background_tooltip")); // NOI18N + txtBackgroundPath.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusLost(java.awt.event.FocusEvent evt) { + txtBackgroundPathFocusLost(evt); + } + }); + + chkEnableShadow.setText(C.i18n("launcher.enable_shadow")); // NOI18N + chkEnableShadow.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + chkEnableShadowItemStateChanged(evt); + } + }); + + chkEnableBlur.setText(C.i18n("launcher.enable_blur")); // NOI18N + chkEnableBlur.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + chkEnableBlurItemStateChanged(evt); + } + }); + + chkEnableAnimation.setText(C.i18n("launcher.enable_animation")); // NOI18N + chkEnableAnimation.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + chkEnableAnimationItemStateChanged(evt); + } + }); + + chkDecorated.setText(C.i18n("launcher.decorated")); // NOI18N + chkDecorated.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + chkDecoratedItemStateChanged(evt); + } + }); + + btnSelBackgroundPath.setText(C.i18n("ui.button.explore")); // NOI18N + btnSelBackgroundPath.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnSelBackgroundPathActionPerformed(evt); + } + }); + + cboFontFamily.addItemListener(new java.awt.event.ItemListener() { + public void itemStateChanged(java.awt.event.ItemEvent evt) { + cboFontFamilyItemStateChanged(evt); + } + }); + + lblFont.setText(C.i18n("launcher.log_font")); // NOI18N + + spinnerFontSize.addChangeListener(new javax.swing.event.ChangeListener() { + public void stateChanged(javax.swing.event.ChangeEvent evt) { + spinnerFontSizeStateChanged(evt); + } + }); + + lblExample.setText("19:10:10 [Client Thread/INFO]: Example"); + + javax.swing.GroupLayout pnlUILayout = new javax.swing.GroupLayout(pnlUI); + pnlUI.setLayout(pnlUILayout); + pnlUILayout.setHorizontalGroup( + pnlUILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnlUILayout.createSequentialGroup() + .addContainerGap() + .addGroup(pnlUILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnlUILayout.createSequentialGroup() + .addGroup(pnlUILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(chkDecorated) + .addGroup(pnlUILayout.createSequentialGroup() + .addComponent(chkEnableShadow) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(chkEnableBlur) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(chkEnableAnimation))) + .addGap(0, 15, Short.MAX_VALUE)) + .addGroup(pnlUILayout.createSequentialGroup() + .addGroup(pnlUILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(lblBackground) + .addComponent(lblFont) + .addComponent(lblTheme)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(pnlUILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(cboTheme, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(pnlUILayout.createSequentialGroup() + .addGroup(pnlUILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtBackgroundPath) + .addComponent(cboFontFamily, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(pnlUILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(btnSelBackgroundPath, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(spinnerFontSize))) + .addGroup(pnlUILayout.createSequentialGroup() + .addComponent(lblExample) + .addGap(0, 0, Short.MAX_VALUE))))) + .addContainerGap()) + ); + pnlUILayout.setVerticalGroup( + pnlUILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnlUILayout.createSequentialGroup() + .addContainerGap() + .addGroup(pnlUILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(lblBackground) + .addComponent(txtBackgroundPath, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(btnSelBackgroundPath, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addGroup(pnlUILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(cboFontFamily, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblFont) + .addComponent(spinnerFontSize, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(lblExample) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(pnlUILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(cboTheme, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblTheme)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 63, Short.MAX_VALUE) + .addGroup(pnlUILayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(chkEnableShadow) .addComponent(chkEnableBlur) .addComponent(chkEnableAnimation)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(chkDecorated) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) - .addComponent(btnCheckUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGroup(layout.createSequentialGroup() - .addComponent(btnMCBBS, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE) - .addGap(1, 1, 1))) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(lblRestart) + .addContainerGap()) + ); + + tabLauncherSettings.addTab("UI", pnlUI); + + lblAbout.setText(C.i18n("launcher.about")); // NOI18N + lblAbout.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + + javax.swing.GroupLayout pnlAboutLayout = new javax.swing.GroupLayout(pnlAbout); + pnlAbout.setLayout(pnlAboutLayout); + pnlAboutLayout.setHorizontalGroup( + pnlAboutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnlAboutLayout.createSequentialGroup() + .addContainerGap() + .addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(104, Short.MAX_VALUE)) + ); + pnlAboutLayout.setVerticalGroup( + pnlAboutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(pnlAboutLayout.createSequentialGroup() + .addContainerGap() + .addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + tabLauncherSettings.addTab("About", pnlAbout); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(10, 10, 10) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(lblModpack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblRestart)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addComponent(tabLauncherSettings) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(tabLauncherSettings) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(lblModpack, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(lblAbout, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(lblRestart) .addContainerGap()) ); + + tabLauncherSettings.getAccessibleContext().setAccessibleName("General"); }// //GEN-END:initComponents private void cboDownloadSourceItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboDownloadSourceItemStateChanged @@ -501,12 +603,23 @@ public class LauncherSettingsPanel extends RepaintPage { Settings.getInstance().setCommonpath(txtCommonPath.getText()); }//GEN-LAST:event_txtCommonPathFocusLost + private void cboFontFamilyItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboFontFamilyItemStateChanged + Settings.getInstance().setFontFamily(evt.getItem().toString()); + lblExample.setFont(Settings.getInstance().getConsoleFont()); + }//GEN-LAST:event_cboFontFamilyItemStateChanged + + private void spinnerFontSizeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerFontSizeStateChanged + Settings.getInstance().setFontSize(MathUtils.parseInt(spinnerFontSize.getValue().toString(), 12)); + lblExample.setFont(Settings.getInstance().getConsoleFont()); + }//GEN-LAST:event_spinnerFontSizeStateChanged + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnCheckUpdate; private javax.swing.JButton btnMCBBS; private javax.swing.JButton btnSelBackgroundPath; private javax.swing.JButton btnSetCommonPath; private javax.swing.JComboBox cboDownloadSource; + private javax.swing.JComboBox cboFontFamily; private javax.swing.JComboBox cboLang; private javax.swing.JComboBox cboTheme; private javax.swing.JCheckBox chkDecorated; @@ -517,6 +630,8 @@ public class LauncherSettingsPanel extends RepaintPage { private javax.swing.JLabel lblBackground; private javax.swing.JLabel lblCommonPath; private javax.swing.JLabel lblDownloadSource; + private javax.swing.JLabel lblExample; + private javax.swing.JLabel lblFont; private javax.swing.JLabel lblLang; private javax.swing.JLabel lblModpack; private javax.swing.JLabel lblProxy; @@ -526,6 +641,11 @@ public class LauncherSettingsPanel extends RepaintPage { private javax.swing.JLabel lblProxyUserName; private javax.swing.JLabel lblRestart; private javax.swing.JLabel lblTheme; + private javax.swing.JPanel pnlAbout; + private javax.swing.JPanel pnlGeneral; + private javax.swing.JPanel pnlUI; + private javax.swing.JSpinner spinnerFontSize; + private javax.swing.JTabbedPane tabLauncherSettings; private javax.swing.JTextField txtBackgroundPath; private javax.swing.JTextField txtCommonPath; private javax.swing.JTextField txtProxyHost; diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LogWindow.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LogWindow.java index 0f0cb0d00..b10d18de4 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/LogWindow.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/LogWindow.java @@ -27,6 +27,7 @@ import org.jackhuang.hmcl.util.C; import org.jackhuang.hmcl.api.HMCLog; import org.jackhuang.hmcl.util.log.Level; import org.jackhuang.hmcl.api.func.NonFunction; +import org.jackhuang.hmcl.setting.Settings; import org.jackhuang.hmcl.util.DoubleOutputStream; import org.jackhuang.hmcl.util.Utils; import org.jackhuang.hmcl.util.sys.ProcessMonitor; @@ -54,11 +55,7 @@ public class LogWindow extends javax.swing.JFrame { SwingUtilities.invokeLater(() -> { setLocationRelativeTo(null); txtLog.setEditable(false); - Font font = Font.decode("Consolas"); - if (font == null) - font = Font.decode("Monospace"); - if (font != null) - txtLog.setFont(font); + txtLog.setFont(Settings.getInstance().getConsoleFont()); }); } @@ -271,6 +268,7 @@ public class LogWindow extends javax.swing.JFrame { @Override public void setVisible(boolean b) { + txtLog.setFont(Settings.getInstance().getConsoleFont()); lblCrash.setVisible(false); btnMCBBS.setVisible(false); btnTieBa.setVisible(false); @@ -279,6 +277,7 @@ public class LogWindow extends javax.swing.JFrame { } public void showAsCrashWindow(boolean out_date) { + txtLog.setFont(Settings.getInstance().getConsoleFont()); if (out_date) { lblCrash.setVisible(false); btnMCBBS.setVisible(false); diff --git a/HMCLAPI/build.gradle b/HMCLAPI/build.gradle index 0bb8722bb..ec9ac0aa8 100644 --- a/HMCLAPI/build.gradle +++ b/HMCLAPI/build.gradle @@ -18,7 +18,7 @@ plugins { id "me.tatarka.retrolambda" version "3.5.0" - id "org.jetbrains.kotlin.jvm" version "1.1.2-2" + //id "org.jetbrains.kotlin.jvm" version "1.1.2-2" } if (System.getenv("BUILD_NUMBER") != null) diff --git a/HMCLCore/build.gradle b/HMCLCore/build.gradle index 3f0ed1261..3e1232c78 100644 --- a/HMCLCore/build.gradle +++ b/HMCLCore/build.gradle @@ -18,7 +18,7 @@ plugins { id "me.tatarka.retrolambda" version "3.5.0" - id "org.jetbrains.kotlin.jvm" version "1.1.2-2" + //id "org.jetbrains.kotlin.jvm" version "1.1.2-2" } if (System.getenv("BUILD_NUMBER") != null) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/log/Level.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/log/Level.java index ebec9b1d6..6ea731135 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/log/Level.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/log/Level.java @@ -51,6 +51,7 @@ public enum Level { public static final String JAVA_SYMBOL = "([a-zA-Z_$][a-zA-Z\\d_$]*\\.)+[a-zA-Z_$][a-zA-Z\\d_$]*"; public static Level guessLevel(String line, Level preLevel) { + if (line.startsWith("MC:")) line = line.substring("MC:".length()); Level level = preLevel; Matcher m = MINECRAFT_LOGGER.matcher(line); if (m.find()) { diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/ui/JFontComboBox.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/ui/JFontComboBox.java new file mode 100644 index 000000000..12fb051b3 --- /dev/null +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/ui/JFontComboBox.java @@ -0,0 +1,71 @@ +/* + * 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.hmcl.util.ui; + +import java.awt.Component; +import java.awt.Font; +import java.awt.GraphicsEnvironment; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JList; +import javax.swing.ListCellRenderer; + +/** + * + * @author huang + */ +public class JFontComboBox extends JComboBox implements ItemListener { + private static DefaultComboBoxModel defaultModel = null; + private int fontSize; + + protected static DefaultComboBoxModel getDefaultModel() { + if (defaultModel == null) + defaultModel = new DefaultComboBoxModel<>(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()); + return defaultModel; + } + + public JFontComboBox() { + super(); + setRenderer(new JFontComboBoxCellRenderer()); + setModel(getDefaultModel()); + addItemListener(this); + fontSize = getFont().getSize(); + } + + @Override + public void itemStateChanged(ItemEvent e) { + setFont(new Font(e.getItem().toString(), Font.PLAIN, fontSize)); + } + + public static class JFontComboBoxCellRenderer extends JLabel implements ListCellRenderer { + + @Override + public Component getListCellRendererComponent(JList list, String value, int index, boolean isSelected, boolean cellHasFocus) { + Font font = new Font(value, Font.PLAIN, 14); + setEnabled(list.isEnabled()); + setText(font.getFontName()); + setFont(font); + return this; + } + + } + +} diff --git a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N.lang b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N.lang index 2625904fe..810dc4935 100644 --- a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N.lang +++ b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N.lang @@ -330,6 +330,7 @@ launcher.decorated=Enable system window border(in order to fix the problem that launcher.modpack=Documentations for modpacks. launcher.lang=Language launcher.restart=Options will be in operations only if restart this app. +launcher.log_font=Log Font launcher.title.game=Games launcher.title.main=Home diff --git a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N.properties b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N.properties index 08c7d3141..1fc5514b6 100644 --- a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N.properties +++ b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N.properties @@ -330,6 +330,7 @@ launcher.decorated=Enable system window border(in order to fix the problem that launcher.modpack=Documentations for modpacks. launcher.lang=Language launcher.restart=Options will be in operations only if restart this app. +launcher.log_font=Log Font launcher.title.game=Games launcher.title.main=Home diff --git a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_vi.lang b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_vi.lang index d89d19a11..0b3c9c981 100644 --- a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_vi.lang +++ b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_vi.lang @@ -328,6 +328,7 @@ launcher.decorated=Enable system window border(in order to fix the problem that launcher.modpack=Documentations for modpacks. launcher.lang=Language launcher.restart=Options will be in operations only if restart this app. +launcher.log_font=Log Font launcher.title.game=Phiên bản & Mods launcher.title.main=HMCL Main diff --git a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_vi.properties b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_vi.properties index 840b5efb7..c2345ce68 100644 --- a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_vi.properties +++ b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_vi.properties @@ -328,6 +328,7 @@ launcher.decorated=Enable system window border(in order to fix the problem that launcher.modpack=Documentations for modpacks. launcher.lang=Language launcher.restart=Options will be in operations only if restart this app. +launcher.log_font=Log Font launcher.title.game=Phi\u00ean b\u1ea3n & Mods launcher.title.main=HMCL Main diff --git a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh.lang b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh.lang index 69b2a4ed6..8c212e9fb 100644 --- a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh.lang +++ b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh.lang @@ -330,6 +330,7 @@ launcher.decorated=啟用視窗邊框(Linux下可解決程式介面全灰問題) launcher.modpack=整合包作者幫助 launcher.lang=語言 launcher.restart=本介面選項需要重啟本啟動器生效 +launcher.log_font=日誌字體 launcher.title.game=遊戲設定 launcher.title.main=主頁 diff --git a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh.properties b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh.properties index b64cc302c..3325a368f 100644 --- a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh.properties +++ b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh.properties @@ -330,6 +330,7 @@ launcher.decorated=\u555f\u7528\u8996\u7a97\u908a\u6846(Linux\u4e0b\u53ef\u89e3\ launcher.modpack=\u6574\u5408\u5305\u4f5c\u8005\u5e6b\u52a9 launcher.lang=\u8a9e\u8a00 launcher.restart=\u672c\u4ecb\u9762\u9078\u9805\u9700\u8981\u91cd\u555f\u672c\u555f\u52d5\u5668\u751f\u6548 +launcher.log_font=\u65e5\u8a8c\u5b57\u9ad4 launcher.title.game=\u904a\u6232\u8a2d\u5b9a launcher.title.main=\u4e3b\u9801 diff --git a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh_CN.lang b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh_CN.lang index 2b281258d..278c26421 100644 --- a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh_CN.lang +++ b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh_CN.lang @@ -330,6 +330,7 @@ launcher.decorated=启用窗口边框(Linux下可解决程序界面全灰问题) launcher.modpack=整合包作者帮助 launcher.lang=语言 launcher.restart=本界面选项需要重启本启动器生效 +launcher.log_font=日志字体 launcher.title.game=游戏设置 launcher.title.main=主页 diff --git a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh_CN.properties b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh_CN.properties index 5cb371277..844022995 100644 --- a/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh_CN.properties +++ b/HMCLCore/src/main/resources/org/jackhuang/hmcl/lang/I18N_zh_CN.properties @@ -330,6 +330,7 @@ launcher.decorated=\u542f\u7528\u7a97\u53e3\u8fb9\u6846(Linux\u4e0b\u53ef\u89e3\ launcher.modpack=\u6574\u5408\u5305\u4f5c\u8005\u5e2e\u52a9 launcher.lang=\u8bed\u8a00 launcher.restart=\u672c\u754c\u9762\u9009\u9879\u9700\u8981\u91cd\u542f\u672c\u542f\u52a8\u5668\u751f\u6548 +launcher.log_font=\u65e5\u5fd7\u5b57\u4f53 launcher.title.game=\u6e38\u620f\u8bbe\u7f6e launcher.title.main=\u4e3b\u9875 diff --git a/HMCLaF/build.gradle b/HMCLaF/build.gradle index a7a27dc46..b0510b21f 100755 --- a/HMCLaF/build.gradle +++ b/HMCLaF/build.gradle @@ -18,7 +18,7 @@ plugins { id "me.tatarka.retrolambda" version "3.5.0" - id "org.jetbrains.kotlin.jvm" version "1.1.2-2" + //id "org.jetbrains.kotlin.jvm" version "1.1.2-2" } if (System.getenv("BUILD_NUMBER") != null) diff --git a/build/kotlin-build/caches/version.txt b/build/kotlin-build/caches/version.txt new file mode 100644 index 000000000..01aabacbf --- /dev/null +++ b/build/kotlin-build/caches/version.txt @@ -0,0 +1 @@ +11001 \ No newline at end of file