From c43446e2cbed7af5b98340cbada117c5f233751b Mon Sep 17 00:00:00 2001 From: NorbiPeti Date: Sat, 15 May 2021 03:00:35 +0200 Subject: [PATCH] Add USING_STEAM checks --- GCMM/MainForm.cs | 6 ++++++ GCMM/MainUtils.cs | 12 ++++++++++++ GCMM/SettingsForm.cs | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/GCMM/MainForm.cs b/GCMM/MainForm.cs index 7ce5e09..19b0c9d 100644 --- a/GCMM/MainForm.cs +++ b/GCMM/MainForm.cs @@ -26,7 +26,9 @@ namespace GCMM private readonly ModInfo gcipa = new ModInfo { Author = "modtainers", Name = "GCIPA" }; private readonly ModInfo gcmm = new ModInfo { Author = "NorbiPeti", Name = "GCMM" }; private DateTime lastGameUpdateTime; +#if USING_STEAM private string steamPath; +#endif private const string defaultInfo = @" Techblox Mod Manager @@ -66,6 +68,7 @@ You may also want to verify the game's files by clicking on the Validate game bu mods.Clear(); //This method may get called twice when ran from the command line UpdateButton(installbtn, false); modinfobox.Text = defaultInfo; +#if USING_STEAM var (steamPath, user) = GetSteamLocationAndUser(); if (steamPath != null) this.steamPath = steamPath; @@ -87,6 +90,7 @@ You may also want to verify the game's files by clicking on the Validate game bu Settings.Default.AutoLaunch = false; Settings.Default.Save(); } +#endif if (string.IsNullOrWhiteSpace(Settings.Default.GamePath) || GetExe() == null) { Settings.Default.GamePath = GetGameFolder(); @@ -299,10 +303,12 @@ You may also want to verify the game's files by clicking on the Validate game bu return; string exe = GetExe(); File.Delete(GamePath($@"\{exe.Replace(".exe", "")}_Data\Managed\IllusionInjector.dll")); //Used to check if game is patched +#if USING_STEAM if (Environment.OSVersion.Platform == PlatformID.Win32NT) Process.Start("steam://validate/1078000/"); else Process.Start("xdg-open", "steam://validate/1078000/"); +#endif } private void MainForm_Shown(object sender, EventArgs e) diff --git a/GCMM/MainUtils.cs b/GCMM/MainUtils.cs index 378ca65..220860f 100644 --- a/GCMM/MainUtils.cs +++ b/GCMM/MainUtils.cs @@ -34,6 +34,7 @@ namespace GCMM public string GetGameFolder() { +#if USING_STEAM string libs; if (Environment.OSVersion.Platform == PlatformID.Win32NT) libs = steamPath + @"\steamapps\libraryfolders.vdf"; @@ -51,6 +52,8 @@ namespace GCMM return library + "Techblox"; } return null; +#endif + return null; //TODO } public string SelectGameFolder() @@ -58,7 +61,9 @@ namespace GCMM var ofd = new OpenFileDialog(); ofd.Filter = "Techblox executable|Techblox.exe|Techblox Preview executable|TechbloxPreview.exe"; ofd.Title = "Game location"; +#if USING_STEAM ofd.InitialDirectory = steamPath + @"\steamapps\common\"; +#endif //TODO ofd.CheckFileExists = true; ofd.ShowDialog(); if (string.IsNullOrWhiteSpace(ofd.FileName)) @@ -66,6 +71,7 @@ namespace GCMM return Directory.GetParent(ofd.FileName).FullName; } +#if USING_STEAM public (string, int) AskForSteamLogin() { while (MessageBox.Show("Couid not find your Steam configuration to set launch options.\n\n" + @@ -176,6 +182,7 @@ namespace GCMM else Settings.Default.AutoLaunch = false; } +#endif private (EventHandler, Task) CheckStartGame(string command) { @@ -197,10 +204,15 @@ namespace GCMM await CheckModUpdatesAsync(); Process.Start(command); } +#if USING_STEAM else if (Environment.OSVersion.Platform == PlatformID.Win32NT) Process.Start("steam://run/1078000/"); else Process.Start("xdg-open", "steam://run/1078000/"); +#else + if (Environment.OSVersion.Platform == PlatformID.Win32NT) + Process.Start(GamePath("\\" + GetExe())); +#endif EndWork(false); tcs.SetResult(null); }; diff --git a/GCMM/SettingsForm.cs b/GCMM/SettingsForm.cs index 074f11e..939080a 100644 --- a/GCMM/SettingsForm.cs +++ b/GCMM/SettingsForm.cs @@ -16,7 +16,9 @@ namespace GCMM public partial class SettingsForm : Form { private MainForm mainForm; +#if USING_STEAM private bool autopatchingEnabled; +#endif public SettingsForm() { InitializeComponent(); @@ -27,8 +29,10 @@ namespace GCMM gamelocation.Text = Settings.Default.GamePath; useProxy.Checked = Settings.Default.UseProxy; mainForm = Owner as MainForm; +#if USING_STEAM autopatchingEnabled = Settings.Default.SteamUserID != 0 && mainForm.UpdateOrGetSteamConfigToAutoStart(null); autopatching.Checked = autopatchingEnabled; +#endif } private void browsebtn_Click(object sender, EventArgs e) @@ -40,6 +44,7 @@ namespace GCMM { Settings.Default.GamePath = gamelocation.Text; Settings.Default.UseProxy = useProxy.Checked; +#if USING_STEAM if (autopatching.Checked != autopatchingEnabled) { if (autopatching.Checked && Settings.Default.SteamUserID == 0) @@ -52,6 +57,7 @@ namespace GCMM else mainForm.UpdateOrGetSteamConfigToAutoStart(autopatching.Checked); } +#endif Settings.Default.Save(); Close(); }