Mercurial > mm7
annotate Mouse.cpp @ 1362:d6cf8ead9242
Condition checking functions slightly renamed, some final changes in Player::SetCondition
author | Grumpy7 |
---|---|
date | Mon, 15 Jul 2013 00:42:50 +0200 |
parents | 22cb507446a4 |
children | cc9a3a24d61d |
rev | line source |
---|---|
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
1 #ifdef _MSC_VER |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
2 #define _CRT_SECURE_NO_WARNINGS |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
3 #endif |
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
4 |
0 | 5 |
1262 | 6 #include "Texture.h" |
7 #include "mm7_data.h" | |
1253 | 8 #include "Render.h" |
0 | 9 #include "Mouse.h" |
10 #include "Items.h" | |
11 #include "Party.h" | |
12 #include "LOD.h" | |
13 #include "Game.h" | |
14 | |
1016 | 15 #include "stru11.h" |
1296 | 16 #include "TurnEngine.h" |
17 #include "Viewport.h" | |
18 #include "GUIWindow.h" | |
19 #include "Vis.h" | |
20 #include "Actor.h" | |
21 #include "MM7.h" | |
1297 | 22 #include "AudioPlayer.h" |
0 | 23 |
24 | |
25 Mouse *pMouse; | |
26 | |
27 | |
28 | |
29 | |
30 | |
31 //----- (00469860) -------------------------------------------------------- | |
32 void Mouse::GetClickPos(unsigned int *pX, unsigned int *pY) | |
33 { | |
1038 | 34 *pX = uMouseClickX; |
35 *pY = uMouseClickY; | |
0 | 36 } |
37 | |
38 //----- (004698A6) -------------------------------------------------------- | |
39 void Mouse::RemoveHoldingItem() | |
40 { | |
41 pParty->pPickedItem.Reset(); | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
42 if (_stricmp(pCurrentCursorName, "MICON2")) |
0 | 43 SetCursorBitmap("MICON1"); |
44 } | |
45 | |
46 //----- (004698D8) -------------------------------------------------------- | |
47 void Mouse::SetCursorBitmapFromItemID(unsigned int uItemID) | |
48 { | |
49 pMouse->SetCursorBitmap(pItemsTable->pItems[uItemID].pIconName); | |
50 } | |
51 | |
52 //----- (004698F6) -------------------------------------------------------- | |
53 void Mouse::SetCurrentCursorBitmap() | |
54 { | |
55 SetCursorBitmap(pCurrentCursorName); | |
56 } | |
57 | |
58 //----- (00469903) -------------------------------------------------------- | |
59 void Mouse::SetCursorBitmap(const char *pName) | |
60 { | |
61 Mouse *v2; // esi@1 | |
62 HCURSOR v3; // eax@10 | |
1038 | 63 //int v4; // ecx@10 |
0 | 64 double v5; // st7@11 |
65 float v6; // ST04_4@12 | |
66 LONG v7; // eax@14 | |
67 LONG v8; // eax@17 | |
68 unsigned int v9; // eax@21 | |
69 float v10; // [sp+4h] [bp-18h]@11 | |
70 struct tagPOINT Point; // [sp+14h] [bp-8h]@20 | |
71 | |
72 v2 = this; | |
73 if ( !this->bInitialized || !pName ) | |
74 return; | |
1104 | 75 if ( _stricmp("MICON2", pName) ) |
0 | 76 pGame->uFlags2 &= 0xFFFFFFEFu; |
77 else | |
78 pGame->uFlags2 |= 0x10u; | |
1104 | 79 if ( _stricmp(v2->pCurrentCursorName, pName) ) |
0 | 80 strcpy(v2->pCurrentCursorName, pName); |
81 ClearCursor(); | |
82 if ( _strnicmp(pName, "MICON1", 5u) ) | |
83 { | |
84 v9 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); | |
85 v2->uCursorTextureID = v9; | |
86 v2->uCursorTextureID_2 = v9; | |
87 v2->AllocCursorSystemMem(); | |
88 v2->field_C = 0; | |
791 | 89 v2->bRedraw = 1; |
0 | 90 v2->bActive = 1; |
91 if ( !areWeLoadingTexture ) | |
92 { | |
93 if (uCursorTextureID != -1) | |
94 pIcons_LOD->pTextures[uCursorTextureID].Release(); | |
1006 | 95 pIcons_LOD->SyncLoadedFilesCount(); |
0 | 96 } |
97 return; | |
98 } | |
99 v2->bActive = 0; | |
100 v2->field_C = 1; | |
101 if ( !strcmp(pName, "MICON1") ) | |
102 { | |
103 v3 = LoadCursorA(GetModuleHandleW(nullptr), "Arrow"); | |
104 SetClassLongA(hWnd, GCL_HCURSOR, (LONG)v3); | |
105 } | |
1068 | 106 else if ( !strcmp(pName, "MICON2") ) |
0 | 107 { |
108 v7 = (LONG)LoadCursorA(GetModuleHandleW(nullptr), "Target"); | |
109 SetClassLongA(hWnd, -12, v7); | |
110 } | |
1068 | 111 else if ( !strcmp(pName, "MICON3") ) |
0 | 112 { |
113 v8 = (LONG)LoadCursorA(0, (LPCSTR)IDC_WAIT); | |
114 SetClassLongA(hWnd, -12, v8); | |
115 } | |
779 | 116 //LABEL_18: |
1038 | 117 |
779 | 118 GetCursorPos(&Point); |
1068 | 119 ClientToScreen(hWnd,&Point); |
779 | 120 SetCursorPos(Point.x, Point.y); |
0 | 121 } |
122 // 506128: using guessed type int areWeLoadingTexture; | |
123 | |
124 //----- (00469AE4) -------------------------------------------------------- | |
125 LONG Mouse::_469AE4() | |
126 { | |
127 Mouse *v1; // esi@1 | |
128 LONG v2; // ecx@2 | |
129 LONG result; // eax@2 | |
130 struct tagPOINT Point; // [sp+Ch] [bp-8h]@2 | |
131 | |
132 v1 = this; | |
133 this->field_8 = 1; | |
1038 | 134 /*if (pAsyncMouse) |
0 | 135 { |
136 v2 = *((int *)pAsyncMouse + 6); | |
137 Point.x = *((int *)pAsyncMouse + 6); | |
138 result = *((int *)pAsyncMouse + 7); | |
139 } | |
140 else | |
1038 | 141 {*/ |
0 | 142 GetCursorPos(&Point); |
143 if ( pRenderer->bWindowMode ) | |
144 ScreenToClient(hWnd, &Point); | |
145 result = Point.y; | |
146 v2 = Point.x; | |
1038 | 147 //} |
0 | 148 v1->uMouseClickX = v2; |
149 v1->uMouseClickY = result; | |
150 if ( pRenderer->bWindowMode ) | |
151 goto LABEL_16; | |
1038 | 152 //if (pAsyncMouse) |
153 // goto LABEL_24; | |
0 | 154 if ( v2 < 0 ) |
155 v2 = 0; | |
156 if ( result < 0 ) | |
157 result = 0; | |
158 if ( v2 > 639 ) | |
159 v2 = 639; | |
160 if ( result > 479 ) | |
161 { | |
162 result = 479; | |
163 LABEL_16: | |
1038 | 164 //if (pAsyncMouse) |
165 // goto LABEL_24; | |
0 | 166 if ( pRenderer->bWindowMode && (v2 < 0 || result < 0 || v2 > 639 || result > 479) ) |
167 goto LABEL_23; | |
168 } | |
169 if ( v1->field_C ) | |
170 LABEL_23: | |
171 v1->bActive = 0; | |
172 LABEL_24: | |
173 v1->field_8 = 0; | |
174 return result; | |
175 } | |
176 | |
177 //----- (00469BA3) -------------------------------------------------------- | |
178 void Mouse::ClearCursor() | |
179 { | |
180 Mouse *v1; // esi@1 | |
181 void *v2; // eax@1 | |
182 void **v3; // esi@5 | |
183 | |
184 v1 = this; | |
185 v2 = this->pCursorBitmap_sysmem; | |
186 this->bActive = 0; | |
187 if ( v2 ) | |
188 { | |
189 free(v2); | |
190 v1->pCursorBitmap_sysmem = 0; | |
191 } | |
192 if ( v1->pCursorBitmap2_sysmem ) | |
193 { | |
194 free(v1->pCursorBitmap2_sysmem); | |
195 v1->pCursorBitmap2_sysmem = 0; | |
196 } | |
197 v3 = &v1->ptr_90; | |
198 if ( *v3 ) | |
199 free(*v3); | |
200 *v3 = 0; | |
201 } | |
202 | |
203 //----- (00469BE6) -------------------------------------------------------- | |
204 void Mouse::AllocCursorSystemMem() | |
205 { | |
206 bActive = 0; | |
207 if (!pCursorBitmap_sysmem) | |
208 pCursorBitmap_sysmem = (unsigned __int16 *)DoAllocCursorMem(); | |
209 if (!pCursorBitmap2_sysmem) | |
210 pCursorBitmap2_sysmem = (unsigned __int8 *)DoAllocCursorMem(); | |
211 } | |
212 | |
213 //----- (00469C0D) -------------------------------------------------------- | |
214 void *Mouse::DoAllocCursorMem() | |
215 { | |
973 | 216 auto tex = pIcons_LOD->GetTexture(uCursorTextureID); |
217 return malloc(4 * tex->uTextureWidth * tex->uTextureHeight); | |
0 | 218 } |
219 | |
220 //----- (00469C39) -------------------------------------------------------- | |
221 POINT *Mouse::GetCursorPos(POINT *a2) | |
222 { | |
1038 | 223 a2->x = this->uMouseClickX; |
224 a2->y = this->uMouseClickY; | |
225 return a2; | |
0 | 226 } |
227 | |
228 //----- (00469C65) -------------------------------------------------------- | |
229 void Mouse::Initialize(HWND hWnd) | |
230 { | |
231 this->hWnd = hWnd; | |
232 this->bActive = 0; | |
233 this->bInitialized = 1; | |
234 this->pCursorBitmapPos.x = 0; | |
235 this->pCursorBitmapPos.y = 0; | |
236 this->uMouseClickX = 0; | |
237 this->uMouseClickY = 0; | |
238 this->pCursorBitmap_sysmem = 0; | |
239 this->field_34 = 0; | |
240 this->pCursorBitmap2_sysmem = 0; | |
241 | |
242 SetCursorBitmap("MICON3"); | |
243 SetCursorBitmap("MICON2"); | |
244 SetCursorBitmap("MICON1"); | |
245 } | |
246 | |
762 | 247 // inlined |
248 //----- (0045FE00) mm6 chinese -------------------------------------------- | |
249 void Mouse::SetActive(bool active) | |
250 { | |
251 bActive = active; | |
252 } | |
253 | |
0 | 254 //----- (00469CC2) -------------------------------------------------------- |
255 void Mouse::Deactivate() | |
256 { | |
257 if (bInitialized) | |
762 | 258 SetActive(false); |
0 | 259 } |
260 | |
261 //----- (00469CCD) -------------------------------------------------------- | |
262 void Mouse::DrawCursor() | |
263 { | |
264 Mouse *v1; // esi@1 | |
265 char v11; // zf@6 | |
266 signed int v3; // eax@6 | |
267 signed int v4; // ecx@6 | |
268 Vec4_int_ *v5; // edx@21 | |
269 int v6; // edi@21 | |
270 int v7; // ebx@21 | |
271 int v8; // eax@29 | |
272 unsigned int v9; // eax@31 | |
273 | |
274 v1 = this; | |
275 if ( this->bInitialized ) | |
276 { | |
277 if ( !this->field_8 && this->bActive && !this->field_C ) | |
278 pMouse->_469AE4(); | |
279 v11 = v1->field_C == 0; | |
280 v3 = v1->uMouseClickX; | |
281 v4 = v1->uMouseClickY; | |
282 v1->field_F4 = 1; | |
283 if ( !v11 ) | |
284 goto LABEL_12; | |
285 if ( pRenderer->bWindowMode ) | |
286 { | |
287 if ( v3 < 0 || v4 < 0 || v3 > 639 || v4 > 479 ) | |
288 { | |
289 LABEL_12: | |
290 v1->field_F4 = 0; | |
291 return; | |
292 } | |
293 } | |
294 else | |
295 { | |
296 if ( v3 < 0 ) | |
297 v3 = 0; | |
298 if ( v4 < 0 ) | |
299 v4 = 0; | |
300 if ( v3 > 639 ) | |
301 v3 = 639; | |
302 if ( v4 > 479 ) | |
303 v4 = 479; | |
304 } | |
305 v5 = &v1->pCursorBitmapRect; | |
306 v6 = v3 + v1->uCursorBitmapPitch; | |
307 v7 = v4 + v1->field_5C[0]; | |
308 v1->pCursorBitmapRect.y = v4; | |
309 v1->pCursorBitmapRect.x = v3; | |
310 v1->pCursorBitmapRect.z = v6; | |
311 v1->pCursorBitmapRect.w = v7; | |
312 if ( v3 < 0 ) | |
313 v5->x = 0; | |
314 if ( v4 < 0 ) | |
315 v1->pCursorBitmapRect.y = 0; | |
316 if ( v6 > 640 ) | |
317 v1->pCursorBitmapRect.z = 640; | |
318 if ( v7 > 480 ) | |
319 v1->pCursorBitmapRect.w = 480; | |
320 v8 = v1->pCursorBitmapRect.z; | |
321 v1->bActive = 0; | |
322 v1->uCursorBitmapWidth = v8 - v5->x; | |
791 | 323 v11 = v1->bRedraw == 0; |
0 | 324 v1->uCursorBitmapHeight = v1->pCursorBitmapRect.w - v1->pCursorBitmapRect.y; |
325 if ( !v11 ) | |
326 { | |
327 if ( pMouse->ptr_90 ) | |
328 v9 = 2 * pMouse->uCursorBitmapPitch; | |
329 else | |
330 v9 = 0; | |
331 pRenderer->_4A6DF5( | |
332 v1->pCursorBitmap_sysmem, | |
333 v9, | |
334 &v1->pCursorBitmapPos, | |
335 pRenderer->pTargetSurface, | |
336 pRenderer->uTargetSurfacePitch, | |
337 &v1->pCursorBitmapRect); | |
791 | 338 v1->bRedraw = false; |
0 | 339 } |
340 } | |
341 } | |
342 | |
343 //----- (00469E1C) -------------------------------------------------------- | |
344 void Mouse::_469E1C() | |
345 { | |
346 bActive = true; | |
347 } | |
348 | |
349 //----- (00469E24) -------------------------------------------------------- | |
350 void Mouse::_469E24() | |
351 { | |
352 if (pCursorBitmap3_sysmembits_16bit) | |
353 { | |
354 free(pCursorBitmap3_sysmembits_16bit); | |
355 pCursorBitmap3_sysmembits_16bit = 0; | |
356 } | |
357 } | |
358 | |
359 //----- (00469E3B) -------------------------------------------------------- | |
360 void Mouse::DrawCursorToTarget() | |
361 { | |
362 if (!pCursorBitmap3_sysmembits_16bit) | |
363 return; | |
364 | |
365 auto pSrc = pCursorBitmap3_sysmembits_16bit; | |
366 for (uint y = field_44; y < field_4C; ++y) | |
367 for (uint x = field_40; x < field_48; ++x) | |
368 pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++; | |
369 } | |
370 | |
371 //----- (00469EA4) -------------------------------------------------------- | |
372 void Mouse::_469EA4() | |
373 { | |
920 | 374 //Mouse *v1; // esi@1 |
375 unsigned int pTextureID; // eax@2 | |
376 Texture *pTexture; // edi@2 | |
0 | 377 unsigned int v4; // ecx@3 |
378 unsigned int v5; // eax@3 | |
379 unsigned int v6; // ebx@5 | |
380 int v7; // ecx@15 | |
381 int v8; // ecx@25 | |
382 int v9; // ebx@26 | |
383 unsigned int v10; // eax@26 | |
384 int v11; // edx@27 | |
385 unsigned __int16 *v12; // edx@29 | |
386 unsigned __int16 *v13; // ebx@29 | |
387 unsigned int a2; // [sp+Ch] [bp-1Ch]@5 | |
388 unsigned int v15; // [sp+10h] [bp-18h]@5 | |
389 unsigned int v16; // [sp+14h] [bp-14h]@25 | |
390 unsigned __int16 *v17; // [sp+18h] [bp-10h]@25 | |
391 int v18; // [sp+1Ch] [bp-Ch]@27 | |
392 int v19; // [sp+20h] [bp-8h]@15 | |
393 unsigned __int16 *v20; // [sp+20h] [bp-8h]@28 | |
920 | 394 int pTextureWidth; // [sp+24h] [bp-4h]@12 |
0 | 395 unsigned __int16 *v22; // [sp+24h] [bp-4h]@25 |
396 | |
920 | 397 //v1 = this; |
0 | 398 if ( pParty->pPickedItem.uItemID ) |
399 { | |
920 | 400 pTextureID = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, TEXTURE_16BIT_PALETTE); |
401 pTexture = (Texture *)(pTextureID != -1 ? (int)&pIcons_LOD->pTextures[pTextureID] : 0); | |
1038 | 402 |
0 | 403 v4 = pMouse->uMouseClickX; |
404 v5 = pMouse->uMouseClickY; | |
1038 | 405 |
0 | 406 v6 = v5; |
407 a2 = v4; | |
408 v15 = v5; | |
409 if ( (signed int)v4 <= 639 && (signed int)v5 <= 479 ) | |
410 { | |
411 if ( (v4 & 0x80000000u) != 0 ) | |
412 a2 = 0; | |
413 if ( (v5 & 0x80000000u) != 0 ) | |
414 { | |
415 v6 = 0; | |
416 v15 = 0; | |
417 } | |
920 | 418 if ( (signed int)(pTexture->uTextureWidth + a2) <= 640 ) |
419 pTextureWidth = pTexture->uTextureWidth; | |
0 | 420 else |
920 | 421 pTextureWidth = 640 - a2; |
422 if ( (signed int)(pTexture->uTextureHeight + v6) <= 480 ) | |
0 | 423 { |
920 | 424 v19 = pTexture->uTextureHeight; |
425 v7 = pTexture->uTextureHeight; | |
0 | 426 } |
427 else | |
428 { | |
429 v7 = 480 - v6; | |
430 v19 = 480 - v6; | |
431 } | |
920 | 432 if ( !this->pCursorBitmap3_sysmembits_16bit |
433 || a2 != this->field_40 | |
434 || v6 != this->field_44 | |
435 || a2 + pTextureWidth != this->field_48 | |
436 || v6 + v7 != this->field_4C ) | |
0 | 437 { |
920 | 438 if ( this->pCursorBitmap3_sysmembits_16bit ) |
439 free(this->pCursorBitmap3_sysmembits_16bit); | |
440 this->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)operator new(2 * pTexture->uTextureHeight * pTexture->uTextureWidth); | |
441 this->field_40 = a2; | |
442 this->field_48 = a2 + pTextureWidth; | |
443 this->field_44 = v6; | |
444 this->field_4C = v6 + v19; | |
0 | 445 } |
920 | 446 v8 = this->field_44; |
447 v22 = this->pCursorBitmap3_sysmembits_16bit; | |
0 | 448 v17 = pRenderer->pTargetSurface; |
449 v16 = pRenderer->uTargetSurfacePitch; | |
920 | 450 if ( v8 < this->field_4C ) |
0 | 451 { |
920 | 452 v9 = this->field_48; |
0 | 453 v10 = pRenderer->uTargetSurfacePitch * v8; |
454 do | |
455 { | |
920 | 456 v11 = this->field_40; |
457 v18 = this->field_40; | |
0 | 458 if ( v11 < v9 ) |
459 { | |
460 v20 = &v17[v10 + v11]; | |
461 do | |
462 { | |
463 v12 = v20; | |
464 v13 = v22; | |
465 ++v18; | |
466 ++v20; | |
467 ++v22; | |
468 *v13 = *v12; | |
920 | 469 v9 = this->field_48; |
0 | 470 } |
471 while ( v18 < v9 ); | |
472 } | |
473 v10 += v16; | |
474 ++v8; | |
475 } | |
920 | 476 while ( v8 < this->field_4C ); |
0 | 477 v6 = v15; |
478 } | |
315 | 479 if (pParty->pPickedItem.Broken()) |
920 | 480 pRenderer->DrawTransparentRedShade(a2, v6, pTexture); |
315 | 481 else if (!pParty->pPickedItem.Identified()) |
920 | 482 pRenderer->DrawTransparentGreenShade(a2, v6, pTexture); |
0 | 483 else |
920 | 484 pRenderer->DrawTextureTransparent(a2, v6, pTexture); |
0 | 485 } |
486 } | |
487 else | |
488 { | |
489 if ( this->pCursorBitmap3_sysmembits_16bit ) | |
490 { | |
491 free(this->pCursorBitmap3_sysmembits_16bit); | |
920 | 492 this->pCursorBitmap3_sysmembits_16bit = 0; |
0 | 493 } |
494 } | |
495 } | |
496 | |
497 //----- (0046A080) -------------------------------------------------------- | |
498 void Mouse::Activate(int bActive) | |
499 { | |
500 bActive = bActive; | |
501 } | |
502 | |
503 //----- (0046A08A) -------------------------------------------------------- | |
504 void Mouse::SetMouseClick(int x, int y) | |
505 { | |
506 uMouseClickX = x; | |
507 uMouseClickY = y; | |
508 } | |
1296 | 509 //----- (004175C0) -------------------------------------------------------- |
510 void UI_OnMouseLeftClick(int *pXY) | |
511 { | |
512 int *pXY_; // esi@1 | |
513 signed int y; // eax@7 | |
514 signed int x; // ecx@7 | |
515 unsigned int v4; // eax@11 | |
516 signed int v5; // eax@17 | |
517 signed int v6; // esi@19 | |
518 int v7; // esi@30 | |
519 GUIWindow *v8; // edx@31 | |
520 GUIButton *i; // esi@37 | |
521 signed int v10; // eax@50 | |
522 int v11; // ecx@52 | |
523 unsigned int pX; // [sp+14h] [bp-8h]@7 | |
524 unsigned int pY; // [sp+18h] [bp-4h]@7 | |
0 | 525 |
1296 | 526 pXY_ = pXY; |
527 if ( pCurrentScreen == SCREEN_VIDEO | |
528 || sub_4637E0_is_there_popup_onscreen() ) | |
529 return; | |
530 if ( pGUIWindow2 && pGUIWindow2->ptr_1C == (void *)33 ) | |
531 { | |
532 sub_4452BB(); | |
533 return; | |
534 } | |
535 if ( pXY_ ) | |
536 { | |
537 x = *pXY_; | |
538 y = pXY_[1]; | |
539 pX = *pXY_; | |
540 pY = y; | |
541 } | |
542 else | |
543 { | |
544 pMouse->GetClickPos(&pX, &pY); | |
545 y = pY; | |
546 x = pX; | |
547 } | |
548 if ( pCurrentScreen != SCREEN_GAME || !dword_507B98_ctrl_pressed ) | |
549 goto LABEL_30; | |
550 v4 = GetCurrentMenuID(); | |
551 x = pX; | |
552 if ( (v4 & 0x80000000u) == 0 | |
553 || (signed int)pX < (signed int)pViewport->uViewportTL_X | |
554 || (signed int)pX > (signed int)pViewport->uViewportBR_X ) | |
555 { | |
556 y = pY; | |
557 LABEL_30: | |
558 v7 = uNumVisibleWindows; | |
559 if ( uNumVisibleWindows < 0 ) | |
560 return; | |
561 while ( 1 ) | |
562 { | |
563 //v8 = (GUIWindow *)&pWindowList_at_506F50_minus1_indexing[21 * pVisibleWindowsIdxs[v7]]; | |
564 v8 = &pWindowList[pVisibleWindowsIdxs[v7] - 1]; | |
565 if ( x >= (signed int)v8->uFrameX ) | |
566 { | |
567 if ( x <= (signed int)v8->uFrameZ && y >= (signed int)v8->uFrameY && y <= (signed int)v8->uFrameW ) | |
568 break; | |
569 } | |
570 --v7; | |
571 if ( v7 < 0 ) | |
572 return; | |
573 } | |
574 for ( i = v8->pControlsHead; ; i = i->pNext ) | |
575 { | |
576 if ( !i ) | |
577 return; | |
578 if ( i->uButtonType == 1 ) | |
579 goto LABEL_41; | |
580 if ( i->uButtonType != 2 ) | |
581 break; | |
582 if ( (signed int)(signed __int64)sqrt((double)((x - i->uX) * (x - i->uX) + (y - i->uY) * (y - i->uY))) < (signed int)i->uWidth ) | |
583 goto LABEL_50; | |
584 y = pY; | |
585 x = pX; | |
586 LABEL_45: | |
587 ; | |
588 } | |
589 if ( i->uButtonType != 3 ) | |
590 goto LABEL_45; | |
591 LABEL_41: | |
592 if ( x >= (signed int)i->uX && x <= (signed int)i->uZ && y >= (signed int)i->uY && y <= (signed int)i->uW ) | |
593 { | |
594 LABEL_50: | |
595 i->field_2C_is_pushed = 1; | |
596 v10 = pMessageQueue_50CBD0->uNumMessages; | |
597 if ( pMessageQueue_50CBD0->uNumMessages ) | |
598 { | |
599 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
600 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
601 } | |
602 //v11 = i->uControlParam; | |
603 pMessageQueue_50CBD0->AddMessage(i->msg, i->msg_param, 0); | |
604 return; | |
605 } | |
606 goto LABEL_45; | |
607 } | |
608 y = pY; | |
609 if ( (signed int)pY < (signed int)pViewport->uViewportTL_Y || (signed int)pY > (signed int)pViewport->uViewportBR_Y ) | |
610 goto LABEL_30; | |
611 if ( pRenderer->pRenderD3D ) | |
612 v5 = pGame->pVisInstance->get_picked_object_zbuf_val(); | |
613 else | |
614 v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; | |
615 v6 = (unsigned __int16)v5; | |
616 if (PID_TYPE(v5) == OBJECT_Actor | |
617 && uActiveCharacter | |
618 && v5 < 0x2000000 | |
619 && pPlayers[uActiveCharacter]->CanAct() | |
620 && pPlayers[uActiveCharacter]->CanSteal() ) | |
621 { | |
622 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
623 { | |
624 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_1B; | |
625 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6 >> 3; | |
626 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
627 ++pMessageQueue_50CBD0->uNumMessages; | |
628 }*/ | |
629 pMessageQueue_50CBD0->AddMessage(UIMSG_1B, PID_ID(v6), 0); | |
630 | |
631 if ( pParty->bTurnBasedModeOn == 1 ) | |
632 { | |
1340 | 633 if ( pTurnEngine->turn_stage == 3 ) |
1332 | 634 pTurnEngine->field_18 |= TE_FLAG_8; |
1296 | 635 } |
636 } | |
637 } | |
638 | |
639 | |
640 | |
641 //----- (00417871) -------------------------------------------------------- | |
642 void __thiscall sub_417871(int *pXY) | |
643 { | |
644 POINT v1; // [sp+0h] [bp-18h]@5 | |
645 POINT a2; // [sp+8h] [bp-10h]@5 | |
646 unsigned int pY; // [sp+10h] [bp-8h]@3 | |
647 unsigned int pX; // [sp+14h] [bp-4h]@3 | |
648 | |
649 if ( !pRenderer->pRenderD3D ) | |
650 { | |
651 if ( pXY ) | |
652 { | |
653 pX = *pXY; | |
654 pY = pXY[1]; | |
655 } | |
656 else | |
657 { | |
658 pMouse->GetClickPos(&pX, &pY); | |
659 } | |
660 pMouse->GetCursorPos(&a2); | |
661 pMouse->GetCursorPos(&v1); | |
662 } | |
663 } | |
1297 | 664 //----- (0041CD4F) -------------------------------------------------------- |
665 bool UI_OnKeyDown(unsigned int vkKey) | |
666 { | |
667 //unsigned int v1; // edi@1 | |
668 //unsigned int v2; // eax@2 | |
669 int v3; // esi@3 | |
670 int v4; // ecx@10 | |
671 GUIButton *pButton; // eax@11 | |
672 int v6; // edx@12 | |
673 int v7; // ecx@20 | |
674 char v8; // zf@21 | |
675 //GUIButton *v9; // ecx@24 | |
676 int v10; // esi@24 | |
677 //int v11; // edx@26 | |
678 int v12; // edx@28 | |
679 int v13; // esi@32 | |
680 //GUIButton *v14; // eax@37 | |
681 int v15; // edx@38 | |
682 int v17; // ecx@50 | |
683 int v18; // edx@50 | |
684 //GUIButton *v19; // ecx@54 | |
685 int v20; // esi@54 | |
686 //int v21; // edx@56 | |
687 int v22; // ecx@59 | |
688 int v23; // edx@59 | |
689 int v24; // ecx@60 | |
690 int v25; // esi@63 | |
691 //unsigned int v26; // [sp+Ch] [bp-14h]@1 | |
692 //int v27; // [sp+10h] [bp-10h]@1 | |
693 int v28; // [sp+14h] [bp-Ch]@10 | |
694 int v29; // [sp+14h] [bp-Ch]@36 | |
695 unsigned int uClickX; // [sp+18h] [bp-8h]@10 | |
696 unsigned int uClickY; // [sp+1Ch] [bp-4h]@10 | |
697 | |
698 //v1 = 0; | |
699 //v27 = uNumVisibleWindows; | |
700 if ( uNumVisibleWindows < 0 ) | |
701 return false; | |
702 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
703 for (int i = uNumVisibleWindows; i >= 0; --i) | |
704 //while ( 1 ) | |
705 { | |
706 v3 = pVisibleWindowsIdxs[i] - 1; | |
707 if (!pWindowList[v3].receives_keyboard_input) | |
708 continue; | |
709 | |
710 switch (vkKey) | |
711 { | |
712 case VK_LEFT: | |
713 { | |
714 v12 = pWindowList[v3].field_34; | |
715 if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 ) | |
716 { | |
717 v8 = pCurrentScreen == SCREEN_PARTY_CREATION; | |
718 pWindowList[v3].pCurrentPosActiveItem -= v12; | |
719 if ( v8 ) | |
720 { | |
721 pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); | |
722 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
723 } | |
724 } | |
725 if ( pWindowList[v3].field_30 != 0 ) | |
726 { | |
727 break; | |
728 } | |
729 pButton = pWindowList[v3].pControlsHead; | |
730 v13 = pWindowList[v3].pCurrentPosActiveItem; | |
731 if ( v13 > 0) | |
732 { | |
733 do | |
734 { | |
735 pButton = pButton->pNext; | |
736 --v13; | |
737 } | |
738 while ( v13 ); | |
739 } | |
740 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
741 break; | |
742 } | |
743 case VK_RIGHT: | |
744 { | |
745 v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34; | |
746 if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem ) | |
747 { | |
748 v8 = pCurrentScreen == SCREEN_PARTY_CREATION; | |
749 pWindowList[v3].pCurrentPosActiveItem = v7; | |
750 if ( v8 ) | |
751 { | |
752 pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); | |
753 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
754 } | |
755 } | |
756 if ( pWindowList[v3].field_30 != 0 ) | |
757 { | |
758 break; | |
759 } | |
760 pButton = pWindowList[v3].pControlsHead; | |
761 v10 = pWindowList[v3].pCurrentPosActiveItem; | |
762 if ( v10 > 0) | |
763 { | |
764 do | |
765 { | |
766 pButton = pButton->pNext; | |
767 --v10; | |
768 } | |
769 while ( v10 ); | |
770 } | |
771 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
772 break; | |
773 } | |
774 case VK_DOWN: | |
775 { | |
776 v17 = pWindowList[v3].pStartingPosActiveItem; | |
777 v18 = pWindowList[v3].pCurrentPosActiveItem; | |
778 if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 ) | |
779 pWindowList[v3].pCurrentPosActiveItem = v17; | |
780 else | |
781 pWindowList[v3].pCurrentPosActiveItem = v18 + 1; | |
782 if ( pWindowList[v3].field_30 != 0 ) | |
783 return true; | |
784 pButton = pWindowList[v3].pControlsHead; | |
785 v20 = pWindowList[v3].pCurrentPosActiveItem; | |
786 if ( v20 > 0) | |
787 { | |
788 do | |
789 { | |
790 pButton = pButton->pNext; | |
791 --v20; | |
792 } | |
793 while ( v20 ); | |
794 } | |
795 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
796 return true; | |
797 } | |
798 case VK_SELECT: | |
799 { | |
800 pMouse->GetClickPos(&uClickX, &uClickY); | |
801 v4 = pWindowList[v3].pStartingPosActiveItem; | |
802 v28 = v4 + pWindowList[v3].pNumPresenceButton; | |
803 if ( v4 < v4 + pWindowList[v3].pNumPresenceButton ) | |
804 { | |
805 while ( 1 ) | |
806 { | |
807 pButton = pWindowList[v3].pControlsHead; | |
808 if ( v4 > 0 ) | |
809 { | |
810 v6 = v4; | |
811 do | |
812 { | |
813 pButton = pButton->pNext; | |
814 --v6; | |
815 } | |
816 while ( v6 ); | |
817 } | |
818 if ( (signed int)uClickX >= (signed int)pButton->uX//test for StatsTab in PlayerCreation Window | |
819 && (signed int)uClickX <= (signed int)pButton->uZ | |
820 && (signed int)uClickY >= (signed int)pButton->uY | |
821 && (signed int)uClickY <= (signed int)pButton->uW ) | |
822 break; | |
823 ++v4; | |
824 if ( v4 >= v28 ) | |
825 { | |
826 //v1 = 0; | |
827 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
828 //--i; | |
829 //if ( i < 0 ) | |
830 return false; | |
831 //continue; | |
832 } | |
833 } | |
834 pWindowList[v3].pCurrentPosActiveItem = v4; | |
835 return true; | |
836 } | |
837 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
838 break; | |
839 } | |
840 case VK_UP: | |
841 { | |
842 v22 = pWindowList[v3].pCurrentPosActiveItem; | |
843 v23 = pWindowList[v3].pStartingPosActiveItem; | |
844 if ( v22 <= v23 ) | |
845 v24 = pWindowList[v3].pNumPresenceButton + v23 - 1; | |
846 else | |
847 v24 = v22 - 1; | |
848 v8 = pWindowList[v3].field_30 == 0; | |
849 pWindowList[v3].pCurrentPosActiveItem = v24; | |
850 if ( !v8 ) | |
851 return true; | |
852 pButton = pWindowList[v3].pControlsHead; | |
853 v25 = pWindowList[v3].pCurrentPosActiveItem; | |
854 if ( v25 > 0) | |
855 { | |
856 do | |
857 { | |
858 pButton = pButton->pNext; | |
859 --v25; | |
860 } | |
861 while ( v25 ); | |
862 } | |
863 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
864 return true; | |
865 } | |
866 case VK_NEXT: | |
867 { | |
868 //if ( pWindowList[v3].field_30 != 0 ) //crashed at skill draw | |
869 //{ | |
870 // pMouse->GetClickPos(&uClickX, &uClickY); | |
871 // v4 = pWindowList[v3].pStartingPosActiveItem; | |
872 // v29 = v4 + pWindowList[v3].pNumPresenceButton; //num buttons more than buttons | |
873 // if ( v4 < v29 ) | |
874 // { | |
875 // while ( 1 ) | |
876 // { | |
877 // pButton = pWindowList[v3].pControlsHead; | |
878 // if ( v4 > 0 ) | |
879 // { | |
880 // v15 = v4; | |
881 // do | |
882 // { | |
883 // pButton = pButton->pNext; | |
884 // --v15; | |
885 // } | |
886 // while ( v15 ); | |
887 // } | |
888 // if ( (signed int)uClickX >= (signed int)pButton->uX | |
889 // && (signed int)uClickX <= (signed int)pButton->uZ | |
890 // && (signed int)uClickY >= (signed int)pButton->uY | |
891 // && (signed int)uClickY <= (signed int)pButton->uW ) | |
892 // { | |
893 // pWindowList[v3].pCurrentPosActiveItem = v4; | |
894 // return true; | |
895 // } | |
896 // ++v4; | |
897 // if ( v4 >= v29 ) | |
898 // { | |
899 // //v1 = 0; | |
900 // //v2 = pMessageQueue_50CBD0->uNumMessages; | |
901 // break; | |
902 // } | |
903 // } | |
904 // } | |
905 // else | |
906 // { | |
907 // //v2 = pMessageQueue_50CBD0->uNumMessages; | |
908 // } | |
909 //} | |
910 break; | |
911 } | |
912 default: | |
913 { | |
914 break; | |
915 } | |
916 } | |
917 } | |
918 } |