Skip to content

Commit

Permalink
Merge pull request #289 from X-Hax/settings-tab-rework
Browse files Browse the repository at this point in the history
Settings tab, profile and dependencies rework
  • Loading branch information
Sora-yx authored Jan 31, 2025
2 parents 648bbc5 + 8aee98e commit 5c96415
Show file tree
Hide file tree
Showing 54 changed files with 1,772 additions and 848 deletions.
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/01-bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "Bug Report"
description: "File a Bug Report"
title: "[Bug Report]: "
labels: ["bug"]
body:
- type: checkboxes
attributes:
label: Report Verification
description: Please confirm that this report you are submitting is for the Mod Manager. If it is for game crashes pertaining to the Mod Loader, please report those to the corresponding repository. If it's a mod related issue, please report that to the mod developer. Please also confirm that you have checked the Issues to ensure this issue has not already been reported.
options:
- label: This report is for a bug with the SA Mod Manager.
required: true
- label: I have checked and verified this issue has not been reported previously.
required: true
- type: textarea
attributes:
label: Bug Description
description: Please provide a clear and concise description of the bug you're experiencing.
validations:
required: true
- type: textarea
attributes:
label: Reproduction Steps
description: Please provide the steps you were taking when the bug occurred.
value: |
1.
2.
3.
...
validations:
required: true
- type: textarea
attributes:
label: Operating System
description: Please provide what your operating system is.
placeholder: e.g. Windows 10, Linux Mint, MacOS, SteamOS (SteamDeck), etc.
validations:
required: true
- type: textarea
attributes:
label: Additional Information
description: Please provide any additional information you believe may pertain to this bug. You can provide screenshots, videos, and any potential logs by clicking this area to highlight it, then dragging the file(s) in.
validations:
required: false
17 changes: 17 additions & 0 deletions .github/ISSUE_TEMPLATE/02-feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "Feature Request"
description: "Request new features or alterations to the program here. Please be mindful that while you can make a request, we will not always accept it as it may not align with features we need and/or want."
title: "[Feature Request]: "
labels: ["enhancement"]
body:
- type: textarea
attributes:
label: Request Details
description: Please explain what the feature is you're requesting.
validations:
required: true
- type: textarea
attributes:
label: Additional Information
description: If you have any additional information you would like to provide, please do so here. You can include screenshots by highlighting the box and dragging in your images.
validations:
required: false
37 changes: 0 additions & 37 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: SADX Mod Loader Issue Reporting
url: https://github.com/X-Hax/sadx-mod-loader/issues
about: Issues with SADX involving the Mod Loader should be reported here.
- name: SA2 Mod Loader Issue Reporting
url: https://github.com/X-Hax/sa2-mod-loader/issues
about: Issues with SA2 involving the Mod Loader should be reported here.
162 changes: 101 additions & 61 deletions SA-Mod-Manager/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,52 @@
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Text;
using System.Collections.ObjectModel;
using SAModManager.Management;

namespace SAModManager
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
///

public partial class App : Application
{
private const string pipeName = "sa-mod-manager";
public static Version Version = Assembly.GetExecutingAssembly().GetName().Version;
public static string VersionString = $"{Version.Major}.{Version.Minor}.{Version.Revision}";
public static readonly string StartDirectory = AppDomain.CurrentDomain.BaseDirectory;
public static string ConfigFolder = Directory.Exists(Path.Combine(StartDirectory, "SAManager")) ? Path.Combine(StartDirectory, "SAManager") : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SAManager");
public static string extLibPath = Path.Combine(ConfigFolder, "extlib");
public static readonly string tempFolder = Path.Combine(StartDirectory, "SATemp");
public static string crashFolder = Path.Combine(ConfigFolder, "CrashDump");
public static bool isVanillaTransition = false; //used when installing the manager from an update
public static bool isFirstBoot = false; //used when installing the new manager manually
public static bool isLinux = false;
public static bool CancelUpdate = false;
public static bool isDebug = false;

public static string ManagerConfigFile = Path.Combine(ConfigFolder, "Manager.json");
public static ManagerSettings ManagerSettings { get; set; }
public static Profiles Profiles { get; set; }

private static readonly Mutex mutex = new(true, pipeName);
public static Updater.UriQueue UriQueue;
public static string RepoCommit = SAModManager.Properties.Resources.Version.Trim();

public static LangEntry CurrentLang { get; set; }
public static LanguageList LangList { get; set; }

public static ThemeEntry CurrentTheme { get; set; }
public static bool IsLightTheme = false;
public static ThemeList ThemeList { get; set; }
public static List<string> UpdateChannels { get; set; } = ["Release", "Development"];
public static string CurrentChannel { get; set; } = string.IsNullOrEmpty(RepoCommit) ? UpdateChannels[0] : UpdateChannels[1];

public static Game CurrentGame = new();
public static List<Game> GamesList = new();
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
///

public partial class App : Application
{
private const string pipeName = "sa-mod-manager";
public static Version Version = Assembly.GetExecutingAssembly().GetName().Version;
public static string VersionString = $"{Version.Major}.{Version.Minor}.{Version.Revision}";
public static readonly string StartDirectory = AppDomain.CurrentDomain.BaseDirectory;
public static string ConfigFolder = Directory.Exists(Path.Combine(StartDirectory, "SAManager")) ? Path.Combine(StartDirectory, "SAManager") : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "SAManager");
public static string oldExtLibPath = Path.Combine(ConfigFolder, "extlib"); //for migration
public static string extLibPath = oldExtLibPath; //will be updated if a game is set as new path use mods folder
public static readonly string tempFolder = Path.Combine(StartDirectory, "SATemp");
public static string crashFolder = Path.Combine(ConfigFolder, "CrashDump");
public static bool isVanillaTransition = false; //used when installing the manager from an update
public static bool isFirstBoot = false; //used when installing the new manager manually
public static bool isLinux = false;
public static bool CancelUpdate = false;
public static bool isDebug = false;

public static string ManagerConfigFile = Path.Combine(ConfigFolder, "Manager.json");
public static ManagerSettings ManagerSettings { get; set; }
public static Profiles Profiles { get; set; }

private static readonly Mutex mutex = new(true, pipeName);
public static Updater.UriQueue UriQueue;
public static string RepoCommit = SAModManager.Properties.Resources.Version.Trim();

public static LangEntry CurrentLang { get; set; }
public static LanguageList LangList { get; set; }

public static ThemeEntry CurrentTheme { get; set; }
public static bool IsLightTheme = false;
public static ThemeList ThemeList { get; set; }
public static List<string> UpdateChannels { get; set; } = ["Release", "Development"];
public static string CurrentChannel { get; set; } = string.IsNullOrEmpty(RepoCommit) ? UpdateChannels[0] : UpdateChannels[1];

public static Game CurrentGame = new();
public static ObservableCollection<Game> GamesList = new();

[STAThread]
/// <summary>
Expand Down Expand Up @@ -108,7 +111,7 @@ protected override async void OnStartup(StartupEventArgs e)
Steam.Init();
SetupLanguages();
SetupThemes();
ManagerSettings = LoadManagerConfig();
LoadManagerConfig();
await SAModManager.Startup.StartupCheck();

await InitUriAsync(args, alreadyRunning);
Expand All @@ -134,6 +137,24 @@ protected override async void OnStartup(StartupEventArgs e)

}

