Mercurial > mm7
diff GUIWindow.cpp @ 2275:8193a64c7461
Слияние
author | Ritor1 |
---|---|
date | Fri, 14 Mar 2014 09:32:42 +0600 |
parents | 42b6a910b5d8 |
children | 0cd17b0d36c2 |
line wrap: on
line diff
--- a/GUIWindow.cpp Fri Mar 14 09:32:25 2014 +0600 +++ b/GUIWindow.cpp Fri Mar 14 09:32:42 2014 +0600 @@ -80,41 +80,27 @@ uNumMessages = pMessages[0].field_8 != 0; } - //----- (004356B9) -------------------------------------------------------- void GUIMessageQueue::PopMessage(enum UIMessageType *pType, int *pParam, int *a4) { - signed int v4; // edx@1 - GUIMessage *v5; // eax@2 - - v4 = 0; if ( this->uNumMessages ) { - v5 = this->pMessages; *pType = this->pMessages[0].eType; *pParam = this->pMessages[0].param; *a4 = this->pMessages[0].field_8; if ( (signed int)(this->uNumMessages - 1) > 0 ) { - do + for ( uint i = 0; i < (signed int)(this->uNumMessages - 1); ++i ) { - v5->eType = v5[1].eType; - v5->param = v5[1].param; - v5->field_8 = v5[1].field_8; - ++v4; - ++v5; + this->pMessages[i].eType = this->pMessages[i + 1].eType; + this->pMessages[i].param = this->pMessages[i + 1].param; + this->pMessages[i].field_8 = this->pMessages[i + 1].field_8; } - while ( v4 < (signed int)(this->uNumMessages - 1) ); } --this->uNumMessages; } } - - - - - //----- (0041B4E1) -------------------------------------------------------- int __fastcall GUI_ReplaceHotkey(unsigned __int8 uOldHotkey, unsigned __int8 uNewHotkey, char bFirstCall) { @@ -160,9 +146,6 @@ return result; } - - - //----- (0041B438) -------------------------------------------------------- GUIButton *__fastcall GUI_HandleHotkey(unsigned __int8 uHotkey) { @@ -343,9 +326,7 @@ case WINDOW_null: return; default: - { break; - } } //v8 = this->pControlsHead; if ( this->pControlsHead ) @@ -373,11 +354,6 @@ uNumVisibleWindows = uNumVisibleWindows - 1; } - - - - - //----- (0041CD3B) -------------------------------------------------------- GUIButton *GUIWindow::GetControl(unsigned int uID) { @@ -647,30 +623,14 @@ void GUIWindow::DrawMessageBox(int arg0) { unsigned int v2; // edi@1 - GUIWindow *v3; // ebx@1 signed int v4; // esi@2 unsigned int v5; // eax@2 - unsigned int v6; // edx@4 - unsigned int v7; // ecx@6 - unsigned int v8; // eax@9 - __int32 v9; // eax@10 - unsigned int v10; // eax@18 - LONG v11; // ecx@18 - unsigned int v12; // edx@18 - unsigned int v13; // eax@18 - const char *v14; // ecx@18 - int v15; // eax@19 unsigned int v16; // esi@19 - const char *v17; // ebx@25 - int v18; // eax@26 - GUIWindow v19; // [sp+Ch] [bp-60h]@18 - POINT a2; // [sp+60h] [bp-Ch]@8 - unsigned int v21; // [sp+68h] [bp-4h]@18 + GUIWindow current_window; // [sp+Ch] [bp-60h]@18 + POINT cursor; // [sp+60h] [bp-Ch]@8 unsigned int v22; // [sp+74h] [bp+8h]@2 - unsigned int v23; // [sp+74h] [bp+8h]@18 v2 = 0; - v3 = this; if ( arg0 ) { v4 = pViewport->uViewportTL_X; @@ -684,108 +644,82 @@ v5 = window->GetWidth(); v22 = window->GetHeight(); } - v6 = this->uFrameX; + pMouse->GetCursorPos(&cursor); if ( (signed int)this->uFrameX >= v4 ) { - v7 = this->uFrameWidth; - if ( (signed int)(v7 + v6) <= (signed int)v5 ) - goto LABEL_9; - v3->uFrameX = v5 - v7; + if ( (signed int)(this->uFrameWidth + this->uFrameX) > (signed int)v5 ) + { + this->uFrameX = v5 - this->uFrameWidth; + this->uFrameY = cursor.y + 30; + } } else { this->uFrameX = v4; + this->uFrameY = cursor.y + 30; } - v3->uFrameY = pMouse->GetCursorPos(&a2)->y + 30; -LABEL_9: - v8 = v3->uFrameY; - if ( (signed int)v8 >= (signed int)v2 ) + + if ( (signed int)this->uFrameY >= (signed int)v2 ) { - if ( (signed int)(v8 + v3->uFrameHeight) <= (signed int)v22 ) - goto LABEL_14; - v9 = pMouse->GetCursorPos(&a2)->y - v3->uFrameHeight - 30; + if ( (signed int)(this->uFrameY + this->uFrameHeight) > (signed int)v22 ) + this->uFrameY = cursor.y - this->uFrameHeight - 30; } else - { - v9 = pMouse->GetCursorPos(&a2)->y + 30; - } - v3->uFrameY = v9; -LABEL_14: - if ( (signed int)v3->uFrameY < (signed int)v2 ) - v3->uFrameY = v2; - if ( (signed int)v3->uFrameX < v4 ) - v3->uFrameX = v4; - v10 = v3->uFrameWidth; - v11 = v3->uFrameX; - v12 = v3->uFrameY; - v21 = v10; - a2.y = v11; - v3->uFrameZ = v10 + v11 - 1; - v13 = v3->uFrameHeight; - v3->uFrameW = v13 + v12 - 1; - memcpy(&v19, v3, sizeof(v19)); - v19.uFrameX += 12; - v19.uFrameWidth -= 24; - v19.uFrameY += 12; - v19.uFrameHeight -= 12; - v19.uFrameZ = v19.uFrameWidth + v19.uFrameX - 1; - v23 = v12; - v19.uFrameW = v19.uFrameHeight + v19.uFrameY - 1; - v14 = v3->Hint; - if ( v14 ) - { - v15 = pFontLucida->CalcTextHeight(v14, &v19, 0, 0); - v12 = v23; - v16 = v15 + 24; - } + this->uFrameY = cursor.y + 30; + if ( (signed int)this->uFrameY < (signed int)v2 ) + this->uFrameY = v2; + if ( (signed int)this->uFrameX < v4 ) + this->uFrameX = v4; + this->uFrameZ = this->uFrameWidth + this->uFrameX - 1; + this->uFrameW = this->uFrameHeight + this->uFrameY - 1; + memcpy(¤t_window, this, sizeof(current_window)); + current_window.uFrameX += 12; + current_window.uFrameWidth -= 24; + current_window.uFrameY += 12; + current_window.uFrameHeight -= 12; + current_window.uFrameZ = current_window.uFrameWidth + current_window.uFrameX - 1; + current_window.uFrameW = current_window.uFrameHeight + current_window.uFrameY - 1; + if ( this->Hint ) + v16 = pFontLucida->CalcTextHeight(this->Hint, ¤t_window, 0, 0) + 24; else - { - v16 = v13; - } + v16 = this->uFrameHeight; if ( (signed int)v16 < 64 ) v16 = 64; - if ( (signed int)(v16 + v12) > 479 ) - v16 = 479 - v12; - DrawPopupWindow(a2.y, v12, v21, v16); - v17 = v3->Hint; - if ( v17 ) - { - v18 = pFontLucida->CalcTextHeight(v17, &v19, 0, 0); - v19.DrawTitleText(pFontLucida, 0, (signed int)(v16 - v18) / 2 - 14, 0, v17, 3); - } + if ( (signed int)(v16 + this->uFrameY) > 479 ) + v16 = 479 - this->uFrameY; + DrawPopupWindow(this->uFrameX, this->uFrameY, this->uFrameWidth, v16); + if ( this->Hint ) + current_window.DrawTitleText(pFontLucida, 0, (signed int)(v16 - pFontLucida->CalcTextHeight(this->Hint, ¤t_window, 0, 0)) / 2 - 14, 0, this->Hint, 3); } - - - //----- (00411B59) -------------------------------------------------------- void __fastcall LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer) { - unsigned int v2; // esi@1 - unsigned int v3; // edi@1 + //unsigned int v2; // esi@1 + //unsigned int v3; // edi@1 FILE *v4; // ebx@1 FILE *v5; // eax@2 char pContainerName[64]; // [sp+Ch] [bp-44h]@1 - unsigned int v7; // [sp+4Ch] [bp-4h]@1 + //unsigned int v7; // [sp+4Ch] [bp-4h]@1 - v2 = uSlot; - v7 = uPlayer; - v3 = uSlot + 1; + //v2 = uSlot; + //v7 = uPlayer; + //v3 = uSlot + 1; sprintf(pContainerName, "data\\lloyd%d%d.pcx", uPlayer, uSlot + 1); v4 = fopen(pContainerName, "rb"); if ( v4 ) { - pSavegameThumbnails[v2].LoadFromFILE(v4, 0, 1u); + pSavegameThumbnails[uSlot].LoadFromFILE(v4, 0, 1); fclose(v4); } else { - sprintf(pContainerName, "lloyd%d%d.pcx", v7, v3); + sprintf(pContainerName, "lloyd%d%d.pcx", uPlayer, uSlot + 1); v5 = pNew_LOD->FindContainer(pContainerName, 1); if ( v5 ) - pSavegameThumbnails[v2].LoadFromFILE(v5, 0, 0); + pSavegameThumbnails[uSlot].LoadFromFILE(v5, 0, 0); else - *((int *)&pSavegameThumbnails.data()->pPixels + 10 * v2) = 0; + *((int *)&pSavegameThumbnails.data()->pPixels + 10 * uSlot) = 0; } } @@ -900,9 +834,7 @@ pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); } else - { pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); - } return; } if ( current_npc_text ) @@ -925,9 +857,7 @@ pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); } else - { pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); - } return; } for ( v8 = 0; v8 < uNumDialogueNPCPortraits; ++v8 ) @@ -964,9 +894,7 @@ pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); } else - { pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); - } return; } v4 = (char *)pDialogueNPCCount - 1; @@ -981,15 +909,11 @@ pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); } else - { pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); - } return; } if ( v4 || !dword_591080 )// - { SimpleHouseDialog(); - } else { sprintfex( pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], @@ -1058,9 +982,7 @@ pRenderer->DrawTextureIndexed(476, 451, &pIcons_LOD->pTextures[uTextureID_x_ok_u]); } else - { pRenderer->DrawTextureIndexed(471, 445, &pIcons_LOD->pTextures[uExitCancelTextureId]); - } } //----- (004B1854) -------------------------------------------------------- @@ -1117,13 +1039,11 @@ this->DrawTitleText(pFontArrus, 0, (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), this, 0, 0)) / 2 + 101, Color16(0xFFu, 0xFFu, 0x9Bu), pTmpBuf.data(), 3); } - - //----- (0044D406) -------------------------------------------------------- void GUIWindow::DrawTitleText( GUIFont *a2, signed int uHorizontalMargin, unsigned int uVerticalMargin, unsigned __int16 uDefaultColor, const char *pInString, unsigned int uLineSpacing ) { - GUIWindow *pWindow; // esi@1 + //GUIWindow *pWindow; // esi@1 unsigned int v8; // ebx@1 char *v9; // eax@1 unsigned int v11; // edi@1 @@ -1132,14 +1052,14 @@ GUIFont *pFont; // [sp+Ch] [bp-4h]@1 const char *Stra; // [sp+24h] [bp+14h]@5 - pWindow = this; + //pWindow = this; pFont = a2; v8 = this->uFrameWidth - uHorizontalMargin; ui_current_text_color = uDefaultColor; v9 = FitTextInAWindow(pInString, a2, this, uHorizontalMargin, 0); Stra = strtok(v9, "\n"); - v11 = uHorizontalMargin + pWindow->uFrameX; - v12 = uVerticalMargin + pWindow->uFrameY; + v11 = uHorizontalMargin + this->uFrameX; + v12 = uVerticalMargin + this->uFrameY; while ( 1 ) { if ( !Stra ) @@ -1154,8 +1074,6 @@ } // 5C6DB4: using guessed type int ui_current_text_color; - - //----- (0044CE08) -------------------------------------------------------- void GUIWindow::DrawText( GUIFont *a2, signed int uX, int uY, unsigned int uFontColor, const char *Str, int a7, int a8, signed int uFontShadowColor ) { @@ -1202,9 +1120,7 @@ if ( !uX ) uX = 12; if ( a8 ) - { v32 = Str; - } else { v11 = (int)FitTextInAWindow(Str, v10, v9, uX, 0); @@ -1230,7 +1146,7 @@ switch ( (unsigned __int8)v11 ) { case 9u: - strncpy(Dest, &v32[v14 + 1], 3u); + strncpy(Dest, &v32[v14 + 1], 3); Dest[3] = 0; pInString += 3; v29 = atoi(Dest); @@ -1244,17 +1160,21 @@ v13 = uY + v31->uFrameY; v12 = uX + v29 + v31->uFrameX; if ( a8 ) - goto LABEL_36; + { + v11 = v11 + v13 - 3; + if ( v11 > a8 ) + return; + } break; case 0xCu: - strncpy(Dest, &v32[v14 + 1], 5u); + strncpy(Dest, &v32[v14 + 1], 5); Dest[5] = 0; v11 = atoi(Dest); pInString += 5; uFontColor = v11; break; case 0xDu: - strncpy(Dest, &v32[v14 + 1], 3u); + strncpy(Dest, &v32[v14 + 1], 3); Dest[3] = 0; pInString += 3; v18 = atoi(Dest); @@ -1264,7 +1184,6 @@ if ( a8 ) { v11 = LOBYTE(v10->uFontHeight); -LABEL_36: v11 = v11 + v13 - 3; if ( v11 > a8 ) return; @@ -1285,24 +1204,11 @@ v12 += v10->pMetrics[v15].uLeftSpacing; v17 = (int)((char *)&v10[1] + v10->font_pixels_offset[v15]); if ( (short)uFontColor ) - pRenderer->DrawText( - v12, - v13, - (unsigned __int8 *)v17, - v16, - LOBYTE(v10->uFontHeight), - v10->pFontPalettes[0], - uFontColor, - uFontShadowColor); + pRenderer->DrawText(v12, v13, (unsigned __int8 *)v17, v16, LOBYTE(v10->uFontHeight), + v10->pFontPalettes[0], uFontColor, uFontShadowColor); else - pRenderer->DrawTextPalette( - v12, - v13, - (unsigned char*)v17, - v16, - LOBYTE(v10->uFontHeight), - v10->pFontPalettes[0], - a7); + pRenderer->DrawTextPalette(v12, v13, (unsigned char*)v17, v16, LOBYTE(v10->uFontHeight), + v10->pFontPalettes[0], a7); LOBYTE(v11) = v30; v12 += v28; if ( (signed int)pInString < (signed int)v30 ) @@ -1325,8 +1231,7 @@ //----- (0044CB4F) -------------------------------------------------------- int GUIWindow::DrawTextInRect( GUIFont *pFont, unsigned int uX, unsigned int uY, unsigned int uColor, const char *text, int rect_width, int reverse_text ) - { - +{ int pLineWidth; // ebx@1 int text_width; // esi@3 unsigned __int8 v12; // cl@7 @@ -1368,7 +1273,7 @@ if ( reverse_text ) _strrev(pTmpBuf2.data()); Str1a = 0; - for (i=0; i<pNumLen; ++i) + for ( i = 0; i < pNumLen; ++i ) { if ( text_width >= rect_width ) break; @@ -1390,7 +1295,7 @@ text_width += pFont->pMetrics[v12].uWidth; if ( i < pNumLen ) text_width += pFont->pMetrics[v12].uRightSpacing; - } + } } } pTmpBuf2[i - 1] = 0; @@ -1456,10 +1361,8 @@ v13 += v20; if ( i < (signed int)pNumLen ) v13 += pFont->pMetrics[v15].uRightSpacing; - } + } } - - } return v28; } @@ -1528,7 +1431,7 @@ //----- (0041C432) -------------------------------------------------------- GUIWindow * GUIWindow::Create( unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight, enum WindowType eWindowType, int pButton, const char* hint ) - { +{ unsigned int uNextFreeWindowID; // ebp@1 //int *v8; // eax@1 //GUIWindow *pWindow; // esi@4 @@ -1665,9 +1568,7 @@ pWindow->CreateButton(0x1E0u, v11 + 130, 0x8Cu, v11, 1, 0, UIMSG_SelectNPCDialogueOption, 0x4Cu, 0, pTmpBuf.data(), 0); } else - { pWindow->CreateButton(0x1E0u, v11 + 130, 0x8Cu, v11, 1, 0, UIMSG_SelectNPCDialogueOption, 0x4Cu, 0, pGlobalTXT_LocalizationStrings[406], 0);// - } num_menu_buttons = 2; } } @@ -1675,7 +1576,8 @@ } break; } - case WINDOW_ChangeLocation: { + case WINDOW_ChangeLocation: + { pMainScreenNum = pCurrentScreen; pCurrentScreen = SCREEN_CHANGE_LOCATION; pBtn_ExitCancel = pWindow->CreateButton( 566, 445, 75, 33, 1, 0, UIMSG_CHANGE_LOCATION_ClickCencelBtn, 0, 'N', pGlobalTXT_LocalizationStrings[156], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);// @@ -1683,7 +1585,7 @@ pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63, 73, 1, 0, UIMSG_OnTravelByFoot, 1, ' ', pWindow->Hint, 0, 0, 0); pWindow->CreateButton( 8, 8, 460, 344, 1, 0, UIMSG_OnTravelByFoot, 1, 0, pWindow->Hint, 0); break; - } + } case WINDOW_SpellBook: {// InitializeBookTextures(); pWindow->OpenSpellBook(); @@ -1700,11 +1602,11 @@ return pWindow; } //LABEL_62: - pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, '1', "", 0); - pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, '2', "", 0); - pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, '3', "", 0); - pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, '4', "", 0); - pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9u, "", 0); + pWindow->CreateButton(61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); + pWindow->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); + pWindow->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); + pWindow->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); + pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9, "", 0); return pWindow; } if (eWindowType == WINDOW_HouseInterior) @@ -1927,9 +1829,7 @@ if ( pParty->PartyTimes._shop_ban_times[window_SpeakInHouse->par1C] <=pParty->uTimePlayed ) { if ( window_SpeakInHouse->par1C < 53 ) - { pParty->PartyTimes._shop_ban_times[window_SpeakInHouse->par1C] = 0; - } continue; } pNumMessages = pMessageQueue_50CBD0->uNumMessages; @@ -2212,9 +2112,7 @@ continue; } default: - { continue; - } } } if ( GetCurrentMenuID() == -1 ) @@ -2255,9 +2153,6 @@ Dst.DrawTitleText(pFontSmallnum, 0, 0xCu, ui_mainmenu_copyright_color, pGlobalTXT_LocalizationStrings[157], 3); } - - - int modal_window_prev_screen; //----- (004141CA) -------------------------------------------------------- @@ -2299,10 +2194,9 @@ //----- (00467FB6) -------------------------------------------------------- void CreateScrollWindow() - { +{ unsigned int v0; // eax@1 char *v1; // ST18_4@3 - unsigned int v2; // eax@3 GUIWindow a1; // [sp+Ch] [bp-54h]@1 memcpy(&a1, pGUIWindow_ScrollWindow, sizeof(a1)); @@ -2311,8 +2205,7 @@ a1.uFrameY = 1; a1.uFrameWidth = 468; v0 = pFontSmallnum->CalcTextHeight(pScrolls[pGUIWindow_ScrollWindow->par1C], &a1, 0, 0) - + 2 * LOBYTE(pFontCreate->uFontHeight) - + 24; + + 2 * LOBYTE(pFontCreate->uFontHeight) + 24; a1.uFrameHeight = v0; if ( (signed int)(v0 + a1.uFrameY) > 479 ) { @@ -2329,31 +2222,20 @@ a1.uFrameZ = a1.uFrameWidth + a1.uFrameX - 1; a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1; v1 = pItemsTable->pItems[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C + 700].pName; - v2 = Color16(0xFFu, 0xFFu, 0x9Bu); - sprintf(pTmpBuf.data(), format_4E2D80, v2, v1); - a1.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3u); - a1.DrawText( - pFontSmallnum, - 1, - LOBYTE(pFontCreate->uFontHeight) - 3, - 0, - pScrolls[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C], - 0, - 0, - 0); + sprintf(pTmpBuf.data(), format_4E2D80, Color16(0xFFu, 0xFFu, 0x9Bu), v1); + a1.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3); + a1.DrawText(pFontSmallnum, 1, LOBYTE(pFontCreate->uFontHeight) - 3, 0, + pScrolls[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C], 0, 0, 0); } //----- (00467F48) -------------------------------------------------------- void CreateMsgScrollWindow( signed int mscroll_id ) - { - signed int v1; // esi@1 - - v1 = mscroll_id; +{ if ( !pGUIWindow_ScrollWindow && mscroll_id >= 700 ) { if ( mscroll_id <= 782 ) { uTextureID_720980 = pIcons_LOD->LoadTexture("leather", TEXTURE_16BIT_PALETTE); - pGUIWindow_ScrollWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Scroll, v1 - 700, 0); + pGUIWindow_ScrollWindow = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_Scroll, mscroll_id - 700, 0); } } }