Now a version setting can be linked to the global setting or its specialized setting
This commit is contained in:
@@ -72,7 +72,6 @@ public final class Config implements Cloneable {
|
||||
@SerializedName("configurations")
|
||||
private TreeMap<String, Profile> configurations;
|
||||
@SerializedName("auth")
|
||||
@SuppressWarnings("FieldMayBeFinal")
|
||||
private Map<String, Map> auth;
|
||||
|
||||
public List<JdkVersion> getJava() {
|
||||
@@ -130,7 +129,6 @@ public final class Config implements Cloneable {
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Last selected profile name.
|
||||
*/
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.launcher.setting;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import org.jackhuang.hellominecraft.launcher.util.HMCLGameLauncher;
|
||||
import org.jackhuang.hellominecraft.launcher.util.HMCLMinecraftService;
|
||||
import java.io.File;
|
||||
@@ -35,7 +36,14 @@ import org.jackhuang.hellominecraft.util.sys.OS;
|
||||
*/
|
||||
public final class Profile {
|
||||
|
||||
private String name, selectedMinecraftVersion = "", gameDir;
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
@SerializedName("selectedMinecraftVersion")
|
||||
private String selectedMinecraftVersion = "";
|
||||
@SerializedName("gameDir")
|
||||
private String gameDir;
|
||||
@SerializedName("global")
|
||||
private VersionSetting global;
|
||||
|
||||
private transient IMinecraftService service;
|
||||
private transient HMCLGameLauncher launcher = new HMCLGameLauncher(this);
|
||||
@@ -52,6 +60,7 @@ public final class Profile {
|
||||
public Profile(String name, String gameDir) {
|
||||
this.name = name;
|
||||
this.gameDir = gameDir;
|
||||
this.global = new VersionSetting();
|
||||
}
|
||||
|
||||
public Profile(String name, Profile v) {
|
||||
@@ -82,7 +91,42 @@ public final class Profile {
|
||||
}
|
||||
|
||||
public VersionSetting getVersionSetting(String id) {
|
||||
return ((HMCLMinecraftService) service()).getVersionSetting(id);
|
||||
VersionSetting vs = ((HMCLMinecraftService) service()).getVersionSetting(id);
|
||||
if (vs == null || vs.isUsesGlobal()) {
|
||||
global.isGlobal = true;
|
||||
return global;
|
||||
} else
|
||||
return vs;
|
||||
}
|
||||
|
||||
public boolean isVersionSettingGlobe(String id) {
|
||||
VersionSetting vs = ((HMCLMinecraftService) service()).getVersionSetting(id);
|
||||
return vs == null || vs.isUsesGlobal();
|
||||
}
|
||||
|
||||
public void makeVersionSettingSpecial(String id) {
|
||||
HMCLMinecraftService s = (HMCLMinecraftService) service();
|
||||
VersionSetting vs = s.getVersionSetting(id);
|
||||
if (vs == null) {
|
||||
s.createVersionSetting(id);
|
||||
vs = s.getVersionSetting(id);
|
||||
if (vs == null)
|
||||
return;
|
||||
vs.setUsesGlobal(false);
|
||||
} else
|
||||
vs.setUsesGlobal(false);
|
||||
propertyChanged.execute("selectedMinecraftVersion");
|
||||
selectedVersionChangedEvent.execute(selectedMinecraftVersion);
|
||||
}
|
||||
|
||||
public void makeVersionSettingGlobal(String id) {
|
||||
HMCLMinecraftService s = (HMCLMinecraftService) service();
|
||||
VersionSetting vs = s.getVersionSetting(id);
|
||||
if (vs == null)
|
||||
return;
|
||||
vs.setUsesGlobal(true);
|
||||
propertyChanged.execute("selectedMinecraftVersion");
|
||||
selectedVersionChangedEvent.execute(selectedMinecraftVersion);
|
||||
}
|
||||
|
||||
public String getSettingsSelectedMinecraftVersion() {
|
||||
|
||||
@@ -39,7 +39,10 @@ import org.jackhuang.hellominecraft.util.sys.OS;
|
||||
public class VersionSetting {
|
||||
|
||||
public transient String id;
|
||||
public transient boolean isGlobal = false;
|
||||
|
||||
@SerializedName("usesGlobal")
|
||||
private boolean usesGlobal;
|
||||
@SerializedName("javaArgs")
|
||||
private String javaArgs;
|
||||
@SerializedName("minecraftArgs")
|
||||
@@ -88,6 +91,7 @@ public class VersionSetting {
|
||||
|
||||
public VersionSetting() {
|
||||
fullscreen = false;
|
||||
usesGlobal = true;
|
||||
launcherVisibility = 1;
|
||||
gameDirType = 0;
|
||||
javaDir = java = minecraftArgs = serverIp = precalledCommand = wrapper = "";
|
||||
@@ -277,6 +281,15 @@ public class VersionSetting {
|
||||
propertyChanged.execute("notCheckGame");
|
||||
}
|
||||
|
||||
public boolean isUsesGlobal() {
|
||||
return usesGlobal;
|
||||
}
|
||||
|
||||
public void setUsesGlobal(boolean usesGlobal) {
|
||||
this.usesGlobal = usesGlobal;
|
||||
propertyChanged.execute("usesGlobal");
|
||||
}
|
||||
|
||||
public LaunchOptions createLaunchOptions(File gameDir) {
|
||||
LaunchOptions x = new LaunchOptions();
|
||||
x.setFullscreen(isFullscreen());
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="pnlTop" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="tabVersionEdit" alignment="1" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
@@ -35,6 +35,10 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnTestGame" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="lblUsesGlobal" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@@ -52,6 +56,8 @@
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="pnlTop" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblUsesGlobal" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="tabVersionEdit" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
@@ -63,7 +69,7 @@
|
||||
</Group>
|
||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace pref="447" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="421" max="32767" attributes="0"/>
|
||||
<Component id="btnIncludeMinecraft" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@@ -192,7 +198,7 @@
|
||||
<Component id="lblDimension" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="txtWidth" alignment="3" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="99" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="60" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="btnDownloadAllAssets" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnCleanGame" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
@@ -449,7 +455,7 @@
|
||||
<Component id="lblServerIP" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="txtServerIP" min="-2" pref="26" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="39" max="32767" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="chkNoJVMArgs" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="chkDontCheckGame" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
@@ -612,7 +618,7 @@
|
||||
<Component id="btnRemoveMod" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="jScrollPane1" pref="299" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="259" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="lblModInfo" min="-2" max="-2" attributes="0"/>
|
||||
@@ -970,5 +976,16 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnIncludeMinecraftActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lblUsesGlobal">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jLabel1"/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="手型光标"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="lblUsesGlobalMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
||||
@@ -56,6 +56,7 @@ import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.VersionSetting;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
import org.jackhuang.hellominecraft.util.AbstractSwingWorker;
|
||||
import org.jackhuang.hellominecraft.util.Event;
|
||||
import org.jackhuang.hellominecraft.util.MinecraftVersionRequest;
|
||||
import org.jackhuang.hellominecraft.util.sys.OS;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
@@ -323,6 +324,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
btnShowLog = new javax.swing.JButton();
|
||||
btnMakeLaunchScript = new javax.swing.JButton();
|
||||
btnIncludeMinecraft = new javax.swing.JButton();
|
||||
lblUsesGlobal = new javax.swing.JLabel();
|
||||
|
||||
setBackground(new java.awt.Color(255, 255, 255));
|
||||
setOpaque(false);
|
||||
@@ -513,7 +515,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
.addComponent(lblDimensionX, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblDimension)
|
||||
.addComponent(txtWidth, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 99, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 60, Short.MAX_VALUE)
|
||||
.addGroup(pnlSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnDownloadAllAssets)
|
||||
.addComponent(btnCleanGame))
|
||||
@@ -644,7 +646,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
.addComponent(lblServerIP)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(txtServerIP, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 39, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(chkNoJVMArgs)
|
||||
.addComponent(chkDontCheckGame))
|
||||
@@ -709,7 +711,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnRemoveMod)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE))
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 259, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblModInfo))
|
||||
);
|
||||
@@ -905,22 +907,33 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
}
|
||||
});
|
||||
|
||||
lblUsesGlobal.setText("jLabel1");
|
||||
lblUsesGlobal.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
|
||||
lblUsesGlobal.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
lblUsesGlobalMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(pnlTop, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(tabVersionEdit)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(tabVersionEdit, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(btnMakeLaunchScript)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnShowLog)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnTestGame)))
|
||||
.addComponent(btnTestGame))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(lblUsesGlobal)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
@@ -933,6 +946,8 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(pnlTop, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblUsesGlobal)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(tabVersionEdit)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
@@ -942,7 +957,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
.addContainerGap())
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap(447, Short.MAX_VALUE)
|
||||
.addContainerGap(421, Short.MAX_VALUE)
|
||||
.addComponent(btnIncludeMinecraft)
|
||||
.addContainerGap()))
|
||||
);
|
||||
@@ -1183,6 +1198,16 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
loadVersions();
|
||||
}//GEN-LAST:event_txtGameDirFocusLost
|
||||
|
||||
private void lblUsesGlobalMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblUsesGlobalMouseClicked
|
||||
if (mcVersion == null)
|
||||
return;
|
||||
Profile profile = Settings.getLastProfile();
|
||||
if (profile.isVersionSettingGlobe(mcVersion))
|
||||
profile.makeVersionSettingSpecial(mcVersion);
|
||||
else
|
||||
profile.makeVersionSettingGlobal(mcVersion);
|
||||
}//GEN-LAST:event_lblUsesGlobalMouseClicked
|
||||
|
||||
// </editor-fold>
|
||||
// <editor-fold defaultstate="collapsed" desc="Load">
|
||||
void prepareVersionSetting(VersionSetting profile) {
|
||||
@@ -1375,6 +1400,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
private javax.swing.JLabel lblProfile;
|
||||
private javax.swing.JLabel lblRunDirectory;
|
||||
private javax.swing.JLabel lblServerIP;
|
||||
private javax.swing.JLabel lblUsesGlobal;
|
||||
private javax.swing.JLabel lblVersions;
|
||||
private javax.swing.JTable lstExternalMods;
|
||||
private javax.swing.JPanel pnlAdvancedSettings;
|
||||
@@ -1449,6 +1475,8 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
reloadMods();
|
||||
prepareVersionSetting(Settings.getLastProfile().getVersionSetting(version));
|
||||
loadMinecraftVersion(version);
|
||||
|
||||
lblUsesGlobal.setText(C.i18n(Settings.getLastProfile().isVersionSettingGlobe(version) ? "settings.type.global" : "settings.type.special"));
|
||||
for (InstallerPanel p : installerPanels)
|
||||
p.loadVersions();
|
||||
isLoading = false;
|
||||
|
||||
@@ -533,7 +533,6 @@ public class MainPagePanel extends Page {
|
||||
model.setSelectedItem(selectedVersion);
|
||||
break;
|
||||
}
|
||||
cboVersions.setToolTipText(selectedVersion);
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,17 @@ public class HMCLMinecraftService extends IMinecraftService {
|
||||
}
|
||||
}
|
||||
if (vs == null)
|
||||
vs = new VersionSetting();
|
||||
return;
|
||||
initVersionSetting(id, vs);
|
||||
}
|
||||
|
||||
public void createVersionSetting(String id) {
|
||||
if (provider.getVersionById(id) == null || versionSettings.containsKey(id))
|
||||
return;
|
||||
initVersionSetting(id, new VersionSetting());
|
||||
}
|
||||
|
||||
private void initVersionSetting(String id, VersionSetting vs) {
|
||||
vs.id = id;
|
||||
vs.propertyChanged.register((sender, t) -> {
|
||||
saveVersionSetting(((VersionSetting) sender).id);
|
||||
|
||||
Reference in New Issue
Block a user