changeset 972:c8a0f6d89c70

Some inqury on selecting Knight bug.
author Nomad
date Wed, 08 May 2013 19:54:19 +0200
parents 35f2e900618e
children ec7568e13b24
files Actor.cpp GUIWindow.cpp GUIWindow.h Items.cpp Mouse.cpp UICharacter.cpp UIPartyCreation.cpp mm7_1.cpp mm7_2.cpp mm7_4.cpp mm7_5.cpp mm7_data.h
diffstat 12 files changed, 137 insertions(+), 151 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Wed May 08 17:02:37 2013 +0600
+++ b/Actor.cpp	Wed May 08 19:54:19 2013 +0200
@@ -246,7 +246,7 @@
              || pNPCInfo->uProfession > 38 && (pNPCInfo->uProfession <= 43 || pNPCInfo->uProfession == 52)) )
         {
           pDialogueWindow->CreateButton(480, 250, 140, LOBYTE(pFontArrus->uFontHeight) - 3, 1, 0, UIMSG_SelectNPCDialogueOption, 9, 0, "", 0);
-          pDialogueWindow->_41D08F(4, 1, 0, 1);
+          pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 1);
         }
       }
     }
--- a/GUIWindow.cpp	Wed May 08 17:02:37 2013 +0600
+++ b/GUIWindow.cpp	Wed May 08 19:54:19 2013 +0200
@@ -276,7 +276,7 @@
 }
 
 //----- (0041D08F) --------------------------------------------------------
-void GUIWindow::_41D08F(int a2, int a3, int a4, int a5)
+void GUIWindow::_41D08F_set_keyboard_control_group(int a2, int a3, int a4, int a5)
 {
   if ( a2 )
   {
@@ -285,7 +285,7 @@
     this->field_34 = a4;
     this->pCurrentPosActiveItem = a5;
     this->pStartingPosActiveItem = a5;
-    this->field_44 = 1;
+    this->receives_keyboard_input = true;
   }
   else
   {
@@ -294,7 +294,7 @@
     this->field_34 = a4;
     this->pCurrentPosActiveItem = 0;
     this->pStartingPosActiveItem = 0;
-    this->field_44 = 0;
+    this->receives_keyboard_input = false;
   }
 }
 
@@ -962,7 +962,7 @@
 
   CreateButton(0, 0, 0, 0, 1, 0, UIMSG_33, 0, '\t', "", 0);
   if ( a2 )
-    _41D08F(a2, 0, 0, 0);
+    _41D08F_set_keyboard_control_group(a2, 0, 0, 0);
 
   if (pPlayer->pActiveSkills[PLAYER_SKILL_FIRE])   CreateButton(399,  10, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 0, 0, aSpellSchoolNames[0], 0);
   if (pPlayer->pActiveSkills[PLAYER_SKILL_AIR])    CreateButton(399,  46, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 1, 0, aSpellSchoolNames[1], 0);
@@ -1755,7 +1755,7 @@
   pWindow->uFrameY = uY;
   pWindow->uFrameHeight = uHeight;
   pWindow->eWindowType = eWindowType;
-  pWindow->field_44 = 0;
+  pWindow->receives_keyboard_input = false;
   ++uNumVisibleWindows;
   pWindow->numVisibleWindows = uNumVisibleWindows;
   pVisibleWindowsIdxs[uNumVisibleWindows] = uNextFreeWindowID + 1;
@@ -1857,7 +1857,7 @@
                 num_menu_buttons = 2;
               }
             }
-            pWindow->_41D08F(num_menu_buttons, 1, 0, 1);
+            pWindow->_41D08F_set_keyboard_control_group(num_menu_buttons, 1, 0, 1);
           }
           break;
 
--- a/GUIWindow.h	Wed May 08 17:02:37 2013 +0600
+++ b/GUIWindow.h	Wed May 08 19:54:19 2013 +0200
@@ -330,7 +330,7 @@
   void DrawMessageBox(int arg0);
   GUIButton *GetControl(unsigned int uID);
   void Release();
-  void _41D08F(int a2, int a3, int a4, int a5);
+  void _41D08F_set_keyboard_control_group(int a2, int a3, int a4, int a5);
   void DrawQuickCharRecord();
   char _41D73D_draw_buff_tooltip();
 
@@ -356,7 +356,7 @@
   int pStartingPosActiveItem;
   int numVisibleWindows;
   int field_40;
