AboutWindow.cs 4.1 KB

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