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