-  int field_44;
+  int receives_keyboard_input;
   char *Hint;
   GUIButton *pControlsHead;
   GUIButton *pControlsTail;
--- a/Items.cpp	Wed May 08 17:02:37 2013 +0600
+++ b/Items.cpp	Wed May 08 19:54:19 2013 +0200
@@ -2314,7 +2314,7 @@
 		++dword_F8B1DC;
 		CreateButtonInColumn(i+1, v29);
 		}
-	pDialogueWindow->_41D08F(i, 1, 0, 2);
+	pDialogueWindow->_41D08F_set_keyboard_control_group(i, 1, 0, 2);
 	dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
 	}
 
--- a/Mouse.cpp	Wed May 08 17:02:37 2013 +0600
+++ b/Mouse.cpp	Wed May 08 19:54:19 2013 +0200
@@ -1331,7 +1331,7 @@
       {
         pGame->PickMouse(512.0, *v4, *(int *)(v2 + 16), 0, &a3, &a4);
         if ( GetCurrentMenuID() == 6 )
-          sub_41CD4F(0x29u);
+          UI_OnKeyDown(VK_SELECT);
         UI_OnMouseLeftClick((int *)(v2 + 12));
       }
       else
--- a/UICharacter.cpp	Wed May 08 17:02:37 2013 +0600
+++ b/UICharacter.cpp	Wed May 08 19:54:19 2013 +0200
@@ -2589,7 +2589,7 @@
                     }
                     while ( v17 <= &pMiscSkills[11] );
                     if ( a2 )
-                        pGUIWindow_CurrentMenu->_41D08F(a2, 1, 0, a5);
+                        pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(a2, 1, 0, a5);
     }
 
 //----- (00418511) --------------------------------------------------------
--- a/UIPartyCreation.cpp	Wed May 08 17:02:37 2013 +0600
+++ b/UIPartyCreation.cpp	Wed May 08 19:54:19 2013 +0200
@@ -132,7 +132,7 @@
         return result;
     }
 //----- (00495B39) --------------------------------------------------------
-void __cdecl PlayerCreationUI_Draw()
+void PlayerCreationUI_Draw()
 {
   int pTextCenter; // eax@3
   IconFrame *pFrame; // eax@3
@@ -185,7 +185,18 @@
   pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos, 2, pTexture_MAKESKY);
   pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos - 640, 2, pTexture_MAKESKY);
   pRenderer->DrawTextureTransparent(0, 0, pTexture_MAKETOP);
+
   uPlayerCreationUI_SelectedCharacter = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) / 7;
+  switch (uPlayerCreationUI_SelectedCharacter)
+  {
+    case 0: pX = 12;  break;
+    case 1: pX = 171; break;
+    case 2: pX = 329; break;
+    case 3: pX = 488; break;
+    default:
+      assert(false && "Invalid selected character");
+  }
+
   pTextCenter = pFontCChar->AlignText_Center(640, pGlobalTXT_LocalizationStrings[51]);
   pGUIWindow_CurrentMenu->DrawText(pFontCChar, pTextCenter + 1, 0, 0, pGlobalTXT_LocalizationStrings[51], 0, 0, 0);
   pRenderer->DrawTextureTransparent(17, 35, pPlayerPortraits[pParty->pPlayers[0].uFace]);
@@ -193,31 +204,14 @@
   pRenderer->DrawTextureTransparent(335, 35, pPlayerPortraits[pParty->pPlayers[2].uFace]);
   pRenderer->DrawTextureTransparent(494, 35, pPlayerPortraits[pParty->pPlayers[3].uFace]);
   pFrame = pIconsFrameTable->GetFrame(uIconID_CharacterFrame, pEventTimer->uStartTime);
-  switch ( uPlayerCreationUI_SelectedCharacter )
-  {
-    case 0:
-      pX = 12;
-      break;
-    case 1:
-      pX = 171;
-      break;
-    case 2:
-      pX = 329;
-      break;
-    case 3:
-      pX = 488;
-      break;
-    default:
-      assert(false);//if click "Knight" crash
-      //pX = v123;
-      break;
-  }
+
 
   pRenderer->DrawTextureTransparent(pX, 29, &pIcons_LOD->pTextures[pFrame->uTextureID]);
   uPosActiveItem = pGUIWindow_CurrentMenu->GetControl(pGUIWindow_CurrentMenu->pCurrentPosActiveItem);
   uPlayerCreationUI_ArrowAnim = 19 - (GetTickCount() % 500) / 25;
   pRenderer->DrawTextureTransparent(uPosActiveItem->uZ - 4, uPosActiveItem->uY, pTextures_arrowl[uPlayerCreationUI_ArrowAnim]);
   pRenderer->DrawTextureTransparent(uPosActiveItem->uX - 12, uPosActiveItem->uY, pTextures_arrowr[uPlayerCreationUI_ArrowAnim]);
