コード例 #1
0
        private void RefreshTreeView()
        {
            var dbContext = Program.NinjectKernel.Get <IRealmDbContext>();

            treeBrowse.Nodes.Clear();
            treeBrowse.ImageList.Images.Clear();

            var filterText = txtFilter.Text.Trim();

            Program.MainForm.ProgressStatus.Minimum = 0;
            Program.MainForm.ProgressStatus.Maximum = EditorFactory.Builders.Count;
            Program.MainForm.ProgressStatus.Value   = Program.MainForm.ProgressStatus.Minimum;

            // Initialize the interface with the registered editors
            var iconIndex = 0;

            foreach (var builder in EditorFactory.Builders.Values)
            {
                if (!builder.IsVisible)
                {
                    continue;
                }

                treeBrowse.ImageList.Images.Add(builder.Icon);

                var classList = dbContext.SystemClasses
                                .Where(x => x.SystemType == builder.SystemType)
                                .Where(x => x.ParentClassId == null);

                if (classList.Count() > 1)
                {
                    throw new EditorException($"Multiple parent classes for system [{builder.SystemType}]");
                }

                if (!classList.Any())
                {
                    throw new EditorException($"No parent class for system [{builder.SystemType}]");
                }

                var classId = classList.ToList().First().Id;

                var rootNode   = new TreeNode(builder.DisplayPlural);
                var browseInfo = new EditorBrowseInfo(builder.SystemType, builder.DisplayName, classId, 0);
                rootNode.Tag              = browseInfo;
                rootNode.ImageKey         = "closedFolder";
                rootNode.ContextMenuStrip = contextBrowseFolder;

                rootNode.SetupBrowseTree(builder, !string.IsNullOrEmpty(filterText), filterText);
                if (!builder.HasDelete())
                {
                    // This will disable for everything...?
                    // contextBrowseNode.Items[0].Enabled = false;
                }
                builder.PopulateBrowseNode(rootNode, browseInfo.ClassId, contextBrowseNode, txtFilter.Text.Trim());
                treeBrowse.Nodes.Add(rootNode);
                Program.MainForm.ProgressStatus.Value += 1;

                iconIndex++;
            }
        }
コード例 #2
0
        private void saveNodesGrid(int aDefId)
        {
            Database.deleteData("npc_node_map", "npc_def_id", aDefId);
            foreach (DataGridViewRow gridRow in gridNodes.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    EditorBrowseInfo itemDefIdBrowseInfo = gridRow.Cells["item_def_id"].Value as EditorBrowseInfo;
                    if (itemDefIdBrowseInfo == null)
                    {
                        continue;
                    }

                    int rowId = Database.createData("npc_node_map", "npc_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in npc_node_map");
                    }

                    Database.updateData("npc_node_map", "npc_node_map_id", rowId, "ref_npc_node_type_id", (int)gridRow.Cells["ref_npc_node_type_id"].Value);
                    Database.updateData("npc_node_map", "npc_node_map_id", rowId, "item_def_id", itemDefIdBrowseInfo.Id);
                }
            }
            gridNodes.flushDeletedRows();
        }
コード例 #3
0
        private void saveOppositionGrid(int aDefId)
        {
            Database.deleteData("faction_opposition_map", "faction_def_id", aDefId);
            foreach (DataGridViewRow gridRow in gridOpposition.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    EditorBrowseInfo factionDefIdBrowseInfo = gridRow.Cells["target_faction_def_id"].Value as EditorBrowseInfo;
                    if (factionDefIdBrowseInfo == null)
                    {
                        continue;
                    }

                    int rowId = Database.createData("faction_opposition_map", "faction_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in faction_opposition_map");
                    }

                    Database.updateData("faction_opposition_map", "faction_opposition_map_id", rowId, "target_faction_def_id", factionDefIdBrowseInfo.Id);

                    if (gridRow.Cells["ref_faction_relationship_id"].Value == DBNull.Value)
                    {
                        Database.updateData("faction_opposition_map", "faction_opposition_map_id", rowId, "ref_faction_relationship_id", Globals.FACTION_RELATIONSHIP_Neutral);
                    }
                    else
                    {
                        Database.updateData("faction_opposition_map", "faction_opposition_map_id", rowId, "ref_faction_relationship_id", (int)gridRow.Cells["ref_faction_relationship_id"].Value);
                    }
                }
            }
            gridOpposition.flushDeletedRows();
        }
