Exemplo n.º 1
0
        public override object EditValue(
            ITypeDescriptorContext context,
            IServiceProvider provider,
            object value)
        {
            if (context.Instance is object[])
            {
                if (((object[])context.Instance).Length > 1)
                {
                    return(null);
                }
            }

            //use IWindowsFormsEditorService object to display a control in the dropdown area
            IWindowsFormsEditorService frmsvr = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (frmsvr == null)
            {
                return(null);
            }

            FontItem font = null;

            if (value != null)
            {
                font = value as FontItem;
            }
            else
            {
                try
                {
                    object obj = ((object[])context.Instance)[0];
                    PropertyGridConverters.TextPropertyConverter prop = (PropertyGridConverters.TextPropertyConverter)obj;

                    CoronaObject objectSelected = prop.GetObjectSelected();
                    font = (objectSelected.DisplayObject.Figure as CGE_Figures.Texte).font2.FontItem;
                }
                catch (Exception ex)
                {
                    return(null);
                }
            }



            FontPropertyEditor control = new FontPropertyEditor(font, frmsvr);

            frmsvr.DropDownControl(control);

            if (control.SelectedItems.Count > 0)
            {
                return(control.SelectedItems[0].Tag);
            }
            else
            {
                return(font);
            }
        }
Exemplo n.º 2
0
 public void setObjectA(CoronaObject o)
 {
     if (o == null)
     {
         return;
     }
     this.objA        = o;
     this.Obj1Tb.Text = this.objA.DisplayObject.Name;
 }
Exemplo n.º 3
0
 public void setObj2(CoronaObject o)
 {
     if (o == null)
     {
         return;
     }
     this.objB        = o;
     this.obj2Tb.Text = this.objB.DisplayObject.Name;
 }
Exemplo n.º 4
0
        //---------------------------------------------------
        //-------Protocole de creation  jointures------------
        //---------------------------------------------------
        public void startCreationJoint()
        {
            this.MainForm.setModeJoint();
            this.MainForm.sceneEditorView1.SetDefaultCursor();
            this.MainForm.guideCreationJoint.Text = "SELECT OBJECT A";
            this.objA = null;
            this.objB = null;

            CreationStep = 1;
        }
Exemplo n.º 5
0
        public PathFollow cloneInstance(CoronaObject parent)
        {
            PathFollow path = new PathFollow(parent);

            path.Path.AddRange(this.Path);

            path.isCurve          = this.isCurve;
            path.isCyclic         = this.isCyclic;
            path.isEnabled        = this.isEnabled;
            path.removeOnComplete = this.removeOnComplete;
            return(path);
        }
Exemplo n.º 6
0
 private void goCreationStep2(CoronaObject objA)
 {
     if (objA != null)
     {
         this.setObj(objA);
         this.MainForm.guideCreationJoint.Text = "SELECT ANCHOR POINT";
         CreationStep = 2;
     }
     else
     {
         MessageBox.Show("Error during joint creation ! Object A not selected !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         this.startCreationJoint();
     }
 }
Exemplo n.º 7
0
 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";
     }
 }
Exemplo n.º 8
0
 private void goCreationStep2(CoronaObject objA)
 {
     if (objA != null)
     {
         this.setObj1(objA);
         this.MainForm.sceneEditorView1.SetDefaultCursor();
         this.MainForm.guideCreationJoint.Text = "SELECT OBJECT B";
         CreationStep = 2;
     }
     else
     {
         MessageBox.Show("Error during joint creation ! Object A not selected !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         this.startCreationJoint();
     }
 }
Exemplo n.º 9
0
 private void goCreationStep3(CoronaObject objB)
 {
     if (objB != null)
     {
         this.setObj2(objB);
         this.MainForm.sceneEditorView1.SetEditCursor();
         this.MainForm.guideCreationJoint.Text = "SELECT ANCHOR POINT";
         CreationStep = 3;
     }
     else
     {
         MessageBox.Show("Error during joint creation ! Object B not selected !", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         goCreationStep2(this.objA);
     }
 }
Exemplo n.º 10
0
        public CollisionGroupPropertyEditor(CoronaObject obj,
                                            IWindowsFormsEditorService editorServiceParam)
        {
            editorService = editorServiceParam;
            InitializeComponent();

            // Add all groups from the scene
            List <CollisionFilterGroup> groups = obj.LayerParent.SceneParent.CollisionFilterGroups;

            for (int i = 0; i < groups.Count; i++)
            {
                CollisionFilterGroup group = groups[i];
                this.Items.Add(group.GroupName);
            }

            this.Refresh();
        }
Exemplo n.º 11
0
        public void init(Form1 mainForm, CoronaObject coronaObject)
        {
            this.mainForm     = mainForm;
            this.coronaObject = coronaObject;



            this.graduationBarY.setDefaultOffset(this.graduationBarX.Size.Height);
            this.setScrollBarsValues();

            setModeNormal();
            isMouseDown = false;

            if (this.mainForm.isFormLocked == false)
            {
                GorgonLibrary.Gorgon.Go();
            }
        }
Exemplo n.º 12
0
        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";
            }
        }
Exemplo n.º 13
0
        public SpriteSequencePropertyEditor(CoronaObject obj,
                                            IWindowsFormsEditorService editorServiceParam)
        {
            editorService = editorServiceParam;
            InitializeComponent();

            // Add all groups from the scene
            List <CoronaSpriteSetSequence> sequences = obj.DisplayObject.SpriteSet.Sequences;

            this.Items.Add("DEFAULT");
            for (int i = 0; i < sequences.Count; i++)
            {
                CoronaSpriteSetSequence sequence = sequences[i];
                this.Items.Add(sequence.Name);
            }

            this.Refresh();
        }