+
   memset(pText, 0, 200);
   strcpy(pText, pGlobalTXT_LocalizationStrings[205]);// "Skills"
   uNumLet = strlen(pText) - 1;
@@ -605,10 +599,10 @@
   }
   while ( (signed int)uXb < 640 );
 
-  pGUIWindow_CurrentMenu->CreateButton(  5, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 0, 0x31u, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(163, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 1, 0x32u, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(321, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 2, 0x33u, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(479, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 3, 0x34u, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(  5, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 0, '1', "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(163, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 1, '2', "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(321, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 2, '3', "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(479, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 3, '4', "", 0);
 
   uXc = 23;
   uControlParamc = 2;
@@ -625,7 +619,8 @@
     uXc += 158;
   }
   while ( (signed int)uControlParamc < 30 );
-  pGUIWindow_CurrentMenu->_41D08F(28, 0, 7, 40);
+  pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(28, 0, 7, 40);
+
   pGUIWindow_CurrentMenu->CreateButton(323, 417,          65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0,    0, "", 0);
   pGUIWindow_CurrentMenu->CreateButton(323, v0 + 417,     65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0xC,  0, "", 0);
   pGUIWindow_CurrentMenu->CreateButton(323, 2 * v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x14, 0, "", 0);
@@ -635,6 +630,7 @@
   pGUIWindow_CurrentMenu->CreateButton(453, 417,          65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x10, 0, "", 0);
   pGUIWindow_CurrentMenu->CreateButton(453, v0 + 417,     65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 8,    0, "", 0);
   pGUIWindow_CurrentMenu->CreateButton(453, 2 * v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 4,    0, "", 0);
+
   uControlParamd = 0;
   do
   {
@@ -646,6 +642,7 @@
     ++uControlParamd;
   }
   while ( uControlParamd < 9 );
+
   pPlayerCreationUI_BtnOK    = pGUIWindow_CurrentMenu->CreateButton(580, 431, 51, 39, 1, 0, UIMSG_PlayerCreationClickOK, 0, 0xD, "", pIcons_LOD->GetTexture(uTextureID_BUTTMAKE), 0);
   pPlayerCreationUI_BtnReset = pGUIWindow_CurrentMenu->CreateButton(527, 431, 51, 39, 1, 0, UIMSG_PlayerCreationClickReset, 0, 0x43, "", pIcons_LOD->GetTexture(uTextureID_BUTTMAKE2), 0);
   pPlayerCreationUI_BtnMinus = pGUIWindow_CurrentMenu->CreateButton(523, 393, 20, 35, 1, 0, UIMSG_PlayerCreationClickMinus, 0, 0x2D, "", pTexture_buttminu, 0);
--- a/mm7_1.cpp	Wed May 08 17:02:37 2013 +0600
+++ b/mm7_1.cpp	Wed May 08 19:54:19 2013 +0200
@@ -99,17 +99,17 @@
         j->uY = dword_506988;
         j->uZ = dword_506984;
         j->uW = dword_506980;
-        pGUIWindow_CurrentMenu->_41D08F(1, 0, 0, 0);
+        pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(1, 0, 0, 0);
       }
     }
   }
 }
 
 //----- (0041CD4F) --------------------------------------------------------
-bool __thiscall sub_41CD4F(unsigned int _this)
+bool UI_OnKeyDown(unsigned int vkKey)
 {
-  unsigned int v1; // edi@1
-  unsigned int v2; // eax@2
+  //unsigned int v1; // edi@1
+  //unsigned int v2; // eax@2
   int v3; // esi@3
   int v4; // ecx@10
   GUIButton *v5; // eax@11
@@ -132,25 +132,26 @@
   int v23; // edx@59
   int v24; // ecx@60
   int v25; // esi@63
-  unsigned int v26; // [sp+Ch] [bp-14h]@1
-  int v27; // [sp+10h] [bp-10h]@1
+  //unsigned int v26; // [sp+Ch] [bp-14h]@1
+  //int v27; // [sp+10h] [bp-10h]@1
   int v28; // [sp+14h] [bp-Ch]@10
   int v29; // [sp+14h] [bp-Ch]@36
   unsigned int uClickX; // [sp+18h] [bp-8h]@10
   unsigned int uClickY; // [sp+1Ch] [bp-4h]@10
 
-  v1 = 0;
-  v26 = _this;
-  v27 = uNumVisibleWindows;
+  //v1 = 0;
+  //v27 = uNumVisibleWindows;
   if ( uNumVisibleWindows < 0 )
     return 0;
-  v2 = pMessageQueue_50CBD0->uNumMessages;
-  while ( 1 )
+  //v2 = pMessageQueue_50CBD0->uNumMessages;
+  for (int i = uNumVisibleWindows; i >= 0; --i)
+  //while ( 1 )
   {
-    v3 = pVisibleWindowsIdxs[v27] - 1;
-    if ( pWindowList[v3].field_44 != v1 )
-	{
-		switch(v26)
+    v3 = pVisibleWindowsIdxs[i] - 1;
+    if (!pWindowList[v3].receives_keyboard_input)
+      continue;
+
+		switch (vkKey)
 		{
 			case VK_LEFT:
 				{
@@ -161,17 +162,17 @@
 				  pWindowList[v3].pCurrentPosActiveItem -= v12;
 				  if ( v8 )
 				  {
-					pAudioPlayer->PlaySound(SOUND_Button, v1, v1, -1, v1, v1, v1, v1);
-					v2 = pMessageQueue_50CBD0->uNumMessages;
+					pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+					//v2 = pMessageQueue_50CBD0->uNumMessages;
 				  }
 				}
-				if ( pWindowList[v3].field_30 != v1 )
+				if ( pWindowList[v3].field_30 != 0 )
 				{
 					break;
 				}
 				v9 = pWindowList[v3].pControlsHead;
 				v13 = pWindowList[v3].pCurrentPosActiveItem;
-				if ( v13 > (signed int)v1 )
+				if ( v13 > 0)
 				{
 				  do
 				  {
@@ -181,7 +182,7 @@
 				  while ( v13 );
 				}
 
-                pMessageQueue_50CBD0->AddMessage(v9->msg, v9->msg_param, v1);
+                pMessageQueue_50CBD0->AddMessage(v9->msg, v9->msg_param, 0);
 				break;
 				}
 			case VK_RIGHT:
@@ -193,17 +194,17 @@
 					pWindowList[v3].pCurrentPosActiveItem = v7;
 					if ( v8 )
 					{
-						pAudioPlayer->PlaySound(SOUND_Button, v1, v1, -1, v1, v1, v1, v1);
-						v2 = pMessageQueue_50CBD0->uNumMessages;
+						pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
+						//v2 = pMessageQueue_50CBD0->uNumMessages;
 					}
 				}
-				if ( pWindowList[v3].field_30 != v1 )
+				if ( pWindowList[v3].field_30 != 0 )
 				{
 					break;
 				}
 				v9 = pWindowList[v3].pControlsHead;
 				v10 = pWindowList[v3].pCurrentPosActiveItem;
-				if ( v10 > (signed int)v1 )
+				if ( v10 > 0)
 				{
 					do
 					{
@@ -212,7 +213,7 @@
 					}
 					while ( v10 );
 				}
-				pMessageQueue_50CBD0->AddMessage(v9->msg, v9->msg_param, v1);
+				pMessageQueue_50CBD0->AddMessage(v9->msg, v9->msg_param, 0);
 				break;				
 				}
 			case VK_DOWN:
@@ -223,11 +224,11 @@
 					pWindowList[v3].pCurrentPosActiveItem = v17;
 				else
 					pWindowList[v3].pCurrentPosActiveItem = v18 + 1;
-				if ( pWindowList[v3].field_30 != v1 )
+				if ( pWindowList[v3].field_30 != 0 )
 					return 1;
 				v19 = pWindowList[v3].pControlsHead;
 				v20 = pWindowList[v3].pCurrentPosActiveItem;
-				if ( v20 > (signed int)v1 )
+				if ( v20 > 0)
 				{
 					do
 					{
@@ -236,7 +237,7 @@
 					}
 					while ( v20 );
 				}
-				pMessageQueue_50CBD0->AddMessage(v19->msg, v19->msg_param, v1);
+				pMessageQueue_50CBD0->AddMessage(v19->msg, v19->msg_param, 0);
 				return 1;
 				}
 			case VK_SELECT:
@@ -267,10 +268,10 @@
 						++v4;
 						if ( v4 >= v28 )
 						{
-							v1 = 0;
-							v2 = pMessageQueue_50CBD0->uNumMessages;
-							--v27;
-							if ( v27 < 0 )
+							//v1 = 0;
+							//v2 = pMessageQueue_50CBD0->uNumMessages;
+							--i;
+							if ( i < 0 )
   								return 0;
 							continue;
 						}
@@ -278,7 +279,7 @@
 					pWindowList[v3].pCurrentPosActiveItem = v4;
 					return 1;
 				}
-				v2 = pMessageQueue_50CBD0->uNumMessages;
+				//v2 = pMessageQueue_50CBD0->uNumMessages;
 				break;
 				}
 			case VK_UP:
