Exemplo n.º 1
0
        private void loadProjClick(object sender, EventArgs e)
        {
            openFile.Multiselect     = false;
            openFile.Filter          = "Dyzen Project File (*.dyz)|*.dyz";
            openFile.CheckFileExists = true;
            openFile.CheckPathExists = true;
            if (projectPath != null)
            {
                openFile.FileName = Path.GetFileNameWithoutExtension(projectPath);
            }
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                projectPath = openFile.FileName;
            }
            else
            {
                return;
            }
            if (Path.GetFileNameWithoutExtension(projectPath) == "")
            {
                return;
            }
            ProjectContainer pc = ProjectContainer.Deserialize(projectPath);

            pc.GlobalPalette.ToGlobalColorPalette();
            File.WriteAllBytes("tmp.bin", pc.SP12);
            spriteGFXBox1.LoadGFX("tmp.bin", 0);
            File.Delete("tmp.bin");
            File.WriteAllBytes("tmp.bin", pc.SP34);
            spriteGFXBox2.LoadGFX("tmp.bin", 0);
            File.Delete("tmp.bin");
            if (pc.Frames != null && pc.Frames.Length > 0)
            {
                resizeableSpriteGridController1.MidX = pc.Frames[0].MidX + 136;
                resizeableSpriteGridController1.MidY = pc.Frames[0].MidY + 104;
            }
            frameCreator1.LoadProjectFrames(pc.GetFrames(spriteGFXBox1.Tiles16,
                                                         spriteGFXBox2.Tiles16, spriteGFXBox1.Tiles8, spriteGFXBox2.Tiles8));
            animationCreator1.LoadProject(pc.GetAnimations(frameCreator1.Frames));
            codeEditorController1.CodeEditor.ClearAll();
            codeEditorController1.CodeEditor.AppendText(pc.Code);
            MessageBox.Show("Project " + Path.GetFileNameWithoutExtension(projectPath) + " Loaded.",
                            "Load Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }