mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-18 16:26:05 -04:00
Settings.s() -> Settings.getInstance()
This commit is contained in:
parent
fb7bbbcaaf
commit
bee81fd6d9
@ -1,3 +1,8 @@
|
|||||||
|
|
||||||
|
import java.util.jar.JarOutputStream
|
||||||
|
import java.util.zip.ZipEntry
|
||||||
|
import java.util.zip.ZipFile
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
* Copyright 2013 huangyuhui <huanghongxun2008@126.com>
|
||||||
*
|
*
|
||||||
@ -86,6 +91,28 @@ task proguard(type: proguard.gradle.ProGuardTask, dependsOn: jar) {
|
|||||||
configuration 'proguard.pro'
|
configuration 'proguard.pro'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task makeExecutable(dependsOn: jar) {
|
||||||
|
ext {
|
||||||
|
def re = jar.classifier
|
||||||
|
injar = jar.archivePath
|
||||||
|
jar.classifier = ''
|
||||||
|
outjar = jar.archivePath
|
||||||
|
jar.classifier = re
|
||||||
|
}
|
||||||
|
def fos = new FileOutputStream(outjar)
|
||||||
|
def is = new FileInputStream('')
|
||||||
|
def read
|
||||||
|
def bytes = new byte[8192]
|
||||||
|
while((read = is.read(bytes)) != -1)
|
||||||
|
fos.write(bytes, 0, read);
|
||||||
|
is.close()
|
||||||
|
is = new FileInputStream(injar)
|
||||||
|
while((read = is.read(bytes)) != -1)
|
||||||
|
fos.write(bytes, 0, read);
|
||||||
|
is.close()
|
||||||
|
fos.close()
|
||||||
|
}
|
||||||
|
|
||||||
launch4j {
|
launch4j {
|
||||||
launch4jCmd = 'D:\\Develop\\Java\\Launch4j\\launch4j.exe'
|
launch4jCmd = 'D:\\Develop\\Java\\Launch4j\\launch4j.exe'
|
||||||
supportUrl = 'http://www.mcbbs.net/thread-142335-1-1.html'
|
supportUrl = 'http://www.mcbbs.net/thread-142335-1-1.html'
|
||||||
@ -108,4 +135,5 @@ processResources {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
build.dependsOn proguard
|
//build.dependsOn proguard
|
||||||
|
build.dependsOn makeExecutable
|
@ -102,14 +102,14 @@ public final class Main implements DoneListener0 {
|
|||||||
|
|
||||||
Settings.UPDATE_CHECKER.start();
|
Settings.UPDATE_CHECKER.start();
|
||||||
|
|
||||||
if (StrUtils.isNotBlank(Settings.s().getProxyHost()) && StrUtils.isNotBlank(Settings.s().getProxyPort())) {
|
if (StrUtils.isNotBlank(Settings.getInstance().getProxyHost()) && StrUtils.isNotBlank(Settings.getInstance().getProxyPort())) {
|
||||||
System.setProperty("http.proxyHost", Settings.s().getProxyHost());
|
System.setProperty("http.proxyHost", Settings.getInstance().getProxyHost());
|
||||||
System.setProperty("http.proxyPort", Settings.s().getProxyPort());
|
System.setProperty("http.proxyPort", Settings.getInstance().getProxyPort());
|
||||||
if (StrUtils.isNotBlank(Settings.s().getProxyUserName()) && StrUtils.isNotBlank(Settings.s().getProxyPassword()))
|
if (StrUtils.isNotBlank(Settings.getInstance().getProxyUserName()) && StrUtils.isNotBlank(Settings.getInstance().getProxyPassword()))
|
||||||
Authenticator.setDefault(new Authenticator() {
|
Authenticator.setDefault(new Authenticator() {
|
||||||
@Override
|
@Override
|
||||||
protected PasswordAuthentication getPasswordAuthentication() {
|
protected PasswordAuthentication getPasswordAuthentication() {
|
||||||
return new PasswordAuthentication(Settings.s().getProxyUserName(), Settings.s().getProxyPassword().toCharArray());
|
return new PasswordAuthentication(Settings.getInstance().getProxyUserName(), Settings.getInstance().getProxyPassword().toCharArray());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -137,11 +137,11 @@ public final class Main implements DoneListener0 {
|
|||||||
MessageBox.Show(C.i18n("update.no_browser"));
|
MessageBox.Show(C.i18n("update.no_browser"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Settings.s().setCheckUpdate(false);
|
Settings.getInstance().setCheckUpdate(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void invokeUpdate() {
|
public static void invokeUpdate() {
|
||||||
if (Settings.s().isCheckUpdate()) update();
|
if (Settings.getInstance().isCheckUpdate()) update();
|
||||||
MainFrame.instance.invokeUpdate();
|
MainFrame.instance.invokeUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class AssetsMojangLoader extends IAssetsHandler {
|
|||||||
File assets = mp.getAssets();
|
File assets = mp.getAssets();
|
||||||
HMCLog.log("Get index: " + assetsId);
|
HMCLog.log("Get index: " + assetsId);
|
||||||
File f = IOUtils.tryGetCanonicalFile(new File(assets, "indexes/" + assetsId + ".json"));
|
File f = IOUtils.tryGetCanonicalFile(new File(assets, "indexes/" + assetsId + ".json"));
|
||||||
if (!f.exists() && !MCUtils.downloadMinecraftAssetsIndex(assets, assetsId, Settings.s().getDownloadSource())) {
|
if (!f.exists() && !MCUtils.downloadMinecraftAssetsIndex(assets, assetsId, Settings.getInstance().getDownloadSource())) {
|
||||||
dl.accept(null);
|
dl.accept(null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -35,21 +35,17 @@ public abstract class IAuthenticator {
|
|||||||
public static final List<IAuthenticator> logins;
|
public static final List<IAuthenticator> logins;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
String clientToken = Settings.s().getClientToken();
|
String clientToken = Settings.getInstance().getClientToken();
|
||||||
logins = new ArrayList<>();
|
logins = new ArrayList<>();
|
||||||
logins.add(offlineLogin = new OfflineAuthenticator(clientToken));
|
logins.add(offlineLogin = new OfflineAuthenticator(clientToken));
|
||||||
logins.add(yggdrasilLogin = new YggdrasilAuthenticator(clientToken));
|
logins.add(yggdrasilLogin = new YggdrasilAuthenticator(clientToken));
|
||||||
logins.add(skinmeLogin = new SkinmeAuthenticator(clientToken));
|
logins.add(skinmeLogin = new SkinmeAuthenticator(clientToken));
|
||||||
//logins.add(bestLogin = new BestLogin(clientToken));
|
//logins.add(bestLogin = new BestLogin(clientToken));
|
||||||
yggdrasilLogin.onLoadSettings(Settings.s().getYggdrasilConfig());
|
yggdrasilLogin.onLoadSettings(Settings.getInstance().getYggdrasilConfig());
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
Runtime.getRuntime().addShutdownHook(new Thread(() ->
|
||||||
|
Settings.getInstance().setYggdrasilConfig(yggdrasilLogin.onSaveSettings())
|
||||||
@Override
|
));
|
||||||
public void run() {
|
|
||||||
Settings.s().setYggdrasilConfig(yggdrasilLogin.onSaveSettings());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String clientToken;
|
protected String clientToken;
|
||||||
|
@ -66,7 +66,7 @@ public class ForgeInstaller extends Task {
|
|||||||
File from = new File(gameDir, "versions" + File.separator + profile.install.minecraft);
|
File from = new File(gameDir, "versions" + File.separator + profile.install.minecraft);
|
||||||
if(!from.exists()) {
|
if(!from.exists()) {
|
||||||
if(MessageBox.Show(C.i18n("install.no_version_if_intall")) == MessageBox.YES_OPTION) {
|
if(MessageBox.Show(C.i18n("install.no_version_if_intall")) == MessageBox.YES_OPTION) {
|
||||||
if(!mp.install(profile.install.minecraft, Settings.s().getDownloadSource())) {
|
if(!mp.install(profile.install.minecraft, Settings.getInstance().getDownloadSource())) {
|
||||||
setFailReason(new RuntimeException(C.i18n("install.no_version")));
|
setFailReason(new RuntimeException(C.i18n("install.no_version")));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -44,7 +44,7 @@ public final class Settings {
|
|||||||
private static final Config settings;
|
private static final Config settings;
|
||||||
public static final UpdateChecker UPDATE_CHECKER;
|
public static final UpdateChecker UPDATE_CHECKER;
|
||||||
|
|
||||||
public static Config s() {
|
public static Config getInstance() {
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,14 +193,14 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean refreshJson(String id) {
|
public boolean refreshJson(String id) {
|
||||||
return MCUtils.downloadMinecraftVersionJson(baseFolder, id, Settings.s().getDownloadSource());
|
return MCUtils.downloadMinecraftVersionJson(baseFolder, id, Settings.getInstance().getDownloadSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean refreshAssetsIndex(String id) {
|
public boolean refreshAssetsIndex(String id) {
|
||||||
MinecraftVersion mv = getVersionById(id);
|
MinecraftVersion mv = getVersionById(id);
|
||||||
if (mv == null) return false;
|
if (mv == null) return false;
|
||||||
return MCUtils.downloadMinecraftAssetsIndex(new File(baseFolder, "assets"), mv.assets, Settings.s().getDownloadSource());
|
return MCUtils.downloadMinecraftAssetsIndex(new File(baseFolder, "assets"), mv.assets, Settings.getInstance().getDownloadSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -226,7 +226,7 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
|||||||
@Override
|
@Override
|
||||||
public List<GameLauncher.DownloadLibraryJob> getDownloadLibraries(DownloadType downloadType) {
|
public List<GameLauncher.DownloadLibraryJob> getDownloadLibraries(DownloadType downloadType) {
|
||||||
ArrayList<DownloadLibraryJob> downloadLibraries = new ArrayList<>();
|
ArrayList<DownloadLibraryJob> downloadLibraries = new ArrayList<>();
|
||||||
MinecraftVersion v = profile.getSelectedMinecraftVersion().resolve(this, Settings.s().getDownloadSource());
|
MinecraftVersion v = profile.getSelectedMinecraftVersion().resolve(this, Settings.getInstance().getDownloadSource());
|
||||||
for (IMinecraftLibrary l : v.libraries) {
|
for (IMinecraftLibrary l : v.libraries) {
|
||||||
l.init();
|
l.init();
|
||||||
if (l.allow()) {
|
if (l.allow()) {
|
||||||
@ -259,7 +259,7 @@ public final class MinecraftVersionManager extends IMinecraftProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameLauncher.DecompressLibraryJob getDecompressLibraries() {
|
public GameLauncher.DecompressLibraryJob getDecompressLibraries() {
|
||||||
MinecraftVersion v = profile.getSelectedMinecraftVersion().resolve(this, Settings.s().getDownloadSource());
|
MinecraftVersion v = profile.getSelectedMinecraftVersion().resolve(this, Settings.getInstance().getDownloadSource());
|
||||||
ArrayList<File> unzippings = new ArrayList<>();
|
ArrayList<File> unzippings = new ArrayList<>();
|
||||||
ArrayList<String[]> extractRules = new ArrayList<>();
|
ArrayList<String[]> extractRules = new ArrayList<>();
|
||||||
for (IMinecraftLibrary l : v.libraries) {
|
for (IMinecraftLibrary l : v.libraries) {
|
||||||
|
@ -1020,12 +1020,12 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
|||||||
}//GEN-LAST:event_btnRetryLiteLoaderActionPerformed
|
}//GEN-LAST:event_btnRetryLiteLoaderActionPerformed
|
||||||
|
|
||||||
private void btnDownloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadActionPerformed
|
private void btnDownloadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadActionPerformed
|
||||||
downloadMinecraft(Settings.s().getDownloadSource());
|
downloadMinecraft(Settings.getInstance().getDownloadSource());
|
||||||
refreshVersions();
|
refreshVersions();
|
||||||
}//GEN-LAST:event_btnDownloadActionPerformed
|
}//GEN-LAST:event_btnDownloadActionPerformed
|
||||||
|
|
||||||
private void btnRefreshGameDownloadsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshGameDownloadsActionPerformed
|
private void btnRefreshGameDownloadsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRefreshGameDownloadsActionPerformed
|
||||||
refreshDownloads(Settings.s().getDownloadSource());
|
refreshDownloads(Settings.getInstance().getDownloadSource());
|
||||||
}//GEN-LAST:event_btnRefreshGameDownloadsActionPerformed
|
}//GEN-LAST:event_btnRefreshGameDownloadsActionPerformed
|
||||||
|
|
||||||
private void btnExploreMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnExploreMouseClicked
|
private void btnExploreMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnExploreMouseClicked
|
||||||
@ -1158,7 +1158,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
|||||||
for (Profile s : Settings.getProfiles()) {
|
for (Profile s : Settings.getProfiles()) {
|
||||||
if (firstProfile == null) firstProfile = s;
|
if (firstProfile == null) firstProfile = s;
|
||||||
cboProfiles.addItem(s.getName());
|
cboProfiles.addItem(s.getName());
|
||||||
if (Settings.s().getLast() != null && Settings.s().getLast().equals(s.getName())) {
|
if (Settings.getInstance().getLast() != null && Settings.getInstance().getLast().equals(s.getName())) {
|
||||||
index = i;
|
index = i;
|
||||||
selectedProfile = s;
|
selectedProfile = s;
|
||||||
}
|
}
|
||||||
@ -1250,7 +1250,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
|||||||
if (mcVersion == null || profile == null) return;
|
if (mcVersion == null || profile == null) return;
|
||||||
type.getList((value) -> {
|
type.getList((value) -> {
|
||||||
if (value != null)
|
if (value != null)
|
||||||
TaskWindow.getInstance().addTask(type.getDownloadTask(Settings.s().getDownloadSource().getProvider())).start();
|
TaskWindow.getInstance().addTask(type.getDownloadTask(Settings.getInstance().getDownloadSource().getProvider())).start();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1297,7 +1297,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
|||||||
void downloadMinecraft(DownloadType index) {
|
void downloadMinecraft(DownloadType index) {
|
||||||
if (profile == null) return;
|
if (profile == null) return;
|
||||||
if (lstDownloads.getSelectedRow() < 0)
|
if (lstDownloads.getSelectedRow() < 0)
|
||||||
refreshDownloads(Settings.s().getDownloadSource());
|
refreshDownloads(Settings.getInstance().getDownloadSource());
|
||||||
if (lstDownloads.getSelectedRow() < 0) {
|
if (lstDownloads.getSelectedRow() < 0) {
|
||||||
MessageBox.Show(C.i18n("gamedownload.not_refreshed"));
|
MessageBox.Show(C.i18n("gamedownload.not_refreshed"));
|
||||||
return;
|
return;
|
||||||
@ -1328,7 +1328,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void refreshVersions() {
|
void refreshVersions() {
|
||||||
list = Settings.s().getDownloadSource().getProvider().getInstallerByType(id);
|
list = Settings.getInstance().getDownloadSource().getProvider().getInstallerByType(id);
|
||||||
if (TaskWindow.getInstance().addTask(new TaskRunnableArg1<>(C.i18n("install." + id + ".get_list"), list)
|
if (TaskWindow.getInstance().addTask(new TaskRunnableArg1<>(C.i18n("install." + id + ".get_list"), list)
|
||||||
.registerPreviousResult(new DefaultPreviousResult<>(new String[]{getMinecraftVersionFormatted()})))
|
.registerPreviousResult(new DefaultPreviousResult<>(new String[]{getMinecraftVersionFormatted()})))
|
||||||
.start())
|
.start())
|
||||||
|
@ -38,14 +38,14 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
|||||||
public LauncherSettingsPanel() {
|
public LauncherSettingsPanel() {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
|
||||||
txtBackgroundPath.setText(Settings.s().getBgpath());
|
txtBackgroundPath.setText(Settings.getInstance().getBgpath());
|
||||||
txtProxyHost.setText(Settings.s().getProxyHost());
|
txtProxyHost.setText(Settings.getInstance().getProxyHost());
|
||||||
txtProxyPort.setText(Settings.s().getProxyPort());
|
txtProxyPort.setText(Settings.getInstance().getProxyPort());
|
||||||
txtProxyUsername.setText(Settings.s().getProxyUserName());
|
txtProxyUsername.setText(Settings.getInstance().getProxyUserName());
|
||||||
txtProxyPassword.setText(Settings.s().getProxyPassword());
|
txtProxyPassword.setText(Settings.getInstance().getProxyPassword());
|
||||||
cboDownloadSource.setSelectedIndex(Settings.s().getDownloadType());
|
cboDownloadSource.setSelectedIndex(Settings.getInstance().getDownloadType());
|
||||||
cboTheme.setSelectedIndex(Settings.s().getTheme());
|
cboTheme.setSelectedIndex(Settings.getInstance().getTheme());
|
||||||
chkEnableShadow.setSelected(Settings.s().isEnableShadow());
|
chkEnableShadow.setSelected(Settings.getInstance().isEnableShadow());
|
||||||
|
|
||||||
setBackground(Color.white);
|
setBackground(Color.white);
|
||||||
setOpaque(true);
|
setOpaque(true);
|
||||||
@ -250,7 +250,7 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
|||||||
}// </editor-fold>//GEN-END:initComponents
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
|
|
||||||
private void cboDownloadSourceItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboDownloadSourceItemStateChanged
|
private void cboDownloadSourceItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboDownloadSourceItemStateChanged
|
||||||
Settings.s().setDownloadType(cboDownloadSource.getSelectedIndex());
|
Settings.getInstance().setDownloadType(cboDownloadSource.getSelectedIndex());
|
||||||
}//GEN-LAST:event_cboDownloadSourceItemStateChanged
|
}//GEN-LAST:event_cboDownloadSourceItemStateChanged
|
||||||
|
|
||||||
private void btnSelBackgroundPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelBackgroundPathActionPerformed
|
private void btnSelBackgroundPathActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelBackgroundPathActionPerformed
|
||||||
@ -266,7 +266,7 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
|||||||
String path = fc.getSelectedFile().getCanonicalPath();
|
String path = fc.getSelectedFile().getCanonicalPath();
|
||||||
path = IOUtils.removeLastSeparator(path);
|
path = IOUtils.removeLastSeparator(path);
|
||||||
txtBackgroundPath.setText(path);
|
txtBackgroundPath.setText(path);
|
||||||
Settings.s().setBgpath(path);
|
Settings.getInstance().setBgpath(path);
|
||||||
MainFrame.instance.loadBackground();
|
MainFrame.instance.loadBackground();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
HMCLog.warn("Failed to set background path.", e);
|
HMCLog.warn("Failed to set background path.", e);
|
||||||
@ -275,7 +275,7 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
|||||||
}//GEN-LAST:event_btnSelBackgroundPathActionPerformed
|
}//GEN-LAST:event_btnSelBackgroundPathActionPerformed
|
||||||
|
|
||||||
private void txtBackgroundPathFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtBackgroundPathFocusLost
|
private void txtBackgroundPathFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtBackgroundPathFocusLost
|
||||||
Settings.s().setBgpath(txtBackgroundPath.getText());
|
Settings.getInstance().setBgpath(txtBackgroundPath.getText());
|
||||||
MainFrame.instance.loadBackground();
|
MainFrame.instance.loadBackground();
|
||||||
}//GEN-LAST:event_txtBackgroundPathFocusLost
|
}//GEN-LAST:event_txtBackgroundPathFocusLost
|
||||||
|
|
||||||
@ -284,29 +284,29 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
|
|||||||
}//GEN-LAST:event_btnCheckUpdateActionPerformed
|
}//GEN-LAST:event_btnCheckUpdateActionPerformed
|
||||||
|
|
||||||
private void chkEnableShadowFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_chkEnableShadowFocusLost
|
private void chkEnableShadowFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_chkEnableShadowFocusLost
|
||||||
Settings.s().setEnableShadow(chkEnableShadow.isSelected());
|
Settings.getInstance().setEnableShadow(chkEnableShadow.isSelected());
|
||||||
}//GEN-LAST:event_chkEnableShadowFocusLost
|
}//GEN-LAST:event_chkEnableShadowFocusLost
|
||||||
|
|
||||||
private void cboThemeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboThemeItemStateChanged
|
private void cboThemeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboThemeItemStateChanged
|
||||||
Settings.s().setTheme(cboTheme.getSelectedIndex());
|
Settings.getInstance().setTheme(cboTheme.getSelectedIndex());
|
||||||
if(MainFrame.instance != null)
|
if(MainFrame.instance != null)
|
||||||
MainFrame.instance.reloadColor();
|
MainFrame.instance.reloadColor();
|
||||||
}//GEN-LAST:event_cboThemeItemStateChanged
|
}//GEN-LAST:event_cboThemeItemStateChanged
|
||||||
|
|
||||||
private void txtProxyHostFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyHostFocusLost
|
private void txtProxyHostFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyHostFocusLost
|
||||||
Settings.s().setProxyHost(txtProxyHost.getText());
|
Settings.getInstance().setProxyHost(txtProxyHost.getText());
|
||||||
}//GEN-LAST:event_txtProxyHostFocusLost
|
}//GEN-LAST:event_txtProxyHostFocusLost
|
||||||
|
|
||||||
private void txtProxyPortFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyPortFocusLost
|
private void txtProxyPortFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyPortFocusLost
|
||||||
Settings.s().setProxyPort(txtProxyPort.getText());
|
Settings.getInstance().setProxyPort(txtProxyPort.getText());
|
||||||
}//GEN-LAST:event_txtProxyPortFocusLost
|
}//GEN-LAST:event_txtProxyPortFocusLost
|
||||||
|
|
||||||
private void txtProxyUsernameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyUsernameFocusLost
|
private void txtProxyUsernameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyUsernameFocusLost
|
||||||
Settings.s().setProxyUserName(txtProxyUsername.getText());
|
Settings.getInstance().setProxyUserName(txtProxyUsername.getText());
|
||||||
}//GEN-LAST:event_txtProxyUsernameFocusLost
|
}//GEN-LAST:event_txtProxyUsernameFocusLost
|
||||||
|
|
||||||
private void txtProxyPasswordFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyPasswordFocusLost
|
private void txtProxyPasswordFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtProxyPasswordFocusLost
|
||||||
Settings.s().setProxyPassword(txtProxyPassword.getText());
|
Settings.getInstance().setProxyPassword(txtProxyPassword.getText());
|
||||||
}//GEN-LAST:event_txtProxyPasswordFocusLost
|
}//GEN-LAST:event_txtProxyPasswordFocusLost
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
@ -70,7 +70,7 @@ public final class MainFrame extends DraggableFrame {
|
|||||||
|
|
||||||
MainFrame() {
|
MainFrame() {
|
||||||
defaultTitle = Main.makeTitle();
|
defaultTitle = Main.makeTitle();
|
||||||
enableShadow = Settings.s().isEnableShadow();
|
enableShadow = Settings.getInstance().isEnableShadow();
|
||||||
if (enableShadow)
|
if (enableShadow)
|
||||||
setSize(834, 542);
|
setSize(834, 542);
|
||||||
else
|
else
|
||||||
@ -89,7 +89,7 @@ public final class MainFrame extends DraggableFrame {
|
|||||||
getRootPane().setBorder(border = new DropShadowBorder(borderColor, 4));
|
getRootPane().setBorder(border = new DropShadowBorder(borderColor, 4));
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
HMCLog.err("Failed to set window transparent.", ex);
|
HMCLog.err("Failed to set window transparent.", ex);
|
||||||
Settings.s().setEnableShadow(false);
|
Settings.getInstance().setEnableShadow(false);
|
||||||
setSize(802, 511);
|
setSize(802, 511);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,8 +97,8 @@ public final class MainFrame extends DraggableFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
borderColor = BasicColors.bgcolors[Settings.s().getTheme()];
|
borderColor = BasicColors.bgcolors[Settings.getInstance().getTheme()];
|
||||||
borderColorDarker = BasicColors.bgcolors_darker[Settings.s().getTheme()];
|
borderColorDarker = BasicColors.bgcolors_darker[Settings.getInstance().getTheme()];
|
||||||
|
|
||||||
realPanel = new JPanel();
|
realPanel = new JPanel();
|
||||||
realPanel.setLayout(null);
|
realPanel.setLayout(null);
|
||||||
@ -265,7 +265,7 @@ public final class MainFrame extends DraggableFrame {
|
|||||||
ImageIcon background;
|
ImageIcon background;
|
||||||
|
|
||||||
public void loadBackground() {
|
public void loadBackground() {
|
||||||
background = Utils.searchBackgroundImage(Main.getIcon("background.jpg"), Settings.s().getBgpath(), 800, 480);
|
background = Utils.searchBackgroundImage(Main.getIcon("background.jpg"), Settings.getInstance().getBgpath(), 800, 480);
|
||||||
if (background != null) {
|
if (background != null) {
|
||||||
if (backgroundLabel == null) {
|
if (backgroundLabel == null) {
|
||||||
backgroundLabel = new JLabel(background);
|
backgroundLabel = new JLabel(background);
|
||||||
@ -316,8 +316,8 @@ public final class MainFrame extends DraggableFrame {
|
|||||||
Color borderColorDarker = BasicColors.COLOR_BLUE_DARKER;
|
Color borderColorDarker = BasicColors.COLOR_BLUE_DARKER;
|
||||||
|
|
||||||
public void reloadColor() {
|
public void reloadColor() {
|
||||||
borderColor = BasicColors.bgcolors[Settings.s().getTheme()];
|
borderColor = BasicColors.bgcolors[Settings.getInstance().getTheme()];
|
||||||
borderColorDarker = BasicColors.bgcolors_darker[Settings.s().getTheme()];
|
borderColorDarker = BasicColors.bgcolors_darker[Settings.getInstance().getTheme()];
|
||||||
if (border != null)
|
if (border != null)
|
||||||
border.setColor(borderColor);
|
border.setColor(borderColor);
|
||||||
header.setBackground(borderColor);
|
header.setBackground(borderColor);
|
||||||
|
@ -293,7 +293,7 @@ public class MainPagePanel extends javax.swing.JPanel {
|
|||||||
}//GEN-LAST:event_txtPlayerNameFocusGained
|
}//GEN-LAST:event_txtPlayerNameFocusGained
|
||||||
|
|
||||||
private void txtPlayerNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtPlayerNameFocusLost
|
private void txtPlayerNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtPlayerNameFocusLost
|
||||||
Settings.s().setUsername(txtPlayerName.getText());
|
Settings.getInstance().setUsername(txtPlayerName.getText());
|
||||||
}//GEN-LAST:event_txtPlayerNameFocusLost
|
}//GEN-LAST:event_txtPlayerNameFocusLost
|
||||||
|
|
||||||
private void cboLoginModeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboLoginModeItemStateChanged
|
private void cboLoginModeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboLoginModeItemStateChanged
|
||||||
@ -313,15 +313,15 @@ public class MainPagePanel extends javax.swing.JPanel {
|
|||||||
CardLayout cl = (CardLayout) pnlPassword.getLayout();
|
CardLayout cl = (CardLayout) pnlPassword.getLayout();
|
||||||
if (l.isLoggedIn()) cl.last(pnlPassword);
|
if (l.isLoggedIn()) cl.last(pnlPassword);
|
||||||
else cl.first(pnlPassword);
|
else cl.first(pnlPassword);
|
||||||
String username = Settings.s().getUsername();
|
String username = Settings.getInstance().getUsername();
|
||||||
if (StrUtils.isNotBlank(username)) txtPlayerName.setText(username);
|
if (StrUtils.isNotBlank(username)) txtPlayerName.setText(username);
|
||||||
|
|
||||||
Settings.s().setLoginType(index);
|
Settings.getInstance().setLoginType(index);
|
||||||
}//GEN-LAST:event_cboLoginModeItemStateChanged
|
}//GEN-LAST:event_cboLoginModeItemStateChanged
|
||||||
|
|
||||||
private void cboProfilesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboProfilesItemStateChanged
|
private void cboProfilesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboProfilesItemStateChanged
|
||||||
if (!isLoading && cboProfiles.getSelectedIndex() != -1 && !StrUtils.isBlank((String) cboProfiles.getSelectedItem())) {
|
if (!isLoading && cboProfiles.getSelectedIndex() != -1 && !StrUtils.isBlank((String) cboProfiles.getSelectedItem())) {
|
||||||
Settings.s().setLast((String) cboProfiles.getSelectedItem());
|
Settings.getInstance().setLast((String) cboProfiles.getSelectedItem());
|
||||||
loadMinecraftVersions();
|
loadMinecraftVersions();
|
||||||
}
|
}
|
||||||
}//GEN-LAST:event_cboProfilesItemStateChanged
|
}//GEN-LAST:event_cboProfilesItemStateChanged
|
||||||
@ -401,12 +401,12 @@ public class MainPagePanel extends javax.swing.JPanel {
|
|||||||
}
|
}
|
||||||
final int index = cboLoginMode.getSelectedIndex();
|
final int index = cboLoginMode.getSelectedIndex();
|
||||||
final IAuthenticator l = IAuthenticator.logins.get(index);
|
final IAuthenticator l = IAuthenticator.logins.get(index);
|
||||||
final LoginInfo li = new LoginInfo(Settings.s().getUsername(), l.isLoggedIn() || l.isHidePasswordBox() ? null : new String(txtPassword.getPassword()));
|
final LoginInfo li = new LoginInfo(Settings.getInstance().getUsername(), l.isLoggedIn() || l.isHidePasswordBox() ? null : new String(txtPassword.getPassword()));
|
||||||
Thread t = new Thread() {
|
Thread t = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Thread.currentThread().setName("Game Launcher");
|
Thread.currentThread().setName("Game Launcher");
|
||||||
DefaultGameLauncher gl = new DefaultGameLauncher(getCurrentProfile(), li, l, Settings.s().getDownloadSource());
|
DefaultGameLauncher gl = new DefaultGameLauncher(getCurrentProfile(), li, l, Settings.getInstance().getDownloadSource());
|
||||||
gl.failEvent.register((sender, s) -> {
|
gl.failEvent.register((sender, s) -> {
|
||||||
if (s != null) MessageBox.Show(s);
|
if (s != null) MessageBox.Show(s);
|
||||||
MainFrame.instance.closeMessage();
|
MainFrame.instance.closeMessage();
|
||||||
@ -431,9 +431,9 @@ public class MainPagePanel extends javax.swing.JPanel {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
HMCLog.warn("Failed to get login name", ex);
|
HMCLog.warn("Failed to get login name", ex);
|
||||||
}
|
}
|
||||||
if (Settings.s().getLoginType() < list.size()) {
|
if (Settings.getInstance().getLoginType() < list.size()) {
|
||||||
preaparingAuth = false;
|
preaparingAuth = false;
|
||||||
cboLoginMode.setSelectedIndex(Settings.s().getLoginType());
|
cboLoginMode.setSelectedIndex(Settings.getInstance().getLoginType());
|
||||||
|
|
||||||
cboLoginModeItemStateChanged(null);
|
cboLoginModeItemStateChanged(null);
|
||||||
}
|
}
|
||||||
@ -526,7 +526,7 @@ public class MainPagePanel extends javax.swing.JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onSelected() {
|
public void onSelected() {
|
||||||
refreshMinecrafts(Settings.s().getLast());
|
refreshMinecrafts(Settings.getInstance().getLast());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
|
Loading…
x
Reference in New Issue
Block a user