Ejemplo n.º 1
0
 public void UpdateCurrentJoystick()
 {
     if (FrameWorkStaticHelper.GetNumberOfAvailableJoysticks() > 0)
     {
         currentJoystick = joysticks[FrameWorkStaticHelper.GetCurrentJoystickIndex()];
     }
 }
Ejemplo n.º 2
0
        protected override List <object> GetAvailableOptions()
        {
            List <object> availableModes = new List <object>();

            FrameWorkStaticHelper.GetNumberOfAvailableJoysticks();
            for (int i = 0; i < joysticks.Count; i++)
            {
                availableModes.Add(LanguageResources.GetString(LanguageKey.Joystick) + " " + (i + 1) + " - ID=" + joysticks[i].Vendor() + "_" + joysticks[i].ID);
            }
            return(availableModes);
        }
Ejemplo n.º 3
0
        protected override void LayoutOptions(List <object> availableOptions, Window window, Callback cc)
        {
            uint oldFontSize = fontSize;

            SetFontSize((uint)(fontSize * 0.8f));
            mGui.mFontSize = fontSize;

            base.LayoutOptions(availableOptions, window, cc);
            SetFontSize(oldFontSize);
            mGui.mFontSize = oldFontSize;

            if (FrameWorkStaticHelper.GetNumberOfAvailableJoysticks() == 0)
            {
                float imgSize = fontSize * 10;
                window.createStaticImage(new Vector4((window.w - imgSize) * 0.5f, (window.h - imgSize) * 0.5f, imgSize, imgSize), "nojoysticks.png");
                return;
            }
            float h = GetTextVSpacing();
            //totalOptions
            float y = joystickChangerHelper.AddControlsInfoToGui(guiWindow, mGui, (int)h, (int)(GetTextVSpacing() * 0.8f * (availableOptions.Count + 3)), 0, viewport.ActualWidth * 0.75f, 0.75f * GetTextVSpacing(), (uint)(GetFontSize() * 0.75f));


            y += (int)(h * 1);

            const string txt     = "Reset";
            var          txtSize = ViewHelper.MeasureText(mGui.mFont, txt, fontSize);

            var pos         = new Vector4(h, y, txtSize, h);
            var resetButton = guiWindow.createButton(pos, "bgui.button", txt, new Callback(this), resetButtonID);

            joystickChangerHelper_onChangeButtonAdded(resetButton);

            y += (int)(h * 0.5f);

            joystickWindowsInitialY = y;


            CreateJoystickPointerControls(window);
            selectButton(currentButton);

            // mGui.mFontSize = oldFontSize;

            // joystick info
            // var txt = "Current joystick reading: "+ FrameWorkStaticHelper.GetJoystickVector(joysticks, false);
            // guiWindow.createStaticText(pos, txt);
        }
Ejemplo n.º 4
0
        protected override void ProcessOptionSelection(ButtonHolder holder)
        {
            string jid;

            if (holder.Option.id.Equals(resetButtonID))
            {
                KeyMap.Instance.BackToDefaults(joysticks);
                KeyMap.Instance.Value = KeyMap.Instance.Value;
                //FrameWorkStaticHelper.SetCurrentJoystickIndex(0);

                for (int i = 0; i < FrameWorkStaticHelper.GetNumberOfAvailableJoysticks(); i++)
                {
                    jid = joysticks[i].Vendor() + "_" + joysticks[i].ID;

                    if (jid.Equals(KeyMap.Instance.CurrentJoystick))
                    {
                        FrameWorkStaticHelper.SetCurrentJoystickIndex(i);
                        break;
                    }
                }
                joystickChangerHelper.UpdateCurrentJoystick();
                this.RecreateGUI();
                return;
            }

            bool restart = false;

            string[] opts = holder.Value.Split(new string[] { "ID=" }, System.StringSplitOptions.RemoveEmptyEntries);

            jid = opts[1];

            KeyMap.Instance.CurrentJoystick = jid;
            KeyMap.Instance.Value           = KeyMap.Instance.Value;

            for (int i = 0; i < joysticks.Count; i++)
            {
                if (jid.Equals(joysticks[i].Vendor() + "_" + joysticks[i].ID))
                {
                    FrameWorkStaticHelper.SetCurrentJoystickIndex(i);
                    joystickChangerHelper.UpdateCurrentJoystick();

                    this.RecreateGUI();
                    break;
                }
            }
        }
Ejemplo n.º 5
0
        protected override bool IsOptionSelected(int index, ButtonHolder holder)
        {
            string option = holder.Value;

            if (holder.Option.id.Equals(resetButtonID))
            {
                return(false);
            }

            if (FrameWorkStaticHelper.GetNumberOfAvailableJoysticks() == 1 && index == 0)
            {
                return(true);
            }

            string[] opts = option.Split(new string[] { "ID=" }, System.StringSplitOptions.RemoveEmptyEntries);
            string   jid  = opts[1];

            return(jid.Equals(KeyMap.Instance.CurrentJoystick));
        }