Esempio n. 1
0
        void BtnClicked(string controlID)
        {
            if (controlID.Contains("Recent_"))
            {
                string filepath = ((TextButton)CurrentControl).Text;
                bool   found    = false;

                if (SerializationHelper.FileExists(filepath))
                {
                    recent.Add(filepath);

                    string text = filepath;

                    string[] split = text.Split(new char[]
                    {
                        '\\', '/'
                    });

                    int len = split[split.Length - 1].Length;
                    len++;

                    text = text.Remove(text.Length - len, len);

                    text += InterOperations.LibraryFilepathExtention;

                    Crosswalk.Message message = new Crosswalk.Message()
                    {
                        Messages = new string[] { text }
                    };

                    SerializationHelper.Serialize <EEDK.Crosswalk.Message>(message, "Temp.temp", "");

                    LoadProject(filepath);

                    InterOperations.ProjectName = SerializationHelper.GetFolderName(
                        filepath.Remove(filepath.Length -
                                        InterOperations.ProjectFileExtention.Length,
                                        InterOperations.ProjectFileExtention.Length));

                    len = ".EPROJ".Length + InterOperations.ProjectName.Length;
                    InterOperations.RootFilepath = filepath.Remove(filepath.Length - len, len);

                    InterOperations.Project.ProjectRootFilepath = InterOperations.RootFilepath;
                    InterOperations.Project.ProjectName         = InterOperations.ProjectName;

                    found = true;
                }
                else
                {
                    recent.Remove(filepath);
                    CurrentControl.Destroy();
                }

                SaveRecent();

                if (found)
                {
                    StartLibraryReader();
                }
            }
            else
            {
                switch (controlID)
                {
                case "Load Level":
                {
                    Common.ShowMouse(true);

                    if (openDia.ShowDialog() == DialogResult.OK)
                    {
                        string filepath = openDia.FileName;

                        recent.Add(filepath);

                        Crosswalk.Message message = new Crosswalk.Message()
                        {
                            Messages = new string[] { (filepath.Remove(filepath.Length -
                                                                       (openDia.SafeFileName.Length + 1), openDia.SafeFileName.Length + 1)) +
                                                      InterOperations.LibraryFilepathExtention }
                        };

                        SerializationHelper.Serialize <Crosswalk.Message>(message, "Temp.temp", "");

                        LoadProject(filepath);

                        InterOperations.ProjectName = SerializationHelper.GetFolderName(
                            filepath.Remove(filepath.Length -
                                            InterOperations.ProjectFileExtention.Length,
                                            InterOperations.ProjectFileExtention.Length));

                        int len = ".EPROJ".Length + InterOperations.ProjectName.Length;
                        InterOperations.RootFilepath = filepath.Remove(filepath.Length - len, len);

                        InterOperations.Project.ProjectRootFilepath = InterOperations.RootFilepath;
                        InterOperations.Project.ProjectName         = InterOperations.ProjectName;

                        StartLibraryReader();
                    }

                    Common.ShowMouse(false);

                    SaveRecent();
                }
                break;

                case "New Level":
                {
                    Common.ShowMouse(true);

                    if (folderDia.ShowDialog() == DialogResult.OK)
                    {
                        string root = folderDia.SelectedPath;

                        InterOperations.RootFilepath = root + "\\";
                        InterOperations.Project      = new Crosswalk.ProjectFile();
                        InterOperations.ProjectName  = SerializationHelper.GetFolderName(root);
                        recent.Add(root + "\\" + InterOperations.ProjectName + InterOperations.ProjectFileExtention);

                        InterOperations.Project.ProjectRootFilepath = InterOperations.RootFilepath;
                        InterOperations.Project.ProjectName         = InterOperations.ProjectName;
                        InterOperations.Project.Framework           = new FrameworkCreation()
                        {
                            AssemblyRefferences = new string[]
                            {
                                "Eon",
                                "Eon.Rendering2D",
                                "Eon.Rendering3D"
                            },
                            DefaultLanguage         = "English",
                            DefaultScreenResolution = 0,
                            DefaultScreenSize       = 0,
                            DefaultTextureQuality   = 2,
                            FullScreen       = true,
                            TargetFramerate  = 166,
                            EngineComponents = new ParameterCollection[]
                            {
                                new ParameterCollection
                                {
                                    ObjectType = "Eon.Rendering3D.Framework.Framework"
                                },
                                new ParameterCollection
                                {
                                    ObjectType = "Eon.Rendering2D.Framework.Framework"
                                }
                            }
                        };

                        string lib = root + InterOperations.LibraryFilepathExtention;
                        SerializationHelper.CopyFiles(Environment.CurrentDirectory, lib, ".dll", "Eon.", true);

                        string content = root + EEDK.Crosswalk.InterOperations.ContentFilepathExtention + "\\Eon";
                        string eonRoot = Environment.CurrentDirectory + "\\Content\\Eon";
                        SerializationHelper.CopyFiles(eonRoot, content, ".xnb", true);

                        EEDK.Crosswalk.Message message = new Crosswalk.Message()
                        {
                            Messages = new string[] { lib }
                        };

                        SerializationHelper.Serialize <EEDK.Crosswalk.Message>(message, "Temp.temp", "");

                        StartLibraryReader();
                    }

                    Common.ShowMouse(false);

                    SaveRecent();
                }
                break;

                default:
                    Common.ExitGame();
                    break;
                }
            }
        }