Fixed saving common path setting

This commit is contained in:
huangyuhui
2017-02-13 14:02:13 +08:00
parent 1b81c1e221
commit 33ef03ef71
10 changed files with 33 additions and 9 deletions

View File

@@ -27,4 +27,3 @@ before_cache:
cache:
directories:
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"

View File

@@ -17,10 +17,22 @@
*/
plugins {
id "edu.sc.seis.macAppBundle" version "2.1.6"
id "me.tatarka.retrolambda" version "3.5.0"
//id "me.tatarka.retrolambda" version "3.5.0"
id 'edu.sc.seis.launch4j' version '2.3.0'
}
buildscript {
repositories {
mavenCentral();
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.1.0'
}
}
}
apply plugin: 'me.tatarka.retrolambda'
import java.util.jar.JarOutputStream
import java.util.zip.ZipEntry
import java.util.zip.ZipFile

View File

@@ -18,15 +18,16 @@
package org.jackhuang.hellominecraft.launcher.api.event.config;
import org.jackhuang.hellominecraft.api.SimpleEvent;
import org.jackhuang.hellominecraft.launcher.setting.Profile;
/**
* This event gets fired when the selected profile changed.
* @param String the new profile id.
* @param Profile the new profile.
* @author huangyuhui
*/
public class ProfileChangedEvent extends SimpleEvent<String> {
public class ProfileChangedEvent extends SimpleEvent<Profile> {
public ProfileChangedEvent(Object source, String value) {
public ProfileChangedEvent(Object source, Profile value) {
super(source, value);
}

View File

@@ -222,7 +222,7 @@ public final class Config implements Cloneable {
theme = 4;
decorated = OS.os() == OS.LINUX;
auth = new HashMap<>();
commonpath = MCUtils.getWorkingDirectory("hmcl").getAbsolutePath();
commonpath = MCUtils.getLocation().getAbsolutePath();
}
public DownloadType getDownloadSource() {

View File

@@ -161,7 +161,7 @@ public final class Settings {
Profile p = getLastProfile();
if (p == null)
throw new Error("No profiles here, it should not happen");
HMCAPI.EVENT_BUS.fireChannel(new ProfileChangedEvent(SETTINGS, p.getName()));
HMCAPI.EVENT_BUS.fireChannel(new ProfileChangedEvent(SETTINGS, p));
p.onSelected();
}

View File

@@ -1492,7 +1492,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
}
final Consumer<ProfileChangedEvent> onSelectedProfilesChanged = event -> {
Profile t = Settings.getProfile(event.getValue());
Profile t = event.getValue();
t.propertyChanged.register(e -> {
if ("selectedMinecraftVersion".equals(e.getPropertyName()))
versionChanged(e.getNewValue());

View File

@@ -392,6 +392,9 @@
<ResourceString bundle="org/jackhuang/hellominecraft/lang/I18N.properties" key="launcher.commpath_tooltip" replaceFormat="C.i18n(&quot;{key}&quot;)"/>
</Property>
</Properties>
<Events>
<EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="txtCommonPathFocusLost"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnSetCommonPath">
<Properties>

View File

@@ -259,6 +259,11 @@ public class LauncherSettingsPanel extends RepaintPage {
lblCommonPath.setText(C.i18n("launcher.common_location")); // NOI18N
txtCommonPath.setToolTipText(C.i18n("launcher.commpath_tooltip")); // NOI18N
txtCommonPath.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusLost(java.awt.event.FocusEvent evt) {
txtCommonPathFocusLost(evt);
}
});
btnSetCommonPath.setText(C.i18n("ui.button.explore")); // NOI18N
btnSetCommonPath.addActionListener(new java.awt.event.ActionListener() {
@@ -490,6 +495,10 @@ public class LauncherSettingsPanel extends RepaintPage {
}
}//GEN-LAST:event_btnSetCommonPathActionPerformed
private void txtCommonPathFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtCommonPathFocusLost
Settings.getInstance().setCommonpath(txtCommonPath.getText());
}//GEN-LAST:event_txtCommonPathFocusLost
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnCheckUpdate;
private javax.swing.JButton btnMCBBS;

View File

@@ -530,7 +530,7 @@ public class MainPagePanel extends Page {
}
final Consumer<ProfileChangedEvent> onSelectedProfilesChanged = event -> {
Profile t = Settings.getProfile(event.getValue());
Profile t = event.getValue();
t.propertyChanged.register(e -> {
if ("selectedMinecraftVersion".equals(e.getPropertyName()))
versionChanged(e.getNewValue());