Exemplo n.º 14
0
        public override object EditValue(
            ITypeDescriptorContext context,
            IServiceProvider provider,
            object value)
        {
            //use IWindowsFormsEditorService object to display a control in the dropdown area
            IWindowsFormsEditorService frmsvr = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (frmsvr == null)
            {
                return(null);
            }



            object propertyConverter = null;

            if (context.Instance is object[])
            {
                propertyConverter = ((object[])context.Instance)[0];
            }
            else
            {
                propertyConverter = context.Instance;
            }

            PropertyGridConverters.SpritePropertyConverter prop = (PropertyGridConverters.SpritePropertyConverter)propertyConverter;

            CoronaObject obj = prop.GetObjectSelected();

            SpriteSequencePropertyEditor control = new SpriteSequencePropertyEditor(obj, frmsvr);

            frmsvr.DropDownControl(control);

            if (control.SelectedItem != null)
            {
                return(control.SelectedItem.ToString());
            }
            else
            {
                return("DEFAULT");
            }
        }
Exemplo n.º 15
0
 public void nextCreationStep(Point p)
 {
     //Verifier l'etape de creation
     //--> Recuperer l'objet A
     if (this.CreationStep == 1)
     {
         CoronaObject obj = this.MainForm.getElementTreeView().LayerSelected.getObjTouched(p);
         if (obj != null)
         {
             if (obj.PhysicsBody.Mode != PhysicsBody.PhysicBodyMode.Inactive)
             {
                 this.goCreationStep2(obj);
             }
         }
     }
     else if (this.CreationStep == 2)
     {
         closeCreationJoint(p);
     }
 }
Exemplo n.º 16
0
        //---------------------------------------------------
        //-------------------Methodes------------------------
        //---------------------------------------------------
        public void init(Form1 mainForm, CoronaJointure joint)
        {
            this.joint    = joint;
            this.mainForm = mainForm;
            CreationStep  = 0;

            if (this.joint.type.Equals("PIVOT"))
            {
                this.isMotorEnabledChkBx.Checked = joint.isMotorEnable;
                this.isLimitedChkBx.Checked      = joint.isLimitEnabled;

                this.motorSpeedNumUpDw.Value = System.Convert.ToInt32(joint.motorSpeed);
                this.maxTorqueNumUpDw.Value  = System.Convert.ToInt32(joint.maxMotorTorque);

                this.nameObj1TxtBx.Text = joint.coronaObjA.DisplayObject.Name;
                this.nameObj2TxtBx.Text = joint.coronaObjB.DisplayObject.Name;

                this.upperLimitNumUpDw.Value = Convert.ToDecimal(joint.upperLimit);
                this.lowerLimitNumUpDw.Value = Convert.ToDecimal(joint.lowerLimit);

                this.objA        = joint.coronaObjA;
                this.objB        = joint.coronaObjB;
                this.anchorPoint = joint.AnchorPointA;
                modePanel        = "MODIFY";
            }
            else
            {
                this.isMotorEnabledChkBx.Checked = false;
                this.isLimitedChkBx.Checked      = false;

                this.motorSpeedNumUpDw.Value = 0;
                this.maxTorqueNumUpDw.Value  = 0;

                this.upperLimitNumUpDw.Value = 0;
                this.lowerLimitNumUpDw.Value = 0;
                this.nameObj1TxtBx.Text      = "";
                this.nameObj2TxtBx.Text      = "";
                modePanel = "NEW";
            }
        }
Exemplo n.º 17
0
 public void nextCreationStep(Point p)
 {
     //Verifier l'etape de creation
     //--> Recuperer l'objet A
     if (this.CreationStep == 1 || this.CreationStep == 2)
     {
         CoronaObject obj = this.MainForm.getElementTreeView().LayerSelected.getObjTouched(p);
         if (obj != null)
         {
             if (obj.PhysicsBody != null)
             {
                 if (this.CreationStep == 1)
                 {
                     this.goCreationStep2(obj);
                 }
                 else
                 {
                     this.goCreationStep3(obj);
                 }
             }
         }
     }
     else if (this.CreationStep == 3)
     {
         goCreationStep4(p);
     }
     else if (this.CreationStep == 4)
     {
         goCreationStep5(p);
     }
     else if (this.CreationStep == 5)
     {
         goCreationStep6(p);
     }
     else if (this.CreationStep == 6)
     {
         this.closeCreationJoint(p);
     }
 }
Exemplo n.º 18
0
        public TransformBox(CoronaObject obj)
        {
            this.objectParent = obj;

            if (obj.isEntity == false)
            {
                if (obj.DisplayObject.Type.Equals("FIGURE"))
                {
                    Figure fig = obj.DisplayObject.Figure;
                    if (fig.ShapeType.Equals("LINE"))
                    {
                        currentLine       = (Line)fig;
                        this.hotSpotsLine = new List <Rectangle>();
                        isLine            = true;
                    }
                    else if (fig.ShapeType.Equals("CURVE"))
                    {
                        currentCurve      = (CourbeBezier)fig;
                        this.hotSpotsLine = new List <Rectangle>();
                        isCurve           = true;
                    }
                }
            }
        }
Exemplo n.º 19
0
 public void setObjectA(CoronaObject obj)
 {
     this.objA        = obj;
     this.obj1Tb.Text = this.objA.DisplayObject.Name;
 }
