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