diff Mouse.cpp @ 1296:c423f946dc99

moving files continue
author Ritor1
date Tue, 18 Jun 2013 17:28:11 +0600
parents 0aeac0b9ca30
children 5450af4f57ef
line wrap: on
line diff
--- a/Mouse.cpp	Mon Jun 17 17:34:01 2013 +0600
+++ b/Mouse.cpp	Tue Jun 18 17:28:11 2013 +0600
@@ -13,9 +13,12 @@
 #include "Game.h"
 
 #include "stru11.h"
-
-
-
+#include "TurnEngine.h"
+#include "Viewport.h"
+#include "GUIWindow.h"
+#include "Vis.h"
+#include "Actor.h"
+#include "MM7.h"
 
 
 Mouse *pMouse;
@@ -502,4 +505,158 @@
   uMouseClickX = x;
   uMouseClickY = y;
 }
+//----- (004175C0) --------------------------------------------------------
+void UI_OnMouseLeftClick(int *pXY)
+{
+  int *pXY_; // esi@1
+  signed int y; // eax@7
+  signed int x; // ecx@7
+  unsigned int v4; // eax@11
+  signed int v5; // eax@17
+  signed int v6; // esi@19
+  int v7; // esi@30
+  GUIWindow *v8; // edx@31
+  GUIButton *i; // esi@37
+  signed int v10; // eax@50
+  int v11; // ecx@52
+  unsigned int pX; // [sp+14h] [bp-8h]@7
+  unsigned int pY; // [sp+18h] [bp-4h]@7
 
+  pXY_ = pXY;
+  if ( pCurrentScreen == SCREEN_VIDEO
+    || sub_4637E0_is_there_popup_onscreen() )
+    return;
+  if ( pGUIWindow2 && pGUIWindow2->ptr_1C == (void *)33 )
+  {
+    sub_4452BB();
+    return;
+  }
+  if ( pXY_ )
+  {
+    x = *pXY_;
+    y = pXY_[1];
+    pX = *pXY_;
+    pY = y;
+  }
+  else
+  {
+    pMouse->GetClickPos(&pX, &pY);
+    y = pY;
+    x = pX;
+  }
+  if ( pCurrentScreen != SCREEN_GAME || !dword_507B98_ctrl_pressed )
+    goto LABEL_30;
+  v4 = GetCurrentMenuID();
+  x = pX;
+  if ( (v4 & 0x80000000u) == 0
+    || (signed int)pX < (signed int)pViewport->uViewportTL_X
+    || (signed int)pX > (signed int)pViewport->uViewportBR_X )
+  {
+    y = pY;
+LABEL_30:
+    v7 = uNumVisibleWindows;
+    if ( uNumVisibleWindows < 0 )
+      return;
+    while ( 1 )
+    {
+      //v8 = (GUIWindow *)&pWindowList_at_506F50_minus1_indexing[21 * pVisibleWindowsIdxs[v7]];
+      v8 = &pWindowList[pVisibleWindowsIdxs[v7] - 1];
+      if ( x >= (signed int)v8->uFrameX )
+      {
+        if ( x <= (signed int)v8->uFrameZ && y >= (signed int)v8->uFrameY && y <= (signed int)v8->uFrameW )
+          break;
+      }
+      --v7;
+      if ( v7 < 0 )
+        return;
+    }
+    for ( i = v8->pControlsHead; ; i = i->pNext )
+    {
+      if ( !i )
+        return;
+      if ( i->uButtonType == 1 )
+        goto LABEL_41;
+      if ( i->uButtonType != 2 )
+        break;
+      if ( (signed int)(signed __int64)sqrt((double)((x - i->uX) * (x - i->uX) + (y - i->uY) * (y - i->uY))) < (signed int)i->uWidth )
+        goto LABEL_50;
+      y = pY;
+      x = pX;
+LABEL_45:
+      ;
+    }
+    if ( i->uButtonType != 3 )
+      goto LABEL_45;
+LABEL_41:
+    if ( x >= (signed int)i->uX && x <= (signed int)i->uZ && y >= (signed int)i->uY && y <= (signed int)i->uW )
+    {
+LABEL_50:
+      i->field_2C_is_pushed = 1;
+      v10 = pMessageQueue_50CBD0->uNumMessages;
+      if ( pMessageQueue_50CBD0->uNumMessages )
+      {
+        v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+        pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
+      }
+      //v11 = i->uControlParam;
+      pMessageQueue_50CBD0->AddMessage(i->msg, i->msg_param, 0);
+      return;
+    }
+    goto LABEL_45;
+  }
+  y = pY;
+  if ( (signed int)pY < (signed int)pViewport->uViewportTL_Y || (signed int)pY > (signed int)pViewport->uViewportBR_Y )
+    goto LABEL_30;
+  if ( pRenderer->pRenderD3D )
+    v5 = pGame->pVisInstance->get_picked_object_zbuf_val();
+  else
+    v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];
+  v6 = (unsigned __int16)v5;
+  if (PID_TYPE(v5) == OBJECT_Actor
+    && uActiveCharacter
+    && v5 < 0x2000000
+    && pPlayers[uActiveCharacter]->CanAct()
+    && pPlayers[uActiveCharacter]->CanSteal() )
+  {
+    /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
+    {
+      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_1B;
+      pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6 >> 3;
+      *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
+      ++pMessageQueue_50CBD0->uNumMessages;
+    }*/
+    pMessageQueue_50CBD0->AddMessage(UIMSG_1B, PID_ID(v6), 0);
+
+    if ( pParty->bTurnBasedModeOn == 1 )
+    {
+      if ( pTurnEngine->field_4 == 3 )
+        pTurnEngine->field_18 |= 8u;
+    }
+  }
+}
+
+
+
+//----- (00417871) --------------------------------------------------------
+void __thiscall sub_417871(int *pXY)
+{
+  POINT v1; // [sp+0h] [bp-18h]@5
+  POINT a2; // [sp+8h] [bp-10h]@5
+  unsigned int pY; // [sp+10h] [bp-8h]@3
+  unsigned int pX; // [sp+14h] [bp-4h]@3
+
+  if ( !pRenderer->pRenderD3D )
+  {
+    if ( pXY )
+    {
+      pX = *pXY;
+      pY = pXY[1];
+    }
+    else
+    {
+      pMouse->GetClickPos(&pX, &pY);
+    }
+    pMouse->GetCursorPos(&a2);
+    pMouse->GetCursorPos(&v1);
+  }
+}