World of Might and Magic  0.2.0
Open reimplementation of Might and Magic 6 7 8 game engine
Файл Mouse.h

См. исходные тексты.

Классы

class  Mouse
 

Функции

bool UI_OnVkKeyDown (unsigned int vkKey)
 

Функции

◆ UI_OnVkKeyDown()

bool UI_OnVkKeyDown ( unsigned int  vkKey)

См. определение в файле Mouse.cpp строка 336

336  {
337  for (GUIWindow *win : lWindowList) {
338  if (!win->receives_keyboard_input) {
339  continue;
340  }
341 
342  switch (vkKey) {
343  case VK_LEFT: {
344  int v12 = win->field_34;
345  if (win->pCurrentPosActiveItem - win->pStartingPosActiveItem - v12 >= 0) {
346  win->pCurrentPosActiveItem -= v12;
349  // v2 = pMessageQueue_50CBD0->uNumMessages;
350  }
351  }
352  if (win->field_30 != 0) {
353  break;
354  }
355  GUIButton *pButton = win->GetControl(win->pCurrentPosActiveItem);
356  pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0);
357  break;
358  }
359  case VK_RIGHT: {
360  int v7 = win->pCurrentPosActiveItem + win->field_34;
361  if (v7 <
362  win->pNumPresenceButton + win->pStartingPosActiveItem) {
363  win->pCurrentPosActiveItem = v7;
366  0, -1, 0, 0);
367  // v2 = pMessageQueue_50CBD0->uNumMessages;
368  }
369  }
370  if (win->field_30 != 0) {
371  break;
372  }
373  GUIButton *pButton =
374  win->GetControl(win->pCurrentPosActiveItem);
375  pMessageQueue_50CBD0->AddGUIMessage(pButton->msg,
376  pButton->msg_param, 0);
377  break;
378  }
379  case VK_DOWN: {
380  int v17 = win->pStartingPosActiveItem;
381  int v18 = win->pCurrentPosActiveItem;
382  if (v18 >= win->pNumPresenceButton + v17 - 1)
383  win->pCurrentPosActiveItem = v17;
384  else
385  win->pCurrentPosActiveItem = v18 + 1;
386  if (win->field_30 != 0) return true;
387  GUIButton *pButton =
388  win->GetControl(win->pCurrentPosActiveItem);
389  pMessageQueue_50CBD0->AddGUIMessage(pButton->msg,
390  pButton->msg_param, 0);
391  return true;
392  }
393  case VK_SELECT: {
394  unsigned int uClickX;
395  unsigned int uClickY;
396  EngineIoc::ResolveMouse()->GetClickPos(&uClickX, &uClickY);
397  int v4 = win->pStartingPosActiveItem;
398  int v28 = v4 + win->pNumPresenceButton;
399  if (v4 < v4 + win->pNumPresenceButton) {
400  while (true) {
401  GUIButton *pButton = win->GetControl(v4);
402  if (uClickX >= pButton->uX // test for StatsTab in
403  // PlayerCreation Window
404  && uClickX <= pButton->uZ &&
405  uClickY >= pButton->uY && uClickY <= pButton->uW)
406  break;
407  ++v4;
408  if (v4 >= v28) {
409  // v1 = 0;
410  // v2 = pMessageQueue_50CBD0->uNumMessages;
411  // --i;
412  // if ( i < 0 )
413  return false;
414  // continue;
415  }
416  }
417  win->pCurrentPosActiveItem = v4;
418  return true;
419  }
420  // v2 = pMessageQueue_50CBD0->uNumMessages;
421  break;
422  }
423  case VK_UP: {
424  int v22 = win->pCurrentPosActiveItem;
425  int v23 = win->pStartingPosActiveItem;
426  if (v22 <= v23)
427  win->pCurrentPosActiveItem =
428  win->pNumPresenceButton + v23 - 1;
429  else
430  win->pCurrentPosActiveItem = v22 - 1;
431  if (win->field_30 != 0) return true;
432  GUIButton *pButton =
433  win->GetControl(win->pCurrentPosActiveItem);
434  pMessageQueue_50CBD0->AddGUIMessage(pButton->msg,
435  pButton->msg_param, 0);
436  return true;
437  }
438  case VK_NEXT: {
439  if (win->field_30 != 0) { // crashed at skill draw
440  unsigned int uClickX;
441  unsigned int uClickY;
442  EngineIoc::ResolveMouse()->GetClickPos(&uClickX, &uClickY);
443  int v29 = win->pStartingPosActiveItem +
444  win->pNumPresenceButton; // num buttons more than
445  // buttons
446  for (int v4 = win->pStartingPosActiveItem; v4 < v29; ++v4) {
447  GUIButton *pButton = win->GetControl(v4);
448  if (!pButton) continue;
449  if (uClickX >= pButton->uX && uClickX <= pButton->uZ &&
450  uClickY >= pButton->uY && uClickY <= pButton->uW) {
451  win->pCurrentPosActiveItem = v4;
452  return true;
453  }
454  }
455  }
456  break;
457  }
458  default:
459  break;
460  }
461  }
462 
463  return 0;
464 }

Перекрестные ссылки current_screen_type, Mouse::GetClickPos(), lWindowList, GUIButton::msg, GUIButton::msg_param, pAudioPlayer, AudioPlayer::PlaySound(), pMessageQueue_50CBD0, Engine_::IocContainer::ResolveMouse(), SCREEN_PARTY_CREATION, SOUND_SelectingANewCharacter, GUIButton::uX и GUIButton::uY.

Используется в GUI_UpdateWindows(), Application::GameWindowHandler::OnMouseLeftClick() и Application::GameWindowHandler::OnVkDown().

+ Граф вызовов:
+ Граф вызова функции:
GUIWindow
Definition: GUIWindow.h:433
AudioPlayer::PlaySound
void PlaySound(SoundID eSoundID, int pid, unsigned int uNumRepeats, int x, int y, int a7)
Definition: AudioPlayer.cpp:195
GUIButton
Definition: GUIButton.h:11
current_screen_type
enum CURRENT_SCREEN current_screen_type
Definition: GUIWindow.cpp:83
CURRENT_SCREEN::SCREEN_PARTY_CREATION
@ SCREEN_PARTY_CREATION
SOUND_SelectingANewCharacter
@ SOUND_SelectingANewCharacter
Definition: AudioPlayer.h:34
Engine_::IocContainer::ResolveMouse
static Mouse * ResolveMouse()
Definition: IocContainer.cpp:88
GUIButton::msg
UIMessageType msg
Definition: GUIButton.h:29
Mouse::GetClickPos
void GetClickPos(unsigned int *pX, unsigned int *pY)
Definition: Mouse.cpp:20
GUIButton::uX
unsigned int uX
Definition: GUIButton.h:21
GUIButton::msg_param
unsigned int msg_param
Definition: GUIButton.h:30
GUIButton::uY
unsigned int uY
Definition: GUIButton.h:22
lWindowList
std::list< GUIWindow * > lWindowList
Definition: GUIWindow.cpp:79
pAudioPlayer
AudioPlayer * pAudioPlayer
Definition: AudioPlayer.cpp:20
pMessageQueue_50CBD0
struct GUIMessageQueue * pMessageQueue_50CBD0
Definition: GUIWindow.cpp:86