Skip to content

Commit

Permalink
Merge pull request #69 from GregLando113/dev
Browse files Browse the repository at this point in the history
r13.4 add checkbox "use plugin folder mods"
  • Loading branch information
DubbleClick authored Aug 26, 2023
2 parents e21751f + aea8204 commit ce1d974
Show file tree
Hide file tree
Showing 8 changed files with 2,033 additions and 1,959 deletions.
21 changes: 7 additions & 14 deletions GW Launcher/Classes/Account.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,20 @@

public class Account
{
[JsonIgnore] public bool active;

[JsonRequired] public string character = "";

public bool elevated;

[JsonRequired] public string email = "";

public string extraargs = "";

[JsonIgnore] public Guid? guid = Guid.NewGuid();

[JsonRequired] public string gwpath = "";

public List<Mod> mods = new();

[JsonRequired] public string password = "";
public string extraargs = "";
public bool elevated = false;
public string title = "";
public bool usePluginFolderMods = true;
public List<Mod> mods = new();

[JsonIgnore] public bool active;
[JsonIgnore] public GWCAMemory? process;
[JsonIgnore] public Guid? guid = Guid.NewGuid();

public string title = "";

public string Name
{
Expand Down
378 changes: 195 additions & 183 deletions GW Launcher/Forms/AddAccountForm.Designer.cs

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions GW Launcher/Forms/AddAccountForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ private void SaveAccount()
account.character = textBoxCharacter.Text;
account.gwpath = textBoxPath.Text;
account.elevated = checkBoxElevated.Checked;
account.usePluginFolderMods = checkBoxUsePluginFolderMods.Checked;
account.extraargs = textBoxExtraArguments.Text;
MainForm.OnAccountSaved(account);
}
Expand All @@ -37,6 +38,7 @@ private void AddAccountForm_Load(object sender, EventArgs e)
textBoxCharacter.Text = account.character;
textBoxPath.Text = account.gwpath;
checkBoxElevated.Checked = account.elevated;
checkBoxUsePluginFolderMods.Checked = account.usePluginFolderMods;
textBoxExtraArguments.Text = account.extraargs;
}

Expand Down
3,514 changes: 1,785 additions & 1,729 deletions GW Launcher/Forms/AddAccountForm.resx

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions GW Launcher/GW Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<Platforms>x86;AnyCPU</Platforms>
<PlatformTarget>x86</PlatformTarget>
<DebugType>portable</DebugType>
<AssemblyVersion>13.13</AssemblyVersion>
<FileVersion>13.13</FileVersion>
<AssemblyVersion>13.14</AssemblyVersion>
<FileVersion>13.14</FileVersion>
<Copyright>2015-2023 GregLando113</Copyright>
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
</PropertyGroup>
Expand All @@ -27,6 +27,14 @@
<WarningLevel>7</WarningLevel>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>7</WarningLevel>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<WarningLevel>7</WarningLevel>
</PropertyGroup>

<ItemGroup>
<COMReference Include="IWshRuntimeLibrary">
<WrapperTool>tlbimp</WrapperTool>
Expand Down
6 changes: 3 additions & 3 deletions GW Launcher/MulticlientPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static IntPtr GetProcessModuleBase(IntPtr process)

uModTexClient? texClient = null;

if (ModManager.GetTexmods(account.gwpath, account.mods).Any())
if (ModManager.GetTexmods(account.gwpath, account).Any())
{
texClient = new uModTexClient();
}
Expand Down Expand Up @@ -65,7 +65,7 @@ private static IntPtr GetProcessModuleBase(IntPtr process)

var memory = new GWCAMemory(process);

foreach (var dll in ModManager.GetDlls(path, account.mods))
foreach (var dll in ModManager.GetDlls(path, account))
{
memory.LoadModule(dll);
}
Expand All @@ -86,7 +86,7 @@ private static IntPtr GetProcessModuleBase(IntPtr process)
Thread.Sleep(200);
}

