| 267 | } |
| 268 | |
| 269 | void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press) |
| 270 | { |
| 271 | #if defined MENU_DEBUG |
| 272 | logger->LogMessage("[SM_MENU] ClientPressedKey() (client %d) (key_press %d)", client, key_press); |
| 273 | #endif |
| 274 | CBaseMenuPlayer *player = GetMenuPlayer(client); |
| 275 | |
| 276 | /* First question: Are we in a menu? */ |
| 277 | if (!player->bInMenu) |
| 278 | { |
| 279 | return; |
| 280 | } |
| 281 | |
| 282 | bool cancel = false; |
| 283 | unsigned int item = 0; |
| 284 | MenuCancelReason reason = MenuCancel_Exit; |
| 285 | MenuEndReason end_reason = MenuEnd_Selected; |
| 286 | menu_states_t &states = player->states; |
| 287 | |
| 288 | /* Save variables */ |
| 289 | IMenuHandler *mh = states.mh; |
| 290 | IBaseMenu *menu = states.menu; |
| 291 | |
| 292 | unsigned int item_on_page = states.item_on_page; |
| 293 | |
| 294 | assert(mh != NULL); |
| 295 | |
| 296 | if (menu == NULL) |
| 297 | { |
| 298 | item = key_press; |
| 299 | } else if (key_press < 1 || key_press > GetMaxPageItems()) { |
| 300 | cancel = true; |
| 301 | } else { |
| 302 | ItemSelection type = states.slots[key_press].type; |
| 303 | |
| 304 | /* Check if we should play a sound about the type */ |
| 305 | if (g_Menus.MenuSoundsEnabled() && |
| 306 | (!menu || (menu->GetMenuOptionFlags() & MENUFLAG_NO_SOUND) != MENUFLAG_NO_SOUND)) |
| 307 | { |
| 308 | CellRecipientFilter filter; |
| 309 | cell_t clients[1]; |
| 310 | |
| 311 | clients[0] = client; |
| 312 | filter.Initialize(clients, 1); |
| 313 | |
| 314 | std::string *sound = g_Menus.GetMenuSound(type); |
| 315 | |
| 316 | if (nullptr != sound && !sound->empty()) |
| 317 | { |
| 318 | edict_t *pEdict = PEntityOfEntIndex(client); |
| 319 | if (pEdict) |
| 320 | { |
| 321 | ICollideable *pCollideable = pEdict->GetCollideable(); |
| 322 | |
| 323 | if (pCollideable) |
| 324 | { |
| 325 | const Vector & pos = pCollideable->GetCollisionOrigin(); |
| 326 | enginesound->EmitSound(filter, |
no test coverage detected