AboutWindow.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using Gtk;
  2. using System;
  3. using System.Diagnostics;
  4. using System.IO;
  5. using System.Reflection;
  6. using System.Runtime.InteropServices;
  7. using Utf8Json;
  8. using Utf8Json.Resolvers;
  9. using GUI = Gtk.Builder.ObjectAttribute;
  10. namespace Ryujinx.Ui
  11. {
  12. public class AboutWindow : Window
  13. {
  14. private static AboutInfo AboutInformation { get; set; }
  15. #pragma warning disable CS0649
  16. #pragma warning disable IDE0044
  17. [GUI] Window _aboutWin;
  18. [GUI] Label _versionText;
  19. [GUI] Image _ryujinxLogo;
  20. [GUI] Image _patreonLogo;
  21. [GUI] Image _gitHubLogo;
  22. [GUI] Image _discordLogo;
  23. [GUI] Image _twitterLogo;
  24. #pragma warning restore CS0649
  25. #pragma warning restore IDE0044
  26. public AboutWindow() : this(new Builder("Ryujinx.Ui.AboutWindow.glade")) { }
  27. private AboutWindow(Builder builder) : base(builder.GetObject("_aboutWin").Handle)
  28. {
  29. builder.Autoconnect(this);
  30. _aboutWin.Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png");
  31. _ryujinxLogo.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.Icon.png" , 100, 100);
  32. _patreonLogo.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.PatreonLogo.png", 30 , 30 );
  33. _gitHubLogo.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.GitHubLogo.png" , 30 , 30 );
  34. _discordLogo.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.DiscordLogo.png", 30 , 30 );
  35. _twitterLogo.Pixbuf = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.assets.TwitterLogo.png", 30 , 30 );
  36. try
  37. {
  38. IJsonFormatterResolver resolver = CompositeResolver.Create(new[] { StandardResolver.AllowPrivateSnakeCase });
  39. using (Stream stream = File.OpenRead(System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "RyuFS", "Installer", "Config", "Config.json")))
  40. {
  41. AboutInformation = JsonSerializer.Deserialize<AboutInfo>(stream, resolver);
  42. }
  43. _versionText.Text = $"Version {AboutInformation.InstallVersion} - {AboutInformation.InstallBranch} ({AboutInformation.InstallCommit})";
  44. }
  45. catch
  46. {
  47. _versionText.Text = "Unknown Version";
  48. }
  49. }
  50. private static void OpenUrl(string url)
  51. {
  52. if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
  53. {
  54. Process.Start(new ProcessStartInfo("cmd", $"/c start {url}"));
  55. }
  56. else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
  57. {
  58. Process.Start("xdg-open", url);
  59. }
  60. else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
  61. {
  62. Process.Start("open", url);
  63. }
  64. }
  65. //Events
  66. private void RyujinxButton_Pressed(object sender, ButtonPressEventArgs args)
  67. {
  68. OpenUrl("https://ryujinx.org");
  69. }
  70. private void PatreonButton_Pressed(object sender, ButtonPressEventArgs args)
  71. {
  72. OpenUrl("https://www.patreon.com/ryujinx");
  73. }
  74. private void GitHubButton_Pressed(object sender, ButtonPressEventArgs args)
  75. {
  76. OpenUrl("https://github.com/Ryujinx/Ryujinx");
  77. }
  78. private void DiscordButton_Pressed(object sender, ButtonPressEventArgs args)
  79. {
  80. OpenUrl("https://discordapp.com/invite/N2FmfVc");
  81. }
  82. private void TwitterButton_Pressed(object sender, ButtonPressEventArgs args)
  83. {
  84. OpenUrl("https://twitter.com/RyujinxEmu");
  85. }
  86. private void ContributorsButton_Pressed(object sender, ButtonPressEventArgs args)
  87. {
  88. OpenUrl("https://github.com/Ryujinx/Ryujinx/graphs/contributors?type=a");
  89. }
  90. private void CloseToggle_Activated(object sender, EventArgs args)
  91. {
  92. Dispose();
  93. }
  94. }
  95. }