コード例 #1
0
        private void BuildRealmFileTree(TreeNode root, RealmJsonFile file)
        {
            root.Nodes.Clear();

            // Add a subnode for each realm in the file
            foreach (Realm r in file.Realms.OrderBy(x => x.ID))
            {
                TreeNode node = new TreeNode(r.ToString());
                node.Tag = r;
                root.Nodes.Add(node);
                r.Node = node;
            }
        }
コード例 #2
0
        private void MenuItemAddRealmFile_Click(object sender, EventArgs e)
        {
            NewRealmFileForm realm  = new NewRealmFileForm();
            DialogResult     result = realm.ShowDialog();

            if (result == DialogResult.OK)
            {
                RealmJsonFile file = new RealmJsonFile();
                file.FileName = realm.realmFileNameText.Text;

                CurrentMod.Data.RealmFiles.Add(file);

                TreeNode root = new TreeNode(file.FileName);
                root.Tag = file;
                root.ContextMenuStrip = contextMenuRealmRoot;
                realmsTreeView.Nodes.Add(root);
            }
        }
コード例 #3
0
        private void ContextRealmRootNew_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = realmsTreeView.SelectedNode;

            if (selectedNode.Tag is Realm)
            {
                selectedNode = selectedNode.Parent;
            }

            RealmJsonFile file = (RealmJsonFile)selectedNode.Tag;
            Realm         r    = new Realm()
            {
                ID = 0, Name = "New Realm"
            };

            file.Realms.Add(r);

            BuildRealmFileTree(selectedNode, file);
        }
コード例 #4
0
        private void SetCurrentMod(string file)
        {
            if (!File.Exists(file))
            {
                return;
            }

            CurrentMod          = JsonConvert.DeserializeObject <Mod>(File.ReadAllText(file));
            CurrentMod.FileName = file;

            WorkingDirectory = Path.GetDirectoryName(file);
            UserPreferences.Default.WorkingDirectory = WorkingDirectory;
            UserPreferences.Default.LastMod          = file;
            UserPreferences.Default.Save();

            this.Text          = EditorName + " - " + CurrentMod.Name;
            tabControl.Enabled = true;
            tabControl.Visible = true;

            modNameTextBox.Text = CurrentMod.Name;
            modNameTextBox.DataBindings.Add("Text", CurrentMod, "Name");

            modIDTextBox.Text = CurrentMod.ID;
            modIDTextBox.DataBindings.Add("Text", CurrentMod, "ID");

            modAuthorTextBox.Text = CurrentMod.Author;
            modAuthorTextBox.DataBindings.Add("Text", CurrentMod, "Author");

            modDescriptionTextBox.Text = CurrentMod.Description;
            modDescriptionTextBox.DataBindings.Add("Text", CurrentMod, "Description");

            // Setup the provinces tree
            provincesTreeView.Nodes.Clear();

            foreach (string f in Directory.GetFiles(Path.Combine(WorkingDirectory, CurrentMod.Name, ProvincesDirectory), "*.txt"))
            {
                ProvinceJsonFile loadedFile = JsonConvert.DeserializeObject <ProvinceJsonFile>(File.ReadAllText(f));
                loadedFile.FileName = Path.GetFileName(f);

                CurrentMod.Data.ProvinceFiles.Add(loadedFile);
            }

            foreach (ProvinceJsonFile provinceFile in CurrentMod.Data.ProvinceFiles)
            {
                TreeNode root = new TreeNode(provinceFile.FileName);
                root.Expand();
                root.Tag = provinceFile;
                provincesTreeView.Nodes.Add(root);

                BuildProvinceFileTree(root, provinceFile);
            }

            // Setup the realm tree
            realmsTreeView.Nodes.Clear();

            foreach (string f in Directory.GetFiles(Path.Combine(WorkingDirectory, CurrentMod.Name, RealmsDirectory), "*.txt"))
            {
                // Load the file data
                RealmJsonFile loadedFile = JsonConvert.DeserializeObject <RealmJsonFile>(File.ReadAllText(f));
                loadedFile.FileName = Path.GetFileName(f);

                CurrentMod.Data.RealmFiles.Add(loadedFile);
            }

            foreach (RealmJsonFile realmFile in CurrentMod.Data.RealmFiles)
            {
                TreeNode root = new TreeNode(realmFile.FileName);
                root.Expand();
                root.Tag = realmFile;
                root.ContextMenuStrip = contextMenuRealmRoot;
                realmsTreeView.Nodes.Add(root);

                BuildRealmFileTree(root, realmFile);
            }
        }