Exemple #1
0
 private void SetGraphicsDeviceWidthHeight(ResolutionConfig resolution)
 {
     GraphicsDeviceManager.PreferredBackBufferWidth       = resolution.Width;
     GraphicsDeviceManager.PreferredBackBufferHeight      = resolution.Height;
     GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Settings.Game.IsVSyncEnabled;
     GraphicsDeviceManager.ApplyChanges();
 }
Exemple #2
0
        private void ToGamepadConfiguration()
        {
            if (selectedResolution == null)
            {
                return;
            }

            var leftAnalog = selectedResolution.LeftAnalog with
            {
                AspectRatioX = double.Parse(txtAspectX.Text),
                AspectRatioY = double.Parse(txtAspectY.Text),
                Radius       = double.Parse(txtRadius.Text),
                FixedRadius  = chkFixed.Checked,
                KeepPressed  = chkPressed.Checked,
                InnerRadius  = double.Parse(txtInnerRadius.Text),
                DeadZone     = float.Parse(txtDeadzone.Text),
                SpringMode   = chkSpringMode.Checked,
                OffsetX      = int.Parse(txtOffsetX.Text),
                OffsetY      = int.Parse(txtOffsetY.Text),
                Button       = selectedResolution.LeftAnalog.Button == null ? null : selectedResolution.LeftAnalog.Button with
                {
                    Button     = selectedResolution.LeftAnalog.Button?.Button ?? "LeftAnalog",
                    Key        = cbMouseKeyboard.SelectedValue.ToString(),
                    MouseClick = (ARPGGamepadCore.MouseClick)cbMouseButton.SelectedValue,
                    Modifier   = (ARPGGamepadCore.Modifiers)cbMouseModifier.SelectedValue,
                }
            };
            var rightAnalog = selectedResolution.RightAnalog with
            {
                AspectRatioX = double.Parse(txtRAspectX.Text),
                AspectRatioY = double.Parse(txtRAspectY.Text),
                Radius       = double.Parse(txtRRadius.Text),
                FixedRadius  = chkRFixed.Checked,
                KeepPressed  = chkRPressed.Checked,
                InnerRadius  = double.Parse(txtRInnerRadius.Text),
                DeadZone     = float.Parse(txtRDeadzone.Text),
                OffsetX      = int.Parse(txtROffsetX.Text),
                OffsetY      = int.Parse(txtROffsetY.Text),
                Button       = selectedResolution.RightAnalog.Button == null ? null : selectedResolution.RightAnalog.Button with
                {
                    Button     = selectedResolution.RightAnalog.Button?.Button ?? "RightAnalog",
                    Key        = cbMouseKeyboard.SelectedValue.ToString(),
                    MouseClick = (ARPGGamepadCore.MouseClick)cbMouseButton.SelectedValue,
                    Modifier   = (ARPGGamepadCore.Modifiers)cbMouseModifier.SelectedValue
                }
            };

            selectedResolution = selectedResolution with
            {
                LeftAnalog  = leftAnalog,
                RightAnalog = rightAnalog
            };
            var index = profile.Resolutions.FindIndex(x => x.Name == selectedResolution.Name);

            profile.Resolutions[index] = selectedResolution;
            profile.Name = txtName.Text;
        }
Exemple #3
0
        private void selResolution_SelectedIndexChanged(object sender, EventArgs e)
        {
            var resolution = ((KeyValuePair <string, ResolutionConfig>)selResolution.SelectedItem).Value;

            if (resolution != null)
            {
                this.selectedResolution = resolution;
            }
            ToUIConfiguration();
        }
