Skip to content

Commit

Permalink
Enable Rich Presence only after the activated region is set
Browse files Browse the repository at this point in the history
might fix #402
  • Loading branch information
gablm committed Mar 2, 2024
1 parent 58ca6d0 commit 448ff77
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 1 addition & 5 deletions CollapseLauncher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public static void Main(params string[] args)

Process.GetCurrentProcess().PriorityBoostEnabled = true;

InitializeAppSettings();
ParseArguments(args);
InitializeAppSettings();

HttpLogInvoker.DownloadLog += HttpClientLogWatcher;

Expand Down Expand Up @@ -218,10 +218,6 @@ public static void InitializeAppSettings()
CurrentAppTheme = AppThemeMode.Dark;
LogWriteLine($"ThemeMode: {themeValue} is invalid! Falling back to Dark-mode (Valid values are: {string.Join(',', Enum.GetNames(typeof(AppThemeMode)))})", LogType.Warning, true);
}
#if !DISABLEDISCORD
bool isInitialStart = GetAppConfigValue("EnableDiscordRPC").ToBool();
AppDiscordPresence = new DiscordPresenceManager(isInitialStart);
#endif
}

public static void RunElevateUpdate()
Expand Down
13 changes: 12 additions & 1 deletion CollapseLauncher/XAMLs/MainApp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using CollapseLauncher.Pages;
using CollapseLauncher.Statics;
using Hi3Helper;
using Hi3Helper.DiscordPresence;
using Hi3Helper.Preset;
using Hi3Helper.Shared.ClassStruct;
using InnoSetupHelper;
Expand Down Expand Up @@ -153,9 +154,16 @@ private async Task InitializeStartup()
{
LoadConfigV2();
SetActivatedRegion();

Page = typeof(HomePage);
}

#if !DISABLEDISCORD
bool isInitialStart = GetAppConfigValue("EnableDiscordRPC").ToBool();
AppDiscordPresence = new DiscordPresenceManager(isInitialStart);
AppDiscordPresence.SetActivity(ActivityType.Idle);
#endif

// Lock ChangeBtn for first start
LockRegionChangeBtn = true;

Expand Down Expand Up @@ -1808,7 +1816,6 @@ private bool SetActivatedRegion()
return true;

string oldGameCategory = GetAppConfigValue("GameCategory").ToString();
string oldGameRegion = GetAppConfigValue("GameRegion").ToString();

string GameName = args.Game;

Expand All @@ -1834,6 +1841,10 @@ private bool SetActivatedRegion()
GameRegion = ConfigV2GameRegions[Region];
}

string oldGameRegion = ConfigV2GameRegions.ElementAt(GetPreviousGameRegion(GameName));
if (oldGameRegion == null)
return true;

SetPreviousGameRegion(GameName, GameRegion);
SetAndSaveConfigValue("GameRegion", GameRegion);

Expand Down

0 comments on commit 448ff77

Please sign in to comment.