Add USING_STEAM checks
This commit is contained in:
parent
199e77c68f
commit
c43446e2cb
3 changed files with 24 additions and 0 deletions
|
@ -26,7 +26,9 @@ namespace GCMM
|
||||||
private readonly ModInfo gcipa = new ModInfo { Author = "modtainers", Name = "GCIPA" };
|
private readonly ModInfo gcipa = new ModInfo { Author = "modtainers", Name = "GCIPA" };
|
||||||
private readonly ModInfo gcmm = new ModInfo { Author = "NorbiPeti", Name = "GCMM" };
|
private readonly ModInfo gcmm = new ModInfo { Author = "NorbiPeti", Name = "GCMM" };
|
||||||
private DateTime lastGameUpdateTime;
|
private DateTime lastGameUpdateTime;
|
||||||
|
#if USING_STEAM
|
||||||
private string steamPath;
|
private string steamPath;
|
||||||
|
#endif
|
||||||
private const string defaultInfo = @"
|
private const string defaultInfo = @"
|
||||||
Techblox Mod Manager
|
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
|
mods.Clear(); //This method may get called twice when ran from the command line
|
||||||
UpdateButton(installbtn, false);
|
UpdateButton(installbtn, false);
|
||||||
modinfobox.Text = defaultInfo;
|
modinfobox.Text = defaultInfo;
|
||||||
|
#if USING_STEAM
|
||||||
var (steamPath, user) = GetSteamLocationAndUser();
|
var (steamPath, user) = GetSteamLocationAndUser();
|
||||||
if (steamPath != null)
|
if (steamPath != null)
|
||||||
this.steamPath = steamPath;
|
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.AutoLaunch = false;
|
||||||
Settings.Default.Save();
|
Settings.Default.Save();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (string.IsNullOrWhiteSpace(Settings.Default.GamePath) || GetExe() == null)
|
if (string.IsNullOrWhiteSpace(Settings.Default.GamePath) || GetExe() == null)
|
||||||
{
|
{
|
||||||
Settings.Default.GamePath = GetGameFolder();
|
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;
|
return;
|
||||||
string exe = GetExe();
|
string exe = GetExe();
|
||||||
File.Delete(GamePath($@"\{exe.Replace(".exe", "")}_Data\Managed\IllusionInjector.dll")); //Used to check if game is patched
|
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)
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||||
Process.Start("steam://validate/1078000/");
|
Process.Start("steam://validate/1078000/");
|
||||||
else
|
else
|
||||||
Process.Start("xdg-open", "steam://validate/1078000/");
|
Process.Start("xdg-open", "steam://validate/1078000/");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainForm_Shown(object sender, EventArgs e)
|
private void MainForm_Shown(object sender, EventArgs e)
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace GCMM
|
||||||
|
|
||||||
public string GetGameFolder()
|
public string GetGameFolder()
|
||||||
{
|
{
|
||||||
|
#if USING_STEAM
|
||||||
string libs;
|
string libs;
|
||||||
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||||
libs = steamPath + @"\steamapps\libraryfolders.vdf";
|
libs = steamPath + @"\steamapps\libraryfolders.vdf";
|
||||||
|
@ -51,6 +52,8 @@ namespace GCMM
|
||||||
return library + "Techblox";
|
return library + "Techblox";
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
#endif
|
||||||
|
return null; //TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
public string SelectGameFolder()
|
public string SelectGameFolder()
|
||||||
|
@ -58,7 +61,9 @@ namespace GCMM
|
||||||
var ofd = new OpenFileDialog();
|
var ofd = new OpenFileDialog();
|
||||||
ofd.Filter = "Techblox executable|Techblox.exe|Techblox Preview executable|TechbloxPreview.exe";
|
ofd.Filter = "Techblox executable|Techblox.exe|Techblox Preview executable|TechbloxPreview.exe";
|
||||||
ofd.Title = "Game location";
|
ofd.Title = "Game location";
|
||||||
|
#if USING_STEAM
|
||||||
ofd.InitialDirectory = steamPath + @"\steamapps\common\";
|
ofd.InitialDirectory = steamPath + @"\steamapps\common\";
|
||||||
|
#endif //TODO
|
||||||
ofd.CheckFileExists = true;
|
ofd.CheckFileExists = true;
|
||||||
ofd.ShowDialog();
|
ofd.ShowDialog();
|
||||||
if (string.IsNullOrWhiteSpace(ofd.FileName))
|
if (string.IsNullOrWhiteSpace(ofd.FileName))
|
||||||
|
@ -66,6 +71,7 @@ namespace GCMM
|
||||||
return Directory.GetParent(ofd.FileName).FullName;
|
return Directory.GetParent(ofd.FileName).FullName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if USING_STEAM
|
||||||
public (string, int) AskForSteamLogin()
|
public (string, int) AskForSteamLogin()
|
||||||
{
|
{
|
||||||
while (MessageBox.Show("Couid not find your Steam configuration to set launch options.\n\n" +
|
while (MessageBox.Show("Couid not find your Steam configuration to set launch options.\n\n" +
|
||||||
|
@ -176,6 +182,7 @@ namespace GCMM
|
||||||
else
|
else
|
||||||
Settings.Default.AutoLaunch = false;
|
Settings.Default.AutoLaunch = false;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private (EventHandler, Task) CheckStartGame(string command)
|
private (EventHandler, Task) CheckStartGame(string command)
|
||||||
{
|
{
|
||||||
|
@ -197,10 +204,15 @@ namespace GCMM
|
||||||
await CheckModUpdatesAsync();
|
await CheckModUpdatesAsync();
|
||||||
Process.Start(command);
|
Process.Start(command);
|
||||||
}
|
}
|
||||||
|
#if USING_STEAM
|
||||||
else if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
else if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||||
Process.Start("steam://run/1078000/");
|
Process.Start("steam://run/1078000/");
|
||||||
else
|
else
|
||||||
Process.Start("xdg-open", "steam://run/1078000/");
|
Process.Start("xdg-open", "steam://run/1078000/");
|
||||||
|
#else
|
||||||
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
||||||
|
Process.Start(GamePath("\\" + GetExe()));
|
||||||
|
#endif
|
||||||
EndWork(false);
|
EndWork(false);
|
||||||
tcs.SetResult(null);
|
tcs.SetResult(null);
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,9 @@ namespace GCMM
|
||||||
public partial class SettingsForm : Form
|
public partial class SettingsForm : Form
|
||||||
{
|
{
|
||||||
private MainForm mainForm;
|
private MainForm mainForm;
|
||||||
|
#if USING_STEAM
|
||||||
private bool autopatchingEnabled;
|
private bool autopatchingEnabled;
|
||||||
|
#endif
|
||||||
public SettingsForm()
|
public SettingsForm()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
@ -27,8 +29,10 @@ namespace GCMM
|
||||||
gamelocation.Text = Settings.Default.GamePath;
|
gamelocation.Text = Settings.Default.GamePath;
|
||||||
useProxy.Checked = Settings.Default.UseProxy;
|
useProxy.Checked = Settings.Default.UseProxy;
|
||||||
mainForm = Owner as MainForm;
|
mainForm = Owner as MainForm;
|
||||||
|
#if USING_STEAM
|
||||||
autopatchingEnabled = Settings.Default.SteamUserID != 0 && mainForm.UpdateOrGetSteamConfigToAutoStart(null);
|
autopatchingEnabled = Settings.Default.SteamUserID != 0 && mainForm.UpdateOrGetSteamConfigToAutoStart(null);
|
||||||
autopatching.Checked = autopatchingEnabled;
|
autopatching.Checked = autopatchingEnabled;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private void browsebtn_Click(object sender, EventArgs e)
|
private void browsebtn_Click(object sender, EventArgs e)
|
||||||
|
@ -40,6 +44,7 @@ namespace GCMM
|
||||||
{
|
{
|
||||||
Settings.Default.GamePath = gamelocation.Text;
|
Settings.Default.GamePath = gamelocation.Text;
|
||||||
Settings.Default.UseProxy = useProxy.Checked;
|
Settings.Default.UseProxy = useProxy.Checked;
|
||||||
|
#if USING_STEAM
|
||||||
if (autopatching.Checked != autopatchingEnabled)
|
if (autopatching.Checked != autopatchingEnabled)
|
||||||
{
|
{
|
||||||
if (autopatching.Checked && Settings.Default.SteamUserID == 0)
|
if (autopatching.Checked && Settings.Default.SteamUserID == 0)
|
||||||
|
@ -52,6 +57,7 @@ namespace GCMM
|
||||||
else
|
else
|
||||||
mainForm.UpdateOrGetSteamConfigToAutoStart(autopatching.Checked);
|
mainForm.UpdateOrGetSteamConfigToAutoStart(autopatching.Checked);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
Settings.Default.Save();
|
Settings.Default.Save();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue