Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
/ ModManager Public archive

Commit

Permalink
Version 5.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MatuxGG committed Nov 20, 2022
1 parent b46a461 commit 3f10dff
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 49 deletions.
2 changes: 1 addition & 1 deletion MakeExecutableDotnet6.iss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "Installer\CodeDependencies.iss"

#define MyAppName "ModManager"
#define MyAppVersion "5.3.1"
#define MyAppVersion "5.3.2"
#define MyAppPublisher "Matux"
#define MyAppURL "https://goodloss.fr"
#define MyAppExeName "ModManager5.exe"
Expand Down
27 changes: 27 additions & 0 deletions ModManager5/Classes/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Config
public bool miniEnabled;
public bool multipleGames;
public List<string> availableAmongUsPaths;
public string supportId;

public Config(string modManagerVersion, List<InstalledMod> installedMods, List<InstalledVanilla> installedVanilla, string amongUsPath, string launcher, List<string> faroriteMods, bool miniEnabled, bool multipleGames)
{
Expand All @@ -30,6 +31,9 @@ public Config(string modManagerVersion, List<InstalledMod> installedMods, List<I
this.miniEnabled = miniEnabled;
this.multipleGames = multipleGames;
this.availableAmongUsPaths = new List<string>() { };
Random random = new Random();
this.supportId = new string(Enumerable.Repeat(ModManager.supportIdChars, 10)
.Select(s => s[random.Next(s.Length)]).ToArray());
}

public Config(string modManagerVersion, List<InstalledMod> installedMods, List<InstalledVanilla> installedVanilla, string amongUsPath, string launcher, List<string> faroriteMods, bool miniEnabled)
Expand All @@ -43,6 +47,9 @@ public Config(string modManagerVersion, List<InstalledMod> installedMods, List<I
this.miniEnabled = miniEnabled;
this.multipleGames = false;
this.availableAmongUsPaths = new List<string>() { };
Random random = new Random();
this.supportId = new string(Enumerable.Repeat(ModManager.supportIdChars, 10)
.Select(s => s[random.Next(s.Length)]).ToArray());
}

public Config(string modManagerVersion, List<InstalledMod> installedMods, List<InstalledVanilla> installedVanilla, string amongUsPath, string launcher, List<string> faroriteMods, bool miniEnabled, List<string> availableAmongUsPaths)
Expand All @@ -56,6 +63,23 @@ public Config(string modManagerVersion, List<InstalledMod> installedMods, List<I
this.miniEnabled = miniEnabled;
this.multipleGames = false;
this.availableAmongUsPaths = availableAmongUsPaths;
Random random = new Random();
this.supportId = new string(Enumerable.Repeat(ModManager.supportIdChars, 10)
.Select(s => s[random.Next(s.Length)]).ToArray());
}

public Config(string modManagerVersion, List<InstalledMod> installedMods, List<InstalledVanilla> installedVanilla, string amongUsPath, string launcher, List<string> faroriteMods, bool miniEnabled, List<string> availableAmongUsPaths, string supportId)
{
this.ModManagerVersion = modManagerVersion;
this.installedMods = installedMods;
this.installedVanilla = installedVanilla;
this.amongUsPath = amongUsPath;
this.launcher = launcher;
this.favoriteMods = faroriteMods;
this.miniEnabled = miniEnabled;
this.multipleGames = false;
this.availableAmongUsPaths = availableAmongUsPaths;
this.supportId = supportId;
}

public Config()
Expand All @@ -70,6 +94,9 @@ public Config()
this.miniEnabled = true;
this.multipleGames = false;
this.availableAmongUsPaths = new List<string>() { };
Random random = new Random();
this.supportId = new string(Enumerable.Repeat(ModManager.supportIdChars, 10)
.Select(s => s[random.Next(s.Length)]).ToArray());
}

}
Expand Down
3 changes: 3 additions & 0 deletions ModManager5/Classes/ConfigManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ public static void logConfig()
{
Utils.logE("Loading MM Config FAIL", "ConfigManager");
Utils.logEx(e, "ConfigManager");
Utils.logToServ(e, "ConfigManager");
}
}
public static void logGlobalConfig()
Expand Down Expand Up @@ -329,6 +330,7 @@ public static void logGlobalConfig()
{
Utils.logE("Loading computer info FAIL", "ConfigManager");
Utils.logEx(e, "ConfigManager");
Utils.logToServ(e, "ConfigManager");
}