Exemple #4
0
 public static bool IsValidPlayWindowResolution(ResolutionConfig resolution)
 {
     foreach (ResolutionConfig res in PlayWindowResolutionsList)
     {
         if (resolution.Width == res.Width && resolution.Height == res.Height)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #5
0
        private void doMouseMovement(double frameMS)
        {
            Mobile player = (Mobile)WorldModel.Entities.GetPlayerEntity();

            if (player == null)
            {
                return;
            }

            // if the move button is pressed, change facing and move based on mouse cursor direction.
            if (ContinuousMouseMovementCheck)
            {
                ResolutionConfig resolution     = Settings.World.PlayWindowGumpResolution;
                Point            centerScreen   = new Point(resolution.Width / 2, resolution.Height / 2);
                Direction        mouseDirection = DirectionHelper.DirectionFromPoints(centerScreen, MouseOverWorldPosition);

                m_TimeSinceMovementButtonPressed += frameMS;

                if (m_TimeSinceMovementButtonPressed >= c_PauseBeforeMouseMovementMS)
                {
                    // Get the move direction.
                    Direction moveDirection = mouseDirection;

                    // add the running flag if the mouse cursor is far enough away from the center of the screen.
                    float distanceFromCenterOfScreen = Utility.DistanceBetweenTwoPoints(centerScreen, MouseOverWorldPosition);

                    if (distanceFromCenterOfScreen >= 150.0f || Settings.World.AlwaysRun)
                    {
                        moveDirection |= Direction.Running;
                    }

                    player.PlayerMobile_Move(moveDirection);
                }
                else
                {
                    // Get the move direction.
                    Direction facing = mouseDirection;
                    if (player.Facing != facing)
                    {
                        // Tell the player entity to change facing to this direction.
                        player.PlayerMobile_ChangeFacing(facing);
                        // reset the time since the mouse cursor was pressed - allows multiple facing changes.
                        m_TimeSinceMovementButtonPressed = 0d;
                    }
                }
            }
            else
            {
                m_TimeSinceMovementButtonPressed = 0d;
                // Tell the player to stop moving.
                player.PlayerMobile_Move(Direction.Nothing);
            }
        }
    public void loadJSON()
    {
        config = null;
        menu.DirectoryCheck();

        //ファイルがない場合: 初期設定ファイルの生成
        if (!File.Exists(jsonPath))
        {
            config = new ResolutionConfig();
            makeJSON();
        }

        //ファイルの読込を試行
        try
        {
            //ファイルの内容を一括読み出し
            string jsonString = File.ReadAllText(jsonPath, new UTF8Encoding(false));
            //設定クラスをJSONデコードして生成
            config = JsonUtility.FromJson <ResolutionConfig>(jsonString);

            //ファイルのバージョンが古い場合は、デフォルト設定にして警告(nullの可能性も考慮してtry内)
            if (config.jsonVer != jsonVerMaster)
            {
                menu.ShowDialogOKCancel(LanguageManager.config.jsonloaders.OLD_CONFIG_HEAD, "" + jsonPath + LanguageManager.config.jsonloaders.OLD_CONFIG_BODY, 3f, () => {
                    //OK
                    makeJSON();
                }, () => {
                    //キャンセル
                });
                config = new ResolutionConfig();
            }
        }
        catch (System.Exception e)
        {
            //JSONデコードに失敗した場合
            Debug.Log(e.ToString());
            config = null;
        }

        //デコード失敗した場合は、デフォルト設定にして警告
        if (config == null)
        {
            config = new ResolutionConfig();
            menu.ShowDialogOKCancel(LanguageManager.config.jsonloaders.CORRUPT_CONFIG_HEAD, "" + jsonPath + LanguageManager.config.jsonloaders.CORRUPT_CONFIG_BODY, 3f, () => {
                //OK
                makeJSON();
            }, () => {
                //キャンセル
            });
        }
    }
Exemple #7
0
        private void OnWindowSizeChanged(object sender, EventArgs e)
        {
            GameWindow       window     = (sender as GameWindow);
            ResolutionConfig resolution = new ResolutionConfig(window.ClientBounds.Width, window.ClientBounds.Height);

            // this only occurs when the world is active. Make sure that we don't reduce the window size
            // smaller than the world gump size.
            if (resolution.Width < Settings.World.PlayWindowGumpResolution.Width)
            {
                resolution.Width = Settings.World.PlayWindowGumpResolution.Width;
            }
            if (resolution.Height < Settings.World.PlayWindowGumpResolution.Height)
            {
                resolution.Height = Settings.World.PlayWindowGumpResolution.Height;
            }
            SetGraphicsDeviceWidthHeight(resolution);
        }
Exemple #8
0
        private void btnPlus_Click(object sender, EventArgs e)
        {
            var newResolutionKey = "";

            try
            {
                if (DialogHelper.InputBox("Add Resolution", "Enter new resolution in format <Width>x<Height>", ref newResolutionKey) == System.Windows.Forms.DialogResult.OK)
                {
                    var resData = newResolutionKey.ToLower().Split('x');
                    var newRes  = new ResolutionConfig(int.Parse(resData[0]), int.Parse(resData[1]));

                    profile.Resolutions.Add(newRes);
                    UpdateResolutionsOnCombo(profile);
                }
            }
            catch (Exception ex)
            {
                txtStatus.Text = "Error, invalid format for resolution or is a duplicate resolution; " + ex.Message;
            }
        }
Exemple #9
0
        private void CheckWindowSize(int minWidth, int minHeight)
        {
            GameWindow       window     = this.Window; // (sender as GameWindow);
            ResolutionConfig resolution = new ResolutionConfig(window.ClientBounds.Width, window.ClientBounds.Height);

            // this only occurs when the world is active. Make sure that we don't reduce the window size
            // smaller than the world gump size.
            if (resolution.Width < minWidth)
            {
                resolution.Width = minWidth;
            }
            if (resolution.Height < minHeight)
            {
                resolution.Height = minHeight;
            }
            if (resolution.Width != window.ClientBounds.Width || resolution.Height != window.ClientBounds.Height)
            {
                SetGraphicsDeviceWidthHeight(resolution);
            }
        }
Exemple #10
0
        public void BuildResolutionsLists()
        {
            if (m_FullScreenResolutionsList != null)
            {
                m_FullScreenResolutionsList.Clear();
            }
            else
            {
                m_FullScreenResolutionsList = new List <ResolutionConfig>();
            }

            foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            {
                ResolutionConfig res = new ResolutionConfig(mode.Width, mode.Height);
                if (!m_FullScreenResolutionsList.Contains(res))
                {
                    m_FullScreenResolutionsList.Add(res);
                }
            }

            if (m_PlayWindowResolutionsList != null)
            {
                m_PlayWindowResolutionsList.Clear();
            }
            else
            {
                m_PlayWindowResolutionsList = new List <ResolutionConfig>();
            }

            foreach (ResolutionConfig res in m_FullScreenResolutionsList)
            {
                if (!m_PlayWindowResolutionsList.Contains(res) && res.Width < 2048 && res.Height < 2048)
                {
                    m_PlayWindowResolutionsList.Add(res);
                }
            }
        }
Exemple #11
0
        public static void SetScreenSize(GameWindow window)
        {
            Microsoft.Xna.Framework.Rectangle game;
            System.Drawing.Rectangle          screen;

            if (window != null)
            {
                game   = window.ClientBounds;
                screen = Screen.GetWorkingArea(new System.Drawing.Rectangle(game.X, game.Y, game.Width, game.Height));
            }
            else
            {
                screen = Screen.GetWorkingArea(new System.Drawing.Point(0, 0));
            }

            foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            {
                if (mode.Format != SurfaceFormat.Color)
                {
                    continue;
                }
                ResolutionConfig res = new ResolutionConfig(mode.Width, mode.Height);
                if (!FullScreenResolutionsList.Contains(res))
                {
                    FullScreenResolutionsList.Add(res);
                }
            }

            foreach (ResolutionConfig res in FullScreenResolutionsList)
            {
                if (!PlayWindowResolutionsList.Contains(res) && res.Width <= screen.Width && res.Height <= screen.Height)
                {
                    PlayWindowResolutionsList.Add(res);
                }
            }
        }
Exemple #12
0
        protected override void BeforeDraw(SpriteBatchUI spritebatch, Point position)
        {
            Mobile player = WorldModel.Entities.GetPlayerEntity();

            // Hue the cursor if not in warmode and in trammel.
            if (WorldModel.IsInWorld && !player.Flags.IsWarMode && (m_World.MapIndex == 1))
            {
                CursorHue = 2414;
            }
            else
            {
                CursorHue = 0;
            }

            if (IsHoldingItem)
            {
                ItemSpriteArtIndex = HeldItem.DisplayItemID;

                if (m_ItemSprite != null)
                {
                    m_ItemSprite.Hue    = HeldItem.Hue;
                    m_ItemSprite.Offset = m_HeldItemOffset;
                    if (HeldItem.Amount > 1 && HeldItem.ItemData.IsGeneric && HeldItem.DisplayItemID == HeldItem.ItemID)
                    {
                        int offset = HeldItem.ItemData.Unknown4;
                        m_ItemSprite.Draw(spritebatch, new Point(position.X - 5, position.Y - 5));
                    }
                    m_ItemSprite.Draw(spritebatch, position);
                }

                // set up to draw standard cursor sprite above item art.
                base.BeforeDraw(spritebatch, position);
            }
            else if (IsTargeting)
            {
                int artworkIndex = 8310;

                if (WorldModel.IsInWorld && player.Flags.IsWarMode)
                {
                    // Over the interface or not in world. Display a default cursor.
                    artworkIndex -= 23;
                }

                CursorSpriteArtIndex = artworkIndex;
                CursorOffset         = new Point(13, 13);
                // sourceRect = new Rectangle(1, 1, 46, 34);

                /*if (m_targetingMulti != -1)
                 * {
                 *  // UNIMPLEMENTED !!! Draw a transparent multi
                 * }*/
            }
            else if ((m_World.Input.ContinuousMouseMovementCheck || m_World.Input.IsMouseOverWorld) && !m_UserInterface.IsModalControlOpen)
            {
                ResolutionConfig resolution     = Settings.World.PlayWindowGumpResolution;
                Direction        mouseDirection = DirectionHelper.DirectionFromPoints(new Point(resolution.Width / 2, resolution.Height / 2), m_World.Input.MouseOverWorldPosition);

                int artIndex = 0;

                switch (mouseDirection)
                {
                case Direction.North:
                    CursorOffset = new Point(29, 1);
                    artIndex     = 8299;
                    break;

                case Direction.Right:
                    CursorOffset = new Point(41, 9);
                    artIndex     = 8300;
                    break;

                case Direction.East:
                    CursorOffset = new Point(36, 24);
                    artIndex     = 8301; break;

                case Direction.Down:
                    CursorOffset = new Point(14, 33);
                    artIndex     = 8302;
                    break;

                case Direction.South:
                    CursorOffset = new Point(2, 26);
                    artIndex     = 8303;
                    break;

                case Direction.Left:
                    CursorOffset = new Point(2, 10);
                    artIndex     = 8304;
                    break;

                case Direction.West:
                    CursorOffset = new Point(1, 1);
                    artIndex     = 8305;
                    break;

                case Direction.Up:
                    CursorOffset = new Point(4, 2);
                    artIndex     = 8298;
                    break;

                default:
                    CursorOffset = new Point(2, 10);
                    artIndex     = 8309;
                    break;
                }

                if (WorldModel.IsInWorld && player.Flags.IsWarMode)
                {
                    // Over the interface or not in world. Display a default cursor.
                    artIndex -= 23;
                }

                CursorSpriteArtIndex = artIndex;
            }
            else
            {
                // cursor is over UI or there is a modal message box open. Set up to draw standard cursor sprite.
                base.BeforeDraw(spritebatch, position);
            }
        }