public static void UpdateDependenciesLocation()
{
if (Directory.Exists(App.extLibPath) == false && Directory.Exists(App.oldExtLibPath))
{
Util.CreateSafeDirectory(App.extLibPath);

foreach (string dirPath in Directory.GetDirectories(App.oldExtLibPath, "*", SearchOption.AllDirectories))
{
Util.CreateSafeDirectory(dirPath.Replace(App.oldExtLibPath, App.extLibPath));
}

foreach (string newPath in Directory.GetFiles(App.oldExtLibPath, "*.*", SearchOption.AllDirectories))
{
File.Copy(newPath, newPath.Replace(App.oldExtLibPath, App.extLibPath), true);
}
}
}

public static void SetupLanguages()
{
var resource = Current.TryFindResource("Languages");
Expand Down Expand Up @@ -473,7 +494,7 @@ public static async Task<bool> PerformUpdateManagerCheck()
changelog.AppendLine(string.Format("Revision {0}\n{1}\n", release.TagName, release.Body));
}
}


return (hasUpdate, targetAsset, release.TagName, changelog);

Expand Down Expand Up @@ -627,6 +648,22 @@ private static void SetExeCommands(string[] args)
}
}

public static void ExtractResource(string resourceName, string outputPath)
{

Assembly assembly = Assembly.GetExecutingAssembly();
string fullResourceName = assembly.GetName().Name + ".Resources." + resourceName;
using Stream stream = assembly.GetManifestResourceStream(fullResourceName);
if (stream == null)
{
Console.WriteLine($"Resource not found: {fullResourceName}");
return;
}

using FileStream fileStream = File.Create(outputPath);
stream.CopyTo(fileStream);
}

public static Uri GetResourceUri(string resourceName)
{
// Get the assembly where the resource is located
Expand Down Expand Up @@ -655,29 +692,32 @@ public static Uri GetResourceUri(string resourceName)
return new Uri($"file://{tempFilePath}");
}

private static ManagerSettings LoadManagerConfig()
private static void LoadManagerConfig()
{
ManagerSettings settings = ManagerSettings.Deserialize(Path.Combine(ConfigFolder, ManagerConfigFile));
SettingsManager.InitializeSettingsManager();

if (settings is not null)
if (ManagerSettings is not null)
{

switch (settings.CurrentSetGame)
{
case (int)SetGame.None:
CurrentGame = GamesInstall.Unknown;
break;
case (int)SetGame.SADX:
CurrentGame = GamesInstall.SonicAdventure;
break;
case (int)SetGame.SA2:
CurrentGame = GamesInstall.SonicAdventure2;
break;
}

if (ManagerSettings.GameEntries.Count() > 0)
{
switch (SettingsManager.GetCurrentGame().Type)
{
case GameEntry.GameType.Unsupported:
CurrentGame = GamesInstall.Unknown;
break;
case GameEntry.GameType.SADX:
CurrentGame = GamesInstall.SonicAdventure;
CurrentGame.gameDirectory = SettingsManager.GetCurrentGame().Directory;
break;
case GameEntry.GameType.SA2:
CurrentGame = GamesInstall.SonicAdventure2;
CurrentGame.gameDirectory = SettingsManager.GetCurrentGame().Directory;
break;
}
}
else
CurrentGame = GamesInstall.Unknown;
}

return settings;
}

public static async Task EnableOneClickInstall()
Expand Down
6 changes: 0 additions & 6 deletions SA-Mod-Manager/Configuration/LoaderInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@

namespace SAModManager.Configuration
{
public enum GameType
{
SADX,
SA2
}

public enum UpdateUnit
{
Always,
Expand Down
Loading

0 comments on commit 5c96415

Please sign in to comment.