Mercurial > mm7
annotate Mouse.cpp @ 2122:5b654c03a11e
for snow in house
author | Ritor1 |
---|---|
date | Wed, 25 Dec 2013 17:42:19 +0600 |
parents | 7edf389d49fc |
children | d28d3c006077 |
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 { | |
2098 | 147 //Mouse *v1; // esi@1 |
148 //void *v2; // eax@1 | |
149 //void **v3; // esi@5 | |
0 | 150 |
2098 | 151 //v1 = this; |
152 //v2 = this->pCursorBitmap_sysmem; | |
0 | 153 this->bActive = 0; |
2098 | 154 if ( this->pCursorBitmap_sysmem ) |
0 | 155 { |
2098 | 156 free(this->pCursorBitmap_sysmem); |
157 this->pCursorBitmap_sysmem = 0; | |
0 | 158 } |
2098 | 159 if ( this->pCursorBitmap2_sysmem ) |
0 | 160 { |
2098 | 161 free(this->pCursorBitmap2_sysmem); |
162 this->pCursorBitmap2_sysmem = 0; | |
0 | 163 } |
2098 | 164 //v3 = &this->ptr_90; |
165 if ( this->ptr_90 ) | |
166 free(this->ptr_90); | |
167 this->ptr_90 = 0; | |
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 signed int y; // eax@7 | |
472 signed int x; // ecx@7 | |
473 signed int v5; // eax@17 | |
2098 | 474 GUIButton *control; // esi@37 |
1296 | 475 signed int v10; // eax@50 |
476 int v11; // ecx@52 | |
477 unsigned int pX; // [sp+14h] [bp-8h]@7 | |
478 unsigned int pY; // [sp+18h] [bp-4h]@7 | |
0 | 479 |
2098 | 480 if ( pCurrentScreen == SCREEN_VIDEO || sub_4637E0_is_there_popup_onscreen() ) |
1296 | 481 return; |
482 if ( pGUIWindow2 && pGUIWindow2->ptr_1C == (void *)33 ) | |
483 { | |
484 sub_4452BB(); | |
485 return; | |
486 } | |
2098 | 487 if ( pXY ) |
1296 | 488 { |
2098 | 489 x = *pXY; |
490 y = pXY[1]; | |
491 pX = *pXY; | |
1296 | 492 pY = y; |
493 } | |
494 else | |
495 { | |
496 pMouse->GetClickPos(&pX, &pY); | |
497 y = pY; | |
498 x = pX; | |
499 } | |
1830 | 500 |
501 extern bool _507B98_ctrl_pressed; | |
1296 | 502 x = pX; |
2098 | 503 if ( GetCurrentMenuID() != -1 || pCurrentScreen != SCREEN_GAME || !_507B98_ctrl_pressed // stealing cursor |
504 || (signed int)pX < (signed int)pViewport->uViewportTL_X || (signed int)pX > (signed int)pViewport->uViewportBR_X | |
505 || (signed int)pY < (signed int)pViewport->uViewportTL_Y || (signed int)pY > (signed int)pViewport->uViewportBR_Y) | |
1296 | 506 { |
507 y = pY; | |
2098 | 508 for ( int i = uNumVisibleWindows; i >= 0; --i ) |
1296 | 509 { |
2098 | 510 if ( x >= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameX && x <= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameZ |
511 && y >= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameY && y <= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameW ) | |
512 { | |
513 for ( control = pWindowList[pVisibleWindowsIdxs[i] - 1].pControlsHead; control; control = control->pNext ) | |
514 { | |
515 if ( control->uButtonType == 1 ) | |
516 { | |
517 if ( x >= (signed int)control->uX && x <= (signed int)control->uZ && y >= (signed int)control->uY && y <= (signed int)control->uW ) | |
518 { | |
519 control->field_2C_is_pushed = 1; | |
520 v10 = pMessageQueue_50CBD0->uNumMessages; | |
521 if ( pMessageQueue_50CBD0->uNumMessages ) | |
522 { | |
523 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
524 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
525 } | |
526 pMessageQueue_50CBD0->AddMessage(control->msg, control->msg_param, 0); | |
527 return; | |
528 } | |
529 continue; | |
530 } | |
531 if ( control->uButtonType == 2 )//êîãäà íàæèìàåøü íà ïàðòðåòû ïåðñîâ | |
532 { | |
533 if ( (signed int)(signed __int64)sqrt((double)((x - control->uX) * (x - control->uX) + (y - control->uY) * (y - control->uY))) < (signed int)control->uWidth ) | |
534 { | |
535 control->field_2C_is_pushed = 1; | |
536 v10 = pMessageQueue_50CBD0->uNumMessages; | |
537 if ( pMessageQueue_50CBD0->uNumMessages ) | |
538 { | |
539 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
540 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
541 } | |
542 pMessageQueue_50CBD0->AddMessage(control->msg, control->msg_param, 0); | |
543 return; | |
544 } | |
545 continue; | |
546 } | |
547 if ( control->uButtonType == 3 )//êîãäà íàæèìàåøü íà ñêèëëû | |
548 { | |
549 if ( x >= (signed int)control->uX && x <= (signed int)control->uZ && y >= (signed int)control->uY && y <= (signed int)control->uW ) | |
550 { | |
551 control->field_2C_is_pushed = 1; | |
552 v10 = pMessageQueue_50CBD0->uNumMessages; | |
553 if ( pMessageQueue_50CBD0->uNumMessages ) | |
554 { | |
555 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
556 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
557 } | |
558 pMessageQueue_50CBD0->AddMessage(control->msg, control->msg_param, 0); | |
559 return; | |
560 } | |
561 continue; | |
562 } | |
563 y = pY; | |
564 x = pX; | |
565 } | |
566 } | |
1296 | 567 } |
2098 | 568 return; |
1296 | 569 } |
570 y = pY; | |
571 if ( pRenderer->pRenderD3D ) | |
572 v5 = pGame->pVisInstance->get_picked_object_zbuf_val(); | |
573 else | |
574 v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; | |
1830 | 575 |
2098 | 576 uint type = PID_TYPE((unsigned __int16)v5); |
577 if (type == OBJECT_Actor && uActiveCharacter && v5 < 0x2000000 | |
578 && pPlayers[uActiveCharacter]->CanAct() && pPlayers[uActiveCharacter]->CanSteal() ) | |
1296 | 579 { |
580 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
581 { | |
582 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_1B; | |
583 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6 >> 3; | |
584 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
585 ++pMessageQueue_50CBD0->uNumMessages; | |
586 }*/ | |
2098 | 587 pMessageQueue_50CBD0->AddMessage(UIMSG_STEALFROMACTOR, PID_ID((unsigned __int16)v5), 0); |
1296 | 588 |
589 if ( pParty->bTurnBasedModeOn == 1 ) | |
590 { | |
1340 | 591 if ( pTurnEngine->turn_stage == 3 ) |
1332 | 592 pTurnEngine->field_18 |= TE_FLAG_8; |
1296 | 593 } |
594 } | |
595 } | |
596 | |
597 | |
1297 | 598 //----- (0041CD4F) -------------------------------------------------------- |
599 bool UI_OnKeyDown(unsigned int vkKey) | |
600 { | |
601 //unsigned int v1; // edi@1 | |
602 //unsigned int v2; // eax@2 | |
603 int v3; // esi@3 | |
604 int v4; // ecx@10 | |
605 GUIButton *pButton; // eax@11 | |
606 int v6; // edx@12 | |
607 int v7; // ecx@20 | |
608 char v8; // zf@21 | |
609 //GUIButton *v9; // ecx@24 | |
610 int v10; // esi@24 | |
611 //int v11; // edx@26 | |
612 int v12; // edx@28 | |
613 int v13; // esi@32 | |
614 //GUIButton *v14; // eax@37 | |
615 int v15; // edx@38 | |
616 int v17; // ecx@50 | |
617 int v18; // edx@50 | |
618 //GUIButton *v19; // ecx@54 | |
619 int v20; // esi@54 | |
620 //int v21; // edx@56 | |
621 int v22; // ecx@59 | |
622 int v23; // edx@59 | |
623 int v24; // ecx@60 | |
624 int v25; // esi@63 | |
625 //unsigned int v26; // [sp+Ch] [bp-14h]@1 | |
626 //int v27; // [sp+10h] [bp-10h]@1 | |
627 int v28; // [sp+14h] [bp-Ch]@10 | |
628 int v29; // [sp+14h] [bp-Ch]@36 | |
629 unsigned int uClickX; // [sp+18h] [bp-8h]@10 | |
630 unsigned int uClickY; // [sp+1Ch] [bp-4h]@10 | |
631 | |
632 //v1 = 0; | |
633 //v27 = uNumVisibleWindows; | |
634 if ( uNumVisibleWindows < 0 ) | |
635 return false; | |
636 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
637 for (int i = uNumVisibleWindows; i >= 0; --i) | |
638 //while ( 1 ) | |
639 { | |
640 v3 = pVisibleWindowsIdxs[i] - 1; | |
641 if (!pWindowList[v3].receives_keyboard_input) | |
642 continue; | |
643 | |
644 switch (vkKey) | |
645 { | |
646 case VK_LEFT: | |
647 { | |
648 v12 = pWindowList[v3].field_34; | |
649 if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 ) | |
650 { | |
651 v8 = pCurrentScreen == SCREEN_PARTY_CREATION; | |
652 pWindowList[v3].pCurrentPosActiveItem -= v12; | |
653 if ( v8 ) | |
654 { | |
655 pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); | |
656 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
657 } | |
658 } | |
659 if ( pWindowList[v3].field_30 != 0 ) | |
660 { | |
661 break; | |
662 } | |
663 pButton = pWindowList[v3].pControlsHead; | |
664 v13 = pWindowList[v3].pCurrentPosActiveItem; | |
665 if ( v13 > 0) | |
666 { | |
667 do | |
668 { | |
669 pButton = pButton->pNext; | |
670 --v13; | |
671 } | |
672 while ( v13 ); | |
673 } | |
674 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
675 break; | |
676 } | |
677 case VK_RIGHT: | |
678 { | |
679 v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34; | |
680 if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem ) | |
681 { | |
682 v8 = pCurrentScreen == SCREEN_PARTY_CREATION; | |
683 pWindowList[v3].pCurrentPosActiveItem = v7; | |
684 if ( v8 ) | |
685 { | |
686 pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); | |
687 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
688 } | |
689 } | |
690 if ( pWindowList[v3].field_30 != 0 ) | |
691 { | |
692 break; | |
693 } | |
694 pButton = pWindowList[v3].pControlsHead; | |
695 v10 = pWindowList[v3].pCurrentPosActiveItem; | |
696 if ( v10 > 0) | |
697 { | |
698 do | |
699 { | |
700 pButton = pButton->pNext; | |
701 --v10; | |
702 } | |
703 while ( v10 ); | |
704 } | |
705 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
706 break; | |
707 } | |
708 case VK_DOWN: | |
709 { | |
710 v17 = pWindowList[v3].pStartingPosActiveItem; | |
711 v18 = pWindowList[v3].pCurrentPosActiveItem; | |
712 if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 ) | |
713 pWindowList[v3].pCurrentPosActiveItem = v17; | |
714 else | |
715 pWindowList[v3].pCurrentPosActiveItem = v18 + 1; | |
716 if ( pWindowList[v3].field_30 != 0 ) | |
717 return true; | |
718 pButton = pWindowList[v3].pControlsHead; | |
719 v20 = pWindowList[v3].pCurrentPosActiveItem; | |
720 if ( v20 > 0) | |
721 { | |
722 do | |
723 { | |
724 pButton = pButton->pNext; | |
725 --v20; | |
726 } | |
727 while ( v20 ); | |
728 } | |
729 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
730 return true; | |
731 } | |
732 case VK_SELECT: | |
733 { | |
734 pMouse->GetClickPos(&uClickX, &uClickY); | |
735 v4 = pWindowList[v3].pStartingPosActiveItem; | |
736 v28 = v4 + pWindowList[v3].pNumPresenceButton; | |
737 if ( v4 < v4 + pWindowList[v3].pNumPresenceButton ) | |
738 { | |
739 while ( 1 ) | |
740 { | |
741 pButton = pWindowList[v3].pControlsHead; | |
742 if ( v4 > 0 ) | |
743 { | |
744 v6 = v4; | |
745 do | |
746 { | |
747 pButton = pButton->pNext; | |
748 --v6; | |
749 } | |
750 while ( v6 ); | |
751 } | |
752 if ( (signed int)uClickX >= (signed int)pButton->uX//test for StatsTab in PlayerCreation Window | |
753 && (signed int)uClickX <= (signed int)pButton->uZ | |
754 && (signed int)uClickY >= (signed int)pButton->uY | |
755 && (signed int)uClickY <= (signed int)pButton->uW ) | |
756 break; | |
757 ++v4; | |
758 if ( v4 >= v28 ) | |
759 { | |
760 //v1 = 0; | |
761 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
762 //--i; | |
763 //if ( i < 0 ) | |
764 return false; | |
765 //continue; | |
766 } | |
767 } | |
768 pWindowList[v3].pCurrentPosActiveItem = v4; | |
769 return true; | |
770 } | |
771 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
772 break; | |
773 } | |
774 case VK_UP: | |
775 { | |
776 v22 = pWindowList[v3].pCurrentPosActiveItem; | |
777 v23 = pWindowList[v3].pStartingPosActiveItem; | |
778 if ( v22 <= v23 ) | |
779 v24 = pWindowList[v3].pNumPresenceButton + v23 - 1; | |
780 else | |
781 v24 = v22 - 1; | |
782 v8 = pWindowList[v3].field_30 == 0; | |
783 pWindowList[v3].pCurrentPosActiveItem = v24; | |
784 if ( !v8 ) | |
785 return true; | |
786 pButton = pWindowList[v3].pControlsHead; | |
787 v25 = pWindowList[v3].pCurrentPosActiveItem; | |
788 if ( v25 > 0) | |
789 { | |
790 do | |
791 { | |
792 pButton = pButton->pNext; | |
793 --v25; | |
794 } | |
795 while ( v25 ); | |
796 } | |
797 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
798 return true; | |
799 } | |
800 case VK_NEXT: | |
801 { | |
2099 | 802 if ( pWindowList[v3].field_30 != 0 ) //crashed at skill draw |
803 { | |
804 pMouse->GetClickPos(&uClickX, &uClickY); | |
805 v29 = pWindowList[v3].pStartingPosActiveItem + pWindowList[v3].pNumPresenceButton; //num buttons more than buttons | |
806 for ( v4 = pWindowList[v3].pStartingPosActiveItem; v4 < v29; ++v4 ) | |
807 { | |
808 pButton = pWindowList[v3].pControlsHead; | |
809 if ( v4 > 0 ) | |
810 { | |
811 for ( v15 = v4; v15; --v15 ) | |
812 pButton = pButton->pNext; | |
813 } | |
814 if ( (signed int)uClickX >= (signed int)pButton->uX && (signed int)uClickX <= (signed int)pButton->uZ | |
815 && (signed int)uClickY >= (signed int)pButton->uY && (signed int)uClickY <= (signed int)pButton->uW ) | |
816 { | |
817 pWindowList[v3].pCurrentPosActiveItem = v4; | |
818 return true; | |
819 } | |
820 } | |
821 } | |
1297 | 822 break; |
823 } | |
824 default: | |
825 { | |
826 break; | |
827 } | |
828 } | |
829 } | |
830 } |