コード例 #1
0
        protected override void LoadContent()
        {
            _spriteBatch         = new SpriteBatch(GraphicsDevice);
            MyraEnvironment.Game = this;

            if (!Settings.LoadSettings() || !Load.LoadFixedContent(Content))
            {
                Exit();
                return;
            }
            _gridEditorBounds = new Rectangle(LATERAL_PANEL_WIDTH, 0, GraphicsDevice.Viewport.Width - LATERAL_PANEL_WIDTH, GraphicsDevice.Viewport.Height);
            _ssetBounds       = new Rectangle(0, PALETTE_SELECTOR_Y, LATERAL_PANEL_WIDTH, GraphicsDevice.Viewport.Height - PALETTE_SELECTOR_Y);
            _inventories      = new CustomInventories(_gridEditorBounds);

            if (Levels.Init() && Load.LoadSpriteContent(GraphicsDevice))
            {
                LoadInterface();
            }
            else
            {
                Task.Factory.StartNew(() =>
                {
                    try
                    {
                        string escapedTiles = Levels.TILES_DIR.Escape();
                        Settings.RunExtractor($"--extract-tiles \"{escapedTiles}\"");
                        reloadAtNextFrame = true;
                    }
                    catch { Exit(); }
                });
            }
            base.LoadContent();
        }
コード例 #2
0
        protected override void Update(GameTime gameTime)
        {
            KeyboardState ks = Keyboard.GetState();

            if ((ks.IsKeyDown(Keys.LeftAlt) || ks.IsKeyDown(Keys.RightAlt)) && ks.IsKeyDown(Keys.F4))
            {
                Exit();
            }

            if (reloadAtNextFrame)
            {
                reloadAtNextFrame = false;
                if (Levels.Init() && Load.LoadSpriteContent(GraphicsDevice))
                {
                    LoadInterface();
                }
                else
                {
                    Exit();
                }
            }
            else
            {
                bool gridControls = mode != Mode.Loading && mode != Mode.Menu && !_lateralMenuDesktop.HasModalWidget &&
                                    _specialItemInterface == null && _paraSpecialItemInterface == null && _timesEditor == null &&
                                    _overworldEditor == null;
                MouseState ms = Mouse.GetState();
                List <Controller.Action> actions = Controller.GetActionsGrid(ks, ms, gameTime);
                foreach (Controller.Action action in actions)
                {
                    if (gridControls)
                    {
                        switch (action)
                        {
                        case Controller.Action.TOGGLE_FULLSCREEN:
                            _graphics.ToggleFullScreen();
                            break;

                        case Controller.Action.SELECT_PREVIOUS:
                            sset.SelectPrevious();
                            break;

                        case Controller.Action.SELECT_NEXT:
                            sset.SelectNext();
                            break;

                        default:
                            editor.PerformAction(gameTime, action);
                            break;
                        }
                    }
                    else if (action == Controller.Action.TOGGLE_FULLSCREEN)
                    {
                        _graphics.ToggleFullScreen();
                    }
                }
                if (gridControls)
                {
                    editor.Update(gameTime, ms, ks);
                    sset.Update(ms);
                }
                else if (_overworldEditor != null)
                {
                    _overworldEditor.Update(ms);
                }
            }

            base.Update(gameTime);
        }