Ejemplo n.º 1
0
 public void UpdateAllTabs()
 {
     CharacterTabViewModel.UpdateTabs();
     DialogueTabViewModel.UpdateTabs();
     VendorTabViewModel.UpdateTabs();
     QuestTabViewModel.UpdateTabs();
     CurrencyTabViewModel.UpdateTabs();
 }
Ejemplo n.º 2
0
 public void ResetAll()
 {
     CharacterTabViewModel.Reset();
     DialogueTabViewModel.Reset();
     VendorTabViewModel.Reset();
     QuestTabViewModel.Reset();
     CurrencyTabViewModel.Reset();
 }
Ejemplo n.º 3
0
        public void SaveAll()
        {
            CharacterTabViewModel.Save();
            DialogueTabViewModel.Save();
            VendorTabViewModel.Save();
            QuestTabViewModel.Save();
            CurrencyTabViewModel.Save();

            ProjectData proj = MainWindow.CurrentProject;
            NPCProject  data = proj.data;

            data.lastCharacter = data.characters.IndexOf(CharacterTabViewModel.Character);
            data.lastDialogue  = data.dialogues.IndexOf(DialogueTabViewModel.Dialogue);
            data.lastQuest     = data.quests.IndexOf(QuestTabViewModel.Quest);
            data.lastVendor    = data.vendors.IndexOf(VendorTabViewModel.Vendor);
            data.lastCurrency  = data.currencies.IndexOf(CurrencyTabViewModel.Currency);
        }
Ejemplo n.º 4
0
        public MainWindowViewModel(MainWindow mainWindow)
        {
            MainWindow = mainWindow;
            RoutedCommand saveHotkey = new RoutedCommand();

            saveHotkey.InputGestures.Add(new KeyGesture(Key.S, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(saveHotkey,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                SaveProjectCommand.Execute(null);
            })));
            RoutedCommand loadHotkey = new RoutedCommand();

            loadHotkey.InputGestures.Add(new KeyGesture(Key.O, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(loadHotkey,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                LoadProjectCommand.Execute(null);
            })));
            RoutedCommand exportHotkey = new RoutedCommand();

            exportHotkey.InputGestures.Add(new KeyGesture(Key.E, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(exportHotkey,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                ExportProjectCommand.Execute(null);
            })));
            RoutedCommand newFileHotkey = new RoutedCommand();

            newFileHotkey.InputGestures.Add(new KeyGesture(Key.N, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(newFileHotkey,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                NewProjectCommand.Execute(null);
            })));
            RoutedCommand logWindow = new RoutedCommand();

            logWindow.InputGestures.Add(new KeyGesture(Key.F1, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(logWindow,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                if (ConsoleLogger.IsOpened)
                {
                    ConsoleLogger.HideConsoleWindow();
                }
                else
                {
                    ConsoleLogger.ShowConsoleWindow();
                }
            })));
            RoutedCommand pasteCommand = new RoutedCommand();

            pasteCommand.InputGestures.Add(new KeyGesture(Key.V, ModifierKeys.Control));
            MainWindow.CommandBindings.Add(new CommandBinding(pasteCommand,
                                                              new ExecutedRoutedEventHandler((object sender, ExecutedRoutedEventArgs e) =>
            {
                switch (MainWindow.mainTabControl.SelectedIndex)
                {
                case 0 when CharacterTabViewModel.Character != null:         // character (condition)
                    {
                        if (ClipboardManager.TryGetObject(ClipboardManager.ConditionFormat, out var obj) && obj is Condition cond)
                        {
                            CharacterTabViewModel.Character.visibilityConditions.Add(cond);
                        }
                    }
                    break;

                case 1 when DialogueTabViewModel.Dialogue != null:         // dialogue (nothing at this moment)
                    {
                    }
                    break;

                case 2 when VendorTabViewModel.Vendor != null:         // vendor (vendor item)
                    {
                        if (ClipboardManager.TryGetObject(ClipboardManager.VendorItemFormat, out var obj) && obj is VendorItem item)
                        {
                            if (item.isBuy)
                            {
                                VendorTabViewModel.AddItemBuy(item);
                            }
                            else
                            {
                                VendorTabViewModel.AddItemSell(item);
                            }
                        }
                    }
                    break;

                case 3 when QuestTabViewModel.Quest != null:         // quest (condition, reward)
                    {
                        if (ClipboardManager.TryGetObject(ClipboardManager.ConditionFormat, out var obj) && obj is Condition cond)
                        {
                            QuestTabViewModel.AddCondition(new Controls.Universal_ItemList(cond, true));
                        }
                        else if (ClipboardManager.TryGetObject(ClipboardManager.RewardFormat, out obj) && obj is Reward rew)
                        {
                            QuestTabViewModel.AddReward(new Controls.Universal_ItemList(rew, true));
                        }
                    }
                    break;
                }
            })));
            CharacterTabViewModel = new CharacterTabViewModel();
            DialogueTabViewModel  = new DialogueTabViewModel();
            VendorTabViewModel    = new VendorTabViewModel();
            QuestTabViewModel     = new QuestTabViewModel();
            CurrencyTabViewModel  = new CurrencyTabViewModel();
            MainWindow.mainTabControl.SelectionChanged += TabControl_SelectionChanged;

            MainWindow.CurrentProject.OnDataLoaded += () =>
            {
                ResetAll();

                ProjectData proj = MainWindow.CurrentProject;
                NPCProject  data = proj.data;

                if (data.lastCharacter > -1 && data.lastCharacter < data.characters.Count)
                {
                    CharacterTabViewModel.Character = data.characters[data.lastCharacter];
                }

                if (data.lastDialogue > -1 && data.lastDialogue < data.dialogues.Count)
                {
                    DialogueTabViewModel.Dialogue = data.dialogues[data.lastDialogue];
                }

                if (data.lastVendor > -1 && data.lastVendor < data.vendors.Count)
                {
                    VendorTabViewModel.Vendor = data.vendors[data.lastVendor];
                }

                if (data.lastQuest > -1 && data.lastQuest < data.quests.Count)
                {
                    QuestTabViewModel.Quest = data.quests[data.lastQuest];
                }

                if (data.lastCurrency > -1 && data.lastCurrency < data.currencies.Count)
                {
                    CurrencyTabViewModel.Currency = data.currencies[data.lastCurrency];
                }

                UpdateAllTabs();
            };
        }