comparison Mouse.cpp @ 2216:3f375342de12

window->GetWidth() continue
author Ritor1
date Sat, 15 Feb 2014 16:00:19 +0600
parents e9625ad08541
children 744ed51880ed
comparison
equal deleted inserted replaced
2215:e9625ad08541 2216:3f375342de12
55 if ( !this->bInitialized || !pName ) 55 if ( !this->bInitialized || !pName )
56 return; 56 return;
57 if ( _stricmp("MICON2", pName) ) 57 if ( _stricmp("MICON2", pName) )
58 pGame->uFlags2 &= 0xFFFFFFEFu; 58 pGame->uFlags2 &= 0xFFFFFFEFu;
59 else 59 else
60 pGame->uFlags2 |= 0x10u; 60 pGame->uFlags2 |= 0x10;
61 if ( _stricmp(this->pCurrentCursorName, pName) ) 61 if ( _stricmp(this->pCurrentCursorName, pName) )
62 strcpy(this->pCurrentCursorName, pName); 62 strcpy(this->pCurrentCursorName, pName);
63 ClearCursor(); 63 ClearCursor();
64 if ( _strnicmp(pName, "MICON1", 5) ) 64 if ( _strnicmp(pName, "MICON1", 5) )
65 { 65 {
84 // 506128: using guessed type int areWeLoadingTexture; 84 // 506128: using guessed type int areWeLoadingTexture;
85 85
86 //----- (00469AE4) -------------------------------------------------------- 86 //----- (00469AE4) --------------------------------------------------------
87 LONG Mouse::_469AE4() 87 LONG Mouse::_469AE4()
88 { 88 {
89 Mouse *v1; // esi@1
90 LONG v2; // ecx@2 89 LONG v2; // ecx@2
91 LONG result; // eax@2 90 LONG result; // eax@2
92 struct tagPOINT Point; // [sp+Ch] [bp-8h]@2 91 struct tagPOINT Point; // [sp+Ch] [bp-8h]@2
93 92
94 v1 = this;
95 this->field_8 = 1; 93 this->field_8 = 1;
96 /*if (pAsyncMouse) 94 /*if (pAsyncMouse)
97 { 95 {
98 v2 = *((int *)pAsyncMouse + 6); 96 v2 = *((int *)pAsyncMouse + 6);
99 Point.x = *((int *)pAsyncMouse + 6); 97 Point.x = *((int *)pAsyncMouse + 6);
105 //if ( pRenderer->bWindowMode ) 103 //if ( pRenderer->bWindowMode )
106 ScreenToClient(window->GetApiHandle(), &Point); 104 ScreenToClient(window->GetApiHandle(), &Point);
107 result = Point.y; 105 result = Point.y;
108 v2 = Point.x; 106 v2 = Point.x;
109 //} 107 //}
110 v1->uMouseClickX = v2; 108 this->uMouseClickX = v2;
111 v1->uMouseClickY = result; 109 this->uMouseClickY = result;
112 if ( true/*pRenderer->bWindowMode*/) 110 if ( true/*pRenderer->bWindowMode*/)
113 goto LABEL_16; 111 goto LABEL_16;
114 //if (pAsyncMouse) 112 //if (pAsyncMouse)
115 // goto LABEL_24; 113 // goto LABEL_24;
116 if ( v2 < 0 ) 114 if ( v2 < 0 )
117 v2 = 0; 115 v2 = 0;
118 if ( result < 0 ) 116 if ( result < 0 )
119 result = 0; 117 result = 0;
120 if ( v2 > 639 ) 118 if ( v2 > window->GetWidth() - 1 )
121 v2 = 639; 119 v2 = window->GetWidth() - 1;
122 if ( result > 479 ) 120 if ( result > window->GetHeight() - 1 )
123 { 121 {
124 result = 479; 122 result = window->GetHeight() - 1;
125 LABEL_16: 123 LABEL_16:
126 //if (pAsyncMouse) 124 //if (pAsyncMouse)
127 // goto LABEL_24; 125 // goto LABEL_24;
128 if (true/*pRenderer->bWindowMode*/ && (v2 < 0 || result < 0 || v2 > 639 || result > 479) ) 126 if (true/*pRenderer->bWindowMode*/ && (v2 < 0 || result < 0 || v2 > window->GetWidth() -1 || result > window->GetHeight() - 1) )
129 goto LABEL_23; 127 goto LABEL_23;
130 } 128 }
131 if ( v1->field_C ) 129 if ( this->field_C )
132 LABEL_23: 130 LABEL_23:
133 v1->bActive = 0; 131 this->bActive = 0;
134 LABEL_24: 132 LABEL_24:
135 v1->field_8 = 0; 133 this->field_8 = 0;
136 return result; 134 return result;
137 } 135 }
138 136
139 //----- (00469BA3) -------------------------------------------------------- 137 //----- (00469BA3) --------------------------------------------------------
140 void Mouse::ClearCursor() 138 void Mouse::ClearCursor()
191 void Mouse::Initialize(OSWindow *window) 189 void Mouse::Initialize(OSWindow *window)
192 { 190 {
193 this->window = window; 191 this->window = window;
194 this->bActive = false; 192 this->bActive = false;
195 this->bInitialized = true; 193 this->bInitialized = true;
194
195 //this->field_8 = 0;//Ritor1: result incorrect uMouseClickX, this->uMouseClickY in _469AE4()
196 this->uCursorBitmapPitch = 0;//Ritor1: it's include
197 for ( uint i = 0; i < 13; i++ )
198 this->field_5C[i] = 0;
199
196 this->pCursorBitmapPos.x = 0; 200 this->pCursorBitmapPos.x = 0;
197 this->pCursorBitmapPos.y = 0; 201 this->pCursorBitmapPos.y = 0;
198 this->uMouseClickX = 0; 202 this->uMouseClickX = 0;
199 this->uMouseClickY = 0; 203 this->uMouseClickY = 0;
200 this->pCursorBitmap_sysmem = 0; 204 this->pCursorBitmap_sysmem = 0;
226 unsigned int v9; // eax@31 230 unsigned int v9; // eax@31
227 231
228 if ( this->bInitialized ) 232 if ( this->bInitialized )
229 { 233 {
230 if ( !this->field_8 && this->bActive && !this->field_C ) 234 if ( !this->field_8 && this->bActive && !this->field_C )
231 pMouse->_469AE4(); 235 pMouse->_469AE4();//Ritor1: странная, непонятная функция
232 this->field_F4 = 1; 236 this->field_F4 = 1;
233 if ( this->field_C ) 237 if ( this->field_C )
234 { 238 {
235 this->field_F4 = 0; 239 this->field_F4 = 0;
236 return; 240 return;
254 this->uMouseClickX = 639; 258 this->uMouseClickX = 639;
255 if ( this->uMouseClickY > 479 ) 259 if ( this->uMouseClickY > 479 )
256 this->uMouseClickY = 479; 260 this->uMouseClickY = 479;
257 }*/ 261 }*/
258 this->pCursorBitmapRect.x = this->uMouseClickX; 262 this->pCursorBitmapRect.x = this->uMouseClickX;
259 this->pCursorBitmapRect.w = this->uMouseClickY + this->field_5C[0];//I think this error 263 this->pCursorBitmapRect.w = this->uMouseClickY + this->field_5C[0]; //Ritor1: Maybe this->field_5C[0] - cursor width
260 this->pCursorBitmapRect.y = this->uMouseClickY; 264 this->pCursorBitmapRect.y = this->uMouseClickY;
261 this->pCursorBitmapRect.z = this->uMouseClickX + this->uCursorBitmapPitch;//and this error 265 this->pCursorBitmapRect.z = this->uMouseClickX + this->uCursorBitmapPitch; //Ritor1: Maybe this->uCursorBitmapPitch - cursor height
262 if ( this->uMouseClickX < 0 ) 266 if ( this->uMouseClickX < 0 )
263 this->pCursorBitmapRect.x = 0; 267 this->pCursorBitmapRect.x = 0;
264 if ( this->uMouseClickY < 0 ) 268 if ( this->uMouseClickY < 0 )
265 this->pCursorBitmapRect.y = 0; 269 this->pCursorBitmapRect.y = 0;
266 if ( this->pCursorBitmapRect.z > window->GetWidth() ) 270 if ( this->pCursorBitmapRect.z > window->GetWidth() )
282 } 286 }
283 } 287 }
284 } 288 }
285 289
286 //----- (00469E1C) -------------------------------------------------------- 290 //----- (00469E1C) --------------------------------------------------------
287 void Mouse::_469E1C() 291 void Mouse::Activate()
288 { 292 {
289 bActive = true; 293 bActive = true;
290 } 294 }
291 295
292 //----- (00469E24) -------------------------------------------------------- 296 //----- (00469E24) --------------------------------------------------------
304 { 308 {
305 if (!pCursorBitmap3_sysmembits_16bit) 309 if (!pCursorBitmap3_sysmembits_16bit)
306 return; 310 return;
307 311
308 ushort* pSrc = pCursorBitmap3_sysmembits_16bit; 312 ushort* pSrc = pCursorBitmap3_sysmembits_16bit;
309 for (uint y = field_44; y < field_4C; ++y) 313 for (uint y = uCursorWithItemY; y < uCursorWithItemZ; ++y)
310 for (uint x = field_40; x < field_48; ++x) 314 for (uint x = uCursorWithItemX; x < uCursorWithItemW; ++x)
311 //pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++; 315 //pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + x] = *pSrc++;
312 pRenderer->WritePixel16(x, y, *pSrc++); 316 pRenderer->WritePixel16(x, y, *pSrc++);
313 } 317 }
314 318
315 //----- (00469EA4) -------------------------------------------------------- 319 //----- (00469EA4) --------------------------------------------------------
316 void Mouse::_469EA4() 320 void Mouse::ReadCursorWithItem()
317 { 321 {
318 //Mouse *v1; // esi@1
319 unsigned int pTextureID; // eax@2 322 unsigned int pTextureID; // eax@2
320 Texture *pTexture; // edi@2 323 Texture *pTexture; // edi@2
321 unsigned int v4; // ecx@3
322 unsigned int v5; // eax@3
323 unsigned int v6; // ebx@5
324 int v7; // ecx@15
325 int v8; // ecx@25 324 int v8; // ecx@25
326 int v9; // ebx@26 325 int v9; // ebx@26
327 unsigned int v10; // eax@26 326 unsigned int v10; // eax@26
328 int v11; // edx@27 327 int v11; // edx@27
329 //unsigned __int16 *v12; // edx@29 328 int pTextureHeight; // [sp+20h] [bp-8h]@15
330 //unsigned __int16 *v13; // ebx@29
331 unsigned int a2; // [sp+Ch] [bp-1Ch]@5
332 unsigned int v15; // [sp+10h] [bp-18h]@5
333 //unsigned int v16; // [sp+14h] [bp-14h]@25
334 //unsigned __int16 *v17; // [sp+18h] [bp-10h]@25
335 //int v18; // [sp+1Ch] [bp-Ch]@27
336 int v19; // [sp+20h] [bp-8h]@15
337 unsigned __int16 *v20; // [sp+20h] [bp-8h]@28 329 unsigned __int16 *v20; // [sp+20h] [bp-8h]@28
338 int pTextureWidth; // [sp+24h] [bp-4h]@12 330 int pTextureWidth; // [sp+24h] [bp-4h]@12
339 unsigned __int16 *v22; // [sp+24h] [bp-4h]@25 331 unsigned __int16 *v22; // [sp+24h] [bp-4h]@25
340 332
341 //v1 = this;
342 if ( pParty->pPickedItem.uItemID ) 333 if ( pParty->pPickedItem.uItemID )
343 { 334 {
344 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE); 335 pTextureID = pIcons_LOD->LoadTexture(pParty->pPickedItem.GetIconName(), TEXTURE_16BIT_PALETTE);
345 pTexture = (Texture *)(pTextureID != -1 ? (int)&pIcons_LOD->pTextures[pTextureID] : 0); 336 pTexture = (Texture *)(pTextureID != -1 ? (int)&pIcons_LOD->pTextures[pTextureID] : 0);
346 337
347 v4 = pMouse->uMouseClickX; 338 if ( (signed int)pMouse->uMouseClickX <= window->GetWidth() - 1 && (signed int)pMouse->uMouseClickY <= window->GetHeight() - 1 )
348 v5 = pMouse->uMouseClickY; 339 {
349 340 /*if ( (v4 & 0x80000000u) != 0 )
350 v6 = v5;
351 a2 = v4;
352 v15 = v5;
353 if ( (signed int)v4 <= window->GetWidth() - 1 && (signed int)v5 <= window->GetHeight() - 1 )
354 {
355 if ( (v4 & 0x80000000u) != 0 )
356 a2 = 0; 341 a2 = 0;
357 if ( (v5 & 0x80000000u) != 0 ) 342 if ( (v5 & 0x80000000u) != 0 )
358 { 343 {
359 v6 = 0; 344 //v6 = 0;
360 v15 = 0; 345 v15 = 0;
361 } 346 } */
362 if ( (signed int)(pTexture->uTextureWidth + a2) <= window->GetWidth() ) 347 if ( (signed int)(pTexture->uTextureWidth + pMouse->uMouseClickX) <= window->GetWidth() )
363 pTextureWidth = pTexture->uTextureWidth; 348 pTextureWidth = pTexture->uTextureWidth;
364 else 349 else
365 pTextureWidth = window->GetWidth() - a2; 350 pTextureWidth = window->GetWidth() - pMouse->uMouseClickX;
366 if ( (signed int)(pTexture->uTextureHeight + v6) <= window->GetHeight() ) 351 if ( (signed int)(pTexture->uTextureHeight + pMouse->uMouseClickY) <= window->GetHeight() )
367 { 352 pTextureHeight = pTexture->uTextureHeight;
368 v19 = pTexture->uTextureHeight;
369 v7 = pTexture->uTextureHeight;
370 }
371 else 353 else
372 { 354 pTextureHeight = window->GetHeight() - pMouse->uMouseClickY;
373 v7 = window->GetHeight() - v6;
374 v19 = window->GetHeight() - v6;
375 }
376 if ( !this->pCursorBitmap3_sysmembits_16bit 355 if ( !this->pCursorBitmap3_sysmembits_16bit
377 || a2 != this->field_40 356 || pMouse->uMouseClickX != this->uCursorWithItemX
378 || v6 != this->field_44 357 || pMouse->uMouseClickY != this->uCursorWithItemY
379 || a2 + pTextureWidth != this->field_48 358 || pMouse->uMouseClickX + pTextureWidth != this->uCursorWithItemW
380 || v6 + v7 != this->field_4C ) 359 || pMouse->uMouseClickY + pTextureHeight != this->uCursorWithItemZ )
381 { 360 {
382 if ( this->pCursorBitmap3_sysmembits_16bit ) 361 if ( this->pCursorBitmap3_sysmembits_16bit )
383 free(this->pCursorBitmap3_sysmembits_16bit); 362 free(this->pCursorBitmap3_sysmembits_16bit);
384 this->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)malloc(2 * pTexture->uTextureHeight * pTexture->uTextureWidth); 363 this->pCursorBitmap3_sysmembits_16bit = (unsigned __int16 *)malloc(2 * pTexture->uTextureHeight * pTexture->uTextureWidth);
385 this->field_40 = a2; 364 this->uCursorWithItemX = pMouse->uMouseClickX;
386 this->field_48 = a2 + pTextureWidth; 365 this->uCursorWithItemW = pMouse->uMouseClickX + pTextureWidth;
387 this->field_44 = v6; 366 this->uCursorWithItemY = pMouse->uMouseClickY;
388 this->field_4C = v6 + v19; 367 this->uCursorWithItemZ = pMouse->uMouseClickY + pTextureHeight;
389 } 368 }
390 v8 = this->field_44;
391 v22 = this->pCursorBitmap3_sysmembits_16bit; 369 v22 = this->pCursorBitmap3_sysmembits_16bit;
392 //v17 = pRenderer->pTargetSurface; 370
393 //v16 = pRenderer->uTargetSurfacePitch; 371 for (int y = this->uCursorWithItemY; y < this->uCursorWithItemZ; ++y)
394 372 {
395 v10 = pRenderer->uTargetSurfacePitch * v8; 373 for (int x = this->uCursorWithItemX; x < this->uCursorWithItemW; ++x)
396 v11 = this->field_40; 374 {
397 for (int y = this->field_44; y < this->field_4C; ++y) 375 *v22++ = pRenderer->ReadPixel16(x, y);
398 {
399 //v20 = &v17[v10 + v11];
400 for (int x = this->field_40; x < this->field_48; ++x)
401 {
402 //++v18;
403 *v22++ = pRenderer->ReadPixel16(x, y);
404 } 376 }
405 } 377 }
406 /*if ( v8 < this->field_4C ) 378 /*if ( v8 < this->field_4C )
407 { 379 {
408 v9 = this->field_48; 380 v9 = this->field_48;
428 } 400 }
429 while ( v8 < this->field_4C ); 401 while ( v8 < this->field_4C );
430 v6 = v15; 402 v6 = v15;
431 }*/ 403 }*/
432 404
433 v6 = v15;
434 if (pParty->pPickedItem.IsBroken()) 405 if (pParty->pPickedItem.IsBroken())
435 pRenderer->DrawTransparentRedShade(a2, v6, pTexture); 406 pRenderer->DrawTransparentRedShade(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture);
436 else if (!pParty->pPickedItem.IsIdentified()) 407 else if (!pParty->pPickedItem.IsIdentified())
437 pRenderer->DrawTransparentGreenShade(a2, v6, pTexture); 408 pRenderer->DrawTransparentGreenShade(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture);
438 else 409 else
439 pRenderer->DrawTextureTransparent(a2, v6, pTexture); 410 pRenderer->DrawTextureTransparent(pMouse->uMouseClickX, pMouse->uMouseClickY, pTexture);
440 } 411 }
441 } 412 }
442 else 413 else
443 { 414 {
444 if ( this->pCursorBitmap3_sysmembits_16bit ) 415 if ( this->pCursorBitmap3_sysmembits_16bit )
448 } 419 }
449 } 420 }
450 } 421 }
451 422
452 //----- (0046A080) -------------------------------------------------------- 423 //----- (0046A080) --------------------------------------------------------
453 void Mouse::Activate(int bActive) 424 void Mouse::ChangeActivation(int a1)
454 { 425 {
455 bActive = bActive; 426 this->bActive = a1;
456 } 427 }
457 428
458 //----- (0046A08A) -------------------------------------------------------- 429 //----- (0046A08A) --------------------------------------------------------
459 void Mouse::SetMouseClick(int x, int y) 430 void Mouse::SetMouseClick(int x, int y)
460 { 431 {
816 } 787 }
817 } 788 }
818 break; 789 break;
819 } 790 }
820 default: 791 default:
821 {
822 break; 792 break;
823 } 793 }
824 } 794 }
825 } 795 }
826 }