@@ -289,13 +290,13 @@
 					v24 = pWindowList[v3].pNumPresenceButton + v23 - 1;
 				else
 					v24 = v22 - 1;
-				v8 = pWindowList[v3].field_30 == v1;
+				v8 = pWindowList[v3].field_30 == 0;
 				pWindowList[v3].pCurrentPosActiveItem = v24;
 				if ( !v8 )
 					return 1;
 				v19 = pWindowList[v3].pControlsHead;
 				v25 = pWindowList[v3].pCurrentPosActiveItem;
-				if ( v25 > (signed int)v1 )
+				if ( v25 > 0)
 				{
 					do
 					{
@@ -305,12 +306,12 @@
 					while ( v25 );
 				}
 
-				pMessageQueue_50CBD0->AddMessage(v19->msg, v19->msg_param, v1);
+				pMessageQueue_50CBD0->AddMessage(v19->msg, v19->msg_param, 0);
 				return 1;
 				}
 			case VK_NEXT:
 				{
-				if ( pWindowList[v3].field_30 != v1 )
+				if ( pWindowList[v3].field_30 != 0 )
 				{
 					pMouse->GetClickPos(&uClickX, &uClickY);
 					v4 = pWindowList[v3].pStartingPosActiveItem;
@@ -341,15 +342,15 @@
 							++v4;
 							if ( v4 >= v29 )
 							{
-								v1 = 0;
-								v2 = pMessageQueue_50CBD0->uNumMessages;
+								//v1 = 0;
+								//v2 = pMessageQueue_50CBD0->uNumMessages;
 								break;
 							}
 						}
 					}
 					else
 					{
-						v2 = pMessageQueue_50CBD0->uNumMessages;
+						//v2 = pMessageQueue_50CBD0->uNumMessages;
 					}
 				}
 				break;
