コード例 #1
0
        private void onEntityRenamed(GodzGlue.Entity entity)
        {
            TreeNode n = (TreeNode)actorTreeMap[entity];

            if (n != null)
            {
                n.Text = getEntityName(entity);
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        private String getEntityName(GodzGlue.Entity e)
        {
            UInt32 hash = e.getObjectName();
            String text = Editor.GetHashString(hash);

            if (text == null)
            {
                text = "<" + e.getClass().ClassName + ">";
            }

            return(text);
        }
コード例 #5
0
        //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;
                }
            }
        }
コード例 #6
0
        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";
            }
        }
コード例 #7
0
        //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();
        }
コード例 #8
0
        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]);
        }