Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added warning if user tries loading multiple of the same mod
- Loading branch information
Showing
8 changed files
with
70 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,59 @@ | ||
using BTD6_Mod_Manager.Lib; | ||
using BTD6_Mod_Manager.Lib.Game; | ||
using BTD6_Mod_Manager.Lib.MelonMods; | ||
using BTD6_Mod_Manager.Lib.Natives; | ||
using Ionic.Zip; | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Media.Media3D; | ||
using System.Linq; | ||
using static BTD6_Mod_Manager.Lib.MelonMods.MelonMod_Handler; | ||
|
||
namespace BTD6_Mod_Manager | ||
{ | ||
class Launcher | ||
{ | ||
public static void Launch() | ||
{ | ||
if (!AreModsValid()) | ||
return; | ||
|
||
var gameInfo = GameInfo.GetGame(SessionData.currentGame); | ||
|
||
if (!Utility.IsProgramRunning(gameInfo.ProcName, out var btd6Proc)) | ||
Process.Start("steam://rungameid/" + gameInfo.SteamID); | ||
else | ||
{ | ||
Logger.Log("Please close BTD6 to continue...", OutputType.Both); | ||
} | ||
|
||
private static bool AreModsValid() | ||
{ | ||
foreach (var mod in SessionData.loadedMods) | ||
{ | ||
string filePath = mod; | ||
if (IsFileZip(filePath)) | ||
continue; | ||
|
||
var melonInfo = MelonMod_Handler.GetModInfo(filePath); | ||
string melonModName = melonInfo.Name; | ||
|
||
var similarMods = SessionData.loadedMods.Count(dupMod => GetModInfo(dupMod)?.Name == melonModName); | ||
bool isDuplicate = (similarMods > 1); | ||
if (!isDuplicate) | ||
continue; | ||
|
||
Logger.Log($"Error! You are trying to load {melonModName} twice. You need to disable one to continue.", OutputType.Both); | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
private static bool IsFileZip(string filePath) | ||
{ | ||
FileInfo fileInfo = new FileInfo(filePath); | ||
bool isZip = (fileInfo.Extension == ".zip" || fileInfo.Extension == ".rar" || fileInfo.Extension == ".7z"); | ||
return isZip; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters