Browse Source

Add debug code and update version

tags/v1.6.0
NorbiPeti 2 years ago
parent
commit
62963b6fd2
2 changed files with 12 additions and 1 deletions
  1. +11
    -0
      TBMM/MainUtils.cs
  2. +1
    -1
      TBMM/TBMM.csproj

+ 11
- 0
TBMM/MainUtils.cs View File

@@ -109,6 +109,7 @@ namespace TBMM

private void HandleGameExit(object sender, EventArgs e)
{
Debug.WriteLine("Handling game exit");
_gameProcess = (null, false);
if (InvokeMethod(CheckIfPatched) != GameState.Patched || Configuration.KeepPatched)
return;
@@ -128,27 +129,37 @@ namespace TBMM

private bool CheckIfGameIsRunning()
{
Debug.WriteLine($"Check if game is running: {_gameProcess}");
switch (_gameProcess.Process)
{
case { HasExited: false }:
Debug.WriteLine("Game has not exited");
return true;
case { HasExited: true }:
Debug.WriteLine("Game has exited, dialog shown");
MessageBox.Show("Game has exited without handling... Please report.");
HandleGameExit(null, EventArgs.Empty);
return false;
default:
Debug.WriteLine($"Process seems to be null: {_gameProcess}");
if (_gameProcess.Process?.HasExited ?? true)
{
_gameProcess = (Process.GetProcessesByName(GetExe(withExtension: false)).FirstOrDefault(), false);
Debug.WriteLine($"Game process exited already, got new process object: {_gameProcess}");
}

if (_gameProcess.Process == null) return false;
if (_gameProcess.Process.HasExited)
{
Debug.WriteLine($"Game has exited already: {_gameProcess}");
HandleGameExit(null, EventArgs.Empty);
return false;
}
else
{
Debug.WriteLine($"Game is still running");
if (_gameProcess.ExitHandlerAdded) return true;
Debug.WriteLine("Game running and no exit handler yet, adding it");
_gameProcess.Process.Exited += HandleGameExit;
_gameProcess.Process.EnableRaisingEvents = true;
_gameProcess.ExitHandlerAdded = true;


+ 1
- 1
TBMM/TBMM.csproj View File

@@ -6,7 +6,7 @@
<UseWindowsForms>true</UseWindowsForms>
<SignAssembly>false</SignAssembly>
<ApplicationIcon>favicon.ico</ApplicationIcon>
<Version>1.5.0</Version>
<Version>1.6.0</Version>
<Authors>NorbiPeti</Authors>
<Company>ExMods</Company>
<Description>A mod manager for Techblox. It automatically downloads and runs GCIPA and allows the user to install mods.</Description>


Loading…
Cancel
Save