コード例 #4
0
        private void saveStatisticsGrid(int aDefId)
        {
            Database.deleteData("npc_statistic_map", "npc_def_id", aDefId);
            foreach (DataGridViewRow gridRow in gridStatistics.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    EditorBrowseInfo statDefIdBrowseInfo = gridRow.Cells["statistic_def_id"].Value as EditorBrowseInfo;
                    if (statDefIdBrowseInfo == null)
                    {
                        continue;
                    }

                    int rowId = Database.createData("npc_statistic_map", "npc_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in npc_statistic_map");
                    }

                    Database.updateData("npc_statistic_map", "npc_statistic_map_id", rowId, "statistic_def_id", statDefIdBrowseInfo.Id);
                    Database.updateData("npc_statistic_map", "npc_statistic_map_id", rowId, "value", (int)gridRow.Cells["value"].Value);
                }
            }
            gridStatistics.flushDeletedRows();
        }
コード例 #5
0
        public override void saveItemData(int aDefId)
        {
            Database.deleteData("item_rune_map", "item_def_id", aDefId);
            foreach (DataGridViewRow gridRow in gridSockets.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    EditorBrowseInfo slotDefIdBrowseInfo = gridRow.Cells["slot_def_id"].Value as EditorBrowseInfo;
                    if (slotDefIdBrowseInfo == null)
                    {
                        continue;
                    }

                    int rowId = Database.createData("item_rune_map", "item_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in item_rune_map");
                    }

                    Database.updateData("item_rune_map", "item_rune_map_id", rowId, "slot_def_id", slotDefIdBrowseInfo.Id);

                    int flags =
                        (chkIsRemovable.Checked ? Globals.RUNE_FLAG_Removable : 0);
                    Database.updateData("item_rune_map", "item_rune_map_id", rowId, "flags", flags);
                }
            }
            gridSockets.flushDeletedRows();
        }
コード例 #6
0
        public override void saveItemData(int aDefId)
        {
            Database.deleteData("item_resource_node_map", "item_def_id", aDefId);
            foreach (DataGridViewRow gridRow in gridResources.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    EditorBrowseInfo statDefIdBrowseInfo = gridRow.Cells["statistic_def_id"].Value as EditorBrowseInfo;
                    if (statDefIdBrowseInfo == null)
                    {
                        continue;
                    }

                    EditorBrowseInfo resourceDefIdBrowseInfo = gridRow.Cells["resource_def_id"].Value as EditorBrowseInfo;

                    int rowId = Database.createData("item_resource_node_map", "item_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in item_resource_node_map");
                    }

                    Database.updateData("item_resource_node_map", "item_resource_node_map_id", rowId, "ref_tool_type_id", (int)gridRow.Cells["ref_tool_type_id"].Value);
                    Database.updateData("item_resource_node_map", "item_resource_node_map_id", rowId, "statistic_def_id", statDefIdBrowseInfo.Id);
                    Database.updateData("item_resource_node_map", "item_resource_node_map_id", rowId, "min_skill", (int)gridRow.Cells["min_skill"].Value);
                    Database.updateData("item_resource_node_map", "item_resource_node_map_id", rowId, "gather_amount", (int)gridRow.Cells["gather_amount"].Value);
                    Database.updateData("item_resource_node_map", "item_resource_node_map_id", rowId, "resource_def_id", resourceDefIdBrowseInfo.Id);
                }
            }
            gridResources.flushDeletedRows();
        }
コード例 #7
0
        private void saveAccessLevelsGrid(int aDefId)
        {
            Database.deleteData("zone_access_map", "zone_def_id", aDefId);
            foreach (DataGridViewRow gridRow in gridAccessLevels.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    EditorBrowseInfo accessDefIdBrowseInfo = gridRow.Cells["access_def_id"].Value as EditorBrowseInfo;
                    if (accessDefIdBrowseInfo == null)
                    {
                        continue;
                    }

                    int rowId = Database.createData("zone_access_map", "zone_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in zone_access_map");
                    }

                    Database.updateData("zone_access_map", "zone_access_map_id", rowId, "access_def_id", accessDefIdBrowseInfo.Id);
                }
            }

            gridAccessLevels.flushDeletedRows();
        }
コード例 #8
0
        private void saveConversationsGrid(int aDefId)
        {
            Database.deleteData("npc_conversation_map", "npc_def_id", aDefId);
            foreach (DataGridViewRow gridRow in gridConversations.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    if (string.IsNullOrEmpty(gridRow.Cells["keyword"].ToString()) ||
                        string.IsNullOrEmpty(gridRow.Cells["conversation"].ToString()))
                    {
                        continue;
                    }

                    int rowId = Database.createData("npc_conversation_map", "npc_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in npc_conversation_map");
                    }

                    Database.updateData("npc_conversation_map", "npc_conversation_map_id", rowId, "keyword", gridRow.Cells["keyword"].ToString());
                    Database.updateData("npc_conversation_map", "npc_conversation_map_id", rowId, "conversation", gridRow.Cells["conversation"].ToString());
                    if (gridRow.Cells["is_default"].Value != null)
                    {
                        Database.updateData("npc_conversation_map", "npc_conversation_map_id", rowId, "is_default", (int)gridRow.Cells["is_default"].Value);
                    }

                    EditorBrowseInfo factionDefIdBrowseInfo = gridRow.Cells["faction_def_id"].Value as EditorBrowseInfo;
                    Database.updateData("npc_conversation_map", "npc_conversation_map_id", rowId, "faction_def_id", factionDefIdBrowseInfo.Id);
                    Database.updateData("npc_conversation_map", "npc_conversation_map_id", rowId, "faction_reputation", (int)gridRow.Cells["faction_reputation"].Value);
                }
            }
            gridConversations.flushDeletedRows();
        }
コード例 #9
0
        private void saveItemGrid(int aDefId)
        {
            Database.deleteData("space_item_map", "space_def_id", aDefId);
            foreach (DataGridViewRow gridRow in gridItems.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    EditorBrowseInfo itemDefIdBrowseInfo = gridRow.Cells["item_def_id"].Value as EditorBrowseInfo;
                    if (itemDefIdBrowseInfo == null)
                    {
                        continue;
                    }

                    int rowId = Database.createData("space_item_map", "space_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in space_item_map");
                    }

                    Database.updateData("space_item_map", "space_item_map_id", rowId, "item_def_id", itemDefIdBrowseInfo.Id);
                    if (gridRow.Cells["quantity"].Value == null)
                    {
                        Database.updateData("space_item_map", "space_item_map_id", rowId, "quantity", 1);
                    }
                    else
                    {
                        Database.updateData("space_item_map", "space_item_map_id", rowId, "quantity", (int)gridRow.Cells["quantity"].Value);
                    }
                }
            }
            gridItems.flushDeletedRows();
        }
コード例 #10
0
        private void saveAbilitiesGrid(int aDefId)
        {
            Database.deleteData("npc_ability_map", "npc_def_id", aDefId);
            foreach (DataGridViewRow gridRow in gridAbilities.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    EditorBrowseInfo abilityDefIdBrowseInfo = gridRow.Cells["ability_def_id"].Value as EditorBrowseInfo;
                    if (abilityDefIdBrowseInfo == null)
                    {
                        continue;
                    }

                    int rowId = Database.createData("npc_ability_map", "npc_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in npc_ability_map");
                    }

                    Database.updateData("npc_ability_map", "npc_ability_map_id", rowId, "ability_def_id", abilityDefIdBrowseInfo.Id);
                    if (gridRow.Cells["is_default"].Value != null)
                    {
                        Database.updateData("npc_ability_map", "npc_ability_map_id", rowId, "is_default", (int)gridRow.Cells["is_default"].Value);
                    }
                }
            }
            gridAbilities.flushDeletedRows();
        }