@@ -359,11 +360,7 @@
 				break;
 				}
 			
-		}
-	}
-    --v27;
-    if ( v27 < 0 )
-      return 0;
+        }
   }
 
 }
--- a/mm7_2.cpp	Wed May 08 17:02:37 2013 +0600
+++ b/mm7_2.cpp	Wed May 08 19:54:19 2013 +0200
@@ -293,7 +293,7 @@
                  pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
   pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, UIMSG_0, 0x53u, 0, "", 0);
-  pDialogueWindow->_41D08F(1, 1, 0, 2);
+  pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2);
   dialog_menu_id = HOUSE_DIALOGUE_OTHER;
   v0 = (int)((char *)window_SpeakInHouse->ptr_1C - 102);
   if ( (signed __int64)__PAIR__(pParty->field_3C.field_0[2 * v0 + 1], pParty->field_3C.field_0[2 * v0]) < (signed __int64)pParty->uTimePlayed )
@@ -438,7 +438,7 @@
     pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x56u, 0, "", 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x57u, 0, "", 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xFAu, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x58u, 0, "", 0);
-    pDialogueWindow->_41D08F(4, 1, 0, 1);
+    pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 1);
   }
 }
 // F8B1B4: using guessed type int dword_F8B1B4;
@@ -6792,7 +6792,7 @@
   int v25; // eax@171
   int v26; // eax@172
   char v27; // al@174
-  bool v28; // ebx@201
+  //bool v28; // ebx@201
   char v29; // dl@209
   char v30; // cl@210
   bool v31; // ebx@211
@@ -7014,7 +7014,6 @@
       case WM_SIZING:
         return 1;
       case WM_LBUTTONDOWN:
-        v28 = 0;
         if ( pArcomageGame->bGameInProgress )
         {
           if (pAsyncMouse)
@@ -7023,13 +7022,8 @@
           ArcomageGame::OnMouseClick(0, 1);
           return DefWindowProcA(hWnd, Msg, wParam, lParam);
         }
