| 1047 | } |
| 1048 | |
| 1049 | void I_updateMenuInput(Input* pinput) |
| 1050 | { |
| 1051 | if (pinput->keyboard.keyReleased(SDL_SCANCODE_S) || |
| 1052 | pinput->gamepad.hatReleased(GPH_DOWN)) |
| 1053 | { |
| 1054 | bool select = false; |
| 1055 | int current_item = game.menu.currentItem; |
| 1056 | while (!select) |
| 1057 | { |
| 1058 | game.menu.currentItem++; |
| 1059 | if (game.menu.currentItem > game.menu.current->items.size() - 1) |
| 1060 | game.menu.currentItem = 0; |
| 1061 | select = game.menu.current->items[game.menu.currentItem].function; |
| 1062 | } |
| 1063 | if (game.menu.currentItem != current_item) |
| 1064 | sound.PlayGUISfx(SOUND_SELECT2); |
| 1065 | } |
| 1066 | if (pinput->keyboard.keyReleased(SDL_SCANCODE_W) || |
| 1067 | pinput->gamepad.hatReleased(GPH_UP)) |
| 1068 | { |
| 1069 | bool select = false; |
| 1070 | int current_item = game.menu.currentItem; |
| 1071 | while (!select) |
| 1072 | { |
| 1073 | game.menu.currentItem--; |
| 1074 | if (game.menu.currentItem < 0) |
| 1075 | game.menu.currentItem = |
| 1076 | static_cast<int>(game.menu.current->items.size() - 1); |
| 1077 | select = |
| 1078 | (bool)game.menu.current->items[game.menu.currentItem].function; |
| 1079 | } |
| 1080 | if (game.menu.currentItem != current_item) |
| 1081 | sound.PlayGUISfx(SOUND_SELECT2); |
| 1082 | } |
| 1083 | if (pinput->keyboard.keyReleased(SDL_SCANCODE_A) || |
| 1084 | pinput->gamepad.hatReleased(GPH_LEFT)) |
| 1085 | { |
| 1086 | if (game.menu.current->items[game.menu.currentItem].isSlider) |
| 1087 | { |
| 1088 | *game.menu.current->items[game.menu.currentItem].floatValue = CLAMP( |
| 1089 | *game.menu.current->items[game.menu.currentItem].floatValue - |
| 1090 | 0.1f, |
| 1091 | 0.0f, 1.0f); |
| 1092 | } |
| 1093 | } |
| 1094 | if (pinput->keyboard.keyReleased(SDL_SCANCODE_D) || |
| 1095 | pinput->gamepad.hatReleased(GPH_RIGHT)) |
| 1096 | { |
| 1097 | if (game.menu.current->items[game.menu.currentItem].isSlider) |
| 1098 | { |
| 1099 | *game.menu.current->items[game.menu.currentItem].floatValue = CLAMP( |
| 1100 | *game.menu.current->items[game.menu.currentItem].floatValue + |
| 1101 | 0.1f, |
| 1102 | 0.0f, 1.0f); |
| 1103 | } |
| 1104 | } |
| 1105 | if (pinput->keyboard.keyReleased(SDL_SCANCODE_RETURN) || |
| 1106 | pinput->gamepad.buttonReleased(GPB_A)) |
no test coverage detected