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