-        if ( pVideoPlayer->pVideoFrame.pPixels )
-          pVideoPlayer->bStopBeforeSchedule = 1;
-        if ( !pAsyncMouse )
-          pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
-        if (GetCurrentMenuID() != MENU_CREATEPARTY)
-          goto LABEL_230;
-        goto LABEL_229;
+        goto __handle_mouse_click;
+
       case WM_RBUTTONDOWN:
         v31 = 0;
         if ( !pArcomageGame->bGameInProgress )
@@ -7097,8 +7091,8 @@
         v30 = 1;
         ArcomageGame::OnMouseClick(v30, v29);
         return DefWindowProcA(hWnd, Msg, wParam, lParam);
+
       case WM_LBUTTONDBLCLK:
-        v28 = 0;
         if ( pArcomageGame->bGameInProgress )
         {
           if (pAsyncMouse)
@@ -7107,34 +7101,31 @@
           pArcomageGame->stru1.field_0 = 7;
           return DefWindowProcA(hWnd, Msg, wParam, lParam);
         }
+        
+__handle_mouse_click:
         if ( pVideoPlayer->pVideoFrame.pPixels )
           pVideoPlayer->bStopBeforeSchedule = 1;
+
         if ( !pAsyncMouse )
           pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
-        if ( uCurrentMenuID != 6 )
-          goto LABEL_230;
-        if ( !pAsyncMouse )
-        {
-LABEL_229:
-          sub_41CD4F(0x29u);
-LABEL_230:
-          if ( pAsyncMouse == (void *)v28 )
-            pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
-        }
-        if ( pGame != (Game *)v28 )
-        {
-          if ( pAsyncMouse != (void *)v28 )
-            //goto _def_wnd_proc;
-            return DefWindowProcA(hWnd, Msg, wParam, lParam);
-          pGame->PickMouse(512.0, (unsigned __int16)lParam, lParam >> 16, v28, &vis_sprite_filter_3, &vis_door_filter);
-        }
-        if ( pAsyncMouse == (void *)v28 )
-        {
+
+        if (GetCurrentMenuID() != MENU_CREATEPARTY)
+          pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
+        else
+        {
+          UI_OnKeyDown(VK_SELECT);
+          pMouse->SetMouseClick((unsigned __int16)lParam, lParam >> 16);
+        }
+
+        if (!pAsyncMouse)
+        {
+          if (pGame)
+            pGame->PickMouse(512.0, (unsigned __int16)lParam, lParam >> 16, false, &vis_sprite_filter_3, &vis_door_filter);
+
           UI_OnMouseLeftClick(0);
-          return DefWindowProcA(hWnd, Msg, wParam, lParam);
-        }
-        //goto _def_wnd_proc;
+        }
         return DefWindowProcA(hWnd, Msg, wParam, lParam);
+
       case WM_RBUTTONDBLCLK:
         v31 = 0;
         if ( !pArcomageGame->bGameInProgress )
@@ -7292,7 +7283,7 @@
           return 0;
       }
       if ( !viewparams->field_4C )
-        sub_41CD4F(wParam);
+        UI_OnKeyDown(wParam);
       return 0;
     }
     pArcomageGame->stru1.field_0 = 1;
--- a/mm7_4.cpp	Wed May 08 17:02:37 2013 +0600
+++ b/mm7_4.cpp	Wed May 08 19:54:19 2013 +0200
@@ -7590,7 +7590,7 @@
       CreateButtonInColumn(2, 0x68u);
     }
   }
-  pDialogueWindow->_41D08F(num_buttons, 1, 0, 2);
+  pDialogueWindow->_41D08F_set_keyboard_control_group(num_buttons, 1, 0, 2);
   dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
 }
 // F8B1E0: using guessed type int dword_F8B1E0;
@@ -7605,13 +7605,13 @@
       CreateButtonInColumn(0, 3u);
       CreateButtonInColumn(1, 4u);
       CreateButtonInColumn(2, 5u);
-       pDialogueWindow->_41D08F(3, 1, 0, 2);
+       pDialogueWindow->_41D08F_set_keyboard_control_group(3, 1, 0, 2);
     }
     if ( a1 == 4 )
     {
       CreateButtonInColumn(0, 3u);
       CreateButtonInColumn(1, 4u);
-      pDialogueWindow->_41D08F(2, 1, 0, 2);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(2, 1, 0, 2);
     }
   }
   dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
