Esempio n. 1
0
        //----------------------------------------------------------
        //----------------Corona COntrol-----------------------
        //----------------------------------------------------------
        public void newCoronaControl(CoronaControl control)
        {
            if (this.LayerSelected != null)
            {
                 GameElement node = new GameElement("CONTROL", control.ControlName, control);
                 node.Checked = control.isEnabled;
                GameElement layerNode = getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, LayerSelected);
                if (layerNode != null)
                {
                    layerNode.Nodes.Add(node);

                }

            }
        }
Esempio n. 2
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();
                }
            }
        }
Esempio n. 3
0
        public void removeCoronaControl(CoronaControl control)
        {
            if (this.LayerSelected != null)
            {
                GameElement layerNode = getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, LayerSelected);
                 if (layerNode != null)
                 {

                    GameElement gElementControl = this.getNodeFromObjectInstance(layerNode.Nodes,control);
                    if (gElementControl != null)
                    {
                        LayerSelected.Controls.Remove(control);
                        layerNode.Nodes.Remove(gElementControl);
                    }

                    this.MainForm.sceneEditorView1.GraphicsContentManager.CleanSprite(control, true);
                    control = null;
                 }
            }
            else if (this.SceneSelected != null)
            {

                //Get the layer parent
                CoronaLayer layerParent = null;
                for (int i = 0; i < this.SceneSelected.Layers.Count; i++)
                {
                    bool hasFound = false;
                    CoronaLayer currentLayer = this.SceneSelected.Layers[i];
                    for (int j = 0; j < currentLayer.Controls.Count; j++)
                    {
                        CoronaControl currentControl = currentLayer.Controls[j];
                        if (control == currentControl)
                        {
                            hasFound = true;
                            break;
                        }

                    }

                    if (hasFound == true)
                    {
                        layerParent = currentLayer;
                        break;
                    }
                }

                if (layerParent != null)
                {
                    GameElement layerNode = getNodeFromObjectInstance(this.ProjectRootNodeSelected.Nodes, LayerSelected);
                    if (layerNode != null)
                    {
                        GameElement gElementControl = this.getNodeFromObjectInstance(layerNode.Nodes, control);
                        if (gElementControl != null)
                        {
                            layerParent.Controls.Remove(control);
                            layerNode.Nodes.Remove(gElementControl);
                        }

                        control = null;
                    }
                }

            }

            this.MainForm.propertyGrid1.SelectedObject = null;

            if (this.MainForm.isFormLocked == false)
                this.MainForm.sceneEditorView1.Refresh();
        }
Esempio n. 4
0
        public void UpdateSpriteContent(CoronaControl control, float worldScale, Point offSetPoint)
        {
            try
            {
                if (this.currentProject != null)
                {
                    if (control != null)
                    {
                        if (control.Type == CoronaControl.ControlType.joystick)
                        {
                            JoystickControl joy = control as JoystickControl;

                            if (joy.innerImage != null || joy.outerImage != null)
                            {
                                this.ExportControlToProjectResources(joy);
                            }

                            this.CleanSprite(joy, false);

                            //Charger le sprite
                            string innerPath = Path.Combine(this.currentProject.ProjectPath + "\\Resources\\Images", joy.joystickName + "_inner.png");
                            if(File.Exists(innerPath))
                                joy.InnerGorgonSprite = new Sprite( joy.joystickName + "_inner", GorgonLibrary.Graphics.Image.FromFile(innerPath));

                            string outerPath = Path.Combine(this.currentProject.ProjectPath + "\\Resources\\Images", joy.joystickName + "_outer.png");
                            if (File.Exists(outerPath))
                                 joy.OuterGorgonSprite = new Sprite(joy.joystickName + "_outer", GorgonLibrary.Graphics.Image.FromFile(outerPath));
                        }
                    }
                }
            }
            catch (Exception ex)
            {

            }
        }
Esempio n. 5
0
        public void ExportControlToProjectResources(CoronaControl control)
        {
            if (this.currentProject != null)
            {
                if (!Directory.Exists(this.currentProject.ProjectPath + "\\Resources\\Images"))
                    Directory.CreateDirectory(this.currentProject.ProjectPath + "\\Resources\\Images");

                if (control != null)
                {
                    if (control.Type == CoronaControl.ControlType.joystick)
                    {
                        JoystickControl joy = control as JoystickControl;

                        if (joy.innerImage != null)
                        {
                            string filename = Path.Combine(this.currentProject.ProjectPath + "\\Resources\\Images", joy.joystickName+"_inner.png");
                            if (File.Exists(filename))
                                File.Delete(filename);

                            joy.innerImage.Save(filename);
                        }

                        if (joy.outerImage != null)
                        {
                            string filename = Path.Combine(this.currentProject.ProjectPath + "\\Resources\\Images", joy.joystickName + "_outer.png");
                            if (File.Exists(filename))
                                File.Delete(filename);

                            joy.outerImage.Save(filename);
                        }
                    }
                }
            }
        }
Esempio n. 6
0
        public void CleanSprite(CoronaControl control, bool removeAsset)
        {
            if (this.currentProject != null)
            {
                if (control != null)
                {
                    if (control.Type == CoronaControl.ControlType.joystick)
                    {
                        JoystickControl joy = control as JoystickControl;

                        if (joy.InnerGorgonSprite != null)
                        {
                            joy.InnerGorgonSprite.Image.Dispose();
                            joy.InnerGorgonSprite.Image = null;

                            joy.InnerGorgonSprite = null;
                        }

                        if (joy.OuterGorgonSprite != null)
                        {
                            joy.OuterGorgonSprite.Image.Dispose();
                            joy.OuterGorgonSprite.Image = null;

                            joy.OuterGorgonSprite = null;
                        }

                        if (removeAsset == true)
                        {
                            string innerPath = Path.Combine(this.currentProject.ProjectPath + "\\Resources\\Images",
                                                            joy.joystickName + "_inner.png");
                            if (File.Exists(innerPath))
                            {
                                File.Delete(innerPath);
                            }

                            string outerPath = Path.Combine(this.currentProject.ProjectPath + "\\Resources\\Images",
                                                            joy.joystickName + "_outer.png");
                            if (File.Exists(outerPath))
                            {
                                File.Delete(outerPath);
                            }
                        }
                    }
                }
            }
        }