private void onEntityRenamed(GodzGlue.Entity entity) { TreeNode n = (TreeNode)actorTreeMap[entity]; if (n != null) { n.Text = getEntityName(entity); } }
private void actorsTreeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { TreeNode n = e.Node; GodzGlue.Entity ent = (GodzGlue.Entity)n.Tag; if (ent != null) { TabPanelData data = mMainForm.getTabPanel(); selectEntity(ent, data); } }
private void AddActorToTree(GodzGlue.Entity actor, TreeNode parent) { String text = getEntityName(actor); TreeNode n = new System.Windows.Forms.TreeNode(text); parent.Nodes.Add(n); n.Tag = actor; //store the related entity n.ContextMenuStrip = actorContextMenuStrip1; actorTreeMap.Add(actor, n); }
private String getEntityName(GodzGlue.Entity e) { UInt32 hash = e.getObjectName(); String text = Editor.GetHashString(hash); if (text == null) { text = "<" + e.getClass().ClassName + ">"; } return(text); }
//We handle the mouse click here locally since it's specific to world editor only private void pictureBox1_MouseClick(object sender, MouseEventArgs e) { TabPanelData data = mMainForm.getTabPanel(); if (!mMainForm.mCameraInputActive && e.Button == MouseButtons.Left && data.mActiveLayer != null) { Point p = new Point(); p.X = e.X; p.Y = e.Y; GodzGlue.Entity ent = data.mActiveLayer.pickObjectAtPoint(ref p); if (ent != null) { selectEntity(ent, data); } else { propertyGrid1.SelectedObject = null; } } }
private void selectEntity(GodzGlue.Entity ent, TabPanelData data) { data.mSelectedEntity = ent; Object proxyObj = Editor.GetNewObjectProxy(ent); propertyGrid1.SelectedObject = proxyObj; DatabaseObjectInfo inf = DatabaseObjectRegistry.get(ent); //disable property editing unless this object is checked out propertyGrid1.Enabled = inf.locked; data.mWorld.selectEntity(ent); if (inf.locked) { //if we have it checked out update the tooltip lockForEditingToolStripMenuItem.Text = "Checkin"; } else { lockForEditingToolStripMenuItem.Text = "Checkout"; } }
//add all the actors for the active layer private void buildActorTree(TabPanelData data) { actorsTreeView1.Nodes.Clear(); actorTreeMap.Clear(); TreeNode treeNode2 = new System.Windows.Forms.TreeNode("Entities"); uint num = data.mActiveLayer.getNumActors(); for (uint i = 0; i < num; i++) { GodzGlue.Entity e = data.mActiveLayer.getActor(i); //Only add placeable entities if (e.getClass().isPlaceable()) { AddActorToTree(e, treeNode2); } } actorsTreeView1.Nodes.Add(treeNode2); actorsTreeView1.ExpandAll(); }
private void addToWorldToolStripMenuItem_Click(object sender, EventArgs e) { TabPanelData data = mMainForm.getTabPanel(); if (data.mActiveLayer == null) { MessageBox.Show("Cannot add an entity without an active Sector. Please add one to the Level"); return; } if (packageTreeView1.SelectedNode == null || packageTreeView1.SelectedNode.Tag == null) { //They must have selected a package node... return; } ObjectBase selectedNode = (ObjectBase)packageTreeView1.SelectedNode.Tag; //TODO: need to somehow cache off a global placement position GodzGlue.Vector3 cameraPos = data.mPrimaryCamera.getLocation(); GodzGlue.Vector3 fdir = data.mPrimaryCamera.getForward(); //y+ up fdir.z += 100.0f; cameraPos += fdir; GodzGlue.Entity newActor = null; if (selectedNode.IsA("Mesh")) { //build entity then set Mesh newActor = data.mActiveLayer.spawnActor("WEntity", ref cameraPos, ref zero); //Get mesh from the package Mesh m = (Mesh)selectedNode; newActor.setMesh(m); } else if (selectedNode.IsA("WSunLight")) { if (data.mSun != null) { //display error, can only have 1 Sun MessageBox.Show("You can only have 1 sunlight in the scene"); } else { data.mSun = (GodzGlue.SunLight)data.mActiveLayer.spawnActor("WSunLight", ref cameraPos, ref zero); data.mSun.setSunLight(); newActor = data.mSun; } } else { ClassBase gc = selectedNode.getClass(); newActor = data.mActiveLayer.spawnActor(gc.getObjectName(), ref cameraPos, ref zero); } //set package.... newActor.setPackage(data.mActiveLayer.getPackage()); //Add to the Database Editor.AddEntity(data.mActiveLayer.getName(), newActor); //tick the actors so they send events over to renderer GodzUtil.RunMainPass(); //Add the entity to the 'Actors' list AddActorToTree(newActor, actorsTreeView1.Nodes[0]); }