Ejemplo n.º 1
0
        public void cleanCurrentAssetToSerialize()
        {
            if (this.assetsToSerialize != null)
            {
               /* for (int i = 0; i<this.assetsToSerialize.ListObjects.Count; i++)
                {
                    DisplayObject obj = this.assetsToSerialize.ListObjects[i];
                    if (obj.Image != null)
                        obj.Image.Dispose();

                    if (obj.SpriteSet != null)
                    {
                        for (int j = 0; j < obj.SpriteSet.Frames.Count; j++)
                        {
                            obj.SpriteSet.Frames[j].Image.Dispose();
                        }
                    }
                }*/

                this.assetsToSerialize = null;
            }
        }
Ejemplo n.º 2
0
        public void removeFrame(int index)
        {
            if (this.sheet != null && this.mainForm.CurrentAssetProject != null)
            {
                AssetsToSerialize assetProject = this.mainForm.CurrentAssetProject;
                SpriteFrame       frame        = this.sheet.Frames[index];
                this.sheet.Frames.Remove(frame);

                //Chercher toutes lespsriteSet utilisant cette frame
                for (int i = 0; i < assetProject.SpriteSets.Count; i++)
                {
                    CoronaSpriteSet    set            = assetProject.SpriteSets[i];
                    List <SpriteFrame> framesToDelete = set.checkFramesIntegrity();
                    if (framesToDelete != null)
                    {
                        for (int j = 0; j < framesToDelete.Count; j++)
                        {
                            set.Frames.Remove(framesToDelete[j]);
                        }
                        framesToDelete = null;

                        List <CoronaSpriteSetSequence> sequencesToDelete = set.checkSequencesIntegrity();
                        if (sequencesToDelete != null)
                        {
                            for (int j = 0; j < sequencesToDelete.Count; j++)
                            {
                                CoronaSpriteSetSequence sequenceToDelete = sequencesToDelete[j];
                                set.Sequences.Remove(sequenceToDelete);
                                MessageBox.Show("The sequence named \"" + sequenceToDelete.Name + "\", located in the sprite set named \"" + set.Name + "\", has been automatically removed because it used a frame index that does not exist anymore!", "Sequence Integrity Corrupted", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                sequenceToDelete = null;
                            }

                            sequencesToDelete = null;
                        }
                    }
                }
                frame.Image.Dispose();


                frame = null;


                //Chercher toutes lespsriteSet utilisant cette frame
                //for (int i = 0; i < assetProject.SpriteSets.Count; i++)
                //{
                //    bool hasFound = false;
                //    CoronaSpriteSet set = assetProject.SpriteSets[i];
                //    for (int j = 0; j < set.Frames.Count; j++)
                //    {
                //        if (set.Frames[j] == frame)
                //        {
                //            hasFound = true;
                //            break;
                //        }
                //    }

                //    if (hasFound == true)
                //    {
                //        this.mainForm.removeSpriteSet(set);
                //    }
                //}
                //frame.Image.Dispose();

                //this.sheet.Frames.Remove(frame);
                //frame = null;
            }
        }
Ejemplo n.º 3
0
 public void loadAssetsListBxFromSerialized(AssetsToSerialize assetsToSerialize)
 {
     if (assetsToSerialize != null)
     {
         this.objectCategoryCmbBx.SelectedIndex = 0;
     }
 }
Ejemplo n.º 4
0
        public void loadAssetsFromProject( String pathDirToload)
        {
            if(this.MainForm.CurrentProject != null)
            {
                cleanCurrentAssetToSerialize();

                string documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Native-Software";
                if (!Directory.Exists(documentsDirectory))
                    Directory.CreateDirectory(documentsDirectory);

                //Creer d'abord le repertoire du project en cours si il n'existe pas !
                DirectoryInfo dirCurrentProject = null;
                string pathDirCurrentProject = documentsDirectory + "\\Asset Manager\\" + this.MainForm.CurrentProject.ProjectName;
                if (!Directory.Exists(pathDirCurrentProject))
                {
                    dirCurrentProject = Directory.CreateDirectory(pathDirCurrentProject);
                }

                //Recuperer les assets du repertoire selectioné
                DirectoryInfo dirProjectSelected = new DirectoryInfo(pathDirToload);
                string pathFileSerialized = pathDirToload + "\\" + dirProjectSelected.Name.Replace(" ", "_") + ".kres";
                if (File.Exists(pathFileSerialized))
                {

                    FileStream fs = File.OpenRead(pathFileSerialized);
                    if (fs.Length > 0)
                    {
                        MemoryStream ms = new MemoryStream();
                        ms.SetLength(fs.Length);

                        fs.Read(ms.GetBuffer(), 0, (int)ms.Length);

                        assetsToSerialize = new AssetsToSerialize();

                        assetsToSerialize = (AssetsToSerialize)SerializerHelper.DeSerializeBinary(ms);
                        ms.Close();

                        //Remplir la Assets List bx avec la liste
                        loadAssetsListBxFromSerialized(assetsToSerialize);
                    }

                    fs.Close();

                }
                else
                {
                    MessageBox.Show("NO ASSETS FOUND FOR THIS PROJECT !\n You should open the Asset manager to create your assets for this project !",
                                                                           "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);

                }
            }
               /* else
            {
                MessageBox.Show("NO PROJECT OPENED!\n Please open or create a project before continuing !",
                                                                           "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }*/
        }
Ejemplo n.º 5
0
        private void projectsCmbBx_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.projectsCmbBx.SelectedItem != null)
            {
                 if (this.CurrentAssetProject != null)
                {
                    this.saveCurrentAssetProject();
                    this.CurrentAssetProject.clean();
                    this.CurrentAssetProject = null;
                }

                string projectName = this.projectsCmbBx.SelectedItem.ToString();

                string documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Native-Software";
                if (!Directory.Exists(documentsDirectory))
                    Directory.CreateDirectory(documentsDirectory);

                string projectFullPath = documentsDirectory + "\\Asset Manager\\" + projectName;
                if (Directory.Exists(projectFullPath))
                {
                    if (File.Exists(projectFullPath + "\\" + projectName + ".kres"))
                    {
                        try
                        {
                            //Creer une hierarchie meme vide
                            AssetsToSerialize assets = new AssetsToSerialize();

                            //Recuperer les instnces de chaque Asset
                            FileStream fs = File.OpenRead(projectFullPath + "\\" + projectName + ".kres");
                            if (fs.Length > 0)
                            {
                                MemoryStream ms = new MemoryStream();
                                ms.SetLength(fs.Length);

                                fs.Read(ms.GetBuffer(), 0, (int)ms.Length);

                                assets = (AssetsToSerialize)SerializerHelper.DeSerializeBinary(ms);
                                ms.Close();
                            }
                            fs.Close();
                            assets.ProjectName = projectName;

                            this.CurrentAssetProject = assets;

                            this.RefreshAssetListView();
                        }
                        catch (Exception ex)
                        {
                               MessageBox.Show("Error:\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        private void initAssetProjectsCmbBx()
        {
            try
            {

                this.projectsCmbBx.Items.Clear();
                this.projectsCmbBx.Text = "";
                if (this.CurrentAssetProject != null)
                {
                    this.CurrentAssetProject.clean();
                    this.CurrentAssetProject = null;
                }

                //-----------------------------Verifier que le repertoire des assets est bien crée ---------------------------------

                string documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Native-Software";
                if (!Directory.Exists(documentsDirectory))
                    Directory.CreateDirectory(documentsDirectory);

                if (!Directory.Exists(documentsDirectory + "\\Asset Manager"))
                    Directory.CreateDirectory(documentsDirectory + "\\Asset Manager");

                //Recuperer le repertoire de l'asset manager
                DirectoryInfo dir = new DirectoryInfo(documentsDirectory + "\\Asset Manager\\");
                foreach (DirectoryInfo dirProject in dir.GetDirectories())
                {
                    FileInfo[] tabFileInfo = dirProject.GetFiles("*.kres");
                    if (tabFileInfo.Length == 0)
                    {
                        //Create one
                        AssetsToSerialize assets = new AssetsToSerialize();
                        assets.ProjectName = dirProject.Name;
                        this.CurrentAssetProject = assets;
                        this.saveCurrentAssetProject();
                        this.CurrentAssetProject = null;

                        this.projectsCmbBx.Items.Add(dirProject.Name);
                    }
                    else
                    {
                        for (int i = 0; i < tabFileInfo.Length; i++)
                        {
                            this.projectsCmbBx.Items.Add(dirProject.Name);
                        }

                    }

                }

                if (this.projectsCmbBx.Items.Count > 0)
                    this.projectsCmbBx.SelectedIndex = 0;
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR OCCURS DURING LOADING ! \n " + ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }