Пример #1
0
        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();
                }
            }
        }
Пример #2
0
        private void surfacePictBx_MouseClick(object sender, MouseEventArgs e)
        {
            this.Focus();
            this.Select();

            Point offSetPoint = this.getOffsetPoint();

            for (int i = 0; i < this.objectsSelected.Count; i++)
            {
                CoronaObject obj = this.objectsSelected[i];
                if(obj.DisplayObject != null)
                if (obj.DisplayObject.Type.Equals("FIGURE"))
                    this.GraphicsContentManager.UpdateSpriteStates(obj, this.CurrentScale, offSetPoint);

                //if (obj.DisplayObject.Type.Equals("SPRITE"))
                //{
                //    this.GraphicsContentManager.UpdateSpriteContent(obj, this.CurrentScale, offSetPoint);
                //}
                //else
                //    this.GraphicsContentManager.UpdateSpriteStates(obj, this.CurrentScale, offSetPoint);
            }

            Point pTouched = new Point(Convert.ToInt32(-offSetPoint.X + e.Location.X * (1 / this.CurrentScale)),
                     Convert.ToInt32(-offSetPoint.Y + e.Location.Y * (1 / this.CurrentScale)));

            bool isControlKeyPressed = false;

            //Verifier si le control est actif : si oui ajouter a la liste
            if (Control.ModifierKeys == Keys.Control)
                isControlKeyPressed = true;

            GameElementTreeView treeView = this.mainForm.getElementTreeView();
            Scene sceneSelected = treeView.SceneSelected;

            if (sceneSelected != null)
            {
                if (this.movingMode == "OBJECT")
                {
                    CoronaObject obj = null;
                    if (CurentCalque.Equals("LAYER"))
                        obj = treeView.LayerSelected.getObjTouched(pTouched);
                    else if (CurentCalque.Equals("STAGE"))
                        obj = sceneSelected.getObjectTouched(pTouched);

                    if (this.objectsSelected.Contains(obj) && isControlKeyPressed == false)
                    {
                        if (this.objectsSelected.Count > 0)
                        {

                            if (e.Button == System.Windows.Forms.MouseButtons.Right)
                            {
                                treeView.activerBoutonsNecessairesMenuObject(this.objectsSelected[0]);
                                treeView.menuObject.Show(Cursor.Position);
                            }
                        }
                        else
                        {
                            this.mainForm.propertyGrid1.SelectedObjects = null;
                        }
                        GorgonLibrary.Gorgon.Go();
                        return;
                    }

                    if (!this.Mode.Equals("PATH_FOLLOW") && !this.movingMode.Equals("AD") && !this.Mode.Equals("GENERATOR_ATTACH"))
                    {
                        this.selectObject(obj, isControlKeyPressed);

                    }
                    else if (this.Mode.Equals("GENERATOR_ATTACH") && CurentCalque.Equals("LAYER"))
                    {
                        if (treeView.CoronaObjectSelected != null && obj != null)
                        {
                            if (treeView.CoronaObjectSelected != obj)
                            {
                                treeView.CoronaObjectSelected.objectAttachedToGenerator = obj;

                                MessageBox.Show("The generator of \"" + treeView.CoronaObjectSelected.DisplayObject.Name + "\" has been correctly fastened on the object \"" + obj.DisplayObject.Name + "\"!",
                                    "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.Mode = "NONE";
                            }
                            else
                            {
                                this.mainForm.propertyGrid1.SelectedObjects = null;
                            }

                        }
                    }
                    else if (this.Mode.Equals("GENERATOR_ATTACH") && CurentCalque.Equals("STAGE"))
                    {
                        MessageBox.Show("Please select the layer where the generator is located to define its fastener!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    if (this.objectsSelected.Count > 0)
                    {

                        if (e.Button == System.Windows.Forms.MouseButtons.Right)
                        {
                            treeView.activerBoutonsNecessairesMenuObject(this.objectsSelected[0]);
                            treeView.menuObject.Show(Cursor.Position);
                        }
                    }
                    else
                    {
                        this.mainForm.propertyGrid1.SelectedObjects = null;
                    }

                    treeView.refreshNodesSelectedSceneEditor();
                }
                else if (this.movingMode.Equals("ENTITY"))
                {
                    CoronaObject obj = null;
                    if (CurentCalque.Equals("LAYER"))
                        obj = treeView.LayerSelected.getObjTouched(pTouched);
                    else if (CurentCalque.Equals("STAGE"))
                        obj = sceneSelected.getObjectTouched(pTouched);

                    if (obj != null && obj.EntityParent != null)
                    {
                        if (this.objectsSelected.Contains(obj.EntityParent.objectParent) && isControlKeyPressed == false)
                        {
                            if (this.objectsSelected.Count > 0)
                            {
                                if (e.Button == System.Windows.Forms.MouseButtons.Right)
                                {
                                    treeView.activerBoutonsNecessairesMenuObject(this.objectsSelected[0]);
                                    treeView.menuObject.Show(Cursor.Position);
                                }
                            }
                            GorgonLibrary.Gorgon.Go();
                            return;
                        }

                        this.selectObject(obj.EntityParent.objectParent, isControlKeyPressed);

                        if (this.objectsSelected.Count > 0)
                        {

                            if (e.Button == System.Windows.Forms.MouseButtons.Right)
                            {
                                treeView.activerBoutonsNecessairesMenuObject(this.objectsSelected[0]);
                                treeView.menuObject.Show(Cursor.Position);
                            }
                        }
                        else
                        {
                            this.mainForm.propertyGrid1.SelectedObjects = null;
                        }

                        treeView.refreshNodesSelectedSceneEditor();
                    }
                    else
                    {
                        if(treeView.SceneSelected != null)
                            treeView.SceneSelected.deselectAllObjects();

                        this.objectsSelected.Clear();
                        treeView.refreshNodesSelectedSceneEditor();
                    }

                }

                else if (this.movingMode.Equals("CONTROL"))
                {
                    JoystickControl joy = null;
                    if (CurentCalque.Equals("LAYER"))
                        joy = treeView.LayerSelected.getJoystickTouched(pTouched);
                    else if (CurentCalque.Equals("STAGE"))
                        joy = sceneSelected.getJoystickTouched(pTouched);

                    if (joy != null)
                    {
                        if (isControlKeyPressed)
                        {
                            if (!this.joysticksSelected.Contains(joy))
                            {
                                this.joysticksSelected.Add(joy);
                                joy.setSelected(true);
                            }
                            else
                            {
                                this.joysticksSelected.Remove(joy);
                                joy.setSelected(false);
                            }

                        }

                        else
                        {
                            for (int i = 0; i < this.joysticksSelected.Count; i++)
                            {
                                this.joysticksSelected[i].setSelected(false);
                            }
                            this.joysticksSelected.Clear();
                            this.joysticksSelected.Add(joy);
                            joy.setSelected(true);
                        }
                    }
                    else
                    {
                        if (!isControlKeyPressed)
                        {
                            for (int i = 0; i < this.joysticksSelected.Count; i++)
                            {
                                this.joysticksSelected[i].setSelected(false);
                            }
                            this.joysticksSelected.Clear();
                        }
                    }

                    if (this.joysticksSelected.Count > 0)
                    {
                        object[] tabPropConv = new object[this.joysticksSelected.Count];
                        for (int i = 0; i < this.joysticksSelected.Count; i++)
                        {
                            JoystickControl joySelected = this.joysticksSelected[i];
                            JoystickPropertyConverter joyConverter = new JoystickPropertyConverter(joySelected, mainForm);
                            tabPropConv[i] = joyConverter;

                        }

                        this.mainForm.propertyGrid1.SelectedObjects = tabPropConv;
                    }
                    else
                    {
                        this.mainForm.propertyGrid1.SelectedObjects = null;
                    }
                }
            }

            GorgonLibrary.Gorgon.Go();
        }