Skip to content

Commit

Permalink
Merge branch 'release/2.1.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
gravit0 committed Mar 7, 2023
2 parents e22fc2b + 2e5313b commit b7ecc6f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ repositories {
}

dependencies {
implementation "pro.gravit.launcher:launcher-core:5.3.2"
implementation "pro.gravit.launcher:launcher-ws-api:5.3.2"
implementation "pro.gravit.launcher:launcher-client-api:5.3.2"
implementation "pro.gravit.launcher:launcher-core:5.3.6"
implementation "pro.gravit.launcher:launcher-ws-api:5.3.6"
implementation "pro.gravit.launcher:launcher-client-api:5.3.6"
implementation "pro.gravit.utils.enfs:enfs:1.0.0-SNAPSHOT"
implementation 'io.netty:netty-codec-http:4.1.67.Final'
implementation 'com.github.oshi:oshi-core:5.8.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class JavaRuntimeModule extends LauncherModule {
private RuntimeProvider provider;

public JavaRuntimeModule() {
super(new LauncherModuleInfo("StdJavaRuntime", new Version(2, 1, 3, 1, Version.Type.STABLE),
super(new LauncherModuleInfo("StdJavaRuntime", new Version(2, 1, 4, 1, Version.Type.STABLE),
0, new String[]{}, new String[]{"runtime"}));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import pro.gravit.launcher.client.gui.stage.ConsoleStage;
import pro.gravit.launcher.profiles.ClientProfile;
import pro.gravit.utils.helper.IOHelper;
import pro.gravit.utils.helper.JVMHelper;
import pro.gravit.utils.helper.LogHelper;

import java.io.File;
Expand All @@ -25,6 +26,9 @@
import java.util.function.Consumer;

public class SettingsScene extends AbstractScene {

private final static long MAX_JAVA_MEMORY_X64 = 32*1024;
private final static long MAX_JAVA_MEMORY_X32 = 1536;
private Pane componentList;
private Label ramLabel;
private Slider ramSlider;
Expand Down Expand Up @@ -52,12 +56,14 @@ protected void doInit() {

ramSlider = LookupHelper.lookup(layout, "#ramSlider");
ramLabel = LookupHelper.lookup(layout, "#ramLabel");
long maxSystemMemory;
try {
SystemInfo systemInfo = new SystemInfo();
ramSlider.setMax(systemInfo.getHardware().getMemory().getTotal() >> 20);
maxSystemMemory =(systemInfo.getHardware().getMemory().getTotal() >> 20);
} catch (Throwable e) {
ramSlider.setMax(2048);
maxSystemMemory = 2048;
}
ramSlider.setMax(Math.min(maxSystemMemory, getJavaMaxMemory()));

ramSlider.setSnapToTicks(true);
ramSlider.setShowTickMarks(true);
Expand Down Expand Up @@ -131,6 +137,13 @@ public Double fromString(String string) {
reset();
}

private long getJavaMaxMemory() {
if(application.javaService.isArchAvailable(JVMHelper.ARCH.X86_64) || application.javaService.isArchAvailable(JVMHelper.ARCH.ARM64)) {
return MAX_JAVA_MEMORY_X64;
}
return MAX_JAVA_MEMORY_X32;
}

@Override
public void reset() {
profileSettings = new RuntimeSettings.ProfileSettingsView(application.getProfileSettings());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public JavaService(JavaFXApplication application) {
int build = Integer.parseInt(matcher.group("build"));
JVMHelper.ARCH arch = JVMHelper.ARCH.valueOf(matcher.group("arch"));
boolean javafx = Boolean.parseBoolean(matcher.group("javafx"));
if (arch != JVMHelper.ARCH_TYPE) {
if (!isArchAvailable(arch)) {
continue;
}
if(!JVMHelper.OS_TYPE.name.equals(os)) {
Expand All @@ -52,6 +52,20 @@ public JavaService(JavaFXApplication application) {
javaVersions = Collections.unmodifiableList(versions);
}

public boolean isArchAvailable(JVMHelper.ARCH arch) {
if(JVMHelper.ARCH_TYPE == arch) {
return true;
}
if(arch == JVMHelper.ARCH.X86_64 && JVMHelper.OS_TYPE == JVMHelper.OS.MUSTDIE &&
(( JVMHelper.ARCH_TYPE == JVMHelper.ARCH.X86 && !JVMHelper.isJVMMatchesSystemArch()) || JVMHelper.ARCH_TYPE == JVMHelper.ARCH.ARM64)) {
return true;
}
if(arch == JVMHelper.ARCH.X86_64 && JVMHelper.OS_TYPE == JVMHelper.OS.MACOSX && JVMHelper.ARCH_TYPE == JVMHelper.ARCH.ARM64) {
return true;
}
return false;
}

public boolean isIncompatibleJava(JavaHelper.JavaVersion version, ClientProfile profile) {
return version.version > profile.getMaxJavaVersion() || version.version < profile.getMinJavaVersion()
|| (!version.enabledJavaFX && profile.getRuntimeInClientConfig() != ClientProfile.RuntimeInClientConfig.NONE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pro.gravit.launcher.events.request.ProfilesRequestEvent;
import pro.gravit.launcher.profiles.ClientProfile;
import pro.gravit.launcher.profiles.PlayerProfile;
import pro.gravit.launcher.profiles.optional.OptionalFile;
import pro.gravit.launcher.profiles.optional.OptionalView;
import pro.gravit.launcher.request.Request;

Expand Down Expand Up @@ -61,9 +62,10 @@ public void setProfilesResult(ProfilesRequestEvent rawProfilesResult) {
this.profiles = rawProfilesResult.profiles;
this.profiles.sort(ClientProfile::compareTo);
if (this.optionalViewMap == null) this.optionalViewMap = new HashMap<>();
else this.optionalViewMap.clear();
for (ClientProfile profile : profiles) {
this.optionalViewMap.put(profile, new OptionalView(profile));
OptionalView oldView = this.optionalViewMap.get(profile);
OptionalView newView = oldView != null ? new OptionalView(profile, oldView) : new OptionalView(profile);
this.optionalViewMap.put(profile, newView);
}
}

Expand Down

0 comments on commit b7ecc6f

Please sign in to comment.