public void UpdateCurrentJoystick() { if (FrameWorkStaticHelper.GetNumberOfAvailableJoysticks() > 0) { currentJoystick = joysticks[FrameWorkStaticHelper.GetCurrentJoystickIndex()]; } }
void CreateJoystickPointerControls(Window window) { joystickWindows.Clear(); joystickPointers.Clear(); joystickPointerAxis.Clear(); for (int z = 0; z < FrameWorkStaticHelper.GetCurrentJoystick(joysticks).JoyStickState.AxisCount; z++) { CreateJoystickPointerControl(window, joystickWindowsInitialY, z); } }
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); }
protected override bool FrameEnded(FrameEvent evt) { bool result = base.FrameEnded(evt); if (this.reloadAllReourcesNextFrame) { reloadAllReourcesNextFrame = false; FrameWorkStaticHelper.ReloadAllReources(this); } return(result); }
protected Vector4 getJoystickPointerRect(Window joystickWindow, int axisNo) { float value = FrameWorkStaticHelper.GetJoystickVector(joysticks, false, axisNo); //vvector.y *= EngineConfig.InverseKeys ? -1.0f : 1.0f; float pointerSize = joystickWindow.h; Vector4 pos = new Vector4(joystickWindow.x, joystickWindow.y, pointerSize, pointerSize); pos.x += joystickWindow.w * 0.5f + (joystickWindow.w * 0.5f - pointerSize * 0.5f) * value - pointerSize * 0.5f; pos.y += joystickWindow.h * 0.5f - pointerSize * 0.5f; return(pos); }
public virtual void Destroy() { FrameWorkStaticHelper.DestroyScenes(this); try { root.Dispose(); root = null; } catch (Exception ex) { // throw; } // this.Dispose(); }
protected new static void Main(string[] args) { try { game = new JoystickOptionsGamesTest(); try{ if (EngineConfig.DebugInfo) { User32.SetWindowPos(User32.PtrToConsole, (IntPtr)0, consolePosition.X, consolePosition.Y, 0, 0, User32.SWP_NOSIZE); } } catch (Exception ex) { } EngineConfig.DisplayingMinimap = false; game.Go(); } catch (SEHException sex) { // Check if it's an Ogre Exception if (OgreException.IsThrown) { FrameWorkStaticHelper.ShowOgreException(sex); } else { throw; } } catch (RootInitializationException) { // i tak będzie reload shouldReload = true; } if (shouldReload) { ReloadGame(); } if (game.afterExit != null) { game.afterExit(); } }
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); }
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; } } }
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)); }
private static void Main(string[] args) { try { KamilTestView app = new KamilTestView(); app.Go(); } catch (SEHException sex) { // Check if it's an Ogre Exception if (OgreException.IsThrown) { FrameWorkStaticHelper.ShowOgreException(sex); } else { throw; } } }
public override int AddControlsInfoToGui(Window guiWindow, GUI mGui, int left, int top, int initialTopSpacing, float width, float textVSpacing, uint fontSize) { var joystick = FrameWorkStaticHelper.GetCurrentJoystick(joysticks); int y = initialTopSpacing; int h = (int)textVSpacing; uint oldFontSize = mGui.mFontSize; float spaceSize = ViewHelper.MeasureText(mGui.mFont, " ", mGui.mFontSize); int leftOrg = left; Button b; // przesuniecie o szerokosc guzika (fontsize) + fontSize left += (int)(fontSize + fontSize); Vector4 pos; Setup(mGui, guiWindow); OverlayContainer c; y += (int)(h * 1); mGui.mFontSize = fontSize; y = AddControlLine(LanguageKey.OK, KeyMap.Instance.JoystickEnter, "", guiWindow, mGui, left, top, width, fontSize, y, h, leftOrg); y += (int)(h * 1); y = AddControlLine(LanguageKey.Back, KeyMap.Instance.JoystickEscape, "", guiWindow, mGui, left, top, width, fontSize, y, h, leftOrg); y += (int)(h * 1); y = AddControlLine(LanguageKey.Engine, KeyMap.Instance.JoystickEngine, " (" + LanguageResources.GetString(LanguageKey.Hold) + ")", guiWindow, mGui, left, top, width, fontSize, y, h, leftOrg); y += (int)(h * 1); y = AddControlLine(LanguageKey.Gear, KeyMap.Instance.JoystickGear, "", guiWindow, mGui, left, top, width, fontSize, y, h, leftOrg); y += (int)(h * 1); y = AddControlLine(LanguageKey.Gun, KeyMap.Instance.JoystickGun, "", guiWindow, mGui, left, top, width, fontSize, y, h, leftOrg); y += (int)(h * 1); y = AddControlLine(LanguageKey.Bombs, KeyMap.Instance.JoystickRocket, "/" + LanguageResources.GetString(LanguageKey.Rockets) + ": ", guiWindow, mGui, left, top, width, fontSize, y, h, leftOrg); y += (int)(h * 1); y = AddControlLine(LanguageKey.Spin, KeyMap.Instance.JoystickSpin, "", guiWindow, mGui, left, top, width, fontSize, y, h, leftOrg); y += (int)(h * 1); y = AddControlLine(LanguageKey.Camera, KeyMap.Instance.JoystickCamera, "", guiWindow, mGui, left, top, width, fontSize, y, h, leftOrg); y += (int)(h * 1); y = AddControlLine(LanguageKey.BulletTimeEffect, KeyMap.Instance.JoystickBulletiTimeEffect, "", guiWindow, mGui, left, top, width, fontSize, y, h, leftOrg); y += (int)(h * 1); y = AddControlLine(LanguageKey.RearmEndMission, KeyMap.Instance.JoystickRocket, "", guiWindow, mGui, left, top, width, fontSize, y, h, leftOrg, true); y += (int)(h * 1); pos = new Vector4(left, top + y, width, h); // horizontal axis string txt; float controlTxtWidth; txt = LanguageResources.GetString(LanguageKey.ChooseHorizontalAxisNo) + ":"; controlTxtWidth = ViewHelper.MeasureText(mGui.mFont, txt, mGui.mFontSize); guiWindow.createStaticText(pos, txt); pos.x += controlTxtWidth + spaceSize; // pos.y -= mGui.mFontSize pos.z = spaceSize * 2; for (int i = 0; i < FrameWorkStaticHelper.GetCurrentJoystick(joysticks).JoyStickState.AxisCount; i++) { horizontalAxesButtonIDs.Add(++lastButtonId); var material = (KeyMap.Instance.JoystickHorizontalAxisNo != i) ? "bgui.button" : "bgui.selected.button"; OnChangeButtonAddedDo(guiWindow.createButton(pos, material, i.ToString(), new Callback(this), lastButtonId)); pos.x += pos.z; } y += (int)(h * 1); pos = new Vector4(left, top + y, width, h); // vertical axis //FrameWorkStaticHelper.GetCurrentJoystick(joysticks).JoyStickState.VectorCount txt = LanguageResources.GetString(LanguageKey.ChooseVerticalAxisNo) + ":"; controlTxtWidth = ViewHelper.MeasureText(mGui.mFont, txt, mGui.mFontSize); guiWindow.createStaticText(pos, txt); pos.x += controlTxtWidth + spaceSize; // pos.y -= mGui.mFontSize pos.z = spaceSize * 2; for (int i = 0; i < FrameWorkStaticHelper.GetCurrentJoystick(joysticks).JoyStickState.AxisCount; i++) { verticalAxesButtonIDs.Add(++lastButtonId); var material = (KeyMap.Instance.JoystickVerticalAxisNo != i) ? "bgui.button" : "bgui.selected.button"; OnChangeButtonAddedDo(guiWindow.createButton(pos, material, i.ToString(), new Callback(this), lastButtonId)); pos.x += pos.z; } y += (int)(h * 1); pos = new Vector4(left, top + y, width, h); // deadzone txt = LanguageResources.GetString(LanguageKey.JoystickDeadzone) + " 0."; controlTxtWidth = ViewHelper.MeasureText(mGui.mFont, txt, mGui.mFontSize); guiWindow.createStaticText(pos, txt); pos.x += controlTxtWidth; pos.z = spaceSize * 2; joystickDeadzoneTi = guiWindow.createTextInput(pos, "bgui.textinput", KeyMap.Instance.JoystickDeadZone.ToString(ci).Substring(2).PadRight(2, '0'), 2); joystickDeadzoneTi.Validator = new NumberValidator(); joystickDeadzoneTi.onValueChanged += joystickDeadzoneTi_onValueChanged; y += (int)(h * 1); pos = new Vector4(left, top + y, width, h); // sensitivity txt = LanguageResources.GetString(LanguageKey.JoystickSensitivity) + " (0.01 - 3.00):"; controlTxtWidth = ViewHelper.MeasureText(mGui.mFont, txt, mGui.mFontSize); guiWindow.createStaticText(pos, txt); pos.x += controlTxtWidth + spaceSize; pos.z = spaceSize * 3; joystickSensitivityTi = guiWindow.createTextInput(pos, "bgui.textinput", KeyMap.Instance.JoystickSensivity.ToString(ci), 4); joystickSensitivityTi.Validator = new NumberAndDotValidator(); joystickSensitivityTi.onValueChanged += joystickSensitivityTi_onValueChanged; return(y + top); }
protected virtual void OnUpdateModel(FrameEvent evt) { mouseDiff = mousePos - lastMousePos; Degree scaleRotate = rotateSpeed * evt.timeSinceLastFrame; inputKeyboard.Capture(); if (inputJoysticks != null) { foreach (JoyStick j in inputJoysticks) { j.Capture(); } } /* * if (inputKeyboard.IsKeyDown(KeyMap.Instance.Left)) * { * camera.Yaw(scaleRotate); * } * * if (inputKeyboard.IsKeyDown(KeyMap.Instance.Right)) * { * camera.Yaw(-scaleRotate); * } * * if (inputKeyboard.IsKeyDown(KeyMap.Instance.Up)) * { * camera.Pitch(scaleRotate); * } * * if (inputKeyboard.IsKeyDown(KeyMap.Instance.Down)) * { * camera.Pitch(-scaleRotate); * }*/ if (inputJoysticks != null) { Vector2 joyVector = FrameWorkStaticHelper.GetJoystickVector(inputJoysticks, true); if (joyVector.x != 0) { camera.Yaw(-joyVector.x * scaleRotate); } if (joyVector.y != 0) { camera.Pitch(joyVector.y * scaleRotate); } } // subtract the time since last frame to delay specific key presses toggleDelay -= evt.timeSinceLastFrame; // toggle rendering mode if (inputKeyboard.IsKeyDown(KeyCode.KC_R) && toggleDelay < 0) { if (camera.PolygonMode == PolygonMode.PM_POINTS) { camera.PolygonMode = PolygonMode.PM_SOLID; } else if (camera.PolygonMode == PolygonMode.PM_SOLID) { camera.PolygonMode = PolygonMode.PM_WIREFRAME; } else { camera.PolygonMode = PolygonMode.PM_POINTS; } Console.WriteLine("Rendering mode changed to '{0}'.", camera.PolygonMode); toggleDelay = 1; } if (inputKeyboard.IsKeyDown(KeyCode.KC_SYSRQ)) { string[] temp = Directory.GetFiles(Environment.CurrentDirectory, "wscreenshot*.jpg"); string fileName = string.Format("wscreenshot{0}.jpg", temp.Length + 1); TakeScreenshot(fileName); // show briefly on the screen mDebugText = string.Format("Wrote screenshot '{0}'.", fileName); // show for 2 seconds debugTextDelay = 2.0f; } if (inputKeyboard.IsKeyDown(KeyCode.KC_B)) { sceneMgr.ShowBoundingBoxes = !sceneMgr.ShowBoundingBoxes; } if (inputKeyboard.IsKeyDown(KeyCode.KC_F)) { // hide all overlays, includes ones besides the debug overlay viewport.OverlaysEnabled = !viewport.OverlaysEnabled; } // turn off debug text when delay ends if (debugTextDelay < 0.0f) { debugTextDelay = 0.0f; mDebugText = ""; } else if (debugTextDelay > 0.0f) { debugTextDelay -= evt.timeSinceLastFrame; } // inputMouse.Capture(); HandleCameraInput(inputKeyboard, null, inputJoysticks, evt, camera, null, null); }
protected override List <object> GetAvailableOptions() { List <String> availableOptions = FrameWorkStaticHelper.GetVideoModes(true, 800, 600); return(FilterPossibleOptions(availableOptions)); }
protected override List <object> GetAvailableOptions() { return(FrameWorkStaticHelper.GetAntialiasingModes()); }