Skip to content

Commit 90c241c

Browse files
authored
Merge pull request #970 from erdelf/master
adjusted setting of profile defaults and initialization
2 parents a00a231 + 8def75e commit 90c241c

File tree

2 files changed

+20
-10
lines changed

2 files changed

+20
-10
lines changed

AutoDuty/AutoDuty.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public AutoDuty()
228228
AssemblyDirectoryInfo = AssemblyFileInfo.Directory;
229229

230230
Version =
231-
((PluginInterface.IsDev ? new Version(0,0,0, 214) :
231+
((PluginInterface.IsDev ? new Version(0,0,0, 215) :
232232
PluginInterface.IsTesting ? PluginInterface.Manifest.TestingAssemblyVersion ?? PluginInterface.Manifest.AssemblyVersion : PluginInterface.Manifest.AssemblyVersion)!).Revision;
233233

234234
if (!_configDirectory.Exists)
@@ -261,12 +261,9 @@ public AutoDuty()
261261
WindowSystem.AddWindow(MainWindow);
262262
WindowSystem.AddWindow(Overlay);
263263

264-
if (Configuration.ShowOverlay && (!Configuration.HideOverlayWhenStopped || States.HasFlag(PluginState.Looping) || States.HasFlag(PluginState.Navigating)))
265-
SchedulerHelper.ScheduleAction("ShowOverlay", () => Overlay.IsOpen = true, () => PlayerHelper.IsReady);
266-
267-
if (Configuration.ShowMainWindowOnStartup)
268-
SchedulerHelper.ScheduleAction("ShowMainWindowOnStartup", () => OpenMainUI(), () => PlayerHelper.IsReady);
269-
264+
if (Svc.ClientState.IsLoggedIn)
265+
this.ClientStateOnLogin();
266+
270267
Svc.Commands.AddHandler("/ad", new CommandInfo(OnCommand) { });
271268
Svc.Commands.AddHandler(CommandName, new CommandInfo(OnCommand)
272269
{
@@ -317,9 +314,20 @@ public AutoDuty()
317314
}
318315
}
319316

320-
private static void ClientStateOnLogin() =>
317+
private void ClientStateOnLogin()
318+
{
321319
ConfigurationMain.Instance.SetProfileToDefault();
322320

321+
Svc.Framework.RunOnTick(() =>
322+
{
323+
if (Configuration.ShowOverlay && (!Configuration.HideOverlayWhenStopped || States.HasFlag(PluginState.Looping) || States.HasFlag(PluginState.Navigating)))
324+
SchedulerHelper.ScheduleAction("ShowOverlay", () => Overlay.IsOpen = true, () => PlayerHelper.IsReady);
325+
326+
if (Configuration.ShowMainWindowOnStartup)
327+
SchedulerHelper.ScheduleAction("ShowMainWindowOnStartup", () => OpenMainUI(), () => PlayerHelper.IsReady);
328+
});
329+
}
330+
323331
private void UiBuilderOnDraw()
324332
{
325333
if (PlayerHelper.IsValid)

AutoDuty/Windows/Config.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,12 @@ public void SetProfileAsDefault()
155155

156156
public void SetProfileToDefault()
157157
{
158+
this.SetProfile(CONFIGNAME_BARE);
158159
Svc.Framework.RunOnTick(() =>
159160
{
160-
DebugLog("Setting to default profile");
161+
DebugLog($"Setting to default profile for {Player.Name} ({Player.CID}) {PlayerHelper.IsValid}");
161162

162-
if (PlayerHelper.IsValid && this.profileByCID.TryGetValue(Player.CID, out string? charProfile))
163+
if (Player.Available && this.profileByCID.TryGetValue(Player.CID, out string? charProfile))
163164
if (this.SetProfile(charProfile))
164165
return;
165166
DebugLog("No char default found. Using general default");
@@ -215,6 +216,7 @@ public void DuplicateCurrentProfile()
215216

216217
public void RemoveCurrentProfile()
217218
{
219+
DebugLog("Removing " + this.ActiveProfileName);
218220
this.profileData.Remove(this.GetCurrentProfile);
219221
this.profileByName.Remove(this.ActiveProfileName);
220222
this.SetProfileToDefault();

0 commit comments

Comments
 (0)