private void refreshToolStripMenuItem_Click(object sender, EventArgs e) { TabPanelData data = mMainForm.getTabPanel(); Editor.RefreshEntity(data.mSelectedEntity, data.mSelectedEntity.getLayer().getName()); GodzUtil.RunMainPass(); }
private void tabControl1_Selected(object sender, TabControlEventArgs e) { sendLostFocusEvent(); mActiveTabPage = e.TabPage; TabPanelData data = (TabPanelData)mTabMap[mActiveTabPage]; data.mListener.OnGainedFocus(); //make sure the tab has a viewport.... if (data.mViewportId.ToInt32() != 0) { GodzUtil.SetViewport(data.mViewportId); if (data.mPrimaryCamera != null) { data.mPrimaryCamera.GrabFocus(); if (data.mSun != null) { //Inform the rendering pipe about the active sunlight data.mSun.setSunLight(); } else { //clear the renderer's active sunlight GodzUtil.ResetSunLight(); } //tick game engine so that it will inform renderer we've switched the primary camera GodzUtil.RunMainPass(); } } }
private void lockForEditingToolStripMenuItem_Click(object sender, EventArgs e) { TabPanelData data = mMainForm.getTabPanel(); DatabaseObjectInfo inf = DatabaseObjectRegistry.get(data.mSelectedEntity); if (inf.locked) { //they trying to checkin changes... submitChanges(); if (Editor.UnlockEntity(data.mSelectedEntity)) { propertyGrid1.Enabled = false; } } else { //grab latest from the server then lock it Editor.RefreshEntity(data.mSelectedEntity, data.mActiveLayer.getName()); if (Editor.LockEntity(data.mSelectedEntity)) { propertyGrid1.Enabled = true; } } }
public void setTabData(TabPanelData data, MainForm1 mainForm) { mMainForm = mainForm; data.mViewportId = pictureBox1.Handle; buildMaterialsTree(); }
public static void addLayerToTree(GodzGlue.Layer layer, TreeView treeView, TabPanelData data, ContextMenuStrip childNodeMenu, TreeNode levelNode) { System.Windows.Forms.TreeNode treeNode2 = null; String nodeName = Editor.GetHashString(layer.getName()); if (nodeName != null) { treeNode2 = new System.Windows.Forms.TreeNode(nodeName); } else { //Error- Editor never submitted the sector name to the DB... return; } levelNode.Nodes.Add(treeNode2); treeNode2.ContextMenuStrip = childNodeMenu; treeNode2.Checked = true; treeNode2.Tag = layer; if (layer.getName() == data.mActiveLayer.getName()) { //assign this layer a special color.... treeNode2.ForeColor = System.Drawing.Color.DarkBlue; } }
public OpenLayerForm(TabPanelData data) { InitializeComponent(); mData = data; List <uint> hashList = new List <uint>(); //Load all the available sectors... try { SqlDataReader myReader = null; SqlCommand myCommand = new SqlCommand("select * from Layers", Editor.sqlConnection); myReader = myCommand.ExecuteReader(); while (myReader.Read()) { Int64 db_hash = (Int64)myReader["HashCode"]; uint hash = (uint)db_hash; hashList.Add(hash); } myReader.Close(); } catch (Exception e) { Console.WriteLine(e.ToString()); } foreach (uint hash in hashList) { String name = Editor.GetHashString(hash); sectorsComboBox1.Items.Add(name); } }
private void propertyGrid1_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { TabPanelData data = mMainForm.getTabPanel(); //We should go update all the Entity names on the tree just incase one of the //properties was the name onEntityRenamed(data.mSelectedEntity); }
private void zoomToActorToolStripMenuItem_Click(object sender, EventArgs e) { TabPanelData data = mMainForm.getTabPanel(); data.mPrimaryCamera.moveToActor(data.mSelectedEntity); GodzUtil.RunMainPass(); }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { TabPanelData data = (TabPanelData)mTabMap[mActiveTabPage]; if (data.mListener != null) { data.mListener.OnSave(); } }
public void setViewport() { GodzUtil.AddViewport(pictureBox1.Handle); TabPanelData data = mMainForm.getTabPanel(); data.mActiveLayer = data.mWorld.addLayer("Default"); data.mPrimaryCamera = data.mActiveLayer.spawnCamera(ref zero, ref zero); data.mPrimaryCamera.GrabFocus(); //make this camera primary }
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 sendLostFocusEvent() { if (mActiveTabPage != null) { TabPanelData old_data = (TabPanelData)mTabMap[mActiveTabPage]; if (old_data != null) { old_data.mListener.OnLostFocus(); } } }
private void navMeshToolStripButton1_Click(object sender, EventArgs e) { //generates a navigation mesh for the level.... TabPanelData data = mMainForm.getTabPanel(); if (data.mActiveLayer != null) { string layerName = Editor.GetHashString(data.mActiveLayer.getName()); data.mActiveLayer.buildNavigationMesh(); data.mActiveLayer.saveNavigationMesh(layerName); } }
// This is the method to run when the timer is raised. private void MainForm1_Timer(Object myObject, EventArgs myEventArgs) { //tick the game logic so events are dispersed //float elapsedTime = GodzUtil.RunMainPass(); //Console.WriteLine("Elapsed Time " + elapsedTime); GodzUtil.RunMainPass(); TabPanelData currTab = getTabPanel(); if (currTab != null) { currTab.mListener.OnTick(); } foreach (GodzGlue.PackageFuture pf in mFutures) { if (pf.isReady()) { GodzGlue.Package p = pf.getPackage(); packages.Add(p); //iterate through all the trees and update... int len = mTabs.Count; for (int i = 0; i < len; i++) { TabPage tab = mTabs[i]; TabPanelData data = (TabPanelData)mTabMap[tab]; data.mListener.PackageLoaded(p); } //see if its the editor package if (p.GetName() == mEditorName) { //now assign the editor icon to all Entity objects uint entityName = GodzUtil.GetHashCode("WEntity"); ClassBase classBase = ClassBase.findClass(entityName); if (classBase != null) { uint matName = GodzUtil.GetHashCode("icon"); mDefaultEntityMaterial = p.FindObject(matName) as Material; if (mDefaultEntityMaterial != null) { classBase.setMaterial(mDefaultEntityMaterial); } } } mFutures.Remove(pf); break; //list was modified while iterating... } } }
private void moveToolStripButton1_CheckStateChanged(object sender, EventArgs e) { //determine if we need to activate/deactivate move mode ToolStripButton button = (ToolStripButton)sender; isCharacterMovementActive = button.Checked; if (!isCharacterMovementActive) { TabPanelData data = mMainForm.getTabPanel(); data.mWorld.selectAxis(GizmoAxis.GizmoAxis_None); } }
private void clearSelection(TabPanelData data) { //clear out the previous selection data.mWorld.selectAxis(GizmoAxis.GizmoAxis_None); mHighlightedAxis = GizmoAxis.GizmoAxis_None; if (data.mSelectedEntity != null) { data.mWorld.deselectEntity(data.mSelectedEntity); data.mSelectedEntity = null; } propertyGrid1.SelectedObject = null; }
public void pictureBox1_MouseWheel(object sender, MouseEventArgs e) { if (mCameraInputActive) { TabPanelData data = (TabPanelData)mTabMap[mActiveTabPage]; GodzGlue.Camera cam = data.mPrimaryCamera; float mousedelta = (float)e.Delta / 120.0f; cam.MoveForward(mousedelta); //tick the actors so they send events over to renderer GodzUtil.RunMainPass(); } }
private void packageToolStripMenuItem_Click(object sender, EventArgs e) { NewPackageForm dlg = new NewPackageForm(); if (dlg.ShowDialog() == DialogResult.OK) { GodzGlue.Package p = dlg.getPackage(); //iterate through all the trees and update... int len = mTabs.Count; for (int i = 0; i < len; i++) { TabPage tab = mTabs[i]; TabPanelData data = (TabPanelData)mTabMap[tab]; data.mListener.PackageLoaded(p); } } }
private void submitChanges() { TabPanelData data = mMainForm.getTabPanel(); DatabaseObjectInfo inf = DatabaseObjectRegistry.get(data.mSelectedEntity); if (inf.locked) { //Update the database entry for this item Editor.UpdateEntity(data.mSelectedEntity.getLayer().getName(), data.mSelectedEntity); //remove from the modified actors list modifiedActorList.Remove(data.mSelectedEntity); } else { MessageBox.Show("Changes cannot be submitted for an unlocked object"); } }
//Makes a Layer active private void makeActiveToolStripMenuItem_Click(object sender, EventArgs e) { TabPanelData data = mMainForm.getTabPanel(); TreeNode node = sectorsTreeView1.SelectedNode; Layer activeLayer = (Layer)node.Tag; if (activeLayer != null && data.mActiveLayer != activeLayer) { setActiveLayer(activeLayer); WorldEditor.buildLayersTree(sectorsTreeView1, "World", data, layerContextMenuStrip, layerContextSubMenuStrip); //re-expand the tree sectorsTreeView1.ExpandAll(); clearSelection(data); } }
public void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (mCameraInputActive && e.Button == MouseButtons.Right) { TabPanelData data = (TabPanelData)mTabMap[mActiveTabPage]; GodzGlue.Camera cam = data.mPrimaryCamera; PictureBox pictureBox = sender as PictureBox; if (pictureBox != null) { cam.UpdateView(Cursor.Position.X, Cursor.Position.Y, origin.X, origin.Y, 0.1f); centerCursor(pictureBox); } //tick the actors so they send events over to renderer GodzUtil.RunMainPass(); } }
public void setTabData(TabPanelData data, MainForm1 mainForm) { mMainForm = mainForm; data.mViewportId = pictureBox1.Handle; data.entityOptionMenuStrip = contextMenuStrip1; WorldEditor.buildLayersTree(sectorsTreeView1, "World", data, layerContextMenuStrip, layerContextSubMenuStrip); pictureBox1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseClick); pictureBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(mainForm.pictureBox1_MouseDown); pictureBox1.MouseUp += new System.Windows.Forms.MouseEventHandler(mainForm.pictureBox1_MouseUp); pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(mainForm.pictureBox1_MouseMove); pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove); pictureBox1.MouseWheel += new System.Windows.Forms.MouseEventHandler(mainForm.pictureBox1_MouseWheel); buildPackageTree(); }
private void worldToolStripMenuItem_Click(object sender, EventArgs e) { sendLostFocusEvent(); //hide the DB access panel this.mainPanel1.SendToBack(); TabPanelData data = new TabPanelData(); data.mWorld = GodzUtil.AddLevel(); mActiveTabPage = new TabPage(mDefaultWorldName); tabControl1.TabPages.Add(mActiveTabPage); WorldEditorForm form = new WorldEditorForm(); mListeners.Add(form); data.mListener = form; form.TopLevel = false; form.Visible = true; form.Dock = DockStyle.Fill; form.Location = new System.Drawing.Point(0, 0); form.Name = "worldEditorForm"; form.setTabData(data, this); mActiveTabPage.Controls.Add(form); tabControl1.ResumeLayout(false); mActiveTabPage.ResumeLayout(false); mTabMap.Add(mActiveTabPage, data); mTabs.Add(mActiveTabPage); tabControl1.SelectedTab = mActiveTabPage; form.setViewport(); //GodzUtil.ResetSunLight(); //tick the engine-- add the new camera, etc GodzUtil.RunMainPass(); ((TabPanelListener)form).OnGainedFocus(); }
private void setActiveLayer(Layer layer) { TabPanelData data = mMainForm.getTabPanel(); data.mActiveLayer = layer; //Change Tab name to the Active Layer String layerName = Editor.GetHashString(layer.getName()); if (layerName != null) { mMainForm.mActiveTabPage.Text = layerName; } //if it's a brand new layer; we acquire everything from SQL Server if (layer.getNumActors() == 0) { data.mPrimaryCamera = data.mActiveLayer.spawnCamera(ref zero, ref zero); data.mPrimaryCamera.GrabFocus(); //make this camera primary Editor.LoadEntities(data); layer.loadNavigationMesh(layerName); } else { //restore the previous layer data.mPrimaryCamera = layer.getPrimaryCamera(); data.mPrimaryCamera.GrabFocus(); //make this camera primary } mSceneCamera = data.mPrimaryCamera; //add all the newly loaded packages packageTreeView1.Nodes.Clear(); buildPackageTree(); buildActorTree(data); sectorsTreeView1.ExpandAll(); }
//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 openSectorToolStripMenuItem_Click(object sender, EventArgs e) { if (Editor.IsConnectedToDatabase()) { TabPanelData data = mMainForm.getTabPanel(); OpenLayerForm form = new OpenLayerForm(data); if (form.ShowDialog() == DialogResult.OK) { //Make it the active layer if one hasn't been set if (data.mActiveLayer == null) { setActiveLayer(form.mLayer); } //Append the Layer to the current "World" WorldEditor.addLayerToTree(form.mLayer, sectorsTreeView1, data, layerContextSubMenuStrip, sectorsTreeView1.Nodes[0]); } form.Dispose(); } }
private void MainForm1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { // Return focus to main form if (mActiveTabPage != null) { mActiveTabPage.Focus(); } return; } if (mActiveTabPage != null) { TabPanelData data = (TabPanelData)mTabMap[mActiveTabPage]; if (data.mListener != null) { data.mListener.OnKeyDown(sender, e); } } }
//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(); }
public void setViewport() { GodzUtil.AddViewport(pictureBox1.Handle); GodzUtil.SetBackgroundColor(pictureBox1.Handle, 162, 162, 162); TabPanelData data = mMainForm.getTabPanel(); data.mActiveLayer = data.mWorld.addLayer("Default"); data.mPrimaryCamera = data.mActiveLayer.spawnCamera(ref zero, ref zero); data.mPrimaryCamera.GrabFocus(); //make this camera primary mSceneCamera = data.mPrimaryCamera; data.mSun = (GodzGlue.SunLight)data.mActiveLayer.spawnActor("WSunLight", ref zero, ref zero); Vector3 sunspot = new Vector3(0.08508922f, -0.4238535f, 0.9017249f); data.mSun.setLookAt(sunspot); // Hide the sunlight icon in this scene data.mSun.hideEditorMaterial(); data.mSun.setSunLight(); }
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"; } }