mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2026-04-21 21:51:56 +00:00
- Remove polymorphic base, this only existed because TKMM has a desktop/switch setup prodecure difference and has 2 implementations of the setup wizard. We only need one. - Remove Systems/UI file split, they're all in Ryujinx.Ava.UI now - made NotificationHelper instance-based to allow you to encapsulate notifications to a window that magically disappear when the window is closed, instead of switching to showing on the main window.
90 lines
2.7 KiB
C#
90 lines
2.7 KiB
C#
using Avalonia.Controls;
|
|
using Ryujinx.Ava.Systems.Configuration;
|
|
using Ryujinx.Ava.UI.Windows;
|
|
using Ryujinx.Common.Configuration;
|
|
using Ryujinx.Common.Logging;
|
|
using System;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Ryujinx.Ava.UI.SetupWizard
|
|
{
|
|
public partial class RyujinxSetupWizardWindow : StyleableAppWindow
|
|
{
|
|
public static bool IsOpen { get; set; }
|
|
|
|
public RyujinxSetupWizardWindow() : base(useCustomTitleBar: true)
|
|
{
|
|
InitializeComponent();
|
|
|
|
if (Program.PreviewerDetached)
|
|
{
|
|
FlushControls.IsVisible = !ConfigurationState.Instance.ShowOldUI;
|
|
}
|
|
}
|
|
|
|
public static Task ShowAsync(Window owner = null)
|
|
{
|
|
if (!CanShowSetupWizard)
|
|
return Task.CompletedTask;
|
|
|
|
Task windowTask = ShowAsync(
|
|
CreateWindow(out RyujinxSetupWizard wiz),
|
|
owner
|
|
);
|
|
_ = wiz.Start();
|
|
return windowTask;
|
|
}
|
|
|
|
public static RyujinxSetupWizardWindow CreateWindow(out RyujinxSetupWizard setupWizard)
|
|
{
|
|
RyujinxSetupWizardWindow window = new();
|
|
window.DataContext = setupWizard = new RyujinxSetupWizard(window);
|
|
window.Height = 600;
|
|
window.Width = 750;
|
|
return window;
|
|
}
|
|
|
|
public static bool CanShowSetupWizard =>
|
|
!File.Exists(Path.Combine(AppDataManager.BaseDirPath, ".DoNotShowSetupWizard"));
|
|
|
|
public static bool DisableSetupWizard()
|
|
{
|
|
if (!CanShowSetupWizard)
|
|
return false; //cannot disable; file exists, so it's already disabled.
|
|
|
|
string disableFile = Path.Combine(AppDataManager.BaseDirPath, ".DoNotShowSetupWizard");
|
|
|
|
try
|
|
{
|
|
File.Create(disableFile, 0).Dispose();
|
|
File.SetAttributes(disableFile, File.GetAttributes(disableFile) | FileAttributes.Hidden);
|
|
return true;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Logger.Error?.PrintStack(LogClass.Application, e.Message);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static bool EnableSetupWizard()
|
|
{
|
|
if (CanShowSetupWizard)
|
|
return false; //cannot enable; file does not exist, so it's already enabled.
|
|
|
|
string disableFile = Path.Combine(AppDataManager.BaseDirPath, ".DoNotShowSetupWizard");
|
|
|
|
try
|
|
{
|
|
File.Delete(disableFile);
|
|
return true;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
Logger.Error?.PrintStack(LogClass.Application, e.Message);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|