@@ -7724,7 +7724,7 @@
             v10 = 1;
             v9 = v4;
 LABEL_42:
-            pDialogueWindow->_41D08F(v9, v10, v11, v17);
+            pDialogueWindow->_41D08F_set_keyboard_control_group(v9, v10, v11, v17);
             goto LABEL_43;
           }
           v4 = 2;
@@ -7835,7 +7835,7 @@
     v1 = 1;
   }
   pDialogueWindow->CreateButton(480, 30 * v1 + 160, 140, 30, 1, 0, UIMSG_SelectNPCDialogueOption, 76, 0, pGlobalTXT_LocalizationStrings[406], 0);//Нанять
-  pDialogueWindow->_41D08F(v1 + 1, 1, 0, 1);
+  pDialogueWindow->_41D08F_set_keyboard_control_group(v1 + 1, 1, 0, 1);
 }
 
 //----- (004B3EF0) --------------------------------------------------------
@@ -7849,7 +7849,7 @@
   pBtn_ExitCancel = pDialogueWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape,                    0, 0, pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uExitCancelTextureId), 0); // Cancel
                     pDialogueWindow->CreateButton(  0,   0,   0,  0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
                     pDialogueWindow->CreateButton(480, 160, 140, 30, 1, 0, UIMSG_ClickNPCTopic,             0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0);
-  pDialogueWindow->_41D08F(1, 1, 0, 2);
+  pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2);
   dialog_menu_id = HOUSE_DIALOGUE_OTHER;
 }
 // F8B19C: using guessed type int dword_F8B19C;
@@ -7873,7 +7873,7 @@
   if ( contract_approved )
     v2 = pGlobalTXT_LocalizationStrings[535];
   pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x4Fu, 0, v2, 0);
-  pDialogueWindow->_41D08F(1, 1, 0, 2);
+  pDialogueWindow->_41D08F_set_keyboard_control_group(1, 1, 0, 2);
   dialog_menu_id = HOUSE_DIALOGUE_OTHER;
 }
 // F8B19C: using guessed type int dword_F8B19C;
@@ -7902,7 +7902,7 @@
   }
   pDialogueWindow->CreateButton(  0x1E0u,  30 * v0 + 160,  0x8Cu,  0x1Eu,  1,  0,  UIMSG_ClickNPCTopic,  0x4Cu,  0,
     pGlobalTXT_LocalizationStrings[406],  0); //"Hire"
-  pDialogueWindow->_41D08F(v0 + 1, 1, 0, 2);
+  pDialogueWindow->_41D08F_set_keyboard_control_group(v0 + 1, 1, 0, 2);
   dialog_menu_id = HOUSE_DIALOGUE_OTHER;
 }
 
@@ -8015,7 +8015,7 @@
             pDialogueWindow->CreateButton( 0x1E0u, 30 * num_menu_buttons++ + 160,  0x8Cu,  0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x18u, 0, "",  0);
         }
       }
-      pDialogueWindow->_41D08F(num_menu_buttons, 1, 0, 2);
+      pDialogueWindow->_41D08F_set_keyboard_control_group(num_menu_buttons, 1, 0, 2);
       dword_F8B1E0 = pDialogueWindow->pNumPresenceButton;
     }
     dialog_menu_id = HOUSE_DIALOGUE_MAIN;
--- a/mm7_5.cpp	Wed May 08 17:02:37 2013 +0600
+++ b/mm7_5.cpp	Wed May 08 19:54:19 2013 +0200
@@ -1501,7 +1501,7 @@
               pBtn_Resume = pGUIWindow_CurrentMenu->CreateButton(241, 263, 214, 40, v0, 0, UIMSG_GameMenu_ReturnToGame, 0, 0x52u,
                              pGlobalTXT_LocalizationStrings[619],// "Return to Game"
                              pIcons_LOD->GetTexture(uTextureID_Resume1), 0);
-              pGUIWindow_CurrentMenu->_41D08F(6, v0, 0, 0);
+              pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(6, v0, 0, 0);
               viewparams->field_48 = v0;
               stru_506E40.Release();
               uNumSeconds = (unsigned int)MakeScreenshot(155, 117);
@@ -10211,7 +10211,8 @@
   ItemGen ItemGen2; // [sp+E4h] [bp-24h]@129
 
   if (GetCurrentMenuID() != MENU_CREATEPARTY)
