Mercurial > mm7
changeset 2219:e6771956e74a
for mouse
author | Ritor1 |
---|---|
date | Mon, 17 Feb 2014 17:28:06 +0600 |
parents | e8f9a06c7bcb |
children | 7dccb5752b66 |
files | Mouse.cpp OSWindow.cpp Render.cpp mm7_2.cpp |
diffstat | 4 files changed, 163 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/Mouse.cpp Sun Feb 16 21:49:39 2014 +0600 +++ b/Mouse.cpp Mon Feb 17 17:28:06 2014 +0600 @@ -25,8 +25,16 @@ //----- (00469860) -------------------------------------------------------- void Mouse::GetClickPos(unsigned int *pX, unsigned int *pY) { - *pX = uMouseClickX; - *pY = uMouseClickY; + if ( !_stricmp(this->pCurrentCursorName, "MICON2") )//смещение для курсора-мишени + { + *pX = uMouseClickX + 14; + *pY = uMouseClickY + 14; + } + else + { + *pX = uMouseClickX; + *pY = uMouseClickY; + } } //----- (004698A6) -------------------------------------------------------- @@ -52,23 +60,25 @@ //----- (00469903) -------------------------------------------------------- void Mouse::SetCursorBitmap(const char *pName) { + DDSURFACEDESC2 Dst; + if ( !this->bInitialized || !pName ) return; if ( _stricmp("MICON2", pName) )//если кусор не мишень - pGame->uFlags2 &= 0xFFFFFFEFu; + pGame->uFlags2 &= 0xFFFFFFEF; else pGame->uFlags2 |= 0x10; if ( _stricmp(this->pCurrentCursorName, pName) ) strcpy(this->pCurrentCursorName, pName); ClearCursor(); - if ( _strnicmp(pName, "MICON1", 5) )//если курсор не стрелка + if ( _strnicmp(pName, "MICON1", 5) )//for click to item / если курсор с вещью { this->uCursorTextureID = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); this->uCursorTextureID_2 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); this->AllocCursorSystemMem(); this->field_C = 0; - this->bRedraw = 1; - this->bActive = 1; + this->bRedraw = true; + this->bActive = true; if ( !areWeLoadingTexture ) { if (uCursorTextureID != -1) @@ -77,6 +87,36 @@ } return; } + /*if ( !_strnicmp(pName, "MICON", 4) ) + { + this->uCursorTextureID = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); + this->uCursorTextureID_2 = pIcons_LOD->LoadTexture(pName, TEXTURE_16BIT_PALETTE); + memset(&Dst, 0, sizeof(Dst)); + //Texture texture = pIcons_LOD->pTextures[this->uCursorTextureID]; + Dst.dwSize = 124; + if ( this->uCursorTextureID != pIcons_LOD->FindTextureByName("pending") ) + { + if ( pRenderer->LockSurface_DDraw4((IDirectDrawSurface4 *)pIcons_LOD->pTextures[this->uCursorTextureID].pPalette16, &Dst, DDLOCK_WAIT) ) + { + unsigned __int8 * v6 = pIcons_LOD->pTextures[this->uCursorTextureID].pLevelOfDetail0_prolly_alpha_mask; + /*v9 = Dst.lpSurface; + v12 = 2 * (Dst.lPitch / 2 - texture->uTextureWidth); + + for ( v13 = 0; v13 < texture->uTextureHeight; v13++ ) + { + for ( v10 = 0; v10 < texture->uTextureWidth; v10++ ) + { + if ( v5[*v6] ) + *(_WORD *)v9 = texture->pPalette16[*v6]; + v9 = (char *)v9 + 2; + ++v6; + } + v9 = (char *)v9 + v12; + } + ErrD3D((pIcons_LOD->pTextures[this->uCursorTextureID].pTextureSurface)->Unlock(0)); + } + }*/ + } this->bActive = false; this->field_C = 1; window->SetCursor(pName); @@ -128,7 +168,7 @@ } if ( this->field_C ) LABEL_23: - this->bActive = 0; + this->bActive = false; LABEL_24: this->field_8 = 0; return result; @@ -137,13 +177,7 @@ //----- (00469BA3) -------------------------------------------------------- void Mouse::ClearCursor() { - //Mouse *v1; // esi@1 - //void *v2; // eax@1 - //void **v3; // esi@5 - - //v1 = this; - //v2 = this->pCursorBitmap_sysmem; - this->bActive = 0; + this->bActive = false; if ( this->pCursorBitmap_sysmem ) { free(this->pCursorBitmap_sysmem); @@ -154,7 +188,6 @@ free(this->pCursorBitmap2_sysmem); this->pCursorBitmap2_sysmem = 0; } - //v3 = &this->ptr_90; if ( this->ptr_90 ) free(this->ptr_90); this->ptr_90 = 0; @@ -163,7 +196,7 @@ //----- (00469BE6) -------------------------------------------------------- void Mouse::AllocCursorSystemMem() { - bActive = 0; + bActive = false; if (!pCursorBitmap_sysmem) pCursorBitmap_sysmem = (unsigned __int16 *)DoAllocCursorMem(); if (!pCursorBitmap2_sysmem) @@ -271,7 +304,7 @@ this->pCursorBitmapRect.z = window->GetWidth(); if ( this->pCursorBitmapRect.w > window->GetHeight() ) this->pCursorBitmapRect.w = window->GetHeight(); - this->bActive = 0; + this->bActive = false; this->uCursorBitmapWidth = this->pCursorBitmapRect.z - this->pCursorBitmapRect.x; this->uCursorBitmapHeight = this->pCursorBitmapRect.w - this->pCursorBitmapRect.y; if ( this->bRedraw ) @@ -304,11 +337,11 @@ } //----- (00469E3B) -------------------------------------------------------- -void Mouse::DrawCursorToTarget() +void Mouse::DrawCursorToTarget()//??? { if (!pCursorBitmap3_sysmembits_16bit) return; - + //пишем на экран курсор с вещью ushort* pSrc = pCursorBitmap3_sysmembits_16bit; for (uint y = uCursorWithItemY; y < uCursorWithItemZ; ++y) for (uint x = uCursorWithItemX; x < uCursorWithItemW; ++x) @@ -792,4 +825,93 @@ break; } } -} \ No newline at end of file +} + +//-----(0046AE97)------------------------------------------------------------------ +/*char AsyncMouse::LoadCursor(const char *pContainer) +{ + int v3; // eax@1 + HRESULT v4; // eax@1 + char result; // al@3 + HRESULT a2; // [sp+8h] [bp-B0h]@1 + int v7; // [sp+58h] [bp-60h]@1 + Texture texture; // [sp+6Ch] [bp-4Ch]@1 + char v9; // [sp+B4h] [bp-4h]@1 + + EnterCriticalSection(&pGame->pThreadWardInstance->cs2); + v3 = *((_DWORD *)this + 1); + a2 = 100; + v7 = 0; + v4 = (*(int (__stdcall **)(int, _DWORD, _DWORD, _DWORD, signed int, HRESULT *))(*(_DWORD *)v3 + 20))( + v3, + 0, + 0, + 0, + 1024, + &a2); + CheckHRESULT((CheckHRESULT_stru0 *)&v9, v4, "E:\\WORK\\MSDEV\\MM7\\MM7\\Code\\MouseAsync.cpp", 129, 0); + Texture::Texture(&texture); + if ( LODFile_IconsBitmaps::LoadTextureFromLOD(&texture, pContainer, TEXTURE_16BIT_PALETTE) != -1 + && AsyncMouse::DrawCursor(&texture, *((IDirectDrawSurface4 **)this + 1), 0) ) + { + Texture::Release(&thisa); + LeaveCriticalSection(&pGame->pThreadWardInstance->cs2); + result = 1; + } + else + result = 0; + return result; +}*/ + +/*bool Mouse::Draw_MICON_Cursor(texture_id, IDirectDrawSurface4 *a2, int a3) +{ + bool result; // eax@1 + unsigned __int16 *v5; // ebx@2 + unsigned __int8 *v6; // edx@2 + int v7; // esi@2 + int v8; // ecx@2 + LPVOID v9; // edi@2 + int v10; // ecx@5 + DDSURFACEDESC2 Dst; // [sp+0h] [bp-84h]@1 + __int32 v12; // [sp+7Ch] [bp-8h]@3 + int v13; // [sp+80h] [bp-4h]@3 + + Dst.dwSize = 124; + result = Render::LockSurface_DDraw4(&pRenderer, a2, &Dst, 1); + if ( result ) + { + //v5 = a1->pPalette16; + v6 = texture->pLevelOfDetail0_prolly_alpha_mask; + v7 = texture->uTextureWidth; + v8 = texture->uTextureHeight; + v9 = Dst.lpSurface; + if ( v8 > 0 ) + { + v12 = 2 * (Dst.lPitch / 2 - v7); + v13 = v8; + do + { + if ( v7 > 0 ) + { + v10 = v7; + do + { + if ( v5[*v6] ) + *(_WORD *)v9 = texture->pPalette16[*v6]; + v9 = (char *)v9 + 2; + ++v6; + --v10; + } + while ( v10 ); + } + v9 = (char *)v9 + v12; + --v13; + } + while ( v13 ); + } + result = ((int (__fastcall *)(IDirectDrawSurface4Vtbl *, unsigned __int8 *, IDirectDrawSurface4 *, int))a2->lpVtbl->Unlock)(a2->lpVtbl, v6, a2, a3); + } + LOBYTE(result) = 1; + return result; +}*/ +
--- a/OSWindow.cpp Sun Feb 16 21:49:39 2014 +0600 +++ b/OSWindow.cpp Mon Feb 17 17:28:06 2014 +0600 @@ -473,9 +473,15 @@ GetCursorPos(&cursor_pos); if (!strcmp(cursor_name, "MICON1") ) + { SetClassLongPtrW(api_handle, GCLP_HCURSOR, (LONG)LoadCursorW(GetModuleHandleW(nullptr), IDC_ARROW)); + //AsyncMouse::LoadCursor(cursor_name) + } else if (!strcmp(cursor_name, "MICON2") ) + { SetClassLongPtrW(api_handle, GCLP_HCURSOR, (LONG)LoadCursorW(GetModuleHandleW(nullptr), L"Target")); + //AsyncMouse::LoadCursor(cursor_name) + } else if (!strcmp(cursor_name, "MICON3") ) SetClassLongPtrW(api_handle, GCLP_HCURSOR, (LONG)LoadCursorW(GetModuleHandleW(nullptr), IDC_WAIT));
--- a/Render.cpp Sun Feb 16 21:49:39 2014 +0600 +++ b/Render.cpp Mon Feb 17 17:28:06 2014 +0600 @@ -6799,24 +6799,24 @@ //----- (004A6DF5) -------------------------------------------------------- void Render::_4A6DF5(unsigned __int16 *pBitmap, unsigned int uBitmapPitch, Vec2_int_ *pBitmapXY, void *pTarget, unsigned int uTargetPitch, Vec4_int_ *a7) { - int v8; // ecx@3 - unsigned __int16 *v10; // ebx@4 - int v11; // esi@4 + int width; // ecx@3 + unsigned __int16 *pixels; // ebx@4 + int height; // esi@4 if ( !pBitmap || !pTarget) return; - v8 = a7->z - a7->x; - v11 = a7->w - a7->y; - v10 = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y; - for ( int y = 0; y < v11; ++y ) - { - for ( int x = 0; x < v8; ++x ) - { - WritePixel16(a7->x + x, a7->y + y, *v10); - ++v10; - } - v10 += uTargetPitch - v8; + width = a7->z - a7->x; + height = a7->w - a7->y; + pixels = (unsigned short *)pTarget + a7->x + uTargetPitch * a7->y; + for ( int y = 0; y < height; ++y ) + { + for ( int x = 0; x < width; ++x ) + { + WritePixel16(a7->x + x, a7->y + y, *pixels); + ++pixels; + } + pixels += uTargetPitch - width; } }
--- a/mm7_2.cpp Sun Feb 16 21:49:39 2014 +0600 +++ b/mm7_2.cpp Mon Feb 17 17:28:06 2014 +0600 @@ -2862,7 +2862,7 @@ pGUIWindow2 = 0; pAudioPlayer->StopChannels(-1, -1);//остановить/подготовить канал - pMouse->RemoveHoldingItem();//установть курсор + pMouse->RemoveHoldingItem();//избавить курсор от вещи pIcons_LOD->_inlined_sub2();