Skip to content

Commit b642599

Browse files
committed
Move config file location at the same path as the app folder
Issue: #79
1 parent e432639 commit b642599

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

Hi3Helper.Core/Classes/Shared/Region/Config/LauncherConfig.cs

+24-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public static class LauncherConfig
5454
public static AppIniStruct appIni = new AppIniStruct();
5555

5656
public static string AppCurrentVersion;
57-
public static string AppFolder = AppDomain.CurrentDomain.BaseDirectory;
57+
public static string AppFolder = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
58+
public static string AppConfigFolder = Path.Combine(AppFolder, "Config");
5859
public static string AppDefaultBG = Path.Combine(AppFolder, "Assets", "BG", "default.png");
5960
public static string AppLangFolder = Path.Combine(AppFolder, "Lang");
6061
public static string AppDataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "LocalLow", "CollapseLauncher");
@@ -72,8 +73,9 @@ public static string AppExecutablePath {
7273
}
7374
public static string AppGameImgFolder { get => Path.Combine(AppGameFolder, "_img"); }
7475
public static string AppGameLogsFolder { get => Path.Combine(AppGameFolder, "_logs"); }
75-
public static string AppConfigFile = Path.Combine(AppDataFolder, "config.ini");
76-
public static string AppNotifIgnoreFile = Path.Combine(AppDataFolder, "ignore_notif_ids.json");
76+
public static string AppConfigFile = Path.Combine(AppConfigFolder, "config.ini");
77+
public static string AppConfigFileOld = Path.Combine(AppDataFolder, "config.ini");
78+
public static string AppNotifIgnoreFile = Path.Combine(AppConfigFolder, "ignore_notif_ids.json");
7779
public static string GamePathOnSteam;
7880

7981
public static string AppNotifURLPrefix => GetCurrentCDN().URLPrefix + "/notification_{0}.json";
@@ -157,6 +159,8 @@ public static void GetScreenResolutionString()
157159

158160
public static void InitAppPreset()
159161
{
162+
TryCopyOldConfig();
163+
160164
// Initialize resolution settings first and assign AppConfigFile to ProfilePath
161165
InitScreenResSettings();
162166
appIni.ProfilePath = AppConfigFile;
@@ -205,6 +209,23 @@ public static void InitAppPreset()
205209
IsFirstInstall = !(IsConfigFileExist && IsUserHasPermission);
206210
}
207211

212+
private static void TryCopyOldConfig()
213+
{
214+
try
215+
{
216+
if (File.Exists(AppConfigFileOld))
217+
{
218+
if (!Directory.Exists(AppConfigFolder))
219+
{
220+
Directory.CreateDirectory(AppConfigFolder);
221+
}
222+
223+
File.Move(AppConfigFileOld, AppConfigFile);
224+
}
225+
}
226+
catch { }
227+
}
228+
208229
private static bool IsDriveExist(string path)
209230
{
210231
return new DriveInfo(Path.GetPathRoot(path)).IsReady;

0 commit comments

Comments
 (0)