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