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