コード例 #11
0
        void gridItems_CurrentCellDirtyStateChanged(object sender, EventArgs e)
        {
            if (gridItems.CurrentCell == null)
            {
                return;
            }

            if (gridItems.CurrentCell is DataGridViewTypedLinkCell)
            {
                // Find the slot information
                EditorBrowseInfo itemDefIdBrowseInfo = gridItems.CurrentRow.Cells["item_def_id"].Value as EditorBrowseInfo;
                int itemDefId = itemDefIdBrowseInfo.Id;

                DataTable dt = Database.getData("item_slot_map", "item_def_id", itemDefId, null);
                if (dt == null)
                {
                    return;
                }
                if (dt.Rows.Count == 0)
                {
                    return;
                }

                DataRow dataRow = dt.Rows[0];
                DataGridViewLinkCell cellSlot = gridItems.CurrentRow.Cells["slot_def_id"] as DataGridViewLinkCell;
                cellSlot.Value = EditorFactory.getBrowseInfo(EditorSystemType.Slot, dataRow, "slot_def_id");

                DataGridViewNumericUpDownElements.DataGridViewNumericUpDownCell cellQty = gridItems.CurrentRow.Cells["quantity"] as DataGridViewNumericUpDownElements.DataGridViewNumericUpDownCell;
                cellQty.Value = (int)1;
            }
        }
コード例 #12
0
        private void saveTablesGrid(int aDefId)
        {
            Database.deleteData("treasure_table_map", "treasure_def_id", aDefId);
            foreach (DataGridViewRow gridRow in gridTables.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    int rowId = Database.createData("treasure_table_map", "treasure_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in treasure_table_map");
                    }

                    EditorBrowseInfo tableDefIdBrowseInfo = gridRow.Cells["treasure_table_def_id"].Value as EditorBrowseInfo;
                    if (tableDefIdBrowseInfo != null)
                    {
                        Database.updateData("treasure_table_map", "treasure_table_map_id", rowId, "treasure_table_def_id", tableDefIdBrowseInfo.Id);
                    }

                    if (gridRow.Cells["item_quantity"].Value != null)
                    {
                        Database.updateData("treasure_table_map", "treasure_table_map_id", rowId, "item_quantity", (int)gridRow.Cells["item_quantity"].Value);
                    }
                    if (gridRow.Cells["min_coin"].Value != null)
                    {
                        Database.updateData("treasure_table_map", "treasure_table_map_id", rowId, "min_coin", (int)gridRow.Cells["min_coin"].Value);
                    }
                    if (gridRow.Cells["max_coin"].Value != null)
                    {
                        Database.updateData("treasure_table_map", "treasure_table_map_id", rowId, "max_coin", (int)gridRow.Cells["max_coin"].Value);
                    }
                }
            }
            gridTables.flushDeletedRows();
        }
コード例 #13
0
 public AuraLinkLabel()
 {
     Padding   = new Padding(20, 1, 0, 0); // <-- This kicks the text over so that the icon can be left aligned
     AllowDrop = true;
     Text      = string.Empty;
     Tag       = new EditorBrowseInfo(SystemTypes.None, string.Empty, 0, 0);
 }
コード例 #14
0
        private void saveNpcGrid(int aDefId)
        {
            Database.deleteData("spawn_npc_map", "spawn_def_id", aDefId);
            foreach (DataGridViewRow gridRow in gridNpcs.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    EditorBrowseInfo defIdBrowseInfo = gridRow.Cells["npc_def_id"].Value as EditorBrowseInfo;
                    if (defIdBrowseInfo == null)
                    {
                        continue;
                    }

                    int rowId = Database.createData("spawn_npc_map", "spawn_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in spawn_npc_map");
                    }

                    Database.updateData("spawn_npc_map", "spawn_npc_map_id", rowId, "npc_def_id", defIdBrowseInfo.Id);
                    if (gridRow.Cells["ref_behavior_id"].Value != null)
                    {
                        Database.updateData("spawn_npc_map", "spawn_npc_map_id", rowId, "ref_behavior_id", (int)gridRow.Cells["ref_behavior_id"].Value);
                    }
                }
            }
            gridNpcs.flushDeletedRows();
        }