Utils.log("MM Global Config", "ConfigManager");
Expand All @@ -343,6 +345,7 @@ public static void logGlobalConfig()
{
Utils.logE("Loading MM Global Config FAIL", "ConfigManager");
Utils.logEx(e, "ConfigManager");
Utils.logToServ(e, "ConfigManager");
}
}

Expand Down
9 changes: 5 additions & 4 deletions ModManager5/Classes/ModList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public static void load()
ModManagerUI.StatusLabel.Text = Translator.get("Loading Mods...");
string modlistURL = ModManager.apiURL + "/mod";
string modlist = "";
challengerClient = null;
challengerClientBeta = null;
try
{
using (var client = new WebClient())
Expand Down Expand Up @@ -141,10 +143,10 @@ public static async Task loadRelease(Mod m)
{
await m.getGithubRelease();
}
else if (m.id == "Challenger")
else if (m.id == "Challenger" && challengerClient == null)
{
await getChallengerReleases(m, true);
} else if (m.id == "ChallengerBeta")
} else if (m.id == "ChallengerBeta" && challengerClientBeta == null)
{
await getChallengerReleases(m, false);
}
Expand All @@ -159,8 +161,6 @@ public static async Task getChallengerReleases(Mod m, Boolean live)
IReadOnlyList<Release> releases = await client.Repository.Release.GetAll(m.author, m.github);
m.release = releases.First();
// There is no management of Challenger down because we assume that it will be always up
challengerClient = null;
challengerClientBeta = null;
Release challengerMod = null;
foreach (Release r in releases)
{
Expand Down Expand Up @@ -218,6 +218,7 @@ public static void createShortcut(Mod m)
} catch (Exception e)
{
Utils.logEx(e, "ModList");
Utils.logToServ(e, "ModList");
}

