private void AddEntityTemplate(EntityTemplate Tpl) { EntityTpls.Add(Tpl.Uid, Tpl); Tpl.UiNode = EntityCats[Tpl.Category].TplNode.Nodes.Add(Tpl.Uid, Tpl.Uid); Tpl.UiNode.Tag = Tpl; }
private void tcLevelsObjects_SelectedIndexChanged(object sender, EventArgs e) { pEntButtons.Visible = (tcLevelsObjects.SelectedTab == tpEntities); pTplButtons.Visible = (tcLevelsObjects.SelectedTab == tpEntityCats); if (tcLevelsObjects.SelectedTab == tpEntityCats) { CurrTemplate = null; OnSelectTplTreeNode(tvCatsTpls.SelectedNode); } else if (tcLevelsObjects.SelectedTab == tpEntities) { DontFocusOnEntity = true; CurrEntity = null; OnSelectEntityTreeNode(tvEntities.SelectedNode); } else PropGrid.SelectedObject = null; }
private void OnSelectTplTreeNode(TreeNode Node) { if (Node == null) { tvCatsTpls.SelectedNode = tvCatsTpls.Nodes[0]; return; } if (Node.Level == 1) { // Select entity template EntityTemplate Tpl = Node.Tag as EntityTemplate; if (Tpl != CurrTemplate) { //???if (CurrTemplate != null && !CreateNewTpl) CurrTemplate.Save(); CurrTemplate = Tpl; if (CurrTemplate != null) CurrTemplate.Update(); PropGrid.SelectedObject = CurrTemplate; } CreateNewTpl = false; lCatName.Text = Tpl.Category; } else if (Node.Level == 0) { // Select category in template tree Category Cat = Node.Tag as Category; CurrTemplate = new EntityTemplate("", Cat); CurrTemplate.Update(); PropGrid.SelectedObject = CurrTemplate; CreateNewTpl = true; lCatName.Text = Cat.Name; } //???need 2 different buttons?! bCreateTemplate.Visible = CurrTemplate != null && CreateNewTpl; bApplyTplChanges.Visible = CurrTemplate != null && !CreateNewTpl; bDeleteTemplate.Visible = CurrTemplate != null && !CreateNewTpl; tvCatsTpls.Focus(); }
bool LoadProject(string ProjectRoot) { if (EngineAPI.Engine.Init(EngineViewPanel.Handle, ProjectRoot) == 0) { CurrProject = ProjectRoot; MouseCb = new EngineAPI.MouseButtonCallback(EngineViewPanel_MouseCallback); EngineAPI.Engine.SetMouseButtonCallback(MouseCb); int LvlCount = EngineAPI.Levels.GetCount(); for (int i = 0; i < LvlCount; i++) lbLevels.Items.Add(EngineAPI.Levels.GetIDName(i)); if (EngineAPI.Categories.ParseAttrDescs("home:Data/AttrDescs.hrd")) { int AttrDescCount = EngineAPI.Categories.GetAttrDescCount(); AttrDesc.DescList = new Dictionary<string, AttrDesc>(AttrDescCount); for (int i = 0; i < AttrDescCount; i++) { AttrDesc Desc; string Name = EngineAPI.Categories.GetAttrDesc(i, out Desc); if (Desc.ResourceExt.Length > 0) Desc.ResourceDir = CurrProject.Replace('\\', '/') + "/Content" + Desc.ResourceDir; AttrDesc.DescList.Add(Name, Desc); } } EntityCats.Clear(); EntityTpls.Clear(); tvCatsTpls.Nodes.Clear(); tvEntities.Nodes.Clear(); int CatCount = EngineAPI.Categories.GetCount(); for (int i = 0; i < CatCount; i++) { Category Cat = AddCategory(i); if (Cat != null) { int TplCount = EngineAPI.Categories.GetTemplateCount(Cat.Name); for (int j = 0; j < TplCount; j++) { EntityTemplate Tpl = new EntityTemplate(EngineAPI.Categories.GetTemplateID(Cat.Name, j), Cat); AddEntityTemplate(Tpl); } } } return true; } return false; }
private void DeleteEntityTemplate(EntityTemplate Tpl) { Tpl.UiNode.Remove(); Tpl.UiNode = null; EntityTpls.Remove(Tpl.Uid); }
private void bSaveAsTemplate_Click(object sender, EventArgs e) { if (CurrEntity != null) { GetStringWnd Wnd = new GetStringWnd(); Wnd.UserString = CurrEntity.GuidPropValue; if (Wnd.ShowDialog() != DialogResult.OK) return; if (CurrEntity.SaveAsTemplate(Wnd.UserString)) //???need UID param? { Category Cat = EntityCats[CurrEntity.Category]; EntityTemplate Tpl = new EntityTemplate(Wnd.UserString, Cat); AddEntityTemplate(Tpl); tvCatsTpls.SelectedNode = Tpl.UiNode; tcLevelsObjects.SelectedTab = tpEntityCats; } else MessageBox.Show("Не удалось создать новый шаблон!"); } }