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