public DeckSectionTabViewModel() { AddCommand = new RelayCommand(AddItem); AddGlobalCommand = new RelayCommand(AddGlobalItem); DeckSectionDropHandler = new DeckSectionDropHandler(); Items = new IdeCollection <IdeBaseItem>(this, typeof(DeckSectionItemModel)); foreach (var deckSection in ViewModelLocator.GameLoader.Game.DeckSections.Values) { Items.Add(new DeckSectionItemModel(deckSection, Items)); } Items.CollectionChanged += (sender, args) => { ViewModelLocator.GameLoader.Game.DeckSections = Items.ToDictionary(x => ((DeckSectionItemModel)x).Name, y => ((DeckSectionItemModel)y)._deckSection); }; GlobalItems = new IdeCollection <IdeBaseItem>(this, typeof(DeckSectionItemModel)); foreach (var globalDeckSection in ViewModelLocator.GameLoader.Game.SharedDeckSections.Values) { GlobalItems.Add(new DeckSectionItemModel(globalDeckSection, GlobalItems)); } GlobalItems.CollectionChanged += (sender, args) => { ViewModelLocator.GameLoader.Game.SharedDeckSections = GlobalItems.ToDictionary(x => ((DeckSectionItemModel)x).Name, y => ((DeckSectionItemModel)y)._deckSection); }; Messenger.Default.Register <GroupChangedMessage>(this, x => { RaisePropertyChanged("HasPiles"); RaisePropertyChanged("HasGlobalPiles"); }); }
public PropertyTabViewModel() { Items = new IdeCollection <IdeBaseItem>(this, typeof(PropertyItemModel)); foreach (var property in ViewModelLocator.GameLoader.Game.CardProperties.Values) { Items.Add(new PropertyItemModel(property, Items)); } Items.CollectionChanged += (sender, args) => { ViewModelLocator.GameLoader.Game.CardProperties = Items.ToDictionary(x => ((PropertyItemModel)x).Name, y => ((PropertyItemModel)y)._property); Messenger.Default.Send(new CustomPropertyChangedMessage(args)); }; AddCommand = new RelayCommand(AddItem); }
public SoundTabViewModel() { AddCommand = new RelayCommand(AddItem); _mediaPlayer = new MediaPlayer(); Items = new IdeCollection <IdeBaseItem>(this); foreach (var sound in ViewModelLocator.GameLoader.Game.Sounds) { Items.Add(new SoundItemModel(sound.Value, Items)); } Items.CollectionChanged += (a, b) => { ViewModelLocator.GameLoader.Game.Sounds = Items.ToDictionary(x => (x as SoundItemModel).Name, y => (y as SoundItemModel)._sound); }; }
public MarkerTabViewModel() { AddCommand = new RelayCommand(AddItem); Items = new IdeCollection <IdeBaseItem>(this, typeof(MarkerItemModel)); foreach (var marker in ViewModelLocator.GameLoader.Game.Markers) { Items.Add(new MarkerItemModel(marker.Value, Items)); } Items.CollectionChanged += (a, b) => { ViewModelLocator.GameLoader.Game.Markers = Items.ToDictionary( x => (x as MarkerItemModel)._marker.Id, x => (x as MarkerItemModel)._marker); }; }
public ScriptsTabViewModel() { GlobalVariables = new IdeCollection <IdeBaseItem>(); foreach (var globalvariable in ViewModelLocator.GameLoader.Game.GlobalVariables) { GlobalVariables.Add(new GlobalVariableItemModel(globalvariable.Value, GlobalVariables)); } GlobalVariables.CollectionChanged += (sender, args) => { ViewModelLocator.GameLoader.Game.GlobalVariables = GlobalVariables.ToDictionary( x => (x as GlobalVariableItemModel).Name, y => (y as GlobalVariableItemModel)._globalVariable ); }; AddGlobalVariableCommand = new RelayCommand(AddGlobalVariable); PlayerVariables = new IdeCollection <IdeBaseItem>(); foreach (var globalvariable in ViewModelLocator.GameLoader.Game.Player.GlobalVariables) { PlayerVariables.Add(new GlobalVariableItemModel(globalvariable.Value, PlayerVariables)); } PlayerVariables.CollectionChanged += (sender, args) => { ViewModelLocator.GameLoader.Game.Player.GlobalVariables = PlayerVariables.ToDictionary( x => (x as GlobalVariableItemModel).Name, y => (y as GlobalVariableItemModel)._globalVariable ); }; AddPlayerVariableCommand = new RelayCommand(AddPlayerVariable); Scripts = new IdeCollection <IdeBaseItem>(); var game = ViewModelLocator.GameLoader.Game; var scriptSerializer = new GameScriptSerializer(game.Id) { Game = game }; foreach (var scriptPath in game.Scripts) { var path = Path.Combine(ViewModelLocator.GameLoader.WorkingDirectory.FullName, scriptPath); var script = (GameScript)scriptSerializer.Deserialize(path); var scriptModel = new ScriptItemModel(script, Scripts); Scripts.Add(scriptModel); } Scripts.CollectionChanged += (a, b) => { // ViewModelLocator.GameLoader.Scripts = Scripts.Select(x => ((ScriptItemModel)x)._script); }; AddScriptCommand = new RelayCommand(AddScript); Events = new IdeCollection <IdeBaseItem>(); foreach (var gameEventType in ViewModelLocator.GameLoader.Game.Events) { foreach (var gameEvent in gameEventType.Value) { Events.Add(new GameEventItemModel(gameEvent, Events)); } } Events.CollectionChanged += (a, b) => { var items = ViewModelLocator.GameLoader.Game.Events = Events.GroupBy(x => ((GameEventItemModel)x).Name) .ToDictionary( x => x.Key, y => y.Select(z => ((GameEventItemModel)z)._gameEvent).ToArray()); }; AddEventCommand = new RelayCommand(AddGameEvent); }
public ScriptsTabViewModel() { GlobalVariables = new IdeCollection <IdeBaseItem>(); foreach (var globalvariable in ViewModelLocator.GameLoader.Game.GlobalVariables) { GlobalVariables.Add(new GlobalVariableItemModel(globalvariable.Value, GlobalVariables)); } GlobalVariables.CollectionChanged += (sender, args) => { ViewModelLocator.GameLoader.Game.GlobalVariables = GlobalVariables.ToDictionary( x => (x as GlobalVariableItemModel).Name, y => (y as GlobalVariableItemModel)._globalVariable ); }; AddGlobalVariableCommand = new RelayCommand(AddGlobalVariable); PlayerVariables = new IdeCollection <IdeBaseItem>(); foreach (var globalvariable in ViewModelLocator.GameLoader.Game.Player.GlobalVariables) { PlayerVariables.Add(new GlobalVariableItemModel(globalvariable.Value, PlayerVariables)); } PlayerVariables.CollectionChanged += (sender, args) => { ViewModelLocator.GameLoader.Game.Player.GlobalVariables = PlayerVariables.ToDictionary( x => (x as GlobalVariableItemModel).Name, y => (y as GlobalVariableItemModel)._globalVariable ); }; AddPlayerVariableCommand = new RelayCommand(AddPlayerVariable); Scripts = new IdeCollection <IdeBaseItem>(); foreach (var script in ViewModelLocator.GameLoader.Scripts) { Scripts.Add(new ScriptItemModel(script, Scripts)); } Scripts.CollectionChanged += (a, b) => { ViewModelLocator.GameLoader.Scripts = Scripts.Select(x => ((ScriptItemModel)x)._script); }; AddScriptCommand = new RelayCommand(AddScript); Events = new IdeCollection <IdeBaseItem>(); foreach (var gameEventType in ViewModelLocator.GameLoader.Game.Events) { foreach (var gameEvent in gameEventType.Value) { Events.Add(new GameEventItemModel(gameEvent, Events)); } } Events.CollectionChanged += (a, b) => { var items = ViewModelLocator.GameLoader.Game.Events = Events.GroupBy(x => ((GameEventItemModel)x).Name) .ToDictionary( x => x.Key, y => y.Select(z => ((GameEventItemModel)z)._gameEvent).ToArray()); }; AddEventCommand = new RelayCommand(AddGameEvent); }