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