diff --git a/Sources/Stim/App.xaml.cs b/Sources/Stim/App.xaml.cs index 4a3a143..277653f 100644 --- a/Sources/Stim/App.xaml.cs +++ b/Sources/Stim/App.xaml.cs @@ -1,5 +1,6 @@ using Model; using StimPersistance; +using StimStub; namespace Stim; @@ -13,7 +14,20 @@ public partial class App : Application { InitializeComponent(); string mainDir = FileSystem.Current.AppDataDirectory; - Mgr = new Manager(new Persistance(mainDir)); + if (File.Exists(Path.Combine(mainDir,"games.xml"))) Mgr = new Manager(new Persistance(mainDir)); + else Mgr = new Manager(new Stub()); MainPage = new AppShell(); } + protected override Window CreateWindow(IActivationState activationState) + { + Window window = base.CreateWindow(activationState); + + window.Stopped += (s, e) => + { + Mgr._persistance = new Persistance(FileSystem.Current.AppDataDirectory); + Mgr.SaveGames(); + }; + + return window; + } }