Exemplo n.º 1
0
    private void Signal_TreeItemEdited()
    {
        var edited = ProjectTree.GetSelected();

        if (edited.GetParent() == resourcesRoot)
        {
            var    oldFilename = resourcesNames[edited];
            string newFilename = edited.GetText(0);

            justRenamedInUi = newFilename;
            System.IO.File.Move(System.IO.Path.Combine(ModProjectDir, oldFilename), System.IO.Path.Combine(ModProjectDir, newFilename));
            resourcesNames[edited] = newFilename;
            foreach (var mod in ModProject.Mods)
            {
                var controller = ContentPackController.GetControllerForMod(mod.ContentPackFor);
                controller.OnResourceRenamed(this, mod, oldFilename, newFilename);
            }
        }
    }
Exemplo n.º 2
0
    private void Signal_TreeCellActivated()
    {
        var  sel     = ProjectTree.GetSelected();
        Node newArea = null;

        if (sel == ProjectRoot)
        {
            var editor   = ProjectEditor.Instance();
            var lineEdit = editor.GetNode <LineEdit>("Name/LineEdit");
            lineEdit.Text = ModProject.Name;
            lineEdit.Connect("text_changed", this, nameof(Signal_ProjectNameEdited));
            lineEdit      = editor.GetNode <LineEdit>("Description/LineEdit");
            lineEdit.Text = ModProject.Description;
            lineEdit.Connect("text_changed", this, nameof(Signal_ProjectDescriptionEdited));
            lineEdit      = editor.GetNode <LineEdit>("UniqueId/LineEdit");
            lineEdit.Text = ModProject.UniqueId;
            lineEdit.Connect("text_changed", this, nameof(Signal_ProjectUniqueIdEdited));
            lineEdit      = editor.GetNode <LineEdit>("Version/LineEdit");
            lineEdit.Text = ModProject.Version;
            lineEdit.Connect("text_changed", this, nameof(Signal_ProjectVersionEdited));
            lineEdit      = editor.GetNode <LineEdit>("Author/LineEdit");
            lineEdit.Text = ModProject.Author;
            lineEdit.Connect("text_changed", this, nameof(Signal_ProjectAuthorEdited));
            newArea = editor;
        }
        else if (sel.GetParent() == depsRoot)
        {
            activeDep = sel;
            var dep = deps[sel];

            var editor   = DependencyEditor.Instance();
            var lineEdit = editor.GetNode <LineEdit>("Id/LineEdit");
            lineEdit.Text = dep.UniqueID;
            lineEdit.Connect("text_changed", this, nameof(Signal_DependencyIdEdited));
            var checkBox = editor.GetNode <CheckBox>("Required/CheckBox");
            checkBox.Pressed = dep.IsRequired;
            checkBox.Connect("toggled", this, nameof(Signal_DependencyRequiredToggled));
            lineEdit      = editor.GetNode <LineEdit>("MinimumVersion/LineEdit");
            lineEdit.Text = dep.MinimumVersion;
            lineEdit.Connect("text_changed", this, nameof(Signal_DependencyMinimumVersionEdited));
            newArea = editor;
        }
        else if (sel.GetParent() == updateKeysRoot)
        {
            activeUpdateKey = sel;
            var updateKey = updateKeys[sel];

            var editor       = UpdateKeyEditor.Instance();
            var optionButton = editor.GetNode <OptionButton>("Platform/OptionButton");
            int selInd       = 0;
            for (int i = 0; i < optionButton.GetItemCount(); ++i)
            {
                if (optionButton.GetItemText(i) == updateKey.Platform)
                {
                    selInd = i;
                    break;
                }
            }
            optionButton.Selected = selInd;
            optionButton.Connect("item_selected", this, nameof(Signal_UpdateKeyPlatformEdited));
            var lineEdit = editor.GetNode <LineEdit>("Id/LineEdit");
            lineEdit.Text = updateKey.Id;
            lineEdit.Connect("text_changed", this, nameof(Signal_UpdateKeyIdEdited));
            newArea = editor;
        }
        else if (sel.HasMeta(Meta.CorrespondingController))
        {
            var controller = ContentPackController.GetControllerForMod((string)sel.GetMeta(Meta.CorrespondingController));
            var data       = ModProject.Mods.Find(md => md.ContentPackFor == controller.ModUniqueId);
            newArea = controller.CreateMainEditingArea(this, data, sel);
        }

        if (newArea != null)
        {
            ClearMainEditingArea();
            MainEditingArea.AddChild(newArea);
        }
    }