//--------------------------------------------------- //-------------------Methodes------------------------ //--------------------------------------------------- public void init(Form1 mainForm, CoronaJointure joint) { this.joint = joint; this.mainForm = mainForm; this.modePanel = "NEW"; if (this.joint.type.Equals("PISTON")) { this.isMotorEnabledChkBx.Checked = joint.isMotorEnable; this.isLimitedChkBx.Checked = joint.isLimitEnabled; this.motorSpeedNumUpDw.Value = System.Convert.ToInt32(joint.motorSpeed); this.maxMotorForceNumUpDw.Value = System.Convert.ToInt32(joint.maxMotorForce); this.nameObj1TxtBx.Text = joint.coronaObjA.DisplayObject.Name; this.nameObj2TxtBx.Text = joint.coronaObjB.DisplayObject.Name; this.axisDistanceTxtBx.Text = joint.axisDistance.ToString(); this.objA = joint.coronaObjA; this.objB = joint.coronaObjB; this.anchorPoint = joint.AnchorPointA; this.axisDistance = joint.axisDistance; this.modePanel = "MODIFY"; } }
//--------------------------------------------------- //-------------------Methodes------------------------ //--------------------------------------------------- public void init(Form1 mainForm, CoronaJointure joint) { this.joint = joint; this.mainForm = mainForm; if (this.joint.type.Equals("DISTANCE")) { this.frequencyNumUpDw.Value = System.Convert.ToInt32(joint.frequency); this.dampingRatioNumUpDw.Value = System.Convert.ToInt32(joint.dampingRatio); this.nameObj1TxtBx.Text = joint.coronaObjA.DisplayObject.Name; this.nameObj2TxtBx.Text = joint.coronaObjB.DisplayObject.Name; this.objA = joint.coronaObjA; this.objB = joint.coronaObjB; this.modePanel = "MODIFY"; } else { this.modePanel = "NEW"; this.frequencyNumUpDw.Value = 0; this.dampingRatioNumUpDw.Value = 0; this.nameObj1TxtBx.Text = ""; this.nameObj2TxtBx.Text = ""; } }
public CoronaEntity cloneEntity(CoronaObject objectParent) { string newName = objectParent.LayerParent.SceneParent.projectParent.IncrementObjectName(this.Name); CoronaEntity newEntity = new CoronaEntity(newName, objectParent); objectParent.Entity = newEntity; ////Copier toutes les objets for (int i = 0; i < this.CoronaObjects.Count; i++) { CoronaObject obj = this.CoronaObjects[i].cloneObject(this.CoronaObjects[i].LayerParent, true, true); newEntity.addObject(obj); } //Recreer toutes les jointures for (int i = 0; i < this.Jointures.Count; i++) { CoronaJointure currentJoint = this.Jointures[i]; int indexOfOBJA = -1; int indexOfOBJB = -1; if (currentJoint.coronaObjA != null) { indexOfOBJA = this.CoronaObjects.IndexOf(currentJoint.coronaObjA); } if (currentJoint.coronaObjB != null) { indexOfOBJB = this.CoronaObjects.IndexOf(currentJoint.coronaObjB); } CoronaObject newOBJA = null; CoronaObject newOBJB = null; if (indexOfOBJA > -1) { newOBJA = newEntity.CoronaObjects[indexOfOBJA]; } if (indexOfOBJB > -1) { newOBJB = newEntity.CoronaObjects[indexOfOBJB]; } CoronaJointure newJoint = currentJoint.clone(newOBJA, newOBJB, currentJoint.layerParent); newEntity.Jointures.Add(newJoint); } return(newEntity); }
public void Init(Form1 mainForm, CoronaJointure joint ) { this.MainForm = mainForm; this.cJoint = joint; this.modePanel="NEW"; if(this.cJoint.type.Equals("TOUCH")){ this.objTb.Text = cJoint.coronaObjA.DisplayObject.Name; this.obj = cJoint.coronaObjA; this.anchorPointTb.Text = cJoint.AnchorPointA.ToString(); this.anchorPoint = cJoint.AnchorPointA; this.modePanel="MODIFY"; } }
public void Init(Form1 mainForm, CoronaJointure joint) { this.MainForm = mainForm; this.cJoint = joint; this.modePanel = "NEW"; if (this.cJoint.type.Equals("FRICTION")) { this.obj1Tb.Text = cJoint.coronaObjA.DisplayObject.Name; objA = cJoint.coronaObjA; this.obj2Tb.Text = cJoint.coronaObjB.DisplayObject.Name; objB = cJoint.coronaObjB; anchorPoint = cJoint.AnchorPointA; this.maxForceNup.Value = Convert.ToInt32(cJoint.maxForce); this.maxTorqueNup.Value = Convert.ToInt32(cJoint.maxTorque); this.modePanel = "MODIFY"; } }
public void Init(Form1 mainForm, CoronaJointure joint) { this.MainForm = mainForm; this.cJoint = joint; this.modePanel = "NEW"; if (this.cJoint.type.Equals("PULLEY")) { setObjectA(cJoint.coronaObjA); setObjectB(cJoint.coronaObjB); setAnchorPointA(cJoint.AnchorPointA); setAnchorPointB(cJoint.AnchorPointB); setObjAnchorPointA(cJoint.ObjectAnchorPointA); setObjAnchorPointB(cJoint.ObjectAnchorPointB); this.modePanel = "MODIFY"; } }
public CoronaJointure clone(CoronaObject objA, CoronaObject objB, CoronaLayer layerParent) { CoronaJointure newJoint = new CoronaJointure(layerParent); newJoint.isEnabled = this.isEnabled; newJoint.coronaObjA = objA; newJoint.coronaObjB = objB; newJoint.type = this.type; if (objB != null) { newJoint.name = newJoint.type + "_" + objA.DisplayObject.Name + "_" + objB.DisplayObject.Name; } else { newJoint.name = newJoint.type + "_" + objA.DisplayObject.Name; } newJoint.AnchorPointA = new Point(this.AnchorPointA.X, this.AnchorPointA.Y); newJoint.AnchorPointB = new Point(this.AnchorPointB.X, this.AnchorPointB.Y); newJoint.ObjectAnchorPointA = new Point(this.ObjectAnchorPointA.X, this.ObjectAnchorPointA.Y); newJoint.ObjectAnchorPointB = new Point(this.ObjectAnchorPointB.X, this.ObjectAnchorPointB.Y); newJoint.axisDistance = new Point(this.axisDistance.X, this.axisDistance.Y); newJoint.motorSpeed = this.motorSpeed; newJoint.maxMotorForce = this.maxMotorForce; newJoint.maxMotorTorque = this.maxMotorTorque; newJoint.isMotorEnable = this.isMotorEnable; newJoint.isLimitEnabled = this.isLimitEnabled; newJoint.upperLimit = this.upperLimit; newJoint.lowerLimit = this.lowerLimit; newJoint.frequency = this.frequency; newJoint.maxForce = this.maxForce; newJoint.maxTorque = this.maxTorque; return(newJoint); }
public void Init(Form1 mainForm, CoronaJointure joint) { this.MainForm = mainForm; this.cJoint = joint; modePanel = "NEW"; if (this.cJoint.type.Equals("WHEEL")) { this.objA = cJoint.coronaObjA; obj1Tb.Text = objA.DisplayObject.Name; this.objB = cJoint.coronaObjB; obj2Tb.Text = objB.DisplayObject.Name; this.axisDistance = cJoint.axisDistance; axisDistanceTb.Text = axisDistance.ToString(); this.setAnchorPoint(cJoint.AnchorPointA); motorSpeedNup.Value = Convert.ToInt32(cJoint.motorSpeed); motorForceNup.Value = Convert.ToInt32( cJoint.maxMotorTorque); modePanel = "MODIFY"; } }
public void removeCoronaObject(CoronaObject obj) { if (obj != null && ProjectRootNodeSelected != null) { //Remove all joints including this object if (obj.isEntity == true) { CoronaObject[] listToTreat = new CoronaObject[obj.Entity.CoronaObjects.Count]; obj.Entity.CoronaObjects.CopyTo(listToTreat); for (int i = 0; i < listToTreat.Length; i++) { CoronaObject child = listToTreat[i]; this.removeCoronaObject(child); } GameElement gElementObj = this.getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, obj); if (gElementObj != null) { if (this.SelectedNodes.Contains(gElementObj)) this.SelectedNodes.Remove(gElementObj); isRemovingNode = true; gElementObj.Remove(); isRemovingNode = false; } this.CoronaObjectSelected = obj; this.removeAttributeToolStripMenuItem_Click(null, null); this.CoronaObjectSelected = null; obj.LayerParent.removeCoronaObject(obj); this.MainForm.propertyGrid1.SelectedObject = null; obj = null; if (this.MainForm.isFormLocked == false) GorgonLibrary.Gorgon.Go(); } else { if (obj.EntityParent != null) { CoronaEntity entityParent = obj.EntityParent; this.removeAllJointsUsedByObject(obj); GameElement gElementObj = this.getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, obj); if (gElementObj != null) { if (this.SelectedNodes.Contains(gElementObj)) this.SelectedNodes.Remove(gElementObj); isRemovingNode = true; gElementObj.Remove(); isRemovingNode = false; } this.CoronaObjectSelected = obj; this.removeAttributeToolStripMenuItem_Click(null, null); this.CoronaObjectSelected = null; if (obj.LayerParent.SceneParent.Camera.objectFocusedByCamera == obj) obj.LayerParent.SceneParent.Camera.objectFocusedByCamera = null; entityParent.CoronaObjects.Remove(obj); this.MainForm.sceneEditorView1.GraphicsContentManager.CleanSprite(obj, true, true); this.MainForm.propertyGrid1.SelectedObject = null; if (this.MainForm.isFormLocked == false) GorgonLibrary.Gorgon.Go(); } else { CoronaLayer layerParent = obj.LayerParent; if (layerParent != null) { CoronaJointure[] joints = new CoronaJointure[layerParent.Jointures.Count]; layerParent.Jointures.CopyTo(joints); for (int i = 0; i < joints.Length; i++) { CoronaJointure joint = joints[i]; if (joint.coronaObjA != null) { if (joint.coronaObjA == obj) { this.removeCoronaJointure(joint,layerParent); continue; } if (joint.coronaObjB == obj) { this.removeCoronaJointure(joint,layerParent); continue; } } } } GameElement gElementObj = this.getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, obj); if (gElementObj != null) { if (this.SelectedNodes.Contains(gElementObj)) this.SelectedNodes.Remove(gElementObj); isRemovingNode = true; gElementObj.Remove(); isRemovingNode = false; } this.CoronaObjectSelected = obj; this.removeAttributeToolStripMenuItem_Click(null, null); this.CoronaObjectSelected = null; layerParent.removeCoronaObject(obj); this.MainForm.sceneEditorView1.GraphicsContentManager.CleanSprite(obj, true, true); this.MainForm.propertyGrid1.SelectedObject = null; if (this.MainForm.isFormLocked == false) GorgonLibrary.Gorgon.Go(); } } } }
//---------------------------------------------------------- //----------------CORONA JOINTURE----------------------- //---------------------------------------------------------- public void newJoint(CoronaJointure joint,bool addToList,TreeNode nodeExisting) { if (joint != null) { CoronaObject coronaObjA = joint.coronaObjA; CoronaObject coronaObjB = joint.coronaObjB; if (coronaObjA != null && coronaObjB != null) { if (coronaObjA.EntityParent != null && coronaObjB.EntityParent != null) { if (coronaObjA.EntityParent == coronaObjB.EntityParent) { GameElement entityNode = getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, coronaObjA.EntityParent.objectParent); if (entityNode != null) { if (addToList == true) coronaObjA.EntityParent.Jointures.Add(joint); TreeNode nodeJoints = entityNode.Nodes["JOINTS"]; if (nodeExisting == null) { GameElement nodeNewJoint = new GameElement("JOINT", joint.name, joint); nodeJoints.Nodes.Add(nodeNewJoint); nodeNewJoint.Checked = joint.isEnabled; } else { nodeJoints.Nodes.Add(nodeExisting); } return; } } } else if (coronaObjA != null && coronaObjB == null) { if (coronaObjA.EntityParent != null) { GameElement entityNode = getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, coronaObjA.EntityParent.objectParent); if (entityNode != null) { if (addToList == true) coronaObjA.EntityParent.Jointures.Add(joint); TreeNode nodeJoints = entityNode.Nodes["JOINTS"]; if (nodeExisting == null) { GameElement nodeNewJoint = new GameElement("JOINT", joint.name, joint); nodeJoints.Nodes.Add(nodeNewJoint); nodeNewJoint.Checked = joint.isEnabled; } else { nodeJoints.Nodes.Add(nodeExisting); } return; } } } } GameElement layerNode = getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, joint.layerParent); if (layerNode != null) { if (addToList == true) joint.layerParent.Jointures.Add(joint); TreeNode nodeJoints = layerNode.Nodes["JOINTS"]; if (nodeExisting == null) { GameElement nodeNewJoint = new GameElement("JOINT", joint.name, joint); nodeNewJoint.Checked = joint.isEnabled; nodeJoints.Nodes.Add(nodeNewJoint); } else { nodeJoints.Nodes.Add(nodeExisting); } } } }
private void treeViewElements_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (hasChecked == false) { try { bool isCustomBuild = this.MainForm.IsCustomBuild; float XRatio = 1; float YRatio = 1; if (isCustomBuild == true) { XRatio = (float)this.MainForm.currentTargetResolution.Resolution.Width / (float)this.MainForm.CurrentProject.width; YRatio = (float)this.MainForm.currentTargetResolution.Resolution.Height / (float)this.MainForm.CurrentProject.height; } //Recuperer la node Project root ProjectRootNodeSelected = getRootNode(e.Node); ProjectSelected = (CoronaGameProject)ProjectRootNodeSelected.Tag; //Si il y a deja un panel Physic d'ouvert : Le fermer if (this.MainForm.CurrentObjectPhysicEditorPanel != null) if (this.MainForm.getMapEditorPage().Controls.Contains(this.MainForm.CurrentObjectPhysicEditorPanel)) { this.MainForm.getMapEditorPage().Controls.Remove(this.MainForm.CurrentObjectPhysicEditorPanel); } //SI la node selectionnée est un game element if (e.Node == this.ProjectRootNodeSelected) { ProjectPropertyConverter converter = new ProjectPropertyConverter(this.ProjectSelected, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = converter; } if (e.Node.Name.Equals("GAME_ELEMENT")) { //Faire le traitement de selection GameElement nodeSelected = (GameElement)e.Node; if (nodeSelected.NodeType.Equals("STAGE")) { this.SceneSelected = ((Scene)nodeSelected.InstanceObjet); this.MainForm.sceneEditorView1.objectsSelected.Clear(); this.MainForm.sceneEditorView1.setModeSceneEditor(this.SceneSelected); //Deselect others if (this.LayerSelected != null) { this.LayerSelected.deselectAllObjects(); this.LayerSelected.deselectAllControls(); } this.LayerSelected = null; this.CoronaObjectSelected = null; //Afficher les proprietes du layer dans le property grid ScenePropertyConverter sceneConverter = new ScenePropertyConverter(this.SceneSelected, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = sceneConverter; //Mettre a jour le fichier lua this.MainForm.cgEeditor1.RefreshSceneLuaCode(this.SceneSelected, isCustomBuild, XRatio, YRatio); } else if (nodeSelected.NodeType.Equals("LAYER")) { //Deselect others if (this.LayerSelected != null) { this.LayerSelected.deselectAllObjects(); this.LayerSelected.deselectAllControls(); } this.LayerSelected = ((CoronaLayer)nodeSelected.InstanceObjet); this.LayerSelected.deselectAllObjects(); this.LayerSelected.deselectAllControls(); this.MainForm.sceneEditorView1.objectsSelected.Clear(); this.SceneSelected = this.LayerSelected.SceneParent; this.CoronaObjectSelected = null; this.MainForm.sceneEditorView1.setModeLayerEditor(this.LayerSelected); //Afficher les proprietes du layer dans le property grid LayerPropertyConverter layerConverter = new LayerPropertyConverter(this.LayerSelected, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = layerConverter; //Mettre a jour le fichier lua //this.MainForm.cgEeditor1.RefreshSceneLuaCode(this.SceneSelected, isCustomBuild, XRatio, YRatio); } else if (nodeSelected.NodeType.Equals("OBJECT") || nodeSelected.NodeType.Equals("ENTITY")) { CoronaObject obj = ((CoronaObject)nodeSelected.InstanceObjet); //Selectionner le layer parent this.LayerSelected = obj.LayerParent; if (nodeSelected.NodeType.Equals("ENTITY")) { this.MainForm.SetModeEntity(); //this.LayerSelected.deselectAllObjects(); } else this.MainForm.SetModeObject(); //Fermer le layer et la scene this.SceneSelected = this.LayerSelected.SceneParent; this.CoronaObjectSelected = obj; //Mettre a jour le fichier lua //this.MainForm.cgEeditor1.RefreshSceneLuaCode(this.SceneSelected, isCustomBuild, XRatio, YRatio); /*if (this.MainForm.isFormLocked == false) this.MainForm.sceneEditorView1.surfacePictBx.Refresh();*/ } else if (nodeSelected.NodeType.Equals("TILESMAP")) { this.MainForm.SetModeObject(); TilesMap map = ((TilesMap)nodeSelected.InstanceObjet); //Selectionner le layer parent this.CoronaObjectSelected = null; this.LayerSelected = (CoronaLayer)((GameElement)nodeSelected.Parent).InstanceObjet; this.SceneSelected = this.LayerSelected.SceneParent; //Deselect all objects this.LayerSelected.deselectAllObjects(); //Afficher les proprietes de l'objet dans le property grid TilesMapPropertyConverter mapConverter = new TilesMapPropertyConverter(map, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = mapConverter; if (this.MainForm.isFormLocked == false) GorgonLibrary.Gorgon.Go(); } else if (nodeSelected.NodeType.Equals("CONTROL")) { this.MainForm.SetModeControl(); CoronaControl control = ((CoronaControl)nodeSelected.InstanceObjet); this.ControlSelected = control; if (control.type == CoronaControl.ControlType.joystick) { JoystickControl joy = (JoystickControl)control; JoystickPropertyConverter joyConverter = new JoystickPropertyConverter(joy, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = joyConverter; } } else if (nodeSelected.NodeType.Equals("WIDGET")) { CoronaWidget widget = ((CoronaWidget)nodeSelected.InstanceObjet); this.WidgetSelected = widget; widget.Type = CoronaWidget.WidgetType.tabBar; if (widget.Type == CoronaWidget.WidgetType.tabBar) { TabBarPropertyConverter converter = new TabBarPropertyConverter(widget, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = converter; } else if (widget.Type == CoronaWidget.WidgetType.pickerWheel) { WidgetPickerWheel pickerW = (WidgetPickerWheel)widget; this.MainForm.propertyGrid1.SelectedObject = pickerW; } } else if (nodeSelected.NodeType.Equals("JOINT")) { CoronaJointure joint = nodeSelected.InstanceObjet as CoronaJointure; this.MainForm.setModeJoint(); //Selectionner le layer parent this.CoronaObjectSelected = null; this.JointureSelected = joint; this.LayerSelected = joint.layerParent; this.LayerSelected.JointureSelected = joint; this.SelectedNodes.Add(nodeSelected); this.MainForm.sceneEditorView1.setModeLayerEditor(joint.layerParent); //Ouvrir le property converter correspondant au joint if (this.JointureSelected.type.Equals("DISTANCE")) { DistancePropertyConverter converter = new DistancePropertyConverter(this.JointureSelected, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = converter; } else if (this.JointureSelected.type.Equals("FRICTION")) { FrictionPropertyConverter converter = new FrictionPropertyConverter(this.JointureSelected, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = converter; } else if (this.JointureSelected.type.Equals("PISTON")) { PistonPropertyConverter converter = new PistonPropertyConverter(this.JointureSelected, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = converter; } else if (this.JointureSelected.type.Equals("PIVOT")) { PivotPropertyConverter converter = new PivotPropertyConverter(this.JointureSelected, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = converter; } else if (this.JointureSelected.type.Equals("WELD")) { WeldPropertyConverter converter = new WeldPropertyConverter(this.JointureSelected, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = converter; } else if (this.JointureSelected.type.Equals("WHEEL")) { WheelPropertyConverter converter = new WheelPropertyConverter(this.JointureSelected, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = converter; } else if (this.JointureSelected.type.Equals("PULLEY")) { PulleyPropertyConverter converter = new PulleyPropertyConverter(this.JointureSelected, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = converter; } else if (this.JointureSelected.type.Equals("TOUCH")) { TouchPropertyConverter converter = new TouchPropertyConverter(this.JointureSelected, this.MainForm); this.MainForm.propertyGrid1.SelectedObject = converter; } //Mettre a jour le fichier lua this.MainForm.cgEeditor1.RefreshSceneLuaCode(this.SceneSelected, isCustomBuild, XRatio, YRatio); } else if (nodeSelected.NodeType.Equals("AUDIO")) { this.AudioObjectSelected = (AudioObject)nodeSelected.InstanceObjet; } else if (nodeSelected.NodeType.Equals("SNIPPET")) { this.SnippetSelected = (Snippet)nodeSelected.InstanceObjet; this.MainForm.cgEeditor1.RefreshSnippetLuaCode(this.ProjectSelected); } else if (nodeSelected.NodeType.Equals("FONT")) { this.FontSelected = (FontItem)nodeSelected.InstanceObjet; } //------------Verifier si le clic est un clic droit if (e.Button == System.Windows.Forms.MouseButtons.Right) { if (nodeSelected.NodeType.Equals("STAGE")) { this.treeViewElements.ContextMenuStrip = this.menuScene; this.treeViewElements.ContextMenuStrip.Show(); this.LayerSelected = null; } else if (nodeSelected.NodeType.Equals("LAYER")) { this.treeViewElements.ContextMenuStrip = this.menuLayer; this.treeViewElements.ContextMenuStrip.Show(); } else if (nodeSelected.NodeType.Equals("OBJECT") || nodeSelected.NodeType.Equals("ENTITY")) { CoronaObject obj = ((CoronaObject)nodeSelected.InstanceObjet); activerBoutonsNecessairesMenuObject(obj); this.treeViewElements.ContextMenuStrip = this.menuObject; this.treeViewElements.ContextMenuStrip.Show(); } else if (nodeSelected.NodeType.Equals("CONTROL")) { this.treeViewElements.ContextMenuStrip = this.menuControl; this.treeViewElements.ContextMenuStrip.Show(); } else if (nodeSelected.NodeType.Equals("WIDGET")) { CoronaWidget widget = (CoronaWidget)nodeSelected.InstanceObjet; if (widget.Type == CoronaWidget.WidgetType.tabBar) { this.treeViewElements.ContextMenuStrip = this.menuWidgetTabBar; this.treeViewElements.ContextMenuStrip.Show(); } else if (widget.Type == CoronaWidget.WidgetType.pickerWheel) { this.treeViewElements.ContextMenuStrip = this.menuWidgetPickerWheel; this.treeViewElements.ContextMenuStrip.Show(); } } else if (nodeSelected.NodeType.Equals("SPRITESHEET") || nodeSelected.NodeType.Equals("SPRITESET")) { this.treeViewElements.ContextMenuStrip = this.menuSpriteSetSheet; this.treeViewElements.ContextMenuStrip.Show(); } else if (nodeSelected.NodeType.Equals("JOINT")) { this.treeViewElements.ContextMenuStrip = this.menuJointures; this.treeViewElements.ContextMenuStrip.Show(); } else if (nodeSelected.NodeType.Equals("AUDIO")) { this.treeViewElements.ContextMenuStrip = this.menuAudio; this.treeViewElements.ContextMenuStrip.Show(); } else if (nodeSelected.NodeType.Equals("TILESMAP")) { this.treeViewElements.ContextMenuStrip = this.menuTilesmap; this.treeViewElements.ContextMenuStrip.Show(); } else if (nodeSelected.NodeType.Equals("SNIPPET")) { this.treeViewElements.ContextMenuStrip = this.menuSnippets; this.treeViewElements.ContextMenuStrip.Show(); } else if (nodeSelected.NodeType.Equals("FONT")) { this.treeViewElements.ContextMenuStrip = this.fontMenu; this.treeViewElements.ContextMenuStrip.Show(); } else this.treeViewElements.ContextMenuStrip = null; } else this.treeViewElements.ContextMenuStrip = null; } else if (e.Node.Name.Equals("PROJECT")) { //Verifier si le clic est un clic droit if (e.Button == System.Windows.Forms.MouseButtons.Right) { this.treeViewElements.ContextMenuStrip = this.menuProject; this.treeViewElements.ContextMenuStrip.Show(); } } else this.treeViewElements.ContextMenuStrip = null; } catch (Exception ex) { Application.Exit(); } } }
private void checkJointIntegrity(CoronaJointure joint) { //Get joint node GameElement jointNode = this.getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, joint); if (jointNode != null) { bool hasFoundJoint = false; for (int i = 0; i < joint.layerParent.Jointures.Count; i++) { if(joint.layerParent.Jointures[i] == joint) { joint.layerParent.Jointures.Remove(joint); hasFoundJoint = true; break; } } if (hasFoundJoint == false) { for (int i = 0; i < joint.layerParent.CoronaObjects.Count; i++) { CoronaObject obj = joint.layerParent.CoronaObjects[i]; if (obj.isEntity == true) { for (int j = 0; j < obj.Entity.Jointures.Count; j++) { if (obj.Entity.Jointures[j] == joint) { obj.Entity.Jointures.Remove(joint); hasFoundJoint = true; break; } } } if (hasFoundJoint == true) break; } } if (hasFoundJoint == true) { jointNode.Parent.Nodes.Remove(jointNode); if (joint.coronaObjA.LayerParent != joint.layerParent) { MessageBox.Show("The object \""+joint.coronaObjA.DisplayObject.Name+"\" used in the joint named \""+joint.name+"\" does not exists anymore in the layer \""+joint.layerParent.Name+"\"!\n So the joint has been automatically removed to preserve the project integrity!", "Joint Integrity Information",MessageBoxButtons.OK,MessageBoxIcon.Information); joint = null; jointNode = null; return; } if(joint.coronaObjB != null && (joint.coronaObjB.LayerParent != joint.layerParent)) { MessageBox.Show("The object \"" + joint.coronaObjB.DisplayObject.Name + "\" used in the joint named \"" + joint.name + "\" does not exists anymore in the layer \"" + joint.layerParent.Name + "\"!\n So the joint has been automatically removed to preserve the project integrity!", "Joint Integrity Information",MessageBoxButtons.OK,MessageBoxIcon.Information); joint = null; jointNode = null; return; } this.newJoint(joint, true, jointNode); } } }
public void clearTreeView() { this.LayerSelected = null; this.SceneSelected = null; CoronaObjectSelected = null; this.JointureSelected = null; this.nodeTemp = null; this.treeViewElements.Nodes.Clear(); }
//------------------------------------------------------------------------------ //---------------------CREATION DES JOINTURES--------------------------------------- //----------------------------------------------------------------------------------- public void openPanelJointure(String nameJoint, CoronaJointure joint) { //Fermer un panel si existant //if (!this.tabControlArea5.Controls.Contains(this.jointManagerPage)) // this.tabControlArea5.Controls.Add(this.jointManagerPage); if (this.jointManagerPage.Parent == null) { this.checkAndOpenTabPage(this.jointManagerPage); } TabControl controlParent = this.jointManagerPage.Parent as TabControl; controlParent.SelectedTab = this.jointManagerPage; this.checkAllTabControlEmpty(); if (nameJoint.Equals("PIVOT")) { PivotPropertiesPanel pivotPanel = new PivotPropertiesPanel(); pivotPanel.init(this, joint); this.CurrentJointPanel = pivotPanel; this.jointManagerPage.Controls.Add(pivotPanel); } else if (nameJoint.Equals("DISTANCE")) { DistancePropertiesPanel distancePanel = new DistancePropertiesPanel(); distancePanel.init(this, joint); this.CurrentJointPanel = distancePanel; this.jointManagerPage.Controls.Add(distancePanel); } else if (nameJoint.Equals("FRICTION")) { FrictionPropertiesPanel panel = new FrictionPropertiesPanel(); panel.Init(this, joint); this.CurrentJointPanel = panel; this.jointManagerPage.Controls.Add(panel); } else if (nameJoint.Equals("PISTON")) { PistonPropertiesPanel panel = new PistonPropertiesPanel(); panel.init(this, joint); this.CurrentJointPanel = panel; this.jointManagerPage.Controls.Add(panel); } else if (nameJoint.Equals("PULLEY")) { PulleyPropertiesPanel panel = new PulleyPropertiesPanel(); panel.Init(this, joint); this.CurrentJointPanel = panel; this.jointManagerPage.Controls.Add(panel); } else if (nameJoint.Equals("WHEEL")) { WheelPropertiesPanel panel = new WheelPropertiesPanel(); panel.Init(this, joint); this.CurrentJointPanel = panel; this.jointManagerPage.Controls.Add(panel); } else if (nameJoint.Equals("WELD")) { WeldPropertiesPanel panel = new WeldPropertiesPanel(); panel.Init(this, joint); this.CurrentJointPanel = panel; this.jointManagerPage.Controls.Add(panel); } else if (nameJoint.Equals("TOUCH")) { TouchPropertiesPanel panel = new TouchPropertiesPanel(); panel.Init(this, joint); this.CurrentJointPanel = panel; this.jointManagerPage.Controls.Add(panel); } this.setWorkSpace("GLOBAL"); }
public CoronaJointure clone(CoronaObject objA, CoronaObject objB,CoronaLayer layerParent) { CoronaJointure newJoint = new CoronaJointure(layerParent); newJoint.isEnabled = this.isEnabled; newJoint.coronaObjA = objA; newJoint.coronaObjB = objB; newJoint.type = this.type; if(objB != null) newJoint.name = newJoint.type + "_" + objA.DisplayObject.Name + "_" + objB.DisplayObject.Name; else newJoint.name = newJoint.type + "_" + objA.DisplayObject.Name; newJoint.AnchorPointA = new Point(this.AnchorPointA.X, this.AnchorPointA.Y); newJoint.AnchorPointB = new Point(this.AnchorPointB.X, this.AnchorPointB.Y); newJoint.ObjectAnchorPointA = new Point(this.ObjectAnchorPointA.X, this.ObjectAnchorPointA.Y); newJoint.ObjectAnchorPointB = new Point(this.ObjectAnchorPointB.X, this.ObjectAnchorPointB.Y); newJoint.axisDistance = new Point(this.axisDistance.X, this.axisDistance.Y); newJoint.motorSpeed = this.motorSpeed; newJoint.maxMotorForce = this.maxMotorForce; newJoint.maxMotorTorque = this.maxMotorTorque; newJoint.isMotorEnable = this.isMotorEnable; newJoint.isLimitEnabled = this.isLimitEnabled; newJoint.upperLimit = this.upperLimit; newJoint.lowerLimit = this.lowerLimit; newJoint.frequency = this.frequency; newJoint.maxForce = this.maxForce; newJoint.maxTorque = this.maxTorque; return newJoint ; }
public void removeCoronaJointure(CoronaJointure joint,object objectParent) { if (objectParent != null) { if (objectParent is CoronaLayer) { CoronaLayer layerParent = objectParent as CoronaLayer; GameElement layerNode = getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, layerParent); if (layerNode != null) { GameElement gElementControl = this.getNodeFromObjectInstance(layerNode.Nodes, joint); if (gElementControl != null) { layerParent.Jointures.Remove(joint); layerNode.Nodes["JOINTS"].Nodes.Remove(gElementControl); } joint = null; } } else if (objectParent is CoronaObject) { CoronaObject objParent = objectParent as CoronaObject; GameElement objNode = getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, objParent); if (objNode != null) { GameElement gElementControl = this.getNodeFromObjectInstance(objNode.Nodes, joint); if (gElementControl != null) { objParent.Entity.Jointures.Remove(joint); objNode.Nodes["JOINTS"].Nodes.Remove(gElementControl); } joint = null; } } } }
public void removeAllJointsUsedByObject(CoronaObject obj) { //Get layer parent CoronaLayer layerParent = null; if (obj.EntityParent !=null) layerParent = obj.EntityParent.objectParent.LayerParent; else layerParent = obj.LayerParent; //--Search in layer's joints CoronaJointure[] joints = new CoronaJointure[layerParent.Jointures.Count]; layerParent.Jointures.CopyTo(joints); for (int i = 0; i < joints.Length; i++) { CoronaJointure joint = joints[i]; if (joint.coronaObjA != null) { if (joint.coronaObjA == obj) { this.removeCoronaJointure(joint, layerParent); continue; } if (joint.coronaObjB == obj) { this.removeCoronaJointure(joint, layerParent); continue; } } } //--Search in ALL entities joints for (int j = 0; j < layerParent.CoronaObjects.Count; j++) { CoronaObject currObj = layerParent.CoronaObjects[j]; if (currObj.isEntity == true) { CoronaJointure[] joints2 = new CoronaJointure[currObj.Entity.Jointures.Count]; currObj.Entity.Jointures.CopyTo(joints2); for (int i = 0; i < joints2.Length; i++) { CoronaJointure joint = joints2[i]; if (joint.coronaObjA != null) { if (joint.coronaObjA == obj) { this.removeCoronaJointure(joint, currObj); continue; } if (joint.coronaObjB == obj) { this.removeCoronaJointure(joint, currObj); continue; } } } } } }
public PistonPropertyConverter(CoronaJointure joint, Form1 MainForm) { this.jointSelected = joint; this.MainForm = MainForm; }
public void removeJointSelected() { if (this.SelectedNodes.Count > 0) { TreeNode nodeSelected = this.SelectedNodes[0]; if (nodeSelected != null) { if (nodeSelected.Name.Equals("GAME_ELEMENT")) { //Recuperer le layer parent GameElement nodeElem = (GameElement)nodeSelected; if (nodeElem.NodeType.Equals("JOINT")) { CoronaJointure joint = (CoronaJointure)nodeElem.InstanceObjet; CoronaLayer layerParent = joint.layerParent; if (nodeElem.Parent!= null) { if (nodeElem.Parent.Parent is GameElement) { GameElement elemParent = nodeElem.Parent.Parent as GameElement; if (elemParent.NodeType.Equals("LAYER")) { CoronaLayer layerSelected = elemParent.InstanceObjet as CoronaLayer; layerSelected.Jointures.Remove(joint); } else if(elemParent.NodeType.Equals("ENTITY")) { CoronaObject entitySelected = elemParent.InstanceObjet as CoronaObject; entitySelected.Entity.Jointures.Remove(joint); } } } if (this.SelectedNodes.Contains(nodeElem)) this.SelectedNodes.Remove(nodeElem); nodeElem.Remove(); nodeElem = null; layerParent.JointureSelected = null; this.JointureSelected = null; this.MainForm.propertyGrid1.SelectedObject = null; if (this.MainForm.isFormLocked == false) GorgonLibrary.Gorgon.Go(); } } } } }
private void startJointCreationBt_Click(object sender, EventArgs e) { closeJointPage(); //Verifier qu'on est bien sur un layer seulement if (this.sceneEditorView1.CurentCalque.Equals("LAYER")) { //Creer une jointure vide CoronaJointure joint = new CoronaJointure(this.gameElementTreeView1.LayerSelected); //Pour les pivots if (this.typeJointCmbBx.SelectedIndex == 0) { this.openPanelJointure("PIVOT", joint); ((PivotPropertiesPanel)this.CurrentJointPanel).startCreationJoint(); } //Pour les Distance else if (this.typeJointCmbBx.SelectedIndex == 1) { this.openPanelJointure("DISTANCE", joint); ((DistancePropertiesPanel)this.CurrentJointPanel).startCreationJoint(); } //Pour les Piston else if (this.typeJointCmbBx.SelectedIndex == 2) { this.openPanelJointure("PISTON", joint); ((PistonPropertiesPanel)this.CurrentJointPanel).startCreationJoint(); } //Pour les Friction else if (this.typeJointCmbBx.SelectedIndex == 3) { this.openPanelJointure("FRICTION", joint); ((FrictionPropertiesPanel)this.CurrentJointPanel).startCreationJoint(); } //Pour les Weld else if (this.typeJointCmbBx.SelectedIndex == 4) { this.openPanelJointure("WELD", joint); ((WeldPropertiesPanel)this.CurrentJointPanel).startCreationJoint(); } //Pour les Wheel else if (this.typeJointCmbBx.SelectedIndex == 5) { this.openPanelJointure("WHEEL", joint); ((WheelPropertiesPanel)this.CurrentJointPanel).startCreationJoint(); } //Pour les Pulley else if (this.typeJointCmbBx.SelectedIndex == 6) { this.openPanelJointure("PULLEY", joint); ((PulleyPropertiesPanel)this.CurrentJointPanel).startCreationJoint(); } //Pour les Touch else if (this.typeJointCmbBx.SelectedIndex == 7) { this.openPanelJointure("TOUCH", joint); ((TouchPropertiesPanel)this.CurrentJointPanel).startCreationJoint(); } this.setWorkSpace("GLOBAL"); } else { MessageBox.Show("Please select a Layer to create joints !", "Select a layer", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }