Add an option to disable common path
This commit is contained in:
@@ -50,7 +50,7 @@ if (buildnumber == null)
|
||||
|
||||
def versionroot = System.getenv("VERSION_ROOT")
|
||||
if (versionroot == null)
|
||||
versionroot = "2.7.0"
|
||||
versionroot = "2.7.1"
|
||||
|
||||
String mavenGroupId = 'HMCL'
|
||||
String mavenVersion = versionroot + '.' + buildnumber
|
||||
|
||||
@@ -41,6 +41,8 @@ public final class Profile {
|
||||
private String selectedMinecraftVersion = "";
|
||||
@SerializedName("gameDir")
|
||||
private String gameDir;
|
||||
@SerializedName("noCommon")
|
||||
private boolean noCommon;
|
||||
@SerializedName("global")
|
||||
private VersionSetting global;
|
||||
|
||||
@@ -169,6 +171,16 @@ public final class Profile {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isNoCommon() {
|
||||
return noCommon;
|
||||
}
|
||||
|
||||
public void setNoCommon(boolean noCommon) {
|
||||
PropertyChangedEvent event = new PropertyChangedEvent(this, "noCommon", this.noCommon, noCommon);
|
||||
this.noCommon = noCommon;
|
||||
propertyChanged.fire(event);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -419,7 +419,9 @@
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkNoJVMArgs" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="chkNoCommon" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="96" max="32767" attributes="0"/>
|
||||
<Component id="chkDontCheckGame" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
@@ -469,6 +471,7 @@
|
||||
<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"/>
|
||||
<Component id="chkNoCommon" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
@@ -573,6 +576,19 @@
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkDontCheckGameItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JCheckBox" name="chkNoCommon">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hmcl/lang/I18N.properties" key="advancedsettings.no_common" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="org/jackhuang/hmcl/lang/I18N.properties" key="launcher.commpath_tooltip" replaceFormat="C.i18n("{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="chkNoCommonItemStateChanged"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="pnlModManagement">
|
||||
|
||||
@@ -314,6 +314,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
lblPrecalledCommand1 = new javax.swing.JLabel();
|
||||
txtWrapperLauncher = new javax.swing.JTextField();
|
||||
chkDontCheckGame = new javax.swing.JCheckBox();
|
||||
chkNoCommon = new javax.swing.JCheckBox();
|
||||
pnlModManagement = new Page();
|
||||
pnlModManagementContent = new Page();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
@@ -610,6 +611,14 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
}
|
||||
});
|
||||
|
||||
chkNoCommon.setText(C.i18n("advancedsettings.no_common")); // NOI18N
|
||||
chkNoCommon.setToolTipText(C.i18n("launcher.commpath_tooltip")); // NOI18N
|
||||
chkNoCommon.addItemListener(new java.awt.event.ItemListener() {
|
||||
public void itemStateChanged(java.awt.event.ItemEvent evt) {
|
||||
chkNoCommonItemStateChanged(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout pnlAdvancedSettingsLayout = new javax.swing.GroupLayout(pnlAdvancedSettings);
|
||||
pnlAdvancedSettings.setLayout(pnlAdvancedSettingsLayout);
|
||||
pnlAdvancedSettingsLayout.setHorizontalGroup(
|
||||
@@ -632,7 +641,9 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(chkNoJVMArgs)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(chkNoCommon)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 96, Short.MAX_VALUE)
|
||||
.addComponent(chkDontCheckGame))
|
||||
.addGroup(pnlAdvancedSettingsLayout.createSequentialGroup()
|
||||
.addGroup(pnlAdvancedSettingsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@@ -672,7 +683,8 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
.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))
|
||||
.addComponent(chkDontCheckGame)
|
||||
.addComponent(chkNoCommon))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@@ -958,7 +970,7 @@ 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(tabVersionEdit, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)
|
||||
.addComponent(tabVersionEdit)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(btnTestGame)
|
||||
@@ -1218,26 +1230,32 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
profile.makeVersionSettingGlobal(mcVersion);
|
||||
}//GEN-LAST:event_lblUsesGlobalMouseClicked
|
||||
|
||||
private void chkNoCommonItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chkNoCommonItemStateChanged
|
||||
if (!isLoading)
|
||||
Settings.getLastProfile().setNoCommon(chkNoCommon.isSelected());
|
||||
}//GEN-LAST:event_chkNoCommonItemStateChanged
|
||||
|
||||
// </editor-fold>
|
||||
// <editor-fold defaultstate="collapsed" desc="Load">
|
||||
void prepareVersionSetting(VersionSetting profile) {
|
||||
if (profile == null)
|
||||
void prepareVersionSetting(Profile profile, VersionSetting vs) {
|
||||
if (vs == null)
|
||||
return;
|
||||
isLoading = true;
|
||||
txtWidth.setText(profile.getWidth());
|
||||
txtHeight.setText(profile.getHeight());
|
||||
txtMaxMemory.setText(profile.getMaxMemory());
|
||||
txtPermSize.setText(profile.getPermSize());
|
||||
txtJavaArgs.setText(profile.getJavaArgs());
|
||||
txtMinecraftArgs.setText(profile.getMinecraftArgs());
|
||||
txtPrecalledCommand.setText(profile.getPrecalledCommand());
|
||||
txtServerIP.setText(profile.getServerIp());
|
||||
chkNoJVMArgs.setSelected(profile.isNoJVMArgs());
|
||||
chkDontCheckGame.setSelected(profile.isNotCheckGame());
|
||||
chkFullscreen.setSelected(profile.isFullscreen());
|
||||
cboLauncherVisibility.setSelectedIndex(profile.getLauncherVisibility().ordinal());
|
||||
cboRunDirectory.setSelectedIndex(profile.getGameDirType().ordinal());
|
||||
cboJava.setSelectedIndex(profile.getJavaIndexInAllJavas());
|
||||
txtWidth.setText(vs.getWidth());
|
||||
txtHeight.setText(vs.getHeight());
|
||||
txtMaxMemory.setText(vs.getMaxMemory());
|
||||
txtPermSize.setText(vs.getPermSize());
|
||||
txtJavaArgs.setText(vs.getJavaArgs());
|
||||
txtMinecraftArgs.setText(vs.getMinecraftArgs());
|
||||
txtPrecalledCommand.setText(vs.getPrecalledCommand());
|
||||
txtServerIP.setText(vs.getServerIp());
|
||||
chkNoJVMArgs.setSelected(vs.isNoJVMArgs());
|
||||
chkDontCheckGame.setSelected(vs.isNotCheckGame());
|
||||
chkNoCommon.setSelected(profile.isNoCommon());
|
||||
chkFullscreen.setSelected(vs.isFullscreen());
|
||||
cboLauncherVisibility.setSelectedIndex(vs.getLauncherVisibility().ordinal());
|
||||
cboRunDirectory.setSelectedIndex(vs.getGameDirType().ordinal());
|
||||
cboJava.setSelectedIndex(vs.getJavaIndexInAllJavas());
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
@@ -1392,6 +1410,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
private javax.swing.JComboBox cboVersions;
|
||||
private javax.swing.JCheckBox chkDontCheckGame;
|
||||
private javax.swing.JCheckBox chkFullscreen;
|
||||
private javax.swing.JCheckBox chkNoCommon;
|
||||
private javax.swing.JCheckBox chkNoJVMArgs;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JLabel lblDimension;
|
||||
@@ -1481,7 +1500,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
|
||||
this.mcVersion = version;
|
||||
reloadMods();
|
||||
prepareVersionSetting(Settings.getLastProfile().getVersionSetting(version));
|
||||
prepareVersionSetting(Settings.getLastProfile(), Settings.getLastProfile().getVersionSetting(version));
|
||||
loadMinecraftVersion(version);
|
||||
|
||||
lblUsesGlobal.setText(C.i18n(Settings.getLastProfile().isVersionSettingGlobe(version) ? "settings.type.global" : "settings.type.special"));
|
||||
|
||||
@@ -33,7 +33,7 @@ public class HMCLAssetService extends MinecraftAssetService {
|
||||
}
|
||||
|
||||
private boolean useSelf(String assetId) {
|
||||
return new File(service.baseDirectory(), "assets/indexes/" + assetId + ",json").exists();
|
||||
return new File(service.baseDirectory(), "assets/indexes/" + assetId + ",json").exists() || ((HMCLMinecraftService) service).p.isNoCommon();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
package org.jackhuang.hmcl.util;
|
||||
|
||||
import java.io.File;
|
||||
import org.jackhuang.hmcl.api.HMCLApi;
|
||||
import org.jackhuang.hmcl.api.event.version.MinecraftLibraryPathEvent;
|
||||
import org.jackhuang.hmcl.api.game.GameDirType;
|
||||
import org.jackhuang.hmcl.api.game.IMinecraftLibrary;
|
||||
import org.jackhuang.hmcl.core.version.MinecraftVersion;
|
||||
import org.jackhuang.hmcl.core.version.MinecraftVersionManager;
|
||||
import org.jackhuang.hmcl.setting.Settings;
|
||||
import org.jackhuang.hmcl.setting.VersionSetting;
|
||||
@@ -33,11 +33,16 @@ public class HMCLGameProvider extends MinecraftVersionManager {
|
||||
|
||||
public HMCLGameProvider(HMCLMinecraftService p) {
|
||||
super(p);
|
||||
|
||||
HMCLApi.EVENT_BUS.channel(MinecraftLibraryPathEvent.class).register(t -> {
|
||||
if (!t.getFile().getValue().exists())
|
||||
t.getFile().setValue(new File(Settings.getInstance().getCommonpath(), t.getLocation()));
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getLibraryFile(MinecraftVersion version, IMinecraftLibrary lib) {
|
||||
VersionSetting vs = ((HMCLMinecraftService) service).getVersionSetting(version.id);
|
||||
File self = super.getLibraryFile(version, lib);
|
||||
if (self.exists() || (vs != null && ((HMCLMinecraftService) service).p.isNoCommon()))
|
||||
return self;
|
||||
else
|
||||
return lib.getFilePath(new File(Settings.getInstance().getCommonpath()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,8 +51,8 @@ public class HMCLGameProvider extends MinecraftVersionManager {
|
||||
if (vs == null)
|
||||
return super.getRunDirectory(id);
|
||||
else
|
||||
return ((HMCLMinecraftService) service).getVersionSetting(id).getGameDirType() == GameDirType.VERSION_FOLDER
|
||||
? service.version().versionRoot(id)
|
||||
: super.getRunDirectory(id);
|
||||
return vs.getGameDirType() == GameDirType.VERSION_FOLDER
|
||||
? service.version().versionRoot(id)
|
||||
: super.getRunDirectory(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user