Пример #1
0
        public static void DownloadFramework(bool setsStatus)
        {
            if (!Feed.CheckOnline())
            {
                MessageBox.Show("Reloading the framework requires a valid internet connection. The Lynx2D framework could not be downloaded.", "Lynx2D Engine - Message");
                return;
            }

            try
            {
                using (WebClient client = new WebClient())
                {
                    client.DownloadFileCompleted += (object s, AsyncCompletedEventArgs e) =>
                    {
                        if (setsStatus)
                        {
                            form.SetStatus("Downloaded Lynx2D framework.", Main.StatusType.Message);
                        }

                        form.RefreshBrowser();

                        client.Dispose();
                    };

                    client.DownloadFile(new Uri("http://www.lynx2d.com/res/lynx2d-min.js"), "projects/" + cur + "/data/lynx2d.js");
                }
            }
            catch (Exception exc)
            {
                Feed.GiveException("Framework Reload", exc);
            }
        }
Пример #2
0
        public static void Create()
        {
            if (!Feed.CheckOnline())
            {
                MessageBox.Show("Creating a project requires a valid internet connection. The Lynx2D framework could not be downloaded.", "Lynx2D Engine - Message");
                return;
            }

            CheckProjectsExistence();

            cur = Input.Prompt("Enter the name of the new project", "Create New Project");
            if (cur == "HAS_BEEN_CLOSED")
            {
                return;
            }

            if (Manager.CheckDirectory("projects/" + cur, false))
            {
                MessageBox.Show("Project '" + cur + "' already exists.", "Lynx2D Engine - Message");

                Create();
                return;
            }

            MakeCanon();
        }
Пример #3
0
        public static async void Export()
        {
            if (cur == string.Empty || cur == "HAS_BEEN_CLOSED")
            {
                return;
            }

            bool obfuscated = false;

            form.SetStatus("Started exporting project.", Main.StatusType.Message);

            Save();
            ExportHTML();

            gameCode = (Engine.bSettings.mergeFramework ? File.ReadAllText("projects/" + cur + "/data/lynx2d.js") : "") + "lx.Initialize('" + cur + "'); lx.Smoothing(" + Engine.bSettings.imageSmoothing.ToString().ToLower() + ");";
            Engine.BuildEngineCode(true);

            gameCode += "lx.Start(" + Engine.bSettings.initialFramerate + ")";

            using (FileStream fs = new FileStream("projects/" + cur + "/data/game.js", FileMode.Create))
                using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
                {
                    if (Engine.bSettings.obfuscates)
                    {
                        if (!Feed.CheckOnline())
                        {
                            form.SetStatus("Game obfuscation requires a internet connection.", Main.StatusType.Warning);
                        }
                        else
                        {
                            form.SetStatus("Obfuscating game code.", Main.StatusType.Message);

                            try
                            {
                                string r = await Obfuscator.Encode(gameCode);

                                gameCode = r;

                                obfuscated = true;
                            }
                            catch
                            {
                                form.SetStatus("Could not obfuscate game code.", Main.StatusType.Warning);
                            }
                        }
                    }

                    w.Write(gameCode);

                    w.Close();
                    fs.Close();
                }

            gameCode = "lx.Initialize('" + cur + "'); lx.Smoothing(true); lx.Start(60);";

            if (obfuscated || !Engine.bSettings.obfuscates)
            {
                form.SetStatus("'" + cur + "' has been exported.", Main.StatusType.Message);

                Manager.OpenDirectory(@WorkDirectory());
            }
        }