コード例 #15
0
        public static TreeNode FindTreeNode(this TreeView value, EditorBrowseInfo browseInfo)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value), Resources.NullParameterErrorMessage);
            }

            return(FindTreeNodeImpl(value.Nodes, browseInfo));
        }
コード例 #16
0
        protected override void OnDoubleClick(EventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException(nameof(e), Resources.NullParameterErrorMessage);
            }

            Tag  = new EditorBrowseInfo(_systemType, string.Empty, 0, 0);
            Text = string.Empty;
            base.OnDoubleClick(e);
        }
コード例 #17
0
        private static bool CompareNodeToBrowse(TreeNode aNode, EditorBrowseInfo browseInfo)
        {
            var nodeInfo = aNode.Tag as EditorBrowseInfo;

            if (nodeInfo == null)
            {
                return(false);
            }

            return(nodeInfo.SystemType == browseInfo.SystemType &&
                   nodeInfo.ClassId == browseInfo.ClassId &&
                   nodeInfo.Id == browseInfo.Id);
        }
コード例 #18
0
        public static bool DefaultDragCompare(this EditorBrowseInfo value, EditorBrowseInfo dragInfo)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value), Resources.NullParameterErrorMessage);
            }
            if (dragInfo == null)
            {
                throw new ArgumentNullException(nameof(dragInfo), Resources.NullParameterErrorMessage);
            }

            return(dragInfo.SystemType == value.SystemType && dragInfo.Id > 0);
        }
コード例 #19
0
        public void OpenTab(EditorBrowseInfo browseInfo, bool openCopy, bool makeDirty)
        {
            if (browseInfo == null)
            {
                throw new ArgumentNullException(nameof(browseInfo), Resources.NullParameterErrorMessage);
            }

            TabPage page = null;

            // If we are not opening a copy, always create a new page and do not use an already open page.
            if (!openCopy)
            {
                page = FindTab(browseInfo.SystemType, browseInfo.Id);
            }

            if (page != null)
            {
                tabContent.SelectedTab = page;
            }
            else
            {
                var builder = EditorFactory.Builders[EnumerationExtensions.GetEnum <SystemTypes>((int)browseInfo.SystemType)];
                if (!builder.HasEditor())
                {
                    return;
                }

                // Create a new edit control based on the selected node
                var editControl =
                    EditorFactory.Create(EnumerationExtensions.GetEnum <SystemTypes>((int)browseInfo.SystemType),
                                         browseInfo.ClassId);

                // Initialize the new control with the content that was dclicked
                editControl.InitContent(browseInfo.Id);
                var tabName = editControl.ControlName;
                if (openCopy)
                {
                    editControl.MakeCopy();
                    tabName = "*" + editControl.ControlName + "*";
                }
                else if (makeDirty)
                {
                    editControl.MakeDirty();
                    tabName = "*" + editControl.ControlName + "*";
                }

                tabName = $"[{editControl.Id}] {tabName}";

                CreateContentTab(tabName, editControl);
            }
        }
コード例 #20
0
        private static TreeNode FindTreeNodeImpl(IEnumerable aNodeCollection, EditorBrowseInfo browseInfo)
        {
            foreach (TreeNode node in aNodeCollection)
            {
                if (CompareNodeToBrowse(node, browseInfo))
                {
                    return(node);
                }

                var foundNode = FindTreeNodeImpl(node.Nodes, browseInfo);
                if (foundNode != null)
                {
                    return(foundNode);
                }
            }

            return(null);
        }
コード例 #21
0
        private void saveExitGrid(int aDefId)
        {
            Database.deleteData("space_exit_map", "space_def_id", aDefId);
            foreach (DataGridViewRow gridRow in gridExits.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    EditorBrowseInfo spaceDefIdBrowseInfo = gridRow.Cells["destination_space_def_id"].Value as EditorBrowseInfo;
                    if (spaceDefIdBrowseInfo == null)
                    {
                        continue;
                    }

                    int rowId = Database.createData("space_exit_map", "space_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in space_exit_map");
                    }

                    Database.updateData("space_exit_map", "space_exit_map_id", rowId, "ref_direction_id", (gridRow.Cells["ref_direction_id"].Value as TagInfo).Id);
                    Database.updateData("space_exit_map", "space_exit_map_id", rowId, "destination_space_def_id", spaceDefIdBrowseInfo.Id);

                    int flags =
                        (Convert.ToBoolean(gridRow.Cells["is_hidden"].Value) ? Globals.EXIT_FLAG_Hidden : 0) |
                        (Convert.ToBoolean(gridRow.Cells["is_oneway"].Value) ? Globals.EXIT_FLAG_OneWay : 0) |
                        (Convert.ToBoolean(gridRow.Cells["is_transparent"].Value) ? Globals.EXIT_FLAG_Transparent : 0);
                    Database.updateData("space_exit_map", "space_exit_map_id", rowId, "flags", flags);

                    if (gridRow.Cells["ref_difficulty_id"].Value != null)
                    {
                        Database.updateData("space_exit_map", "space_exit_map_id", rowId, "ref_difficulty_id", (gridRow.Cells["ref_difficulty_id"].Value as TagInfo).Id);
                    }

                    EditorBrowseInfo barrierDefIdBrowseInfo = gridRow.Cells["barrier_def_id"].Value as EditorBrowseInfo;
                    if (barrierDefIdBrowseInfo != null)
                    {
                        Database.updateData("space_exit_map", "space_exit_map_id", rowId, "barrier_def_id", barrierDefIdBrowseInfo.Id);
                    }
                }
            }
            gridExits.flushDeletedRows();
        }
コード例 #22
0
        private void saveTerrainGrid(int aDefId)
        {
            foreach (DataGridViewRow gridRow in gridTerrain.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    EditorBrowseInfo terrainDefIdBrowseInfo = gridRow.Cells["terrain_def_id"].Value as EditorBrowseInfo;
                    if (terrainDefIdBrowseInfo == null)
                    {
                        continue;
                    }

                    int rowId = Database.createData("item_vehicle_terrain_map", "item_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in item_vehicle_terrain_map");
                    }

                    Database.updateData("item_vehicle_terrain_map", "item_vehicle_terrain_map_id", rowId, "statistic_def_id", terrainDefIdBrowseInfo.Id);
                }
            }

            gridTerrain.flushDeletedRows();
        }
コード例 #23
0
        private void saveResourcesGrid(int aDefId)
        {
            foreach (DataGridViewRow gridRow in gridResources.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    EditorBrowseInfo resourceDefIdBrowseInfo = gridRow.Cells["resource_item_def_id"].Value as EditorBrowseInfo;
                    if (resourceDefIdBrowseInfo == null)
                    {
                        continue;
                    }

                    int rowId = Database.createData("item_formula_resource_map", "item_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in item_formula_resource_map");
                    }

                    Database.updateData("item_formula_resource_map", "item_formula_resource_map_id", rowId, "resource_item_def_id", resourceDefIdBrowseInfo.Id);
                    Database.updateData("item_formula_resource_map", "item_formula_resource_map_id", rowId, "resource_quantity", (int)gridRow.Cells["resource_quantity"].Value);
                }
            }
            gridResources.flushDeletedRows();
        }
