diff mm7_1.cpp @ 972:c8a0f6d89c70

Some inqury on selecting Knight bug.
author Nomad
date Wed, 08 May 2013 19:54:19 +0200
parents 5a12082c803d
children 8b46828a64f4
line wrap: on
line diff
--- 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;
+        }
   }
 
 }