2502
|
1 #define _CRTDBG_MAP_ALLOC
|
|
2 #include <stdlib.h>
|
|
3 #include <crtdbg.h>
|
|
4
|
|
5 #define _CRT_SECURE_NO_WARNINGS
|
|
6
|
|
7 #include "Engine/mm7_data.h"
|
|
8 #include "Mouse.h"
|
|
9 #include "Engine/Party.h"
|
|
10 #include "Engine/LOD.h"
|
|
11 #include "Engine/Game.h"
|
|
12
|
|
13 #include "Engine/TurnEngine/TurnEngine.h"
|
|
14 #include "Engine/Graphics/Viewport.h"
|
|
15 #include "GUI/GUIWindow.h"
|
|
16 #include "Engine/Graphics/Vis.h"
|
|
17 #include "Engine/Objects/Actor.h"
|
|
18 #include "Engine/MM7.h"
|
|
19 #include "Media/Audio/AudioPlayer.h"
|
|
20
|
|
21
|
|
22 Mouse *pMouse;
|
|
23
|
|
24
|
|
25
|
|
26
|
|
27
|
|
28 //----- (00469860) --------------------------------------------------------
|
|
29 void Mouse::GetClickPos(unsigned int *pX, unsigned int *pY)
|
|
30 {
|
|
31 *pX = uMouseClickX;
|
|
32 *pY = uMouseClickY;
|
|
33 }
|
|
34
|
|
35 //----- (004698A6) --------------------------------------------------------
|
|
36 void Mouse::RemoveHoldingItem()
|
|
37 {
|
|
38 pParty->pPickedItem.Reset();
|
|
39 if (_stricmp(pCurrentCursorName, "MICON2"))
|
|
40 SetCursorBitmap("MICON1");
|
|
41 }
|
|
42
|
|
43 //----- (004698D8) --------------------------------------------------------
|
|
44 void Mouse::SetCursorBitmapFromItemID(unsigned int uItemID)
|
|
45 {
|
|
46 pMouse->SetCursorBitmap(pItemsTable->pItems[uItemID].pIconName);
|
|
47 }
|
|
48
|
|
49 //----- (004698F6) --------------------------------------------------------
|
|
50 void Mouse::SetCurrentCursorBitmap()
|
|
51 {
|
|
52 SetCursorBitmap(pCurrentCursorName);
|
|
53 }
|
|
54
|
|
55 //----- (00469903) --------------------------------------------------------
|
|
56 void Mouse::SetCursorBitmap(const char *pName)
|
|
57 {
|
|
58 // DDSURFACEDESC2 Dst;
|
|
59
|
|
60 if ( !this->bInitialized || !pName )
|
|
61 return;
|
|
62 if ( _stricmp("MICON2", pName) )//если кусор не мишень
|
|
63 pGame->uFlags2 &= 0xFFFFFFEF;
|
|
64 else
|
|
65 pGame->uFlags2 |= 0x10;
|
|
66 if ( _stricmp(this->pCurrentCursorName, pName) )
|
|
67 strcpy(this->pCurrentCursorName, pName);
|
|
68 ClearCursor();
|
|
69 if ( _strnicmp(pName, "MICON1", 5) )//for click to item / если курсор с вещью
|
|
70 {
|
|
71 this->uCursorTextureID = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE);
|
|
72 this->uCursorTextureID_2 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE);
|
|
73 this->AllocCursorSystemMem();
|
|
74 this->field_C = 0;
|
|
75 this->bRedraw = true;
|
|
76 this->bActive = true;
|
|
77 if ( !areWeLoadingTexture )
|
|
78 {
|
|
79 if (uCursorTextureID != -1)
|
|
80 pIcons_LOD->pTextures[uCursorTextureID].Release();
|
|
81 pIcons_LOD->SyncLoadedFilesCount();
|
|
82 }
|
|
83 return;
|
|
84 }
|
|
85 this->bActive = false;
|
|
86 this->field_C = 1;
|
|
87 window->SetCursor(pName);
|
|
88 }
|
|
89 // 506128: using guessed type int areWeLoadingTexture;
|
|
90
|
|
91 //----- (00469AE4) --------------------------------------------------------
|
|
92 LONG Mouse::_469AE4()
|
|
93 {
|
|
94 LONG v2; // ecx@2
|
|
95 LONG result; // eax@2
|
|
96 struct tagPOINT Point; // [sp+Ch] [bp-8h]@2
|
|
97
|
|
98 this->field_8 = 1;
|
|
99 /*if (pAsyncMouse)
|
|
100 {
|
|
101 v2 = *((int *)pAsyncMouse + 6);
|
|
102 Point.x = *((int *)pAsyncMouse + 6);
|
|
103 result = *((int *)pAsyncMouse + 7);
|
|
104 }
|
|
105 else
|
|
106 {*/
|
|
107 GetCursorPos(&Point);
|
|
108 //if ( pRenderer->bWindowMode )
|
|
109 ScreenToClient(window->GetApiHandle(), &Point);
|
|
110 result = Point.y;
|
|
111 v2 = Point.x;
|
|
112 //}
|
|
113 this->uMouseClickX = v2;
|
|
114 this->uMouseClickY = result;
|
|
115
|
|
116 /*
|
|
117 //This block has been commented out, because of the changed condition above "if(true)"
|
|
118 //Also the next condition and the first line has been commented out as well
|
|
119
|
|
120 // if (pRenderer->bWindowMode)
|
|
121 if ( true )
|
|
122 goto LABEL_16;
|
|
123 //if (pAsyncMouse)
|
|
124 // goto LABEL_24;
|
|
125
|
|
126
|
|
127 if ( v2 < 0 )
|
|
128 v2 = 0;
|
|
129 if ( result < 0 )
|
|
130 result = 0;
|
|
131 if ( v2 > window->GetWidth() - 1 )
|
|
132 v2 = window->GetWidth() - 1;
|
|
133 */
|
|
134
|
|
135 // if ( result > window->GetHeight() - 1 )
|
|
136 // {
|
|
137 // result = window->GetHeight() - 1;
|
|
138 //LABEL_16:
|
|
139 //if (pAsyncMouse)
|
|
140 // goto LABEL_24;
|
|
141 if (true/*pRenderer->bWindowMode*/ && (v2 < 0 || result < 0 || v2 > window->GetWidth() - 1 || result > window->GetHeight() - 1))
|
|
142 {
|
|
143 this->bActive = false;
|
|
144 //LABEL_24:
|
|
145 this->field_8 = 0;
|
|
146 return result;
|
|
147 }
|
|
148 //}
|
|
149
|
|
150 if ( this->field_C )
|
|
151 //LABEL_23:
|
|
152 this->bActive = false;
|
|
153 //LABEL_24:
|
|
154 this->field_8 = 0;
|
|
155 return result;
|
|
156 }
|
|
157
|
|
158 //----- (00469BA3) --------------------------------------------------------
|
|
159 void Mouse::ClearCursor()
|
|
160 {
|
|
161 this->bActive = false;
|
|
162 free(this->pCursorBitmap_sysmem);
|
|
163 this->pCursorBitmap_sysmem = nullptr;
|
|
164 free(this->pCursorBitmap2_sysmem);
|
|
165 this->pCursorBitmap2_sysmem = nullptr;
|
|
166 free(this->ptr_90);
|
|
167 this->ptr_90 = nullptr;
|
|
168 }
|
|
169
|
|
170 //----- (00469BE6) --------------------------------------------------------
|
|
171 void Mouse::AllocCursorSystemMem()
|
|
172 {
|
|
173 bActive = false;
|
|
174 if (!pCursorBitmap_sysmem)
|
|
175 pCursorBitmap_sysmem = (unsigned __int16 *)DoAllocCursorMem();
|
|
176 if (!pCursorBitmap2_sysmem)
|
|
177 pCursorBitmap2_sysmem = (unsigned __int8 *)DoAllocCursorMem();
|
|
178 }
|
|
179
|
|
180 //----- (00469C0D) --------------------------------------------------------
|
|
181 void *Mouse::DoAllocCursorMem()
|
|
182 {
|
|
183 Texture* tex = pIcons_LOD->GetTexture(uCursorTextureID);
|
|
184 return malloc(4 * tex->uTextureWidth * tex->uTextureHeight);
|
|
185 }
|
|
186
|
|
187 //----- (00469C39) --------------------------------------------------------
|
|
188 POINT *Mouse::GetCursorPos(POINT *a2)
|
|
189 {
|
|
190 a2->x = this->uMouseClickX;
|
|
191 a2->y = this->uMouseClickY;
|
|
192 return a2;
|
|
193 }
|
|
194
|
|
195 //----- (00469C65) --------------------------------------------------------
|
|
196 void Mouse::Initialize(OSWindow *window)
|
|
197 {
|
|
198 this->window = window;
|
|
199 this->bActive = false;
|
|
200 this->bInitialized = true;
|
|
201
|
|
202 //this->field_8 = 0;//Ritor1: result incorrect uMouseClickX, this->uMouseClickY in _469AE4()
|
|
203 this->uCursorBitmapPitch = 0;//Ritor1: it's include
|
|
204 for ( uint i = 0; i < 13; i++ )
|
|
205 this->field_5C[i] = 0;
|
|
206
|
|
207 this->pCursorBitmapPos.x = 0;
|
|
208 this->pCursorBitmapPos.y = 0;
|
|
209 this->uMouseClickX = 0;
|
|
210 this->uMouseClickY = 0;
|
|
211 this->pCursorBitmap_sysmem = nullptr;
|
|
212 this->field_34 = 0;
|
|
213 this->pCursorBitmap2_sysmem = nullptr;
|
|
214
|
|
215 SetCursorBitmap("MICON3");
|
|
216 SetCursorBitmap("MICON2");
|
|
217 SetCursorBitmap("MICON1");
|
|
218 }
|
|
219
|
|
220 // inlined
|
|
221 //----- (0045FE00) mm6 chinese --------------------------------------------
|
|
222 void Mouse::SetActive(bool active)
|
|
223 {
|
|
224 bActive = active;
|
|
225 }
|
|
226
|
|
227 //----- (00469CC2) --------------------------------------------------------
|
|
228 void Mouse::Deactivate()
|
|
229 {
|
|
230 if (bInitialized)
|
|
231 SetActive(false);
|
|
232 }
|
|
233
|
|
234 //----- (00469CCD) --------------------------------------------------------
|
|
235 void Mouse::DrawCursor()
|
|
236 {
|
|
237 unsigned int v9; // eax@31
|
|
238
|
|
239 if ( this->bInitialized )
|
|
240 {
|
|
241 if ( !this->field_8 && this->bActive && !this->field_C ) //Uninitialized memory access(this->field_8)
|
|
242 pMouse->_469AE4();//Ritor1: странная, непонятная функция
|
|
243 this->field_F4 = 1;
|
|
244 if ( this->field_C )
|
|
245 {
|
|
246 this->field_F4 = 0;
|
|
247 return;
|
|
248 }
|
|
249
|
|
250 //if ( pRenderer->bWindowMode )
|
|
251 {
|
|
252 if ( this->uMouseClickX < 0 || this->uMouseClickY < 0 || this->uMouseClickX > window->GetWidth() - 1 || this->uMouseClickY > window->GetHeight() - 1 )
|
|
253 {
|
|
254 this->field_F4 = 0;
|
|
255 return;
|
|
256 }
|
|
257 }
|
|
258 /*else
|
|
259 {
|
|
260 if ( this->uMouseClickX < 0 )
|
|
261 this->uMouseClickX = 0;
|
|
262 if ( this->uMouseClickY < 0 )
|
|
263 this->uMouseClickY = 0;
|
|
264 if ( this->uMouseClickX > 639 )
|
|
265 this->uMouseClickX = 639;
|
|
266 if ( this->uMouseClickY > 479 )
|
|
267 this->uMouseClickY = 479;
|
|
268 }*/
|
|
269 this->pCursorBitmapRect.x = this->uMouseClickX;
|
|
270 this->pCursorBitmapRect.w = this->uMouseClickY + this->field_5C[0]; //Ritor1: Maybe this->field_5C[0] - cursor width
|
|
271 this->pCursorBitmapRect.y = this->uMouseClickY;
|
|
272 this->pCursorBitmapRect.z = this->uMouseClickX + this->uCursorBitmapPitch; //Ritor1: Maybe this->uCursorBitmapPitch - cursor height
|
|
273 if ( this->uMouseClickX < 0 )
|
|
274 this->pCursorBitmapRect.x = 0;
|
|
275 if ( this->uMouseClickY < 0 )
|
|
276 this->pCursorBitmapRect.y = 0;
|
|
277 if ( this->pCursorBitmapRect.z > window->GetWidth() )
|
|
278 this->pCursorBitmapRect.z = window->GetWidth();
|
|
279 if ( this->pCursorBitmapRect.w > window->GetHeight() )
|
|
280 this->pCursorBitmapRect.w = window->GetHeight();
|
|
281 this->bActive = false;
|
|
282 this->uCursorBitmapWidth = this->pCursorBitmapRect.z - this->pCursorBitmapRect.x;
|
|
283 this->uCursorBitmapHeight = this->pCursorBitmapRect.w - this->pCursorBitmapRect.y;
|
|
284 if ( this->bRedraw )
|
|
285 {
|
|
286 if ( pMouse->ptr_90 )
|
|
287 v9 = 2 * pMouse->uCursorBitmapPitch;
|
|
288 else
|
|
289 v9 = 0;
|
|
290 pRenderer->_4A6DF5( this->pCursorBitmap_sysmem, v9, &this->pCursorBitmapPos, pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch,
|
|
291 &this->pCursorBitmapRect);//срабатывает когда берём курсором вещь в инвенторе
|
|
292 this->bRedraw = false;
|
|
293 }
|
|
294 }
|
|
295 }
|
|
296
|
|
297 //----- (00469E1C) --------------------------------------------------------
|
|
298 void Mouse::Activate()
|
|
299 {
|
|
300 bActive = true;
|
|
301 }
|
|
302
|
|
303 //----- (00469E24) --------------------------------------------------------
|
|
304 void Mouse::_469E24()
|
|
305 {
|
|
306 free(pCursorBitmap3_sysmembits_16bit);
|
|
307 pCursorBitmap3_sysmembits_16bit = nullptr;
|
|
308 }
|
|
309
|
|
310 //----- (00469E3B) --------------------------------------------------------
|
|
311 void Mouse::DrawCursorToTarget()//??? DrawCursorWithItem
|
|
312 {
|
|
313 if (!pCursorBitmap3_sysmembits_16bit)
|
|
314 return;
|
|
315 //пишем на экран курсор с вещью
|
|
316 ushort* pSrc = pCursorBitmap3_sysmembits_16bit;
|
|
317 for (int y = uCursorWithItemY; y < uCursorWithItemZ; ++y)
|
|
318 for (int x = uCursorWithItemX; x < uCursorWithItemW; ++x)
|
|
319 //pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++;
|
|
320 pRenderer->WritePixel16(x, y, *pSrc++);
|
|
321 }
|
|
322
|
|
323 //----- (00469EA4) --------------------------------------------------------
|
|
324 void Mouse::ReadCursorWithItem()
|
|
325 {
|
|
326 unsigned int pTextureID; // eax@2
|
|
327 Texture *pTexture; // edi@2
|
|
328 // int v8; // ecx@25
|
|
329 // int v9; // ebx@26
|
|
330 // unsigned int v10; // eax@26
|
|
331 // int v11; // edx@27
|
|
332 int pTextureHeight; // [sp+20h] [bp-8h]@15
|
|
333 // unsigned __int16 *v20; // [sp+20h] [bp-8h]@28
|
|
334 int pTextureWidth; // [sp+24h] [bp-4h]@12
|
|
335 unsigned __int16 *v22; // [sp+24h] [bp-4h]@25
|
|
336
|
|
337 if ( pParty->pPickedItem.uItemID )
|
|
338 {
|
|
339 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
|
|
340 pTexture = (Texture *)(pTextureID != -1 ? (int)&pIcons_LOD->pTextures[pTextureID] : 0);
|
|
341
|
|
342 if ( (signed int)pMouse->uMouseClickX <= window->GetWidth() - 1 && (signed int)pMouse->uMouseClickY <= window->GetHeight() - 1 )
|
|
343 {
|
|
344 /*if ( (v4 & 0x80000000u) != 0 )
|
|
345 a2 = 0;
|
|
346 if ( (v5 & 0x80000000u) != 0 )
|
|
347 {
|
|
348 //v6 = 0;
|
|
349 v15 = 0;
|
|
350 } */
|
|
351 if ( (signed int)(pTexture->uTextureWidth + pMouse->uMouseClickX) <= window->GetWidth() )
|
|
352 pTextureWidth = pTexture->uTextureWidth;
|
|
353 else
|
|
354 pTextureWidth = window->GetWidth() - pMouse->uMouseClickX;
|
|
355 if ( (signed int)(pTexture->uTextureHeight + pMouse->uMouseClickY) <= window->GetHeight() )
|
|
356 pTextureHeight = pTexture->uTextureHeight;
|
|
357 else
|
|
358 pTextureHeight = window->GetHeight() - pMouse->uMouseClickY;
|
|
359 if ( !this->pCursorBitmap3_sysmembits_16bit
|
|
360 || pMouse->uMouseClickX != this->uCursorWithItemX
|
|
361 || pMouse->uMouseClickY != this->uCursorWithItemY
|
|
362 || pMouse->uMouseClickX + pTextureWidth != this->uCursorWithItemW
|
|
363 || pMouse->uMouseClickY + pTextureHeight != this->uCursorWithItemZ )
|
|
364 {
|
|
365 free(this->pCursorBitmap3_sysmembits_16bit);
|
|
366 this->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)malloc(2 * pTexture->uTextureHeight * pTexture->uTextureWidth);
|
|
367 this->uCursorWithItemX = pMouse->uMouseClickX;
|
|
368 this->uCursorWithItemW = pMouse->uMouseClickX + pTextureWidth;
|
|
369 this->uCursorWithItemY = pMouse->uMouseClickY;
|
|
370 this->uCursorWithItemZ = pMouse->uMouseClickY + pTextureHeight;
|
|
371 }
|
|
372 v22 = this->pCursorBitmap3_sysmembits_16bit;
|
|
373
|
|
374 for (int y = this->uCursorWithItemY; y < this->uCursorWithItemZ; ++y)
|
|
375 {
|
|
376 for (int x = this->uCursorWithItemX; x < this->uCursorWithItemW; ++x)
|
|
377 {
|
|
378 *v22++ = pRenderer->ReadPixel16(x, y);
|
|
379 }
|
|
380 }
|
|
381 /*if ( v8 < this->field_4C )
|
|
382 {
|
|
383 v9 = this->field_48;
|
|
384 v10 = pRenderer->uTargetSurfacePitch * v8;
|
|
385 do
|
|
386 {
|
|
387 v11 = this->field_40;
|
|
388 v18 = this->field_40;
|
|
389 if ( v11 < v9 )
|
|
390 {
|
|
391 v20 = &v17[v10 + v11];
|
|
392 do
|
|
393 {
|
|
394 //v12 = v20;
|
|
395 ++v18;
|
|
396 //++v20;
|
|
397 *v22++ = *v20++;
|
|
398 }
|
|
399 while ( v18 < v9 );
|
|
400 }
|
|
401 v10 += v16;
|
|
402 ++v8;
|
|
403 }
|
|
404 while ( v8 < this->field_4C );
|
|
405 v6 = v15;
|
|
406 }*/
|
|
407
|
|
408 if (pParty->pPickedItem.IsBroken())
|
|
409 pRenderer->DrawTransparentRedShade(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture);
|
|
410 else if (!pParty->pPickedItem.IsIdentified())
|
|
411 pRenderer->DrawTransparentGreenShade(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture);
|
|
412 else
|
|
413 pRenderer->DrawTextureTransparent(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture);
|
|
414 }
|
|
415 }
|
|
416 else
|
|
417 {
|
|
418 free(this->pCursorBitmap3_sysmembits_16bit);
|
|
419 this->pCursorBitmap3_sysmembits_16bit = nullptr;
|
|
420 }
|
|
421 }
|
|
422
|
|
423 //----- (0046A080) --------------------------------------------------------
|
|
424 void Mouse::ChangeActivation(int a1)
|
|
425 {
|
|
426 this->bActive = a1;
|
|
427 }
|
|
428
|
|
429 //----- (0046A08A) --------------------------------------------------------
|
|
430 void Mouse::SetMouseClick(int x, int y)
|
|
431 {
|
|
432 uMouseClickX = x;
|
|
433 uMouseClickY = y;
|
|
434 }
|
|
435 //----- (004175C0) --------------------------------------------------------
|
|
436 void Mouse::UI_OnMouseLeftClick(int *pXY)
|
|
437 {
|
|
438 signed int y; // eax@7
|
|
439 signed int x; // ecx@7
|
|
440 signed int v5; // eax@17
|
|
441 GUIButton *control; // esi@37
|
|
442 signed int v10; // eax@50
|
|
443 // int v11; // ecx@52
|
|
444 unsigned int pX; // [sp+14h] [bp-8h]@7
|
|
445 unsigned int pY; // [sp+18h] [bp-4h]@7
|
|
446
|
|
447 if ( pCurrentScreen == SCREEN_VIDEO || sub_4637E0_is_there_popup_onscreen() )
|
|
448 return;
|
|
449 if ( pGUIWindow2 && pGUIWindow2->ptr_1C == (void *)33 )
|
|
450 {
|
|
451 sub_4452BB();
|
|
452 return;
|
|
453 }
|
|
454 if ( pXY )
|
|
455 {
|
|
456 x = *pXY;
|
|
457 y = pXY[1];
|
|
458 pX = *pXY;
|
|
459 pY = y;
|
|
460 }
|
|
461 else
|
|
462 {
|
|
463 pMouse->GetClickPos(&pX, &pY);
|
|
464 y = pY;
|
|
465 x = pX;
|
|
466 }
|
|
467
|
|
468 extern bool _507B98_ctrl_pressed;
|
|
469 x = pX;
|
|
470 if ( GetCurrentMenuID() != -1 || pCurrentScreen != SCREEN_GAME || !_507B98_ctrl_pressed // stealing cursor
|
|
471 || (signed int)pX < (signed int)pViewport->uViewportTL_X || (signed int)pX > (signed int)pViewport->uViewportBR_X
|
|
472 || (signed int)pY < (signed int)pViewport->uViewportTL_Y || (signed int)pY > (signed int)pViewport->uViewportBR_Y)
|
|
473 {
|
|
474 y = pY;
|
|
475 for ( int i = uNumVisibleWindows; i >= 0; --i )
|
|
476 {
|
|
477 if ( x >= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameX && x <= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameZ
|
|
478 && y >= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameY && y <= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameW )
|
|
479 {
|
|
480 for ( control = pWindowList[pVisibleWindowsIdxs[i] - 1].pControlsHead; control; control = control->pNext )
|
|
481 {
|
|
482 if ( control->uButtonType == 1 )
|
|
483 {
|
|
484 if ( x >= (signed int)control->uX && x <= (signed int)control->uZ && y >= (signed int)control->uY && y <= (signed int)control->uW )
|
|
485 {
|
|
486 control->field_2C_is_pushed = 1;
|
|
487 v10 = pMessageQueue_50CBD0->uNumMessages;
|
|
488 if ( pMessageQueue_50CBD0->uNumMessages )
|
|
489 {
|
|
490 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
|
|
491 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
|
|
492 }
|
|
493 pMessageQueue_50CBD0->AddGUIMessage(control->msg, control->msg_param, 0);
|
|
494 return;
|
|
495 }
|
|
496 continue;
|
|
497 }
|
|
498 if ( control->uButtonType == 2 )//когда нажимаешь на партреты персов
|
|
499 {
|
|
500 if ( (signed int)(signed __int64)sqrt((double)((x - control->uX) * (x - control->uX) + (y - control->uY) * (y - control->uY))) < (signed int)control->uWidth )
|
|
501 {
|
|
502 control->field_2C_is_pushed = 1;
|
|
503 v10 = pMessageQueue_50CBD0->uNumMessages;
|
|
504 if ( pMessageQueue_50CBD0->uNumMessages )
|
|
505 {
|
|
506 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
|
|
507 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
|
|
508 }
|
|
509 pMessageQueue_50CBD0->AddGUIMessage(control->msg, control->msg_param, 0);
|
|
510 return;
|
|
511 }
|
|
512 continue;
|
|
513 }
|
|
514 if ( control->uButtonType == 3 )//когда нажимаешь на скиллы
|
|
515 {
|
|
516 if ( x >= (signed int)control->uX && x <= (signed int)control->uZ && y >= (signed int)control->uY && y <= (signed int)control->uW )
|
|
517 {
|
|
518 control->field_2C_is_pushed = 1;
|
|
519 v10 = pMessageQueue_50CBD0->uNumMessages;
|
|
520 if ( pMessageQueue_50CBD0->uNumMessages )
|
|
521 {
|
|
522 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
|
|
523 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
|
|
524 }
|
|
525 pMessageQueue_50CBD0->AddGUIMessage(control->msg, control->msg_param, 0);
|
|
526 return;
|
|
527 }
|
|
528 continue;
|
|
529 }
|
|
530 y = pY;
|
|
531 x = pX;
|
|
532 }
|
|
533 }
|
|
534 }
|
|
535 return;
|
|
536 }
|
|
537 y = pY;
|
|
538 //if ( pRenderer->pRenderD3D )
|
|
539 v5 = pGame->pVisInstance->get_picked_object_zbuf_val();
|
|
540 /*else
|
|
541 v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];*/
|
|
542
|
|
543 uint type = PID_TYPE((unsigned __int16)v5);
|
|
544 if (type == OBJECT_Actor && uActiveCharacter && v5 < 0x2000000
|
|
545 && pPlayers[uActiveCharacter]->CanAct() && pPlayers[uActiveCharacter]->CanSteal() )
|
|
546 {
|
|
547 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 )
|
|
548 {
|
|
549 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_1B;
|
|
550 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6 >> 3;
|
|
551 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
|
|
552 ++pMessageQueue_50CBD0->uNumMessages;
|
|
553 }*/
|
|
554 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_STEALFROMACTOR, PID_ID((unsigned __int16)v5), 0);
|
|
555
|
|
556 if ( pParty->bTurnBasedModeOn == 1 )
|
|
557 {
|
|
558 if ( pTurnEngine->turn_stage == TE_MOVEMENT )
|
|
559 pTurnEngine->field_18 |= TE_FLAG_8;
|
|
560 }
|
|
561 }
|
|
562 }
|
|
563
|
|
564
|
|
565 //----- (0041CD4F) --------------------------------------------------------
|
|
566 bool Mouse::UI_OnKeyDown(unsigned int vkKey)
|
|
567 {
|
|
568 //unsigned int v1; // edi@1
|
|
569 //unsigned int v2; // eax@2
|
|
570 int v3; // esi@3
|
|
571 int v4; // ecx@10
|
|
572 GUIButton *pButton; // eax@11
|
|
573 int v6; // edx@12
|
|
574 int v7; // ecx@20
|
|
575 char v8; // zf@21
|
|
576 //GUIButton *v9; // ecx@24
|
|
577 int v10; // esi@24
|
|
578 //int v11; // edx@26
|
|
579 int v12; // edx@28
|
|
580 int v13; // esi@32
|
|
581 //GUIButton *v14; // eax@37
|
|
582 int v15; // edx@38
|
|
583 int v17; // ecx@50
|
|
584 int v18; // edx@50
|
|
585 //GUIButton *v19; // ecx@54
|
|
586 int v20; // esi@54
|
|
587 //int v21; // edx@56
|
|
588 int v22; // ecx@59
|
|
589 int v23; // edx@59
|
|
590 int v24; // ecx@60
|
|
591 int v25; // esi@63
|
|
592 //unsigned int v26; // [sp+Ch] [bp-14h]@1
|
|
593 //int v27; // [sp+10h] [bp-10h]@1
|
|
594 int v28; // [sp+14h] [bp-Ch]@10
|
|
595 int v29; // [sp+14h] [bp-Ch]@36
|
|
596 unsigned int uClickX; // [sp+18h] [bp-8h]@10
|
|
597 unsigned int uClickY; // [sp+1Ch] [bp-4h]@10
|
|
598
|
|
599 //v1 = 0;
|
|
600 //v27 = uNumVisibleWindows;
|
|
601 if ( uNumVisibleWindows < 0 )
|
|
602 return false;
|
|
603 //v2 = pMessageQueue_50CBD0->uNumMessages;
|
|
604 for (int i = uNumVisibleWindows; i >= 0; --i)
|
|
605 //while ( 1 )
|
|
606 {
|
|
607 v3 = pVisibleWindowsIdxs[i] - 1;
|
|
608 if (!pWindowList[v3].receives_keyboard_input)
|
|
609 continue;
|
|
610
|
|
611 switch (vkKey)
|
|
612 {
|
|
613 case VK_LEFT:
|
|
614 {
|
|
615 v12 = pWindowList[v3].field_34;
|
|
616 if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 )
|
|
617 {
|
|
618 v8 = pCurrentScreen == SCREEN_PARTY_CREATION;
|
|
619 pWindowList[v3].pCurrentPosActiveItem -= v12;
|
|
620 if ( v8 )
|
|
621 {
|
|
622 pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
|
|
623 //v2 = pMessageQueue_50CBD0->uNumMessages;
|
|
624 }
|
|
625 }
|
|
626 if ( pWindowList[v3].field_30 != 0 )
|
|
627 {
|
|
628 break;
|
|
629 }
|
|
630 pButton = pWindowList[v3].pControlsHead;
|
|
631 v13 = pWindowList[v3].pCurrentPosActiveItem;
|
|
632 if ( v13 > 0)
|
|
633 {
|
|
634 do
|
|
635 {
|
|
636 pButton = pButton->pNext;
|
|
637 --v13;
|
|
638 }
|
|
639 while ( v13 );
|
|
640 }
|
|
641 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0);
|
|
642 break;
|
|
643 }
|
|
644 case VK_RIGHT:
|
|
645 {
|
|
646 v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34;
|
|
647 if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem )
|
|
648 {
|
|
649 v8 = pCurrentScreen == SCREEN_PARTY_CREATION;
|
|
650 pWindowList[v3].pCurrentPosActiveItem = v7;
|
|
651 if ( v8 )
|
|
652 {
|
|
653 pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0);
|
|
654 //v2 = pMessageQueue_50CBD0->uNumMessages;
|
|
655 }
|
|
656 }
|
|
657 if ( pWindowList[v3].field_30 != 0 )
|
|
658 {
|
|
659 break;
|
|
660 }
|
|
661 pButton = pWindowList[v3].pControlsHead;
|
|
662 v10 = pWindowList[v3].pCurrentPosActiveItem;
|
|
663 if ( v10 > 0)
|
|
664 {
|
|
665 do
|
|
666 {
|
|
667 pButton = pButton->pNext;
|
|
668 --v10;
|
|
669 }
|
|
670 while ( v10 );
|
|
671 }
|
|
672 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0);
|
|
673 break;
|
|
674 }
|
|
675 case VK_DOWN:
|
|
676 {
|
|
677 v17 = pWindowList[v3].pStartingPosActiveItem;
|
|
678 v18 = pWindowList[v3].pCurrentPosActiveItem;
|
|
679 if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 )
|
|
680 pWindowList[v3].pCurrentPosActiveItem = v17;
|
|
681 else
|
|
682 pWindowList[v3].pCurrentPosActiveItem = v18 + 1;
|
|
683 if ( pWindowList[v3].field_30 != 0 )
|
|
684 return true;
|
|
685 pButton = pWindowList[v3].pControlsHead;
|
|
686 v20 = pWindowList[v3].pCurrentPosActiveItem;
|
|
687 if ( v20 > 0)
|
|
688 {
|
|
689 do
|
|
690 {
|
|
691 pButton = pButton->pNext;
|
|
692 --v20;
|
|
693 }
|
|
694 while ( v20 );
|
|
695 }
|
|
696 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0);
|
|
697 return true;
|
|
698 }
|
|
699 case VK_SELECT:
|
|
700 {
|
|
701 pMouse->GetClickPos(&uClickX, &uClickY);
|
|
702 v4 = pWindowList[v3].pStartingPosActiveItem;
|
|
703 v28 = v4 + pWindowList[v3].pNumPresenceButton;
|
|
704 if ( v4 < v4 + pWindowList[v3].pNumPresenceButton )
|
|
705 {
|
|
706 while ( 1 )
|
|
707 {
|
|
708 pButton = pWindowList[v3].pControlsHead;
|
|
709 if ( v4 > 0 )
|
|
710 {
|
|
711 v6 = v4;
|
|
712 do
|
|
713 {
|
|
714 pButton = pButton->pNext;
|
|
715 --v6;
|
|
716 }
|
|
717 while ( v6 );
|
|
718 }
|
|
719 if ( (signed int)uClickX >= (signed int)pButton->uX//test for StatsTab in PlayerCreation Window
|
|
720 && (signed int)uClickX <= (signed int)pButton->uZ
|
|
721 && (signed int)uClickY >= (signed int)pButton->uY
|
|
722 && (signed int)uClickY <= (signed int)pButton->uW )
|
|
723 break;
|
|
724 ++v4;
|
|
725 if ( v4 >= v28 )
|
|
726 {
|
|
727 //v1 = 0;
|
|
728 //v2 = pMessageQueue_50CBD0->uNumMessages;
|
|
729 //--i;
|
|
730 //if ( i < 0 )
|
|
731 return false;
|
|
732 //continue;
|
|
733 }
|
|
734 }
|
|
735 pWindowList[v3].pCurrentPosActiveItem = v4;
|
|
736 return true;
|
|
737 }
|
|
738 //v2 = pMessageQueue_50CBD0->uNumMessages;
|
|
739 break;
|
|
740 }
|
|
741 case VK_UP:
|
|
742 {
|
|
743 v22 = pWindowList[v3].pCurrentPosActiveItem;
|
|
744 v23 = pWindowList[v3].pStartingPosActiveItem;
|
|
745 if ( v22 <= v23 )
|
|
746 v24 = pWindowList[v3].pNumPresenceButton + v23 - 1;
|
|
747 else
|
|
748 v24 = v22 - 1;
|
|
749 v8 = pWindowList[v3].field_30 == 0;
|
|
750 pWindowList[v3].pCurrentPosActiveItem = v24;
|
|
751 if ( !v8 )
|
|
752 return true;
|
|
753 pButton = pWindowList[v3].pControlsHead;
|
|
754 v25 = pWindowList[v3].pCurrentPosActiveItem;
|
|
755 if ( v25 > 0)
|
|
756 {
|
|
757 do
|
|
758 {
|
|
759 pButton = pButton->pNext;
|
|
760 --v25;
|
|
761 }
|
|
762 while ( v25 );
|
|
763 }
|
|
764 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0);
|
|
765 return true;
|
|
766 }
|
|
767 case VK_NEXT:
|
|
768 {
|
|
769 if ( pWindowList[v3].field_30 != 0 ) //crashed at skill draw
|
|
770 {
|
|
771 pMouse->GetClickPos(&uClickX, &uClickY);
|
|
772 v29 = pWindowList[v3].pStartingPosActiveItem + pWindowList[v3].pNumPresenceButton; //num buttons more than buttons
|
|
773 for ( v4 = pWindowList[v3].pStartingPosActiveItem; v4 < v29; ++v4 )
|
|
774 {
|
|
775 pButton = pWindowList[v3].pControlsHead;
|
|
776 if ( v4 > 0 )
|
|
777 {
|
|
778 for ( v15 = v4; v15; --v15 )
|
|
779 pButton = pButton->pNext;
|
|
780 }
|
|
781 if ( (signed int)uClickX >= (signed int)pButton->uX && (signed int)uClickX <= (signed int)pButton->uZ
|
|
782 && (signed int)uClickY >= (signed int)pButton->uY && (signed int)uClickY <= (signed int)pButton->uW )
|
|
783 {
|
|
784 pWindowList[v3].pCurrentPosActiveItem = v4;
|
|
785 return true;
|
|
786 }
|
|
787 }
|
|
788 }
|
|
789 break;
|
|
790 }
|
|
791 default:
|
|
792 break;
|
|
793 }
|
|
794 }
|
|
795 }
|