Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit ccce6e4

Browse files
committed
added Help and See Changelog buttons
1 parent c10aee1 commit ccce6e4

File tree

6 files changed

+53
-10
lines changed

6 files changed

+53
-10
lines changed

Interop/Updater/UpdateWindow.xaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
Width="650" Height="700" TitleCaps="False" ShowInTaskbar="False"
66
Background="{DynamicResource WhiteBrush}"
77
GlowBrush="{DynamicResource AccentColorBrush}"
8-
WindowStartupLocation="CenterOwner" WindowStyle="None" >
8+
WindowStartupLocation="CenterOwner" WindowStyle="None"
9+
KeyDown="MetroWindow_KeyDown">
910
<controls:MetroWindow.Resources>
1011
<ResourceDictionary>
1112
<ResourceDictionary.MergedDictionaries>

Interop/Updater/UpdateWindow.xaml.cs

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Text;
77
using System.Threading;
88
using System.Windows;
9+
using System.Windows.Input;
910
using MahApps.Metro;
1011
using MdXaml;
1112
using SPCode.Utils;
@@ -25,7 +26,7 @@ public UpdateWindow()
2526
InitializeComponent();
2627
}
2728

28-
public UpdateWindow(UpdateInfo info) : this()
29+
public UpdateWindow(UpdateInfo info, bool OnlyChangelog = false) : this()
2930
{
3031

3132
if (Program.OptionsObject.Program_AccentColor != "Red" || Program.OptionsObject.Program_Theme != "BaseDark")
@@ -35,7 +36,7 @@ public UpdateWindow(UpdateInfo info) : this()
3536
}
3637

3738
updateInfo = info;
38-
PrepareUpdateWindow();
39+
PrepareUpdateWindow(OnlyChangelog);
3940

4041
}
4142
#endregion
@@ -54,19 +55,39 @@ private void ActionGithubButton_Click(object sender, RoutedEventArgs e)
5455
{
5556
Process.Start(new ProcessStartInfo(Constants.GitHubLatestRelease));
5657
}
58+
private void MetroWindow_KeyDown(object sender, KeyEventArgs e)
59+
{
60+
if (e.Key == Key.Escape)
61+
{
62+
Close();
63+
}
64+
}
5765
#endregion
5866

5967
#region Methods
6068
/// <summary>
6169
/// Prepares the update window with all the necessary info.
6270
/// </summary>
63-
public void PrepareUpdateWindow()
71+
public void PrepareUpdateWindow(bool OnlyChangelog = false)
6472
{
65-
Title = string.Format(Program.Translations.GetLanguage("VersionAvailable"), updateInfo.AllReleases[0].TagName);
66-
MainLine.Text = Program.Translations.GetLanguage("WantToUpdate");
67-
ActionYesButton.Content = Program.Translations.GetLanguage("Yes");
68-
ActionNoButton.Content = Program.Translations.GetLanguage("No");
69-
ActionGithubButton.Content = Program.Translations.GetLanguage("ViewGithub");
73+
if (OnlyChangelog)
74+
{
75+
Title = "SPCode Changelog";
76+
MainLine.Visibility = Visibility.Hidden;
77+
ActionYesButton.Visibility = Visibility.Hidden;
78+
ActionNoButton.Visibility = Visibility.Hidden;
79+
ActionGithubButton.Visibility = Visibility.Hidden;
80+
Icon.Visibility = Visibility.Hidden;
81+
DescriptionBox.Margin = new Thickness(0, 0, 0, 0);
82+
}
83+
else
84+
{
85+
Title = string.Format(Program.Translations.GetLanguage("VersionAvailable"), updateInfo.AllReleases[0].TagName);
86+
MainLine.Text = Program.Translations.GetLanguage("WantToUpdate");
87+
ActionYesButton.Content = Program.Translations.GetLanguage("Yes");
88+
ActionNoButton.Content = Program.Translations.GetLanguage("No");
89+
ActionGithubButton.Content = Program.Translations.GetLanguage("ViewGithub");
90+
}
7091

7192
var releasesBody = new StringBuilder();
7293

UI/MainWindow/MainWindow.xaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,10 @@
175175
<MenuItem x:Name="MenuI_Decompile" Header="Decompile .smx (Lysis)" Click="Menu_DecompileLysis" />
176176
<Separator />
177177
<MenuItem x:Name="MenuI_ReportBugGit" Header="Report a Bug on GitHub" Click="ReportBug_Click" />
178+
<MenuItem x:Name="MenuI_Changelog" Header="See Changelog" Click="Changelog_Click" />
178179
<MenuItem x:Name="UpdateCheckItem" Header="Check for Updates" Click="UpdateCheck_Click" />
180+
<Separator/>
181+
<MenuItem x:Name="MenuI_Help" Header="Help" Click="Menu_Help" />
179182
<MenuItem x:Name="MenuI_About" Header="About" Click="Menu_About" />
180183
</MenuItem>
181184
</Menu>

UI/MainWindow/MainWindowMenuHandler.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ private void Menu_About(object sender, RoutedEventArgs e)
219219
aboutWindow.ShowDialog();
220220
}
221221

222+
private void Menu_Help(object sender, RoutedEventArgs e)
223+
{
224+
Process.Start(new ProcessStartInfo(Constants.GitHubWiki));
225+
}
226+
222227
private void Menu_OpenSPDef(object sender, RoutedEventArgs e)
223228
{
224229
var spDefinitionWindow = new SPDefinitionWindow { Owner = this, ShowInTaskbar = false };
@@ -295,6 +300,19 @@ await this.ShowMessageAsync(Program.Translations.GetLanguage("VersUpToDate"),
295300
}
296301
}
297302

303+
private async void Changelog_Click(object sender, RoutedEventArgs e)
304+
{
305+
var dialog = await this.ShowProgressAsync("Retrieving changelog...", "Please wait...");
306+
dialog.SetIndeterminate();
307+
308+
await UpdateCheck.Check();
309+
var status = Program.UpdateStatus;
310+
311+
await dialog.CloseAsync();
312+
var uw = new UpdateWindow(status, true) { Owner = this };
313+
uw.ShowDialog();
314+
}
315+
298316
private void MenuButton_Compile(object sender, RoutedEventArgs e)
299317
{
300318
Compile_SPScripts(CompileButton.SelectedIndex != 1);

UI/Windows/SPDefinitionWindow.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
65
Width="1000" Height="600" ResizeMode="CanResize" WindowStartupLocation="CenterOwner" GlowBrush="{DynamicResource AccentColorBrush}"
76
ShowTitleBar="False" Title="Parsed Sourcepawn Definion">
87
<controls:MetroWindow.Resources>

Utils/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public static class Constants
66
public const string GitHubNewIssueLink = "https://github.com/SPCodeOrg/SPCode/issues/new";
77
public const string GitHubReleases = "https://github.com/SPCodeOrg/SPCode/releases";
88
public const string GitHubLatestRelease = "https://github.com/SPCodeOrg/SPCode/releases/latest";
9+
public const string GitHubWiki = "https://github.com/SPCodeOrg/SPCode/wiki";
910
public const string GetSPCodeText = "Get SPCode";
1011
public const string DiscordRPCAppID = "692110664948514836";
1112
public const string JavaDownloadSite64 = "https://api.adoptopenjdk.net/v3/installer/latest/15/ga/windows/x64/jdk/hotspot/normal/adoptopenjdk?project=jdk";

0 commit comments

Comments
 (0)