shortcut.Save();
Expand Down
26 changes: 14 additions & 12 deletions ModManager5/Classes/ModManagerUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -855,18 +855,10 @@ public static void refreshModForm(Form f)
{
ModWorker.startTransaction();
StatusLabel.Text = Translator.get("Adding local mod...");
string newPath = ModManager.appDataPath + @"\localMods\" + ModTitle.Text;
Directory.CreateDirectory(newPath);
string tempPath = ModManager.tempPath + @"\ModZip";
Utils.DirectoryDelete(tempPath);
Directory.CreateDirectory(tempPath);
string vanillaDestPath = ModManager.appDataPath + @"\vanilla\" + ModVersion.Text;
ZipFile.ExtractToDirectory(FileButton.Text, tempPath);
tempPath = ModWorker.getBepInExInsideRec(tempPath);
Utils.DirectoryCopy(vanillaDestPath, newPath, true);
Utils.DirectoryCopy(tempPath, newPath, true);
string newPath = ModManager.appDataPath + @"\localMods\" + ModTitle.Text + ".zip";
Utils.FileCopy(FileButton.Text, newPath);
Mod newLocalMod = new Mod(ModTitle.Name, ModTitle.Text, "local", "local", ModVersion.Text, new List<string>() { }, "", @"localMods\"+ModTitle.Text, "0", "", "", "", "") ;
Mod newLocalMod = new Mod(ModTitle.Name, ModTitle.Text, "local", "local", ModVersion.Text, new List<string>() { }, "", @"localMods\"+ModTitle.Text+".zip", "0", "", "", "", "") ;
ModList.localMods.Add(newLocalMod);
Expand All @@ -890,7 +882,8 @@ public static void refreshModForm(Form f)
Mod m = ModList.getLocalModById(modId);
string path = m.github.Replace(@"localMods\", ModManager.appDataPath + @"\localMods\");
Utils.DirectoryDelete(path);
Utils.FileDelete(path);
ModList.localMods.Remove(m);
ModList.updateLocalMods();
Expand Down Expand Up @@ -1243,6 +1236,15 @@ public static void loadSettings()

SettingsForm.Controls.Add(Visuals.SettingsButton(ResetButton, Translator.get("Reset")));

// Support Id
MMButton SupportIdButton = new MMButton("trans");
SupportIdButton.Click += new EventHandler((object sender, EventArgs e) =>
{
Clipboard.SetText(ConfigManager.config.supportId);
});

SettingsForm.Controls.Add(Visuals.SettingsButton(SupportIdButton, Translator.get("Copy Support Id")));

// Send log
MMButton LogButton = new MMButton("trans");
LogButton.Click += new EventHandler((object sender, EventArgs e) =>
Expand Down
75 changes: 45 additions & 30 deletions ModManager5/Classes/ModWorker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,52 +115,66 @@ public static void startMod(Mod m)
//startSteam();
if (m.type == "local")
{
string dirPath = ModManager.appDataPath + @"\localMods\" + m.name;
string dirPath = ModManager.appDataPath + @"\localMods\" + m.name + ".zip";

if (!ModManager.silent)
ModManagerUI.StatusLabel.Text = Translator.get("Starting MODNAME ... Please wait...").Replace("MODNAME", m.name);

if (!ConfigManager.config.multipleGames && isGameOpen()) return;

if (ConfigManager.config.launcher != "Steam")
{
cleanGame();
Utils.DirectoryCopy(dirPath, ConfigManager.config.amongUsPath, true);

string newPath = ModManager.tempPath + @"\ModZip";
Utils.DirectoryDelete(newPath);
Directory.CreateDirectory(newPath);
try
{
ZipFile.ExtractToDirectory(dirPath, newPath);
}
catch (Exception ex)
{
Utils.logE("Local mod zip extraction FAIL", "ModWorker");
Utils.logEx(ex, "ModWorker");
Utils.logToServ(ex, "ModWorker");
return;
}
newPath = getBepInExInsideRec(newPath);

Utils.DirectoryCopy(newPath, ConfigManager.config.amongUsPath, true);
Process.Start("explorer", ConfigManager.config.amongUsPath + @"\Among Us.exe");
}
else
{
string dirPathLocal = ModManager.appDataPath + @"\localMods\" + m.name + @"-work";
string vanillaDestPath = ModManager.appDataPath + @"\vanilla\" + m.gameVersion;

if (!ConfigManager.containsGameVersion(m.gameVersion))
string vanillaPath = ModManager.appDataPath + @"\vanilla\" + m.gameVersion;
string playPath = ModManager.appDataPath + @"\epicplay";
Utils.DirectoryDelete(playPath);
Utils.DirectoryCreate(playPath);

string newPath = ModManager.tempPath + @"\ModZip";
Utils.DirectoryDelete(newPath);
Directory.CreateDirectory(newPath);
try
{
string tempPath = ModManager.tempPath + @"\" + m.gameVersion + ".zip";
Utils.FileDelete(tempPath);

DownloadWorker.download(ModManager.fileURL + @"/client/" + m.gameVersion + @".zip", tempPath, Translator.get("Installing MODNAME, please wait...").Replace("MODNAME", m.name) + "\n(PERCENT)", 0, 100);

Utils.DirectoryDelete(vanillaDestPath);
Directory.CreateDirectory(vanillaDestPath);
try
{
ZipFile.ExtractToDirectory(tempPath, vanillaDestPath);
}
catch (Exception ex)
{
Utils.logE("Client zip extraction FAIL", "ModWorker");
Utils.logEx(ex, "ModWorker");
return;
}
ConfigManager.config.installedVanilla.Add(new InstalledVanilla(m.gameVersion));
ConfigManager.update();
ZipFile.ExtractToDirectory(dirPath, newPath);
}
catch (Exception ex)
{
Utils.logE("Local mod zip extraction FAIL", "ModWorker");
Utils.logEx(ex, "ModWorker");
Utils.logToServ(ex, "ModWorker");
return;
}
newPath = getBepInExInsideRec(newPath);

Utils.DirectoryDelete(dirPathLocal);
Utils.DirectoryCreate(dirPathLocal);
Utils.DirectoryCopy(vanillaDestPath, dirPathLocal, true);
Utils.DirectoryCopy(dirPath, dirPathLocal, true);
Process.Start("explorer", dirPathLocal + @"\Among Us.exe");
Utils.DirectoryCopy(vanillaPath, playPath, true);
Utils.DirectoryCopy(newPath, playPath, true);

Process.Start("explorer", playPath + @"\Among Us.exe");
}


if (!ModManager.silent)
ModManagerUI.StatusLabel.Text = Translator.get("MODNAME started.").Replace("MODNAME", m.name);

Expand Down Expand Up @@ -758,6 +772,7 @@ private static void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
Utils.logE("Client zip extraction FAIL", "ModWorker");
Utils.logEx(ex, "ModWorker");
Utils.logToServ(ex, "ModWorker");
backgroundWorker.ReportProgress(100);
}
ConfigManager.config.installedVanilla.Add(new InstalledVanilla(m.gameVersion));
Expand Down
26 changes: 26 additions & 0 deletions ModManager5/Classes/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Windows.Forms;

namespace ModManager5.Classes
Expand Down Expand Up @@ -79,6 +82,29 @@ public static void logEx(Exception e, string className)
Utils.logE("Source: " + e.Source, className);
}

public static void logToServ(Exception e, string className)
{
logToServ("Mod Manager " + ModManager.visibleVersion + " - Client id: " + ConfigManager.config.supportId + " - Class: " + className + " - Message: " + e.Message + " - Source = " + e.Source);
}

public static void logToServ(string text)
{
if (!String.IsNullOrEmpty(text))
{
using (var client = new WebClient())
{
var values = new NameValueCollection();
values["text"] = text;

var response = client.UploadValues(ModManager.apiURL + "/log", values);

var responseString = Encoding.Default.GetString(response);

}
}

}

// Spec : str <= 15
public static string getTabs(string str)
{
Expand Down
29 changes: 29 additions & 0 deletions ModManager5/Classes/VersionUpdater.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ModManager5.Classes
{
public static class VersionUpdater
{
public static void applyUpdates(string oldVersion, string newVersion)
{
if (Version.Parse(oldVersion) < Version.Parse("5.3.2"))
{
ModList.localMods = new List<Mod>() { };
string localPath = ModManager.appDataPath + @"\localMods\";
Utils.DirectoryDelete(localPath);
Utils.DirectoryCreate(localPath);
ModList.updateLocalMods();
}

if (oldVersion != newVersion)
{
ConfigManager.config.ModManagerVersion = newVersion;
ConfigManager.update();
}
}
}
}
3 changes: 3 additions & 0 deletions ModManager5/ModManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public partial class ModManager : Form
public static Version version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
public static string visibleVersion = version.ToString().Substring(0, version.ToString().Length - 2);
public static string token = System.IO.File.ReadAllText(appPath + @"\token.txt");
public static string supportIdChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789";

public static bool debug = false;

Expand Down Expand Up @@ -152,6 +153,8 @@ public async Task Start(string[] args)
ConfigManager.updateGlobalConfig();
}

VersionUpdater.applyUpdates(ConfigManager.config.ModManagerVersion, visibleVersion);

if (args.Count() > 0)
{
Utils.log("Starting mod from a shortcut", "ModManager");
Expand Down
4 changes: 2 additions & 2 deletions ModManager5/ModManager5.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
<TargetFramework>net6.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>modmanager.ico</ApplicationIcon>
<AssemblyVersion>5.3.1.0</AssemblyVersion>
<FileVersion>5.3.1.0</FileVersion>
<AssemblyVersion>5.3.2.0</AssemblyVersion>
<FileVersion>5.3.2.0</FileVersion>
</PropertyGroup>
<ItemGroup>
<COMReference Include="IWshRuntimeLibrary">
Expand Down
Loading

0 comments on commit 3f10dff

Please sign in to comment.