Mercurial > mm7
annotate Mouse.cpp @ 2069:259df09dfb50
32bits almost there
author | Nomad |
---|---|
date | Tue, 03 Dec 2013 20:18:17 +0200 |
parents | 30c2b575d25c |
children | 52415f8bf7c2 |
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) | |
2069 | 335 //pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++; |
336 pRenderer->WritePixel16(x, y, *pSrc++); | |
0 | 337 } |
338 | |
339 //----- (00469EA4) -------------------------------------------------------- | |
340 void Mouse::_469EA4() | |
341 { | |
920 | 342 //Mouse *v1; // esi@1 |
343 unsigned int pTextureID; // eax@2 | |
344 Texture *pTexture; // edi@2 | |
0 | 345 unsigned int v4; // ecx@3 |
346 unsigned int v5; // eax@3 | |
347 unsigned int v6; // ebx@5 | |
348 int v7; // ecx@15 | |
349 int v8; // ecx@25 | |
350 int v9; // ebx@26 | |
351 unsigned int v10; // eax@26 | |
352 int v11; // edx@27 | |
2069 | 353 //unsigned __int16 *v12; // edx@29 |
354 //unsigned __int16 *v13; // ebx@29 | |
0 | 355 unsigned int a2; // [sp+Ch] [bp-1Ch]@5 |
356 unsigned int v15; // [sp+10h] [bp-18h]@5 | |
2069 | 357 //unsigned int v16; // [sp+14h] [bp-14h]@25 |
358 //unsigned __int16 *v17; // [sp+18h] [bp-10h]@25 | |
359 //int v18; // [sp+1Ch] [bp-Ch]@27 | |
0 | 360 int v19; // [sp+20h] [bp-8h]@15 |
361 unsigned __int16 *v20; // [sp+20h] [bp-8h]@28 | |
920 | 362 int pTextureWidth; // [sp+24h] [bp-4h]@12 |
0 | 363 unsigned __int16 *v22; // [sp+24h] [bp-4h]@25 |
364 | |
920 | 365 //v1 = this; |
0 | 366 if ( pParty->pPickedItem.uItemID ) |
367 { | |
1709
8251e59fd7c1
ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
Grumpy7
parents:
1687
diff
changeset
|
368 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE); |
920 | 369 pTexture = (Texture *)(pTextureID != -1 ? (int)&pIcons_LOD->pTextures[pTextureID] : 0); |
1038 | 370 |
0 | 371 v4 = pMouse->uMouseClickX; |
372 v5 = pMouse->uMouseClickY; | |
1038 | 373 |
0 | 374 v6 = v5; |
375 a2 = v4; | |
376 v15 = v5; | |
377 if ( (signed int)v4 <= 639 && (signed int)v5 <= 479 ) | |
378 { | |
379 if ( (v4 & 0x80000000u) != 0 ) | |
380 a2 = 0; | |
381 if ( (v5 & 0x80000000u) != 0 ) | |
382 { | |
383 v6 = 0; | |
384 v15 = 0; | |
385 } | |
920 | 386 if ( (signed int)(pTexture->uTextureWidth + a2) <= 640 ) |
387 pTextureWidth = pTexture->uTextureWidth; | |
0 | 388 else |
920 | 389 pTextureWidth = 640 - a2; |
390 if ( (signed int)(pTexture->uTextureHeight + v6) <= 480 ) | |
0 | 391 { |
920 | 392 v19 = pTexture->uTextureHeight; |
393 v7 = pTexture->uTextureHeight; | |
0 | 394 } |
395 else | |
396 { | |
397 v7 = 480 - v6; | |
398 v19 = 480 - v6; | |
399 } | |
920 | 400 if ( !this->pCursorBitmap3_sysmembits_16bit |
401 || a2 != this->field_40 | |
402 || v6 != this->field_44 | |
403 || a2 + pTextureWidth != this->field_48 | |
404 || v6 + v7 != this->field_4C ) | |
0 | 405 { |
920 | 406 if ( this->pCursorBitmap3_sysmembits_16bit ) |
407 free(this->pCursorBitmap3_sysmembits_16bit); | |
1631 | 408 this->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)malloc(2 * pTexture->uTextureHeight * pTexture->uTextureWidth); |
920 | 409 this->field_40 = a2; |
410 this->field_48 = a2 + pTextureWidth; | |
411 this->field_44 = v6; | |
412 this->field_4C = v6 + v19; | |
0 | 413 } |
920 | 414 v8 = this->field_44; |
415 v22 = this->pCursorBitmap3_sysmembits_16bit; | |
2069 | 416 //v17 = pRenderer->pTargetSurface; |
417 //v16 = pRenderer->uTargetSurfacePitch; | |
418 | |
419 v10 = pRenderer->uTargetSurfacePitch * v8; | |
420 v11 = this->field_40; | |
421 for (int y = this->field_44; y < this->field_4C; ++y) | |
422 { | |
423 //v20 = &v17[v10 + v11]; | |
424 for (int x = this->field_40; x < this->field_48; ++x) | |
425 { | |
426 //++v18; | |
427 *v22++ = pRenderer->ReadPixel16(x, y); | |
428 } | |
429 } | |
430 /*if ( v8 < this->field_4C ) | |
0 | 431 { |
920 | 432 v9 = this->field_48; |
0 | 433 v10 = pRenderer->uTargetSurfacePitch * v8; |
434 do | |
435 { | |
920 | 436 v11 = this->field_40; |
437 v18 = this->field_40; | |
0 | 438 if ( v11 < v9 ) |
439 { | |
440 v20 = &v17[v10 + v11]; | |
441 do | |
442 { | |
2069 | 443 //v12 = v20; |
0 | 444 ++v18; |
2069 | 445 //++v20; |
446 *v22++ = *v20++; | |
0 | 447 } |
448 while ( v18 < v9 ); | |
449 } | |
450 v10 += v16; | |
451 ++v8; | |
452 } | |
920 | 453 while ( v8 < this->field_4C ); |
0 | 454 v6 = v15; |
2069 | 455 }*/ |
456 | |
457 v6 = v15; | |
1567
9f8b3e904e14
Player::ReceiveDamage, very small edits; prepended "Is" to item functions returning bool values (broken, indetified, stolen)
Grumpy7
parents:
1458
diff
changeset
|
458 if (pParty->pPickedItem.IsBroken()) |
920 | 459 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
|
460 else if (!pParty->pPickedItem.IsIdentified()) |
920 | 461 pRenderer->DrawTransparentGreenShade(a2, v6, pTexture); |
0 | 462 else |
920 | 463 pRenderer->DrawTextureTransparent(a2, v6, pTexture); |
0 | 464 } |
465 } | |
466 else | |
467 { | |
468 if ( this->pCursorBitmap3_sysmembits_16bit ) | |
469 { | |
470 free(this->pCursorBitmap3_sysmembits_16bit); | |
920 | 471 this->pCursorBitmap3_sysmembits_16bit = 0; |
0 | 472 } |
473 } | |
474 } | |
475 | |
476 //----- (0046A080) -------------------------------------------------------- | |
477 void Mouse::Activate(int bActive) | |
478 { | |
479 bActive = bActive; | |
480 } | |
481 | |
482 //----- (0046A08A) -------------------------------------------------------- | |
483 void Mouse::SetMouseClick(int x, int y) | |
484 { | |
485 uMouseClickX = x; | |
486 uMouseClickY = y; | |
487 } | |
1296 | 488 //----- (004175C0) -------------------------------------------------------- |
489 void UI_OnMouseLeftClick(int *pXY) | |
490 { | |
491 int *pXY_; // esi@1 | |
492 signed int y; // eax@7 | |
493 signed int x; // ecx@7 | |
2006 | 494 signed int v4; // eax@11 |
1296 | 495 signed int v5; // eax@17 |
496 signed int v6; // esi@19 | |
497 int v7; // esi@30 | |
498 GUIWindow *v8; // edx@31 | |
499 GUIButton *i; // esi@37 | |
500 signed int v10; // eax@50 | |
501 int v11; // ecx@52 | |
502 unsigned int pX; // [sp+14h] [bp-8h]@7 | |
503 unsigned int pY; // [sp+18h] [bp-4h]@7 | |
0 | 504 |
1296 | 505 pXY_ = pXY; |
506 if ( pCurrentScreen == SCREEN_VIDEO | |
507 || sub_4637E0_is_there_popup_onscreen() ) | |
508 return; | |
509 if ( pGUIWindow2 && pGUIWindow2->ptr_1C == (void *)33 ) | |
510 { | |
511 sub_4452BB(); | |
512 return; | |
513 } | |
514 if ( pXY_ ) | |
515 { | |
516 x = *pXY_; | |
517 y = pXY_[1]; | |
518 pX = *pXY_; | |
519 pY = y; | |
520 } | |
521 else | |
522 { | |
523 pMouse->GetClickPos(&pX, &pY); | |
524 y = pY; | |
525 x = pX; | |
526 } | |
1830 | 527 |
528 extern bool _507B98_ctrl_pressed; | |
529 if ( pCurrentScreen != SCREEN_GAME || !_507B98_ctrl_pressed ) // stealing cursor | |
1296 | 530 goto LABEL_30; |
531 v4 = GetCurrentMenuID(); | |
532 x = pX; | |
2006 | 533 if ( v4 != -1 |
1296 | 534 || (signed int)pX < (signed int)pViewport->uViewportTL_X |
535 || (signed int)pX > (signed int)pViewport->uViewportBR_X ) | |
536 { | |
537 y = pY; | |
538 LABEL_30: | |
539 v7 = uNumVisibleWindows; | |
540 if ( uNumVisibleWindows < 0 ) | |
541 return; | |
542 while ( 1 ) | |
543 { | |
544 //v8 = (GUIWindow *)&pWindowList_at_506F50_minus1_indexing[21 * pVisibleWindowsIdxs[v7]]; | |
545 v8 = &pWindowList[pVisibleWindowsIdxs[v7] - 1]; | |
546 if ( x >= (signed int)v8->uFrameX ) | |
547 { | |
548 if ( x <= (signed int)v8->uFrameZ && y >= (signed int)v8->uFrameY && y <= (signed int)v8->uFrameW ) | |
549 break; | |
550 } | |
551 --v7; | |
552 if ( v7 < 0 ) | |
553 return; | |
554 } | |
555 for ( i = v8->pControlsHead; ; i = i->pNext ) | |
556 { | |
557 if ( !i ) | |
558 return; | |
559 if ( i->uButtonType == 1 ) | |
560 goto LABEL_41; | |
561 if ( i->uButtonType != 2 ) | |
562 break; | |
563 if ( (signed int)(signed __int64)sqrt((double)((x - i->uX) * (x - i->uX) + (y - i->uY) * (y - i->uY))) < (signed int)i->uWidth ) | |
564 goto LABEL_50; | |
565 y = pY; | |
566 x = pX; | |
567 LABEL_45: | |
568 ; | |
569 } | |
570 if ( i->uButtonType != 3 ) | |
571 goto LABEL_45; | |
572 LABEL_41: | |
573 if ( x >= (signed int)i->uX && x <= (signed int)i->uZ && y >= (signed int)i->uY && y <= (signed int)i->uW ) | |
574 { | |
575 LABEL_50: | |
576 i->field_2C_is_pushed = 1; | |
577 v10 = pMessageQueue_50CBD0->uNumMessages; | |
578 if ( pMessageQueue_50CBD0->uNumMessages ) | |
579 { | |
580 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
581 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
582 } | |
583 //v11 = i->uControlParam; | |
584 pMessageQueue_50CBD0->AddMessage(i->msg, i->msg_param, 0); | |
585 return; | |
586 } | |
587 goto LABEL_45; | |
588 } | |
589 y = pY; | |
590 if ( (signed int)pY < (signed int)pViewport->uViewportTL_Y || (signed int)pY > (signed int)pViewport->uViewportBR_Y ) | |
591 goto LABEL_30; | |
592 if ( pRenderer->pRenderD3D ) | |
593 v5 = pGame->pVisInstance->get_picked_object_zbuf_val(); | |
594 else | |
595 v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; | |
596 v6 = (unsigned __int16)v5; | |
1830 | 597 |
1980 | 598 uint type = PID_TYPE(v6); |
1830 | 599 if (type == OBJECT_Actor |
1296 | 600 && uActiveCharacter |
601 && v5 < 0x2000000 | |
602 && pPlayers[uActiveCharacter]->CanAct() | |
603 && pPlayers[uActiveCharacter]->CanSteal() ) | |
604 { | |
605 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
606 { | |
607 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_1B; | |
608 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6 >> 3; | |
609 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
610 ++pMessageQueue_50CBD0->uNumMessages; | |
611 }*/ | |
1687
5f01f1ed97f4
Player::StealFromActor cleanup, renamed UIMSG_1B to UIMSG_STEALFROMACTOR
Grumpy7
parents:
1631
diff
changeset
|
612 pMessageQueue_50CBD0->AddMessage(UIMSG_STEALFROMACTOR, PID_ID(v6), 0); |
1296 | 613 |
614 if ( pParty->bTurnBasedModeOn == 1 ) | |
615 { | |
1340 | 616 if ( pTurnEngine->turn_stage == 3 ) |
1332 | 617 pTurnEngine->field_18 |= TE_FLAG_8; |
1296 | 618 } |
619 } | |
620 } | |
621 | |
622 | |
1297 | 623 //----- (0041CD4F) -------------------------------------------------------- |
624 bool UI_OnKeyDown(unsigned int vkKey) | |
625 { | |
626 //unsigned int v1; // edi@1 | |
627 //unsigned int v2; // eax@2 | |
628 int v3; // esi@3 | |
629 int v4; // ecx@10 | |
630 GUIButton *pButton; // eax@11 | |
631 int v6; // edx@12 | |
632 int v7; // ecx@20 | |
633 char v8; // zf@21 | |
634 //GUIButton *v9; // ecx@24 | |
635 int v10; // esi@24 | |
636 //int v11; // edx@26 | |
637 int v12; // edx@28 | |
638 int v13; // esi@32 | |
639 //GUIButton *v14; // eax@37 | |
640 int v15; // edx@38 | |
641 int v17; // ecx@50 | |
642 int v18; // edx@50 | |
643 //GUIButton *v19; // ecx@54 | |
644 int v20; // esi@54 | |
645 //int v21; // edx@56 | |
646 int v22; // ecx@59 | |
647 int v23; // edx@59 | |
648 int v24; // ecx@60 | |
649 int v25; // esi@63 | |
650 //unsigned int v26; // [sp+Ch] [bp-14h]@1 | |
651 //int v27; // [sp+10h] [bp-10h]@1 | |
652 int v28; // [sp+14h] [bp-Ch]@10 | |
653 int v29; // [sp+14h] [bp-Ch]@36 | |
654 unsigned int uClickX; // [sp+18h] [bp-8h]@10 | |
655 unsigned int uClickY; // [sp+1Ch] [bp-4h]@10 | |
656 | |
657 //v1 = 0; | |
658 //v27 = uNumVisibleWindows; | |
659 if ( uNumVisibleWindows < 0 ) | |
660 return false; | |
661 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
662 for (int i = uNumVisibleWindows; i >= 0; --i) | |
663 //while ( 1 ) | |
664 { | |
665 v3 = pVisibleWindowsIdxs[i] - 1; | |
666 if (!pWindowList[v3].receives_keyboard_input) | |
667 continue; | |
668 | |
669 switch (vkKey) | |
670 { | |
671 case VK_LEFT: | |
672 { | |
673 v12 = pWindowList[v3].field_34; | |
674 if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 ) | |
675 { | |
676 v8 = pCurrentScreen == SCREEN_PARTY_CREATION; | |
677 pWindowList[v3].pCurrentPosActiveItem -= v12; | |
678 if ( v8 ) | |
679 { | |
680 pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); | |
681 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
682 } | |
683 } | |
684 if ( pWindowList[v3].field_30 != 0 ) | |
685 { | |
686 break; | |
687 } | |
688 pButton = pWindowList[v3].pControlsHead; | |
689 v13 = pWindowList[v3].pCurrentPosActiveItem; | |
690 if ( v13 > 0) | |
691 { | |
692 do | |
693 { | |
694 pButton = pButton->pNext; | |
695 --v13; | |
696 } | |
697 while ( v13 ); | |
698 } | |
699 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
700 break; | |
701 } | |
702 case VK_RIGHT: | |
703 { | |
704 v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34; | |
705 if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem ) | |
706 { | |
707 v8 = pCurrentScreen == SCREEN_PARTY_CREATION; | |
708 pWindowList[v3].pCurrentPosActiveItem = v7; | |
709 if ( v8 ) | |
710 { | |
711 pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); | |
712 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
713 } | |
714 } | |
715 if ( pWindowList[v3].field_30 != 0 ) | |
716 { | |
717 break; | |
718 } | |
719 pButton = pWindowList[v3].pControlsHead; | |
720 v10 = pWindowList[v3].pCurrentPosActiveItem; | |
721 if ( v10 > 0) | |
722 { | |
723 do | |
724 { | |
725 pButton = pButton->pNext; | |
726 --v10; | |
727 } | |
728 while ( v10 ); | |
729 } | |
730 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
731 break; | |
732 } | |
733 case VK_DOWN: | |
734 { | |
735 v17 = pWindowList[v3].pStartingPosActiveItem; | |
736 v18 = pWindowList[v3].pCurrentPosActiveItem; | |
737 if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 ) | |
738 pWindowList[v3].pCurrentPosActiveItem = v17; | |
739 else | |
740 pWindowList[v3].pCurrentPosActiveItem = v18 + 1; | |
741 if ( pWindowList[v3].field_30 != 0 ) | |
742 return true; | |
743 pButton = pWindowList[v3].pControlsHead; | |
744 v20 = pWindowList[v3].pCurrentPosActiveItem; | |
745 if ( v20 > 0) | |
746 { | |
747 do | |
748 { | |
749 pButton = pButton->pNext; | |
750 --v20; | |
751 } | |
752 while ( v20 ); | |
753 } | |
754 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
755 return true; | |
756 } | |
757 case VK_SELECT: | |
758 { | |
759 pMouse->GetClickPos(&uClickX, &uClickY); | |
760 v4 = pWindowList[v3].pStartingPosActiveItem; | |
761 v28 = v4 + pWindowList[v3].pNumPresenceButton; | |
762 if ( v4 < v4 + pWindowList[v3].pNumPresenceButton ) | |
763 { | |
764 while ( 1 ) | |
765 { | |
766 pButton = pWindowList[v3].pControlsHead; | |
767 if ( v4 > 0 ) | |
768 { | |
769 v6 = v4; | |
770 do | |
771 { | |
772 pButton = pButton->pNext; | |
773 --v6; | |
774 } | |
775 while ( v6 ); | |
776 } | |
777 if ( (signed int)uClickX >= (signed int)pButton->uX//test for StatsTab in PlayerCreation Window | |
778 && (signed int)uClickX <= (signed int)pButton->uZ | |
779 && (signed int)uClickY >= (signed int)pButton->uY | |
780 && (signed int)uClickY <= (signed int)pButton->uW ) | |
781 break; | |
782 ++v4; | |
783 if ( v4 >= v28 ) | |
784 { | |
785 //v1 = 0; | |
786 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
787 //--i; | |
788 //if ( i < 0 ) | |
789 return false; | |
790 //continue; | |
791 } | |
792 } | |
793 pWindowList[v3].pCurrentPosActiveItem = v4; | |
794 return true; | |
795 } | |
796 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
797 break; | |
798 } | |
799 case VK_UP: | |
800 { | |
801 v22 = pWindowList[v3].pCurrentPosActiveItem; | |
802 v23 = pWindowList[v3].pStartingPosActiveItem; | |
803 if ( v22 <= v23 ) | |
804 v24 = pWindowList[v3].pNumPresenceButton + v23 - 1; | |
805 else | |
806 v24 = v22 - 1; | |
807 v8 = pWindowList[v3].field_30 == 0; | |
808 pWindowList[v3].pCurrentPosActiveItem = v24; | |
809 if ( !v8 ) | |
810 return true; | |
811 pButton = pWindowList[v3].pControlsHead; | |
812 v25 = pWindowList[v3].pCurrentPosActiveItem; | |
813 if ( v25 > 0) | |
814 { | |
815 do | |
816 { | |
817 pButton = pButton->pNext; | |
818 --v25; | |
819 } | |
820 while ( v25 ); | |
821 } | |
822 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
823 return true; | |
824 } | |
825 case VK_NEXT: | |
826 { | |
827 //if ( pWindowList[v3].field_30 != 0 ) //crashed at skill draw | |
828 //{ | |
829 // pMouse->GetClickPos(&uClickX, &uClickY); | |
830 // v4 = pWindowList[v3].pStartingPosActiveItem; | |
831 // v29 = v4 + pWindowList[v3].pNumPresenceButton; //num buttons more than buttons | |
832 // if ( v4 < v29 ) | |
833 // { | |
834 // while ( 1 ) | |
835 // { | |
836 // pButton = pWindowList[v3].pControlsHead; | |
837 // if ( v4 > 0 ) | |
838 // { | |
839 // v15 = v4; | |
840 // do | |
841 // { | |
842 // pButton = pButton->pNext; | |
843 // --v15; | |
844 // } | |
845 // while ( v15 ); | |
846 // } | |
847 // if ( (signed int)uClickX >= (signed int)pButton->uX | |
848 // && (signed int)uClickX <= (signed int)pButton->uZ | |
849 // && (signed int)uClickY >= (signed int)pButton->uY | |
850 // && (signed int)uClickY <= (signed int)pButton->uW ) | |
851 // { | |
852 // pWindowList[v3].pCurrentPosActiveItem = v4; | |
853 // return true; | |
854 // } | |
855 // ++v4; | |
856 // if ( v4 >= v29 ) | |
857 // { | |
858 // //v1 = 0; | |
859 // //v2 = pMessageQueue_50CBD0->uNumMessages; | |
860 // break; | |
861 // } | |
862 // } | |
863 // } | |
864 // else | |
865 // { | |
866 // //v2 = pMessageQueue_50CBD0->uNumMessages; | |
867 // } | |
868 //} | |
869 break; | |
870 } | |
871 default: | |
872 { | |
873 break; | |
874 } | |
875 } | |
876 } | |
877 } |