-    sub_41CD4F(34);
+    UI_OnKeyDown(VK_NEXT);
+
   for ( i = 1; i <= uNumVisibleWindows; ++i )
   {
     pWindow = &pWindowList[pVisibleWindowsIdxs[i] - 1];
@@ -11564,10 +11565,10 @@
         pButton->uY = dword_506988;
         pButton->uZ = dword_506984;
         pButton->uW = dword_506980;
-        pGUIWindow_CurrentMenu->_41D08F(1, 0, 0, 0);
-      }
-    }
-  }
-}
-
-
+        pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(1, 0, 0, 0);
+      }
+    }
+  }
+}
+
+
--- a/mm7_data.h	Wed May 08 17:02:37 2013 +0600
+++ b/mm7_data.h	Wed May 08 19:54:19 2013 +0200
@@ -1616,7 +1616,7 @@
 void __cdecl GameUI_Footer_2();
 void __thiscall sub_41C0B8_set_status_string(const char *pStr); // idb
 void __cdecl GameUI_Footer();
-bool __thiscall sub_41CD4F(unsigned int _this);
+bool UI_OnKeyDown(unsigned int vkKey);
 char __fastcall sub_41D20D_buff_remaining_time_string(int ecx0, struct GUIWindow *edx0, __int64 a3, struct GUIFont *a2);
 void GameUI_DrawItemInfo(struct ItemGen* inspect_item); // idb
 void MonsterPopup_Draw(unsigned int uActorID, struct GUIWindow *edx0);
@@ -1956,33 +1956,33 @@
 int _48B561_mess_with_scaling_along_z(/*int a1, */float a2);
 signed int __cdecl PlayerCreation_Chose4Skills();
 signed int __cdecl PlayerCreation_ComputeAttributeBonus();
-void __cdecl LoadPlayerPortraintsAndVoices();
+void LoadPlayerPortraintsAndVoices();
 int __fastcall ReloadPlayerPortraits(int, int); // weak
-void __cdecl sub_491E3A();
-void __cdecl DrawHiredNPCs();
+void sub_491E3A();
+void DrawHiredNPCs();
 void __thiscall GameUI_DrawPortraits(unsigned int _this);
 signed int __thiscall CycleCharacter(unsigned int _this);
 void __fastcall Rest(unsigned int uHoursToSleep);
-int __cdecl _493938_regenerate();
+int _493938_regenerate();
 void sub_493F79(struct stru351_summoned_item *_this, __int64 a2);
-void __cdecl _494035_timed_effects__water_walking_damage__etc();
+void _494035_timed_effects__water_walking_damage__etc();
 unsigned int __fastcall _494820_training_time(unsigned int a1);
 char *__fastcall sub_495366(unsigned __int8 a1, unsigned __int8 a2);
 char * GetReputationString(signed int a1);
 char *BuilDialogueString(char *lpsz, unsigned __int8 uPlayerID, struct ItemGen *a3, char *a4, int a5, __int64 *a6);
-void __cdecl PlayerCreationUI_Draw();
-void __cdecl PlayerCreationUI_Initialize();
-void __cdecl DeleteCCharFont();
-bool __cdecl PlayerCreationUI_Loop();
-void __cdecl loc_49B785(); // idb
+void PlayerCreationUI_Draw();
+void PlayerCreationUI_Initialize();
+void DeleteCCharFont();
+bool PlayerCreationUI_Loop();
+void loc_49B785(); // idb
 unsigned int __fastcall GetMaxMipLevels(unsigned int uDim);
-bool __cdecl CheckTextureStages();
-bool __cdecl AreRenderSurfacesOk();
+bool CheckTextureStages();
+bool AreRenderSurfacesOk();
 unsigned int BlendColors(unsigned int c1, unsigned int c2); // weak
-void __cdecl DoRenderBillboards_D3D();
+void DoRenderBillboards_D3D();
 int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int z, int a4, unsigned int lightColor);
-void __cdecl Present_ColorKey();
-void __cdecl Present_NoColorKey();
+void Present_ColorKey();
+void Present_NoColorKey();
 int __thiscall sub_4A7063(unsigned int uDiffuse, float a2); // idb
 struct SoundHeader *__fastcall FindSound_BinSearch(unsigned int uStart, unsigned int uEnd, const char *pName);
 struct SoundData *LoadSound(const char *pSoundName, struct SoundData *pOutBuff, unsigned int uID);