Skip to content

Commit

Permalink
Center certain dialogs on the screen instead of Studio
Browse files Browse the repository at this point in the history
  • Loading branch information
psyGamer committed Sep 2, 2024
1 parent 3dbc7c9 commit 60f4ba4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Studio/CelesteStudio/Dialog/SettingsErrorDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Celeste Studio {Studio.Version}
Result = SettingsErrorAction.None;

Load += (_, _) => Studio.Instance.WindowCreationCallback(this);
Shown += (_, _) => Location = Studio.Instance.Location + new Point((Studio.Instance.Width - Width) / 2, (Studio.Instance.Height - Height) / 2);
Shown += (_, _) => Location = new Point((int)((Screen.WorkingArea.Width - Width) / 2), (int)((Screen.WorkingArea.Height - Height) / 2));
}

protected override void OnClosing(CancelEventArgs e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Control GenerateContent() {
Studio.RegisterDialog(this);

Load += (_, _) => Studio.Instance.WindowCreationCallback(this);
Shown += (_, _) => Location = Studio.Instance.Location + new Point((Studio.Instance.Width - Width) / 2, (Studio.Instance.Height - Height) / 2);
Shown += (_, _) => Location = new Point((int)((Screen.WorkingArea.Width - Width) / 2), (int)((Screen.WorkingArea.Height - Height) / 2));
}

public static void Show(string title, string markdown) => new WhatsNewDialog(title, markdown).ShowModal();
Expand Down
15 changes: 7 additions & 8 deletions Studio/CelesteStudio/Migration/Migrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ public static void ApplyPreLoadMigrations() {
}
}
}

Studio.Instance.Shown += (_, _) => {
foreach ((string? versionName, var stream) in changelogs) {
WhatsNewDialog.Show($"Whats new in Studio v{versionName}?", new StreamReader(stream).ReadToEnd());
stream.Dispose();
}
};
}

public static void ApplyPostLoadMigrations() {
Expand All @@ -68,12 +75,4 @@ public static void ApplyPostLoadMigrations() {
}
}
}

public static async Task ShowChangelogs() {
foreach ((string? versionName, var stream) in changelogs) {
WhatsNewDialog.Show($"Whats new in Studio v{versionName}?", await new StreamReader(stream).ReadToEndAsync().ConfigureAwait(false));
await stream.DisposeAsync().ConfigureAwait(false);
}
changelogs.Clear();
}
}
6 changes: 0 additions & 6 deletions Studio/CelesteStudio/Studio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,6 @@ public Studio(string[] args, Action<Window> windowCreationCallback) {
OnNewFile();
}
};
Shown += (_, _) => Task.Run(async () => {
// Wait a bit, so that the window definitely is shown
// A bit janky, but not doing this seems to cause issues
await Task.Delay(5_000).ConfigureAwait(false);
await Application.Instance.InvokeAsync(Migrator.ShowChangelogs).ConfigureAwait(false);
});

CommunicationWrapper.Start();
}
Expand Down

0 comments on commit 60f4ba4

Please sign in to comment.