-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameManager.cs
More file actions
47 lines (40 loc) · 1.61 KB
/
Copy pathGameManager.cs
File metadata and controls
47 lines (40 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using UnityModStudio.Common.Options;
namespace UnityModStudio.Options;
[InheritedExport]
public interface IGameManager
{
IGameRegistry GameRegistry { get; }
bool ShowEditDialog(Game game);
IEnumerable<Game> ShowAddGamesDialog<TViewModel>() where TViewModel : AddGamesViewModelBase, new();
bool ShowGameRegistryDialog();
}
[method: ImportingConstructor]
public class GameManager(ICompositionService compositionService, IGameRegistry gameRegistry) : IGameManager
{
public IGameRegistry GameRegistry { get; } = gameRegistry;
public bool ShowEditDialog(Game game)
{
var viewModel = new GamePropertiesViewModel(game);
compositionService.SatisfyImportsOnce(viewModel);
var window = new GamePropertiesWindow(viewModel);
return window.ShowModal() ?? false;
}
public IEnumerable<Game> ShowAddGamesDialog<TViewModel>() where TViewModel : AddGamesViewModelBase, new()
{
var viewModel = new TViewModel();
compositionService.SatisfyImportsOnce(viewModel);
var window = new AddGamesWindow(viewModel);
return window.ShowModal() ?? false ? viewModel.SelectedGames : Enumerable.Empty<Game>();
}
public bool ShowGameRegistryDialog()
{
var innerViewModel = new GameRegistryViewModel();
compositionService.SatisfyImportsOnce(innerViewModel);
var viewModel = new GameRegistryWindowViewModel(innerViewModel);
var window = new GameRegistryWindow(viewModel);
return window.ShowModal() ?? false;
}
}