public int updateControls(Controls controller) { // if this scene is active and shown, then update controls if (Active && Show) { // update button controls for (int i = 1; i < buttonAmount; i++) { btnList[i].UpdateControls(controller.MousePos, controller.bClicked, buttonIndex); } // update gamepad movement and buttonFocus if (controller.bGamePad) updateGamePadSelected(controller); else { buttonIndex = 0; } // return selected button for (int i = 1; i < buttonAmount; i++) { if (btnList[i].bPressed) return i; } } return 0; }
private void updateGamePadSelected(Controls controller) { if (controller.dpad.up) buttonIndex--; if (controller.dpad.down) buttonIndex++; // make sure focus doesn't go out of button range if (buttonIndex > currentAnswerAmount - 1) buttonIndex = 1; if (buttonIndex < 1) buttonIndex = currentAnswerAmount -1; }
// Add Controller support here! /// <summary> /// Updates control logic for buttons. This will return the eventname of the button pressed. TODO: Add controller support here! /// </summary> public string updateHitTest(Point mousepos, bool bClicked, Controls controller) { string eName = ""; // Update Button's hittest logic. btnSleep.UpdateControls(mousepos, bClicked, buttonIndex); btnText.UpdateControls(mousepos, bClicked, buttonIndex); btnTV.UpdateControls(mousepos, bClicked, buttonIndex); btnEat.UpdateControls(mousepos, bClicked, buttonIndex); btnGame.UpdateControls(mousepos, bClicked, buttonIndex); btnClass.UpdateControls(mousepos, bClicked, buttonIndex); btnWrite.UpdateControls(mousepos, bClicked, buttonIndex); btnHomework.UpdateControls(mousepos, bClicked, buttonIndex); btnMusic.UpdateControls(mousepos, bClicked, buttonIndex); btnPorn.UpdateControls(mousepos, bClicked, buttonIndex); btnWalk.UpdateControls(mousepos, bClicked, buttonIndex); btnSave.UpdateControls(mousepos, bClicked, buttonIndex); if (controller.bGamePad) updateGamePadSelected(controller); else { buttonIndex = 0; } // get what button is pushed, and return with eventname if (btnSleep.bPressed) { eName = "sleep"; } if (btnText.bPressed) eName = "text"; if (btnTV.bPressed) eName = "tv"; if (btnEat.bPressed) eName = "eat"; if (btnGame.bPressed) eName = "game"; if (btnClass.bPressed) eName = "class"; if (btnWrite.bPressed) eName = "write"; if (btnHomework.bPressed) eName = "homework"; if (btnMusic.bPressed) eName = "music"; if (btnPorn.bPressed) eName = "p**n"; if (btnWalk.bPressed) eName = "walk"; if (btnSave.bPressed) eName = "savegame"; return eName; }
private void updateGamePadSelected(Controls controller) { if (controller.dpad.up) buttonIndex--; if (controller.dpad.down) buttonIndex++; if (controller.dpad.right) buttonIndex += 6; if (controller.dpad.left) buttonIndex -= 6; // make sure focus doesn't go out of button range if (buttonIndex > 12) buttonIndex = 1; if (buttonIndex < 1) buttonIndex = 12; }
public void UpdateControls(Point mousepos, bool bClicked, Controls controller) { MousePos = mousepos; // send all this to the buttons if (!sceneOptions.bEnabled) { btnStart.UpdateControls(mousepos, bClicked, buttonIndex); btnContinue.UpdateControls(mousepos, bClicked, buttonIndex); btnQuit.UpdateControls(mousepos, bClicked, buttonIndex); btnDemo.UpdateControls(mousepos, bClicked, buttonIndex); btnOptions.UpdateControls(mousepos, bClicked, buttonIndex); if (btnOptions.bPressed) sceneOptions.bEnabled = true; } else { // Update Options window logic sceneOptions.UpdateControls(mousepos, bClicked); } if (controller.bGamePad) updateGamePadSelected(controller); else { buttonIndex = 0; } }