Mercurial > mm7
annotate Mouse.cpp @ 2486:1e70f8470638
simplified SpriteObject::Create
author | Grumpy7 |
---|---|
date | Sun, 07 Sep 2014 01:36:04 +0200 |
parents | e42e01ff1526 |
children | 5abd8fc8f1c6 |
rev | line source |
---|---|
2415 | 1 #define _CRTDBG_MAP_ALLOC |
2 #include <stdlib.h> | |
3 #include <crtdbg.h> | |
4 | |
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
|
5 #define _CRT_SECURE_NO_WARNINGS |
2464 | 6 |
1262 | 7 #include "mm7_data.h" |
0 | 8 #include "Mouse.h" |
9 #include "Party.h" | |
10 #include "LOD.h" | |
11 #include "Game.h" | |
12 | |
1296 | 13 #include "TurnEngine.h" |
14 #include "Viewport.h" | |
15 #include "GUIWindow.h" | |
16 #include "Vis.h" | |
17 #include "Actor.h" | |
18 #include "MM7.h" | |
1297 | 19 #include "AudioPlayer.h" |
0 | 20 |
21 | |
22 Mouse *pMouse; | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 //----- (00469860) -------------------------------------------------------- | |
29 void Mouse::GetClickPos(unsigned int *pX, unsigned int *pY) | |
30 { | |
2223 | 31 *pX = uMouseClickX; |
32 *pY = uMouseClickY; | |
0 | 33 } |
34 | |
35 //----- (004698A6) -------------------------------------------------------- | |
36 void Mouse::RemoveHoldingItem() | |
37 { | |
38 pParty->pPickedItem.Reset(); | |
1165
29a8defbad9e
temporary _CRT_SECURE_NO_WARNINGS to remove some warnings
Grumpy7
parents:
1104
diff
changeset
|
39 if (_stricmp(pCurrentCursorName, "MICON2")) |
0 | 40 SetCursorBitmap("MICON1"); |
41 } | |
42 | |
43 //----- (004698D8) -------------------------------------------------------- | |
44 void Mouse::SetCursorBitmapFromItemID(unsigned int uItemID) | |
45 { | |
46 pMouse->SetCursorBitmap(pItemsTable->pItems[uItemID].pIconName); | |
47 } | |
48 | |
49 //----- (004698F6) -------------------------------------------------------- | |
50 void Mouse::SetCurrentCursorBitmap() | |
51 { | |
52 SetCursorBitmap(pCurrentCursorName); | |
53 } | |
54 | |
55 //----- (00469903) -------------------------------------------------------- | |
56 void Mouse::SetCursorBitmap(const char *pName) | |
57 { | |
2334 | 58 // DDSURFACEDESC2 Dst; |
2219 | 59 |
0 | 60 if ( !this->bInitialized || !pName ) |
61 return; | |
2217 | 62 if ( _stricmp("MICON2", pName) )//если кусор не мишень |
2219 | 63 pGame->uFlags2 &= 0xFFFFFFEF; |
0 | 64 else |
2216 | 65 pGame->uFlags2 |= 0x10; |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
66 if ( _stricmp(this->pCurrentCursorName, pName) ) |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
67 strcpy(this->pCurrentCursorName, pName); |
0 | 68 ClearCursor(); |
2219 | 69 if ( _strnicmp(pName, "MICON1", 5) )//for click to item / если курсор с вещью |
0 | 70 { |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
71 this->uCursorTextureID = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
72 this->uCursorTextureID_2 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
73 this->AllocCursorSystemMem(); |
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
74 this->field_C = 0; |
2219 | 75 this->bRedraw = true; |
76 this->bActive = true; | |
0 | 77 if ( !areWeLoadingTexture ) |
78 { | |
79 if (uCursorTextureID != -1) | |
80 pIcons_LOD->pTextures[uCursorTextureID].Release(); | |
1006 | 81 pIcons_LOD->SyncLoadedFilesCount(); |
0 | 82 } |
83 return; | |
84 } | |
1802 | 85 this->bActive = false; |
1429
c7489dd19f88
BuildingType_Tavern and CastSpellInfo_PushCastSpellInfo fix
Ritor1
parents:
1391
diff
changeset
|
86 this->field_C = 1; |
1802 | 87 window->SetCursor(pName); |
0 | 88 } |
89 // 506128: using guessed type int areWeLoadingTexture; | |
90 | |
91 //----- (00469AE4) -------------------------------------------------------- | |
92 LONG Mouse::_469AE4() | |
93 { | |
94 LONG v2; // ecx@2 | |
95 LONG result; // eax@2 | |
96 struct tagPOINT Point; // [sp+Ch] [bp-8h]@2 | |
97 | |
98 this->field_8 = 1; | |
1038 | 99 /*if (pAsyncMouse) |
0 | 100 { |
101 v2 = *((int *)pAsyncMouse + 6); | |
102 Point.x = *((int *)pAsyncMouse + 6); | |
103 result = *((int *)pAsyncMouse + 7); | |
104 } | |
105 else | |
1038 | 106 {*/ |
0 | 107 GetCursorPos(&Point); |
2153 | 108 //if ( pRenderer->bWindowMode ) |
1802 | 109 ScreenToClient(window->GetApiHandle(), &Point); |
0 | 110 result = Point.y; |
111 v2 = Point.x; | |
1038 | 112 //} |
2216 | 113 this->uMouseClickX = v2; |
114 this->uMouseClickY = result; | |
2472 | 115 |
116 /* | |
117 //This block has been commented out, because of the changed condition above "if(true)" | |
118 //Also the next condition and the first line has been commented out as well | |
119 | |
120 // if (pRenderer->bWindowMode) | |
121 if ( true ) | |
0 | 122 goto LABEL_16; |
1038 | 123 //if (pAsyncMouse) |
124 // goto LABEL_24; | |
2472 | 125 |
126 | |
0 | 127 if ( v2 < 0 ) |
128 v2 = 0; | |
129 if ( result < 0 ) | |
130 result = 0; | |
2216 | 131 if ( v2 > window->GetWidth() - 1 ) |
132 v2 = window->GetWidth() - 1; | |
2472 | 133 */ |
134 | |
135 // if ( result > window->GetHeight() - 1 ) | |
136 // { | |
137 // result = window->GetHeight() - 1; | |
138 //LABEL_16: | |
1038 | 139 //if (pAsyncMouse) |
140 // goto LABEL_24; | |
2472 | 141 if (true/*pRenderer->bWindowMode*/ && (v2 < 0 || result < 0 || v2 > window->GetWidth() - 1 || result > window->GetHeight() - 1)) |
142 { | |
143 this->bActive = false; | |
144 //LABEL_24: | |
145 this->field_8 = 0; | |
146 return result; | |
147 } | |
148 //} | |
149 | |
2216 | 150 if ( this->field_C ) |
2472 | 151 //LABEL_23: |
2219 | 152 this->bActive = false; |
2334 | 153 //LABEL_24: |
2216 | 154 this->field_8 = 0; |
0 | 155 return result; |
156 } | |
157 | |
158 //----- (00469BA3) -------------------------------------------------------- | |
159 void Mouse::ClearCursor() | |
160 { | |
2219 | 161 this->bActive = false; |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2339
diff
changeset
|
162 free(this->pCursorBitmap_sysmem); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2339
diff
changeset
|
163 this->pCursorBitmap_sysmem = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2339
diff
changeset
|
164 free(this->pCursorBitmap2_sysmem); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2339
diff
changeset
|
165 this->pCursorBitmap2_sysmem = nullptr; |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2339
diff
changeset
|
166 free(this->ptr_90); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2339
diff
changeset
|
167 this->ptr_90 = nullptr; |
0 | 168 } |
169 | |
170 //----- (00469BE6) -------------------------------------------------------- | |
171 void Mouse::AllocCursorSystemMem() | |
172 { | |
2219 | 173 bActive = false; |
0 | 174 if (!pCursorBitmap_sysmem) |
175 pCursorBitmap_sysmem = (unsigned __int16 *)DoAllocCursorMem(); | |
176 if (!pCursorBitmap2_sysmem) | |
177 pCursorBitmap2_sysmem = (unsigned __int8 *)DoAllocCursorMem(); | |
178 } | |
179 | |
180 //----- (00469C0D) -------------------------------------------------------- | |
181 void *Mouse::DoAllocCursorMem() | |
182 { | |
1980 | 183 Texture* tex = pIcons_LOD->GetTexture(uCursorTextureID); |
973 | 184 return malloc(4 * tex->uTextureWidth * tex->uTextureHeight); |
0 | 185 } |
186 | |
187 //----- (00469C39) -------------------------------------------------------- | |
188 POINT *Mouse::GetCursorPos(POINT *a2) | |
189 { | |
1038 | 190 a2->x = this->uMouseClickX; |
191 a2->y = this->uMouseClickY; | |
192 return a2; | |
0 | 193 } |
194 | |
195 //----- (00469C65) -------------------------------------------------------- | |
1802 | 196 void Mouse::Initialize(OSWindow *window) |
0 | 197 { |
1802 | 198 this->window = window; |
199 this->bActive = false; | |
200 this->bInitialized = true; | |
2216 | 201 |
202 //this->field_8 = 0;//Ritor1: result incorrect uMouseClickX, this->uMouseClickY in _469AE4() | |
203 this->uCursorBitmapPitch = 0;//Ritor1: it's include | |
204 for ( uint i = 0; i < 13; i++ ) | |
205 this->field_5C[i] = 0; | |
206 | |
0 | 207 this->pCursorBitmapPos.x = 0; |
208 this->pCursorBitmapPos.y = 0; | |
209 this->uMouseClickX = 0; | |
210 this->uMouseClickY = 0; | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2339
diff
changeset
|
211 this->pCursorBitmap_sysmem = nullptr; |
0 | 212 this->field_34 = 0; |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2339
diff
changeset
|
213 this->pCursorBitmap2_sysmem = nullptr; |
0 | 214 |
215 SetCursorBitmap("MICON3"); | |
216 SetCursorBitmap("MICON2"); | |
217 SetCursorBitmap("MICON1"); | |
218 } | |
219 | |
762 | 220 // inlined |
221 //----- (0045FE00) mm6 chinese -------------------------------------------- | |
222 void Mouse::SetActive(bool active) | |
223 { | |
224 bActive = active; | |
225 } | |
226 | |
0 | 227 //----- (00469CC2) -------------------------------------------------------- |
228 void Mouse::Deactivate() | |
229 { | |
230 if (bInitialized) | |
762 | 231 SetActive(false); |
0 | 232 } |
233 | |
234 //----- (00469CCD) -------------------------------------------------------- | |
235 void Mouse::DrawCursor() | |
236 { | |
237 unsigned int v9; // eax@31 | |
238 | |
239 if ( this->bInitialized ) | |
240 { | |
2420 | 241 if ( !this->field_8 && this->bActive && !this->field_C ) //Uninitialized memory access(this->field_8) |
2216 | 242 pMouse->_469AE4();//Ritor1: странная, непонятная функция |
2093 | 243 this->field_F4 = 1; |
244 if ( this->field_C ) | |
245 { | |
246 this->field_F4 = 0; | |
247 return; | |
248 } | |
2155 | 249 |
250 //if ( pRenderer->bWindowMode ) | |
0 | 251 { |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2155
diff
changeset
|
252 if ( this->uMouseClickX < 0 || this->uMouseClickY < 0 || this->uMouseClickX > window->GetWidth() - 1 || this->uMouseClickY > window->GetHeight() - 1 ) |
0 | 253 { |
2093 | 254 this->field_F4 = 0; |
0 | 255 return; |
256 } | |
257 } | |
2155 | 258 /*else |
0 | 259 { |
2093 | 260 if ( this->uMouseClickX < 0 ) |
261 this->uMouseClickX = 0; | |
262 if ( this->uMouseClickY < 0 ) | |
263 this->uMouseClickY = 0; | |
264 if ( this->uMouseClickX > 639 ) | |
265 this->uMouseClickX = 639; | |
266 if ( this->uMouseClickY > 479 ) | |
267 this->uMouseClickY = 479; | |
2155 | 268 }*/ |
2093 | 269 this->pCursorBitmapRect.x = this->uMouseClickX; |
2216 | 270 this->pCursorBitmapRect.w = this->uMouseClickY + this->field_5C[0]; //Ritor1: Maybe this->field_5C[0] - cursor width |
2093 | 271 this->pCursorBitmapRect.y = this->uMouseClickY; |
2216 | 272 this->pCursorBitmapRect.z = this->uMouseClickX + this->uCursorBitmapPitch; //Ritor1: Maybe this->uCursorBitmapPitch - cursor height |
2093 | 273 if ( this->uMouseClickX < 0 ) |
274 this->pCursorBitmapRect.x = 0; | |
275 if ( this->uMouseClickY < 0 ) | |
276 this->pCursorBitmapRect.y = 0; | |
2215
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2155
diff
changeset
|
277 if ( this->pCursorBitmapRect.z > window->GetWidth() ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2155
diff
changeset
|
278 this->pCursorBitmapRect.z = window->GetWidth(); |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2155
diff
changeset
|
279 if ( this->pCursorBitmapRect.w > window->GetHeight() ) |
e9625ad08541
fog fix and change 640,480 - window->GetWidth(), window->GetHeight()
Ritor1
parents:
2155
diff
changeset
|
280 this->pCursorBitmapRect.w = window->GetHeight(); |
2219 | 281 this->bActive = false; |
2093 | 282 this->uCursorBitmapWidth = this->pCursorBitmapRect.z - this->pCursorBitmapRect.x; |
283 this->uCursorBitmapHeight = this->pCursorBitmapRect.w - this->pCursorBitmapRect.y; | |
284 if ( this->bRedraw ) | |
0 | 285 { |
286 if ( pMouse->ptr_90 ) | |
287 v9 = 2 * pMouse->uCursorBitmapPitch; | |
288 else | |
289 v9 = 0; | |
2093 | 290 pRenderer->_4A6DF5( this->pCursorBitmap_sysmem, v9, &this->pCursorBitmapPos, pRenderer->pTargetSurface, pRenderer->uTargetSurfacePitch, |
291 &this->pCursorBitmapRect);//срабатывает когда берём курсором вещь в инвенторе | |
292 this->bRedraw = false; | |
0 | 293 } |
294 } | |
295 } | |
296 | |
297 //----- (00469E1C) -------------------------------------------------------- | |
2216 | 298 void Mouse::Activate() |
0 | 299 { |
300 bActive = true; | |
301 } | |
302 | |
303 //----- (00469E24) -------------------------------------------------------- | |
304 void Mouse::_469E24() | |
305 { | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2339
diff
changeset
|
306 free(pCursorBitmap3_sysmembits_16bit); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2339
diff
changeset
|
307 pCursorBitmap3_sysmembits_16bit = nullptr; |
0 | 308 } |
309 | |
310 //----- (00469E3B) -------------------------------------------------------- | |
2223 | 311 void Mouse::DrawCursorToTarget()//??? DrawCursorWithItem |
0 | 312 { |
313 if (!pCursorBitmap3_sysmembits_16bit) | |
314 return; | |
2219 | 315 //пишем на экран курсор с вещью |
1980 | 316 ushort* pSrc = pCursorBitmap3_sysmembits_16bit; |
2335 | 317 for (int y = uCursorWithItemY; y < uCursorWithItemZ; ++y) |
318 for (int x = uCursorWithItemX; x < uCursorWithItemW; ++x) | |
2069 | 319 //pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++; |
320 pRenderer->WritePixel16(x, y, *pSrc++); | |
0 | 321 } |
322 | |
323 //----- (00469EA4) -------------------------------------------------------- | |
2216 | 324 void Mouse::ReadCursorWithItem() |
0 | 325 { |
920 | 326 unsigned int pTextureID; // eax@2 |
327 Texture *pTexture; // edi@2 | |
2334 | 328 // int v8; // ecx@25 |
329 // int v9; // ebx@26 | |
330 // unsigned int v10; // eax@26 | |
331 // int v11; // edx@27 | |
2216 | 332 int pTextureHeight; // [sp+20h] [bp-8h]@15 |
2334 | 333 // unsigned __int16 *v20; // [sp+20h] [bp-8h]@28 |
920 | 334 int pTextureWidth; // [sp+24h] [bp-4h]@12 |
0 | 335 unsigned __int16 *v22; // [sp+24h] [bp-4h]@25 |
336 | |
337 if ( pParty->pPickedItem.uItemID ) | |
338 { | |
1709
8251e59fd7c1
ITEM_ENCHANTED to ITEM_HARDENED, created helper functions to get params from itemtable for ItemGens
Grumpy7
parents:
1687
diff
changeset
|
339 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE); |
920 | 340 pTexture = (Texture *)(pTextureID != -1 ? (int)&pIcons_LOD->pTextures[pTextureID] : 0); |
1038 | 341 |
2216 | 342 if ( (signed int)pMouse->uMouseClickX <= window->GetWidth() - 1 && (signed int)pMouse->uMouseClickY <= window->GetHeight() - 1 ) |
0 | 343 { |
2216 | 344 /*if ( (v4 & 0x80000000u) != 0 ) |
0 | 345 a2 = 0; |
346 if ( (v5 & 0x80000000u) != 0 ) | |
347 { | |
2216 | 348 //v6 = 0; |
0 | 349 v15 = 0; |
2216 | 350 } */ |
351 if ( (signed int)(pTexture->uTextureWidth + pMouse->uMouseClickX) <= window->GetWidth() ) | |
920 | 352 pTextureWidth = pTexture->uTextureWidth; |
0 | 353 else |
2216 | 354 pTextureWidth = window->GetWidth() - pMouse->uMouseClickX; |
355 if ( (signed int)(pTexture->uTextureHeight + pMouse->uMouseClickY) <= window->GetHeight() ) | |
356 pTextureHeight = pTexture->uTextureHeight; | |
0 | 357 else |
2216 | 358 pTextureHeight = window->GetHeight() - pMouse->uMouseClickY; |
920 | 359 if ( !this->pCursorBitmap3_sysmembits_16bit |
2216 | 360 || pMouse->uMouseClickX != this->uCursorWithItemX |
361 || pMouse->uMouseClickY != this->uCursorWithItemY | |
362 || pMouse->uMouseClickX + pTextureWidth != this->uCursorWithItemW | |
363 || pMouse->uMouseClickY + pTextureHeight != this->uCursorWithItemZ ) | |
0 | 364 { |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2339
diff
changeset
|
365 free(this->pCursorBitmap3_sysmembits_16bit); |
1631 | 366 this->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)malloc(2 * pTexture->uTextureHeight * pTexture->uTextureWidth); |
2216 | 367 this->uCursorWithItemX = pMouse->uMouseClickX; |
368 this->uCursorWithItemW = pMouse->uMouseClickX + pTextureWidth; | |
369 this->uCursorWithItemY = pMouse->uMouseClickY; | |
370 this->uCursorWithItemZ = pMouse->uMouseClickY + pTextureHeight; | |
0 | 371 } |
920 | 372 v22 = this->pCursorBitmap3_sysmembits_16bit; |
2216 | 373 |
374 for (int y = this->uCursorWithItemY; y < this->uCursorWithItemZ; ++y) | |
2069 | 375 { |
2216 | 376 for (int x = this->uCursorWithItemX; x < this->uCursorWithItemW; ++x) |
2069 | 377 { |
2216 | 378 *v22++ = pRenderer->ReadPixel16(x, y); |
2069 | 379 } |
380 } | |
381 /*if ( v8 < this->field_4C ) | |
0 | 382 { |
920 | 383 v9 = this->field_48; |
0 | 384 v10 = pRenderer->uTargetSurfacePitch * v8; |
385 do | |
386 { | |
920 | 387 v11 = this->field_40; |
388 v18 = this->field_40; | |
0 | 389 if ( v11 < v9 ) |
390 { | |
391 v20 = &v17[v10 + v11]; | |
392 do | |
393 { | |
2069 | 394 //v12 = v20; |
0 | 395 ++v18; |
2069 | 396 //++v20; |
397 *v22++ = *v20++; | |
0 | 398 } |
399 while ( v18 < v9 ); | |
400 } | |
401 v10 += v16; | |
402 ++v8; | |
403 } | |
920 | 404 while ( v8 < this->field_4C ); |
0 | 405 v6 = v15; |
2069 | 406 }*/ |
407 | |
1567
9f8b3e904e14
Player::ReceiveDamage, very small edits; prepended "Is" to item functions returning bool values (broken, indetified, stolen)
Grumpy7
parents:
1458
diff
changeset
|
408 if (pParty->pPickedItem.IsBroken()) |
2216 | 409 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
|
410 else if (!pParty->pPickedItem.IsIdentified()) |
2216 | 411 pRenderer->DrawTransparentGreenShade(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture); |
0 | 412 else |
2216 | 413 pRenderer->DrawTextureTransparent(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture); |
0 | 414 } |
415 } | |
416 else | |
417 { | |
2369
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2339
diff
changeset
|
418 free(this->pCursorBitmap3_sysmembits_16bit); |
bddcaf5d5db2
removing non-nullptr conditions before frees, chaning 0 and NULL assignmnets to pointers to nullptr assignments
Grumpy7
parents:
2339
diff
changeset
|
419 this->pCursorBitmap3_sysmembits_16bit = nullptr; |
0 | 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) -------------------------------------------------------- |
2339 | 436 void Mouse::UI_OnMouseLeftClick(int *pXY) |
1296 | 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 |
2334 | 443 // int v11; // ecx@52 |
1296 | 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 } | |
2402 | 493 pMessageQueue_50CBD0->AddGUIMessage(control->msg, control->msg_param, 0); |
2098 | 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 } | |
2402 | 509 pMessageQueue_50CBD0->AddGUIMessage(control->msg, control->msg_param, 0); |
2098 | 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 } | |
2402 | 525 pMessageQueue_50CBD0->AddGUIMessage(control->msg, control->msg_param, 0); |
2098 | 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 }*/ | |
2402 | 554 pMessageQueue_50CBD0->AddGUIMessage(UIMSG_STEALFROMACTOR, PID_ID((unsigned __int16)v5), 0); |
1296 | 555 |
556 if ( pParty->bTurnBasedModeOn == 1 ) | |
557 { | |
2242 | 558 if ( pTurnEngine->turn_stage == TE_MOVEMENT ) |
1332 | 559 pTurnEngine->field_18 |= TE_FLAG_8; |
1296 | 560 } |
561 } | |
562 } | |
563 | |
564 | |
1297 | 565 //----- (0041CD4F) -------------------------------------------------------- |
2339 | 566 bool Mouse::UI_OnKeyDown(unsigned int vkKey) |
1297 | 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 } | |
2402 | 641 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); |
1297 | 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 } | |
2402 | 672 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); |
1297 | 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 } | |
2402 | 696 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); |
1297 | 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 } | |
2402 | 764 pMessageQueue_50CBD0->AddGUIMessage(pButton->msg, pButton->msg_param, 0); |
1297 | 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 } | |
2219 | 795 } |