Beispiel #1
0
        public MainWindowViewModel()
        {
            EntityDirectory directory = new EntityDirectory();

            EntityDirectory = directory;
            Initialise(directory);
        }
Beispiel #2
0
        public static IEntityDirectory <string> GetMirroredDirectory(IEntityDirectory <string> directory)
        {
            var mirror = EntityDirectory <string> .Create();

            directory.Changes.Subscribe(mirror.Changes);

            return(mirror);
        }
Beispiel #3
0
        private void Initialise(EntityDirectory directory)
        {
            CmdSaveDirectory = ReactiveCommand.CreateFromTask(async() =>
            {
                OpenFolderDialog dlg = new OpenFolderDialog();
                dlg.Title            = "Select the location to save the directory";
                string filePath      = await dlg.ShowAsync(CommonUtils.MainWindow);
                if (!string.IsNullOrEmpty(filePath))
                {
                    try
                    {
                        EntityDirectory.WriteDirectory(filePath);
                        CurrentDirectoryPath = filePath;
                        directorySaved       = true;
                    }
                    catch (Exception ex)
                    {
                        var msg = CommonUtils.GetMessageBox("Error opening save file",
                                                            "An error occured while saving the save file: " + ex.Message, ButtonEnum.Ok, Icon.Error);
                        await msg.ShowDialog(CommonUtils.MainWindow);
                    }
                }
            }, this.WhenAnyValue(x => x.DirectoryInUse));

            CmdAddEntity = ReactiveCommand.Create(() =>
            {
                Entity ent       = new Entity();
                ent.Name         = "New Entity";
                ent.EntityType   = NPCType.NPC;
                ent.ObjectType   = ObjectTypes.None;
                ent.DestroyType  = DeathType.None;
                ent.InteractType = Interaction.None;
                ent.Behaviors[0] = ActionBehaviors.None;
                ent.Behaviors[1] = ActionBehaviors.None;
                EntityDirectory.Entities[CurrentKey].Add(ent);
                RebuildLineIndexesDescriptions();
                SelectedLineIndex = EntityDirectory.Entities[CurrentKey].Count - 1;
            }, this.WhenAnyValue(x => x.DirectoryInUse, x => x.CurrentKey,
                                 (directoryInUse, currentKey) => directoryInUse && currentKey != -1));

            CmdEditEntityName = ReactiveCommand.CreateFromTask(async() =>
            {
                EditEntityNameView dlg = new EditEntityNameView(this);
                string savedName       = CurrentEntity.Name;
                await dlg.ShowDialog(CommonUtils.MainWindow);
                if (dlg.Confirmed)
                {
                    int index = SelectedLineIndex;
                    RebuildLineIndexesDescriptions();
                    SelectedLineIndex = index;
                }
                else
                {
                    CurrentEntity.Name = savedName;
                }
            }, this.WhenAnyValue(x => x.EntitySelected));
        }
Beispiel #4
0
        public MainWindowViewModel(EntityDirectory directory)
        {
            EntityDirectory = directory;
            Initialise(directory);

            GeneralView         = new GeneralView(this);
            ActionsLocationView = new ActionsLocationView(this);
            ArraysView          = new ArraysView(this);
            CollidersView       = new CollidersView(this);
            EmoticonsView       = new EmoticonsView(this);
            PropertiesView      = new PropertiesView(this);
        }
Beispiel #5
0
        public static IEntityDirectory <string> GetCommonDirectory()
        {
            var root = EntityDirectory <string> .Create();

            var subFolder  = root.GetOrAdd("TestDirectory", EntityDirectory <string> .Create);
            var testString = subFolder.GetOrAdd("TestString", () => EntitySubject <string> .Create("TestString"));
            var testInt    = subFolder.GetOrAdd("TestInt", () => EntitySubject <int> .Create(23));
            var testDouble = subFolder.GetOrAdd("TestDouble", () => EntitySubject <double> .Create(23.0));
            var testBool   = subFolder.GetOrAdd("TestBool", () => EntitySubject <bool> .Create(true));
            var testList   = subFolder.GetOrAdd("TestList", () => EntityList <IEntitySubject <int> > .Create());

            testList.Add(EntitySubject <int> .Create(1));
            testList.Add(EntitySubject <int> .Create(10));
            testList.Add(EntitySubject <int> .Create(15));
            return(root);
        }
Beispiel #6
0
        public async void OpenDirectory()
        {
            if (DirectoryInUse && !directorySaved)
            {
                var msg = CommonUtils.GetMessageBox("Directory in use", "An unsaved directory is currently in use, " +
                                                    "opening a directory will loose all unsaved changes,\nare you sure you want to proceed?",
                                                    ButtonEnum.YesNo, Icon.Question);
                await msg.ShowDialog(CommonUtils.MainWindow);

                if (msg.ButtonResult == ButtonResult.No)
                {
                    return;
                }
            }

            OpenFolderDialog dlg = new OpenFolderDialog();

            dlg.Title = "Select a Bug Fables entitydata directory";
            string filePaths = await dlg.ShowAsync(CommonUtils.MainWindow);

            if (string.IsNullOrEmpty(filePaths))
            {
                return;
            }

            try
            {
                EntityDirectory.ResetToDefault();
                EntityDirectory.LoadDirectory(filePaths);
                CurrentDirectoryPath = filePaths;
                DirectoryInUse       = true;
                directorySaved       = true;
                RebuildKeysDescriptions();
                LineIndexesDescriptions.Clear();
            }
            catch (Exception ex)
            {
                EntityDirectory.ResetToDefault();
                var msg = CommonUtils.GetMessageBox("Error opening directory",
                                                    "An error occured while opening the directory: " + ex.Message, ButtonEnum.Ok, Icon.Error);
                await msg.ShowDialog(CommonUtils.MainWindow);
            }
        }
Beispiel #7
0
        public static dynamic GetDynamicCommonDirectory()
        {
            var root = EntityDirectory <string> .Create().AsDynamic();

            root.TestDirectory = EntityDirectory <string> .Create();

            root.TestDirectory.TestString = EntitySubject <string> .Create("TestString");

            root.TestDirectory.TestInt = EntitySubject <int> .Create(23);

            root.TestDirectory.TestDouble = EntitySubject <double> .Create(23.0);

            root.TestDirectory.TestBool = EntitySubject <bool> .Create(true);

            root.TestDirectory.TestList = EntityList <IEntitySubject <int> > .Create();

            root.TestDirectory.TestList.Add(EntitySubject <int> .Create(1));
            root.TestDirectory.TestList.Add(EntitySubject <int> .Create(10));
            root.TestDirectory.TestList.Add(EntitySubject <int> .Create(15));
            return(root);
        }