Exemplo n.º 20
0
        public Boolean generateImageFilesWithRatio(float XRatio, float YRatio)
        {
            if (this.Project == null)
            {
                return(false);
            }
            if (this.Project.ImageSuffix == null)
            {
                return(false);
            }

            float moyenneRatio = (XRatio + YRatio) / 2;

            try
            {
                for (int i = 0; i < this.Project.Scenes.Count; i++)
                {
                    if (this.Project.Scenes[i].isEnabled == true)
                    {
                        for (int j = 0; j < this.Project.Scenes[i].Layers.Count; j++)
                        {
                            if (this.Project.Scenes[i].Layers[j].isEnabled == true)
                            {
                                for (int k = 0; k < this.Project.Scenes[i].Layers[j].CoronaObjects.Count; k++)
                                {
                                    CoronaObject coronaObject = this.Project.Scenes[i].Layers[j].CoronaObjects[k];
                                    if (coronaObject.isEnabled == true)
                                    {
                                        if (coronaObject.isEntity == false)
                                        {
                                            DisplayObject obj = coronaObject.DisplayObject;
                                            if (obj.Type.Equals("IMAGE"))
                                            {
                                                if (obj.GorgonSprite != null)
                                                {
                                                    string imagePath = Path.Combine(this.Project.ProjectPath + "\\Resources\\Images",
                                                                                    obj.OriginalAssetName + ".png");

                                                    Size   finalSize      = new Size(Convert.ToInt32(obj.SurfaceRect.Size.Width * XRatio), Convert.ToInt32(obj.SurfaceRect.Size.Height * YRatio));
                                                    string finalImageName = Project.BuildFolderPath + "\\" + obj.OriginalAssetName.ToLower() + finalSize.Width + "x" + finalSize.Height;
                                                    if (File.Exists(imagePath))
                                                    {
                                                        if (!File.Exists(finalImageName + ".png"))
                                                        {
                                                            Bitmap originalImage = (Bitmap)Bitmap.FromFile(imagePath);
                                                            //Bitmap originalImage = (Bitmap)obj.GorgonSprite.Image.SaveBitmap();

                                                            Image finalImage = new Bitmap(originalImage, finalSize);
                                                            finalImage.Save(finalImageName + ".png",
                                                                            System.Drawing.Imaging.ImageFormat.Png);
                                                            finalImage.Dispose();
                                                            finalImage = null;

                                                            originalImage.Dispose();
                                                            originalImage = null;
                                                        }
                                                    }
                                                }
                                            }

                                            if (coronaObject.BitmapMask != null)
                                            {
                                                if (coronaObject.BitmapMask.MaskImage != null && coronaObject.BitmapMask.IsMaskEnabled == true)
                                                {
                                                    Image finalImage = new Bitmap(coronaObject.BitmapMask.MaskImage,
                                                                                  new Size(Convert.ToInt32(coronaObject.BitmapMask.MaskImage.Size.Width * moyenneRatio),
                                                                                           Convert.ToInt32(coronaObject.BitmapMask.MaskImage.Size.Height * moyenneRatio)));
                                                    finalImage.Save(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + "_mask.png", System.Drawing.Imaging.ImageFormat.Png);
                                                    finalImage.Dispose();
                                                    finalImage = null;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            for (int e = 0; e < coronaObject.Entity.CoronaObjects.Count; e++)
                                            {
                                                CoronaObject child = coronaObject.Entity.CoronaObjects[e];
                                                if (child.isEnabled == true)
                                                {
                                                    DisplayObject obj = child.DisplayObject;
                                                    if (obj.Type.Equals("IMAGE"))
                                                    {
                                                        if (obj.GorgonSprite != null)
                                                        {
                                                            string imagePath = Path.Combine(this.Project.ProjectPath + "\\Resources\\Images",
                                                                                            obj.OriginalAssetName + ".png");

                                                            Size   finalSize      = new Size(Convert.ToInt32(obj.SurfaceRect.Size.Width * XRatio), Convert.ToInt32(obj.SurfaceRect.Size.Height * YRatio));
                                                            string finalImageName = Project.BuildFolderPath + "\\" + obj.OriginalAssetName.ToLower() + finalSize.Width + "x" + finalSize.Height;
                                                            if (File.Exists(imagePath))
                                                            {
                                                                if (!File.Exists(finalImageName + ".png"))
                                                                {
                                                                    Bitmap originalImage = (Bitmap)Bitmap.FromFile(imagePath);
                                                                    //Bitmap originalImage = (Bitmap)obj.GorgonSprite.Image.SaveBitmap();

                                                                    Image finalImage = new Bitmap(originalImage, finalSize);
                                                                    finalImage.Save(finalImageName + ".png",
                                                                                    System.Drawing.Imaging.ImageFormat.Png);
                                                                    finalImage.Dispose();
                                                                    finalImage = null;
                                                                    originalImage.Dispose();
                                                                    originalImage = null;
                                                                }
                                                            }
                                                        }
                                                    }

                                                    if (coronaObject.BitmapMask != null)
                                                    {
                                                        if (coronaObject.BitmapMask.MaskImage != null && coronaObject.BitmapMask.IsMaskEnabled == true)
                                                        {
                                                            Image finalImage = new Bitmap(coronaObject.BitmapMask.MaskImage,
                                                                                          new Size(Convert.ToInt32(coronaObject.BitmapMask.MaskImage.Size.Width * moyenneRatio),
                                                                                                   Convert.ToInt32(coronaObject.BitmapMask.MaskImage.Size.Height * moyenneRatio)));
                                                            finalImage.Save(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + "_mask.png", System.Drawing.Imaging.ImageFormat.Png);

                                                            finalImage.Dispose();
                                                            finalImage = null;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            Scene scene = this.Project.Scenes[i];


                            //scene.createAllSpriteSheetsImages("", moyenneRatio, moyenneRatio);

                            for (int l = 0; l < scene.SpriteSheets.Count; l++)
                            {
                                CoronaSpriteSheet sheet = scene.SpriteSheets[l];


                                //if (size.Width >= 4096 || size.Height >= 4096)
                                //{
                                //    MessageBox.Show("The size of the " + sheet.Name + " sprite sheet image seems to be too big (4096 max)!\n Please go to the asset manager and increase the frames factor for this sheet!",
                                //        "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                //}

                                //Creer le fichier lua associé
                                SpriteSheetLuaGenerator gen = new SpriteSheetLuaGenerator(sheet, this.Project);
                                gen.writeToLua(new DirectoryInfo(this.Project.BuildFolderPath), "", moyenneRatio, moyenneRatio);
                            }


                            for (int l = 0; l < scene.Layers.Count; l++)
                            {
                                CoronaLayer layer = scene.Layers[l];
                                if (layer.isEnabled == true)
                                {
                                    if (layer.TilesMap != null)
                                    {
                                        if (layer.TilesMap.isEnabled == true)
                                        {
                                            string texturesDataSheetName         = layer.TilesMap.TilesMapName.ToLower() + "textsheet";
                                            string objectsDataSheetName          = layer.TilesMap.TilesMapName.ToLower() + "objsheet";
                                            string textureSequencesDataSheetName = layer.TilesMap.TilesMapName.ToLower() + "textsequencessheet";
                                            string objectSequencesDataSheetName  = layer.TilesMap.TilesMapName.ToLower() + "objsequencessheet";

                                            float orientedXRatio = 0;
                                            float orientedYRatio = 0;
                                            if (this.Project.Orientation == CoronaGameProject.OrientationScreen.Portrait)
                                            {
                                                orientedXRatio = XRatio;
                                                orientedYRatio = YRatio;
                                            }
                                            else
                                            {
                                                orientedXRatio = YRatio;
                                                orientedYRatio = XRatio;
                                            }

                                            layer.TilesMap.refreshTilesMapContent();
                                            layer.TilesMap.createTextureSet(this.Project.BuildFolderPath, texturesDataSheetName, "", orientedXRatio, orientedYRatio);
                                            layer.TilesMap.createObjectsSet(this.Project.BuildFolderPath, objectsDataSheetName, "", orientedXRatio, orientedYRatio);
                                            layer.TilesMap.creatTextureSequencesSet(this.Project.BuildFolderPath, textureSequencesDataSheetName, "", orientedXRatio, orientedYRatio);
                                            layer.TilesMap.createObjectSequencesSet(this.Project.BuildFolderPath, objectSequencesDataSheetName, "", orientedXRatio, orientedYRatio);


                                            string fileNameDest = layer.TilesMap.createJSONConfigFile(scene, this.Project.SourceFolderPath, orientedXRatio, orientedYRatio);
                                        }
                                    }
                                }
                            }

                            for (int k = 0; k < this.Project.Scenes[i].Layers[j].Controls.Count; k++)
                            {
                                CoronaControl control = this.Project.Scenes[i].Layers[j].Controls[k];
                                if (control.isEnabled == true)
                                {
                                    if (control.Type == CoronaControl.ControlType.joystick)
                                    {
                                        JoystickControl joy = control as JoystickControl;

                                        //Pour l'image OUTER
                                        if (joy.outerImage != null)
                                        {
                                            //Enregistrer l'image en size *ratio
                                            Size   sizeBack   = new Size(Convert.ToInt32(joy.outerRadius * 2 * XRatio), Convert.ToInt32(joy.outerRadius * 2 * moyenneRatio));
                                            Bitmap OuterImage = new Bitmap(joy.outerImage, sizeBack);
                                            OuterImage.Save(Project.BuildFolderPath + "\\" + joy.joystickName + "Outer.png", System.Drawing.Imaging.ImageFormat.Png);
                                            OuterImage.Dispose();
                                        }

                                        //Pour l'image Inner
                                        if (joy.innerImage != null)
                                        {
                                            //Enregistrer l'image en size *ratio
                                            Size   sizeBack   = new Size(Convert.ToInt32(joy.innerRadius * 2 * moyenneRatio), Convert.ToInt32(joy.innerRadius * 2 * moyenneRatio));
                                            Bitmap InnerImage = new Bitmap(joy.innerImage, sizeBack);
                                            InnerImage.Save(Project.BuildFolderPath + "\\" + joy.joystickName + "Inner.png", System.Drawing.Imaging.ImageFormat.Png);
                                            InnerImage.Dispose();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }



                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Exemplo n.º 21
0
        public Boolean GenerateImageFile()
        {
            if (this.Project == null)
            {
                return(false);
            }
            if (this.Project.ImageSuffix == null)
            {
                return(false);
            }

            List <ImageSuffix> ListImgSuffix = new List <ImageSuffix>();

            // Fill All Image Suffix String in an Object
            for (int i = 0; i < this.Project.ImageSuffix.Count; i++)
            {
                ListImgSuffix.Add(new ImageSuffix(Project.ImageSuffix[i]));
            }

            try
            {
                for (int i = 0; i < this.Project.Scenes.Count; i++)
                {
                    if (this.Project.Scenes[i].isEnabled == true)
                    {
                        for (int j = 0; j < this.Project.Scenes[i].Layers.Count; j++)
                        {
                            if (this.Project.Scenes[i].Layers[j].isEnabled == true)
                            {
                                for (int k = 0; k < this.Project.Scenes[i].Layers[j].CoronaObjects.Count; k++)
                                {
                                    CoronaObject coronaObject = this.Project.Scenes[i].Layers[j].CoronaObjects[k];
                                    if (coronaObject.isEnabled == true)
                                    {
                                        if (coronaObject.isEntity == false)
                                        {
                                            DisplayObject obj = coronaObject.DisplayObject;
                                            if (obj.Type.Equals("IMAGE"))
                                            {
                                                //Enregistrer l'image en size *1
                                                if (!File.Exists(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + ".png"))
                                                {
                                                    if (obj.GorgonSprite != null)
                                                    {
                                                        //Bitmap originalImage = (Bitmap)obj.GorgonSprite.Image.SaveBitmap();
                                                        string imagePath = Path.Combine(this.Project.ProjectPath + "\\Resources\\Images",
                                                                                        obj.OriginalAssetName + ".png");

                                                        string finalImageName = Project.BuildFolderPath + "\\" + obj.OriginalAssetName.ToLower() + obj.SurfaceRect.Width + "x" + obj.SurfaceRect.Height;

                                                        if (File.Exists(imagePath))
                                                        {
                                                            if (!File.Exists(finalImageName + ".png"))
                                                            {
                                                                Bitmap originalImage = (Bitmap)Bitmap.FromFile(imagePath);
                                                                Bitmap finalImage    = new Bitmap(originalImage, obj.SurfaceRect.Size);
                                                                finalImage.Save(finalImageName + ".png",
                                                                                System.Drawing.Imaging.ImageFormat.Png);
                                                                finalImage.Dispose();

                                                                for (int l = 0; l < this.Project.ImageSuffix.Count; l++)
                                                                {
                                                                    Bitmap ImageResized = new Bitmap(originalImage, Convert.ToInt32(obj.SurfaceRect.Size.Width * ListImgSuffix[l].ratio),
                                                                                                     Convert.ToInt32(obj.SurfaceRect.Size.Height * ListImgSuffix[l].ratio));

                                                                    ImageResized.Save(finalImageName + ListImgSuffix[l].suffix + ".png",
                                                                                      System.Drawing.Imaging.ImageFormat.Png);

                                                                    ImageResized.Dispose();
                                                                }

                                                                originalImage.Dispose();
                                                            }
                                                        }
                                                    }
                                                    //else
                                                    //{
                                                    //    finalImage = new Bitmap(obj.Image, obj.SurfaceRect.Size);
                                                    //    finalImage.Save(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + ".png", System.Drawing.Imaging.ImageFormat.Png);
                                                    //    finalImage.Dispose();
                                                    //}
                                                }
                                            }

                                            if (coronaObject.BitmapMask != null)
                                            {
                                                if (coronaObject.BitmapMask.MaskImage != null && coronaObject.BitmapMask.IsMaskEnabled == true)
                                                {
                                                    coronaObject.BitmapMask.MaskImage.Save(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + "_mask.png", System.Drawing.Imaging.ImageFormat.Png);
                                                }
                                            }
                                        }
                                        else
                                        {
                                            for (int e = 0; e < coronaObject.Entity.CoronaObjects.Count; e++)
                                            {
                                                CoronaObject child = coronaObject.Entity.CoronaObjects[e];
                                                if (child.isEnabled == true)
                                                {
                                                    DisplayObject obj = child.DisplayObject;
                                                    if (obj.Type.Equals("IMAGE"))
                                                    {
                                                        //Enregistrer l'image en size *1
                                                        if (!File.Exists(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + ".png"))
                                                        {
                                                            if (obj.GorgonSprite != null)
                                                            {
                                                                string imagePath = Path.Combine(this.Project.ProjectPath + "\\Resources\\Images",
                                                                                                obj.OriginalAssetName + ".png");

                                                                string finalImageName = Project.BuildFolderPath + "\\" + obj.OriginalAssetName.ToLower() + obj.SurfaceRect.Width + "x" + obj.SurfaceRect.Height;

                                                                if (File.Exists(imagePath))
                                                                {
                                                                    if (!File.Exists(finalImageName + ".png"))
                                                                    {
                                                                        Bitmap originalImage = (Bitmap)Bitmap.FromFile(imagePath);
                                                                        //Bitmap originalImage = (Bitmap)obj.GorgonSprite.Image.SaveBitmap();

                                                                        Image finalImage = new Bitmap(originalImage, obj.SurfaceRect.Size);
                                                                        finalImage.Save(finalImageName + ".png",
                                                                                        System.Drawing.Imaging.ImageFormat.Png);
                                                                        finalImage.Dispose();

                                                                        for (int l = 0; l < this.Project.ImageSuffix.Count; l++)
                                                                        {
                                                                            Bitmap ImageResized = new Bitmap(originalImage, Convert.ToInt32(obj.SurfaceRect.Size.Width * ListImgSuffix[l].ratio), Convert.ToInt32(obj.SurfaceRect.Size.Height * ListImgSuffix[l].ratio));
                                                                            ImageResized.Save(finalImageName + ListImgSuffix[l].suffix + ".png", System.Drawing.Imaging.ImageFormat.Png);
                                                                            ImageResized.Dispose();
                                                                        }

                                                                        originalImage.Dispose();
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }



                                                    if (child.BitmapMask != null)
                                                    {
                                                        if (child.BitmapMask.MaskImage != null && child.BitmapMask.IsMaskEnabled == true)
                                                        {
                                                            child.BitmapMask.MaskImage.Save(Project.BuildFolderPath + "\\" + obj.Name.ToLower() + "_mask.png", System.Drawing.Imaging.ImageFormat.Png);
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                            Scene scene = this.Project.Scenes[i];


                            // scene.createAllSpriteSheetsImages("", 1, 1);

                            for (int l = 0; l < scene.SpriteSheets.Count; l++)
                            {
                                CoronaSpriteSheet sheet = scene.SpriteSheets[l];

                                //if (size.Width >= 4096 || size.Height >= 4096)
                                //{
                                //    MessageBox.Show("The size of the " + sheet.Name + " sprite sheet image seems to be too big (4096 max)!\n Please go to the asset manager and increase the frames factor for this sheet!",
                                //        "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                //}

                                //Creer le fichier lua associé
                                SpriteSheetLuaGenerator gen = new SpriteSheetLuaGenerator(sheet, this.Project);
                                gen.writeToLua(new DirectoryInfo(this.Project.BuildFolderPath), "", 1, 1);
                            }

                            for (int l = 0; l < scene.Layers.Count; l++)
                            {
                                CoronaLayer layer = scene.Layers[l];
                                if (layer.isEnabled == true)
                                {
                                    if (layer.TilesMap != null)
                                    {
                                        if (layer.TilesMap.isEnabled == true)
                                        {
                                            string texturesDataSheetName         = layer.TilesMap.TilesMapName.ToLower() + "textsheet";
                                            string objectsDataSheetName          = layer.TilesMap.TilesMapName.ToLower() + "objsheet";
                                            string textureSequencesDataSheetName = layer.TilesMap.TilesMapName.ToLower() + "textsequencessheet";
                                            string objectSequencesDataSheetName  = layer.TilesMap.TilesMapName.ToLower() + "objsequencessheet";


                                            layer.TilesMap.createTextureSet(this.Project.BuildFolderPath, texturesDataSheetName, "", 1, 1);
                                            layer.TilesMap.createObjectsSet(this.Project.BuildFolderPath, objectsDataSheetName, "", 1, 1);
                                            layer.TilesMap.creatTextureSequencesSet(this.Project.BuildFolderPath, textureSequencesDataSheetName, "", 1, 1);
                                            layer.TilesMap.createObjectSequencesSet(this.Project.BuildFolderPath, objectSequencesDataSheetName, "", 1, 1);
                                            layer.TilesMap.refreshTilesMapContent();

                                            string fileNameDest = layer.TilesMap.createJSONConfigFile(scene, this.Project.SourceFolderPath, 1, 1);
                                        }
                                    }
                                }
                            }

                            //Creer les sprites sheets
                            for (int k = 0; k < this.Project.ImageSuffix.Count; k++)
                            {
                                // scene.createAllSpriteSheetsImages(ListImgSuffix[k].suffix, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);

                                for (int l = 0; l < scene.SpriteSheets.Count; l++)
                                {
                                    CoronaSpriteSheet sheet = scene.SpriteSheets[l];


                                    //if (size.Width >= 4096 || size.Height >= 4096)
                                    //{
                                    //    MessageBox.Show("The size of the " + sheet.Name + " sprite sheet image seems to be too big (4096 max)!\n Please go to the asset manager and increase the frames factor for this sheet!",
                                    //        "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    //}

                                    //Creer le fichier lua associé
                                    SpriteSheetLuaGenerator gen = new SpriteSheetLuaGenerator(sheet, this.Project);
                                    gen.writeToLua(new DirectoryInfo(this.Project.BuildFolderPath), ListImgSuffix[k].suffix, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);
                                }

                                for (int l = 0; l < scene.Layers.Count; l++)
                                {
                                    CoronaLayer layer = scene.Layers[l];
                                    if (layer.isEnabled == true)
                                    {
                                        if (layer.TilesMap != null)
                                        {
                                            if (layer.TilesMap.isEnabled == true)
                                            {
                                                string texturesDataSheetName         = layer.TilesMap.TilesMapName.ToLower() + "textsheet";
                                                string objectsDataSheetName          = layer.TilesMap.TilesMapName.ToLower() + "objsheet";
                                                string textureSequencesDataSheetName = layer.TilesMap.TilesMapName.ToLower() + "textsequencessheet";
                                                string objectSequencesDataSheetName  = layer.TilesMap.TilesMapName.ToLower() + "objsequencessheet";

                                                layer.TilesMap.refreshTilesMapContent();
                                                layer.TilesMap.createTextureSet(this.Project.BuildFolderPath, texturesDataSheetName, ListImgSuffix[k].suffix, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);
                                                layer.TilesMap.createObjectsSet(this.Project.BuildFolderPath, objectsDataSheetName, ListImgSuffix[k].suffix, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);
                                                layer.TilesMap.creatTextureSequencesSet(this.Project.BuildFolderPath, textureSequencesDataSheetName, ListImgSuffix[k].suffix, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);
                                                layer.TilesMap.createObjectSequencesSet(this.Project.BuildFolderPath, objectSequencesDataSheetName, ListImgSuffix[k].suffix, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);


                                                //string fileNameDest = layer.TilesMap.createJSONConfigFile(scene, this.Project.SourceFolderPath, (float)ListImgSuffix[k].ratio, (float)ListImgSuffix[k].ratio);
                                            }
                                        }
                                    }
                                }
                            }

                            for (int k = 0; k < this.Project.Scenes[i].Layers[j].Controls.Count; k++)
                            {
                                CoronaControl control = this.Project.Scenes[i].Layers[j].Controls[k];
                                if (control.isEnabled == true)
                                {
                                    if (control.Type == CoronaControl.ControlType.joystick)
                                    {
                                        JoystickControl joy = control as JoystickControl;

                                        //Pour l'image OUTER
                                        if (joy.outerImage != null)
                                        {
                                            //Enregistrer l'image en size *1
                                            Size   sizeBack   = new Size(joy.outerRadius * 2, joy.outerRadius * 2);
                                            Bitmap OuterImage = new Bitmap(joy.outerImage, sizeBack);
                                            OuterImage.Save(Project.BuildFolderPath + "\\" + joy.joystickName + "Outer.png", System.Drawing.Imaging.ImageFormat.Png);

                                            for (int l = 0; l < this.Project.ImageSuffix.Count; l++)
                                            {
                                                Bitmap ImageResized = new Bitmap(joy.outerImage, Convert.ToInt32(sizeBack.Width * ListImgSuffix[l].ratio), Convert.ToInt32(sizeBack.Height * ListImgSuffix[l].ratio));
                                                ImageResized.Save(Project.BuildFolderPath + "\\" + joy.joystickName + "Outer" + ListImgSuffix[l].suffix + ".png", System.Drawing.Imaging.ImageFormat.Png);
                                                ImageResized.Dispose();
                                                ImageResized = null;
                                            }

                                            OuterImage.Dispose();
                                            OuterImage = null;
                                        }

                                        //Pour l'image Inner
                                        if (joy.innerImage != null)
                                        {
                                            //Enregistrer l'image en size *1
                                            Size   sizeBack   = new Size(joy.innerRadius * 2, joy.innerRadius * 2);
                                            Bitmap InnerImage = new Bitmap(joy.innerImage, sizeBack);
                                            InnerImage.Save(Project.BuildFolderPath + "\\" + joy.joystickName + "Inner.png", System.Drawing.Imaging.ImageFormat.Png);

                                            for (int l = 0; l < this.Project.ImageSuffix.Count; l++)
                                            {
                                                Bitmap ImageResized = new Bitmap(joy.innerImage, Convert.ToInt32(sizeBack.Width * ListImgSuffix[l].ratio), Convert.ToInt32(sizeBack.Height * ListImgSuffix[l].ratio));
                                                ImageResized.Save(Project.BuildFolderPath + "\\" + joy.joystickName + "Inner" + ListImgSuffix[l].suffix + ".png", System.Drawing.Imaging.ImageFormat.Png);
                                                ImageResized.Dispose();
                                                ImageResized = null;
                                            }

                                            InnerImage.Dispose();
                                            InnerImage = null;
                                        }
                                    }
                                }
                            }

                            for (int k = 0; k < this.Project.Scenes[i].Layers[j].Widgets.Count; k++)
                            {
                                CoronaWidget widget = this.Project.Scenes[i].Layers[j].Widgets[k];
                                if (widget.Type == CoronaWidget.WidgetType.tabBar)
                                {
                                    WidgetTabBar tabBar = (WidgetTabBar)widget;

                                    //Pour tous les bouttons
                                    for (int e = 0; e < tabBar.Buttons.Count; e++)
                                    {
                                        WidgetTabBar.TabBarButton bt = tabBar.Buttons[e];
                                        if (bt.ImagePressedState != null)
                                        {
                                            bt.ImagePressedState.Save(Project.BuildFolderPath + "\\" + tabBar.Name + bt.Id + "down.png");
                                        }
                                        if (bt.ImageUnPressedState != null)
                                        {
                                            bt.ImageUnPressedState.Save(Project.BuildFolderPath + "\\" + tabBar.Name + bt.Id + "up.png");
                                        }
                                    }

                                    /*if (tabBar.BackgroundImage != null)
                                     * {
                                     *  Bitmap bmp = new Bitmap(tabBar.BackgroundImage, tabBar.Size);
                                     *  bmp.Save(Project.BuildFolderPath + "\\" + tabBar.Name + "background.png");
                                     * }*/
                                }
                                else if (widget.Type == CoronaWidget.WidgetType.pickerWheel)
                                {
                                    WidgetPickerWheel pickW = (WidgetPickerWheel)widget;
                                    if (pickW.BackgroundImage != null)
                                    {
                                        Bitmap background = new Bitmap(pickW.BackgroundImage, pickW.BackgroundSize);
                                        background.Save(Project.BuildFolderPath + "\\" + pickW.Name + "background.png");
                                    }
                                }
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception ex) {
                MessageBox.Show("Error during image files generation !\n" + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Exemplo n.º 22
0
 public RectPropertyConverter(CoronaObject obj, Form1 MainForm) :
     base(obj, MainForm)
 {
     objSelected = obj;
     rect        = (Rect)obj.DisplayObject.Figure;
 }
Exemplo n.º 23
0
 public ImagePropertyConverter(CoronaObject obj, Form1 MainForm) :
     base(obj, MainForm)
 {
     this.obj = obj;
 }
Exemplo n.º 24
0
 public CurvePropertyConverter(CoronaObject obj, Form1 MainForm) :
     base(obj, MainForm)
 {
     objSelected = obj;
     curve       = (CourbeBezier)obj.DisplayObject.Figure;
 }
Exemplo n.º 25
0
 public FigurePropertyConverter(CoronaObject obj, Form1 MainForm) :
     base(obj, MainForm)
 {
     this.shape = obj.DisplayObject.Figure;
     this.obj   = obj;
 }
Exemplo n.º 26
0
        private void assetsListView_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (this.MainForm.CurrentProject != null)
            {
                GameElementTreeView treeView = this.MainForm.getElementTreeView();
                if (this.objectCategoryCmbBx.SelectedIndex == 0 || this.objectCategoryCmbBx.SelectedIndex == 1)
                {
                    if (this.displayObjectSelected != null && treeView.LayerSelected != null)
                    {
                        DisplayObject dispObjTemp = this.displayObjectSelected.cloneInstance(true);
                        dispObjTemp.Name = this.displayObjectSelected.Name.ToLower().Replace(" ", "").Replace("-", "");
                        dispObjTemp.OriginalAssetName = this.displayObjectSelected.Name;

                        //Creer un corona object et l'ajouter
                        CoronaObject obj = new CoronaObject(dispObjTemp);
                        if (obj.DisplayObject != null)
                        {
                            obj.DisplayObject.SurfaceRect = new Rectangle(treeView.LayerSelected.SceneParent.SurfaceFocus.Location, obj.DisplayObject.SurfaceRect.Size);
                            this.MainForm.sceneEditorView1.GraphicsContentManager.UpdateSpriteContent(obj,
                                                                                                      this.MainForm.sceneEditorView1.CurrentScale, this.MainForm.sceneEditorView1.getOffsetPoint());
                            this.MainForm.sceneEditorView1.GraphicsContentManager.CleanProjectBitmaps();
                        }

                        CoronaObject objectSelectedInTreeView = treeView.CoronaObjectSelected;
                        if (objectSelectedInTreeView != null)
                        {
                            if (objectSelectedInTreeView.EntityParent != null)
                            {
                                objectSelectedInTreeView.EntityParent.addObject(obj);
                            }
                            else if (objectSelectedInTreeView.isEntity == true)
                            {
                                objectSelectedInTreeView.Entity.addObject(obj);
                            }
                            else
                            {
                                treeView.LayerSelected.addCoronaObject(obj, true);
                            }
                        }
                        else
                        {
                            treeView.LayerSelected.addCoronaObject(obj, true);
                        }


                        treeView.newCoronaObject(obj);

                        if (this.MainForm.isFormLocked == false)
                        {
                            GorgonLibrary.Gorgon.Go();
                        }
                    }
                }
                else if (this.objectCategoryCmbBx.SelectedIndex == 2)
                {
                    if (audioObjectSelected != null)
                    {
                        try
                        {
                            AudioObject obj = audioObjectSelected.cloneInstance();
                            obj.name = obj.name.ToLower().Replace(" ", "").Replace("_", "").Replace("-", "");
                            string assetProjectsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Native-Software\\Asset Manager";
                            if (!Directory.Exists(assetProjectsDirectory))
                            {
                                Directory.CreateDirectory(assetProjectsDirectory);
                            }

                            File.Copy(assetProjectsDirectory + "\\" + this.assetsToSerialize.ProjectName + "\\" + audioObjectSelected.name,
                                      this.MainForm.CurrentProject.SourceFolderPath + "\\" + obj.name, true);

                            this.MainForm.getElementTreeView().newAudioObject(obj);
                            this.MainForm.CurrentProject.AudioObjects.Add(obj);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error during audio file transfert ! \n" + ex.Message);
                        }
                    }
                }
                else if (this.objectCategoryCmbBx.SelectedIndex == 3)
                {
                    if (snippetSelected != null)
                    {
                        Snippet           snippet = snippetSelected.cloneInstance();
                        CoronaGameProject project = this.MainForm.CurrentProject;
                        if (project != null)
                        {
                            bool res = false;
                            for (int i = 0; i < project.Snippets.Count; i++)
                            {
                                if (project.Snippets[i].Name.Equals(snippet.Name))
                                {
                                    res = true;
                                    break;
                                }
                            }

                            if (res == false)
                            {
                                this.MainForm.getElementTreeView().newSnippet(snippet);
                                project.Snippets.Add(snippet);
                                this.MainForm.cgEeditor1.RefreshSnippetLuaCode(project);
                            }
                        }
                    }
                }
                else if (this.objectCategoryCmbBx.SelectedIndex == 4)
                {
                    if (this.fontItemSelected != null)
                    {
                        FontItem font = fontItemSelected.cloneInstance();
                        if (File.Exists(font.OriginalPath))
                        {
                            string destFile = this.MainForm.CurrentProject.SourceFolderPath + "\\" + font.NameForAndroid + ".ttf";
                            File.Copy(font.OriginalPath, destFile, true);
                            font.FileName     = destFile;
                            font.OriginalPath = destFile;
                        }



                        CoronaGameProject project = this.MainForm.CurrentProject;
                        font.projectParent = project;
                        if (project != null)
                        {
                            bool res = false;
                            for (int i = 0; i < project.AvailableFont.Count; i++)
                            {
                                if (project.AvailableFont[i].NameForIphone.Equals(font.NameForIphone))
                                {
                                    res = true;
                                    break;
                                }
                            }

                            if (res == false)
                            {
                                this.MainForm.getElementTreeView().newFontItem(font);
                                project.AvailableFont.Add(font);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 27
0
 //---------------------------------------------------
 //-------------------Constructeurs-------------------
 //---------------------------------------------------
 public PathFollow(CoronaObject objectParent)
 {
     this.Path         = new List <Point>();
     this.objectParent = objectParent;
 }
Exemplo n.º 28
0
        public override object EditValue(
            ITypeDescriptorContext context,
            IServiceProvider provider,
            object value)
        {
            //use IWindowsFormsEditorService object to display a control in the dropdown area
            IWindowsFormsEditorService frmsvr = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (frmsvr == null)
            {
                return(null);
            }



            object propertyConverter = null;

            if (context.Instance is object[])
            {
                propertyConverter = ((object[])context.Instance)[0];
            }
            else
            {
                propertyConverter = context.Instance;
            }

            CoronaObject obj = null;

            if (propertyConverter is PropertyGridConverters.ObjectPropertyConverter)
            {
                PropertyGridConverters.ObjectPropertyConverter prop = (PropertyGridConverters.ObjectPropertyConverter)propertyConverter;

                obj = prop.GetObjectSelected();
            }
            else if (propertyConverter is PropertyGridConverters.SpritePropertyConverter)
            {
                PropertyGridConverters.SpritePropertyConverter prop = (PropertyGridConverters.SpritePropertyConverter)propertyConverter;

                obj = prop.GetObjectSelected();
            }
            else if (propertyConverter is PropertyGridConverters.BodyElementPropertyConverter)
            {
                PropertyGridConverters.BodyElementPropertyConverter prop = (PropertyGridConverters.BodyElementPropertyConverter)propertyConverter;

                obj = prop.GetObjectSelected();
            }

            if (obj != null)
            {
                CollisionGroupPropertyEditor control = new CollisionGroupPropertyEditor(obj, frmsvr);
                frmsvr.DropDownControl(control);

                if (control.SelectedItem != null)
                {
                    return(control.SelectedItem.ToString());
                }
                else
                {
                    return("Default");
                }
            }

            return("Default");
        }
Exemplo n.º 29
0
 public SpritePropertyConverter(CoronaObject obj, Form1 MainForm)
 {
     this.selectedObject = obj;
     this.MainForm       = MainForm;
 }
Exemplo n.º 30
0
 public void setObjectB(CoronaObject obj)
 {
     this.objB        = obj;
     this.obj2Tb.Text = this.objB.DisplayObject.Name;
 }