@@ -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) | |||
@@ -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); | |||
}; | |||
@@ -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(); | |||
} | |||