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