Example #1
0
        protected override Task LoadContent()
#endif
        {
            base.LoadContent();

            MyraEnvironment.Game = this;

            UpdateTitle();

            _desktop = new Desktop();

            // Load UI
            var ui = new Notepad();

            var newItem = ui.menuItemNew;

            newItem.Selected += NewItemOnDown;

            // File/Open
            var openItem = ui.menuItemOpen;

            openItem.Selected += OpenItemOnDown;

            // File/Save
            var saveItem = ui.menuItemSave;

            saveItem.Selected += SaveItemOnDown;

            // File/Save As...
            var saveAsItem = ui.menuItemSaveAs;

            saveAsItem.Selected += SaveAsItemOnDown;

            ui.menuItemDebugOptions.Selected += DebugOptionsOnDown;

            // File/Quit
            var quitItem = ui.menuItemQuit;

            quitItem.Selected += QuitItemOnDown;

            var aboutItem = ui.menuItemAbout;

            aboutItem.Selected += AboutItemOnDown;

            _textField = ui.textArea;

            var resources = new ResourceAssetResolver(typeof(NotepadGame).Assembly, "Myra.Samples.Notepad.");

            _textField.Text = resources.ReadAsString("hobbits.txt");
            _desktop.FocusedKeyboardWidget = _textField;

            _textField.TextChanged += TextFieldOnTextChanged;

            _desktop.Widgets.Add(ui);

#if XENKO
            return(base.LoadContent());
#endif
        }
Example #2
0
        protected override void LoadContent()
        {
            base.LoadContent();

            MyraEnvironment.Game = this;

            UpdateTitle();

            _host = new Desktop();

            // Load UI
            var ui = new Notepad();

            var newItem = ui.menuItemNew;

            newItem.Selected += NewItemOnDown;

            // File/Open
            var openItem = ui.menuItemOpen;

            openItem.Selected += OpenItemOnDown;

            // File/Save
            var saveItem = ui.menuItemSave;

            saveItem.Selected += SaveItemOnDown;

            // File/Save As...
            var saveAsItem = ui.menuItemSaveAs;

            saveAsItem.Selected += SaveAsItemOnDown;

            // File/Quit
            var quitItem = ui.menuItemQuit;

            quitItem.Selected += QuitItemOnDown;

            var aboutItem = ui.menuItemAbout;

            aboutItem.Selected += AboutItemOnDown;

            _textField = ui.textArea;

            _textField.Text =
                "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum!";

            _textField.TextChanged += TextFieldOnTextChanged;

            _host.Widgets.Add(ui);
        }
Example #3
0
        protected override void LoadContent()
        {
            base.LoadContent();

            MyraEnvironment.Game = this;

            UpdateTitle();

            // Load UI
            var ui = new Notepad();

            var newItem = ui.menuItemNew;

            newItem.Selected += NewItemOnDown;

            // File/Open
            var openItem = ui.menuItemOpen;

            openItem.Selected += OpenItemOnDown;

            // File/Save
            var saveItem = ui.menuItemSave;

            saveItem.Selected += SaveItemOnDown;

            // File/Save As...
            var saveAsItem = ui.menuItemSaveAs;

            saveAsItem.Selected += SaveAsItemOnDown;

            ui.menuItemDebugOptions.Selected += DebugOptionsOnDown;

            // File/Quit
            var quitItem = ui.menuItemQuit;

            quitItem.Selected += QuitItemOnDown;

            var aboutItem = ui.menuItemAbout;

            aboutItem.Selected += AboutItemOnDown;

            _textField = ui.textArea;

            _textField.Text = typeof(NotepadGame).Assembly.ReadResourceAsString("hobbits.txt");
            Desktop.FocusedKeyboardWidget = _textField;

            _textField.TextChanged += TextBoxOnTextChanged;

            Desktop.Widgets.Add(ui);

            Desktop.KeyDown += (s, a) =>
            {
                if (Desktop.HasModalWidget || ui._mainMenu.IsOpen)
                {
                    return;
                }

                if (Desktop.DownKeys.Contains(Keys.LeftControl) || Desktop.DownKeys.Contains(Keys.RightControl))
                {
                    if (Desktop.DownKeys.Contains(Keys.N))
                    {
                        NewItemOnDown(this, EventArgs.Empty);
                    }
                    else if (Desktop.DownKeys.Contains(Keys.O))
                    {
                        OpenItemOnDown(this, EventArgs.Empty);
                    }
                    else if (Desktop.DownKeys.Contains(Keys.S))
                    {
                        SaveItemOnDown(this, EventArgs.Empty);
                    }
                    else if (Desktop.DownKeys.Contains(Keys.Q))
                    {
                        Exit();
                    }
                }
            };
        }