//---------------------------------------------------------- //--------------------- CONSTRUCTEURS ---------------------- //---------------------------------------------------------- public WidgetTabBar(string name, CoronaLayer layerParent) : base(name, WidgetType.tabBar, layerParent) { Buttons = new List <TabBarButton>(); GradientForTup = new GradientColor(); GradientForTup.isEnabled = false; }
public override CoronaControl Clone(CoronaLayer layerDest, bool incrementName) { JoystickControl newControl = new JoystickControl(layerDest); newControl.isEnabled = this.isEnabled; if (incrementName == true) { int res = -1; if (int.TryParse(this.joystickName.Substring(this.joystickName.Length - 1), out res) == true) { newControl.joystickName = joystickName.Substring(0, joystickName.Length - 1) + (res + 1).ToString(); } else { newControl.joystickName = this.joystickName + 1; } newControl.ControlName = this.ControlName; } else { newControl.joystickName = this.joystickName; newControl.ControlName = this.ControlName; } newControl.ghost = this.ghost; newControl.innerAlpha = this.innerAlpha; newControl.outerAlpha = this.outerAlpha; newControl.outerRadius = this.outerRadius; newControl.innerRadius = this.innerRadius; if (this.innerImage != null) { newControl.innerImage = new Bitmap(this.innerImage); } if (this.outerImage != null) { newControl.outerImage = new Bitmap(this.outerImage); } newControl.joystickLocation = new Point(this.joystickLocation.X, this.joystickLocation.Y); newControl.joystickAlpha = this.joystickAlpha; newControl.joystickFade = this.joystickFade; newControl.joystickFadeDelay = this.joystickFadeDelay; return(newControl); }
//--------------------------------------------------- //-------------------Constructeurs-------------------- //--------------------------------------------------- public JoystickControl(CoronaLayer layerParent) : base(ControlType.joystick, layerParent.Name + "_joystick" + layerParent.Controls.Count) { this.joystickName = layerParent.Name + "_joystick" + layerParent.Controls.Count; this.layerParent = layerParent; this.outerImage = null; this.innerImage = null; this.outerRadius = 30; this.outerAlpha = 1; this.innerRadius = 15; this.innerAlpha = 1; this.joystickLocation = new Point(0, 0); this.joystickAlpha = 1; this.joystickFade = true; this.joystickFadeDelay = 2000; this.ghost = 150; }
public CoronaJointure clone(CoronaObject objA, CoronaObject objB, CoronaLayer layerParent) { CoronaJointure newJoint = new CoronaJointure(layerParent); newJoint.isEnabled = this.isEnabled; newJoint.coronaObjA = objA; newJoint.coronaObjB = objB; newJoint.type = this.type; if (objB != null) { newJoint.name = newJoint.type + "_" + objA.DisplayObject.Name + "_" + objB.DisplayObject.Name; } else { newJoint.name = newJoint.type + "_" + objA.DisplayObject.Name; } newJoint.AnchorPointA = new Point(this.AnchorPointA.X, this.AnchorPointA.Y); newJoint.AnchorPointB = new Point(this.AnchorPointB.X, this.AnchorPointB.Y); newJoint.ObjectAnchorPointA = new Point(this.ObjectAnchorPointA.X, this.ObjectAnchorPointA.Y); newJoint.ObjectAnchorPointB = new Point(this.ObjectAnchorPointB.X, this.ObjectAnchorPointB.Y); newJoint.axisDistance = new Point(this.axisDistance.X, this.axisDistance.Y); newJoint.motorSpeed = this.motorSpeed; newJoint.maxMotorForce = this.maxMotorForce; newJoint.maxMotorTorque = this.maxMotorTorque; newJoint.isMotorEnable = this.isMotorEnable; newJoint.isLimitEnabled = this.isLimitEnabled; newJoint.upperLimit = this.upperLimit; newJoint.lowerLimit = this.lowerLimit; newJoint.frequency = this.frequency; newJoint.maxForce = this.maxForce; newJoint.maxTorque = this.maxTorque; return(newJoint); }
public void clearProject() { //Relacher tous les composants graphiques for (int i = 0; i < this.Scenes.Count; i++) { Scene scene = this.Scenes[i]; for (int j = 0; j < scene.Layers.Count; j++) { CoronaLayer layer = scene.Layers[j]; for (int h = 0; h < layer.CoronaObjects.Count; h++) { CoronaObject obj = layer.CoronaObjects[h]; obj = null; } layer = null; } scene = null; } }
//*********************************** // Constructor //*********************************** public CoronaJointure(CoronaLayer layerParent) { this.type = "NONE"; this.layerParent = layerParent; }
public void refreshAPI(string sourcePage) { //Clear all lists this.Categories.Clear(); this.Items.Clear(); //Chercher toutes les infex de href="# int indexStart = 0; int indexFirstEndBalise = 0; int indexSecondEndBalise = 0; string strStart = "href=\"#"; string strEndFirstBalise = ">"; string strEndSecondBalise = "</a>"; while (indexStart < sourcePage.Length) { indexStart = sourcePage.IndexOf(strStart, indexSecondEndBalise); if (indexStart == -1) { break; } indexFirstEndBalise = sourcePage.IndexOf(strEndFirstBalise, indexStart); if (indexFirstEndBalise == -1) { break; } indexSecondEndBalise = sourcePage.IndexOf(strEndSecondBalise, indexFirstEndBalise); if (indexSecondEndBalise == -1) { break; } string content = sourcePage.Substring(indexFirstEndBalise + 1, indexSecondEndBalise - indexFirstEndBalise - 1); //Treat the content content = content.Replace("\n", ""); content = content.Replace(" ", ""); //Treat if is a category if (content.Contains(".")) { string catName = content.Substring(0, content.IndexOf(".")); int len = content.Length - content.IndexOf("."); string itemName = content.Substring(content.IndexOf(".") + 1, len - 1); this.addItem(catName, itemName, false); } else if (content.Contains(":")) { string catName = content.Substring(0, content.IndexOf(":")); int len = content.Length - content.IndexOf(":"); string itemName = content.Substring(content.IndexOf(":") + 1, len - 1); this.addItem(catName, itemName, true); } else { this.addItem(null, content, false); } } APICategory objectCategory = null; for (int i = 0; i < this.Categories.Count; i++) { if (this.Categories[i].name.ToLower().Equals("object")) { objectCategory = this.Categories[i]; break; } } if (this.editorParent.sceneSelected != null) { CoronaGameProject currentProject = this.editorParent.sceneSelected.projectParent; if (currentProject != null) { APICategory catStoryboard = new APICategory("storyboard"); this.Categories.Add(catStoryboard); if (currentProject.Snippets.Count > 0) { APICategory catSnippets = new APICategory("snippets"); this.Categories.Add(catSnippets); for (int i = 0; i < currentProject.Snippets.Count; i++) { Snippet snippet = currentProject.Snippets[i]; APIItem itemSnippet = new APIItem(snippet.Name.Replace(" ", ""), true); catSnippets.Items.Add(itemSnippet); } } APICategory catResources = new APICategory("resources"); catStoryboard.SubCategories.Add(catResources); //AJouter les scenes for (int i = 0; i < currentProject.Scenes.Count; i++) { Scene scene = currentProject.Scenes[i]; APICategory catScene = new APICategory(scene.Name); catResources.SubCategories.Add(catScene); for (int j = 0; j < scene.Layers.Count; j++) { CoronaLayer layer = scene.Layers[j]; APICategory catLayer = new APICategory(layer.Name); catScene.SubCategories.Add(catLayer); for (int k = 0; k < layer.CoronaObjects.Count; k++) { CoronaObject obj = layer.CoronaObjects[k]; APICategory catObj = new APICategory(obj.DisplayObject.Name); catLayer.SubCategories.Add(catObj); if (objectCategory != null) { catObj.SubCategories.Add(objectCategory); } } for (int k = 0; k < layer.Jointures.Count; k++) { CoronaJointure joint = layer.Jointures[k]; APIItem itemJoint = new APIItem(joint.name, false); catLayer.Items.Add(itemJoint); } for (int k = 0; k < layer.Controls.Count; k++) { CoronaControl control = layer.Controls[k]; APIItem itemControl = new APIItem(control.ControlName, false); catLayer.Items.Add(itemControl); } } } } } }
//---------------------------------------------------------- //--------------------- CONSTRUCTEURS ---------------------- //---------------------------------------------------------- public WidgetPickerWheel(string name, CoronaLayer layerParent) : base(name, WidgetType.pickerWheel, layerParent) { this.Columns = new List <PickerWheelColumn>(); }
//--------------------------------------------------- //-------------------Constructeurs------------------- //--------------------------------------------------- public LayerPropertyConverter(CoronaLayer layer, Form1 MainForm) { this.layerSelected = layer; this.MainForm = MainForm; }
//---------------------------------------------------------- //--------------------- CONSTRUCTEURS ---------------------- //---------------------------------------------------------- public CoronaWidget(string name, WidgetType type, CoronaLayer layerParent) { this.Name = name; this.Type = type; this.LayerParent = layerParent; }
public bool IsNameExistsInProject(string objName) { for (int i = 0; i < this.Scenes.Count; i++) { Scene scene = this.Scenes[i]; if (scene.Name.Equals(objName)) { return(true); } for (int j = 0; j < scene.Layers.Count; j++) { CoronaLayer layer = scene.Layers[j]; if (layer.Name.Equals(objName)) { return(true); } if (layer.TilesMap != null) { if (layer.TilesMap.TilesMapName.Equals(objName)) { return(true); } } for (int k = 0; k < layer.CoronaObjects.Count; k++) { CoronaObject obj = layer.CoronaObjects[k]; if (obj.isEntity == false) { if (obj.DisplayObject.Name.Equals(objName)) { return(true); } } else { if (obj.Entity.Name.Equals(objName)) { return(true); } for (int l = 0; l < obj.Entity.CoronaObjects.Count; l++) { CoronaObject child = obj.Entity.CoronaObjects[l]; if (child.DisplayObject.Name.Equals(objName)) { return(true); } } } } for (int k = 0; k < layer.Controls.Count; k++) { if (layer.Controls[k].ControlName.Equals(objName)) { return(true); } } } } return(false); }
public void buildToLua(BackgroundWorker worker, bool isCustomBuild, float XRatio, float YRatio, bool isDebug) { if (this.project != null) { try { float moyenneRatio = (XRatio + YRatio) / 2; //Report progress worker.ReportProgress(10); if (Directory.Exists(this.project.BuildFolderPath)) { Directory.Delete(this.project.BuildFolderPath, true); } Directory.CreateDirectory(this.project.BuildFolderPath); //Report progress worker.ReportProgress(20); CreateConfigLua(isCustomBuild, XRatio, YRatio); CreateBuildSettings(); //Report progress worker.ReportProgress(30); createMain(isDebug); //Report progress worker.ReportProgress(40); ImageResizer ImageResizer = new ImageResizer(this.project); if (!ImageResizer.GenerateIconFile()) { MessageBox.Show("can't create Icon!"); } if (isCustomBuild == false) { if (!ImageResizer.GenerateImageFile()) { MessageBox.Show("can't create Images!"); } } else { if (!ImageResizer.generateImageFilesWithRatio(XRatio, YRatio)) { MessageBox.Show("can't create Images!"); } } //Report progress worker.ReportProgress(50); CreateLuaLangue(this.project); //Report progress worker.ReportProgress(60); //Importer les fichiers necessaires List <string> filenames = this.getLuaFilesUsed(isDebug); if (filenames != null) { for (int i = 0; i < filenames.Count; i++) { File.Copy(this.PATH_REPOSITORY_DIR + "\\" + filenames[i], this.project.BuildFolderPath + "\\" + filenames[i].Replace("Krea Remote\\", ""), true); } } for (int i = 0; i < project.Scenes.Count; i++) { Scene scene = project.Scenes[i]; if (scene.isEnabled == true) { for (int j = 0; j < scene.Layers.Count; j++) { CoronaLayer layer = scene.Layers[j]; if (layer.isEnabled == true) { for (int k = 0; k < layer.CoronaObjects.Count; k++) { CoronaObject objectToBuild = layer.CoronaObjects[k]; if (objectToBuild.isEnabled == true) { if (objectToBuild.isEntity == false) { PhysicsBody ph = objectToBuild.PhysicsBody; if (ph.Mode != PhysicsBody.PhysicBodyMode.Inactive) { string objName = objectToBuild.DisplayObject.Name.Replace(" ", ""); //Creer le fichier lua associé PhysicBodyLuaGenerator gen = new PhysicBodyLuaGenerator(ph); gen.writeToLua(new DirectoryInfo(project.BuildFolderPath), XRatio, YRatio); if (File.Exists(project.SourceFolderPath + "\\body" + objName.ToLower() + ".lua")) { File.Delete(project.SourceFolderPath + "\\body" + objName.ToLower() + ".lua"); } } } else { for (int l = 0; l < objectToBuild.Entity.CoronaObjects.Count; l++) { CoronaObject child = objectToBuild.Entity.CoronaObjects[l]; if (child.isEnabled == true) { PhysicsBody ph = child.PhysicsBody; if (ph.Mode != PhysicsBody.PhysicBodyMode.Inactive) { string objName = child.DisplayObject.Name.Replace(" ", ""); //Creer le fichier lua associé PhysicBodyLuaGenerator gen = new PhysicBodyLuaGenerator(ph); gen.writeToLua(new DirectoryInfo(project.BuildFolderPath), XRatio, YRatio); if (File.Exists(project.SourceFolderPath + "\\body" + objName.ToLower() + ".lua")) { File.Delete(project.SourceFolderPath + "\\body" + objName.ToLower() + ".lua"); } } } } } } } } } } } CopyFolder(this.project.SourceFolderPath, this.project.BuildFolderPath); } catch (Exception ex) { MessageBox.Show("Build Failed!\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } else { MessageBox.Show("Build Failed ! ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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); } }
public CoronaObject cloneObject(CoronaLayer layerDest, bool incrementName, bool keepPosition) { if (this.isEntity == true) { CoronaObject newEntity = new CoronaObject(true); newEntity.isEnabled = this.isEnabled; layerDest.addCoronaObject(newEntity, incrementName); newEntity.Entity = this.Entity.cloneEntity(newEntity); return(newEntity); } else if (this.EntityParent != null) { if (this.displayObject != null) { //Dupliquer le displayObject DisplayObject newDisplayObject = this.DisplayObject.cloneInstance(keepPosition); CoronaObject newObject = new CoronaObject(newDisplayObject); newObject.displayObject.Name = layerDest.SceneParent.projectParent.IncrementObjectName(newDisplayObject.Name); if (newObject != null) { //Copier le body if (this.PhysicsBody != null) { newObject.PhysicsBody = this.PhysicsBody.cloneBody(newObject); } newObject.isDraggable = this.isDraggable; //Copier les events de l'objet newObject.onStartFunction = this.onStartFunction; newObject.onPauseFunction = this.onPauseFunction; newObject.onDeleteFunction = this.onDeleteFunction; StringBuilder sb = new StringBuilder(); //Retirer le nom des functions et les ajuster au nom de l'objet //---POUR START sb.Append(newObject.onStartFunction); newObject.onStartFunction = sb.ToString().Replace(this.displayObject.Name, newObject.displayObject.Name); sb.Clear(); //---POUR PAUSE sb.Append(newObject.onPauseFunction); newObject.onPauseFunction = sb.ToString().Replace(this.displayObject.Name, newObject.displayObject.Name); sb.Clear(); //---POUR DELETE sb.Append(newObject.onDeleteFunction); newObject.onDeleteFunction = sb.ToString().Replace(this.displayObject.Name, newObject.displayObject.Name); sb.Clear(); if (this.isGenerator == true) { newObject.isGenerator = true; newObject.generatorDelay = this.generatorDelay; newObject.generatorIteration = this.generatorIteration; newObject.generatorEmissionType = this.generatorEmissionType; newObject.FadeInEnabled = this.FadeInEnabled; newObject.FadeInSpeed = this.FadeInSpeed; newObject.FadeOutEnabled = this.FadeOutEnabled; newObject.FadeOutSpeed = this.FadeOutSpeed; newObject.RemoveOnCompleteFadeOut = this.RemoveOnCompleteFadeOut; newObject.DelayBetweenFades = this.DelayBetweenFades; newObject.GeneratorXImpulse = this.GeneratorXImpulse; newObject.GeneratorYImpulse = this.GeneratorYImpulse; } newObject.displayObject.GradientColor.isEnabled = this.displayObject.GradientColor.isEnabled; newObject.displayObject.GradientColor.color1 = this.displayObject.GradientColor.color1; newObject.displayObject.GradientColor.color2 = this.displayObject.GradientColor.color2; newObject.displayObject.GradientColor.direction = this.displayObject.GradientColor.direction; newObject.displayObject.Alpha = this.displayObject.Alpha; newObject.PathFollow = this.PathFollow.cloneInstance(newObject); newObject.displayObject.Rotation = this.displayObject.Rotation; newObject.isDraggable = this.isDraggable; return(newObject); } } } else { if (this.displayObject != null) { //Dupliquer le displayObject DisplayObject newDisplayObject = this.DisplayObject.cloneInstance(keepPosition); CoronaObject newObject = new CoronaObject(newDisplayObject); if (newObject != null) { newObject.isEnabled = this.isEnabled; //Copier le layer parent layerDest.addCoronaObject(newObject, incrementName); newObject.displayObject.OriginalAssetName = this.displayObject.OriginalAssetName; //Copier le body if (this.PhysicsBody != null) { newObject.PhysicsBody = this.PhysicsBody.cloneBody(newObject); } //Copier les events de l'objet newObject.onStartFunction = this.onStartFunction; newObject.onPauseFunction = this.onPauseFunction; newObject.onDeleteFunction = this.onDeleteFunction; StringBuilder sb = new StringBuilder(); //Retirer le nom des functions et les ajuster au nom de l'objet //---POUR START sb.Append(newObject.onStartFunction); newObject.onStartFunction = sb.ToString().Replace(this.displayObject.Name, newObject.displayObject.Name); sb.Clear(); //---POUR PAUSE sb.Append(newObject.onPauseFunction); newObject.onPauseFunction = sb.ToString().Replace(this.displayObject.Name, newObject.displayObject.Name); sb.Clear(); //---POUR DELETE sb.Append(newObject.onDeleteFunction); newObject.onDeleteFunction = sb.ToString().Replace(this.displayObject.Name, newObject.displayObject.Name); sb.Clear(); if (this.isGenerator == true) { newObject.isGenerator = true; newObject.generatorDelay = this.generatorDelay; newObject.generatorIteration = this.generatorIteration; newObject.generatorEmissionType = this.generatorEmissionType; newObject.FadeInEnabled = this.FadeInEnabled; newObject.FadeInSpeed = this.FadeInSpeed; newObject.FadeOutEnabled = this.FadeOutEnabled; newObject.FadeOutSpeed = this.FadeOutSpeed; newObject.RemoveOnCompleteFadeOut = this.RemoveOnCompleteFadeOut; newObject.DelayBetweenFades = this.DelayBetweenFades; newObject.GeneratorXImpulse = this.GeneratorXImpulse; newObject.GeneratorYImpulse = this.GeneratorYImpulse; } newObject.displayObject.GradientColor.isEnabled = this.displayObject.GradientColor.isEnabled; newObject.displayObject.GradientColor.color1 = this.displayObject.GradientColor.color1; newObject.displayObject.GradientColor.color2 = this.displayObject.GradientColor.color2; newObject.displayObject.GradientColor.direction = this.displayObject.GradientColor.direction; newObject.displayObject.Alpha = this.displayObject.Alpha; newObject.PathFollow = this.PathFollow.cloneInstance(newObject); newObject.displayObject.Rotation = this.displayObject.Rotation; newObject.isDraggable = this.isDraggable; return(newObject); } } } return(null); }
private void createMain(bool isDebug) { string path = this.project.BuildFolderPath + "\\main.lua"; //Copier le fichier template main.lua et l'editer File.Copy(this.PATH_TEMPLATES_DIR + "\\main.lua", path, true); StringBuilder sb = new StringBuilder(); //Ouvrir le fichier et recuperer son contenu sb.Append(File.ReadAllText(path)); //if (isDebug == true) //{ // sb.Insert(0, "require(\"mobdebug\").on()\n"); //} //Se deplacer a l'index de ----BODY:START int indexToWrite = sb.ToString().IndexOf("----BODY:START") + "----BODY:START".Length; String contentToWrite = "\n\n"; //bool containsTextObject = false; //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++) // { // CoronaLayer layer = this.project.Scenes[i].Layers[j]; // if (layer.isEnabled == true) // { // for (int k = 0; k < layer.CoronaObjects.Count; k++) // { // if (layer.CoronaObjects[k].isEnabled == true) // { // if (layer.CoronaObjects[k].isEntity == false) // { // if (layer.CoronaObjects[k].DisplayObject.Type.Equals("FIGURE")) // { // if (layer.CoronaObjects[k].DisplayObject.Figure.ShapeType.Equals("TEXT")) // { // containsTextObject = true; // break; // } // } // } // else // { // for (int l = 0; l < layer.CoronaObjects[k].Entity.CoronaObjects.Count; l++) // { // if (layer.CoronaObjects[k].Entity.CoronaObjects[l].DisplayObject.Type.Equals("FIGURE")) // { // if (layer.CoronaObjects[k].Entity.CoronaObjects[l].isEnabled == true) // { // if (layer.CoronaObjects[k].Entity.CoronaObjects[l].DisplayObject.Figure.ShapeType.Equals("TEXT")) // { // containsTextObject = true; // break; // } // } // } // } // if (containsTextObject == true) // break; // } // } // } // } // if (containsTextObject == true) // break; // } // } // if (containsTextObject == true) // break; //} //if (containsTextObject == true) // contentToWrite += "rosetta:initiate()\n"; //Set the default language contentToWrite += "rosetta:initiate()\n"; contentToWrite += "rosetta:setCurrentLanguage(\"" + this.project.DefaultLanguage.ToLower() + "\")\n\n"; //Creer les sons contentToWrite += this.CreateAudioParamsLua(this.project.AudioObjects); //Copier toutes les ressources necessaires aux tilesmap du resources directory au documents directory 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++) { CoronaLayer layer = this.project.Scenes[i].Layers[j]; if (layer.isEnabled == true) { if (layer.TilesMap != null) { if (layer.TilesMap.isEnabled == true) { string mapName = layer.TilesMap.TilesMapName.ToLower(); contentToWrite += "\t local override = false\n"; contentToWrite += "\t local path1 = system.pathForFile(\"" + mapName + "lastmodifiedtime.txt\", system.ResourceDirectory)\n"; contentToWrite += "\t local path2 = system.pathForFile(\"" + mapName + "lastmodifiedtime.txt\", system.DocumentsDirectory)\n"; contentToWrite += "\t local result = getLastestFileTime(path1,path2)\n"; contentToWrite += "\t if(result) then \n"; contentToWrite += "\t\t if(result == path1) then\n"; contentToWrite += "\t\t\t override = true\n"; contentToWrite += "\t\t elseif(result == path2) then \n"; contentToWrite += "\t\t\t override = false\n"; contentToWrite += "\t\t end\n"; contentToWrite += "\t else\n"; contentToWrite += "\t\t override = true\n"; contentToWrite += "\t end\n"; contentToWrite += "\tcopyFile( \"" + mapName + "lastmodifiedtime.txt\", system.ResourceDirectory, \"" + mapName + "lastmodifiedtime.txt\", system.DocumentsDirectory,override )\n"; contentToWrite += "\tcopyFile( \"" + mapName + "textures.json\", system.ResourceDirectory, \"" + mapName + "textures.json\", system.DocumentsDirectory,override )\n"; contentToWrite += "\tcopyFile( \"" + mapName + "objects.json\", system.ResourceDirectory, \"" + mapName + "objects.json\", system.DocumentsDirectory,override)\n"; contentToWrite += "\tcopyFile( \"" + mapName + "collisions.json\", system.ResourceDirectory, \"" + mapName + "collisions.json\", system.DocumentsDirectory,override )\n"; contentToWrite += "\n"; } } } } } } for (int i = 0; i < this.project.Scenes.Count; i++) { if (this.project.Scenes[i].isEnabled == true) { contentToWrite += "storyboard.gotoScene(\"" + this.project.Scenes[i].Name.ToLower() + "\")\n"; break; } } if (Settings1.Default.RemoteControlEnabled == true && isDebug == false) { string ip = this.GetIpAdresse(); if (!ip.Equals("")) { //Copy Remote Lua File contentToWrite += "local remoteParams= {ipAddress = \"" + ip + "\", port = 8200}\n"; contentToWrite += "local remoteConnection = function()\n\tlocal remoteControler,errorsLog = require(\"remotecontroler\").RemoteControler.create(remoteParams)\n"; contentToWrite += "\tfor i = 1,#errorsLog do\n"; contentToWrite += "\t\tprint(errorsLog[i])\n"; contentToWrite += "\tend\n"; contentToWrite += "end\n"; contentToWrite += "timer.performWithDelay(1000,remoteConnection,1)"; } } sb.Insert(indexToWrite, contentToWrite); File.Delete(path); FileStream fs = File.Create(path); fs.Close(); File.AppendAllText(path, sb.ToString()); sb.Clear(); sb = null; }
//--------------------------------------------------- //-------------------Methodes------------------------ //--------------------------------------------------- public List <string> getLuaFilesUsed(bool isDebug) { if (this.project != null) { bool fpsAnalyser = false; bool fStarPathFinding = false; bool generator = false; bool joystick = false; bool mobileEditorEngine = false; bool pathFollow = false; bool rosetta = true; bool tilesmap = false; bool entity = false; List <string> fileNames = new List <string>(); for (int i = 0; i < this.project.Scenes.Count; i++) { Scene scene = this.project.Scenes[i]; if (scene.isEnabled == true) { if (scene.Name.Equals("mapeditormobile")) { mobileEditorEngine = true; } if (scene.IsFPSVisible == true) { fpsAnalyser = true; } for (int j = 0; j < scene.Layers.Count; j++) { CoronaLayer layer = scene.Layers[j]; if (layer.isEnabled == true) { if (layer.TilesMap != null) { if (layer.TilesMap.isEnabled == true) { tilesmap = true; if (layer.TilesMap.IsPathFindingEnabled == true) { fStarPathFinding = true; } } } } for (int k = 0; k < layer.Controls.Count; k++) { CoronaControl control = layer.Controls[k]; if (control.isEnabled == true) { if (control.Type == CoronaControl.ControlType.joystick) { joystick = true; break; } } } for (int k = 0; k < layer.CoronaObjects.Count; k++) { CoronaObject obj = layer.CoronaObjects[k]; if (obj.isEnabled == true) { if (obj.isEntity == false) { if (obj.PathFollow.isEnabled == true) { pathFollow = true; } if (obj.isGenerator == true) { generator = true; } } else { entity = true; if (obj.isGenerator == true) { generator = true; } for (int l = 0; l < obj.Entity.CoronaObjects.Count; l++) { CoronaObject child = obj.Entity.CoronaObjects[l]; if (child.isEnabled == true) { if (child.PathFollow.isEnabled == true) { pathFollow = true; } if (child.isGenerator == true) { generator = true; } } } } } } } } } fileNames.Add("object.lua"); fileNames.Add("camera.lua"); fileNames.Add("soundengine.lua"); if (fpsAnalyser == true) { fileNames.Add("graph.lua"); fileNames.Add("perfanalyser.lua"); } if (fStarPathFinding == true) { fileNames.Add("fstar.lua"); } if (generator == true) { fileNames.Add("generator.lua"); } if (joystick == true) { fileNames.Add("joystick.lua"); } if (mobileEditorEngine == true) { fileNames.Add("mobileeditorengine.lua"); } if (pathFollow == true) { fileNames.Add("pathfollow.lua"); } if (rosetta == true) { fileNames.Add("rosetta.lua"); } if (tilesmap == true) { fileNames.Add("tilesmap.lua"); } if (entity == true) { fileNames.Add("entity.lua"); } if (Settings1.Default.RemoteControlEnabled == true && isDebug == false) { fileNames.Add("Krea Remote\\remotecontroler.lua"); } //if (isDebug == true) //{ // fileNames.Add("mobdebug.lua"); //} return(fileNames); } return(null); }
public abstract CoronaControl Clone(CoronaLayer layerDest, bool incrementName);
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); } }
private List <string> getAllFontsUsed(CoronaGameProject project) { if (project != null) { List <string> list = new List <string>(); for (int i = 0; i < project.Scenes.Count; i++) { Scene scene = this.project.Scenes[i]; for (int j = 0; j < scene.Layers.Count; j++) { CoronaLayer layer = scene.Layers[j]; for (int k = 0; k < layer.CoronaObjects.Count; k++) { CoronaObject obj = layer.CoronaObjects[k]; if (obj.isEntity == false) { if (obj.DisplayObject.Figure != null) { Figure fig = obj.DisplayObject.Figure; if (fig.ShapeType.Equals("TEXT")) { Texte txt = fig as Texte; string fontName = txt.font2.getFontNameForAndroid(); if (!list.Contains(fontName)) { list.Add(fontName); string fontsfolder = System.Environment.GetFolderPath( System.Environment.SpecialFolder.Fonts); FontNameGetter fontNameGetter = new FontNameGetter(); string res = fontNameGetter.GetFontFileName(new DirectoryInfo(fontsfolder), txt.font2); if (File.Exists(res)) { string fileDest = project.BuildFolderPath + "\\" + fontName + ".ttf"; File.Copy(res, fileDest, true); } } } } } else { for (int l = 0; l < obj.Entity.CoronaObjects.Count; l++) { CoronaObject child = obj.Entity.CoronaObjects[l]; if (child.DisplayObject.Figure != null) { Figure fig = child.DisplayObject.Figure; if (fig.ShapeType.Equals("TEXT")) { Texte txt = fig as Texte; string fontName = txt.font2.getFontNameForAndroid(); if (!list.Contains(fontName)) { list.Add(fontName); string fontsfolder = System.Environment.GetFolderPath( System.Environment.SpecialFolder.Fonts); FontNameGetter fontNameGetter = new FontNameGetter(); string res = fontNameGetter.GetFontFileName(new DirectoryInfo(fontsfolder), txt.font2); if (File.Exists(res)) { string fileDest = project.BuildFolderPath + "\\" + fontName + ".ttf"; File.Copy(res, fileDest, true); } } } } } } } } } return(list); } return(null); }