コード例 #24
0
        private void saveEffectsGrid(int aDefId)
        {
            Database.deleteData("space_effect_map", "space_def_id", aDefId);
            foreach (DataGridViewRow gridRow in gridEffects.Rows)
            {
                if (!gridRow.IsNewRow && gridRow.Visible)
                {
                    EditorBrowseInfo effectDefIdBrowseInfo = gridRow.Cells["space_effect_def_id"].Value as EditorBrowseInfo;
                    if (effectDefIdBrowseInfo == null)
                    {
                        continue;
                    }

                    int rowId = Database.createData("space_effect_map", "space_def_id", aDefId, null, null);
                    if (rowId == 0)
                    {
                        throw new Exception("Failed to create new row in space_effect_map");
                    }

                    Database.updateData("space_effect_map", "space_effect_map_id", rowId, "space_effect_def_id", effectDefIdBrowseInfo.Id);
                }
            }
            gridEffects.flushDeletedRows();
        }
コード例 #25
0
        private void InitAll()
        {
            try
            {
                SystemTags.Init();

                treeBrowse.Nodes.Clear();

                imagesSystem.Images.Clear();
                imagesSystem.Images.Add("openFolder", ShellIcon.extractIconFromFile("shell32.dll", 4, false));
                foreach (var builder in EditorFactory.Builders.Values)
                {
                    imagesSystem.Images.Add(builder.DisplayName, builder.Icon);
                }

                treeBrowse.BeginUpdate();
                treeBrowse.ImageList = imagesSystem;
                tabContent.ImageList = imagesSystem;

                var filterText = txtFilter.Text.Trim();
                Program.MainForm.ProgressStatus.Minimum = 0;
                Program.MainForm.ProgressStatus.Maximum = EditorFactory.Builders.Count;
                Program.MainForm.ProgressStatus.Value   = Program.MainForm.ProgressStatus.Minimum;

                // Initialize the interface with the registered editors
                foreach (var builder in EditorFactory.Builders.Values)
                {
                    if (!builder.IsVisible)
                    {
                        continue;
                    }

                    var dbContext = Program.NinjectKernel.Get <IRealmDbContext>();
                    var classList = dbContext.SystemClasses
                                    .Where(x => x.SystemType == builder.SystemType)
                                    .Where(x => x.ParentClassId == null)
                                    .ToList();

                    if (classList.Count > 1)
                    {
                        throw new EditorException("Multiple parent classes for system [" + builder.SystemType + "]");
                    }

                    if (!classList.Any())
                    {
                        throw new EditorException($"No parent class for system [{builder.SystemType}]");
                    }

                    var classId = classList.First().Id;

                    var rootNode   = new TreeNode(builder.DisplayPlural);
                    var browseInfo = new EditorBrowseInfo(builder.SystemType, builder.DisplayName, classId, 0);
                    rootNode.Tag              = browseInfo;
                    rootNode.ImageKey         = Resources.ClosedFolderImageKey;
                    rootNode.ContextMenuStrip = contextBrowseFolder;

                    rootNode.SetupBrowseTree(builder, true, filterText);
                    if (!builder.HasDelete())
                    {
                        // This will disable for everything...?
                        // contextBrowseNode.Items[0].Enabled = false;
                    }
                    builder.PopulateBrowseNode(rootNode, browseInfo.ClassId, contextBrowseNode, txtFilter.Text.Trim());
                    treeBrowse.Nodes.Add(rootNode);
                    Program.MainForm.ProgressStatus.Value += 1;
                }

                treeBrowse.EndUpdate();
                Application.DoEvents();
                Program.MainForm.SetStatusMessage($"{EditorFactory.Builders.Count} builders initialized.");
                Program.Log.InfoFormat(Resources.TEXT_BUILDER_INIT_SUMMARY.Replace("{0}",
                                                                                   EditorFactory.Builders.Count.ToString()));
            }
            catch (Exception ex)
            {
                Program.Log.Error(ex.Message, ex);
            }
        }
コード例 #26
0
 public void Clear()
 {
     Text = string.Empty;
     Tag  = new EditorBrowseInfo(_systemType, string.Empty, 0, 0);
 }
コード例 #27
0
 public virtual bool HandleCustomDrag(DragEventArgs e, EditorBrowseInfo aTargetBrowseInfo, bool aSetValue)
 {
     return(false);
 }