Cleanup logs, improve instant singleplayer UX a bit

This commit is contained in:
dginovker 2023-11-05 13:57:35 -05:00
parent 65db9e9c70
commit fb0dc2102c
4 changed files with 4 additions and 12 deletions

View file

@ -143,21 +143,14 @@ public static class SingleplayerManagement
public static T ParseConf<T>(string key, T defaultValue = default)
{
Console.WriteLine($"Getting key {key}..");
if (!File.Exists(ConfPath)) return defaultValue;
_confCache ??= GrabConfCache();
if (!_confCache.TryGetValue(key, out var value))
{
Console.WriteLine($"Cache not hit - returning default {value}");
return defaultValue;
}
Console.WriteLine($"Cache hit - returning {value}");
if (!_confCache.TryGetValue(key, out var value)) return defaultValue;
return (T)Convert.ChangeType(value, typeof(T));
}
public static void WriteConf(string key, object value)
{
Console.WriteLine($"Writing {key}");
_confCache[key] = value.ToString().ToLowerInvariant(); // Update cache
var filePath = CrossPlatform.GetSingleplayerHome() + "/game/worldprops/default.conf";
var lines = File.ReadAllLines(filePath).Select(l =>

View file

@ -64,10 +64,8 @@ public static class Windows
return;
}
log("Starting process");
Process serverProcess = StartJavaProcess(javaExecutableLocation, serverJar, "2G", log, null);
log("waiting process");
while (!IsPortInUse(43595)) Thread.Sleep(1000);
StartJavaProcess(javaExecutableLocation, clientJar, "1G", null, () =>

View file

@ -128,12 +128,13 @@ public class SingleplayerViewModel : ViewModelBase
);
if (!javaVersionOutput.Contains("11"))
{
PrintLog("You don't have Java 11 set! Saradomin will grab it's own copy..");
await _javaUpdateService.DownloadAndSetJava11(_settingsService);
}
CanLaunch = false;
PrintLog("Starting Singleplayer.. The Singleplayer client will launch when 2009scape is ready. Sit tight!");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
PrintLog("Starting windowsssssss");
new Task(() => Utilities.Singleplayer.Windows.WindowsLaunchServerAndClient(Launcher.JavaExecutableLocation, PrintLog)).Start();
}
else

View file

@ -278,7 +278,7 @@ namespace Saradomin.ViewModel.Windows
{
if (e.Item2)
{
LaunchText = "Play!";
LaunchText = "Play! (Multiplayer)";
return;
}
if (e.Item1 >= 0.999f)