foreach (var tex in ModManager.GetTexmods(path, account.mods))
foreach (var tex in ModManager.GetTexmods(path, account))
{
if (Program.shouldClose || timeout >= 10)
{
Expand Down
2 changes: 1 addition & 1 deletion GW Launcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ GW Launcher will close.
}

var isPipeRunning = Directory.GetFiles(@"\\.\pipe\", @"Game2uMod").Any();
if (isPipeRunning && accounts.Any(a => ModManager.GetTexmods(a.gwpath, a.mods).Any()))
if (isPipeRunning && accounts.Any(a => ModManager.GetTexmods(a.gwpath, a).Any()))
{
MessageBox.Show(@"uMod may be running in the background. Textures may not load.");
}
Expand Down
57 changes: 30 additions & 27 deletions GW Launcher/Utilities/ModManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,54 @@ namespace GW_Launcher.Utilities;

public class ModManager
{
public static IOrderedEnumerable<string> GetDlls(string path, IReadOnlyCollection<Mod> mods)
public static IOrderedEnumerable<string> GetDlls(string path, Account account)
{
return GetMods(path, mods).Item1;
return GetMods(path, account).Item1;
}

public static IOrderedEnumerable<string> GetTexmods(string path, IReadOnlyCollection<Mod> mods)
public static IOrderedEnumerable<string> GetTexmods(string path, Account account)
{
return GetMods(path, mods).Item2;
return GetMods(path, account).Item2;
}

private static Tuple<IOrderedEnumerable<string>, IOrderedEnumerable<string>>
GetMods(string path, IReadOnlyCollection<Mod> mods)
GetMods(string path, Account account)
{
var directory = Path.Combine(Directory.GetCurrentDirectory(), "plugins");
var dllsToLoad = new List<string>();
var texsToLoad = new List<string>();
if (Directory.Exists(directory))
if (account.usePluginFolderMods)
{
var links = Directory.GetFiles(directory, "*.lnk");
var files = Directory.GetFiles(directory, "*.dll");
var dlllinks = links.Select(GetShortcutPath).Where(l => l.EndsWith(".dll")).ToArray();
var textures = Directory.GetFiles(directory, "*").Where(t => t.EndsWith(".tpf") || t.EndsWith(".zip"));
var directory = Path.Combine(Directory.GetCurrentDirectory(), "plugins");
if (Directory.Exists(directory))
{
var links = Directory.GetFiles(directory, "*.lnk");
var files = Directory.GetFiles(directory, "*.dll");
var dlllinks = links.Select(GetShortcutPath).Where(l => l.EndsWith(".dll")).ToArray();
var textures = Directory.GetFiles(directory, "*").Where(t => t.EndsWith(".tpf") || t.EndsWith(".zip"));

dllsToLoad.AddRange(files);
dllsToLoad.AddRange(dlllinks);
texsToLoad.AddRange(textures);
}
dllsToLoad.AddRange(files);
dllsToLoad.AddRange(dlllinks);
texsToLoad.AddRange(textures);
}

directory = Path.Combine(Path.GetDirectoryName(path)!, "plugins");
if (Directory.Exists(directory))
{
var links = Directory.GetFiles(directory, "*.lnk");
var files = Directory.GetFiles(directory, "*.dll");
var dlllinks = links.Select(GetShortcutPath).Where(l => l.EndsWith(".dll")).ToArray();
var textures = Directory.GetFiles(directory, "*").Where(t => t.EndsWith(".tpf") || t.EndsWith(".zip"));
directory = Path.Combine(Path.GetDirectoryName(path)!, "plugins");
if (Directory.Exists(directory))
{
var links = Directory.GetFiles(directory, "*.lnk");
var files = Directory.GetFiles(directory, "*.dll");
var dlllinks = links.Select(GetShortcutPath).Where(l => l.EndsWith(".dll")).ToArray();
var textures = Directory.GetFiles(directory, "*").Where(t => t.EndsWith(".tpf") || t.EndsWith(".zip"));

dllsToLoad.AddRange(dlllinks);
dllsToLoad.AddRange(files);
texsToLoad.AddRange(textures);
dllsToLoad.AddRange(dlllinks);
dllsToLoad.AddRange(files);
texsToLoad.AddRange(textures);
}
}

dllsToLoad.AddRange(mods
dllsToLoad.AddRange(account.mods
.Where(mod => mod is { type: ModType.kModTypeDLL, active: true } && File.Exists(mod.fileName))
.Select(mod => mod.fileName));
texsToLoad.AddRange(mods
texsToLoad.AddRange(account.mods
.Where(mod => mod is { type: ModType.kModTypeTexmod, active: true } && File.Exists(mod.fileName))
.Select(mod => mod.fileName));

Expand Down

1 comment on commit ce1d974

@BearsMan
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice update!

Please sign in to comment.