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