Exemplo n.º 1
0
        public GuiScreenMenu() : base(0, 0, EditorWindow.Instance.ClientSize.Width, EditorWindow.Instance.ClientSize.Height)
        {
            if (File.Exists(Path.Combine(EditorWindow.Instance.LauncherDir, "background_menu.png")))
            {
                bgImg = true;
                using (Bitmap img = new Bitmap(Path.Combine(EditorWindow.Instance.LauncherDir, "background_menu.png")))
                {
                    _textureId = TextureManager.GetOrRegister("menubg", img, true);
                }
            }

            try
            {
                SecureWebClient wc = new SecureWebClient();
                ChangelogText = wc.DownloadString("https://raw.githubusercontent.com/haawwkeye/Sound-Space-Quantum-Editor/master/changelog");
                Changelog     = new GuiLabel(0, 0, ChangelogText, "main", 16);

                ScrollBar = new GuiSlider(0, 0, 20, 720)
                {
                    MaxValue = ChangelogText.Split('\n').Length,
                    Value    = ChangelogText.Split('\n').Length,
                };
            } catch {
                Changelog = new GuiLabel(0, 0, "Failed to load changelog", "main", 16);
            }

            Buttons.Add(_createMapButton);
            Buttons.Add(_loadMapButton);
            Buttons.Add(_importButton);
            Buttons.Add(_SettingsButton);
            Buttons.Add(ScrollBar);

            CHANGELOGlabel.Color        = Color.FromArgb(255, 255, 255);
            CHANGELOGlabelOutline.Color = Color.FromArgb(0, 0, 0);
            ssLabel.Color        = Color.FromArgb(255, 255, 255);
            ssLabelOutline.Color = Color.FromArgb(0, 0, 0);
            qeLabel.Color        = Color.FromArgb(255, 255, 255);
            qeLabelOutline.Color = Color.FromArgb(0, 0, 0);

            Changelog.Color = Color.FromArgb(255, 255, 255);

            OnResize(EditorWindow.Instance.ClientSize);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            // End-To-End encryption example
            Encryption.StartSession();

            SecureWebClient.SendEncrypteValues("https://yourdomain.ltd", new NameValueCollection
            {
                ["example"]  = Encryption.Encrypt("data"),
                ["example2"] = Encryption.Encrypt("data")
            }, "CUSTOM_USERAGENT");

            Encryption.EndSession();

            // Grab server-sided variables
            string variable = Variables.GrabVariable("https://yourdomain.ltd", "ExampleName", "YourPassword", "CUSTOM_USERAGENT");

            // Some of the improved WebClient methods
            SecureWebClient.DownloadString("https://thirdpartydomain.ltd" /*, "useragent"*/);
            SecureWebClient.DownloadData("https://thirdpartydomain.ltd" /*, "useragent"*/);
            SecureWebClient.UploadValues("https://thirdpartydomain.ltd", new NameValueCollection {
                ["example"] = "data"
            } /*, "useragent"*/);
        }
        protected override void OnButtonClicked(int id)
        {
            switch (id)
            {
            case 0:
                EditorWindow.Instance.OpenGuiScreen(new GuiScreenCreate());
                break;

            case 1:
                using (var dialog = new OpenFileDialog
                {
                    Title = "Select Map File",
                    Filter = "Text Documents (*.txt)|*.txt"
                })
                {
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        EditorWindow.Instance.LoadFile(dialog.FileName);
                    }
                }
                break;

            case 2:
                /*if (importmapclicked == false)
                 * {
                 *      importmapclicked = true;
                 *      _pasteDataButton.Visible = true;
                 *      _githubButton.Visible = true;
                 * }
                 * else
                 * {
                 *      importmapclicked = false;
                 *      _pasteDataButton.Visible = false;
                 *      _githubButton.Visible = false;
                 * }*/

                try
                {
                    var             clipboard = Clipboard.GetText();
                    SecureWebClient wc        = new SecureWebClient();
                    if (clipboard.Contains("gist") || clipboard.Contains("github"))
                    {
                        try
                        {
                            var reply = wc.DownloadString(clipboard);
                            EditorWindow.Instance.LoadMap(reply, false);
                        }
                        catch
                        {
                            MessageBox.Show("Error while loading map data from link.\nIs it valid?");
                        }
                    }
                    else
                    {
                        try
                        {
                            EditorWindow.Instance.LoadMap(clipboard, false);
                        }
                        catch
                        {
                            MessageBox.Show("Error while loading map data.\nIs it valid?");
                        }
                    }
                }
                catch
                {
                }

                break;

            case 3:
                EditorWindow.Instance.LoadFile(Properties.Settings.Default.LastFile);
                break;

                /*
                 * case 4:
                 *      try
                 *      {
                 *              var clipboard = Clipboard.GetText();
                 *              EditorWindow.Instance.LoadMap(clipboard, false);
                 *      }
                 *      catch
                 *      {
                 *              return;
                 *      }
                 *      break;
                 * case 5:
                 *      try
                 *      {
                 *              var gclipboard = Clipboard.GetText();
                 *              WebClient wc = new WebClient();
                 *              var reply = wc.DownloadString(gclipboard);
                 *              EditorWindow.Instance.LoadMap(reply, false);
                 *      }
                 *      catch
                 *      {
                 *              MessageBox.Show("Couldn't read map data from the link. Do you have it copied?");
                 *      }
                 *      break;
                 */
            }
            base.OnButtonClicked(id);
        }
Exemplo n.º 4
0
        protected override void OnButtonClicked(int id)
        {
            switch (id)
            {
            case 0:
                EditorWindow.Instance.OpenGuiScreen(new GuiScreenCreate());
                break;

            case 1:
                using (var dialog = new OpenFileDialog
                {
                    Title = "Select Map File",
                    Filter = "Text Documents (*.txt)|*.txt"
                })
                {
                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        EditorWindow.Instance.LoadFile(dialog.FileName);
                    }
                }
                break;

            case 2:
                try
                {
                    var             clipboard = Clipboard.GetText();
                    SecureWebClient wc        = new SecureWebClient();
                    if (clipboard.Contains("githubusercontent") || clipboard.Contains("raw") || clipboard.Contains("gist"))
                    {
                        try
                        {
                            var reply = wc.DownloadString(clipboard);
                            EditorWindow.Instance.LoadMap(reply, false);
                        }
                        catch
                        {
                            MessageBox.Show("Error while loading map data from link.\nIs it valid?");
                        }
                    }
                    else
                    {
                        try
                        {
                            EditorWindow.Instance.LoadMap(clipboard, false);
                        }
                        catch
                        {
                            MessageBox.Show("Error while loading map data.\nIs it valid?");
                        }
                    }
                }
                catch
                {
                }

                break;

            case 3:
                EditorWindow.Instance.OpenGuiScreen(new GuiScreenSettings());
                break;
            }
            base.OnButtonClicked(id);
        }