Mercurial > mm7
annotate Mouse.cpp @ 2273:42b6a910b5d8
FindIcon cleaned
author | Ritor1 |
---|---|
date | Fri, 14 Mar 2014 02:03:41 +0600 |
parents | aff7a7b072b7 |
children | ddb803517a48 |
rev | line source |
---|---|
2253
aff7a7b072b7
adding _CRT_SECURE_NO_WARNINGS to get rid of a few hundrer annoying warnings + adding count parameter to swprintf
Grumpy7
parents:
2242
diff
changeset
|
1 #define _CRT_SECURE_NO_WARNINGS |
1262 | 2 #include "Texture.h" |
3 #include "mm7_data.h" | |
1253 | 4 #include "Render.h" |
0 | 5 #include "Mouse.h" |
6 #include "Items.h" | |
7 #include "Party.h" | |
8 #include "LOD.h" | |
9 #include "Game.h" | |
10 | |
1296 | 11 #include "TurnEngine.h" |
12 #include "Viewport.h" | |
13 #include "GUIWindow.h" | |
14 #include "Vis.h" | |
15 #include "Actor.h" | |
16 #include "MM7.h" | |
1297 | 17 #include "AudioPlayer.h" |
0 | 18 |
19 | |
20 Mouse *pMouse; | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 //----- (00469860) -------------------------------------------------------- | |
27 void Mouse::GetClickPos(unsigned int *pX, unsigned int *pY) | |
28 { | |
2223 | 29 *pX = uMouseClickX; |
30 *pY = uMouseClickY; | |
0 | 31 } |
32 | |
33 //----- (004698A6) -------------------------------------------------------- | |
34 void Mouse::RemoveHoldingItem() | |
35 { | |
36 pParty->pPickedItem.Reset(); | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
37 if (_stricmp(pCurrentCursorName, "MICON2")) |
0 | 38 SetCursorBitmap("MICON1"); |
39 } | |
40 | |
41 //----- (004698D8) -------------------------------------------------------- | |
42 void Mouse::SetCursorBitmapFromItemID(unsigned int uItemID) | |
43 { | |
44 pMouse->SetCursorBitmap(pItemsTable->pItems[uItemID].pIconName); | |
45 } | |
46 | |
47 //----- (004698F6) -------------------------------------------------------- | |
48 void Mouse::SetCurrentCursorBitmap() | |
49 { | |
50 SetCursorBitmap(pCurrentCursorName); | |
51 } | |
52 | |
53 //----- (00469903) -------------------------------------------------------- | |
54 void Mouse::SetCursorBitmap(const char *pName) | |
55 { | |
2219 | 56 DDSURFACEDESC2 Dst; |
57 | |
0 | 58 if ( !this->bInitialized || !pName ) |
59 return; | |
2217 | 60 if ( _stricmp("MICON2", pName) )//если кусор не мишень |
2219 | 61 pGame->uFlags2 &= 0xFFFFFFEF; |
0 | 62 else |
2216 | 63 pGame->uFlags2 |= 0x10; |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
64 if ( _stricmp(this->pCurrentCursorName, pName) ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
65 strcpy(this->pCurrentCursorName, pName); |
0 | 66 ClearCursor(); |
2219 | 67 if ( _strnicmp(pName, "MICON1", 5) )//for click to item / если курсор с вещью |
0 | 68 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
69 this->uCursorTextureID = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
70 this->uCursorTextureID_2 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
71 this->AllocCursorSystemMem(); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
72 this->field_C = 0; |
2219 | 73 this->bRedraw = true; |
74 this->bActive = true; | |
0 | 75 if ( !areWeLoadingTexture ) |
76 { | |
77 if (uCursorTextureID != -1) | |
78 pIcons_LOD->pTextures[uCursorTextureID].Release(); | |
1006 | 79 pIcons_LOD->SyncLoadedFilesCount(); |
0 | 80 } |
81 return; | |
82 } | |
1802 | 83 this->bActive = false; |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
84 this->field_C = 1; |
1802 | 85 window->SetCursor(pName); |
0 | 86 } |
87 // 506128: using guessed type int areWeLoadingTexture; | |
88 | |
89 //----- (00469AE4) -------------------------------------------------------- | |
90 LONG Mouse::_469AE4() | |
91 { | |
92 LONG v2; // ecx@2 | |
93 LONG result; // eax@2 | |
94 struct tagPOINT Point; // [sp+Ch] [bp-8h]@2 | |
95 | |
96 this->field_8 = 1; | |
1038 | 97 /*if (pAsyncMouse) |
0 | 98 { |
99 v2 = *((int *)pAsyncMouse + 6); | |
100 Point.x = *((int *)pAsyncMouse + 6); | |
101 result = *((int *)pAsyncMouse + 7); | |
102 } | |
103 else | |
1038 | 104 {*/ |
0 | 105 GetCursorPos(&Point); |
2153 | 106 //if ( pRenderer->bWindowMode ) |
1802 | 107 ScreenToClient(window->GetApiHandle(), &Point); |
0 | 108 result = Point.y; |
109 v2 = Point.x; | |
1038 | 110 //} |
2216 | 111 this->uMouseClickX = v2; |
112 this->uMouseClickY = result; | |
2155 | 113 if ( true/*pRenderer->bWindowMode*/) |
0 | 114 goto LABEL_16; |
1038 | 115 //if (pAsyncMouse) |
116 // goto LABEL_24; | |
0 | 117 if ( v2 < 0 ) |
118 v2 = 0; | |
119 if ( result < 0 ) | |
120 result = 0; | |
2216 | 121 if ( v2 > window->GetWidth() - 1 ) |
122 v2 = window->GetWidth() - 1; | |
123 if ( result > window->GetHeight() - 1 ) | |
0 | 124 { |
2216 | 125 result = window->GetHeight() - 1; |
0 | 126 LABEL_16: |
1038 | 127 //if (pAsyncMouse) |
128 // goto LABEL_24; | |
2216 | 129 if (true/*pRenderer->bWindowMode*/ && (v2 < 0 || result < 0 || v2 > window->GetWidth() -1 || result > window->GetHeight() - 1) ) |
0 | 130 goto LABEL_23; |
131 } | |
2216 | 132 if ( this->field_C ) |
0 | 133 LABEL_23: |
2219 | 134 this->bActive = false; |
0 | 135 LABEL_24: |
2216 | 136 this->field_8 = 0; |
0 | 137 return result; |
138 } | |
139 | |
140 //----- (00469BA3) -------------------------------------------------------- | |
141 void Mouse::ClearCursor() | |
142 { | |
2219 | 143 this->bActive = false; |
2098 | 144 if ( this->pCursorBitmap_sysmem ) |
0 | 145 { |
2098 | 146 free(this->pCursorBitmap_sysmem); |
147 this->pCursorBitmap_sysmem = 0; | |
0 | 148 } |
2098 | 149 if ( this->pCursorBitmap2_sysmem ) |
0 | 150 { |
2098 | 151 free(this->pCursorBitmap2_sysmem); |
152 this->pCursorBitmap2_sysmem = 0; | |
0 | 153 } |
2098 | 154 if ( this->ptr_90 ) |
155 free(this->ptr_90); | |
156 this->ptr_90 = 0; | |
0 | 157 } |
158 | |
159 //----- (00469BE6) -------------------------------------------------------- | |
160 void Mouse::AllocCursorSystemMem() | |
161 { | |
2219 | 162 bActive = false; |
0 | 163 if (!pCursorBitmap_sysmem) |
164 pCursorBitmap_sysmem = (unsigned __int16 *)DoAllocCursorMem(); | |
165 if (!pCursorBitmap2_sysmem) | |
166 pCursorBitmap2_sysmem = (unsigned __int8 *)DoAllocCursorMem(); | |
167 } | |
168 | |
169 //----- (00469C0D) -------------------------------------------------------- | |
170 void *Mouse::DoAllocCursorMem() | |
171 { | |
1980 | 172 Texture* tex = pIcons_LOD->GetTexture(uCursorTextureID); |
973 | 173 return malloc(4 * tex->uTextureWidth * tex->uTextureHeight); |
0 | 174 } |
175 | |
176 //----- (00469C39) -------------------------------------------------------- | |
177 POINT *Mouse::GetCursorPos(POINT *a2) | |
178 { | |
1038 | 179 a2->x = this->uMouseClickX; |
180 a2->y = this->uMouseClickY; | |
181 return a2; | |
0 | 182 } |
183 | |
184 //----- (00469C65) -------------------------------------------------------- | |
1802 | 185 void Mouse::Initialize(OSWindow *window) |
0 | 186 { |
1802 | 187 this->window = window; |
188 this->bActive = false; | |
189 this->bInitialized = true; | |
2216 | 190 |
191 //this->field_8 = 0;//Ritor1: result incorrect uMouseClickX, this->uMouseClickY in _469AE4() | |
192 this->uCursorBitmapPitch = 0;//Ritor1: it's include | |
193 for ( uint i = 0; i < 13; i++ ) | |
194 this->field_5C[i] = 0; | |
195 | |
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 ) | |
2216 | 231 pMouse->_469AE4();//Ritor1: странная, непонятная функция |
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 { |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2155
diff
changeset
|
241 if ( this->uMouseClickX < 0 || this->uMouseClickY < 0 || this->uMouseClickX > window->GetWidth() - 1 || this->uMouseClickY > window->GetHeight() - 1 ) |
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; |
2216 | 259 this->pCursorBitmapRect.w = this->uMouseClickY + this->field_5C[0]; //Ritor1: Maybe this->field_5C[0] - cursor width |
2093 | 260 this->pCursorBitmapRect.y = this->uMouseClickY; |
2216 | 261 this->pCursorBitmapRect.z = this->uMouseClickX + this->uCursorBitmapPitch; //Ritor1: Maybe this->uCursorBitmapPitch - cursor height |
2093 | 262 if ( this->uMouseClickX < 0 ) |
263 this->pCursorBitmapRect.x = 0; | |
264 if ( this->uMouseClickY < 0 ) | |
265 this->pCursorBitmapRect.y = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2155
diff
changeset
|
266 if ( this->pCursorBitmapRect.z > window->GetWidth() ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2155
diff
changeset
|
267 this->pCursorBitmapRect.z = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2155
diff
changeset
|
268 if ( this->pCursorBitmapRect.w > window->GetHeight() ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2155
diff
changeset
|
269 this->pCursorBitmapRect.w = window->GetHeight(); |
2219 | 270 this->bActive = false; |
2093 | 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) -------------------------------------------------------- | |
2216 | 287 void Mouse::Activate() |
0 | 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) -------------------------------------------------------- | |
2223 | 303 void Mouse::DrawCursorToTarget()//??? DrawCursorWithItem |
0 | 304 { |
305 if (!pCursorBitmap3_sysmembits_16bit) | |
306 return; | |
2219 | 307 //пишем на экран курсор с вещью |
1980 | 308 ushort* pSrc = pCursorBitmap3_sysmembits_16bit; |
2216 | 309 for (uint y = uCursorWithItemY; y < uCursorWithItemZ; ++y) |
310 for (uint x = uCursorWithItemX; x < uCursorWithItemW; ++x) | |
2069 | 311 //pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++; |
312 pRenderer->WritePixel16(x, y, *pSrc++); | |
0 | 313 } |
314 | |
315 //----- (00469EA4) -------------------------------------------------------- | |
2216 | 316 void Mouse::ReadCursorWithItem() |
0 | 317 { |
920 | 318 unsigned int pTextureID; // eax@2 |
319 Texture *pTexture; // edi@2 | |
0 | 320 int v8; // ecx@25 |
321 int v9; // ebx@26 | |
322 unsigned int v10; // eax@26 | |
323 int v11; // edx@27 | |
2216 | 324 int pTextureHeight; // [sp+20h] [bp-8h]@15 |
0 | 325 unsigned __int16 *v20; // [sp+20h] [bp-8h]@28 |
920 | 326 int pTextureWidth; // [sp+24h] [bp-4h]@12 |
0 | 327 unsigned __int16 *v22; // [sp+24h] [bp-4h]@25 |
328 | |
329 if ( pParty->pPickedItem.uItemID ) | |
330 { | |
1709
8251e59fd7c1
ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
Grumpy7
parents:
1687
diff
changeset
|
331 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE); |
920 | 332 pTexture = (Texture *)(pTextureID != -1 ? (int)&pIcons_LOD->pTextures[pTextureID] : 0); |
1038 | 333 |
2216 | 334 if ( (signed int)pMouse->uMouseClickX <= window->GetWidth() - 1 && (signed int)pMouse->uMouseClickY <= window->GetHeight() - 1 ) |
0 | 335 { |
2216 | 336 /*if ( (v4 & 0x80000000u) != 0 ) |
0 | 337 a2 = 0; |
338 if ( (v5 & 0x80000000u) != 0 ) | |
339 { | |
2216 | 340 //v6 = 0; |
0 | 341 v15 = 0; |
2216 | 342 } */ |
343 if ( (signed int)(pTexture->uTextureWidth + pMouse->uMouseClickX) <= window->GetWidth() ) | |
920 | 344 pTextureWidth = pTexture->uTextureWidth; |
0 | 345 else |
2216 | 346 pTextureWidth = window->GetWidth() - pMouse->uMouseClickX; |
347 if ( (signed int)(pTexture->uTextureHeight + pMouse->uMouseClickY) <= window->GetHeight() ) | |
348 pTextureHeight = pTexture->uTextureHeight; | |
0 | 349 else |
2216 | 350 pTextureHeight = window->GetHeight() - pMouse->uMouseClickY; |
920 | 351 if ( !this->pCursorBitmap3_sysmembits_16bit |
2216 | 352 || pMouse->uMouseClickX != this->uCursorWithItemX |
353 || pMouse->uMouseClickY != this->uCursorWithItemY | |
354 || pMouse->uMouseClickX + pTextureWidth != this->uCursorWithItemW | |
355 || pMouse->uMouseClickY + pTextureHeight != this->uCursorWithItemZ ) | |
0 | 356 { |
920 | 357 if ( this->pCursorBitmap3_sysmembits_16bit ) |
358 free(this->pCursorBitmap3_sysmembits_16bit); | |
1631 | 359 this->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)malloc(2 * pTexture->uTextureHeight * pTexture->uTextureWidth); |
2216 | 360 this->uCursorWithItemX = pMouse->uMouseClickX; |
361 this->uCursorWithItemW = pMouse->uMouseClickX + pTextureWidth; | |
362 this->uCursorWithItemY = pMouse->uMouseClickY; | |
363 this->uCursorWithItemZ = pMouse->uMouseClickY + pTextureHeight; | |
0 | 364 } |
920 | 365 v22 = this->pCursorBitmap3_sysmembits_16bit; |
2216 | 366 |
367 for (int y = this->uCursorWithItemY; y < this->uCursorWithItemZ; ++y) | |
2069 | 368 { |
2216 | 369 for (int x = this->uCursorWithItemX; x < this->uCursorWithItemW; ++x) |
2069 | 370 { |
2216 | 371 *v22++ = pRenderer->ReadPixel16(x, y); |
2069 | 372 } |
373 } | |
374 /*if ( v8 < this->field_4C ) | |
0 | 375 { |
920 | 376 v9 = this->field_48; |
0 | 377 v10 = pRenderer->uTargetSurfacePitch * v8; |
378 do | |
379 { | |
920 | 380 v11 = this->field_40; |
381 v18 = this->field_40; | |
0 | 382 if ( v11 < v9 ) |
383 { | |
384 v20 = &v17[v10 + v11]; | |
385 do | |
386 { | |
2069 | 387 //v12 = v20; |
0 | 388 ++v18; |
2069 | 389 //++v20; |
390 *v22++ = *v20++; | |
0 | 391 } |
392 while ( v18 < v9 ); | |
393 } | |
394 v10 += v16; | |
395 ++v8; | |
396 } | |
920 | 397 while ( v8 < this->field_4C ); |
0 | 398 v6 = v15; |
2069 | 399 }*/ |
400 | |
1567
9f8b3e904e14
Player::ReceiveDamage, very small edits; prepended "Is" to item functions returning bool values (broken, indetified, stolen)
Grumpy7
parents:
1458
diff
changeset
|
401 if (pParty->pPickedItem.IsBroken()) |
2216 | 402 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
|
403 else if (!pParty->pPickedItem.IsIdentified()) |
2216 | 404 pRenderer->DrawTransparentGreenShade(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture); |
0 | 405 else |
2216 | 406 pRenderer->DrawTextureTransparent(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture); |
0 | 407 } |
408 } | |
409 else | |
410 { | |
411 if ( this->pCursorBitmap3_sysmembits_16bit ) | |
412 { | |
413 free(this->pCursorBitmap3_sysmembits_16bit); | |
920 | 414 this->pCursorBitmap3_sysmembits_16bit = 0; |
0 | 415 } |
416 } | |
417 } | |
418 | |
419 //----- (0046A080) -------------------------------------------------------- | |
2216 | 420 void Mouse::ChangeActivation(int a1) |
0 | 421 { |
2216 | 422 this->bActive = a1; |
0 | 423 } |
424 | |
425 //----- (0046A08A) -------------------------------------------------------- | |
426 void Mouse::SetMouseClick(int x, int y) | |
427 { | |
428 uMouseClickX = x; | |
429 uMouseClickY = y; | |
430 } | |
1296 | 431 //----- (004175C0) -------------------------------------------------------- |
432 void UI_OnMouseLeftClick(int *pXY) | |
433 { | |
434 signed int y; // eax@7 | |
435 signed int x; // ecx@7 | |
436 signed int v5; // eax@17 | |
2098 | 437 GUIButton *control; // esi@37 |
1296 | 438 signed int v10; // eax@50 |
439 int v11; // ecx@52 | |
440 unsigned int pX; // [sp+14h] [bp-8h]@7 | |
441 unsigned int pY; // [sp+18h] [bp-4h]@7 | |
0 | 442 |
2098 | 443 if ( pCurrentScreen == SCREEN_VIDEO || sub_4637E0_is_there_popup_onscreen() ) |
1296 | 444 return; |
445 if ( pGUIWindow2 && pGUIWindow2->ptr_1C == (void *)33 ) | |
446 { | |
447 sub_4452BB(); | |
448 return; | |
449 } | |
2098 | 450 if ( pXY ) |
1296 | 451 { |
2098 | 452 x = *pXY; |
453 y = pXY[1]; | |
454 pX = *pXY; | |
1296 | 455 pY = y; |
456 } | |
457 else | |
458 { | |
459 pMouse->GetClickPos(&pX, &pY); | |
460 y = pY; | |
461 x = pX; | |
462 } | |
1830 | 463 |
464 extern bool _507B98_ctrl_pressed; | |
1296 | 465 x = pX; |
2098 | 466 if ( GetCurrentMenuID() != -1 || pCurrentScreen != SCREEN_GAME || !_507B98_ctrl_pressed // stealing cursor |
467 || (signed int)pX < (signed int)pViewport->uViewportTL_X || (signed int)pX > (signed int)pViewport->uViewportBR_X | |
468 || (signed int)pY < (signed int)pViewport->uViewportTL_Y || (signed int)pY > (signed int)pViewport->uViewportBR_Y) | |
1296 | 469 { |
470 y = pY; | |
2098 | 471 for ( int i = uNumVisibleWindows; i >= 0; --i ) |
1296 | 472 { |
2098 | 473 if ( x >= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameX && x <= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameZ |
474 && y >= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameY && y <= (signed int)pWindowList[pVisibleWindowsIdxs[i] - 1].uFrameW ) | |
475 { | |
476 for ( control = pWindowList[pVisibleWindowsIdxs[i] - 1].pControlsHead; control; control = control->pNext ) | |
477 { | |
478 if ( control->uButtonType == 1 ) | |
479 { | |
480 if ( x >= (signed int)control->uX && x <= (signed int)control->uZ && y >= (signed int)control->uY && y <= (signed int)control->uW ) | |
481 { | |
482 control->field_2C_is_pushed = 1; | |
483 v10 = pMessageQueue_50CBD0->uNumMessages; | |
484 if ( pMessageQueue_50CBD0->uNumMessages ) | |
485 { | |
486 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
487 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
488 } | |
489 pMessageQueue_50CBD0->AddMessage(control->msg, control->msg_param, 0); | |
490 return; | |
491 } | |
492 continue; | |
493 } | |
494 if ( control->uButtonType == 2 )//когда нажимаешь на партреты персов | |
495 { | |
496 if ( (signed int)(signed __int64)sqrt((double)((x - control->uX) * (x - control->uX) + (y - control->uY) * (y - control->uY))) < (signed int)control->uWidth ) | |
497 { | |
498 control->field_2C_is_pushed = 1; | |
499 v10 = pMessageQueue_50CBD0->uNumMessages; | |
500 if ( pMessageQueue_50CBD0->uNumMessages ) | |
501 { | |
502 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
503 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
504 } | |
505 pMessageQueue_50CBD0->AddMessage(control->msg, control->msg_param, 0); | |
506 return; | |
507 } | |
508 continue; | |
509 } | |
510 if ( control->uButtonType == 3 )//когда нажимаешь на скиллы | |
511 { | |
512 if ( x >= (signed int)control->uX && x <= (signed int)control->uZ && y >= (signed int)control->uY && y <= (signed int)control->uW ) | |
513 { | |
514 control->field_2C_is_pushed = 1; | |
515 v10 = pMessageQueue_50CBD0->uNumMessages; | |
516 if ( pMessageQueue_50CBD0->uNumMessages ) | |
517 { | |
518 v10 = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
519 pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; | |
520 } | |
521 pMessageQueue_50CBD0->AddMessage(control->msg, control->msg_param, 0); | |
522 return; | |
523 } | |
524 continue; | |
525 } | |
526 y = pY; | |
527 x = pX; | |
528 } | |
529 } | |
1296 | 530 } |
2098 | 531 return; |
1296 | 532 } |
533 y = pY; | |
2154 | 534 //if ( pRenderer->pRenderD3D ) |
1296 | 535 v5 = pGame->pVisInstance->get_picked_object_zbuf_val(); |
2154 | 536 /*else |
537 v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]];*/ | |
1830 | 538 |
2098 | 539 uint type = PID_TYPE((unsigned __int16)v5); |
540 if (type == OBJECT_Actor && uActiveCharacter && v5 < 0x2000000 | |
541 && pPlayers[uActiveCharacter]->CanAct() && pPlayers[uActiveCharacter]->CanSteal() ) | |
1296 | 542 { |
543 /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) | |
544 { | |
545 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_1B; | |
546 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v6 >> 3; | |
547 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; | |
548 ++pMessageQueue_50CBD0->uNumMessages; | |
549 }*/ | |
2098 | 550 pMessageQueue_50CBD0->AddMessage(UIMSG_STEALFROMACTOR, PID_ID((unsigned __int16)v5), 0); |
1296 | 551 |
552 if ( pParty->bTurnBasedModeOn == 1 ) | |
553 { | |
2242 | 554 if ( pTurnEngine->turn_stage == TE_MOVEMENT ) |
1332 | 555 pTurnEngine->field_18 |= TE_FLAG_8; |
1296 | 556 } |
557 } | |
558 } | |
559 | |
560 | |
1297 | 561 //----- (0041CD4F) -------------------------------------------------------- |
562 bool UI_OnKeyDown(unsigned int vkKey) | |
563 { | |
564 //unsigned int v1; // edi@1 | |
565 //unsigned int v2; // eax@2 | |
566 int v3; // esi@3 | |
567 int v4; // ecx@10 | |
568 GUIButton *pButton; // eax@11 | |
569 int v6; // edx@12 | |
570 int v7; // ecx@20 | |
571 char v8; // zf@21 | |
572 //GUIButton *v9; // ecx@24 | |
573 int v10; // esi@24 | |
574 //int v11; // edx@26 | |
575 int v12; // edx@28 | |
576 int v13; // esi@32 | |
577 //GUIButton *v14; // eax@37 | |
578 int v15; // edx@38 | |
579 int v17; // ecx@50 | |
580 int v18; // edx@50 | |
581 //GUIButton *v19; // ecx@54 | |
582 int v20; // esi@54 | |
583 //int v21; // edx@56 | |
584 int v22; // ecx@59 | |
585 int v23; // edx@59 | |
586 int v24; // ecx@60 | |
587 int v25; // esi@63 | |
588 //unsigned int v26; // [sp+Ch] [bp-14h]@1 | |
589 //int v27; // [sp+10h] [bp-10h]@1 | |
590 int v28; // [sp+14h] [bp-Ch]@10 | |
591 int v29; // [sp+14h] [bp-Ch]@36 | |
592 unsigned int uClickX; // [sp+18h] [bp-8h]@10 | |
593 unsigned int uClickY; // [sp+1Ch] [bp-4h]@10 | |
594 | |
595 //v1 = 0; | |
596 //v27 = uNumVisibleWindows; | |
597 if ( uNumVisibleWindows < 0 ) | |
598 return false; | |
599 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
600 for (int i = uNumVisibleWindows; i >= 0; --i) | |
601 //while ( 1 ) | |
602 { | |
603 v3 = pVisibleWindowsIdxs[i] - 1; | |
604 if (!pWindowList[v3].receives_keyboard_input) | |
605 continue; | |
606 | |
607 switch (vkKey) | |
608 { | |
609 case VK_LEFT: | |
610 { | |
611 v12 = pWindowList[v3].field_34; | |
612 if ( pWindowList[v3].pCurrentPosActiveItem - pWindowList[v3].pStartingPosActiveItem - v12 >= 0 ) | |
613 { | |
614 v8 = pCurrentScreen == SCREEN_PARTY_CREATION; | |
615 pWindowList[v3].pCurrentPosActiveItem -= v12; | |
616 if ( v8 ) | |
617 { | |
618 pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); | |
619 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
620 } | |
621 } | |
622 if ( pWindowList[v3].field_30 != 0 ) | |
623 { | |
624 break; | |
625 } | |
626 pButton = pWindowList[v3].pControlsHead; | |
627 v13 = pWindowList[v3].pCurrentPosActiveItem; | |
628 if ( v13 > 0) | |
629 { | |
630 do | |
631 { | |
632 pButton = pButton->pNext; | |
633 --v13; | |
634 } | |
635 while ( v13 ); | |
636 } | |
637 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
638 break; | |
639 } | |
640 case VK_RIGHT: | |
641 { | |
642 v7 = pWindowList[v3].pCurrentPosActiveItem + pWindowList[v3].field_34; | |
643 if ( v7 < pWindowList[v3].pNumPresenceButton + pWindowList[v3].pStartingPosActiveItem ) | |
644 { | |
645 v8 = pCurrentScreen == SCREEN_PARTY_CREATION; | |
646 pWindowList[v3].pCurrentPosActiveItem = v7; | |
647 if ( v8 ) | |
648 { | |
649 pAudioPlayer->PlaySound(SOUND_Button, 0, 0, -1, 0, 0, 0, 0); | |
650 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
651 } | |
652 } | |
653 if ( pWindowList[v3].field_30 != 0 ) | |
654 { | |
655 break; | |
656 } | |
657 pButton = pWindowList[v3].pControlsHead; | |
658 v10 = pWindowList[v3].pCurrentPosActiveItem; | |
659 if ( v10 > 0) | |
660 { | |
661 do | |
662 { | |
663 pButton = pButton->pNext; | |
664 --v10; | |
665 } | |
666 while ( v10 ); | |
667 } | |
668 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
669 break; | |
670 } | |
671 case VK_DOWN: | |
672 { | |
673 v17 = pWindowList[v3].pStartingPosActiveItem; | |
674 v18 = pWindowList[v3].pCurrentPosActiveItem; | |
675 if ( v18 >= pWindowList[v3].pNumPresenceButton + v17 - 1 ) | |
676 pWindowList[v3].pCurrentPosActiveItem = v17; | |
677 else | |
678 pWindowList[v3].pCurrentPosActiveItem = v18 + 1; | |
679 if ( pWindowList[v3].field_30 != 0 ) | |
680 return true; | |
681 pButton = pWindowList[v3].pControlsHead; | |
682 v20 = pWindowList[v3].pCurrentPosActiveItem; | |
683 if ( v20 > 0) | |
684 { | |
685 do | |
686 { | |
687 pButton = pButton->pNext; | |
688 --v20; | |
689 } | |
690 while ( v20 ); | |
691 } | |
692 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
693 return true; | |
694 } | |
695 case VK_SELECT: | |
696 { | |
697 pMouse->GetClickPos(&uClickX, &uClickY); | |
698 v4 = pWindowList[v3].pStartingPosActiveItem; | |
699 v28 = v4 + pWindowList[v3].pNumPresenceButton; | |
700 if ( v4 < v4 + pWindowList[v3].pNumPresenceButton ) | |
701 { | |
702 while ( 1 ) | |
703 { | |
704 pButton = pWindowList[v3].pControlsHead; | |
705 if ( v4 > 0 ) | |
706 { | |
707 v6 = v4; | |
708 do | |
709 { | |
710 pButton = pButton->pNext; | |
711 --v6; | |
712 } | |
713 while ( v6 ); | |
714 } | |
715 if ( (signed int)uClickX >= (signed int)pButton->uX//test for StatsTab in PlayerCreation Window | |
716 && (signed int)uClickX <= (signed int)pButton->uZ | |
717 && (signed int)uClickY >= (signed int)pButton->uY | |
718 && (signed int)uClickY <= (signed int)pButton->uW ) | |
719 break; | |
720 ++v4; | |
721 if ( v4 >= v28 ) | |
722 { | |
723 //v1 = 0; | |
724 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
725 //--i; | |
726 //if ( i < 0 ) | |
727 return false; | |
728 //continue; | |
729 } | |
730 } | |
731 pWindowList[v3].pCurrentPosActiveItem = v4; | |
732 return true; | |
733 } | |
734 //v2 = pMessageQueue_50CBD0->uNumMessages; | |
735 break; | |
736 } | |
737 case VK_UP: | |
738 { | |
739 v22 = pWindowList[v3].pCurrentPosActiveItem; | |
740 v23 = pWindowList[v3].pStartingPosActiveItem; | |
741 if ( v22 <= v23 ) | |
742 v24 = pWindowList[v3].pNumPresenceButton + v23 - 1; | |
743 else | |
744 v24 = v22 - 1; | |
745 v8 = pWindowList[v3].field_30 == 0; | |
746 pWindowList[v3].pCurrentPosActiveItem = v24; | |
747 if ( !v8 ) | |
748 return true; | |
749 pButton = pWindowList[v3].pControlsHead; | |
750 v25 = pWindowList[v3].pCurrentPosActiveItem; | |
751 if ( v25 > 0) | |
752 { | |
753 do | |
754 { | |
755 pButton = pButton->pNext; | |
756 --v25; | |
757 } | |
758 while ( v25 ); | |
759 } | |
760 pMessageQueue_50CBD0->AddMessage(pButton->msg, pButton->msg_param, 0); | |
761 return true; | |
762 } | |
763 case VK_NEXT: | |
764 { | |
2099 | 765 if ( pWindowList[v3].field_30 != 0 ) //crashed at skill draw |
766 { | |
767 pMouse->GetClickPos(&uClickX, &uClickY); | |
768 v29 = pWindowList[v3].pStartingPosActiveItem + pWindowList[v3].pNumPresenceButton; //num buttons more than buttons | |
769 for ( v4 = pWindowList[v3].pStartingPosActiveItem; v4 < v29; ++v4 ) | |
770 { | |
771 pButton = pWindowList[v3].pControlsHead; | |
772 if ( v4 > 0 ) | |
773 { | |
774 for ( v15 = v4; v15; --v15 ) | |
775 pButton = pButton->pNext; | |
776 } | |
777 if ( (signed int)uClickX >= (signed int)pButton->uX && (signed int)uClickX <= (signed int)pButton->uZ | |
778 && (signed int)uClickY >= (signed int)pButton->uY && (signed int)uClickY <= (signed int)pButton->uW ) | |
779 { | |
780 pWindowList[v3].pCurrentPosActiveItem = v4; | |
781 return true; | |
782 } | |
783 } | |
784 } | |
1297 | 785 break; |
786 } | |
787 default: | |
788 break; | |
789 } | |
790 } | |
2219 | 791 } |