Mercurial > mm7
changeset 1298:b97d0cdd6c79
new folder UI
author | Ritor1 |
---|---|
date | Wed, 19 Jun 2013 17:18:35 +0600 |
parents | 5450af4f57ef |
children | 8c2f689b5f0b |
files | UI/UIBooks.cpp UI/UICharacter.cpp UI/UIHouses.cpp UI/UIHouses.h UI/UIMainMenu.cpp UI/UIMsgProc.cpp UI/UIOptions.cpp UI/UIPartyCreation.cpp UI/UIPopup.cpp UI/UIRest.cpp UI/UISaveLoad.cpp UI/UITransition.cpp UI/UiGame.cpp |
diffstat | 12 files changed, 19658 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/UIBooks.cpp Wed Jun 19 17:18:35 2013 +0600 @@ -0,0 +1,1770 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include <assert.h> + +#include "MM7.h" + +#include "Mouse.h" + +#include "MapInfo.h" +#include "GUIWindow.h" +#include "GUIFont.h" +#include "Party.h" +#include "AudioPlayer.h" +#include "Outdoor.h" +#include "LOD.h" +#include "Allocator.h" +#include "Viewport.h" +#include "Math.h" +#include "Awards.h" +#include "Autonotes.h" +#include "StorylineTextTable.h" +#include "texts.h" + +#include "mm7_data.h" + + + + + + + +//----- (00411150) -------------------------------------------------------- +void BookUI_DrawTownPortalMap() +{ + //signed int v0; // edi@1 + //__int16 v1; // dx@8 + //POINT *v2; // edi@17 + int v3; // edi@17 + //__int16 v4; // dx@24 + GUIWindow v6; // [sp+Ch] [bp-64h]@1 + //POINT v7; // [sp+60h] [bp-10h]@17 + POINT a2; // [sp+68h] [bp-8h]@17 + + pRenderer->ClearZBuffer(0, 479); + pRenderer->DrawTextureTransparent(8, 8, pTexture_CurrentBook); + pRenderer->DrawTextureTransparent(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId)); + + v6.uFrameX = game_viewport_x; + v6.uFrameY = game_viewport_y; + v6.uFrameWidth = game_viewport_width; + v6.uFrameHeight = game_viewport_height; + v6.uFrameZ = game_viewport_z; + v6.uFrameW = game_viewport_w; + + const uint fountain_bits_lut[] = {PARTY_QUEST_FOUNTAIN_HARMONDALE, + PARTY_QUEST_FOUNTAIN_PIERPONT, + PARTY_QUEST_FOUNTAIN_NIGHON, + PARTY_QUEST_FOUNTAIN_EVENMORN_ISLE, + PARTY_QUEST_FOUNTAIN_CELESTIA, + PARTY_QUEST_FOUNTAIN_THE_PIT}; + for (uint i = 0; i < 6; ++i) + { + + if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[i])) + pRenderer->DrawMaskToZBuffer(pTownPortalBook_xs[i], + pTownPortalBook_ys[i], + pTexture_TownPortalIcons[i], i + 1); + } + +/* v0 = 0; + do + { + if ( !v0 ) + { + v1 = 206; +LABEL_14: + if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v1) ) + goto LABEL_16; + goto LABEL_15; + } + if ( v0 == 1 ) + { + v1 = 208; + goto LABEL_14; + } + if ( v0 == 2 ) + { + v1 = 207; + goto LABEL_14; + } + if ( v0 == 3 ) + { + v1 = 211; + goto LABEL_14; + } + if ( v0 == 4 ) + { + v1 = 209; + goto LABEL_14; + } + if ( v0 == 5 ) + { + v1 = 210; + goto LABEL_14; + } +LABEL_15: + pRenderer->DrawMaskToZBuffer( + pTownPortalBook_xs[v0], + pTownPortalBook_ys[v0], + *(&pTexture_TownPortalHarmn + v0), + v0 + 1); +LABEL_16: + ++v0; + } + while ( v0 < 6 );*/ + + pMouse->GetCursorPos(&a2); + //v2 = pMouse->GetCursorPos(&a2); + v3 = pRenderer->pActiveZBuffer[a2.x + pSRZBufferLineOffsets[a2.y]] & 0xFFFF; + + if (v3) + { + if (_449B57_test_bit(pParty->_quest_bits, fountain_bits_lut[v3 - 1])) + pRenderer->DrawTextureIndexed(pTownPortalBook_xs[v3 - 1], pTownPortalBook_ys[v3 - 1], pTexture_TownPortalIcons[v3 - 1]); + } + v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); + + +/* if ( !v3 ) // Town Portal + { + v6.DrawTitleText(pBook2Font, 0, 22, 0, pGlobalTXT_LocalizationStrings[10], 3); // "Town Portal" + return; + } + if ( v3 == 1 ) + { + v4 = 206; +LABEL_30: + if ( (unsigned __int16)_449B57_test_bit(pParty->_quest_bits, v4) ) + goto LABEL_31; + v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u); // "Town Portal" + return; + } + if ( v3 == 2 ) + { + v4 = 208; + goto LABEL_30; + } + if ( v3 == 3 ) + { + v4 = 207; + goto LABEL_30; + } + if ( v3 == 4 ) + { + v4 = 211; + goto LABEL_30; + } + if ( v3 == 5 ) + { + v4 = 209; + goto LABEL_30; + } + if ( v3 == 6 ) + { + v4 = 210; + goto LABEL_30; + } +LABEL_31: + pRenderer->DrawTextureIndexed(word_4E1D3A[v3], pTownPortalBook_xs[v3 + 5], *(&pTex_tab_an_6b__zoom_on + v3)); + v6.DrawTitleText(pBook2Font, 0, 22u, 0, pGlobalTXT_LocalizationStrings[10], 3u);*/ +} +// 4E1D3A: using guessed type __int16 word_4E1D3A[]; + + + + +//----- (00413CC6) -------------------------------------------------------- +void BookUI_Draw(WindowType book) +{ + pRenderer->DrawTextureIndexed(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId)); + switch (book) + { + case WINDOW_QuestBook: BookUI_Questbook_Draw(); break; + case WINDOW_AutonotesBook: BookUI_Autonotes_Draw(); break; + case WINDOW_MapsBook: BookUI_Map_Draw(); break; + case WINDOW_CalendarBook: BookUI_Calendar_Draw(); break; + case WINDOW_JournalBook: BookUI_Journal_Draw(); break; + + case WINDOW_LloydsBeacon: DrawLloydBeaconsScreen(); break; + case WINDOW_TownPortal: BookUI_DrawTownPortalMap(); break; + } +} + + + +//----- (00413D3C) -------------------------------------------------------- +static const char *GetDayPart() +{ + if (pParty->uCurrentHour <= 4) + return pGlobalTXT_LocalizationStrings[567]; // "Night" + else if (pParty->uCurrentHour == 5) + return pGlobalTXT_LocalizationStrings[55]; // "Dawn" + else if (pParty->uCurrentHour == 20) + return pGlobalTXT_LocalizationStrings[566]; // "Dusk" + else + return pGlobalTXT_LocalizationStrings[56]; // "Day" +} + + + +//----- (00413D6F) -------------------------------------------------------- +void BookUI_Calendar_Draw() +{ + unsigned int v0; // esi@1 + //char *v1; // eax@5 + int v2; // ecx@5 + char *v3; // eax@6 + GUIWindow a1; // [sp+Ch] [bp-60h]@5 + unsigned int v6; // [sp+60h] [bp-Ch]@1 + //int v7; // [sp+64h] [bp-8h]@1 + //int a5; // [sp+68h] [bp-4h]@1 + + + static unsigned int pDayMoonPhase[28] = // 4E1B18 + { + 0, 0, 0, + 1, 1, 1, 1, + 2, 2, 2, + 3, 3, 3, 3, + 4, 4, 4, + 3, 3, 3, 3, + 2, 2, 2, + 1, 1, 1, 1 + }; + + + v0 = pParty->uCurrentHour; + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_13); + if ( (signed int)v0 <= 12 ) + { + if ( !v0 ) + v0 = 12; + } + else + { + v0 -= 12; + } + a1.uFrameX = game_viewport_x; + a1.uFrameY = game_viewport_y; + a1.uFrameWidth = game_viewport_width; + a1.uFrameHeight = game_viewport_height; + a1.uFrameZ = game_viewport_z; + a1.uFrameW = game_viewport_w; + a1.DrawTitleText(pBook2Font, 0, 0x16u, ui_book_calendar_title_color, pGlobalTXT_LocalizationStrings[186], 3); // "Time in Erathia" + + v2 = 0; + if ( pParty->uCurrentHour >= 12 ) + { + if ( pParty->uCurrentHour >= 24 ) + v2=0; + else + v2=1; + } + + sprintf(pTmpBuf.data(), "%s\t100:\t110%d:%02d %s - %s", + pGlobalTXT_LocalizationStrings[526], // "Time" + v0, + pParty->uCurrentMinute, + aAMPMNames[v2], + GetDayPart()); + a1.DrawText(pBookFont, 70, 55, ui_book_calendar_time_color, pTmpBuf.data(), 0, 0, 0); + + sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s", + pGlobalTXT_LocalizationStrings[56], // "Day" + pParty->uDaysPlayed + 1, + aDayNames[pParty->uDaysPlayed % 7]); + a1.DrawText(pBookFont, 70, 2 * LOBYTE(pBookFont->uFontHeight) + 49, ui_book_calendar_day_color, pTmpBuf.data(), 0, 0, 0); + + sprintf(pTmpBuf.data(), "%s\t100:\t110%d - %s", + pGlobalTXT_LocalizationStrings[146], // "Month" + pParty->uCurrentMonth + 1, + aMonthNames[pParty->uCurrentMonth]); + a1.DrawText(pBookFont, 70, 4 * LOBYTE(pBookFont->uFontHeight) + 43, ui_book_calendar_month_color, pTmpBuf.data(), 0, 0, 0); + + sprintf(pTmpBuf.data(), "%s\t100:\t110%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); // "Year" + a1.DrawText(pBookFont, 70, 6 * LOBYTE(pBookFont->uFontHeight) + 37, ui_book_calendar_year_color, pTmpBuf.data(), 0, 0, 0); + + sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[530], aMoonPhaseNames[pDayMoonPhase[pParty->uDaysPlayed]]); // "Moon" + a1.DrawText(pBookFont, 70, 8 * LOBYTE(pBookFont->uFontHeight) + 31, ui_book_calendar_moon_color, pTmpBuf.data(), 0, 0, 0); + + v6 = pMapStats->GetMapInfo(pCurrentMapName.data()); + if ( v6 ) + v3 = pMapStats->pInfos[v6].pName; + else + v3 = "Unknown"; + sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], v3); // "Location" + a1.DrawText(pBookFont, 70, 10 * LOBYTE(pBookFont->uFontHeight) + 25, ui_book_calendar_location_color, pTmpBuf.data(), 0, 0, 0); +} + + + +//----- (0041192C) -------------------------------------------------------- +void InitializeBookTextures() +{ + //signed int v0; // ebp@3 + //Texture **v1; // ebx@3 + + pAudioPlayer->StopChannels(-1, -1); + + ++pIcons_LOD->uTexturePacksCount; + if ( !pIcons_LOD->uNumPrevLoadedFiles ) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + pSpellBookPagesTextr_9 = pIcons_LOD->LoadTexturePtr("book", TEXTURE_16BIT_PALETTE); + pTexture_pagemask = pIcons_LOD->LoadTexturePtr("pagemask", TEXTURE_16BIT_PALETTE); + pTexture_506448 = pIcons_LOD->LoadTexturePtr("ib-m5-u", TEXTURE_16BIT_PALETTE); + ptr_506440 = pIcons_LOD->LoadTexturePtr("ib-m5-d", TEXTURE_16BIT_PALETTE); + pTexture_50643C = pIcons_LOD->LoadTexturePtr("ib-m6-u",TEXTURE_16BIT_PALETTE); + //v0 = 1; + + static const char *texNames[9] = // 004E24EC + { + "SBFB00", "SBAB00", "SBWB00", "SBEB00", + "SBSB00", "SBMB00", "SBBB00", "SBLB00", "SBDB00" + }; + + pTexture_506444 = pIcons_LOD->LoadTexturePtr("ib-m6-d",TEXTURE_16BIT_PALETTE); + for (uint i = 0; i < 9; ++i) + { + pSpellBookPagesTextr[i] = pIcons_LOD->LoadTexturePtr(texNames[i], TEXTURE_16BIT_PALETTE); + + sprintf(pTmpBuf.data(), "tab%da", i+1); + pTextures_tabs[i][0] = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); + sprintf(pTmpBuf.data(), "tab%db", i+1); + pTextures_tabs[i][1] = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); + } +} + + + +//----- (00411AAA) -------------------------------------------------------- +void InitializeBookFonts() +{ + pAudioPlayer->StopChannels(-1, -1); + + ++pIcons_LOD->uTexturePacksCount; + if ( !pIcons_LOD->uNumPrevLoadedFiles ) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + pTexture_mapbordr = pIcons_LOD->LoadTexturePtr("mapbordr", TEXTURE_16BIT_PALETTE); + pBookFont = LoadFont("book.fnt", "FONTPAL", NULL); + pBook2Font = LoadFont("book2.fnt", "FONTPAL", NULL); + pAutonoteFont = LoadFont("autonote.fnt", "FONTPAL", NULL); + pSpellFont = LoadFont("spell.fnt", "FONTPAL", NULL); +} + + + +//----- (00411300) -------------------------------------------------------- +void LoadSpellbook(unsigned int spell_school) +{ + //unsigned int v1; // esi@1 + Player *pPlayer; // ecx@1 + char v3; // al@1 + //int v4; // edi@5 + //Texture *result; // eax@6 + //unsigned char *v6; // edi@7 + //unsigned int v7; // eax@7 + //unsigned __int8 v8; // sf@8 + //unsigned __int8 v9; // of@8 + char pContainer[20]; // [sp+Ch] [bp-1Ch]@7 + //Texture *v11; // [sp+20h] [bp-8h]@5 + //int v12; // [sp+24h] [bp-4h]@5 + + byte_506550 = 0; + //v1 = uID; + pPlayer = pPlayers[uActiveCharacter]; + v3 = pPlayer->uQuickSpell; + if ( v3 && (unsigned __int8)v3 / 11 == spell_school ) + quick_spell_at_page = (unsigned __int8)v3 - 11 * spell_school; + else + quick_spell_at_page = 0; + + for (uint i = 1; i < 12; ++i) + { + if (pPlayer->spellbook.pChapters[spell_school].bIsSpellAvailable[i - 1]) + { + sprintf(pContainer, "SB%sS%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]); + dword_506408[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); + + sprintf(pContainer, "SB%sC%02d", spellbook_texture_filename_suffices[spell_school], pSpellbookSpellIndices[spell_school][i]); + dword_5063D8[i] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); + } + } +} + +//----- (0041140B) -------------------------------------------------------- +void sub_41140B() +{ + signed int v0; // esi@1 + GUIButton *v1; // eax@3 + GUIButton *v2; // esi@4 + + v0 = 0; + do + { + dword_5063D8[11+v0]->Release(); + dword_506408[11+v0]->Release(); + --v0; + } + while ( v0 >= -11 ); + pIcons_LOD->SyncLoadedFilesCount(); + v1 = pGUIWindow_CurrentMenu->pControlsHead; + if ( v1 ) + { + do + { + v2 = v1->pNext; + pAllocator->FreeChunk(v1); + v1 = v2; + } + while ( v2 ); + } + pGUIWindow_CurrentMenu->pControlsHead = 0; + pGUIWindow_CurrentMenu->pControlsTail = 0; + pGUIWindow_CurrentMenu->uNumControls = 0; +} + +//----- (00411473) -------------------------------------------------------- +void sub_411473() +{ + pTexture_pagemask->Release(); + pTexture_506448->Release(); + pTexture_50643C->Release(); + for (uint i = 0; i < 9; ++i) + { + pSpellBookPagesTextr[i]->Release(); + pTextures_tabs[i][0]->Release(); + pTextures_tabs[i][1]->Release(); + } + pAudioPlayer->PlaySound(SOUND_CloseBook, 0, 0, -1, 0, 0, 0, 0); + pIcons_LOD->_4114F2(); +} + + +//----- (00411597) -------------------------------------------------------- +void OnCloseSpellBook() +{ + pAllocator->FreeChunk(pSpellFont); + pSpellFont = nullptr; + pAllocator->FreeChunk(pBookFont); + pBookFont = nullptr; + pAllocator->FreeChunk(pBook2Font); + pBook2Font = nullptr; + pAllocator->FreeChunk(pAutonoteFont); + pAutonoteFont = nullptr; + pTexture_mapbordr->Release(); + pAudioPlayer->PlaySound(SOUND_CloseBook, 0, 0, -1, 0, 0, 0, 0); + pIcons_LOD->_4114F2(); + dword_506364 = 0; +} + + + + + + + +//----- (00412E85) -------------------------------------------------------- +void BookUI_Journal_Draw() +{ + unsigned int v0; // eax@3 + unsigned int v1; // eax@7 + int v2; // eax@10 + const char *v3; // eax@10 + signed int v4; // ecx@12 + int v5; // ecx@14 + int v6; // eax@21 + int v7; // esi@21 + char *v8; // eax@21 + char* v9; // eax@22 + unsigned int v11; // [sp-8h] [bp-64h]@3 + unsigned int v12; // [sp-8h] [bp-64h]@7 + Texture *v13; // [sp-4h] [bp-60h]@3 + Texture *v14; // [sp-4h] [bp-60h]@7 + GUIWindow a1; // [sp+8h] [bp-54h]@10 + + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_11); + if ( BtnUp_flag || !dword_506528 ) + { + v13 = pTex_tab_an_6a__zoom_off; + v11 = pViewport->uViewportTL_Y + 2; + v0 = pViewport->uViewportTL_X + 407; + } + else + { + v13 = pTex_tab_an_6b__zoom_on; + v11 = pViewport->uViewportTL_Y + 1; + v0 = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(v0, v11, v13); + + if ( BtnDown_flag || dword_506528 + num_achieved_awards >= num_achieved_awards_2 ) + { + v14 = pTex_tab_an_7a__zoot_off; + v12 = pViewport->uViewportTL_Y + 38; + v1 = pViewport->uViewportTL_X + 407; + } + else + { + v14 = pTex_tab_an_7b__zoot_on; + v12 = pViewport->uViewportTL_Y + 38; + v1 = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(v1, v12, v14); + + if ( !byte_5C6D50[dword_506528] ) + { + v2 = achieved_awards[dword_506528]; + a1.uFrameWidth = game_viewport_width; + a1.uFrameX = game_viewport_x; + a1.uFrameY = game_viewport_y; + a1.uFrameHeight = game_viewport_height; + v3 = (const char *)pStorylineText->StoreLine[v2].pPageTitle;//field_4[]; + a1.uFrameZ = game_viewport_z; + a1.uFrameW = game_viewport_w; + if ( v3 ) + a1.DrawTitleText(pBook2Font, 0, 22, ui_book_journal_title_color, v3, 3); + } + + a1.uFrameX = 48; + a1.uFrameY = 70; + a1.uFrameWidth = 360; + a1.uFrameHeight = 264; + v4 = LOBYTE(pAutonoteFont->uFontHeight) - 3; + a1.uFrameZ = 407; + a1.uFrameHeight = v4 * 264 / v4; + a1.uFrameW = a1.uFrameHeight + 69; + if ( BtnDown_flag && dword_506528 + num_achieved_awards < num_achieved_awards_2 ) + { + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + v5 = dword_50651C++; + dword_506528 += num_achieved_awards; + byte_506130[v5] = num_achieved_awards; + } + if ( BtnUp_flag && dword_50651C ) + { + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + --dword_50651C; + dword_506528 -= (unsigned __int8)byte_506130[dword_50651C]; + } + if ( !num_achieved_awards || dword_506528 < 1 ) + { + dword_506528 = 0; + dword_50651C = 0; + } + BtnDown_flag = 0; + v6 = achieved_awards[dword_506528]; + BtnUp_flag = 0; + num_achieved_awards = 0; + //v7 = *pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6); + v7 = (int)pStorylineText->StoreLine[v6].pText;//*(&pStorylineText->field_0 + 3 * v6); + v8 = BuilDialogueString( + pStorylineText->StoreLine[v6].pText, + uActiveCharacter - 1, + 0, + 0, + 0, + (__int64 *)&pParty->field_3C._s_times[ v6 + 21]); + if ( v7 ) + { + v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[dword_506528]); + a1.DrawText(pAutonoteFont, 1, 0, ui_book_journal_text_color, (const char *)v9, 0, a1.uFrameY + a1.uFrameHeight, ui_book_journal_text_shadow); + ++num_achieved_awards; + } +} + + +//----- (00413126) -------------------------------------------------------- +void BookUI_Questbook_Draw() +{ + unsigned int v0; // eax@3 + unsigned int v1; // eax@7 + int v2; // ecx@11 + int v3; // ebx@16 + int v4; // eax@19 + const char *v5; // edi@19 + int v6; // eax@19 + unsigned int v7; // edi@19 + unsigned int v8; // [sp-8h] [bp-68h]@3 + unsigned int v9; // [sp-8h] [bp-68h]@7 + Texture *v10; // [sp-4h] [bp-64h]@3 + Texture *v11; // [sp-4h] [bp-64h]@7 + GUIWindow a1; // [sp+Ch] [bp-54h]@9 + + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_CurrentBook); + if ( BtnUp_flag || !dword_506528 ) + { + v10 = pTex_tab_an_6a__zoom_off; + v8 = pViewport->uViewportTL_Y + 2; + v0 = pViewport->uViewportTL_X + 407; + } + else + { + v10 = pTex_tab_an_6b__zoom_on; + v8 = pViewport->uViewportTL_Y + 1; + v0 = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(v0, v8, v10); + if ( BtnDown_flag || dword_506528 + num_achieved_awards >= num_achieved_awards_2 ) + { + v11 = pTex_tab_an_7a__zoot_off; + v9 = pViewport->uViewportTL_Y + 38; + v1 = pViewport->uViewportTL_X + 407; + } + else + { + v11 = pTex_tab_an_7b__zoot_on; + v9 = pViewport->uViewportTL_Y + 38; + v1 = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(v1, v9, v11); + a1.uFrameWidth = game_viewport_width; + a1.uFrameHeight = game_viewport_height; + a1.uFrameX = game_viewport_x; + a1.uFrameY = game_viewport_y; + a1.uFrameZ = game_viewport_z; + a1.uFrameW = game_viewport_w; + a1.DrawTitleText(pBook2Font, 0, 22, ui_book_quests_title_color, pGlobalTXT_LocalizationStrings[174], 3); //"Current Quests" + + a1.uFrameX = 48; + a1.uFrameY = 70; + a1.uFrameWidth = 360; + a1.uFrameHeight = 264; + a1.uFrameZ = 407; + a1.uFrameW = 333; + if ( BtnDown_flag && dword_506528 + num_achieved_awards < num_achieved_awards_2 ) + { + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + v2 = dword_50651C++; + dword_506528 += num_achieved_awards; + byte_506130[v2] = num_achieved_awards; + } + if ( BtnUp_flag && dword_50651C ) + { + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + --dword_50651C; + dword_506528 -= (unsigned __int8)byte_506130[dword_50651C]; + } + if ( !num_achieved_awards || (v3 = dword_506528, dword_506528 < 1) ) + { + v3 = 0; + dword_50651C = 0; + dword_506528 = 0; + } + BtnDown_flag = 0; + BtnUp_flag = 0; + num_achieved_awards = 0; + while ( v3 < num_achieved_awards_2 ) + { + v4 = achieved_awards[v3]; + ++num_achieved_awards; + v5 = pQuestTable[v4-1];//(&dword_722F10)[4 * v4]; + a1.DrawText(pAutonoteFont, 1, 0, ui_book_quests_text_color, pQuestTable[v4-1], 0, 0, 0);//(&dword_722F10)[4 * v4], 0, 0, 0); + v6 = pAutonoteFont->CalcTextHeight(v5, &a1, 1, 0); + v7 = a1.uFrameY + v6; + if ( (signed int)(a1.uFrameY + v6) > (signed int)a1.uFrameHeight ) + break; + pRenderer->DrawTextureTransparent(100, v7 + 12, pSpellBookPagesTextr_10); + ++v3; + a1.uFrameY = v7 + 24; + } +} + + +//----- (0041338E) -------------------------------------------------------- +void BookUI_Autonotes_Draw() +{ + unsigned int v0; // eax@3 + unsigned int v1; // eax@7 + signed int v2; // ebp@11 + unsigned int v3; // eax@18 + unsigned int v4; // eax@24 + unsigned int v5; // eax@30 + unsigned int v6; // eax@36 + unsigned int v7; // eax@42 + signed int v8; // ebp@47 + int v9; // eax@52 + int v10; // eax@56 + int v11; // edx@57 + int v12; // ebp@64 + int v13; // eax@65 + const char *v14; // edi@65 + int v15; // eax@65 + unsigned int v16; // edi@65 + unsigned int v17; // [sp-8h] [bp-70h]@3 + unsigned int v18; // [sp-8h] [bp-70h]@7 + unsigned int v19; // [sp-8h] [bp-70h]@18 + unsigned int v20; // [sp-8h] [bp-70h]@24 + unsigned int v21; // [sp-8h] [bp-70h]@30 + unsigned int v22; // [sp-8h] [bp-70h]@36 + unsigned int v23; // [sp-8h] [bp-70h]@42 + Texture *v24; // [sp-4h] [bp-6Ch]@3 + Texture *v25; // [sp-4h] [bp-6Ch]@7 + Texture *v26; // [sp-4h] [bp-6Ch]@18 + Texture *v27; // [sp-4h] [bp-6Ch]@24 + Texture *v28; // [sp-4h] [bp-6Ch]@30 + Texture *v29; // [sp-4h] [bp-6Ch]@36 + Texture *v30; // [sp-4h] [bp-6Ch]@42 + signed __int16 v31; // [sp+10h] [bp-58h]@1 + char *v32; // [sp+10h] [bp-58h]@49 + GUIWindow a1; // [sp+14h] [bp-54h]@46 + + v31 = 0; + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_AutonotesBook); + if ( BtnUp_flag || !dword_506528 ) + { + v24 = pTex_tab_an_6a__zoom_off; + v17 = pViewport->uViewportTL_Y + 2; + v0 = pViewport->uViewportTL_X + 407; + } + else + { + v24 = pTex_tab_an_6b__zoom_on; + v17 = pViewport->uViewportTL_Y + 1; + v0 = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(v0, v17, v24); + if ( BtnDown_flag || dword_506528 + num_achieved_awards >= num_achieved_awards_2 ) + { + v25 = pTex_tab_an_7a__zoot_off; + v18 = pViewport->uViewportTL_Y + 38; + v1 = pViewport->uViewportTL_X + 407; + } + else + { + v25 = pTex_tab_an_7b__zoot_on; + v18 = pViewport->uViewportTL_Y + 38; + v1 = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(v1, v18, v25); + if ( !Book_PageBtn3_flag )//Potions_page_flag + { + if (_506568_autonote_type != AUTONOTE_POTION_RECEPIE) + { + pRenderer->DrawTextureTransparent( + pViewport->uViewportTL_X + 408, + pViewport->uViewportTL_Y + 113, + pTexture_506390); + v2 = 1; + goto LABEL_16; + } + goto LABEL_14; + } + if (_506568_autonote_type == AUTONOTE_POTION_RECEPIE) + { +LABEL_14: + v2 = 1; + goto LABEL_15; + } + v2 = 1; + v31 = 1; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); +LABEL_15: + _506568_autonote_type = AUTONOTE_POTION_RECEPIE; + pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTexture_506394); +LABEL_16: + if ( Book_PageBtn4_flag )//Fontains_page_flag + { + if ( _506568_autonote_type != v2 ) + { + v31 = v2; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + } + } + else + { + if ( _506568_autonote_type != v2 ) + { + v26 = pTexture_506388; + v19 = pViewport->uViewportTL_Y + 150; + v3 = pViewport->uViewportTL_X + 408; + goto LABEL_22; + } + } + v26 = pTexture_50638C; + _506568_autonote_type = v2; + v19 = pViewport->uViewportTL_Y + 150; + v3 = pViewport->uViewportTL_X + 399; +LABEL_22: + pRenderer->DrawTextureTransparent(v3, v19, v26); + if ( Book_PageBtn5_flag )//Autonotes_Obelisks_page_flag + { + if ( _506568_autonote_type != AUTONOTE_OBELISK) + { + v31 = v2; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + } + } + else + { + if ( _506568_autonote_type != AUTONOTE_OBELISK) + { + v27 = pTexture_506380; + v20 = pViewport->uViewportTL_Y + 188; + v4 = pViewport->uViewportTL_X + 408; + goto LABEL_28; + } + } + v27 = pTexture_506384; + _506568_autonote_type = AUTONOTE_OBELISK; + v20 = pViewport->uViewportTL_Y + 188; + v4 = pViewport->uViewportTL_X + 397; +LABEL_28: + pRenderer->DrawTextureTransparent(v4, v20, v27); + if ( Book_PageBtn6_flag )//Autonotes_Seer_page_flag + { + if ( _506568_autonote_type != AUTONOTE_SEER) + { + v31 = v2; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + } + } + else + { + if ( _506568_autonote_type != AUTONOTE_SEER) + { + v28 = pTexture_506378; + v21 = pViewport->uViewportTL_Y + 226; + v5 = pViewport->uViewportTL_X + 408; + goto LABEL_34; + } + } + v28 = pTexture_50637C; + _506568_autonote_type = AUTONOTE_SEER; + v21 = pViewport->uViewportTL_Y + 226; + v5 = pViewport->uViewportTL_X + 397; +LABEL_34: + pRenderer->DrawTextureTransparent(v5, v21, v28); + if ( Autonotes_Misc_page_flag ) + { + if ( _506568_autonote_type != AUTONOTE_MISC) + { + v31 = v2; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + } + } + else + { + if ( _506568_autonote_type != AUTONOTE_MISC) + { + v29 = pTexture_506370; + v22 = pViewport->uViewportTL_Y + 263; + v6 = pViewport->uViewportTL_X + 408; + goto LABEL_40; + } + } + v29 = pTexture_506374; + _506568_autonote_type = AUTONOTE_MISC; + v22 = pViewport->uViewportTL_Y + 264; + v6 = pViewport->uViewportTL_X + 397; +LABEL_40: + pRenderer->DrawTextureTransparent(v6, v22, v29); + if ( Autonotes_Instructors_page_flag ) + { + if ( _506568_autonote_type != AUTONOTE_TEACHER) + { + v31 = v2; + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + } + } + else + { + if ( _506568_autonote_type != AUTONOTE_TEACHER) + { + v30 = pTexture_506368; + v23 = pViewport->uViewportTL_Y + 302; + v7 = pViewport->uViewportTL_X + 408; + goto LABEL_46; + } + } + v30 = pTexture_50636C; + _506568_autonote_type = AUTONOTE_TEACHER; + v23 = pViewport->uViewportTL_Y + 302; + v7 = pViewport->uViewportTL_X + 397; +LABEL_46: + pRenderer->DrawTextureTransparent(v7, v23, v30); + a1.uFrameWidth = game_viewport_width; + a1.uFrameHeight = game_viewport_height; + a1.uFrameX = game_viewport_x; + a1.uFrameY = game_viewport_y; + a1.uFrameZ = game_viewport_z; + a1.uFrameW = game_viewport_w; + a1.DrawTitleText(pBook2Font, 0, 22, ui_book_autonotes_title_color, pGlobalTXT_LocalizationStrings[154], 3); // "Auto notes" + + a1.uFrameX = 48; + a1.uFrameY = 70; + a1.uFrameWidth = 360; + a1.uFrameHeight = 264; + a1.uFrameZ = 407; + a1.uFrameW = 333; + if ( v31 ) + { + num_achieved_awards_2 = 0; + dword_506528 = 0; + dword_50651C = 0; + num_achieved_awards = 0; + v8 = 0; + do + { + //if ( dword_72371C[2 * v8] == dword_506568 ) + if ( pAutonoteTxt[v8-1].eType == _506568_autonote_type ) + { + //v32 = (&dword_723718_autonote_related)[8 * (signed __int16)v8]; + v32 = (char *)pAutonoteTxt[v8-1].pText; + if ( (short)v8 ) + { + if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v8) && v32 ) + { + v9 = num_achieved_awards++; + achieved_awards[v9] = (AwardType)v8; + } + } + } + ++v8; + } + while ( v8 < 196 ); + num_achieved_awards_2 = num_achieved_awards; + } + else + { + if ( BtnDown_flag ) + { + v10 = num_achieved_awards + dword_506528; + if ( num_achieved_awards + dword_506528 < num_achieved_awards_2 ) + { + v11 = dword_50651C++; + byte_506130[v11] = num_achieved_awards; + dword_506528 = v10; + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + } + } + if ( BtnUp_flag && dword_50651C ) + { + --dword_50651C; + dword_506528 -= (unsigned __int8)byte_506130[dword_50651C]; + pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0); + } + if ( !num_achieved_awards || dword_506528 < 1 ) + { + dword_506528 = 0; + dword_50651C = 0; + } + } + v12 = dword_506528; + Autonotes_Instructors_page_flag = 0; + BtnDown_flag = 0; + BtnUp_flag = 0; + num_achieved_awards = 0; + Autonotes_Misc_page_flag = 0; + Book_PageBtn6_flag = 0;//Autonotes_Seer_page_flag + Book_PageBtn5_flag = 0;//Autonotes_Obelisks_page_flag + Book_PageBtn4_flag = 0;//Fontains_page_flag + Book_PageBtn3_flag = 0;//Potions_page_flag + while ( v12 < num_achieved_awards_2 ) + { + v13 = achieved_awards[v12]; + ++num_achieved_awards; + //v14 = (&dword_723718_autonote_related)[8 * v13]; + v14 = pAutonoteTxt[v13-1].pText; + //a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_723718_autonote_related)[8 * v13], 0, 0, 0); + a1.DrawText(pAutonoteFont, 1, 0, ui_book_autonotes_text_color, pAutonoteTxt[v13-1].pText, 0, 0, 0); + v15 = pAutonoteFont->CalcTextHeight(v14, &a1, 1, 0); + v16 = a1.uFrameY + v15; + if ( (signed int)(a1.uFrameY + v15) > (signed int)a1.uFrameHeight ) + break; + pRenderer->DrawTextureTransparent(0x64u, v16 + 12, pSpellBookPagesTextr_10); + ++v12; + a1.uFrameY = v16 + 24; + } +} + + +//----- (00413980) -------------------------------------------------------- +void BookUI_Map_Draw() +{ + int v6; // eax@31 + unsigned int map_id; // eax@35 + Texture *buttnTxtr; // [sp-4h] [bp-DCh]@3 + char party_coord[120]; // [sp+Ch] [bp-CCh]@37 + GUIWindow map_window; // [sp+84h] [bp-54h]@35 + unsigned int textrX, textrY; + + pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_12); + if ( BtnUp_flag || viewparams->field_2C / 128 >= 12 ) + { + buttnTxtr = pTex_tab_an_6a__zoom_off; + textrY = pViewport->uViewportTL_Y + 2; + textrX = pViewport->uViewportTL_X + 408; + } + else + { + buttnTxtr = pTex_tab_an_6b__zoom_on; + textrY = pViewport->uViewportTL_Y + 1; + textrX = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); + if ( BtnDown_flag || viewparams->field_2C / 128 <= 3 ) + { + buttnTxtr = pTex_tab_an_7a__zoot_off; + textrY = pViewport->uViewportTL_Y + 38; + textrX = pViewport->uViewportTL_X + 408; + } + else + { + buttnTxtr = pTex_tab_an_7b__zoot_on; + textrY = pViewport->uViewportTL_Y + 38; + textrX = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); + if ( Book_PageBtn3_flag ) + { + buttnTxtr = pTexture_506390; + textrY = pViewport->uViewportTL_Y + 113; + textrX = pViewport->uViewportTL_X + 408; + } + else + { + buttnTxtr = pTexture_506394; + textrY = pViewport->uViewportTL_Y + 113; + textrX = pViewport->uViewportTL_X + 398; + } + pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); + if ( Book_PageBtn4_flag ) + { + buttnTxtr = pTexture_506388; + textrY = pViewport->uViewportTL_X + 150; + textrX = pViewport->uViewportTL_Y + 408; + } + else + { + buttnTxtr = pTexture_50638C; + textrY = pViewport->uViewportTL_X + 150; + textrX = pViewport->uViewportTL_Y + 399; + } + pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); + if ( Book_PageBtn5_flag ) + { + buttnTxtr = pTexture_506380; + textrY = pViewport->uViewportTL_Y + 188; + textrX = pViewport->uViewportTL_X + 408; + } + else + { + buttnTxtr = pTexture_506384; + textrY = pViewport->uViewportTL_Y + 188; + textrX = pViewport->uViewportTL_X + 397; + } + pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); + if ( Book_PageBtn6_flag ) + { + buttnTxtr = pTexture_506378; + textrY = pViewport->uViewportTL_Y + 226; + textrX = pViewport->uViewportTL_X + 408; + } + else + { + buttnTxtr = pTexture_50637C; + textrY = pViewport->uViewportTL_Y + 226; + textrX = pViewport->uViewportTL_X + 397; + } + pRenderer->DrawTextureTransparent(textrX, textrY, buttnTxtr); + if ( BtnDown_flag ) + viewparams->CenterOnParty2(); + if ( BtnUp_flag ) + viewparams->CenterOnParty(); + if ( Book_PageBtn3_flag ) + viewparams->_443219(); + if ( Book_PageBtn4_flag ) + viewparams->_443231(); + if ( Book_PageBtn5_flag ) + viewparams->_44323D(); + if ( Book_PageBtn6_flag ) + viewparams->_443225(); + + if ( BtnUp_flag | BtnDown_flag | Book_PageBtn3_flag | Book_PageBtn4_flag | Book_PageBtn5_flag | Book_PageBtn6_flag ) + pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0); + BtnUp_flag = 0; + BtnDown_flag = 0; + Book_PageBtn6_flag = 0; + Book_PageBtn5_flag = 0; + Book_PageBtn4_flag = 0; + Book_PageBtn3_flag = 0; + DrawBook_Map_sub(97, 49, 361, 313, 0); + pRenderer->DrawTextureTransparent(75, 22, pTexture_mapbordr); + map_window.uFrameWidth = game_viewport_width; + map_window.uFrameHeight = game_viewport_height; + map_window.uFrameX = game_viewport_x; + map_window.uFrameY = game_viewport_y; + map_window.uFrameZ = game_viewport_z; + map_window.uFrameW = game_viewport_w; + map_id = pMapStats->GetMapInfo(pCurrentMapName.data()); + if ( map_id ) + map_window.DrawTitleText(pBook2Font, -14, 12, ui_book_map_title_color, pMapStats->pInfos[map_id].pName, 3); + + map_window.uFrameX = 0; + sprintf(party_coord, pGlobalTXT_LocalizationStrings[659], pParty->vPosition.x, pParty->vPosition.y); //"x: %d y: %d" + map_window.DrawTitleText(pFontComic, 0, 320, ui_book_map_coordinates_color, party_coord, 0); +} + +//----- (00442955) -------------------------------------------------------- +void DrawBook_Map_sub( unsigned int tl_x, unsigned int tl_y, unsigned int br_x, int br_y, int _48074 ) + { + int v5; // ebx@1 + int v6; // edi@1 + BLVMapOutlines *v7; // eax@8 + unsigned __int8 v8; // zf@8 + unsigned __int8 v9; // sf@8 + int v10; // esi@10 + unsigned int v11; // edx@11 + __int16 v12; // cx@12 + signed int v13; // eax@15 + int v14; // eax@16 + Vec3_short_ *v15; // ecx@16 + int v16; // edx@16 + int v17; // ecx@16 + Vec3_short_ *v18; // eax@16 + int v19; // ecx@16 + int v20; // eax@16 + signed int v21; // esi@18 + int v22; // ecx@21 + BLVMapOutline *v23; // ecx@21 + Vec3_short_ *v24; // edx@21 + Vec3_short_ *v25; // eax@21 + int v26; // ecx@21 + unsigned __int16 *v27; // edi@21 + int v28; // edx@21 + int v29; // eax@21 + double v30; // st7@23 + signed __int64 v31; // qax@23 + unsigned short *v32; // edx@23 + int textr_width; // esi@23 + signed int v34; // eax@23 + signed int v35; // ecx@23 + int v36; // esi@27 + int v37; // ecx@27 + int v38; // edx@31 + unsigned int v39; // eax@33 + short *v40; // esi@33 + short *v41; // edi@33 + unsigned __int8 v42; // cf@33 + unsigned int v43; // ecx@33 + short *v44; // edi@33 + short *v45; // esi@33 + int v46; // ecx@33 + signed int v47; // esi@38 + signed int v48; // ecx@38 + int v49; // eax@38 + signed int v50; // edx@55 + unsigned int v51; // ecx@55 + int result; // eax@72 + int v53; // eax@75 + int v54; // esi@75 + int v55; // eax@75 + __int16 v56; // si@85 + double v57; // st7@85 + int v58; // ebx@85 + signed __int64 v59; // qax@85 + signed int v60; // edi@85 + signed __int64 v61; // qax@85 + signed int v62; // ebx@85 + signed int v63; // esi@85 + int v64; // eax@87 + unsigned int v65; // ebx@95 + unsigned short *v66; // edx@95 + unsigned __int16 *v67; // esi@96 + int v68; // edi@98 + unsigned __int16 v69; // cx@99 + unsigned int v70; // [sp-10h] [bp-48074h]@80 + unsigned int v71; // [sp-Ch] [bp-48070h]@80 + unsigned int v72; // [sp-8h] [bp-4806Ch]@80 + signed int v73; // [sp-4h] [bp-48068h]@59 + unsigned __int16 v74; // [sp-4h] [bp-48068h]@79 + unsigned short map_texture_16[147456]; // [sp+Ch] [bp-48058h]@23 + int v76; // [sp+4800Ch] [bp-58h]@23 + unsigned __int16 *v77; // [sp+48010h] [bp-54h]@27 + unsigned __int16 *pPalette_16; // [sp+48014h] [bp-50h]@23 + unsigned int surfPitch; // [sp+48018h] [bp-4Ch]@1 + + int v81; // [sp+48020h] [bp-44h]@23 + unsigned __int16* render16_data; + unsigned char* texture8_data; + unsigned char* curr_line; + int scale_increment; + int scaled_posX; + int scaled_posY; + int stepX_r; + int stepY_r; + + + unsigned int teal; // [sp+48028h] [bp-3Ch]@8 + int v84; // [sp+4802Ch] [bp-38h]@1 + int screenCenter_X; // [sp+48030h] [bp-34h]@1 + int v86; // [sp+48034h] [bp-30h]@1 + int v87; // [sp+48038h] [bp-2Ch]@16 + unsigned int v88; // [sp+4803Ch] [bp-28h]@16 + int black; // [sp+48040h] [bp-24h]@8 + int screenCenterY; // [sp+48044h] [bp-20h]@1 + unsigned int i; // [sp+48048h] [bp-1Ch]@9 + unsigned int screenHeight; // [sp+4804Ch] [bp-18h]@16 + unsigned __int16 *v93; // [sp+48050h] [bp-14h]@16 + signed int screenWidth; // [sp+48054h] [bp-10h]@8 + unsigned int v95; // [sp+48058h] [bp-Ch]@16 + int v96; // [sp+4805Ch] [bp-8h]@10 + const void *v97; // [sp+48060h] [bp-4h]@16 + unsigned short *a4a; // [sp+4806Ch] [bp+8h]@85 + int a5a; // [sp+48070h] [bp+Ch]@86 + + tl_x = tl_x; + tl_y = tl_y; + screenCenter_X = (signed int)(tl_x + br_x) >> 1; + screenCenterY = (signed int)(tl_y + br_y) >> 1; + surfPitch = pRenderer->uTargetSurfacePitch; + pRenderer->SetRasterClipRect(tl_x, tl_y, br_x, br_y); + v5 = viewparams->field_2C; + v6 = viewparams->sViewCenterX; + v86 = viewparams->sViewCenterX; + v84 = viewparams->sViewCenterY; + if ( viewparams->field_2C != 384 ) + { + if ( viewparams->field_2C == 768 ) + { + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + v5 = 680; + } + } + else + { + v6 = viewparams->indoor_center_x; + v86 = viewparams->indoor_center_x; + v84 = viewparams->indoor_center_y; + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) + v5 = viewparams->field_2C - 34; + } + if ( uCurrentlyLoadedLevelType != LEVEL_Indoor) + { + screenWidth = br_x - tl_x + 1; + screenHeight = br_y - tl_y + 1; + render16_data = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch]; + texture8_data = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask; + pPalette_16 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16; + scale_increment = (1 << (pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2 + 16)) / v5; + + v30 = (double)(1 << (16 - pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2)); + + + teal = (unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16; + v97 = (const void *)((unsigned int)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30) << 16); + + v32 = map_texture_16; + textr_width = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth; + stepY_r = (int)(signed __int64)((double)(- v84 - 22528 / (v5 / 384)+ 32768) / v30) << 16; + v81 = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30); + black = (signed __int16)(signed __int64)((double)(v6 - 22528 / (v5 / 384) + 32768) / v30); + + v76 = textr_width; + scaled_posY = stepY_r >> 16; + //nearest neiborhood scaling + if ( texture8_data) + { + for(uint i=0; i<screenHeight;++i) + { + curr_line=&texture8_data[scaled_posY*textr_width]; + stepX_r=teal; + for(uint j=0; j<screenWidth;++j) + { + scaled_posX=stepX_r>>16; + map_texture_16[i*screenWidth+j]=pPalette_16[*(curr_line+scaled_posX)]; + stepX_r+=scale_increment; + } + stepY_r+=scale_increment; + scaled_posY=stepY_r>>16; + } + } + //move visible square to render + for(uint i=0; i<screenHeight;++i) + { + if ( screenWidth > 0 ) + { + memcpy((void*)&render16_data[surfPitch*i],(void*)&map_texture_16[i*screenWidth], screenWidth*2); + } + } + } + else + { + black = TargetColor(0, 0, 0); + teal = TargetColor(0, 0xFFu, 0xFFu); + v7 = pIndoor->pMapOutlines; + uNumBlueFacesInBLVMinimap = 0; + v8 = pIndoor->pMapOutlines->uNumOutlines == 0; + v9 = pIndoor->pMapOutlines->uNumOutlines < 0; + screenWidth = 0; + if ( !(v9 | v8) ) + { + i = 0; + do + { + v10 = (int)((char *)v7 + i + 4); + v96 = pIndoor->pFaces[*(short *)((char *)v7 + i + 8)].uAttributes; + if ( !(BYTE1(v96) & 0x20 || (v11 = pIndoor->pFaces[*(short *)((char *)v7 + i + 10)].uAttributes, BYTE1(v11) & 0x20) )) + { + v12 = *(short *)((char *)v7 + i + 14); + if ( !(v12 & 1) ) + { + if ( !(!(v96 & 0x80) && (v11 & 0x80u) == 0 )) + { + v96 = (signed int)screenWidth >> 3; + v13 = screenWidth; + *(short *)(v10 + 10) = v12 | 1; + pIndoor->_visible_outlines[v96] |= 1 << (7 - v13 % 8); + } + } + if ( (!(v12 & 1) && !(!(v96 & 0x80) && (v11 & 0x80u) == 0 )) || v12 & 1) + { + v14 = *(short *)v10; + v88 = v5; + v15 = &pIndoor->pVertices[v14]; + v16 = v15->x; + v17 = v15->y - v84; + v93 = (unsigned __int16 *)(v16 - v6); + screenHeight = v17; + v18 = &pIndoor->pVertices[*(short *)(v10 + 2)]; + v19 = v18->x; + v20 = v18->y - v84; + v95 = v19 - v6; + v97 = (const void *)v20; + v88 = (unsigned __int64)((v16 - v6) * (signed __int64)v5) >> 16; + v87 = (unsigned __int64)((signed int)screenHeight * (signed __int64)v5) >> 16; + v93 = (unsigned __int16 *)((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16); + screenHeight = (unsigned __int64)(v20 * (signed __int64)v5) >> 16; + pRenderer->RasterLine2D( + screenCenter_X + v88, + screenCenterY - v87, + screenCenter_X + ((unsigned __int64)((v19 - v6) * (signed __int64)v5) >> 16), + screenCenterY - screenHeight, + black); + v7 = pIndoor->pMapOutlines; + } + } + ++screenWidth; + i += 12; + } + while ( screenWidth < (signed int)v7->uNumOutlines ); + } + v21 = 0; + if ( (signed int)uNumBlueFacesInBLVMinimap > 0 ) + { + while ( 1 ) + { + v22 = pBlueFacesInBLVMinimapIDs[v21]; + v87 = v5; + v23 = &v7->pOutlines[v22]; + v24 = &pIndoor->pVertices[v23->uVertex1ID]; + v25 = &pIndoor->pVertices[v23->uVertex2ID]; + v26 = v25->x; + v27 = (unsigned __int16 *)(v24->x - v86); + v28 = v24->y - v84; + v29 = v25->y - v84; + v93 = v27; + screenHeight = v28; + v97 = (const void *)v29; + v87 = (unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16; + v88 = (unsigned __int64)(v28 * (signed __int64)v5) >> 16; + i = (unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16; + v95 = (unsigned __int64)(v29 * (signed __int64)v5) >> 16; + pRenderer->RasterLine2D( + screenCenter_X + ((unsigned __int64)((signed int)v27 * (signed __int64)v5) >> 16), + screenCenterY - v88, + screenCenter_X + ((unsigned __int64)((v26 - v86) * (signed __int64)v5) >> 16), + screenCenterY - v95, + teal); + ++v21; + if ( v21 >= (signed int)uNumBlueFacesInBLVMinimap ) + break; + v7 = pIndoor->pMapOutlines; + } + v6 = v86; + } + } + v47 = ((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 3; + v81 = pParty->vPosition.y - v84; + v97 = (const void *)((unsigned __int64)((pParty->vPosition.y - v84) * (signed __int64)v5) >> 16); + v48 = 1; + v49 = screenCenterY - (int)v97 - 3; + if ( v47 >= (signed int)tl_x ) + { + if ( v47 > (signed int)br_x ) + { + if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X - 6) > (signed int)br_x ) + v48 = 0; + v47 = br_x; + } + } + else + { + if ( (signed int)(((unsigned __int64)((pParty->vPosition.x - v6) * (signed __int64)v5) >> 16) + screenCenter_X) < (signed int)tl_x ) + v48 = 0; + v47 = tl_x; + } + if ( v49 >= (signed int)tl_y ) + { + if ( v49 > br_y ) + { + if ( screenCenterY - (signed int)v97 - 6 > br_y ) + v48 = 0; + v49 = br_y; + } + } + else + { + if ( screenCenterY - (signed int)v97 < (signed int)tl_y ) + v48 = 0; + v49 = tl_y; + } + if ( v48 == 1 ) + { + v50 = 0; + v51 = pParty->sRotationY & stru_5C6E00->uDoublePiMask; + if ( (signed int)(pParty->sRotationY & stru_5C6E00->uDoublePiMask) >= 128 ) + { + if ( (signed int)v51 > 384 ) + { + if ( (signed int)v51 >= 640 ) + { + if ( (signed int)v51 > 896 ) + { + if ( (signed int)v51 >= 1152 ) + { + if ( (signed int)v51 > 1408 ) + { + if ( (signed int)v51 >= 1664 ) + { + if ( (signed int)v51 <= 1920 ) + v73 = 7; + } + else + { + v73 = 6; + } + } + else + { + v73 = 5; + } + } + else + { + v73 = 4; + } + } + else + { + v73 = 3; + } + } + else + { + v73 = 2; + } + if( (signed int)v51 <=1920) + v50 = v73; + } + else + v50 = 1; + } + pRenderer->DrawTransparentRedShade(v47, v49, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[v50])); + } + result = TargetColor(0xFFu, 0xFFu, 0xFFu); + v95 = 0; + v86 = result; + if ( (signed int)uNumLevelDecorations > 0 ) + { + screenWidth = (unsigned int)&pLevelDecorations[0].vPosition; + do + { + if ( *(char *)(screenWidth - 2) & 8 ) + { + v53 = *(int *)(screenWidth + 4) - v84; + v93 = (unsigned __int16 *)(*(int *)screenWidth - v6); + screenHeight = v53; + v54 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X; + v97 = (const void *)((unsigned __int64)(v53 * (signed __int64)v5) >> 16); + v55 = screenCenterY - (int)v97; + if ( v54 >= pRenderer->raster_clip_x ) + { + if ( v54 <= pRenderer->raster_clip_z && v55 >= pRenderer->raster_clip_y && v55 <= pRenderer->raster_clip_w ) + { + v74 = v86; + if ( v5 > 512 ) + { + v96 = v55 + 1; + black = v55 - 1; + pRenderer->RasterLine2D(v54 - 1, v55 - 1, v54 - 1, v55 + 1, v86); + pRenderer->RasterLine2D(v54, black, v54, v96, v86); + ++v54; + v74 = v86; + v72 = v96; + v71 = v54; + v70 = black; + } + else + { + v72 = screenCenterY - (int)v97; + v71 = ((unsigned __int64)((signed int)v93 * (signed __int64)v5) >> 16) + screenCenter_X; + v70 = screenCenterY - (int)v97; + } + pRenderer->RasterLine2D(v54, v70, v71, v72, v74); + } + } + } + ++v95; + result = v95; + screenWidth += 32; + } + while ( (signed int)v95 < (signed int)uNumLevelDecorations ); + } + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + { + screenCenterY = br_x - tl_x + 1; + v95 = br_y - tl_y + 1; + v77 = &pRenderer->pTargetSurface[tl_x + tl_y * surfPitch]; + v56 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2; + black = (1 << (v56 + 16)) / v5; + v57 = (double)(1 << (16 - v56)); + v58 = 22528 / (v5 / 384); + v59 = (signed __int64)((double)(v6 - v58 + 32768) / v57); + v60 = (int)v59 << 16; + v97 = (const void *)((int)v59 << 16); + v61 = (signed __int64)((double)(32768 - v58 - v84) / v57); + pPalette_16 = (unsigned __int16 *)(v60 >> 16); + v62 = (int)v61 << 16; + teal = v60 >> 16; + v63 = (signed __int16)v61; + a4a = map_texture_16; + result = TargetColor(0xCu, 0xCu, 0xCu); + screenCenter_X = 0; + for ( i = result; screenCenter_X < (signed int)v95; result = screenCenter_X ) + { + a5a = 0; + if ( screenCenterY > 0 ) + { + v96 = (v63 - 80) / 4; + v64 = teal; + do + { + v81 = (v64 - 80) / 4; + if ( !pOutdoor->_47F04C(v81, v96) ) + { + if ( pOutdoor->_47F097(v81, v96) ) + { + if ( !((a5a + screenCenter_X) % 2) ) + *a4a = i; + } + else + { + *a4a = 0; + } + } + ++a4a; + v97 = (char *)v97 + black; + v64 = (signed int)v97 >> 16; + ++a5a; + } + while ( a5a < screenCenterY ); + } + v62 += black; + v97 = (const void *)v60; + a4a += screenCenterY - a5a; + v63 = v62 >> 16; + ++screenCenter_X; + teal = (unsigned int)pPalette_16; + } + v65 = v95; + v66 = map_texture_16; + if ( (signed int)v95 > 0 ) + { + v67 = v77; + result = 2 * (surfPitch - screenCenterY); + do + { + if ( screenCenterY > 0 ) + { + v68 = screenCenterY; + do + { + v69 = *(short *)v66; + if ( !*(short *)v66 || v69 == (short)i ) + *v67 = v69; + ++v66; + ++v67; + --v68; + } + while ( v68 ); + } + v67 = (unsigned __int16 *)((char *)v67 + result); + --v65; + } + while ( v65 ); + } + } + } + + + + + +//----- (00412AF9) -------------------------------------------------------- +static void BookUI_Spellbook_DrawCurrentSchoolBackground() +{ + int v0; // ecx@1 + + v0 = 0; + if ( uActiveCharacter ) + v0 = pParty->pPlayers[uActiveCharacter - 1].lastOpenedSpellbookPage;//*((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2); + pRenderer->DrawTextureIndexed(8, 8, pSpellBookPagesTextr[v0]); + pRenderer->DrawTextureIndexed(0x1DCu, 0x1C2u, pTexture_50643C); + pRenderer->DrawTextureIndexed(0x231u, 0x1C2u, pTexture_506448); +} + + + + + +//----- (00412B58) -------------------------------------------------------- +void DrawSpellBookContent(Player *player) +{ + //Player *v0; // ebx@1 + int v1; // ebp@1 + //unsigned int v2; // eax@1 + Texture *v3; // edi@1 + int v4; // esi@1 + Texture *v5; // eax@3 + Texture *v6; // edx@5 + int v7; // eax@8 + int v8; // eax@11 + POINT *v9; // esi@13 + int v10; // eax@13 + Texture *v11; // edx@14 + int v12; // eax@15 + signed int v13; // ecx@18 + unsigned int v14; // esi@18 + unsigned int v15; // edi@18 + Texture *pPageTexture; // eax@21 + unsigned int v17; // [sp-Ch] [bp-2Ch]@8 + unsigned int v18; // [sp-Ch] [bp-2Ch]@15 + unsigned int v19; // [sp-8h] [bp-28h]@8 + unsigned int v20; // [sp-8h] [bp-28h]@15 + Texture *v21; // [sp-4h] [bp-24h]@15 + signed int v22; // [sp-4h] [bp-24h]@22 + Texture *v23; // [sp+10h] [bp-10h]@5 + POINT a2; // [sp+18h] [bp-8h]@13 + POINT v24; + int v25; + + static unsigned int texture_tab_coord1[9][2]= + {{406, 9}, {406, 46}, {406, 84}, {406,121}, {407,158}, {405, 196}, {405, 234}, {405, 272}, {405,309} }; + + static unsigned int texture_tab_coord0[9][2]= + {{415, 10}, {415, 46}, {415, 83}, {415,121}, {415,158}, {416, 196}, {416, 234}, {416, 271}, {416,307} }; + + BookUI_Spellbook_DrawCurrentSchoolBackground(); + + //v0 = pPlayers[uActiveCharacter]; + v1 = 11 * player->lastOpenedSpellbookPage; + //v2 = pIcons_LOD->FindTextureByName("Pending"); + v3 = pIcons_LOD->GetTexture(pIcons_LOD->FindTextureByName("Pending")); + pRenderer->ClearZBuffer(0, 479); + v4 = 1; + if ( __OFSUB__(v1, v1 + 11) ^ 1 ) + { + do + { + if ( *(&player->_guilds_member_bits[v1 + 63] + v4) ) + { + v5 = (Texture *)dword_506408[v4]; + if ( v5 != v3 ) + { + if ( quick_spell_at_page == v4 ) + { + v6 = dword_5063D8[v4]; + v23 = dword_5063D8[v4]; + } + else + { + v23 = dword_506408[v4]; + v6 = v5; + } + if ( v6->pLevelOfDetail0_prolly_alpha_mask ) + { + v7 = player->lastOpenedSpellbookPage; + // v7 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v4]); + v19 = pViewport->uViewportTL_Y + pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos; + v17 = pViewport->uViewportTL_X + pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos; + if ( BYTE1(v6->pBits) & 2 ) + pRenderer->DrawTextureTransparent(v17, v19, v6); + else + pRenderer->DrawTextureIndexed(v17, v19, v6); + pRenderer->DrawMaskToZBuffer(pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Xpos, + pIconPos[v7][pSpellbookSpellIndices[v7][v4]].Ypos, v23, v4); + } + } + } + ++v4; + } + while ( v4 - 1 < 11 ); + } + + + v9 = pMouse->GetCursorPos(&a2); + v10 = pRenderer->pActiveZBuffer[v9->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v24)->y]] & 0xFFFF; + if ( v10 ) + { + v11 = dword_5063D8[v10]; + if ( v11->pLevelOfDetail0_prolly_alpha_mask ) + { + v21 = dword_5063D8[v10]; + v12 = player->lastOpenedSpellbookPage; + // v12 = (12 * v0->lastOpenedSpellbookPage + pSpellbookSpellIndices[v0->lastOpenedSpellbookPage][v10]); + v20 = pViewport->uViewportTL_Y + pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Ypos; + v18 = pViewport->uViewportTL_X + pIconPos[v12][pSpellbookSpellIndices[v12][v10]].Xpos; + if ( BYTE1(v11->pBits) & 2 ) + pRenderer->DrawTextureTransparent(v18, v20, v21); + else + pRenderer->DrawTextureIndexed(v18, v20, v21); + } + } + v13 = 0; + a2.x = (LONG)&player->pActiveSkills[12]; + v14 = (unsigned int)&player->pActiveSkills[12]; + v15 = (unsigned int)&player->pActiveSkills[12]; + v25 = 0; + do + { + if ( *(short *)a2.x ) + { + if ( player->lastOpenedSpellbookPage == v13 ) + { + pPageTexture = pTextures_tabs[v13][1]; + v14=texture_tab_coord1[v13][0]; + v15=texture_tab_coord1[v13][1]; + } + else + { + pPageTexture = pTextures_tabs[v13][0]; + v14=texture_tab_coord0[v13][0]; + v15=texture_tab_coord0[v13][1]; + } + pRenderer->DrawTextureTransparent(v14, v15, pPageTexture); + v13 = v25; + } + a2.x += 2; + ++v13; + v25 = v13; + } + while ( v13 < 9 ); +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/UICharacter.cpp Wed Jun 19 17:18:35 2013 +0600 @@ -0,0 +1,3125 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include <assert.h> + +#include <algorithm> + +#include "MM7.h" + +#include "MapInfo.h" +#include "Game.h" +#include "GUIWindow.h" +#include "GUIFont.h" +#include "GUIProgressBar.h" +#include "Party.h" +#include "AudioPlayer.h" +#include "Render.h" +#include "IndoorCamera.h" +#include "LOD.h" +#include "Viewport.h" +#include "Time.h" +#include "Awards.h" +#include "CastSpellInfo.h" +#include "texts.h" + +#include "mm7_data.h" +#include "Mouse.h" +#include "Allocator.h" + + +int bRingsShownInCharScreen; // 5118E0 + + +unsigned int ui_mainmenu_copyright_color; + +unsigned int ui_character_default_text_color; +unsigned int ui_character_skill_highlight_color; +unsigned int ui_character_header_text_color; +unsigned int ui_character_bonus_text_color; +unsigned int ui_character_bonus_text_color_neg; +unsigned int ui_character_skill_upgradeable_color; +unsigned int ui_character_skill_default_color; +std::array<unsigned int, 6> ui_character_award_color; + +unsigned int ui_game_minimap_outline_color; +unsigned int ui_game_minimap_actor_friendly_color; +unsigned int ui_game_minimap_actor_hostile_color; +unsigned int ui_game_minimap_actor_corpse_color; +unsigned int ui_game_minimap_decoration_color_1; +unsigned int ui_game_minimap_projectile_color; +unsigned int ui_game_minimap_treasure_color; +std::array<unsigned int, 24> ui_game_character_record_playerbuff_colors; + +unsigned int ui_gamemenu_video_gamma_title_color; +unsigned int ui_gamemenu_keys_action_name_color; +unsigned int ui_gamemenu_keys_key_selection_blink_color_1; +unsigned int ui_gamemenu_keys_key_selection_blink_color_2; +unsigned int ui_gamemenu_keys_key_default_color; + +unsigned int ui_book_quests_title_color; +unsigned int ui_book_quests_text_color; +unsigned int ui_book_autonotes_title_color; +unsigned int ui_book_autonotes_text_color; +unsigned int ui_book_map_title_color; +unsigned int ui_book_map_coordinates_color; + +unsigned int ui_book_calendar_title_color; +unsigned int ui_book_calendar_time_color; +unsigned int ui_book_calendar_day_color; +unsigned int ui_book_calendar_month_color; +unsigned int ui_book_calendar_year_color; +unsigned int ui_book_calendar_moon_color; +unsigned int ui_book_calendar_location_color; + +unsigned int ui_book_journal_title_color; +unsigned int ui_book_journal_text_color; +unsigned int ui_book_journal_text_shadow; + +std::array<unsigned int, 16> papredoll_dbrds; +unsigned int papredoll_drhs[4]; +unsigned int papredoll_dlhus[4]; +unsigned int papredoll_dlhs[4]; +unsigned int papredoll_dbods[5]; +int paperdoll_armor_texture[4][17][3]; +//int paperdoll_array_51132C[165]; +unsigned int papredoll_dlaus[5]; +unsigned int papredoll_dlads[4]; +int papredoll_flying_feet[777]; // idb +int paperdoll_boots_texture[4][6];//0x511638 +int paperdoll_cloak_collar_texture[4][10]; // weak +int paperdoll_cloak_texture[4][10]; +int paperdoll_helm_texture[2][16]; //511698 +int paperdoll_belt_texture[4][7]; //511718 + + +const int paperdoll_Weapon[4][16][2] = {//4E4C30 + {{128, 205}, {30, 144}, {88, 85}, {0, 0}, {0, 0}, {0, 0}, {17, 104}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + {{131, 201}, {38, 158}, {98, 87}, {0, 0}, {0, 0}, {0, 0}, {21, 100}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + {{131, 216}, {29, 186}, {88, 119}, {0, 0}, {0, 0}, {0, 0}, { 0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + {{123, 216}, {35, 184}, {98, 119}, {0, 0}, {0, 0}, {0, 0}, { 0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}}, + }; + + + +const int paperdoll_Boot[4][7][2] = //4E5490 + { + 0xE, 0x11D, 0xD, 0x11D, 0xC, 0x10A, 0xA, 0xFF, 0xD, 0xF9, 0xD, 0x137, 0xC, 0x10E, + 0x14, 0x125, 0x13, 0x122, 0x15, 0x120, 0x15, 0x114, 0x13, 0x10A, 0x11, 0x13E, 0x11, 0x116, + 0x1D, 0x121, 0x1C, 0x11F, 0x1B, 0x11B, 0x1C, 0x117, 0x16, 0x116, 0x1B, 0x137, 0x1B, 0x11B, + 0x1F, 0x127, 0x1F, 0x122, 0x1B, 0x11B, 0x1D, 0x117, 0x1D, 0x116, 0x1D, 0x137, 0x1B, 0x11F, + }; +const int paperdoll_Cloak[4][10][2] = //4E5570 + { + 0x11, 0x68, 0xF, 0x68, 0x14, 0x71, 0x19, 0x6B, 0x21, 0x6F, 0x5, 0x68, 0x5, 0x68, 0x14, 0x71, 0x3, 0x6B, 0xF, 0x6F, + 0x15, 0x64, 0xB, 0x6B, 0xE, 0x67, 0x15, 0x6B, 0x1B, 0x6F, 0x3, 0x6B, 0, 0x6B, 0xE, 0x67, 0, 0x6B, 0x3, 0x6F, + 0x10, 0x8A, 0x9, 0x8B, 0x18, 0x98, 0x25, 0x91, 0x29, 0x90, 0x8, 0x8A, 0x9, 0x8B, 0x18, 0x98, 0x3, 0x91, 0x3, 0x90, + 0x14, 0x92, 0x10, 0x92, 0x15, 0x98, 0x1F, 0x91, 0x22, 0x90, 0x8, 0x92, 0xC, 0x92, 0x15, 0x98, 0x3, 0x91, 0x3, 0x90, + }; +const int paperdoll_CloakCollar[4][10][2] = //4E56B0 + { + 0x11, 0x68, 0x34, 0x64, 0x21, 0x69, 0x1D, 0x67, 0x20, 0x67, 0x21, 0x68, 0x34, 0x64, 0x21, 0x69, 0x1D, 0x67, 0x1F, 0x67, + 0x13, 0x64, 0x35, 0x66, 0x29, 0x68, 0x1F, 0x68, 0x1F, 0x6A, 0x21, 0x6A, 0x2B, 0x66, 0x26, 0x68, 0x1F, 0x68, 0x1F, 0x6A, + 0, 0, 0x30, 0x87, 0x1E, 0x86, 0x1B, 0x86, 0x1C, 0x8A, 0x21, 0x87, 0x30, 0x87, 0x1E, 0x86, 0x1B, 0x86, 0x1C, 0x8A, + 0, 0, 0x38, 0x8A, 0x24, 0x8B, 0x1D, 0x8B, 0x21, 0x8C, 0x27, 0x8A, 0x34, 0x8A, 0x24, 0x8B, 0x25, 0x8B, 0x21, 0x8C, + }; +//int dword_4E56B4; // weak +const int paperdoll_Belt[4][7][2] = //4E57F0 + { + 0x3A, 0xB6, 0x37, 0xB2, 0x34, 0xB9, 0x3A, 0xB9, 0x37, 0xB7, 0x38, 0xAC, 0x37, 0xB7, + 0x3E, 0xAD, 0x3A, 0xAC, 0x37, 0xB0, 0x3A, 0xB1, 0x39, 0xB0, 0x3C, 0xA5, 0x39, 0xB0, + 0x3B, 0xD5, 0x37, 0xD2, 0x31, 0xD5, 0x39, 0xD6, 0x37, 0xD8, 0x37, 0xD1, 0x37, 0xD8, + 0x42, 0xD2, 0x3F, 0xD0, 0x3B, 0xD7, 0x3C, 0xD5, 0x3B, 0xD6, 0x3E, 0xCF, 0x36, 0xD6, + }; +const int paperdoll_Helm[4][16][2] = //4E58D0 + { + 0x3E, 0x1F, 0x41, 0x2C, 0x37, 0x2F, 0x31, 0x32, 0x37, 0x2A, 0x39, 0x28, 0x36, 0x34, 0x41, 0x38, 0x40, 0x31, 0x40, 0x21, 0x40, 0x31, 0x3C, 0x33, 0x3D, 0x24, 0x3A, 0x1A, 0x37, 0x2A, 0x41, 0x48, + 0x41, 0x1E, 0x42, 0x2B, 0x37, 0x2F, 0x34, 0x30, 0x39, 0x29, 0x3A, 0x26, 0x36, 0x34, 0x41, 0x37, 0x42, 0x32, 0x40, 0x21, 0x40, 0x31, 0x40, 0x2F, 0x3E, 0x22, 0x3B, 0x1A, 0x39, 0x29, 0x42, 0x47, + 0x3F, 0x47, 0x41, 0x56, 0x37, 0x59, 0x32, 0x5E, 0x37, 0x58, 0x39, 0x54, 0x34, 0x61, 0x40, 0x61, 0x41, 0x5D, 0x3E, 0x4F, 0x3E, 0x5B, 0x3D, 0x5B, 0x3F, 0x4C, 0x3B, 0x45, 0x37, 0x58, 0x41, 0x74, + 0x45, 0x45, 0x46, 0x54, 0x3A, 0x55, 0x38, 0x58, 0x3C, 0x54, 0x3F, 0x52, 0x39, 0x5B, 0x45, 0x5C, 0x47, 0x5C, 0x44, 0x4B, 0x44, 0x57, 0x43, 0x55, 0x44, 0x4A, 0x3E, 0x45, 0x3C, 0x54, 0x47, 0x70, + }; +const int pPaperdoll_Beards[4] = //4E5AD0 + { + 52, 130, 56, 136, + }; +const int pPaperdoll_LeftHand[4][2] = //4E5AE0 + { + 0x67, 0x6A, + 0x65, 0x6C, + 0x74, 0x8D, + 0x74, 0x93, + }; +const int pPaperdoll_SecondLeftHand[4][2] = //4E5B00 + { + 0x1A, 0x6B, + 0x28, 0x6D, + 0x19, 0x8D, + 0x20, 0x92, + }; +const int pPaperdoll_RightHand[4][2] = //4E5B20 + { + 0x1E, 0x90, + 0x22, 0x9E, + 0x19, 0xBA, + 0x1F, 0xB8, + }; +const int pPaperdollLeftEmptyHand[4][2] = //4E5B40 + { + 0x80, 0xCD, + 0x83, 0xC9, + 0x83, 0xD8, + 0x7B, 0xD8, + }; + +int pPaperdoll_BodyX = 481; // 004E4C28 +int pPaperdoll_BodyY = 0; // 004E4C2C +const int paperdoll_Armor[4][17][2] = //4E4E30 + { + // X Y + 0x2C, 0x67, 0x30, 0x69, 0x2D, 0x67, 0x2C, 0x64, 0x14, 0x66, 0x22, 0x67, 0x20, 0x66, 0x25, 0x66, 0x12, 0x66,//Human + 0x0A, 0x66, 0x13, 0x64, 0x0E, 0x64, 0x0A, 0x63, 0x14, 0x66, 0x0A, 0x63, 0x0A, 0x66, 0x25, 0x66, + + 0x32, 0x68, 0x32, 0x69, 0x35, 0x69, 0x33, 0x68, 0x24, 0x67, 0x30, 0x69, 0x33, 0x68, 0x31, 0x69, 0x19, 0x69, + 0x19, 0x6A, 0x16, 0x66, 0x16, 0x65, 0x0F, 0x6B, 0x24, 0x67, 0x0F, 0x6B, 0x19, 0x6A, 0x31, 0x69, + + 0x2A, 0x8C, 0x29, 0x8C, 0x2A, 0x89, 0x29, 0x86, 0x12, 0x87, 0x2D, 0x89, 0x2A, 0x88, 0x25, 0x87, 0x12, 0x8B, + 0x12, 0x8B, 0x11, 0x8A, 0x15, 0x87, 0x09, 0x89, 0x12, 0x87, 0x09, 0x89, 0x12, 0x8B, 0x25, 0x87, + + 0x33, 0x90, 0x32, 0x90, 0x34, 0x91, 0x32, 0x8E, 0x21, 0x8B, 0x31, 0x8B, 0x33, 0x8E, 0x2F, 0x8F, 0x16, 0x8D, + 0x18, 0x8C, 0x19, 0x8C, 0x1B, 0x8E, 0x0C, 0x8C, 0x21, 0x8B, 0x0C, 0x8C, 0x18, 0x8C, 0x2F, 0x8F, + }; +const int paperdoll_shoulder[4][17][2] = //4E5050 + { + 0x64, 0x67, 0x61, 0x67, 0x65, 0x68, 0x6E, 0x74, 0x6C, 0x68, 0x61, 0x67, 0x66, 0x68, 0x6C, 0x6A, 0x6E, 0x6D, + 0x67, 0x69, 0x70, 0x67, 0x6E, 0x6D, 0x6C, 0x6F, 0x6C, 0x68, 0x6C, 0x6F, 0x67, 0x69, 0x6C, 0x6A, + + 0x60, 0x6B, 0x60, 0x6C, 0x60, 0x6B, 0x61, 0x6A, 0x60, 0x69, 0x60, 0x6A, 0x60, 0x6A, 0x61, 0x69, 0x63, 0x6A, + 0x64, 0x6A, 0x61, 0x66, 0x66, 0x67, 0x64, 0x6C, 0x60, 0x69, 0x64, 0x6C, 0x64, 0x6A, 0x61, 0x69, + + 0x6D, 0x8C, 0x75, 0x8C, 0, 0, 0x72, 0x8D, 0x6A, 0x89, 0, 0, 0x73, 0x8C, 0x69, 0x8C, 0x6E, 0x8D, + 0x71, 0x8D, 0x70, 0x8D, 0x72, 0x8D, 0x74, 0x8E, 0x6A, 0x89, 0x74, 0x8E, 0x71, 0x8D, 0x69, 0x8C, + + 0x72, 0x91, 0x72, 0x91, 0, 0, 0x6E, 0x92, 0x6F, 0x91, 0, 0, 0, 0, 0x6E, 0x91, 0x71, 0x90, + 0x72, 0x8D, 0x72, 0x90, 0x73, 0x93, 0x73, 0x90, 0x6F, 0x91, 0x73, 0x90, 0x72, 0x8D, 0x6E, 0x91, + }; +const int dword_4E5270[4][2] = + { + 0, 0, + 0x61, 0x67, + 0, 0, + 0x64, 0x69, + }; + +const char *dlad_texnames_by_face[25] = + { + "pc01lad", "pc02lad", "pc03lad", "pc04lad", "pc05lad", "pc06lad", + "pc07lad", "pc08lad", "pc09lad", "pc10lad", "pc11lad", "pc12lad", + "pc13lad", "pc14lad", "pc15lad", "pc16lad", "pc17lad", "pc18lad", + "pc19lad", "pc20lad", "pc21lad", "pc22lad", "pc23lad", "pc24lad", + "pc25lad" + }; +const char *dlau_texnames_by_face[25] = + { + "pc01lau", "pc02lau", "pc03lau", "pc04lau", "pc05lau", "pc06lau", + "pc07lau", "pc08lau", "pc09lau", "pc10lau", "pc11lau", "pc12lau", + "pc13lau", "pc14lau", "pc15lau", "pc16lau", "pc17lau", "pc18lau", + "pc19lau", "pc20lau", "pc21lau", "pc22lau", "pc23lau", "pc24lau", + "pc25lau" + }; +const char *dbod_texnames_by_face[25] = + { + "pc01bod", "pc02bod", "pc03bod", "pc04bod", "pc05bod", "pc06bod", + "pc07bod", "pc08bod", "pc09bod", "pc10bod", "pc11bod", "pc12bod", + "pc13bod", "pc14bod", "pc15bod", "pc16bod", "pc17bod", "pc18bod", + "pc19bod", "pc20bod", "pc21bod", "pc22bod", "pc23bod", "pc24bod", + "pc25bod" + }; +const char *drh_texnames_by_face[25] = + { + + "pc01rh", "pc02rh", "pc03rh", "pc04rh", "pc05rh", "pc06rh", + "pc07rh", "pc08rh", "pc09rh", "pc10rh", "pc11rh", "pc12rh", + "pc13rh", "pc14rh", "pc15rh", "pc16rh", "pc17rh", "pc18rh", + "pc19rh", "pc20rh", "pc21rh", "pc22rh", "pc23rh", "pc24rh", + "pc25rh" + }; +const char *dlh_texnames_by_face[25] = + { + "pc01lh", "pc02lh", "pc03lh", "pc04lh", "pc05lh", "pc06lh", + "pc07lh", "pc08lh", "pc09lh", "pc10lh", "pc11lh", "pc12lh", + "pc13lh", "pc14lh", "pc15lh", "pc16lh", "pc17lh", "pc18lh", + "pc19lh", "pc20lh", "pc21lh", "pc22lh", "pc23lh", "pc24lh", + "pc25lh" + }; +const char *dlhu_texnames_by_face[25] = + { + "pc01lhu", "pc02lhu", "pc03lhu", "pc04lhu", "pc05lhu", "pc06lhu", + "pc07lhu", "pc08lhu", "pc09lhu", "pc10lhu", "pc11lhu", "pc12lhu", + "pc13lhu", "pc14lhu", "pc15lhu", "pc16lhu", "pc17lhu", "pc18lhu", + "pc19lhu", "pc20lhu", "pc21lhu", "pc22lhu", "pc23lhu", "pc24lhu", + "pc25lhu" + }; + +const int pArmorSkills[5] = {PLAYER_SKILL_LEATHER, PLAYER_SKILL_CHAIN, PLAYER_SKILL_PLATE, PLAYER_SKILL_SHIELD, PLAYER_SKILL_DODGE}; +const int pWeaponSkills[9] = {PLAYER_SKILL_AXE, PLAYER_SKILL_BOW, PLAYER_SKILL_DAGGER, PLAYER_SKILL_MACE, PLAYER_SKILL_SPEAR, + PLAYER_SKILL_STAFF, PLAYER_SKILL_SWORD, PLAYER_SKILL_UNARMED, PLAYER_SKILL_BLASTER}; +const int pMiscSkills[12] = {PLAYER_SKILL_ALCHEMY, PLAYER_SKILL_ARMSMASTER, PLAYER_SKILL_BODYBUILDING, PLAYER_SKILL_ITEM_ID, PLAYER_SKILL_MONSTER_ID, + PLAYER_SKILL_LEARNING, PLAYER_SKILL_TRAP_DISARM, PLAYER_SKILL_MEDITATION, PLAYER_SKILL_MERCHANT, PLAYER_SKILL_PERCEPTION, + PLAYER_SKILL_REPAIR, PLAYER_SKILL_STEALING}; +const int pMagicSkills[9] = {PLAYER_SKILL_FIRE, PLAYER_SKILL_AIR, PLAYER_SKILL_WATER, PLAYER_SKILL_EARTH, PLAYER_SKILL_SPIRIT, + PLAYER_SKILL_MIND, PLAYER_SKILL_BODY, PLAYER_SKILL_LIGHT, PLAYER_SKILL_DARK}; + + + + +void set_default_ui_skin() +{ + ui_mainmenu_copyright_color = TargetColor(255, 255, 255); + + ui_character_default_text_color = TargetColor(255, 255, 255); + ui_character_header_text_color = TargetColor(255, 255, 155); + ui_character_bonus_text_color = TargetColor(0, 255, 0); + ui_character_bonus_text_color_neg = TargetColor(255, 0, 0); + + ui_character_skill_upgradeable_color = TargetColor(0, 175, 255); + ui_character_skill_default_color = TargetColor(255, 0, 0); + ui_character_skill_highlight_color = TargetColor(255, 0, 0); + + ui_character_award_color[0] = TargetColor(248, 108, 160); + ui_character_award_color[1] = TargetColor(112, 220, 248); + ui_character_award_color[2] = TargetColor(192, 192, 240); + ui_character_award_color[3] = TargetColor( 64, 244, 96); + ui_character_award_color[4] = TargetColor(232, 244, 96); + ui_character_award_color[5] = TargetColor(240, 252, 192); + + ui_game_minimap_outline_color = TargetColor(0, 0, 255); + ui_game_minimap_actor_friendly_color = TargetColor(0, 255, 0); + ui_game_minimap_actor_hostile_color = TargetColor(255, 0, 0); + ui_game_minimap_actor_corpse_color = TargetColor(255, 255, 0); + ui_game_minimap_decoration_color_1 = TargetColor(255, 255, 255); + ui_game_minimap_projectile_color = TargetColor(255, 0, 0); + ui_game_minimap_treasure_color = TargetColor(0, 0, 255); + ui_game_character_record_playerbuff_colors[0] = TargetColor(150, 212, 255); + ui_game_character_record_playerbuff_colors[1] = TargetColor(225, 225, 225); + ui_game_character_record_playerbuff_colors[2] = TargetColor(255, 128, 0); + ui_game_character_record_playerbuff_colors[3] = TargetColor(128, 128, 128); + ui_game_character_record_playerbuff_colors[4] = TargetColor(225, 225, 225); + ui_game_character_record_playerbuff_colors[5] = TargetColor(255, 85, 0); + ui_game_character_record_playerbuff_colors[6] = TargetColor(255, 128, 0); + ui_game_character_record_playerbuff_colors[7] = TargetColor(255, 85, 0); + ui_game_character_record_playerbuff_colors[8] = TargetColor(225, 225, 225); + ui_game_character_record_playerbuff_colors[9] = TargetColor(235, 15, 255); + ui_game_character_record_playerbuff_colors[10] = TargetColor(192, 192, 240); + ui_game_character_record_playerbuff_colors[11] = TargetColor(225, 225, 225); + ui_game_character_record_playerbuff_colors[12] = TargetColor(255, 128, 0); + ui_game_character_record_playerbuff_colors[13] = TargetColor(150, 212, 255); + ui_game_character_record_playerbuff_colors[14] = TargetColor(128, 128, 128); + ui_game_character_record_playerbuff_colors[15] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[16] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[17] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[18] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[19] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[20] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[21] = TargetColor(255, 255, 155); + ui_game_character_record_playerbuff_colors[22] = TargetColor(0, 128, 255); + ui_game_character_record_playerbuff_colors[23] = TargetColor(0, 128, 255); + + ui_gamemenu_video_gamma_title_color = TargetColor(255, 255, 155); + ui_gamemenu_keys_action_name_color = TargetColor(255, 255, 255); + ui_gamemenu_keys_key_selection_blink_color_1 = TargetColor(50, 0, 0); + ui_gamemenu_keys_key_selection_blink_color_2 = TargetColor(225, 205, 35); + ui_gamemenu_keys_key_default_color = TargetColor(255, 255, 255); + + ui_book_quests_title_color = TargetColor(255, 255, 255); + ui_book_quests_text_color = TargetColor(255, 255, 255); + ui_book_autonotes_title_color = TargetColor(255, 255, 255); + ui_book_autonotes_text_color = TargetColor(255, 255, 255); + ui_book_map_title_color = TargetColor(255, 255, 255); + ui_book_map_coordinates_color = TargetColor(255, 255, 255); + + ui_book_calendar_title_color = TargetColor(255, 255, 255); + ui_book_calendar_time_color = TargetColor(75, 75, 75); + ui_book_calendar_day_color = TargetColor(75, 75, 75); + ui_book_calendar_month_color = TargetColor(75, 75, 75); + ui_book_calendar_year_color = TargetColor(75, 75, 75); + ui_book_calendar_moon_color = TargetColor(75, 75, 75); + ui_book_calendar_location_color = TargetColor(75, 75, 75); + + ui_book_journal_title_color = TargetColor(255, 255, 255); + ui_book_journal_text_color = TargetColor(255, 255, 255); + ui_book_journal_text_shadow = TargetColor(0, 0, 0); +} + + + + +//----- (00421626) -------------------------------------------------------- +GUIWindow *CharacterUI_Initialize(unsigned int _this) +{ + GUIWindow *pWindow; // edi@3 + + ++pIcons_LOD->uTexturePacksCount; + if ( !pIcons_LOD->uNumPrevLoadedFiles ) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + + pEventTimer->Pause(); + pAudioPlayer->StopChannels(-1, -1); + bRingsShownInCharScreen = false; + CharacterUI_LoadPaperdollTextures(); + pCurrentScreen = _this; + + pWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_CharacterRecord, uActiveCharacter, 0); + pCharacterScreen_StatsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 12, pViewport->uViewportTL_Y + 308, + pIcons_LOD->GetTexture(papredoll_dbrds[9])->uTextureWidth, + pIcons_LOD->GetTexture(papredoll_dbrds[9])->uTextureHeight, + 1, 0, UIMSG_ClickStatsBtn, 0, 'S', pGlobalTXT_LocalizationStrings[216],// Stats + pIcons_LOD->GetTexture(papredoll_dbrds[10]), + pIcons_LOD->GetTexture(papredoll_dbrds[9]), 0); + pCharacterScreen_SkillsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 102, pViewport->uViewportTL_Y + 308, + pIcons_LOD->GetTexture(papredoll_dbrds[7])->uTextureWidth, + pIcons_LOD->GetTexture(papredoll_dbrds[7])->uTextureHeight, + 1, 0, UIMSG_ClickSkillsBtn, 0, 'K', pGlobalTXT_LocalizationStrings[205],//Skills + pIcons_LOD->GetTexture(papredoll_dbrds[8]), + pIcons_LOD->GetTexture(papredoll_dbrds[7]), 0); + pCharacterScreen_InventoryBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 192, pViewport->uViewportTL_Y + 308, + pIcons_LOD->GetTexture(papredoll_dbrds[5])->uTextureWidth, + pIcons_LOD->GetTexture(papredoll_dbrds[5])->uTextureHeight, + 1, 0, UIMSG_ClickInventoryBtn, 0, 'I', pGlobalTXT_LocalizationStrings[120], //Inventory + pIcons_LOD->GetTexture(papredoll_dbrds[6]), + pIcons_LOD->GetTexture(papredoll_dbrds[5]), 0); + pCharacterScreen_AwardsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 282, pViewport->uViewportTL_Y + 308, + pIcons_LOD->GetTexture(papredoll_dbrds[3])->uTextureWidth, + pIcons_LOD->GetTexture(papredoll_dbrds[3])->uTextureHeight, + 1, 0, UIMSG_ClickAwardsBtn, 0, 'A', pGlobalTXT_LocalizationStrings[22], //Awards + pIcons_LOD->GetTexture(papredoll_dbrds[4]), + pIcons_LOD->GetTexture(papredoll_dbrds[3]), 0); + pCharacterScreen_ExitBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 371, pViewport->uViewportTL_Y + 308, + pIcons_LOD->GetTexture(papredoll_dbrds[1])->uTextureWidth, + pIcons_LOD->GetTexture(papredoll_dbrds[1])->uTextureHeight, + 1, 0, UIMSG_ClickExitCharacterWindowBtn, 0, 0, pGlobalTXT_LocalizationStrings[79],//Exit + pIcons_LOD->GetTexture(papredoll_dbrds[2]), + pIcons_LOD->GetTexture(papredoll_dbrds[1]), 0); + pWindow->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, UIMSG_InventoryLeftClick, 0, 0, "", 0); + pCharacterScreen_DetalizBtn = pWindow->CreateButton(0x258u, 0x12Cu, 30, 30, 1, 0, UIMSG_ChangeDetaliz, 0, 0, pGlobalTXT_LocalizationStrings[64], 0); + pCharacterScreen_DollBtn = pWindow->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 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, '\t', "", 0); + FillAwardsData(); + return pWindow; +} + +//----- (004219BE) -------------------------------------------------------- +GUIWindow *CastSpellInfo::sub_4219BE() +{ + GUIWindow *v2; // ebx@1 + + pEventTimer->Pause(); + pAudioPlayer->StopChannels(-1, -1); + bRingsShownInCharScreen = 0; + CharacterUI_LoadPaperdollTextures(); + pCurrentScreen = SCREEN_CASTING; + v2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell_InInventory, (int)this, 0); + pCharacterScreen_ExitBtn = v2->CreateButton(394, 318, 75, 33, 1, 0, UIMSG_ClickExitCharacterWindowBtn, 0, 0, + pGlobalTXT_LocalizationStrings[79], // Close + pIcons_LOD->GetTexture(papredoll_dbrds[2]), + pIcons_LOD->GetTexture(papredoll_dbrds[1]), 0); + v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, UIMSG_InventoryLeftClick, 0, 0, "", 0); + pCharacterScreen_DollBtn = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 0); + + v2->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); + v2->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); + v2->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); + v2->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); + + return v2; +} + + + + + + +static int CharacterUI_SkillsTab_Draw__DrawSkillTable(Player *player, int x, int y, const int *skill_list, int skill_list_size, int right_margin, const char *skill_group_name) +{ + int y_offset = y; + + sprintf(pTmpBuf.data(), "%s\r%03d%s", skill_group_name, right_margin, pGlobalTXT_LocalizationStrings[131]); //"Level" + pGUIWindow_CurrentMenu->DrawText(pFontArrus, x, y, ui_character_header_text_color, pTmpBuf.data(), 0, 0, 0); + + int num_skills_drawn = 0; + for (uint i = 0; i < skill_list_size; ++i) + { + auto skill = (PLAYER_SKILL_TYPE)skill_list[i]; + for (uint j = 0; j < pGUIWindow_CurrentMenu->uNumControls; ++j) + { + auto v8 = pGUIWindow_CurrentMenu->pControlsHead; + + for (int v7 = j; v7 > 0; --v7) + v8 = v8->pNext; + + auto v9 = v8->field_1C; + if ((short)(v8->field_1C) >= 0) + continue; + if ( (v9 & 0x7FFF) != skill ) + continue; + + ++num_skills_drawn; + y_offset = v8->uY; + + auto skill_value = player->pActiveSkills[skill]; + auto skill_level = skill_value & 0x3F; + + uint skill_color = 0; + uint skill_mastery_color = 0; + if (player->uSkillPoints > skill_level) + skill_color = ui_character_skill_upgradeable_color; + + if (pGUIWindow_CurrentMenu->pCurrentPosActiveItem == j) + { + if (player->uSkillPoints > skill_level) + skill_mastery_color = ui_character_bonus_text_color; + else + skill_mastery_color = ui_character_skill_default_color; + skill_color = skill_mastery_color; + } + + if (SkillToMastery(skill_value) == 1) + { + sprintfex(pTmpBuf.data(), "%s\r%03d%2d", pSkillNames[skill], right_margin, skill_level); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, x, v8->uY, skill_color, pTmpBuf.data(), 0, 0, 0); + } + else + { + const char *skill_level_str = nullptr; + + switch (SkillToMastery(skill_value)) + { + case 4: skill_level_str = pGlobalTXT_LocalizationStrings[96]; break; // "Grand" + case 3: skill_level_str = pGlobalTXT_LocalizationStrings[432]; break; // Master + case 2: skill_level_str = pGlobalTXT_LocalizationStrings[433]; break; // Expert + } + + if (!skill_mastery_color) + skill_mastery_color = ui_character_header_text_color; + + sprintfex(pTmpBuf.data(), "%s \f%05d%s\f%05d\r%03d%2d", pSkillNames[skill], skill_mastery_color, skill_level_str, skill_color, right_margin, skill_level); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, x, v8->uY, skill_color, pTmpBuf.data(), 0, 0, 0); + } + } + } + + if (!num_skills_drawn) + { + y_offset += LOBYTE(pFontLucida->uFontHeight) - 3; + pGUIWindow_CurrentMenu->DrawText(pFontLucida, x, y_offset, 0, pGlobalTXT_LocalizationStrings[153], 0, 0, 0); //"None" + } + + return y_offset; +} + + + +//----- (00419719) -------------------------------------------------------- +void CharacterUI_SkillsTab_Draw(Player *player) +{ + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->LoadTexturePtr("fr_skill", TEXTURE_16BIT_PALETTE)); + + sprintfex(pTmpBuf.data(), "%s \f%05d^Pv[%s]\f00000\r177%s: \f%05d%d\f00000", + pGlobalTXT_LocalizationStrings[206], // Skills for + ui_character_header_text_color, + player->pName, + pGlobalTXT_LocalizationStrings[207], // Skill Points + player->uSkillPoints ? ui_character_bonus_text_color : ui_character_default_text_color, + player->uSkillPoints); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf.data(), 0, 0, 0); + + int y = 2 * LOBYTE(pFontLucida->uFontHeight) + 13; + y = CharacterUI_SkillsTab_Draw__DrawSkillTable(player, 24, y, pWeaponSkills, 9, 400, pGlobalTXT_LocalizationStrings[242]); // "Weapons" + + y += 2 * LOBYTE(pFontLucida->uFontHeight) - 10; + CharacterUI_SkillsTab_Draw__DrawSkillTable(player, 24, y, pMagicSkills, 9, 400, pGlobalTXT_LocalizationStrings[138]); // "Magic" + + y = 2 * LOBYTE(pFontLucida->uFontHeight) + 13; + y = CharacterUI_SkillsTab_Draw__DrawSkillTable(player, 248, y, pArmorSkills, 5, 177, pGlobalTXT_LocalizationStrings[11]); // "Armor" + + y += 2 * LOBYTE(pFontLucida->uFontHeight) - 10; + y = CharacterUI_SkillsTab_Draw__DrawSkillTable(player, 248, y, pMiscSkills, 12, 177, pGlobalTXT_LocalizationStrings[143]); //"Misc" +} + + + + + + + + + + +//----- (0041A000) -------------------------------------------------------- +void CharacterUI_AwardsTab_Draw(Player *player) +{ + //unsigned int v1; // esi@1 + //unsigned int v2; // ebx@1 + //unsigned int award_texture_id; // eax@1 + unsigned int result; // eax@1 + int v5; // eax@15 + char *v6; // ebx@15 + int v7; // eax@23 + int v8; // eax@24 + int v9; // eax@25 + //int v10; // eax@27 + int v11; // eax@32 + int v12; // eax@33 + int v13; // eax@34 + //signed int v14; // eax@43 + //unsigned int v15; // eax@43 + //int v16; // eax@43 + //int v17; // [sp-4h] [bp-D4h]@16 + char Source[100]; // [sp+Ch] [bp-C4h]@1 + GUIWindow a1; // [sp+70h] [bp-60h]@1 + //unsigned int v20; // [sp+C4h] [bp-Ch]@15 + //int v21; // [sp+C8h] [bp-8h]@14 + //int v22; // [sp+CCh] [bp-4h]@40 + + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->LoadTexturePtr("fr_award", TEXTURE_16BIT_PALETTE)); + sprintfex(pTmpBuf.data(), "%s \f%05d", pGlobalTXT_LocalizationStrings[LOCSTR_AVARDS_FOR], ui_character_header_text_color); + sprintfex(Source, pGlobalTXT_LocalizationStrings[LOCSTR_S_THE_S], player->pName, pClassNames[player->classType]); + strcat(pTmpBuf.data(), Source); + strcat(pTmpBuf.data(), "\f00000"); + + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 24, 18, 0, pTmpBuf.data(), 0, 0, 0); + result = dword_506528; + a1.uFrameX = 12; + a1.uFrameY = 48; + a1.uFrameWidth = 424; + a1.uFrameHeight = 290; + a1.uFrameZ = 435; + a1.uFrameW = 337; + if (BtnDown_flag && num_achieved_awards + dword_506528 < num_achieved_awards_2) + result = dword_506528++ + 1; + if (BtnUp_flag && result) + { + --result; + dword_506528 = result; + } + + if ( dword_50651C < 0 ) + { + result += num_achieved_awards; + dword_506528 = result; + if ( (signed int)(num_achieved_awards + result) > num_achieved_awards_2 ) + { + result = num_achieved_awards_2 - num_achieved_awards; + dword_506528 = result; + } + } + else if ( dword_50651C > 0 ) + { + result -= num_achieved_awards; + dword_506528 = result; + if ( (result & 0x80000000u) != 0 ) + { + result = 0; + dword_506528 = result; + } + } + //LABEL_14: + BtnDown_flag = 0; + BtnUp_flag = 0; + num_achieved_awards = 0; + dword_50651C = 0; + + + for (uint i = result; i < num_achieved_awards_2; ++i) + { + v5 = achieved_awards[i]; + v6 = (char *)pAwards[v5].pText;//(char *)dword_723E80_award_related[v20 / 4]; + + pTmpBuf[0] = 0; + switch (v5) + { + case Award_Arena_PageWins: sprintf(pTmpBuf.data(), v6, pParty->uNumArenaPageWins); break; + case Award_Arena_SquireWins: sprintf(pTmpBuf.data(), v6, pParty->uNumArenaSquireWins); break; + case Award_Arena_KnightWins: sprintf(pTmpBuf.data(), v6, pParty->uNumArenaKnightWins); break; + case Award_Arena_LordWins: sprintf(pTmpBuf.data(), v6, pParty->uNumArenaLordWins); break; + case Award_ArcomageWins: sprintf(pTmpBuf.data(), v6, pParty->uNumArcomageWins); break; + case Award_ArcomageLoses: sprintf(pTmpBuf.data(), v6, pParty->uNumArcomageLoses); break; + case Award_Deaths: sprintf(pTmpBuf.data(), v6, pParty->uNumDeaths); break; + case Award_BountiesCollected: sprintf(pTmpBuf.data(), v6, pParty->uNumBountiesCollected); break; + case Award_Fine: sprintf(pTmpBuf.data(), v6, pParty->uFine); break; + case Award_PrisonTerms: sprintf(pTmpBuf.data(), v6, pParty->uNumPrisonTerms); break; + } + + if (*pTmpBuf.data()) + v6 = pTmpBuf.data(); + + + a1.DrawText(pFontArrus, 0, 0, ui_character_award_color[pAwards[v5].uPriority % 6], v6, 0, 0, 0); + a1.uFrameY = pFontArrus->CalcTextHeight(v6, &a1, 0, 0) + a1.uFrameY + 4; + if (a1.uFrameY > a1.uFrameHeight) + break; + + ++num_achieved_awards; + } + } + + + + + + +//----- (0041A2C1) -------------------------------------------------------- +unsigned int __fastcall GetSizeInInventorySlots(unsigned int uNumPixels) +{ + if ( (signed int)uNumPixels < 14 ) + uNumPixels = 14; + return ((signed int)(uNumPixels - 14) >> 5) + 1; +} + + + +//----- (0041A556) -------------------------------------------------------- +void draw_leather() +{ + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_Leather)); +} + + +//----- (0041ABFD) -------------------------------------------------------- +void CharacterUI_CharacterScreen_Draw(Player *player) +{ + pRenderer->ClearZBuffer(0, 479); + switch (pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0]) + { + case WINDOW_CharacterWindow_Stats: // stats + CharacterUI_ReleaseButtons(); + sub_419379(); + CharacterUI_StatsTab_Draw(player); + pRenderer->DrawTextureIndexed(pCharacterScreen_StatsBtn->uX, + pCharacterScreen_StatsBtn->uY, + pIcons_LOD->LoadTexturePtr("ib-cd1-d", TEXTURE_16BIT_PALETTE)); + break; + + case WINDOW_CharacterWindow_Skills: // skills + if (dword_507CC0_activ_ch != uActiveCharacter) + { + CharacterUI_ReleaseButtons(); + CharacterUI_SkillsTab_CreateButtons(); + } + sub_419379(); + CharacterUI_SkillsTab_Draw(player); + pRenderer->DrawTextureIndexed(pCharacterScreen_SkillsBtn->uX, + pCharacterScreen_SkillsBtn->uY, + pIcons_LOD->LoadTexturePtr("ib-cd2-d", TEXTURE_16BIT_PALETTE)); + break; + + case WINDOW_CharacterWindow_Awards: // awards + CharacterUI_ReleaseButtons(); + sub_419379(); + sub_419220(); + CharacterUI_AwardsTab_Draw(player); + pRenderer->DrawTextureIndexed(pCharacterScreen_AwardsBtn->uX, + pCharacterScreen_AwardsBtn->uY, + pIcons_LOD->LoadTexturePtr("ib-cd4-d", TEXTURE_16BIT_PALETTE)); + break; + + case WINDOW_CharacterWindow_Inventory: // inventory and other + CharacterUI_ReleaseButtons(); + sub_419379(); + CharacterUI_InventoryTab_Draw(player, false); + pRenderer->DrawTextureIndexed(pCharacterScreen_InventoryBtn->uX, + pCharacterScreen_InventoryBtn->uY, + pIcons_LOD->LoadTexturePtr("ib-cd3-d", TEXTURE_16BIT_PALETTE)); + break; + + default: break; + } + + if (bRingsShownInCharScreen) + CharacterUI_DrawPaperdollWithRingOverlay(player); + else + CharacterUI_DrawPaperdoll(player); +} + +//----- (0043CC7C) -------------------------------------------------------- +void CharacterUI_DrawPaperdoll(Player *player) +{ + //signed int pSex; // eax@1 + unsigned int v6; // ecx@9 + int v7; // ecx@10 + unsigned int pMainHandNum4; // eax@14 + ItemGen *item_MainHand4; // eax@15 + int v10; // edx@15 + unsigned int pX_MainHand4; // edi@15 + unsigned int v14; // ebx@18 + Texture *v16; // ebp@27 + double v17; // st7@29 + int v18; // edi@30 + char *v19; // eax@30 + unsigned int pBowNum; // eax@37 + ItemGen *itemBow; // edi@38 + int pX_Bow; // ebx@38 + double v28; // st7@51 + char *v30; // eax@54 + unsigned int pCloakNum; // eax@59 + ItemGen *item_Cloak; // edx@60 + int v33; // eax@65 + int v34; // eax@74 + int v35; // ebx@74 + LODFile_IconsBitmaps *v38; // ecx@78 + Texture *v39; // edi@85 + double v40; // st7@87 + int v41; // edi@88 + unsigned int pArmorNum; // eax@93 + ItemGen *item_Armor; // edx@94 + int v45; // eax@98 + int v48; // ebx@106 + LODFile_IconsBitmaps *v50; // ecx@110 + Texture *v51; // edi@117 + double v52; // st7@119 + int v53; // edi@120 + char *v55; // eax@122 + unsigned int pBootNum; // eax@127 + ItemGen *item_Boot; // edi@128 + int v59; // ebx@129 + int v60; // ecx@132 + Texture *v63; // edi@145 + double v64; // st7@147 + int v65; // edi@148 + char *v66; // eax@148 + unsigned int pMainHandNum; // edx@155 + int v70; // edx@156 + unsigned int pBeltNum; // eax@160 + ItemGen *item_Belt; // edi@161 + int v73; // edx@163 + unsigned int v75; // ebx@170 + Texture *v77; // edi@181 + double v78; // st7@183 + int v79; // edi@184 + char *v80; // eax@184 + unsigned int pMainHandNum2; // eax@192 + int v83; // eax@193 + int pArmorShoulderNum; // eax@197 + int v87; // eax@197 + int v88; // eax@198 + int v89; // eax@199 + int v94; // ebx@214 + int v95; // eax@214 + char *v96; // edi@226 + double v97; // st7@228 + int v98; // edi@229 + char *v99; // eax@229 + int pX_ArmorShoulder; // eax@237 + int pY_ArmorShoulder; // ecx@237 + int v106; // edx@238 + int v107; // edx@239 + int v108; // edx@240papredoll_flying_feet + int v109; // edi@250 + char *v110; // edx@250 + unsigned int pCloakCollarNum; // eax@259 + ItemGen *item_CloakCollar; // eax@260 + int v114; // eax@265 + int v116; // ebx@274 + double v118; // st7@286 + int v119; // edi@287 + char *v120; // eax@287 + unsigned int v122; // edi@295 + int pHelmNum; // ebx@297 + ItemGen *item_Helm; // edi@298 + int v125; // ecx@303 + unsigned int v127; // ebx@314 + Texture *v129; // edi@325 + double v130; // st7@327 + int v131; // edi@328 + char *v132; // eax@328 + unsigned int pMainHandNum3; // eax@335 + ItemGen *item_MainHand3; // eax@336 + unsigned int v138; // ebx@339 + Texture *v140; // edi@348 + double v141; // st7@350 + int v142; // edi@351 + char *v143; // eax@351 + unsigned int pShieldNum; // eax@358 + ItemGen *item_Shield; // eax@359 + int v149; // edx@359 + int pX_Shield; // ebx@362 + int v151; // ecx@363 + int v152; // ecx@364 + unsigned int v153; // eax@370 + Texture *v157; // ebp@381 + double v158; // st7@383 + char *v160; // eax@386 + unsigned int pMainHandNum5; // eax@393 + ItemGen *item_MainHand5; // eax@394 + char *v166; // [sp-8h] [bp-54h]@16 + const char *v167; // [sp-8h] [bp-54h]@23 + const char *v168; // [sp-8h] [bp-54h]@43 + const char *v169; // [sp-8h] [bp-54h]@79 + const char *v170; // [sp-8h] [bp-54h]@111 + const char *v171; // [sp-8h] [bp-54h]@141 + const char *v172; // [sp-8h] [bp-54h]@177 + const char *v173; // [sp-8h] [bp-54h]@222 + const char *v178; // [sp-8h] [bp-54h]@242 + const char *v179; // [sp-8h] [bp-54h]@280 + const char *v180; // [sp-8h] [bp-54h]@321 + char *v181; // [sp-8h] [bp-54h]@337 + const char *v182; // [sp-8h] [bp-54h]@344 + const char *v183; // [sp-8h] [bp-54h]@375 + signed int v186; // [sp-4h] [bp-50h]@202 + signed int v191; // [sp-4h] [bp-50h]@266 + signed int v192; // [sp-4h] [bp-50h]@304 + int pY_MainHand4; // [sp+10h] [bp-3Ch]@15 + int pY_Bow; // [sp+10h] [bp-3Ch]@38 + unsigned int pY_Cloak; // [sp+10h] [bp-3Ch]@74 + unsigned int pY_Armor; // [sp+10h] [bp-3Ch]@106 + int pY_Boot; // [sp+10h] [bp-3Ch]@129 + int pY_Belt; // [sp+10h] [bp-3Ch]@168 + unsigned int pY_shoulder; // [sp+10h] [bp-3Ch]@216 + unsigned int pY_CloakCollar; // [sp+10h] [bp-3Ch]@274 + int pY_Helm; // [sp+10h] [bp-3Ch]@312 + int pY_MainHand3; // [sp+10h] [bp-3Ch]@336 + int pY_Shield; // [sp+10h] [bp-3Ch]@362 + Texture *a2b; // [sp+14h] [bp-38h]@49 + int pX_Cloak; // [sp+14h] [bp-38h]@74 + int pX_Armor; // [sp+14h] [bp-38h]@106 + int pX_Boot; // [sp+14h] [bp-38h]@129 + int pX_Belt; // [sp+14h] [bp-38h]@168 + int pX_shoulder; // [sp+14h] [bp-38h]@214 + int pX_CloakCollar; // [sp+14h] [bp-38h]@274 + Texture *a2i; // [sp+14h] [bp-38h]@284 + int pX_Helm; // [sp+14h] [bp-38h]@312 + int pX_MainHand3; // [sp+14h] [bp-38h]@336 + int pBodyComplection; // [sp+24h] [bp-28h]@6 + unsigned int pBowTextureNum; // [sp+2Ch] [bp-20h]@38 + signed int v245; // [sp+34h] [bp-18h]@361 + signed int IsDwarf; // [sp+40h] [bp-Ch]@4 + + pIcons_LOD->LoadTexture("sptext01", TEXTURE_16BIT_PALETTE); + if (player->GetRace() == CHARACTER_RACE_DWARF) + { + IsDwarf = 1; + pBodyComplection = player->GetSexByVoice() == SEX_MALE ? 2 : 3; + } + else + { + IsDwarf = 0; + pBodyComplection = player->GetSexByVoice() == SEX_MALE ? 0 : 1; + } + + int uPlayerID = 0; + for (uint i = 0; i < 4; ++i) + if (pPlayers[i + 1] == player) + { + uPlayerID = i + 1; + break; + } + + pRenderer->ResetTextureClipRect(); + pRenderer->DrawTextureIndexed(467, 0, pIcons_LOD->GetTexture(uTextureID_BACKDOLL));//Ïîäëîæêà + if ( IsPlayerWearingWatersuit[uPlayerID] )//àêâàëàíã + { + pRenderer->DrawTextureTransparent(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1])); + if ( !bRingsShownInCharScreen ) + pRenderer->DrawMaskToZBuffer(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]), player->pEquipment.uArmor); + v6 = player->pEquipment.uMainHand; + if ( !v6 || (v7 = *(int *)&pPlayers[uPlayerID]->pInventoryItems[v6-1], pItemsTable->pItems[v7].uEquipType != 1) + && (pItemsTable->pItems[v7].uSkillType != 4 || pPlayers[uPlayerID]->pEquipment.uShield) ) + pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1], + pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1])); + pMainHandNum4 = pPlayers[uPlayerID]->pEquipment.uMainHand; + if ( pMainHandNum4 ) + { + item_MainHand4 = &pPlayers[uPlayerID]->pInventoryItems[pMainHandNum4 - 1]; + pX_MainHand4 = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][1][0] - pItemsTable->pItems[item_MainHand4->uItemID].uEquipX; + pY_MainHand4 = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][1][1] - pItemsTable->pItems[item_MainHand4->uItemID].uEquipY; + if ( item_MainHand4->uItemID == 64 ) //blaster + v166 = "item64v1"; + else + v166 = pItemsTable->pItems[item_MainHand4->uItemID].pIconName; + v14 = pIcons_LOD->LoadTexture(v166, TEXTURE_16BIT_PALETTE); + if ( !( item_MainHand4->uAttributes & 0xF0 ) ) + { + v18 = v14 + 1; + v19 = (char *)pIcons_LOD->GetTexture(v14); + if ( item_MainHand4->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(pX_MainHand4, pY_MainHand4, (Texture *)v19); + else + { + if ( item_MainHand4->uAttributes & 1 ) + pRenderer->DrawTextureTransparent(pX_MainHand4, pY_MainHand4, (Texture *)v19); + else + pRenderer->DrawTransparentGreenShade(pX_MainHand4, pY_MainHand4, (Texture *)v19); + } + } + if ( item_MainHand4->uAttributes & 0xF0 ) + { + if ( ( item_MainHand4->uAttributes & 0xF0) == 16 ) + v167 = "sptext01"; + if ( ( item_MainHand4->uAttributes & 0xF0) == 32 ) + v167 = "sp28a"; + if ( (item_MainHand4->uAttributes & 0xF0) == 64 ) + v167 = "sp30a"; + if ( (item_MainHand4->uAttributes & 0xF0) == 128 ) + v167 = "sp91a"; + v16 = pIcons_LOD->LoadTexturePtr(v167, TEXTURE_16BIT_PALETTE); + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + item_MainHand4->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4 = 0; + } + v17 = (double)GetTickCount() * 0.1; + pRenderer->_4A63E6(pX_MainHand4, pY_MainHand4, pIcons_LOD->GetTexture(v14), v16, (signed __int64)v17, 0, 255); + } + if ( !bRingsShownInCharScreen ) + pRenderer->DrawMaskToZBuffer(pX_MainHand4, pY_MainHand4, (Texture *)v19, pMainHandNum4); + } + } + else// áåç àêâàëàíãà + { + pBowNum = pPlayers[uPlayerID]->pEquipment.uBow; //ñíà÷àëà ðèñóåòñÿ ëóê + if ( pBowNum ) + { + itemBow = &pPlayers[uPlayerID]->pInventoryItems[pBowNum - 1]; + pX_Bow = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][2][0] - pItemsTable->pItems[itemBow->uItemID].uEquipX; + pY_Bow = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][2][1] - pItemsTable->pItems[itemBow->uItemID].uEquipY; + pBowTextureNum = pIcons_LOD->LoadTexture(pItemsTable->pItems[itemBow->uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if ( !(itemBow->uAttributes & 0xF0) )// åñëè íå ïðèìåí¸í çàêë + { + if ( itemBow->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(pX_Bow, pY_Bow, pIcons_LOD->GetTexture(pBowTextureNum)); + else + { + v30 = (char *)pIcons_LOD->GetTexture(pBowTextureNum); + if ( !(itemBow->uAttributes & 1) )//íå îïîçíàííûé ëóê çåë¸íûé + pRenderer->DrawTransparentGreenShade(pX_Bow, pY_Bow, (Texture *)v30); + else // îïîçíàííûé ëóê + pRenderer->DrawTextureTransparent(pX_Bow, pY_Bow, (Texture *)v30); + } + } + else + { + if ( (itemBow->uAttributes & 0xF0) == 16 ) + v168 = "sptext01"; + if ( (itemBow->uAttributes & 0xF0) == 32 ) + v168 = "sp28a"; + if ( (itemBow->uAttributes & 0xF0) == 64 ) + v168 = "sp30a"; + if ( (itemBow->uAttributes & 0xF0) == 128 ) + v168 = "sp91a"; + a2b = pIcons_LOD->LoadTexturePtr(v168, TEXTURE_16BIT_PALETTE); + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + itemBow->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4 = 0; + } + v28 = (double)GetTickCount() * 0.1; + pRenderer->_4A63E6(pX_Bow, pY_Bow, pIcons_LOD->GetTexture(pBowTextureNum), a2b, (signed __int64)v28, 0, 255); + } + if ( !bRingsShownInCharScreen ) + pRenderer->DrawMaskToZBuffer(pX_Bow, pY_Bow, pIcons_LOD->GetTexture(pBowTextureNum), pBowNum); + } + pCloakNum = pPlayers[uPlayerID]->pEquipment.uCloak;// ïîòîì ïëàù + if ( pCloakNum ) + { + item_Cloak = &pPlayers[uPlayerID]->pInventoryItems[pCloakNum - 1]; + switch ( item_Cloak->uItemID ) + { + case ITEM_RELIC_TWILIGHT: + v33 = 5; + break; + case ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP: + v33 = 6; + break; + case ITEM_RARE_SUN_CLOAK: + v33 = 7; + break; + case ITEM_RARE_MOON_CLOAK: + v33 = 8; + break; + case ITEM_RARE_VAMPIRES_CAPE: + v33 = 9; + break; + default: + v33 = item_Cloak->uItemID - 105; + break; + } + if ( v33 >= 0 && v33 < 10 ) + { + v35 = paperdoll_cloak_texture[pBodyComplection][v33];//Texture_Cloak + pX_Cloak = pPaperdoll_BodyX + paperdoll_Cloak[pBodyComplection][v33][0]; + pY_Cloak = pPaperdoll_BodyY + paperdoll_Cloak[pBodyComplection][v33][1]; + if ( !(item_Cloak->uAttributes & 0xF0) ) + { + v41 = v35 + 1; + if ( item_Cloak->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(pX_Cloak, pY_Cloak, pIcons_LOD->GetTexture(v35)); + else + pRenderer->DrawTextureTransparent(pX_Cloak, pY_Cloak, pIcons_LOD->GetTexture(v35)); + } + else + { + if ( (item_Cloak->uAttributes & 0xF0) == 16 ) + v169 = "sptext01"; + if ( (item_Cloak->uAttributes & 0xF0) == 32 ) + v169 = "sp28a"; + if ( (item_Cloak->uAttributes & 0xF0) != 64 ) + v169 = "sp30a"; + if ( (item_Cloak->uAttributes & 0xF0) == 128 ) + v169 = "sp91a"; + v39 = pIcons_LOD->LoadTexturePtr(v169, TEXTURE_16BIT_PALETTE); + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + item_Cloak->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4 = 0; + } + v40 = (double)GetTickCount() * 0.1; + pRenderer->_4A63E6(pX_Cloak, pY_Cloak, pIcons_LOD->GetTexture(v35), v39, (signed __int64)v40, 0, 255); + } + if ( !bRingsShownInCharScreen ) + pRenderer->DrawMaskToZBuffer(pX_Cloak, pY_Cloak, pIcons_LOD->GetTexture(v35), pCloakNum); + } + } + pRenderer->DrawTextureTransparent(pPaperdoll_BodyX, pPaperdoll_BodyY,//ðèñóåòñÿ êóêëà + pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1])); + pArmorNum = pPlayers[uPlayerID]->pEquipment.uArmor;// ïîòîì áðîíÿ + if ( pArmorNum ) + { + item_Armor = &pPlayers[uPlayerID]->pInventoryItems[pArmorNum - 1]; + switch ( item_Armor->uItemID ) + { + case 504: + v45 = 15; + break; + case ITEM_ARTIFACT_YORUBA: + v45 = 14; + break; + case ITEM_RELIC_HARECS_LEATHER: + v45 = 13; + break; + case ITEM_ELVEN_CHAINMAIL: + v45 = 16; + break; + default: + v45 = item_Armor->uItemID - 66; + break; + } + if ( v45 >= 0 && v45 < 17 ) + { + pX_Armor = pPaperdoll_BodyX + paperdoll_Armor[pBodyComplection][v45][0]; + pY_Armor = pPaperdoll_BodyY + paperdoll_Armor[pBodyComplection][v45][1]; + v48 = paperdoll_armor_texture[pBodyComplection][v45][0]; + if ( !(item_Armor->uAttributes & 0xF0) ) + { + v53 = v48 + 1; + if ( item_Armor->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(pX_Armor, pY_Armor, pIcons_LOD->GetTexture(v48)); + else + { + v55 = (char *)&pIcons_LOD->pTextures[v48]; + if ( !(item_Armor->uAttributes & 1) ) + pRenderer->DrawTransparentGreenShade(pX_Armor, pY_Armor, (Texture *)v55); + else + pRenderer->DrawTextureTransparent(pX_Armor, pY_Armor, (Texture *)v55); + } + } + else + { + if ( (item_Armor->uAttributes & 0xF0) == 16 ) + v170 = "sptext01"; + if ( (item_Armor->uAttributes & 0xF0) == 32 ) + v170 = "sp28a"; + if ( (item_Armor->uAttributes & 0xF0) == 64 ) + v170 = "sp30a"; + if ( (item_Armor->uAttributes & 0xF0) == 128 ) + v170 = "sp91a"; + v51 = pIcons_LOD->LoadTexturePtr(v170, TEXTURE_16BIT_PALETTE); + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + item_Armor->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4 = 0; + } + v52 = (double)GetTickCount() * 0.1; + pRenderer->_4A63E6(pX_Armor, pY_Armor, pIcons_LOD->GetTexture(v48), v51, (signed __int64)v52, 0, 255); + } + if ( pPlayers[uPlayerID]->pEquipment.uMainHand //äàëåå ïëå÷è áðîíè + && (pPlayers[uPlayerID]->GetEquippedItemEquipType(EQUIP_MAIN_HAND) == EQUIP_MAIN_HAND || + pPlayers[uPlayerID]->GetEquippedItemSkillType(EQUIP_MAIN_HAND) == EQUIP_SHIELD && + !pPlayers[uPlayerID]->pEquipment.uShield) ) + { + v94 = paperdoll_armor_texture[pBodyComplection][v45][2]; + if ( v94 == pIcons_LOD->FindTextureByName("pending") ) + { + v94 = paperdoll_armor_texture[pBodyComplection][v45][1]; + pX_shoulder = pPaperdoll_BodyX + paperdoll_shoulder[pBodyComplection][v45][0]; + pY_shoulder = pPaperdoll_BodyY + paperdoll_shoulder[pBodyComplection][v45][1]; + } + else + { + pX_shoulder = pPaperdoll_BodyX + dword_4E5270[v45][0]; + pY_shoulder = pPaperdoll_BodyY + dword_4E5270[v45][1]; + } + if ( !(item_Armor->uAttributes & 0xF0) ) + { + v98 = v94 + 1; + v99 = (char *)pIcons_LOD->GetTexture(v94); + if ( item_Armor->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(pX_shoulder, pY_shoulder, (Texture *)v99); + else + { + if ( item_Armor->uAttributes & 1 ) + pRenderer->DrawTextureTransparent(pX_shoulder, pY_shoulder, (Texture *)v99); + else + pRenderer->DrawTransparentGreenShade(pX_shoulder, pY_shoulder, (Texture *)v99); + } + } + else + { + if ( v94 != pIcons_LOD->FindTextureByName("pending") ) + { + if ( item_Armor->uAttributes & 0xF0 ) + { + if ( (item_Armor->uAttributes & 0xF0) == ITEM_AURA_EFFECT_RED ) + v173 = "sptext01"; + if ( (item_Armor->uAttributes & 0xF0) == ITEM_AURA_EFFECT_BLUE ) + v173 = "sp28a"; + if ( ( item_Armor->uAttributes & 0xF0) == ITEM_AURA_EFFECT_GREEN ) + v173 = "sp30a"; + if ( (item_Armor->uAttributes & 0xF0) == ITEM_AURA_EFFECT_PURPLE ) + v173 = "sp91a"; + v96 = (char *)pIcons_LOD->LoadTexturePtr(v173, TEXTURE_16BIT_PALETTE); + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + item_Armor->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4 = 0; + } + v97 = (double)GetTickCount(); + pRenderer->_4A63E6(pX_shoulder, pY_shoulder, pIcons_LOD->GetTexture(v94), (Texture *)v96, (signed __int64)(v97 * 0.1), 0, 255); + } + } + } + } + else + { + v94 = paperdoll_armor_texture[pBodyComplection][v45][1]; + if ( v94 != pIcons_LOD->FindTextureByName("pending") ) + { + pX_ArmorShoulder = pPaperdoll_BodyX + paperdoll_shoulder[pBodyComplection][v45][0]; + pY_ArmorShoulder = pPaperdoll_BodyY + paperdoll_shoulder[pBodyComplection][v45][1]; + if ( !(item_Armor->uAttributes & 0xF0) ) + { + v109 = v94 + 1; + v110 = (char *)pIcons_LOD->GetTexture(v94); + if ( item_Armor->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)v110); + else + { + if ( item_Armor->uAttributes & 1 ) + pRenderer->DrawTextureTransparent(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)v110); + else + pRenderer->DrawTransparentGreenShade(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)v110); + } + } + else + { + if ( (item_Armor->uAttributes & 0xF0) == 16 ) + v178 = "sptext01"; + if ( (item_Armor->uAttributes & 0xF0) == 32 ) + v178 = "sp28a"; + if ( (item_Armor->uAttributes & 0xF0) == 64 ) + v178 = "sp30a"; + if ( (item_Armor->uAttributes & 0xF0) == 128 ) + v178 = "sp91a"; + v96 = (char *)pIcons_LOD->LoadTexturePtr(v178, TEXTURE_16BIT_PALETTE); + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + item_Armor->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4 = 0; + } + v97 = (double)GetTickCount(); + pRenderer->_4A63E6(pX_ArmorShoulder, pY_ArmorShoulder, pIcons_LOD->GetTexture(v94), (Texture *)v96, (signed __int64)(v97 * 0.1), 0, 255); + } + } + } + if ( !bRingsShownInCharScreen ) + pRenderer->DrawMaskToZBuffer(pX_Armor, pY_Armor, (Texture *)v55, pArmorNum); + } + } + pBootNum = pPlayers[uPlayerID]->pEquipment.uBoot;//äàëåå îáóâü + if ( pBootNum ) + { + item_Boot = &pPlayers[uPlayerID]->pInventoryItems[pBootNum - 1]; + switch ( item_Boot->uItemID ) + { + case 529: + v60 = 5; + v59 = papredoll_flying_feet[pPlayers[uPlayerID]->uCurrentFace]; + break; + case 512: + v60 = 6; + v59 = paperdoll_boots_texture[pBodyComplection][5]; + break; + default: + v60 = item_Boot->uItemID - 115; + v59 = paperdoll_boots_texture[pBodyComplection][v60]; + break; + } + if ( v60 >= 0 && v60 < 7 ) + { + pX_Boot = pPaperdoll_BodyX + paperdoll_Boot[pBodyComplection][v60][0]; + pY_Boot = pPaperdoll_BodyY + paperdoll_Boot[pBodyComplection][v60][1]; + if ( !(item_Boot->uAttributes & 0xF0) ) + { + v65 = v59 + 1; + v66 = (char *)pIcons_LOD->GetTexture(v59); + if ( item_Boot->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(pX_Boot, pY_Boot, (Texture *)v66); + else + { + if ( item_Boot->uAttributes & 1 ) + pRenderer->DrawTextureTransparent(pX_Boot, pY_Boot, (Texture *)v66); + else + pRenderer->DrawTransparentGreenShade(pX_Boot, pY_Boot, (Texture *)v66); + } + } + else + { + if ( (item_Boot->uAttributes & 0xF0) == 16 ) + v171 = "sptext01"; + if ( (item_Boot->uAttributes & 0xF0) == 32 ) + v171 = "sp28a"; + if ( (item_Boot->uAttributes & 0xF0) == 64 ) + v171 = "sp30a"; + if ( (item_Boot->uAttributes & 0xF0) == 128 ) + v171 = "sp91a"; + v63 = pIcons_LOD->LoadTexturePtr(v171, TEXTURE_16BIT_PALETTE); + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + item_Boot->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4 = 0; + } + v64 = (double)GetTickCount() * 0.1; + pRenderer->_4A63E6(pX_Boot, pY_Boot, pIcons_LOD->GetTexture(v59), v63, (signed __int64)v64, 0, 255); + } + if ( !bRingsShownInCharScreen ) + pRenderer->DrawMaskToZBuffer(pX_Boot, pY_Boot, (Texture *)v66, pBootNum); + } + } + pMainHandNum = pPlayers[uPlayerID]->pEquipment.uMainHand; + if ( !pMainHandNum || (v70 = *(int *)&pPlayers[uPlayerID]->pInventoryItems[pMainHandNum -1], pItemsTable->pItems[v70].uEquipType != 1) + && (pItemsTable->pItems[v70].uSkillType != 4 || pPlayers[uPlayerID]->pEquipment.uShield) ) + pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0], + pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1], + pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1])); + pBeltNum = pPlayers[uPlayerID]->pEquipment.uBelt;// äàëåå ïîÿñ + if ( pBeltNum ) + { + item_Belt = &pPlayers[uPlayerID]->pInventoryItems[pBeltNum - 1]; + switch ( item_Belt->uItemID ) + { + case ITEM_RILIC_TITANS_BELT: + v73 = 5; + break; + case ITEM_ARTIFACT_HEROS_BELT: + v73 = 6; + break; + default: + v73 = item_Belt->uItemID - 100; + break; + } + if ( v73 >= 0 && v73 < 7 ) + { + pX_Belt = pPaperdoll_BodyX + paperdoll_Belt[pBodyComplection][v73][0]; + pY_Belt = pPaperdoll_BodyY + paperdoll_Belt[pBodyComplection][v73][1]; + if ( IsDwarf != 1 || v73 == 5 ) + v75 = paperdoll_belt_texture[pBodyComplection][v73]; + else + v75 = paperdoll_belt_texture[pBodyComplection - 2][v73]; + if ( !(item_Belt->uAttributes & 0xF0) ) + { + v79 = v75 + 1; + v80 = (char *)pIcons_LOD->GetTexture(v75); + if ( item_Belt->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(pX_Belt, pY_Belt, (Texture *)v80); + else + { + if ( item_Belt->uAttributes & 1 ) + pRenderer->DrawTextureTransparent(pX_Belt, pY_Belt, (Texture *)v80); + else + pRenderer->DrawTransparentGreenShade(pX_Belt, pY_Belt, (Texture *)v80); + } + if ( !bRingsShownInCharScreen ) + pRenderer->DrawMaskToZBuffer(pX_Belt, pY_Belt, (Texture *)v80, pBeltNum); + } + else + { + if ( (item_Belt->uAttributes & 0xF0) == 16 ) + v172 = "sptext01"; + if ( (item_Belt->uAttributes & 0xF0) == 32 ) + v172 = "sp28a"; + if ( (item_Belt->uAttributes & 0xF0) == 64 ) + v172 = "sp30a"; + if ( (item_Belt->uAttributes & 0xF0) == 128 ) + v172 = "sp91a"; + v77 = pIcons_LOD->LoadTexturePtr(v172, TEXTURE_16BIT_PALETTE); + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + item_Belt->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4 = 0; + } + v78 = (double)GetTickCount() * 0.1; + pRenderer->_4A63E6(pX_Belt, pY_Belt, pIcons_LOD->GetTexture(v75), v77, (signed __int64)v78, 0, 255); + } + } + } + pMainHandNum2 = pPlayers[uPlayerID]->pEquipment.uMainHand; + if ( pMainHandNum2 ) + { + v83 = pPlayers[uPlayerID]->pInventoryItems[pMainHandNum2 - 1].uItemID; + if ( pItemsTable->pItems[v83].uEquipType == 1 + || pItemsTable->pItems[v83].uSkillType == PLAYER_SKILL_SPEAR && !pPlayers[uPlayerID]->pEquipment.uShield ) + pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], + pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], + pIcons_LOD->GetTexture(papredoll_dlaus[uPlayerID - 1])); + } + pCloakCollarNum = pPlayers[uPlayerID]->pEquipment.uCloak;//äàëåå âîðîòíèê ïëàùà + if ( pCloakCollarNum ) + { + item_CloakCollar = &pPlayers[uPlayerID]->pInventoryItems[pCloakCollarNum - 1]; + switch ( item_CloakCollar->uItemID ) + { + case 525: + v114 = 5; + break; + case 530: + v114 = 6; + break; + case 547: + v114 = 7; + break; + case 548: + v114 = 8; + break; + case 550: + v114 = 9; + break; + default: + v114 = item_CloakCollar->uItemID - 105; + } + if ( v114 >= 0 && v114 < 10 ) + { + v116 = paperdoll_cloak_collar_texture[pBodyComplection][v114]; + pX_CloakCollar = pPaperdoll_BodyX + paperdoll_CloakCollar[pBodyComplection][v114][0]; + pY_CloakCollar = pPaperdoll_BodyY + paperdoll_CloakCollar[pBodyComplection][v114][1]; + if ( v116 != pIcons_LOD->FindTextureByName("pending") ) + { + if ( !(item_CloakCollar->uAttributes & 0xF0) ) + { + v119 = v116 + 1; + v120 = (char *)pIcons_LOD->GetTexture(v116); + if ( item_CloakCollar->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(pX_CloakCollar, pY_CloakCollar, (Texture *)v120); + else + pRenderer->DrawTextureTransparent(pX_CloakCollar, pY_CloakCollar, (Texture *)v120); + if ( !bRingsShownInCharScreen ) + pRenderer->DrawMaskToZBuffer(pX_CloakCollar, pY_CloakCollar, (Texture *)v120, pCloakCollarNum); + } + else + { + if ( (item_CloakCollar->uAttributes & 0xF0) == 16 ) + v179 = "sptext01"; + if ( (item_CloakCollar->uAttributes & 0xF0) == 32 ) + v179 = "sp28a"; + if ( (item_CloakCollar->uAttributes & 0xF0) == 64 ) + v179 = "sp30a"; + if ( (item_CloakCollar->uAttributes & 0xF0) == 128 ) + v179 = "sp91a"; + a2i = pIcons_LOD->LoadTexturePtr(v179, TEXTURE_16BIT_PALETTE); + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + item_CloakCollar->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4 = 0; + } + v118 = (double)GetTickCount() * 0.1; + pRenderer->_4A63E6(pX_CloakCollar, pY_CloakCollar, pIcons_LOD->GetTexture(v116), a2i, (signed __int64)v118, 0, 255); + } + } + } + } + if ( pPlayers[uPlayerID]->uCurrentFace == 12 || pPlayers[uPlayerID]->uCurrentFace == 13 ) + { + v122 = papredoll_dbrds[pPlayers[uPlayerID]->uCurrentFace]; + if ( v122 != pIcons_LOD->FindTextureByName("Pending") ) + pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_Beards[2 * pPlayers[uPlayerID]->uCurrentFace - 24], + pPaperdoll_BodyY + pPaperdoll_Beards[2 * pPlayers[uPlayerID]->uCurrentFace - 23], + pIcons_LOD->GetTexture(v122)); + } + pHelmNum = pPlayers[uPlayerID]->pEquipment.uHelm;//äàëåå øëåì + if ( pHelmNum ) + { + item_Helm = &pPlayers[uPlayerID]->pInventoryItems[pHelmNum-1]; + switch ( item_Helm->uItemID ) + { + case 521: + v125 = 11; + break; + case 522: + v125 = 12; + break; + case 523: + v125 = 13; + break; + case 532: + v125 = 14; + break; + case 544: + v125 = 15; + break; + default: + v125 = item_Helm->uItemID - 89; + } + if ( v125 >= 0 && v125 < 16 ) + { + pX_Helm = pPaperdoll_BodyX + paperdoll_Helm[pBodyComplection][v125][0]; + pY_Helm = pPaperdoll_BodyY + paperdoll_Helm[pBodyComplection][v125][1]; + if ( IsDwarf != 1 || item_Helm->uItemID != 92 ) + v127 = paperdoll_helm_texture[player->GetSexByVoice()][v125]; + else + v127 = papredoll_dbrds[11]; + if ( item_Helm->uAttributes & 0xF0 ) + { + if ( (item_Helm->uAttributes & 0xF0) == 16 ) + v180 = "sptext01"; + if ( (item_Helm->uAttributes & 0xF0) == 32 ) + v180 = "sp28a"; + if ( (item_Helm->uAttributes & 0xF0) == 64 ) + v180 = "sp30a"; + if ( (item_Helm->uAttributes & 0xF0) == 128 ) + v180 = "sp91a"; + v129 = pIcons_LOD->LoadTexturePtr(v180, TEXTURE_16BIT_PALETTE); + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + item_Helm->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4 = 0; + } + v130 = (double)GetTickCount() * 0.1; + pRenderer->_4A63E6(pX_Helm, pY_Helm, pIcons_LOD->GetTexture(v127), v129, (signed __int64)v130, 0, 255); + } + else + { + v131 = v127 + 1; + v132 = (char *)pIcons_LOD->GetTexture(v127); + if ( item_Helm->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(pX_Helm, pY_Helm, (Texture *)v132); + else + { + if ( item_Helm->uAttributes & 1 ) + pRenderer->DrawTextureTransparent(pX_Helm, pY_Helm, (Texture *)v132); + else + pRenderer->DrawTransparentGreenShade(pX_Helm, pY_Helm, (Texture *)v132); + } + } + if ( !bRingsShownInCharScreen ) + pRenderer->DrawMaskToZBuffer(pX_Helm, pY_Helm, (Texture *)v132, pHelmNum); + } + } + pMainHandNum3 = pPlayers[uPlayerID]->pEquipment.uMainHand;//weapon in right hand + if ( pMainHandNum3 ) + { + item_MainHand3 = &pPlayers[uPlayerID]->pInventoryItems[pMainHandNum3 - 1]; + pX_MainHand3 = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][1][0] - pItemsTable->pItems[item_MainHand3->uItemID].uEquipX; + pY_MainHand3 = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][1][1] - pItemsTable->pItems[item_MainHand3->uItemID].uEquipY; + if ( item_MainHand3->uItemID == 64 ) + v181 = "item64v1"; + else + v181 = pItemsTable->pItems[item_MainHand3->uItemID].pIconName; + v138 = pIcons_LOD->LoadTexture(v181, TEXTURE_16BIT_PALETTE); + if ( !(item_MainHand3->uAttributes & 0xF0) ) + { + v142 = v138 + 1; + v143 = (char *)pIcons_LOD->GetTexture(v138); + if ( item_MainHand3->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(pX_MainHand3, pY_MainHand3, (Texture *)v143); + else + { + if ( item_MainHand3->uAttributes & 1 ) + pRenderer->DrawTextureTransparent(pX_MainHand3, pY_MainHand3, (Texture *)v143); + else + pRenderer->DrawTransparentGreenShade(pX_MainHand3, pY_MainHand3, (Texture *)v143); + } + } + else + { + if ( (item_MainHand3->uAttributes & 0xF0) == 16 ) + v182 = "sptext01"; + if ( (item_MainHand3->uAttributes & 0xF0) == 32 ) + v182 = "sp28a"; + if ( (item_MainHand3->uAttributes & 0xF0) == 64 ) + v182 = "sp30a"; + if ( (item_MainHand3->uAttributes & 0xF0) == 128 ) + v182 = "sp91a"; + v140 = pIcons_LOD->LoadTexturePtr(v182, TEXTURE_16BIT_PALETTE); + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + item_MainHand3->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4 = 0; + } + v141 = (double)GetTickCount() * 0.1; + pRenderer->_4A63E6(pX_MainHand3, pY_MainHand3, pIcons_LOD->GetTexture(v138), v140, (signed __int64)v141, 0, 255); + } + if ( !bRingsShownInCharScreen ) + pRenderer->DrawMaskToZBuffer(pX_MainHand3, pY_MainHand3, (Texture *)v143, pMainHandNum3); + } + pShieldNum = pPlayers[uPlayerID]->pEquipment.uShield;// äàëåå ùèò + if ( pShieldNum ) + { + item_Shield = &pPlayers[uPlayerID]->pInventoryItems[pShieldNum - 1]; + v149 = pItemsTable->pItems[item_Shield->uItemID].uSkillType; + if ( v149 == 2 || v149 == 1 ) + { + v151 = item_Shield->uItemID - 400; + pX_Shield = 596; + v245 = 1; + switch ( item_Shield->uItemID ) + { + case 400: + pY_Shield = 86; + break; + case 403: + pY_Shield = 28; + break; + case 415: + pX_Shield = 595; + pY_Shield = 33; + break; + default: + pX_Shield = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][0][0] - pItemsTable->pItems[item_Shield->uItemID].uEquipX; + pY_Shield = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][0][1] - pItemsTable->pItems[item_Shield->uItemID].uEquipY; + break; + } + } + else + { + v245 = 0; + pX_Shield = pPaperdoll_BodyX + paperdoll_Weapon[pBodyComplection][0][0] - pItemsTable->pItems[item_Shield->uItemID].uEquipX; + pY_Shield = pPaperdoll_BodyY + paperdoll_Weapon[pBodyComplection][0][1] - pItemsTable->pItems[item_Shield->uItemID].uEquipY; + } + v153 = pIcons_LOD->LoadTexture(pItemsTable->pItems[item_Shield->uItemID].pIconName, TEXTURE_16BIT_PALETTE); + if ( !(item_Shield->uAttributes & 0xF0) ) + { + if ( item_Shield->uAttributes & 2 ) + pRenderer->DrawTransparentRedShade(pX_Shield, pY_Shield, pIcons_LOD->GetTexture(v153)); + else + { + v160 = (char *)pIcons_LOD->GetTexture(v153); + if ( !(item_Shield->uAttributes & 1) ) + pRenderer->DrawTransparentGreenShade(pX_Shield, pY_Shield, (Texture *)v160); + else + pRenderer->DrawTextureTransparent(pX_Shield, pY_Shield, (Texture *)v160); + } + } + else + { + if ( (item_Shield->uAttributes & 0xF0) == 16 ) + v183 = "sptext01"; + if ( (item_Shield->uAttributes & 0xF0) == 32 ) + v183 = "sp28a"; + if ( (item_Shield->uAttributes & 0xF0) == 64 ) + v183 = "sp30a"; + if ( (item_Shield->uAttributes & 0xF0) == 128 ) + v183 = "sp91a"; + v157 = pIcons_LOD->LoadTexturePtr(v183, TEXTURE_16BIT_PALETTE); + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if ( _50C9A8_item_enchantment_timer <= 0 ) + { + _50C9A8_item_enchantment_timer = 0; + item_Shield->uAttributes &= 0xFFFFFF0Fu; + ptr_50C9A4 = 0; + } + v158 = (double)GetTickCount() * 0.1; + pRenderer->_4A63E6(pX_Shield, pY_Shield, pIcons_LOD->GetTexture(v153), v157, (signed __int64)v158, 0, 255); + if ( v245 ) + pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdollLeftEmptyHand[pBodyComplection][0], + pPaperdoll_BodyY + pPaperdollLeftEmptyHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlhs[uPlayerID - 1])); + } + if ( !bRingsShownInCharScreen ) + pRenderer->DrawMaskToZBuffer(pX_Shield, pY_Shield, pIcons_LOD->GetTexture(v153), pShieldNum); + } + } + pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_RightHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_RightHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_drhs[uPlayerID - 1])); + pMainHandNum5 = pPlayers[uPlayerID]->pEquipment.uMainHand; + if ( pMainHandNum5 ) + { + item_MainHand5 = &pPlayers[uPlayerID]->pInventoryItems[pMainHandNum5 - 1]; + if ( pItemsTable->pItems[item_MainHand5->uItemID].uEquipType == 1 || + pItemsTable->pItems[item_MainHand5->uItemID].uSkillType == PLAYER_SKILL_SPEAR && + !pPlayers[uPlayerID]->pEquipment.uShield ) + pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], + pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], + pIcons_LOD->GetTexture(papredoll_dlhus[uPlayerID - 1])); + } + if ( !bRingsShownInCharScreen )//ðèñîâàíèå ëóïû + pRenderer->DrawTextureTransparent(603, 299, pIcons_LOD->GetTexture(uTextureID_MAGNIF_B)); + pRenderer->DrawTextureTransparent(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel_loop));//îáðàìëåíèå +} + + + + + + + +//----- (0041A2D1) -------------------------------------------------------- +void CharacterUI_InventoryTab_Draw(Player *player, bool a2) +{ + Texture *v7; // esi@6 + signed int v11; // edx@6 + int v13; // eax@13 + signed int v14; // edx@13 + int v15; // eax@13 + unsigned int v17; // edi@15 + Texture *pTexture; // ebx@24 + unsigned int uCellX; // [sp+30h] [bp-8h]@5 + unsigned int uCellY; // [sp+34h] [bp-4h]@5 + + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_CharacterUI_InventoryBackground)); + if (a2) + pRenderer->DrawTextureIndexed(8, 305, pIcons_LOD->LoadTexturePtr("fr_strip", TEXTURE_16BIT_PALETTE)); + + int i = 0; + for (uint i = 0; i < 126; ++i) + { + int v26 = (int)(player->pInventoryIndices + i); + + if (player->pInventoryIndices[i] <= 0) + continue; + + int item_idx = player->pInventoryIndices[i]; + auto item = &player->pInventoryItems[item_idx - 1]; + if (!item->uItemID) + continue; + + uCellY = 32 * (i / 14) + 17; + uCellX = 32 * (i % 14) + 14; + uint item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item->uItemID].pIconName, TEXTURE_16BIT_PALETTE); + v7 = pIcons_LOD->GetTexture(item_texture_id); + + v11 = v7->uTextureWidth; + if (v11 < 14) + v11 = 14; + + if ( (v11 - 14) / 32 == 0 && v7->uTextureWidth < 32) + uCellX += (32 - v7->uTextureWidth) / 2; + v13 = v11 - 14; + LOBYTE(v13) = v13 & 0xE0; + v15 = v13 + 32; + v14 = v7->uTextureHeight; + if (v14 < 14 ) + v14 = 14; + v17 = uCellX + ((v15 - v7->uTextureWidth) >> 1) + pSRZBufferLineOffsets[uCellY + (( (int)((v14 - 14) & 0xFFFFFFE0) - v7->uTextureHeight + 32) >> 1)]; //added typecast. without it the value in the brackets got cat to unsigned which messed stuff up + + if (item->uAttributes & 0xF0) + { + switch (item->uAttributes & 0xF0) + { + case ITEM_AURA_EFFECT_RED: pTexture = pIcons_LOD->LoadTexturePtr("sptext01", TEXTURE_16BIT_PALETTE); break; + case ITEM_AURA_EFFECT_BLUE: pTexture = pIcons_LOD->LoadTexturePtr("sp28a", TEXTURE_16BIT_PALETTE); break; + case ITEM_AURA_EFFECT_GREEN: pTexture = pIcons_LOD->LoadTexturePtr("sp30a", TEXTURE_16BIT_PALETTE); break; + case ITEM_AURA_EFFECT_PURPLE: pTexture = pIcons_LOD->LoadTexturePtr("sp91a", TEXTURE_16BIT_PALETTE); break; + } + + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if (_50C9A8_item_enchantment_timer <= 0) + { + _50C9A8_item_enchantment_timer = 0; + LOBYTE(item->uAttributes) &= 0xF; + ptr_50C9A4 = 0; + } + + pRenderer->_4A63E6(uCellX, uCellY, v7, pTexture, GetTickCount() * 0.1, 0, 255); + ZBuffer_Fill(&pRenderer->pActiveZBuffer[v17], item_texture_id, item_idx); + } + else + { + if (item->Identified() || pCurrentScreen != SCREEN_HOUSE) + { + if (item->Broken()) + pRenderer->DrawTransparentRedShade(uCellX, uCellY, v7); + else + pRenderer->DrawTextureTransparent(uCellX, uCellY, v7); + } + else + pRenderer->DrawTransparentGreenShade(uCellX, uCellY, v7); + + ZBuffer_Fill(&pRenderer->pActiveZBuffer[v17], item_texture_id, item_idx); + continue; + } + } +} + + + +static void CharacterUI_DrawItem(int x, int y, ItemGen *item, int id) +{ + auto item_texture = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[item->uItemID].pIconName, TEXTURE_16BIT_PALETTE); + + if (item->uAttributes & 0xF0) // enchant animation + { + Texture *enchantment_texture = nullptr; + switch (item->uAttributes & 0xF0) + { + case ITEM_AURA_EFFECT_RED: enchantment_texture = pIcons_LOD->LoadTexturePtr("sptext01", TEXTURE_16BIT_PALETTE); break; + case ITEM_AURA_EFFECT_BLUE: enchantment_texture = pIcons_LOD->LoadTexturePtr("sp28a", TEXTURE_16BIT_PALETTE); break; + case ITEM_AURA_EFFECT_GREEN: enchantment_texture = pIcons_LOD->LoadTexturePtr("sp30a", TEXTURE_16BIT_PALETTE); break; + case ITEM_AURA_EFFECT_PURPLE: enchantment_texture = pIcons_LOD->LoadTexturePtr("sp91a", TEXTURE_16BIT_PALETTE); break; + } + + _50C9A8_item_enchantment_timer -= pEventTimer->uTimeElapsed; + if (_50C9A8_item_enchantment_timer <= 0) + { + _50C9A8_item_enchantment_timer = 0; + item->uAttributes &= 0xFFFFFF0F; + ptr_50C9A4 = 0; + } + pRenderer->_4A63E6(x, y, item_texture, enchantment_texture, GetTickCount() * 0.1, 0, 255); + } + else + { + if (item->Broken()) + pRenderer->DrawTransparentRedShade(x, y, item_texture); + else if (!item->Identified()) + pRenderer->DrawTransparentGreenShade(x, y, item_texture); + else + pRenderer->DrawTextureTransparent(x, y, item_texture); + + pRenderer->ZBuffer_Fill_2(x, y, item_texture, id); + } +} + + +//----- (0043E825) -------------------------------------------------------- +void CharacterUI_DrawPaperdollWithRingOverlay(Player *player) +{ + CharacterUI_DrawPaperdoll(player); + + pRenderer->DrawTextureTransparent(0x1D9u, 0, pIcons_LOD->GetTexture(uTextureID_BACKHAND)); + pRenderer->DrawTextureTransparent(0x1D4u, 0, pIcons_LOD->GetTexture(uTextureID_right_panel_loop)); + pRenderer->DrawTextureIndexed(pCharacterScreen_DetalizBtn->uX, + pCharacterScreen_DetalizBtn->uY, + pIcons_LOD->GetTexture(uTextureID_detaliz_close_button)); + + for (uint i = 0; i < 6; ++i) + { + if (!player->pEquipment.uRings[i]) + continue; + + static int pPaperdollRingsX[6] = {0x1EA, 0x21A, 0x248, 0x1EA, 0x21A, 0x248}; + static int pPaperdollRingsY[6] = {0x0CA, 0x0CA, 0x0CA, 0x0FA, 0x0FA, 0x0FA}; + + CharacterUI_DrawItem(pPaperdollRingsX[i], + pPaperdollRingsY[i], + &player->pInventoryItems[player->pEquipment.uRings[i] - 1], + player->pEquipment.uRings[i]); + } + + + if (player->pEquipment.uAmulet) + { + CharacterUI_DrawItem(493, 91, + &player->pInventoryItems[player->pEquipment.uAmulet - 1], + player->pEquipment.uAmulet); + } + + if (player->pEquipment.uGlove) + { + CharacterUI_DrawItem(586, 88, + &player->pInventoryItems[player->pEquipment.uGlove - 1], + player->pEquipment.uGlove); + } +} + +//----- (0043BCA7) -------------------------------------------------------- +void CharacterUI_LoadPaperdollTextures() +{ + int v0; // edi@7 + enum CHARACTER_RACE pRace; // ebx@7 + signed int pSex; // eax@7 + int v3; // ebx@10 + Player *pPlayer; // edi@12 + unsigned __int8 v5; // cl@12 + int v6; // edi@16 + unsigned int v7; // eax@16 + Player *pPlayer2; // ebx@16 + char *v9; // ebx@16 + char v10; // al@16 + signed int v11; // edi@21 + unsigned int v22; // eax@76 + int v23; // ecx@76 + unsigned int v24; // eax@78 + int v25; // ecx@78 + int v26; // ebx@79 + unsigned int v27; // eax@80 + int v28; // ecx@80 + int v30; // [sp+10h] [bp-28h]@5 + signed int v32; // [sp+10h] [bp-28h]@75 + signed int v33; // [sp+10h] [bp-28h]@77 + int v34; // [sp+10h] [bp-28h]@79 + int pItemTXTNum; // [sp+14h] [bp-24h]@75 + int v37; // [sp+14h] [bp-24h]@77 + signed int v38; // [sp+14h] [bp-24h]@79 + int v42; // [sp+20h] [bp-18h]@6 + int v43; // [sp+20h] [bp-18h]@73 + char pContainer[128]; // [sp+24h] [bp-14h]@12 + + uTextureID_MAGNIF_B = pIcons_LOD->LoadTexture("MAGNIF-B", TEXTURE_16BIT_PALETTE); + //if ( !pParty->uAlignment || pParty->uAlignment == 1 || pParty->uAlignment == 2 ) + uTextureID_BACKDOLL = pIcons_LOD->LoadTexture("BACKDOLL", TEXTURE_16BIT_PALETTE); + uTextureID_right_panel_loop = uTextureID_right_panel; + v30 = 0; + uTextureID_BACKHAND = pIcons_LOD->LoadTexture("BACKHAND", TEXTURE_16BIT_PALETTE); + uTextureID_detaliz_close_button = uExitCancelTextureId; + do + { + v42 = v30 + 1; + if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(v30 + 1) ) + { + v0 = v30; + pRace = pPlayers[v30 + 1]->GetRace(); + pSex = pPlayers[v30 + 1]->GetSexByVoice(); + if ( pRace && pRace != 1 && pRace != 2 )//race == 3 + v3 = (pSex != 0) + 3; + else + v3 = (pSex != 0) + 1; + wsprintfA(pContainer, "pc23v%dBod", v3); + papredoll_dbods[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);//Body texture + wsprintfA(pContainer, "pc23v%dlad", v3); + papredoll_dlads[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);// Left Hand + wsprintfA(pContainer, "pc23v%dlau", v3); + papredoll_dlaus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);// Left Hand2 + wsprintfA(pContainer, "pc23v%drh", v3); + papredoll_drhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);// Right Hand + wsprintfA(pContainer, "pc23v%dlh", v3); + papredoll_dlhs[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);// Left Fist + wsprintfA(pContainer, "pc23v%dlhu", v3); + papredoll_dlhus[v0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); // Left Fist 2 + pPlayer = pPlayers[v0 + 1]; + v5 = pPlayer->uCurrentFace; + if ( v5 == 12 || v5 == 13 ) + papredoll_dbrds[(char)v5] = 0; + papredoll_flying_feet[pPlayer->uCurrentFace] = 0; + IsPlayerWearingWatersuit[v30 + 1] = 1; + } + else + { + papredoll_dbods[v30] = pIcons_LOD->LoadTexture(dbod_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE); + papredoll_dlads[v30] = pIcons_LOD->LoadTexture(dlad_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE); + papredoll_dlaus[v30] = pIcons_LOD->LoadTexture(dlau_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE); + papredoll_drhs[v30] = pIcons_LOD->LoadTexture(drh_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE); + papredoll_dlhs[v30] = pIcons_LOD->LoadTexture(dlh_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE); + papredoll_dlhus[v30] = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[pPlayers[v30 + 1]->uCurrentFace], TEXTURE_16BIT_PALETTE); + v10 = pPlayers[v30 + 1]->uCurrentFace; + if ( v10 == 12 || v10 == 13 ) + { + wsprintfA(pContainer, "pc%02dbrd", v10 + 1); + papredoll_dbrds[v10] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + } + wsprintfA(pContainer, "item281pc%02d", v10 + 1); + papredoll_flying_feet[pPlayers[v30 + 1]->uCurrentFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + IsPlayerWearingWatersuit[v30 + 1] = 0; + } + ++v30; + } + while ( v42 < 4 ); + uTextureID_ar_up_up = pIcons_LOD->LoadTexture("ar_up_up", TEXTURE_16BIT_PALETTE); + uTextureID_ar_up_dn = pIcons_LOD->LoadTexture("ar_up_dn", TEXTURE_16BIT_PALETTE); + uTextureID_ar_dn_up = pIcons_LOD->LoadTexture("ar_dn_up", TEXTURE_16BIT_PALETTE); + uTextureID_ar_dn_dn = pIcons_LOD->LoadTexture("ar_dn_dn", TEXTURE_16BIT_PALETTE); + papredoll_dbrds[9] = pIcons_LOD->LoadTexture("ib-cd1-d", TEXTURE_16BIT_PALETTE); + papredoll_dbrds[7] = pIcons_LOD->LoadTexture("ib-cd2-d", TEXTURE_16BIT_PALETTE); + papredoll_dbrds[5] = pIcons_LOD->LoadTexture("ib-cd3-d", TEXTURE_16BIT_PALETTE); + papredoll_dbrds[3] = pIcons_LOD->LoadTexture("ib-cd4-d", TEXTURE_16BIT_PALETTE); + papredoll_dbrds[1] = pIcons_LOD->LoadTexture("ib-cd5-d", TEXTURE_16BIT_PALETTE); + for ( v11 = 0; v11 < 54; ++v11 )// test equipment + { + party_has_equipment[v11] = 0; + if ( pParty->pPickedItem.uItemID != v11 + 66 ) + { + for ( uint i = 0; i < 4; ++i) + { + if ( Player_has_item(v11 + 66, &pParty->pPlayers[i], 0) ) + party_has_equipment[v11] = 1; + } + } + } + memset(byte_5111F6.data(), 0, 16); + for (uint i = 0; i < 4; ++i) + { + auto player = pParty->pPlayers + i; + + if (Player_has_item(ITEM_ARTICACT_GOVERNONS_ARMOR, player, 1)) byte_5111F6[0] = 1; + if (Player_has_item(ITEM_ARTIFACT_YORUBA, player, 1)) byte_5111F6[1] = 1; + if (Player_has_item(ITEM_RELIC_HARECS_LEATHER, player, 1)) byte_5111F6[2] = 1; + if (Player_has_item(ITEM_ARTIFACT_LEAGUE_BOOTS, player, 1)) byte_5111F6[3] = 1; + if (Player_has_item(ITEM_RELIC_TALEDONS_HELM, player, 1)) byte_5111F6[4] = 1; + if (Player_has_item(ITEM_RELIC_SCHOLARS_CAP, player, 1)) byte_5111F6[5] = 1; + if (Player_has_item(ITEM_RELIC_PHYNAXIAN_CROWN, player, 1)) byte_5111F6[6] = 1; + if (Player_has_item(ITEM_ARTIFACT_MINDS_EYE, player, 1)) byte_5111F6[7] = 1; + if (Player_has_item(ITEM_RARE_SHADOWS_MASK, player, 1)) byte_5111F6[8] = 1; + if (Player_has_item(ITEM_RILIC_TITANS_BELT, player, 1)) byte_5111F6[9] = 1; + if (Player_has_item(ITEM_ARTIFACT_HEROS_BELT, player, 1)) byte_5111F6[10] = 1; + if (Player_has_item(ITEM_RELIC_TWILIGHT, player, 1)) byte_5111F6[11] = 1; + if (Player_has_item(ITEM_ARTIFACT_CLOAK_OF_THE_SHEEP, player, 1)) byte_5111F6[12] = 1; + if (Player_has_item(ITEM_RARE_SUN_CLOAK, player, 1)) byte_5111F6[13] = 1; + if (Player_has_item(ITEM_RARE_MOON_CLOAK, player, 1)) byte_5111F6[14] = 1; + if (Player_has_item(ITEM_RARE_VAMPIRES_CAPE, player, 1)) byte_5111F6[15] = 1; + if (Player_has_item(ITEM_ELVEN_CHAINMAIL, player, 1)) byte_5111F6[16] = 1; + } + + + for (uint i = 0; i < 2; ++i) + { + for ( uint j = 0; j < 5; ++j )//Belt + { + GetItemTextureFilename(pContainer, j + 100, i + 1, 0); + paperdoll_belt_texture[i][j] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + } + GetItemTextureFilename(pContainer, 535, i + 1, 0); + paperdoll_belt_texture[i][6] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + for ( uint j = 0; j < 11; ++j )//Helm + { + GetItemTextureFilename(pContainer, j + 89, i + 1, 0); + paperdoll_helm_texture[i][j] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + } + GetItemTextureFilename(pContainer, 521, i + 1, 0); + paperdoll_helm_texture[i][11] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 522, i + 1, 0); + paperdoll_helm_texture[i][12] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 523, i + 1, 0); + paperdoll_helm_texture[i][13] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 532, i + 1, 0); + paperdoll_helm_texture[i][14] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 544, i + 1, 0); + paperdoll_helm_texture[i][15] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + if ( _43ED6F_check_party_races(true) ) + papredoll_dbrds[11] = pIcons_LOD->LoadTexture("item092v3", TEXTURE_16BIT_PALETTE); + } + v43 = 0; + for (uint i = 0; i < 4; ++i) + { + if ( sub_43EDB9_get_some_race_sex_relation_2(i) ) + { + GetItemTextureFilename(pContainer, 524, i + 1, 0); + paperdoll_belt_texture[i][5] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);//Titans belt + pItemTXTNum = 66; + for ( v32 = 0; v32 < 13; ++v32 )//simple armor + { + GetItemTextureFilename(pContainer, pItemTXTNum, i + 1, 0); + paperdoll_armor_texture[i][v32][0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, pItemTXTNum, i + 1, 1); + paperdoll_armor_texture[i][v32][1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, pItemTXTNum, i + 1, 2); + paperdoll_armor_texture[i][v32][2] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + pItemTXTNum++; + } + GetItemTextureFilename(pContainer, 516, i + 1, 0);//artefacts + paperdoll_armor_texture[i][v32][0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 516, i + 1, 1); + paperdoll_armor_texture[i][v32][1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 516, i + 1, 2); + paperdoll_armor_texture[i][v32][2] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 505, i + 1, 0); + paperdoll_armor_texture[i][v32 + 1][0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 505, i + 1, 1); + paperdoll_armor_texture[i][v32 + 1][1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 505, i + 1, 2); + paperdoll_armor_texture[i][v32 + 1][2] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 504, i + 1, 0); + paperdoll_armor_texture[i][v32 + 2][0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 504, i + 1, 1); + paperdoll_armor_texture[i][v32 + 2][1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 504, i + 1, 2); + paperdoll_armor_texture[i][v32 + 2][2] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 533, i + 1, 0); + paperdoll_armor_texture[i][v32 + 3][0] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 533, i + 1, 1); + paperdoll_armor_texture[i][v32 + 3][1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 533, i + 1, 2); + paperdoll_armor_texture[i][v32 + 3][2] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + for ( v33 = 0; v33 < 5; ++v33 )//boots + { + GetItemTextureFilename(pContainer, v33 + 115, i + 1, 0); + paperdoll_boots_texture[i][v33] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + } + GetItemTextureFilename(pContainer, 512, i + 1, 0); + paperdoll_boots_texture[i][v33] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + for ( v38 = 0; v38 < 5; ++v38 )//Cloak + { + GetItemTextureFilename(pContainer, v38 + 105, i + 1, 0); + paperdoll_cloak_texture[i][v38] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, v38 + 105, i + 1, 1); + paperdoll_cloak_collar_texture[i][v38] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + } + GetItemTextureFilename(pContainer, 525, i + 1, 0); + paperdoll_cloak_texture[i][5] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 530, i + 1, 0); + paperdoll_cloak_texture[i][6] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 547, i + 1, 0); + paperdoll_cloak_texture[i][7] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 548, i + 1, 0); + paperdoll_cloak_texture[i][8] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 550, i + 1, 0); + paperdoll_cloak_texture[i][9] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 525, i + 1, 1); + paperdoll_cloak_collar_texture[i][5] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 530, i + 1, 1); + paperdoll_cloak_collar_texture[i][6] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 547, i + 1, 1); + paperdoll_cloak_collar_texture[i][7] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 548, i + 1, 1); + paperdoll_cloak_collar_texture[i][8] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + GetItemTextureFilename(pContainer, 550, i + 1, 1); + paperdoll_cloak_collar_texture[i][9] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + } + else + { + v26 = v43; + } + v43 = v26 + 40; + } +} + +//----- (00419401) -------------------------------------------------------- +void CharacterUI_SkillsTab_CreateButtons() + { + // unsigned int v0; // ecx@3 + GUIButton *pButton; // eax@3 + unsigned int current_Y; // esi@8 + int buttons_count; // [sp+10h] [bp-14h]@1 + int first_rows; // [sp+14h] [bp-10h]@19 + int skill_id; // [sp+18h] [bp-Ch]@8 + Player *curr_player; // [sp+1Ch] [bp-8h]@8 + int i; + int uCurrFontHeght; + + buttons_count = 0; + if ( dword_507CC0_activ_ch ) + CharacterUI_ReleaseButtons(); + dword_507CC0_activ_ch = uActiveCharacter; + for ( pButton = pGUIWindow_CurrentMenu->pControlsHead; pButton; pButton = pButton->pNext ) + { + if ( pButton->msg == UIMSG_InventoryLeftClick ) + { + dword_50698C_uX = pButton->uX; + dword_506988_uY = pButton->uY; + dword_506984_uZ = pButton->uZ; + dword_506980_uW = pButton->uW; + pButton->uW = 0; + pButton->uZ = 0; + pButton->uY = 0; + pButton->uX = 0; + } + } + first_rows = 0; + // a5 = pGUIWindow_CurrentMenu->uNumControls; + curr_player = &pParty->pPlayers[uActiveCharacter-1]; + + uCurrFontHeght=pFontLucida->uFontHeight; + current_Y = 2 *uCurrFontHeght + 13; + for(i=0; i<9;++i) + { + skill_id = pWeaponSkills[i]; + if ( curr_player->pActiveSkills[skill_id] & 0x3F ) + { + current_Y += uCurrFontHeght - 3; + ++buttons_count; + ++first_rows; + pGUIWindow_CurrentMenu->CreateButton(24, current_Y, 204, uCurrFontHeght - 3, 3, skill_id | 0x8000, UIMSG_SkillUp, skill_id, 0, "", 0, 0); + } + } + if ( !first_rows ) + current_Y += uCurrFontHeght - 3; + current_Y += 2 * uCurrFontHeght - 6; + for(i=0; i<9;++i) + { + skill_id = pMagicSkills[i]; + if ( curr_player->pActiveSkills[skill_id] & 0x3F && buttons_count < 15 ) + { + current_Y += uCurrFontHeght - 3; + ++buttons_count; + pGUIWindow_CurrentMenu->CreateButton(24, current_Y, 204, uCurrFontHeght - 3, 3, skill_id | 0x8000, UIMSG_SkillUp, skill_id, 0, "", 0, 0); + } + } + first_rows = 0; + current_Y = 2 * uCurrFontHeght + 13; + for(i=0; i<5;++i) + { + skill_id = pArmorSkills[i]; + if ( curr_player->pActiveSkills[skill_id] & 0x3F ) + { + current_Y+= uCurrFontHeght - 3; + ++buttons_count; + ++first_rows; + pGUIWindow_CurrentMenu->CreateButton(246, current_Y, 204, uCurrFontHeght - 3, 3, skill_id | 0x8000, UIMSG_SkillUp, skill_id, 0, "", 0, 0); + } + } + if ( !first_rows ) + current_Y += uCurrFontHeght - 3; + current_Y += 2 * uCurrFontHeght - 6; + for(i=0; i<12; ++i) + { + skill_id = pMiscSkills[i]; + if ( curr_player->pActiveSkills[skill_id] & 0x3F ) + { + current_Y += uCurrFontHeght - 3; + ++buttons_count; + pGUIWindow_CurrentMenu->CreateButton(246, current_Y, 204, uCurrFontHeght - 3, 3, skill_id | 0x8000, UIMSG_SkillUp, skill_id, 0, "", 0, 0); + } + } + + if ( buttons_count ) + pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(buttons_count, 1, 0, pGUIWindow_CurrentMenu->uNumControls); + } + + + +//----- (00418511) -------------------------------------------------------- + void CharacterUI_StatsTab_Draw( Player *player ) + { + //Player *pPlayer; // edi@1 + //unsigned int v4; // eax@2 + int v7; // ebp@4 + int v8; // eax@4 + unsigned int v9; // eax@4 + int v10; // ST34_4@4 + int v13; // ebp@4 + int v14; // eax@4 + unsigned int v15; // eax@4 + int v19; // ebp@4 + int v20; // eax@4 + unsigned int v21; // eax@4 + int v25; // ebp@4 + int v26; // eax@4 + unsigned int v27; // eax@4 + int v31; // ebp@4 + int v32; // eax@4 + unsigned int v33; // eax@4 + int v37; // ebp@4 + int v38; // eax@4 + unsigned int v39; // eax@4 + int v43; // ebp@4 + int v44; // eax@4 + unsigned int v45; // eax@4 + signed int v49; // eax@6 + unsigned int v50; // eax@6 + int v53; // eax@8 + unsigned int v54; // eax@8 + int v58; // ebp@8 + int v59; // eax@8 + unsigned int v60; // eax@8 + unsigned int v62; // eax@8 + signed int v64; // eax@8 + //unsigned __int8 v66; // al@8 + char *v67; // eax@9 + signed int v70; // ebp@11 + signed int v71; // eax@11 + unsigned int v72; // eax@11 + int v75; // ebp@13 + int v76; // eax@13 + unsigned int v77; // eax@13 + char *v78; // ecx@14 + unsigned int v81; // eax@16 + int v83; // eax@16 + char *v85; // eax@16 + int v87; // eax@16 + char *v89; // eax@16 + int v90; // eax@16 + unsigned int v92; // eax@19 + int v93; // eax@19 + unsigned int v95; // eax@22 + int v96; // eax@22 + unsigned int v98; // eax@25 + int v99; // eax@25 + unsigned int v101; // eax@27 + int v102; // eax@27 + unsigned int v104; // eax@30 + unsigned int v106; // eax@32 + int v107; // eax@33 + unsigned int v109; // eax@36 + unsigned int v111; // eax@38 + const char *a2; // [sp+14h] [bp-Ch]@4 + const char *a2a; // [sp+14h] [bp-Ch]@6 + const char *a2b; // [sp+14h] [bp-Ch]@11 + const char *a2c; // [sp+14h] [bp-Ch]@16 + const char *a2d; // [sp+14h] [bp-Ch]@19 + const char *a2e; // [sp+14h] [bp-Ch]@22 + const char *a2f; // [sp+14h] [bp-Ch]@25 + const char *a2g; // [sp+14h] [bp-Ch]@27 + const char *a2h; // [sp+14h] [bp-Ch]@33 + int v131; // [sp+18h] [bp-8h]@16 + int v132; // [sp+18h] [bp-8h]@19 + int v133; // [sp+18h] [bp-8h]@22 + int v134; // [sp+18h] [bp-8h]@25 + int v135; // [sp+18h] [bp-8h]@27 + int v136; // [sp+18h] [bp-8h]@33 + + //pPlayer = &pParty->pPlayers[uPlayerID-1]; + //pPlayer = player; + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->LoadTexturePtr("fr_stats", TEXTURE_16BIT_PALETTE)); + sprintf(pTmpBuf.data(), "\f%05d", ui_character_header_text_color); + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[429], player->pName, pClassNames[player->classType]);//"^Pi[%s] %s" / "%s the %s" + strcat(pTmpBuf.data(), pTmpBuf2.data()); + sprintfex(pTmpBuf2.data(), "\f00000\r180%s: \f%05d%d\f00000\n\n\n", + pGlobalTXT_LocalizationStrings[207], // "Skill points" + player->uSkillPoints ? ui_character_bonus_text_color : ui_character_default_text_color, + player->uSkillPoints); + strcat(pTmpBuf.data(), pTmpBuf2.data()); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 18, 0, pTmpBuf.data(), 0, 0, 0); + + v10 = 53; + v7 = player->GetBaseStrength(); + v8 = player->GetActualMight(); + v9 = UI_GetHealthManaStringColor(v8, v7); + sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[144], v9, v8, v7);//Might + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf.data(), 0, 0, 0); + + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v13 = player->GetBaseIntelligence(); + v14 = player->GetActualIntelligence(); + v15 = UI_GetHealthManaStringColor(v14, v13); + sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[116], v15, v14, v13);//Intellect + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf.data(), 0, 0, 0); + + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v19 = player->GetBaseWillpower(); + v20 = player->GetActualWillpower(); + v21 = UI_GetHealthManaStringColor(v20, v19); + sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[163], v21, v20, v19);// + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf.data(), 0, 0, 0); + + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v25 = player->GetBaseEndurance(); + v26 = player->GetActualEndurance(); + v27 = UI_GetHealthManaStringColor(v26, v25); + sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[75], v27, v26, v25);// + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf.data(), 0, 0, 0); + + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v31 = player->GetBaseAccuracy(); + v32 = player->GetActualAccuracy(); + v33 = UI_GetHealthManaStringColor(v32, v31); + sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[1], v33, v32, v31); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf.data(), 0, 0, 0); + + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v37 = player->GetBaseSpeed(); + v38 = player->GetActualSpeed(); + v39 = UI_GetHealthManaStringColor(v38, v37); + sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[211], v39, v38, v37); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf.data(), 0, 0, 0); + + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v43 = player->GetBaseLuck(); + v44 = player->GetActualLuck(); + v45 = UI_GetHealthManaStringColor(v44, v43); + sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n\n", pGlobalTXT_LocalizationStrings[136], v45, v44, v43); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf.data(), 0, 0, 0); + + a2 = "%s\f%05u\r424%d\f00000 /\t185%d\n"; + v10 += 2 * LOBYTE(pFontArrus->uFontHeight) + 5; + if ( player->GetMaxHealth() >= 1000 ) + a2 = "%s\f%05u\r388%d\f00000 / %d\n"; + v49 = player->GetMaxHealth(); + v50 = UI_GetHealthManaStringColor(player->sHealth, v49); + sprintf(pTmpBuf.data(), a2, pGlobalTXT_LocalizationStrings[108], v50, player->sHealth, v49); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf.data(), 0, 0, 0); + + a2a = "%s\f%05u\r424%d\f00000 /\t185%d\n"; + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + if ( player->GetMaxMana() >= 1000 ) + a2a = "%s\f%05u\r388%d\f00000 / %d\n"; + v53 = player->GetMaxMana(); + v54 = UI_GetHealthManaStringColor(player->sMana, v53); + sprintf(pTmpBuf.data(), a2a, pGlobalTXT_LocalizationStrings[212], v54, player->sMana, v53); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf.data(), 0, 0, 0); + + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v58 = player->GetBaseAC(); + v59 = player->GetActualAC(); + v60 = UI_GetHealthManaStringColor(v59, v58); + sprintf(pTmpBuf.data(), "%s\f%05u\r424%d\f00000 /\t185%d\n\n", pGlobalTXT_LocalizationStrings[12], v60, v59, v58); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf.data(), 0, 0, 0); + + v10 += 2 * LOBYTE(pFontArrus->uFontHeight) - 2; + v62 = player->GetMajorConditionIdx(); + v64 = GetConditionDrawColor(v62); + sprintf(pTmpBuf.data(), "%s: \f%05d%s\n", pGlobalTXT_LocalizationStrings[47], v64, aCharacterConditionNames[v62]); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v10, 0, pTmpBuf.data(), 226, 0); + + v10 += LOBYTE(pFontArrus->uFontHeight) + - 1; + if (player->uQuickSpell) + v67 = pSpellStats->pInfos[player->uQuickSpell].pShortName; + else + v67 = pGlobalTXT_LocalizationStrings[153]; + sprintf(pTmpBuf.data(), "%s: %s", pGlobalTXT_LocalizationStrings[172], v67); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v10, 0, pTmpBuf.data(), 226, 0); + + v10 = 50; + v70 = player->GetBaseAge(); + v71 = player->GetActualAge(); + v72 = UI_GetHealthManaStringColor(v71, v70); + sprintf(pTmpBuf.data(), "%s\f%05u\t100%d\f00000 / %d\n", pGlobalTXT_LocalizationStrings[5], v72, v71, v70); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf.data(), 0, 0, 0); + + a2b = "%s\f%05u\t100%d\f00000 / %d\n"; + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + if ( player->GetBaseLevel() > 99 ) + a2b = "%s\f%05u\t180%d\f00000 / %d\n"; + v75 = player->GetBaseLevel(); + v76 = player->GetActualLevel(); + v77 = UI_GetHealthManaStringColor(v76, v75); + sprintf(pTmpBuf.data(), a2b, pGlobalTXT_LocalizationStrings[131], v77, v76, v75); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf.data(), 0, 0, 0); + + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + if (player->uExperience <= 9999999) + v78 = pGlobalTXT_LocalizationStrings[83]; // "Experience" + else + v78 = pGlobalTXT_LocalizationStrings[17]; // "Exp." + v81 = player->GetExperienceDisplayColor(); + sprintf(pTmpBuf.data(), "%s\r180\f%05d%lu\f00000\n\n", v78, v81, LODWORD(player->uExperience)); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf.data(), 0, 0, 0); + + v10 += 2 * LOBYTE(pFontArrus->uFontHeight); + v83 = player->GetActualAttack(0); + sprintf(pTmpBuf.data(), "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[18], v83); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf.data(), 0, 0, 0); + + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v85 = player->GetMeleeDamageString(); + sprintf(pTmpBuf.data(), "%s\t100 %s\n", pGlobalTXT_LocalizationStrings[53], v85); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf.data(), 0, 0, 0); + + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v87 = player->GetRangedAttack(); + sprintf(pTmpBuf.data(), "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[203], v87); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf.data(), 0, 0, 0); + + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v89 = player->GetRangedDamageString(); + sprintf(pTmpBuf.data(), "%s\t100 %s\n\n", pGlobalTXT_LocalizationStrings[53], v89); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf.data(), 0, 0, 0); + + a2c = format_4E2E10; + v10 += 2 * LOBYTE(pFontArrus->uFontHeight) - 4; + v131 = player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE); + v90 = player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE); + if ( v131 > 99 || v90 > 99 ) + a2c = "%s\f%05u\t180%d\f00000 / %d\n"; + v92 = UI_GetHealthManaStringColor(v131, v90); + sprintf(pTmpBuf.data(), a2c, pGlobalTXT_LocalizationStrings[87], v92, v131, v90); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf.data(), 0, 0, 0); + + a2d = format_4E2E10; + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v132 = player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR); + v93 = player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_AIR); + if ( v132 > 99 || v93 > 99 ) + a2d = "%s\f%05u\t180%d\f00000 / %d\n"; + v95 = UI_GetHealthManaStringColor(v132, v93); + sprintf(pTmpBuf.data(), a2d, pGlobalTXT_LocalizationStrings[6], v95, v132, v93); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf.data(), 0, 0, 0); + + a2e = format_4E2E10; + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v133 = player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER); + v96 = player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_WATER); + if ( v133 > 99 || v96 > 99 ) + a2e = "%s\f%05u\t180%d\f00000 / %d\n"; + v98 = UI_GetHealthManaStringColor(v133, v96); + sprintf(pTmpBuf.data(), a2e, pGlobalTXT_LocalizationStrings[240], v98, v133, v96); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf.data(), 0, 0, 0); + + a2f = format_4E2E10; + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v134 = player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH); + v99 = player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH); + if ( v134 > 99 ) + a2f = "%s\f%05u\t180%d\f00000 / %d\n"; + v101 = UI_GetHealthManaStringColor(v134, v99); + sprintf(pTmpBuf.data(), a2f, pGlobalTXT_LocalizationStrings[70], v101, v134, v99); + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf.data(), 0, 0, 0); + + a2g = format_4E2E10; + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v135 = player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND); + v102 = player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_MIND); + if ( v135 > 99 || v102 > 99 ) + a2g = "%s\f%05u\t180%d\f00000 / %d\n"; + v104 = UI_GetHealthManaStringColor(v135, v102); + sprintf(pTmpBuf.data(), a2g, pGlobalTXT_LocalizationStrings[142], v104, v135, v102); + if ( player->classType == PLAYER_CLASS_LICH && v102 == 200 ) + { + v106 = UI_GetHealthManaStringColor(v135, 200); + sprintf(pTmpBuf.data(), format_4E2E00, pGlobalTXT_LocalizationStrings[142], v106, pGlobalTXT_LocalizationStrings[625]); + } + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf.data(), 0, 0, 0); + + a2h = format_4E2E10; + v10 += LOBYTE(pFontArrus->uFontHeight) - 2; + v136 = player->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY); + v107 = player->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_BODY); + if ( v136 > 99 || v107 > 99 ) + a2h = "%s\f%05u\t180%d\f00000 / %d\n"; + v109 = UI_GetHealthManaStringColor(v136, v107); + sprintf(pTmpBuf.data(), a2h, pGlobalTXT_LocalizationStrings[29], v109, v136, v107); + if ( player->classType == PLAYER_CLASS_LICH && v107 == 200 ) + { + v111 = UI_GetHealthManaStringColor(v136, 200); + sprintf(pTmpBuf.data(), format_4E2E00, pGlobalTXT_LocalizationStrings[29], v111, pGlobalTXT_LocalizationStrings[625]); + } + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf.data(), 0, 0, 0); +} + +bool awardSort (int i,int j) { + if (pAwards[i].uPriority == 0) //none + { + return false; + } + else if (pAwards[j].uPriority == 0) + { + return true; + } + else if(pAwards[i].uPriority == 1) //fines,arena stuff,etc + { + return false; + } + else if(pAwards[j].uPriority == 1) + { + return true; + } + else if(pAwards[i].uPriority == 5) //joined guilds + { + return false; + } + else if(pAwards[j].uPriority == 5) + { + return true; + } + else + { + return (pAwards[i].uPriority<pAwards[j].uPriority); + } +} + +//----- (00419100) -------------------------------------------------------- +void FillAwardsData() +{ + auto pPlayer = pPlayers[uActiveCharacter]; + + memset(achieved_awards.data(), 0, 4000); + num_achieved_awards = 0; + + memset(pTmpBuf2.data(), 0, 0x7D0u); + BtnDown_flag = 0; + BtnUp_flag = 0; + dword_50651C = 0; + dword_506528 = 0; + for (int i = 0; i < 105; ++i) + { + if ( _449B57_test_bit(pPlayer->_guilds_member_bits, i) && pAwards[i].pText ) + { + achieved_awards[num_achieved_awards++] = (AwardType)i; + } + } + num_achieved_awards_2 = num_achieved_awards; + num_achieved_awards = 0; + + //sort awards index + if (num_achieved_awards_2 > 0) + { + std::stable_sort(achieved_awards.begin(), achieved_awards.end(), awardSort); + } + } + + +//----- (0043EF2B) -------------------------------------------------------- +void WetsuitOn( unsigned int uPlayerID ) + { + CHARACTER_RACE player_race; // edi@2 + signed int player_sex; // eax@2 + int texture_num; // ecx@5 + char pContainer[20]; // [sp+4h] [bp-1Ch]@7 + + if ( uPlayerID> 0 ) + { + player_race = pPlayers[uPlayerID]->GetRace(); + player_sex = pPlayers[uPlayerID]->GetSexByVoice(); + if ( player_race == CHARACTER_RACE_DWARF ) + texture_num = (player_sex != 0) + 3; + else + texture_num = (player_sex != 0) + 1; + wsprintfA(pContainer, "pc23v%dBod", texture_num); + papredoll_dbods[uPlayerID - 1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + wsprintfA(pContainer, "pc23v%dlad", texture_num); + papredoll_dlads[uPlayerID - 1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + wsprintfA(pContainer, "pc23v%dlau", texture_num); + papredoll_dlaus[uPlayerID - 1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + wsprintfA(pContainer, "pc23v%drh", texture_num); + papredoll_drhs[uPlayerID - 1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + wsprintfA(pContainer, "pc23v%dlh", texture_num); + papredoll_dlhs[uPlayerID - 1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + wsprintfA(pContainer, "pc23v%dlhu", texture_num); + papredoll_dlhus[uPlayerID - 1] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + + if ( pPlayers[uPlayerID]->uCurrentFace == 12 || pPlayers[uPlayerID]->uCurrentFace == 13 ) + papredoll_dbrds[pPlayers[uPlayerID]->uCurrentFace] = 0; + + papredoll_flying_feet[pPlayers[uPlayerID]->uCurrentFace] = 0; + IsPlayerWearingWatersuit[uPlayerID] = 1; + } + } + +//----- (0043F0BD) -------------------------------------------------------- +void WetsuitOff( unsigned int uPlayerID ) + { + char pContainer[20]; // [sp+0h] [bp-18h]@4 + + if (uPlayerID > 0 ) + { + papredoll_dbods[uPlayerID - 1] = pIcons_LOD->LoadTexture(dbod_texnames_by_face[pPlayers[uPlayerID]->uCurrentFace], TEXTURE_16BIT_PALETTE); + papredoll_dlads[uPlayerID - 1] = pIcons_LOD->LoadTexture(dlad_texnames_by_face[pPlayers[uPlayerID]->uCurrentFace], TEXTURE_16BIT_PALETTE); + papredoll_dlaus[uPlayerID - 1] = pIcons_LOD->LoadTexture(dlau_texnames_by_face[pPlayers[uPlayerID]->uCurrentFace], TEXTURE_16BIT_PALETTE); + papredoll_drhs [uPlayerID - 1] = pIcons_LOD->LoadTexture(drh_texnames_by_face [pPlayers[uPlayerID]->uCurrentFace], TEXTURE_16BIT_PALETTE); + papredoll_dlhs [uPlayerID - 1] = pIcons_LOD->LoadTexture(dlh_texnames_by_face [pPlayers[uPlayerID]->uCurrentFace], TEXTURE_16BIT_PALETTE); + papredoll_dlhus[uPlayerID - 1] = pIcons_LOD->LoadTexture(dlhu_texnames_by_face[pPlayers[uPlayerID]->uCurrentFace], TEXTURE_16BIT_PALETTE); + + if ( pPlayers[uPlayerID]->uCurrentFace == 12 || pPlayers[uPlayerID]->uCurrentFace == 13 ) + { + wsprintfA(pContainer, "pc%02dbrd", pPlayers[uPlayerID]->uCurrentFace + 1); + papredoll_dbrds[pPlayers[uPlayerID]->uCurrentFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + } + wsprintfA(pContainer, "item281pc%02d", pPlayers[uPlayerID]->uCurrentFace + 1); + papredoll_flying_feet[pPlayers[uPlayerID]->uCurrentFace] = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + IsPlayerWearingWatersuit[uPlayerID] = 0; + } + } +//----- (00468F8A) -------------------------------------------------------- +void __cdecl OnPaperdollLeftClick() +{ + int v1; // ecx@1 + unsigned int v2; // edi@1 + unsigned int v3; // edx@4 + unsigned int pSkillType; // esi@5 + unsigned __int16 v5; // ax@7 + unsigned int v6; // edi@19 + int v7; // esi@27 + unsigned int v8; // eax@29 + int v9; // edx@32 + int v10; // esi@34 + int v11; // eax@34 + int v12; // esi@38 + int v13; // eax@38 + char v14; // zf@38 + int v15; // esi@42 + int v16; // eax@42 + int v17; // eax@44 + unsigned int v18; // ecx@55 + unsigned int v19; // eax@55 + int v20; // esi@60 + int v21; // eax@60 + unsigned int v22; // eax@61 + unsigned int v23; // eax@62 + int v24; // esi@65 + int v25; // eax@65 + unsigned int v26; // eax@69 + int v27; // esi@81 + int v28; // eax@81 + int v29; // esi@84 + int v30; // eax@84 + int v31; // eax@85 + unsigned int v32; // ecx@88 + unsigned int v33; // eax@88 + int v34; // esi@90 + unsigned int v35; // eax@91 + int v36; // esi@93 + int v37; // edi@93 + ItemGen *v38; // edi@93 + __int16 v39; // dx@99 + ItemGen _this; // [sp+Ch] [bp-40h]@1 + unsigned int v48; // [sp+30h] [bp-1Ch]@88 + unsigned int v49; // [sp+34h] [bp-18h]@57 + unsigned int v50; // [sp+38h] [bp-14h]@50 + int v51; // [sp+3Ch] [bp-10h]@1 + unsigned int v52; // [sp+40h] [bp-Ch]@5 + //int v53; // [sp+44h] [bp-8h]@1 + //unsigned int v54; // [sp+48h] [bp-4h]@1 + + v51 = 0; + _this.Reset(); + //v0 = pPlayers[uActiveCharacter]; + v1 = pPlayers[uActiveCharacter]->pEquipment.uMainHand; + v2 = pPlayers[uActiveCharacter]->pEquipment.uShield; + //v54 = pPlayers[uActiveCharacter]->pEquipment.uShield; + //v53 = v1; + if ( v1 && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1 - 1]].uEquipType == 1 ) + v51 = v1; + v3 = pParty->pPickedItem.uItemID; + if ( pParty->pPickedItem.uItemID ) + { + v52 = pItemsTable->pItems[pParty->pPickedItem.uItemID].uEquipType; + pSkillType = pItemsTable->pItems[pParty->pPickedItem.uItemID].uSkillType; + if ( pSkillType == 4 ) + { + if ( v2 ) + { + LOBYTE(v5) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_SPEAR); + if ( (signed int)SkillToMastery(v5) < 3 ) + { + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + v3 = pParty->pPickedItem.uItemID; + } + } + else + { + if ( (pSkillType == 8 || pSkillType == 1 || pSkillType == 2) + && v1 + && pItemsTable->pItems[*(int *)&pPlayers[uActiveCharacter]->pInventoryItems[v1-1]].uSkillType == 4 ) + { + LOBYTE(v5) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_SPEAR); + if ( (signed int)SkillToMastery(v5) < 3 ) + { + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + } + } + if ( !pPlayers[uActiveCharacter]->CanEquip_RaceAndAlignmentCheck(v3) ) + { + + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + if ( pParty->pPickedItem.uItemID == 604 ) + { + pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)3); + WetsuitOn(uActiveCharacter); + return; + } + v6 = v52; + switch ( v52 ) + { + case 2u: + case 3u: + case 5u: + case 6u: + case 7u: + case 8u: + case 9u: + case 0xBu: + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) + { + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) && (v6 != 3 || bUnderwater) ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + pPlayers[uActiveCharacter]->EquipBody((ITEM_EQUIP_TYPE)v6); + if ( pParty->pPickedItem.uItemID == 604 ) + WetsuitOff(uActiveCharacter); + return; + case 0xAu: + if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + v52 = 10; + v7 = (int)&pPlayers[uActiveCharacter]->pEquipment.uRings; + while ( 1 ) + { + if ( !*(int *)v7 ) + { + v8 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + if ( (v8 & 0x80000000u) == 0 ) + { + v9 = v52; + pParty->pPickedItem.uBodyAnchor = v52 + 1; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v8], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v8])); + *(&pPlayers[uActiveCharacter]->pEquipment.uShield + v9) = v8 + 1; + pMouse->RemoveHoldingItem(); + break; + } + } + ++v52; + v7 += 4; + if ( (signed int)v52 > 15 ) + break; + } + if ( v52 == 16 ) + { + v52 = pPlayers[uActiveCharacter]->pEquipment.uRings[6] - 1; + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v10 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v52); + *(char *)(v10 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v10 + 532)); + _this.uBodyAnchor = 16; + v11 = v52 + 1; + memcpy((void *)(v10 + 532), &_this, 0x24u); + pPlayers[uActiveCharacter]->pEquipment.uRings[6] = v11; + } + return; + case 4u: + if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) + { + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + if ( v2 ) + { + --v2; + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v12 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); + *(char *)(v12 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v12 + 532)); + _this.uBodyAnchor = 1; + v13 = v2 + 1; + v14 = v51 == 0; + memcpy((void *)(v12 + 532), &_this, 0x24u); + pPlayers[uActiveCharacter]->pEquipment.uShield = v13; + if ( v14 ) + return; + } + else + { + v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + if ( (v52 & 0x80000000u) != 0 ) + return; + if ( !v51 ) + { + pParty->pPickedItem.uBodyAnchor = 1; + v17 = v52 + 1; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); + pPlayers[uActiveCharacter]->pEquipment.uShield = v17; + pMouse->RemoveHoldingItem(); + return; + } + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v15 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v1 - 1)); + *(char *)(v15 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v15 + 532)); + _this.uBodyAnchor = 1; + v16 = v52 + 1; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); + pPlayers[uActiveCharacter]->pEquipment.uShield = v16; + } + pPlayers[uActiveCharacter]->pEquipment.uMainHand = 0; + return; + case 0u: + case 0xCu: + if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) + && pParty->pPickedItem.uItemID != 64 + && pParty->pPickedItem.uItemID != 65 ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) + { + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + v50 = 0; + if ( pSkillType == 2 && (unsigned __int16)(pPlayers[uActiveCharacter]->pActiveSkills[2] & 0xFFC0) + || pSkillType == 1 && (signed int)SkillToMastery(pPlayers[uActiveCharacter]->pActiveSkills[1]) >= 3 ) + { + + v18 = pMouse->uMouseClickX; + v19 = pMouse->uMouseClickY; + + v49 = v19; + if ( (signed int)v18 >= 560 ) + { + if ( !v51 ) + { + if ( v2 ) + { + --v2; + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v20 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v2); + *(char *)(v20 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v20 + 532)); + _this.uBodyAnchor = 1; + v21 = v2 + 1; + v14 = v52 == 12; + memcpy((void *)(v20 + 532), &_this, 0x24u); + pPlayers[uActiveCharacter]->pEquipment.uShield = v21; + if ( !v14 ) + return; + v22 = _this.uItemID; + v50 = v22; + if ( v50 ) + { + __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 + stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); + } + break; + } + v23 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + if ( (v23 & 0x80000000u) != 0 ) + return; + pParty->pPickedItem.uBodyAnchor = 1; + v50 = (unsigned int)&pPlayers[uActiveCharacter]->pInventoryItems[v23]; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v23], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v23])); + pPlayers[uActiveCharacter]->pEquipment.uShield = v23 + 1; + pMouse->RemoveHoldingItem(); + if ( v52 != 12 ) + return; + v22 = *(int *)v50; + v50 = v22; + if ( v50 ) + { + __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 + stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); + } + break; + } + } + } + if ( !v1 ) + { + v26 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + if ( (v26 & 0x80000000u) != 0 ) + return; + pParty->pPickedItem.uBodyAnchor = 2; + v50 = (unsigned int)&pPlayers[uActiveCharacter]->pInventoryItems[v26]; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v26], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v26])); + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v26 + 1; + pMouse->RemoveHoldingItem(); + if ( v52 != 12 ) + return; + v22 = *(int *)v50; + v50 = v22; + if ( v50 ) + { + __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 + stru_A750F8[uActiveCharacter - 1]._494836(*((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); + } + break; + } + --v1; + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v24 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); + *(char *)(v24 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v24 + 532)); + _this.uBodyAnchor = 2; + v25 = v1 + 1; + v14 = v52 == 12; + memcpy((void *)(v24 + 532), &_this, 0x24u); + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v25; + if ( v14 ) + v50 = _this.uItemID; + if ( v51 ) + pPlayers[uActiveCharacter]->pEquipment.uShield = 0; + if ( v50 ) + { + __debugbreak(); // looks like offset in player's inventory and wand_lut much like case in 0042ECB5 + stru_A750F8[uActiveCharacter - 1]._494836( *((int *)&pSpellDatas[66].uNormalLevelRecovery + v50), uActiveCharacter - 1 + 9); + } + break; + case 1u: + if ( sub_43EE77_ProbablyIfUnderwaterSuitIsEquipped(uActiveCharacter) ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + if ( !pPlayers[uActiveCharacter]->HasSkill(pSkillType) ) + { + pPlayers[uActiveCharacter]->PlaySound(SPEECH_39, 0); + return; + } + if ( v1 ) + { + if ( v2 ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + --v1; + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v27 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v1); + *(char *)(v27 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v27 + 532)); + _this.uBodyAnchor = 2; + v28 = v1 + 1; + memcpy((void *)(v27 + 532), &_this, 0x24u); + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v28; + } + else + { + v52 = pPlayers[uActiveCharacter]->FindFreeInventorySlot(); + if ( (v52 & 0x80000000u) == 0 ) + { + if ( v2 ) + { + memcpy(&_this, &pParty->pPickedItem, sizeof(_this)); + v29 = (int)((char *)pPlayers[uActiveCharacter] + 36 * (v2 - 1)); + *(char *)(v29 + 556) = 0; + pParty->pPickedItem.Reset(); + pParty->SetHoldingItem((ItemGen *)(v29 + 532)); + _this.uBodyAnchor = 2; + v30 = v52 + 1; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &_this, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); + pPlayers[uActiveCharacter]->pEquipment.uShield = 0; + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v30; + } + else + { + pParty->pPickedItem.uBodyAnchor = 2; + v31 = v52 + 1; + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v52], &pParty->pPickedItem, sizeof(pPlayers[uActiveCharacter]->pInventoryItems[v52])); + pPlayers[uActiveCharacter]->pEquipment.uMainHand = v31; + pMouse->RemoveHoldingItem(); + } + } + } + return; + default: + pPlayers[uActiveCharacter]->UseItem_DrinkPotion_etc(uActiveCharacter, 0); + return; + } + return; + } + + v32 = pMouse->uMouseClickX; + v33 = pMouse->uMouseClickY; + + v34 = pRenderer->pActiveZBuffer[v32 + pSRZBufferLineOffsets[v33]] & 0xFFFF; + if ( v34 ) + { + v36 = v34 - 1; + v37 = (int)((char *)pPlayers[uActiveCharacter] + 36 * v36); + v50 = v37; + v38 = (ItemGen *)(v37 + 532); + v14 = v38->uItemID == 604; + v52 = pItemsTable->pItems[v38->uItemID].uEquipType; + if ( v14 ) + { + if ( bUnderwater ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + WetsuitOff(uActiveCharacter); + } + if ( unk_50C9A0 ) + { + *((char *)pGUIWindow_Settings->ptr_1C + 8) &= 0x7Fu; + *((short *)pGUIWindow_Settings->ptr_1C + 2) = uActiveCharacter - 1; + v39 = v52; + *((int *)pGUIWindow_Settings->ptr_1C + 3) = v36; + *((short *)pGUIWindow_Settings->ptr_1C + 3) = v39; + ptr_50C9A4 = v38; + unk_50C9A0 = 0; + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pMouse->SetCursorBitmap("MICON1"); + dword_50C9D4 = 0; + dword_50C9D0 = 113; + dword_50C9D8 = 256; + } + else + { + if ( !ptr_50C9A4 ) + { + pParty->SetHoldingItem(v38); + *(&pPlayers[uActiveCharacter]->uBirthYear + *(char *)(v50 + 556)) = 0; + v38->Reset(); + } + } + } + else + { + v35 = pPlayers[uActiveCharacter]->pEquipment.uBow; + if ( v35 ) + { + auto _a = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v35 - 1]; + pParty->SetHoldingItem(_a); + _a->Reset(); + pPlayers[uActiveCharacter]->pEquipment.uBow = 0; + } + } +} +//----- (004196A0) -------------------------------------------------------- +void CharacterUI_ReleaseButtons() +{ + GUIButton *i; // esi@2 + GUIButton *j; // esi@7 + + if ( dword_507CC0_activ_ch ) + { + dword_507CC0_activ_ch = 0; + for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = j ) + { + j=i->pNext; + if ( BYTE1(i->field_1C) & 0x80 ) + { + i->Release(); + pAllocator->FreeChunk(i); + } + } + for ( j = pGUIWindow_CurrentMenu->pControlsHead; j; j = j->pNext ) + { + if ( j->msg == UIMSG_InventoryLeftClick) + { + j->uX = dword_50698C_uX; + j->uY = dword_506988_uY; + j->uZ = dword_506984_uZ; + j->uW = dword_506980_uW; + pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(1, 0, 0, 0); + } + } + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/UIHouses.cpp Wed Jun 19 17:18:35 2013 +0600 @@ -0,0 +1,7058 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include "Texture.h" +#include "mm7_data.h" +#include "UIHouses.h" +#include "Party.h" +#include "texts.h" +#include "Events.h" +#include "Arcomage.h" +#include "LOD.h" +#include "Mouse.h" +#include "GUIWindow.h" +#include "GUIFont.h" +#include "Events2D.h" +#include "Overlays.h" +#include "Outdoor.h" +#include "AudioPlayer.h" +#include "VideoPlayer.h" +#include "Monsters.h" +#include "Viewport.h" +#include "Keyboard.h" +#include "IndoorCamera.h" +#include "MapInfo.h" +#include "Log.h" +#include "Game.h" + +#include "stru159.h" +int uHouse_ExitPic; // weak + +int dword_591080; // weak + +int in_current_building_type; // 00F8B198 +HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C + +#pragma pack(push, 1) +struct stru365_travel_info +{ + unsigned char uMapInfoID; + unsigned char pSchedule[7]; + unsigned int uTravelTime; + int arrival_x; + int arrival_y; + int arrival_z; + int arrival_rot_y; + unsigned int uQuestBit; // quest bit required to set for this travel option to be enabled; otherwise 0 +}; +#pragma pack(pop) +stru365_travel_info transport_schedule[35] = // 004F09B0 +{ + {MAP_STEADWICK, {1, 0, 1, 0, 1, 0, 0}, 2, -18048, 4636, 833, 1536, 0}, + {MAP_PIERPONT, {0, 1, 0, 1, 0, 1, 0}, 2, -2527, -6773, 1153, 896, 0}, + {MAP_TATALIA, {1, 0, 1, 0, 1, 0, 0}, 2, 4730, -10580, 320, 1024, 0}, + {MAP_HARMONDALE, {0, 1, 0, 1, 0, 1, 0}, 2, -5692, 11137, 1, 1024, 0}, + {MAP_DEYJA, {1, 0, 0, 1, 0, 0, 0}, 3, 7227, -16007, 2625, 640, 0}, + {MAP_BRAKADA_DESERT, {0, 0, 1, 0, 0, 1, 0}, 3, 8923, 17191, 1, 512, 0}, + {MAP_AVLEE, {1, 0, 1, 0, 1, 0, 0}, 3, 17059, 12331, 512, 1152, 0}, + {MAP_DEYJA, {0, 1, 0, 0, 1, 0, 1}, 2, 7227, -16007, 2625, 640, 0}, + {MAP_HARMONDALE, {0, 1, 0, 1, 0, 1, 0}, 2, -5692, 11137, 1, 1024, 0}, + {MAP_STEADWICK, {1, 0, 1, 0, 1, 0, 0}, 3, -18048, 4636, 833, 1536, 0}, + {MAP_PIERPONT, {0, 1, 0, 1, 0, 1, 0}, 2, -2527, -6773, 1153, 896, 0}, + {MAP_STEADWICK, {1, 0, 1, 0, 1, 0, 1}, 3, -18048, 4636, 833, 1536, 0}, + {MAP_HARMONDALE, {0, 1, 0, 0, 0, 1, 0}, 5, -5692, 11137, 1, 1024, 0}, + {MAP_STEADWICK, {0, 1, 0, 1, 0, 1, 0}, 2, -18048, 4636, 833, 1536, 0}, + {MAP_PIERPONT, {0, 1, 0, 1, 0, 1, 0}, 3, -2527, -16007, 1153, 896, 0}, + {MAP_DEYJA, {0, 0, 1, 0, 0, 0, 1}, 5, 7227, -16007, 2625, 640, 0}, + {MAP_TATALIA, {0, 1, 0, 1, 0, 1, 0}, 2, -2183, -6941, 97, 0, 0}, + {MAP_AVLEE, {1, 0, 0, 0, 1, 0, 0}, 4, 7913, 9476, 193, 0, 0}, + {MAP_EVENMORN_ISLE, {0, 0, 0, 0, 0, 0, 1}, 7, 15616, 6390, 193, 1536, PARTY_QUEST_EVENMORN_MAP_FOUND}, + {MAP_BRAKADA_DESERT, {0, 0, 1, 0, 0, 0, 0}, 6, 19171, -19722, 193, 1024, 0}, + {MAP_AVLEE, {0, 1, 0, 1, 0, 1, 0}, 3, 7913, 9476, 193, 0, 0}, + {MAP_BRAKADA_DESERT, {1, 0, 1, 0, 0, 0, 0}, 6, 19171, -19722, 193, 1024, 0}, + {MAP_TATALIA, {1, 0, 1, 0, 1, 0, 0}, 4, -2183, -6941, 97, 0, 0}, + {MAP_PIERPONT, {0, 0, 0, 0, 0, 1, 0}, 6, -709, -14087, 193, 1024, 0}, + {MAP_STEADWICK, {0, 0, 0, 0, 0, 0, 1}, 6, -10471, 13497, 193, 1536, 0}, + {MAP_EVENMORN_ISLE, {0, 1, 0, 1, 0, 0, 0}, 1, 15616, 6390, 193, 1536, PARTY_QUEST_EVENMORN_MAP_FOUND}, + {MAP_BRAKADA_DESERT, {0, 1, 0, 1, 0, 0, 0}, 1, 19171, -19722, 193, 1024, 0}, + {MAP_STEADWICK, {0, 1, 0, 1, 0, 1, 0}, 2, -10471, 13497, 193, 1536, 0}, + {MAP_BRAKADA_DESERT, {1, 0, 1, 0, 0, 0, 0}, 4, 19171, -19722, 193, 1024, 0}, + {MAP_EVENMORN_ISLE, {0, 0, 0, 0, 0, 0, 1}, 5, 15616, 6390, 193, 1536, PARTY_QUEST_EVENMORN_MAP_FOUND}, + {MAP_AVLEE, {0, 0, 0, 0, 1, 0, 0}, 5, 7913, 9476, 193, 0, 0}, + {MAP_STEADWICK, {0, 1, 0, 0, 0, 1, 0}, 4, -10471, 13497, 193, 1536, 0}, + {MAP_PIERPONT, {1, 0, 1, 0, 1, 0, 0}, 3, -709, -14087, 193, 1024, 0}, + {MAP_TATALIA, {0, 0, 0, 1, 0, 0, 0}, 5, -2183, -6941, 97, 0, 0}, + {MAP_ARENA, {0, 0, 0, 0, 0, 0, 1}, 4, 3844, 2906, 193, 512, 0} +}; + +unsigned char transport_routes[20][4] = +{ + { 0, 1, 1, 34}, // HOUSE_STABLES_HARMONDALE + { 2, 3, 4, 5}, // HOUSE_STABLES_STEADWICK + { 6, 7, 8, 8}, // HOUSE_STABLES_56 + { 9, 10, 10, 10}, // HOUSE_STABLES_57 + { 11, 11, 12, 12}, // HOUSE_STABLES_58 + { 13, 13, 13, 13}, // HOUSE_STABLES_59 + { 14, 14, 15, 15}, // HOUSE_STABLES_60 + {255, 255, 255, 255}, // HOUSE_STABLES_61 + {255, 255, 255, 255}, // HOUSE_STABLES_62 + {255, 255, 255, 255}, // HOUSE_BOATS_63 + { 16, 17, 18, 19}, // HOUSE_BOATS_64 + { 18, 20, 21, 21}, // HOUSE_BOATS_65 + { 22, 23, 24, 25}, // HOUSE_BOATS_66 + { 22, 22, 23, 23}, // HOUSE_BOATS_67 + {255, 255, 255, 255}, // HOUSE_BOATS_68 + { 27, 28, 29, 30}, // HOUSE_BOATS_69 + { 31, 32, 33, 33}, // HOUSE_BOATS_70 + { 24, 24, 24, 24}, // HOUSE_BOATS_71 + {255, 255, 255, 255}, // HOUSE_BOATS_72 + {255, 255, 255, 255} // HOUSE_BOATS_73 +}; + + + + + +std::array<const stru159, 196> pAnimatedRooms = //0x4E5F70 +{{ + {"", 0x4, 0x1F4, 0, 0, 0}, + {"Human Armor01", 0x20, 0x2C0, 2, 58, 0}, + {"Necromancer Armor01", 0x20, 0x2D7, 2, 70, 0 }, + {"Dwarven Armor01", 0x20, 0x2EE, 2, 5, 0 }, + {"Wizard Armor", 0x20, 0x3BD, 2, 19, 0 }, + {"Warlock Armor", 0x20, 0x2D6, 2, 35, 0 }, + {"Elf Armor", 0x20, 0x2BC, 2, 79, 0 }, + {"Human Alchemisht01", 0xE, 0x2BE, 4, 95, 0 }, + {"Necromancer Alchemist01", 0xE, 0x2D6, 4, 69, 0 }, + {"Dwarven Achemist01", 0xE, 0x387, 4, 4, 0 }, + {"Wizard Alchemist", 0xE, 0x232, 4, 25, 0 }, + {"Warlock Alchemist", 0xE, 0x2BE, 4, 42, 0 }, + {"Elf Alchemist", 0xE, 0x38A, 4, 84, 0 }, + {"Human Bank01", 0x6, 0x384, 22, 52, 0 }, + {"Necromancer Bank01", 0x6, 0x2D8, 22, 71, 0 }, + {"Dwarven Bank", 0x6, 0x2F3, 22, 6, 0 }, + {"Wizard Bank", 0x6, 0x3BA, 22, 20, 0 }, + {"Warlock Bank", 0x6, 0x39F, 22, 36, 0 }, + {"Elf Bank", 0x6, 0x2BC, 22, 71, 0 }, + {"Boat01", 0xF, 0x4C, 28, 53, 3 }, + {"Boat01d", 0xF, 0x4C, 28, 53, 3 }, + {"Human Magic Shop01", 0xA, 0x2C8, 3, 54, 0 }, + {"Necromancer Magic Shop01", 0xE, 0x2DC, 3, 66, 0 }, + {"Dwarven Magic Shop01", 0x2A, 0x2EF, 3, 91, 0 }, + {"Wizard Magic Shop", 0x1E, 0x2DF, 3, 15, 0 }, + {"Warlock Magic Shop", 0x7, 0x3B9, 3, 15, 0 }, + {"Elf Magic Shop", 0x24, 0x2CC, 3, 82, 0 }, + {"Human Stables01", 0x21, 0x31, 27, 48, 3 }, + {"Necromancer Stables", 0x21, 0x2DD, 27, 67, 3 }, + {"", 0x21, 0x2F0, 27, 91, 3 }, + {"Wizard Stables", 0x21, 0x3BA, 27, 16, 3 }, + {"Warlock Stables", 0x21, 0x181, 27, 77, 3 }, + {"Elf Stables", 0x21, 0x195, 27, 77, 3 }, + {"Human Tavern01", 0xD, 0x2C2, 21, 49, 0 }, + {"Necromancer Tavern01", 0xD, 0x3B0, 21, 57, 0 }, + {"Dwarven Tavern01", 0xD, 0x2FE, 21, 94, 0 }, + {"Wizard Tavern", 0xD, 0x3BB, 21, 17, 0 }, + {"Warlock Tavern", 0xD, 0x3A8, 21, 33, 0 }, + {"Elf Tavern", 0xD, 0x2CD, 21, 78, 0 }, + {"Human Temple01", 0x24, 0x2DB, 23, 50, 3 }, + {"Necromancer Temple", 0x24, 0x2DF, 23, 60, 3 }, + {"Dwarven Temple01", 0x24, 0x2F1, 23, 86, 3 }, + {"Wizard Temple", 0x24, 0x2E0, 23, 10, 3 }, + {"Warlock Temple", 0x24, 0x3A4, 23, 27, 3 }, + {"Elf Temple", 0x24, 0x2CE, 23, 72, 3 }, + {"Human Town Hall", 0x10, 0x39C, 17, 14, 0 }, + {"Necromancer Town Hall01", 0x10, 0x3A4, 17, 61, 0 }, + {"Dwarven Town Hall", 0x10, 0x2DB, 17, 88, 0 }, + {"Wizard Town Hall", 0x10, 0x3BD, 17, 11, 0 }, + {"Warlock Town Hall", 0x10, 0x2DB, 17, 28, 0 }, + {"Elf Town Hall", 0x10, 0x27A, 17, 73, 0 }, + {"Human Training Ground01", 0x18, 0x2C7, 30, 44, 0 }, + {"Necromancer Training Ground", 0x18, 0x3AD, 30, 62, 0 }, + {"Dwarven Training Ground", 0x18, 0x2F2, 30, 89, 0 }, + {"Wizard Training Ground", 0x18, 0x3A3, 30, 12, 0 }, + {"Warlock Training Ground", 0x18, 0x3A6, 30, 29, 0 }, + {"Elf Training Ground", 0x18, 0x19F, 30, 74, 0 }, + {"Human Weapon Smith01", 0x16, 0x2C1, 1, 45, 4 }, + {"Necromancer Weapon Smith01", 0x16, 0x2D9, 1, 63, 4 }, + {"Dwarven Weapon Smith01", 0x16, 0x2EE, 1, 82, 4 }, + {"Wizard Weapon Smith", 0x16, 0x2D5, 1, 13, 4 }, + {"Warlock Weapon Smith", 0x16, 0x2D7, 1, 23, 4 }, + {"Elf Weapon Smith", 0x16, 0x2CA, 1, 75, 4 }, + {"Air Guild", 0x1D, 0xA4, 6, 1, 3 }, + {"Body Guild", 0x19, 0x3BF, 11, 2, 0 }, + {"DarkGuild", 0x19, 0x2D1, 13, 3, 0 }, + {"EarthGuild", 0x19, 0x2CB, 8, 83, 0 }, + {"Fire Guild", 0x1C, 0x2BF, 5, 56, 0 }, + {"Light Guild", 0x1C, 0x2D5, 12, 46, 0 }, + {"Mind Guild", 0x1C, 0xE5, 10, 40, 0 }, + {"Spirit Guild", 0x1C, 0x2D2, 9, 41, 0 }, + {"Water Guild", 0x1B, 0x2D3, 7, 24, 0 }, + {"Lord And Judge Out01", 1, 0, 29, 39, 0 }, + {"Human Poor House 1", 8, 0, 29, 0, 0 }, + {"Human Poor House 2", 8, 0, 29, 0, 0 }, + {"Human Poor House 3", 8, 0, 29, 0, 0 }, + {"Human Medium House 1", 8, 0, 29, 0, 0 }, + {"Human Medium House 2", 8, 0, 29, 0, 0 }, + {"Human Medium House 3", 8, 0, 29, 0, 0 }, + {"Human Rich House 1", 8, 0, 29, 0, 0 }, + {"Human Rich House 2", 8, 0, 29, 0, 0 }, + {"Human Rich House 3", 8, 0, 29, 0, 0 }, + {"Elven Poor House 1", 8, 0, 29, 0, 0 }, + {"Elven Poor House 2", 8, 0, 29, 0, 0 }, + {"Elven Poor House 3", 8, 0, 29, 0, 0 }, + {"Elven Medium House 1", 8, 0, 29, 0, 0 }, + {"Elven Medium House 2", 8, 0, 29, 0, 0 }, + {"Elven Medium House 3", 8, 0, 29, 0, 0 }, + {"Elven Rich House 1", 8, 0, 29, 0, 0 }, + {"Elven Rich House 2", 8, 0, 29, 0, 0 }, + {"Elven Rich House 3", 8, 0, 29, 0, 0 }, + {"Dwarven Poor House 1", 8, 0, 29, 0, 0 }, + {"Dwarven Poor House 2", 8, 0, 29, 0, 0 }, + {"Dwarven Poor House 3", 8, 0, 29, 0, 0 }, + {"Dwarven Medium House 1", 8, 0, 29, 0, 0 }, + {"Dwarven Medium house 2", 8, 0, 29, 0, 0 }, + {"Dwarven Medium House 3", 8, 0, 29, 0, 0 }, + {"Dwarven Rich House 1", 8, 0, 29, 0, 0 }, + {"Dwarven Rich House 2", 8, 0, 29, 0, 0 }, + {"Dwarven Rich House 3", 8, 0, 29, 0, 0 }, + {"Wizard Poor House 1", 8, 0, 29, 0, 0 }, + {"Wizard Poor House 2", 8, 0, 29, 0, 0 }, + {"Wizard Poor House 3", 8, 0, 29, 0, 0 }, + {"Wizard Medium House 1", 8, 0, 29, 0, 0 }, + {"Wizard Medium House 2", 8, 0, 29, 0, 0 }, + {"Wizard Mdeium House 3", 8, 0, 29, 0, 0 }, + {"Wizard Rich House 1", 8, 0, 29, 0, 0 }, + {"Wizard Rich House 2", 8, 0, 29, 0, 0 }, + {"Wizard Rich House 3", 8, 0, 29, 0, 0 }, + {"Necromancer Poor House 1", 8, 0, 29, 0, 0 }, + {"Necromancer Poor House 2", 8, 0, 29, 0, 0 }, + {"Necromancer Poor House 3", 8, 0, 29, 0, 0 }, + {"Necromancer Medium House 1", 8, 0, 29, 0, 0 }, + {"Necromancer Medium House 2", 8, 0, 29, 0, 0 }, + {"Necromancer Mdeium House 3", 8, 0, 29, 0, 0 }, + {"Necromancer Rich House 1", 8, 0, 29, 0, 0 }, + {"Necromancer Rich House 2", 8, 0, 29, 0, 0 }, + {"Necromancer Rich House 3", 8, 0, 29, 0, 0 }, + {"Warlock Poor House 1", 8, 0, 29, 0, 0 }, + {"Warlock Poor House 2", 8, 0, 29, 0, 0 }, + {"Warlock Poor House 3", 8, 0, 29, 0, 0 }, + {"Warlock Medium House 1", 8, 0, 29, 0, 0 }, + {"Warlock Medium House 2", 8, 0, 29, 0, 0 }, + {"Warlock Mdeium House 3", 8, 0, 29, 0, 0 }, + {"Warlock Rich House 1", 8, 0, 29, 0, 0 }, + {"Warlock Rich House 2", 8, 0, 29, 0, 0 }, + {"Warlock Rich House 3", 8, 0, 29, 0, 0 }, + {"Out01 Temple of the Moon", 0x24, 0, 25, 0, 0 }, + {"Out01 Dragon Cave", 0x24, 0, 25, 0, 0 }, + {"Out02 Castle Harmondy", 0x24, 0, 25, 0, 0 }, + {"Out02 White Cliff Cave", 0x24, 0, 25, 0, 0 }, + {"Out03 Erathian Sewer", 0x24, 0, 25, 0, 0 }, + {"Out03 Fort Riverstride", 0x24, 0, 25, 0, 0 }, + {"Out03 Castle Gryphonheart", 0x24, 0, 25, 0, 0 }, + {"Out04 Elf Castle", 0x24, 0, 25, 0, 0 }, + {"Out04 Tularean Caves", 0x24, 0, 25, 0, 0 }, + {"Out04 Clanker's Laboratory", 0x24, 0, 25, 0, 0 }, + {"Out05 Hall of the Pit", 0x24, 0, 25, 0, 0 }, + {"Out05 Watchtower 6", 0x24, 0, 25, 0, 0 }, + {"Out06 School of Sorcery", 0x24, 0, 25, 0, 0 }, + {"Out06 Red Dwarf Mines", 0x24, 0, 25, 0, 0 }, + {"Out07 Castle Lambert", 0x24, 0, 25, 0, 0 }, + {"Out07 Walls of Mist", 0x24, 0, 25, 0, 0 }, + {"Out07 Temple of the Light", 0x24, 0, 25, 0, 0 }, + {"Out08 Evil Entrance", 0x24, 0, 25, 0, 0 }, + {"Out08 Breeding Zone", 0x24, 0, 25, 0, 0 }, + {"Out08 Temple of the Dark", 0x24, 0, 25, 0, 0 }, + {"Out09 Grand Temple of the Moon", 0x24, 0, 25, 0, 0 }, + {"Out09 Grand Tempple of the Sun", 0x24, 0, 25, 0, 0 }, + {"Out10 Thunderfist Mountain", 0x24, 0, 25, 0, 0 }, + {"Out10 The Maze", 0x24, 0, 25, 0, 0 }, + {"Out10 Connecting Tunnel Cave #1", 0x24, 0, 25, 0, 0 }, + {"", 0x24, 0, 25, 0, 0 }, + {"", 0x24, 0, 25, 0, 0 }, + {"Out11 Stone City", 0x24, 0, 25, 0, 0 }, + {"", 0x24, 0, 25, 0, 0 }, + {"Out12 Colony Zod", 0x24, 0, 25, 0, 0 }, + {"Out12 Connecting Tunnel Cave #1", 0x24, 0, 25, 0, 0 }, + {"", 0x24, 0, 25, 0, 0 }, + {"", 0x24, 0, 25, 0, 0 }, + {"Out13 Mercenary Guild", 0x24, 0, 25, 0, 0 }, + {"Out13 Tidewater Caverns", 0x24, 0, 25, 0, 0 }, + {"Out13 Wine Cellar", 0x24, 0, 25, 0, 0 }, + {"Out14 Titan's Stronghold", 0x24, 0, 25, 0, 0 }, + {"Out14 Temple Of Baa", 0x24, 0, 25, 0, 0 }, + {"Out14 Hall under the Hill", 0x24, 0, 25, 0, 0 }, + {"Out15 The Linclon", 0x24, 0, 25, 0, 0 }, + {"Jail", 0x24, 0, 31, 0, 0 }, + {"Harmondale Throne Room", 0x24, 0, 29, 0, 0 }, + {"Gryphonheart Throne Room", 0x24, 0, 20, 0, 0 }, + {"Elf Castle Throne Room", 0x24, 0, 20, 0, 0 }, + {"Wizard Castle Throne Room", 0x24, 0, 20, 0, 0 }, + {"Necromancer Casstle Trone Room", 0x24, 0, 20, 0, 0 }, + {"Master Thief", 0x24, 0, 29, 0, 0 }, + {"Dwarven King", 0x24, 0, 20, 0, 0 }, + {"Arms Master", 0x24, 0, 29, 0, 0 }, + {"Warlock", 0x24, 0, 29, 0, 0 }, + {"Lord Markam", 0x24, 0, 20, 0, 0 }, + {"Arbiter Neutral Town", 0x24, 0, 29, 0, 0 }, + {"Arbiter Good Town", 0x24, 0, 29, 0, 0 }, + {"Arbiter Evil Town", 0x24, 0, 29, 0, 0 }, + {"Necromancer Throne Room Empty", 0x24, 0, 20, 0, 0 }, + {"", 0x24, 0, 29, 0, 0 }, + {"", 0x24, 0, 29, 0, 0 }, + {"", 0x24, 0, 29, 0, 0 }, + {"", 0x24, 0, 29, 0, 0 }, + {"Boat01", 0xF, 0, 29, 53, 3 }, + {"", 0x24, 0, 28, 0, 0 }, + {"", 0x24, 0, 28, 0, 0 }, + {"", 0x24, 0, 28, 0, 0 }, + {"", 0x24, 0, 29, 0, 0 }, + {"Arbiter Room Neutral", 0x24, 0, 29, 0, 0 }, + {"Out02 Castle Harmondy Abandoned", 0x24, 0, 25, 0, 0 }, + {"Human Temple02", 0x24, 0x3AB, 23, 27, 0 }, + {"Player Castle Good", 0x24, 0, 25, 0, 0 }, + {"Player Castle Bad", 0x24, 0, 25, 0, 0} +}}; + + + +//----- (0044606A) -------------------------------------------------------- +void PrepareHouse(HOUSE_ID house) +{ + //unsigned int v1; // ebx@1 + //signed int v2; // esi@1 + //int uExitPic; // edi@1 + __int16 uExitMapID; // ax@2 + //int result; // eax@5 + //unsigned int *v6; // ecx@8 + int v7; // ebx@11 + //int v8; // esi@16 + //unsigned int v9; // eax@16 + //unsigned int v10; // eax@19 + //int v11; // ecx@19 + //char pContainer[36]; // [sp+Ch] [bp-54h]@16 + int v13; // [sp+30h] [bp-30h]@11 + int npc_id_arr[6]; // [sp+34h] [bp-2Ch]@1 + //unsigned int v15; // [sp+4Ch] [bp-14h]@1 + int uAnimationID; // [sp+50h] [bp-10h]@1 + //unsigned int *v17; // [sp+54h] [bp-Ch]@3 + //unsigned int v18; // [sp+58h] [bp-8h]@1 + //int v19; // [sp+5Ch] [bp-4h]@7 + + + uAnimationID = p2DEvents[house - 1].uAnimationID; + memset(npc_id_arr, 0, sizeof(npc_id_arr)); + uNumDialogueNPCPortraits = 0; + uHouse_ExitPic = p2DEvents[house - 1].uExitPicID; + if ( uHouse_ExitPic ) + { + uExitMapID = p2DEvents[house - 1]._quest_related; + if ( uExitMapID > 0 ) + { + if(_449B57_test_bit(pParty->_quest_bits,uExitMapID)) + { + uHouse_ExitPic = 0; + } + } + } + + dword_591080 = pAnimatedRooms[uAnimationID].house_npc_id; + HouseNPCData[0]=0; + uNumDialogueNPCPortraits = 0; + if ( dword_591080 ) + { + + npc_id_arr[0] = dword_591080; + uNumDialogueNPCPortraits = 1; + } + + for (uint i = 1; i < pNPCStats->uNumNewNPCs; ++i) + { + if (pNPCStats->pNewNPCData[i].Location2D == house ) + { + if (!(pNPCStats->pNewNPCData[i].uFlags & 0x80)) + { + + HouseNPCData[uNumDialogueNPCPortraits+1- (dword_591080 != 0) ? 1 : 0] = &pNPCStats->pNewNPCData[i]; + npc_id_arr[uNumDialogueNPCPortraits] = pNPCStats->pNewNPCData[i].uPortraitID; + ++uNumDialogueNPCPortraits; + if ((pNPCStats->pNewNPCData[i].uFlags & 3) != 2) + ++pNPCStats->pNewNPCData[i].uFlags; + } + } + + } + + for (uint i = 0; i < uNumDialogueNPCPortraits; ++i) + { + + char icon_name[128]; + sprintfex(icon_name, "npc%03u", npc_id_arr[i]); + pDialogueNPCPortraits[i] = pIcons_LOD->LoadTexturePtr(icon_name, TEXTURE_16BIT_PALETTE); + } + + if (uHouse_ExitPic) + { + pDialogueNPCPortraits[uNumDialogueNPCPortraits] = pIcons_LOD->LoadTexturePtr(pHouse_ExitPictures[uHouse_ExitPic], TEXTURE_16BIT_PALETTE); + ++uNumDialogueNPCPortraits; + uHouse_ExitPic = p2DEvents[house - 1].uExitMapID; + } +} + + +//----- (0044622E) -------------------------------------------------------- +bool EnterHouse(enum HOUSE_ID uHouseID) +{ + //enum HOUSE_ID v1; // edi@1 + //int v2; // edi@5 + signed int uOpenTime; // eax@5 + signed int uCloseTime; // esi@5 + unsigned int v5; // esi@5 + int v6; // edx@5 + signed int am_pm_flag_open; // ecx@10 + signed int am_pm_flag_close; // eax@10 + int v9; // esi@10 + //unsigned int v10; // esi@16 + int v11; // ecx@17 + unsigned int v12; // kr00_4@25 + //Player *v13; // esi@25 + int v14; // eax@25 + //Player *v15; // esi@27 + //signed int v16; // eax@32 + unsigned int v17; // eax@37 + signed int v18; // edi@37 + signed int v19; // edi@41 + //unsigned int v20; // ecx@41 + //const char *v22; // [sp-4h] [bp-40h]@33 + char pContainer[40]; // [sp+Ch] [bp-30h]@32 + unsigned int v24; // [sp+34h] [bp-8h]@5 + //enum HOUSE_ID v25; // [sp+38h] [bp-4h]@1 + + //v1 = uHouseID; + //v25 = uHouseID; + GameUI_Footer_TimedString[0] = 0; + pFooterString[0] = 0; + ShowStatusBarString("", 2u); + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + viewparams->bRedrawGameUI = 1; + uDialogueType = 0; + pKeyActionMap->SetWindowInputStatus(3); + pKeyActionMap->ResetKeys(); + if (uHouseID == HOUSE_600 || uHouseID == HOUSE_601) + { + GameOverMenu(0); + return 0; + } + uOpenTime = p2DEvents[uHouseID - 1].uOpenTime; + uCloseTime = p2DEvents[uHouseID - 1].uCloseTime; + current_npc_text = 0; + dword_F8B1E4 = 0; + dword_F8B1F4 = 0; + memset(byte_F8B1F0.data(), 0, 4); + memset(player_levels.data(), 0, 16); + pRenderer->ClearZBuffer(0, 479); + + if (((uCloseTime - 1 <= uOpenTime)&&((pParty->uCurrentHour <uOpenTime)&&(pParty->uCurrentHour >(uCloseTime - 1))))|| + ((uCloseTime - 1 > uOpenTime)&&((pParty->uCurrentHour < uOpenTime)||(pParty->uCurrentHour > (uCloseTime - 1))))) + + { + am_pm_flag_open = 0; + am_pm_flag_close = 0; + if (uOpenTime > 12 ) + { + uOpenTime -= 12; + am_pm_flag_open = 1; + } + if ( uCloseTime > 12 ) + { + uCloseTime -= 12; + am_pm_flag_close = 1; + } + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[414], uOpenTime, aAMPMNames[am_pm_flag_open], + uCloseTime, aAMPMNames[am_pm_flag_close]); //"This place is open from %d%s to %d%s" + ShowStatusBarString(pTmpBuf.data(), 2u); + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_3, 0); + return 0; + } + else + { + //v10 = uHouseID; + if ( (signed int)uHouseID < 53 ) //entering shops and guilds + { + if ( !(pParty->field_3C._shop_ban_times[uHouseID]) + || (pParty->field_3C._shop_ban_times[uHouseID] <= pParty->uTimePlayed) ) + { + pParty->field_3C._shop_ban_times[uHouseID] = 0; + } + else + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[191], 2u);// "You've been banned from this shop!" + return 0; + } + } + pAudioPlayer->StopChannels(-1, -1); + + uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID; + in_current_building_type = pAnimatedRooms[uCurrentHouse_Animation].uBuildingType; + if ( in_current_building_type == BildingType_Throne_Room && pParty->uFine ) // going 2 jail + { + uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID; + uHouseID = HOUSE_JAIL; + pParty->uTimePlayed = pParty->uTimePlayed + 0x7620000; + in_current_building_type = pAnimatedRooms[p2DEvents[HOUSE_LORD_AND_JUDGE_EMERALD_ISLE].uAnimationID].uBuildingType; + ++pParty->uNumPrisonTerms; + pParty->uFine = 0; + for (uint i = 0; i < 4; ++i) + { + pParty->pPlayers[i].uTimeToRecovery = 0; + pParty->pPlayers[i].uNumDivineInterventionCastsThisDay = 0; + pParty->pPlayers[i].SetVariable(VAR_Award, 87); + } + } + ++pIcons_LOD->uTexturePacksCount; + if ( !pIcons_LOD->uNumPrevLoadedFiles ) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + switch (pParty->alignment) + { + case PartyAlignment_Good: sprintf(pContainer, "evt%02d-b", const_2()); break; + case PartyAlignment_Neutral: sprintf(pContainer, "evt%02d", const_2()); break; + case PartyAlignment_Evil: sprintf(pContainer, "evt%02d-c", const_2()); break; + default: assert(false); + } + + v17 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + pDialogueNPCCount = 0; + pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v17]; + uTextureID_right_panel_loop = uTextureID_right_panel; + PrepareHouse(uHouseID); + v18 = 1; + uTextureID_right_panel_loop = uTextureID_right_panel; + if ( uNumDialogueNPCPortraits == 1 ) + pDialogueNPCCount = 1; + pVideoPlayer->OpenHouseMovie(pAnimatedRooms[uCurrentHouse_Animation].video_name, 1u); + dword_5C35D4 = 1; + if ( (signed int)uHouseID < 139 || (signed int)uHouseID > 172 ) + { + if ( (signed int)uHouseID >= HOUSE_STABLES_HARMONDALE && (signed int)uHouseID <= 73 && !IsTravelAvailable(uHouseID - HOUSE_STABLES_HARMONDALE) ) + { + return 1; + } + } + else + { //guilds + v19 = guild_mambership_flags[uHouseID - HOUSE_FIRE_GUILD_INITIATE_EMERALD_ISLE]; //guilds flags + //v20 = uHouseID; + //if ( !((unsigned __int8)(0x80u >> v19 % 8) & pPlayers[uActiveCharacter]->_guilds_member_bits[v19 /8]) ) + if(_449B57_test_bit(pPlayers[uActiveCharacter]->_guilds_member_bits,v19)) + { + PlayHouseSound(uHouseID, HouseSound_Greeting_2); + return 1; + } + } + PlayHouseSound(uHouseID, HouseSound_Greeting); + dword_5C35D4 = 1; + return 1; + } + } + +//----- (004B1E92) -------------------------------------------------------- +void PlayHouseSound(unsigned int uHouseID, HouseSoundID sound) +{ + //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) ) + if ( pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId ) + pAudioPlayer->PlaySound( + //(SoundID)(a2 + 100 * (BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * uHouseID]].field_C) + 300)), + (SoundID)(sound + 100 * (pAnimatedRooms[p2DEvents[uHouseID].uAnimationID].uRoomSoundId + 300)), + 806, 0, -1, 0, 0, 0, 0); +} + +//----- (004B4F4F) -------------------------------------------------------- +void JailDialog() +{ + const char *v0; // esi@1 + const char *v1; // ST10_4@1 + unsigned __int16 v2; // ST0C_2@1 + int v3; // eax@1 + GUIWindow v5; // [sp+8h] [bp-54h]@1 + + memcpy(&v5, window_SpeakInHouse, sizeof(v5)); + v0 = pGlobalTXT_LocalizationStrings[672]; + v1 = pGlobalTXT_LocalizationStrings[672]; + v5.uFrameX = 483; + v5.uFrameWidth = 148; + v5.uFrameZ = 334; + v2 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + v3 = pFontArrus->CalcTextHeight(v0, &v5, 0, 0); + v5.DrawTitleText(pFontArrus, 0, (310 - v3) / 2 + 18, v2, v1, 3u); +} + + + + +//----- (004BCACC) -------------------------------------------------------- +void __fastcall OnSelectShopDialogueOption(signed int uMessageParam) +{ + //unsigned int v1; // edi@1 + //signed int v2; // ebx@1 + //signed int v3; // ecx@2 + int v4; // eax@5 + signed int v5; // esi@5 + //Player *v6; // ecx@5 + //signed int v7; // edx@5 + GUIWindow *v8; // esi@10 + unsigned int v9; // eax@12 + int v10; // esi@31 + int v11; // edi@31 + int v12; // esi@32 + __int16 v13; // bp@32 + int v14; // edx@32 + GUIWindow *v15; // eax@32 + int v16; // eax@32 + int v17; // eax@33 + int v18; // eax@34 + int v19; // eax@35 + __int16 v20; // ax@37 + __int16 v21; // ax@76 + __int16 v22; // ax@107 + __int16 v23; // ax@132 + __int16 v24; // ax@163 + int v25; // esi@190 + __int16 v26; // ax@190 + char v27; // zf@190 + Player *v28; // edi@192 + int v29; // eax@204 + void *v30; // esi@208 + unsigned __int64 v31; // qax@208 + signed int v32; // edi@209 + int v33; // eax@210 + unsigned int v34; // eax@211 + //Player *v35; // edi@227 + signed int v36; // esi@227 + int v37; // ecx@227 + int v38; // esi@230 + int v39; // edx@235 + int v40; // edi@243 + unsigned __int64 v41; // qax@243 + //void *v42; // eax@244 + signed int v43; // edi@244 + int v44; // edx@244 + int v45; // eax@246 + unsigned int v46; // eax@247 + void *v47; // eax@250 + signed int v48; // edi@250 + int v49; // eax@252 + int v50; // eax@256 + unsigned int v51; // eax@257 + void *v52; // eax@260 + signed int v53; // edi@260 + int v54; // eax@262 + //signed int v55; // [sp+10h] [bp-10h]@1 + int v56; // [sp+14h] [bp-Ch]@31 + + //v1 = 0; + //v2 = a1; + //v55 = a1; + if ( !pDialogueWindow->pNumPresenceButton ) + return; + pRenderer->ClearZBuffer(0, 479); + //v3 = dword_F8B198; + if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN) + v8 = window_SpeakInHouse; + //else + if (dialog_menu_id == HOUSE_DIALOGUE_MAIN) + { + if ( in_current_building_type == BildingType_Training ) + { + if ( uMessageParam == HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) + { + v4 = 0; + v5 = 0; + //v6 = pPlayers[uActiveCharacter]; + //v7 = pPlayers[uActiveCharacter]->uLevel; + if ( pPlayers[uActiveCharacter]->uLevel > 0 ) + { + do + v4 += v5++ + 1; + while ( v5 < pPlayers[uActiveCharacter]->uLevel ); + } + if (pPlayers[uActiveCharacter]->uLevel < pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - 89] && + (signed __int64)pPlayers[uActiveCharacter]->uExperience < 1000 * v4) + return; + } + pDialogueWindow->Release(); + pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0); + pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" + pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); + pDialogueWindow->CreateButton(8, 8, 0x1C2, 0x140, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr); +// LABEL_10: + //v3 = dword_F8B198; + v8 = window_SpeakInHouse; + } + //else + if ( in_current_building_type != BildingType_Training ) + { + v8 = window_SpeakInHouse; + if ((in_current_building_type == BildingType_Stables || in_current_building_type == BildingType_Boats) && + transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][uMessageParam - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]].pSchedule[pParty->uDaysPlayed % 7] + || in_current_building_type != BildingType_Temple || uMessageParam != BildingType_MindGuild ) + { + //LABEL_9: + pDialogueWindow->Release(); + pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0); + pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[74],// "End Conversation" + pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); + pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", nullptr); + // LABEL_10: + //v3 = dword_F8B198; + v8 = window_SpeakInHouse; + } + else if (uActiveCharacter) + { + if ( !pPlayers[uActiveCharacter]->IsPlayerHealableByTemple() ) + return; + v8 = window_SpeakInHouse; + } + } + //LABEL_11: + dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam; + if ( in_current_building_type < BildingType_19 ) + { + v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_building_type], TEXTURE_16BIT_PALETTE); + //v3 = dword_F8B198; + ShopTexture = &pIcons_LOD->pTextures[v9]; + //LABEL_13: + v8 = window_SpeakInHouse; + } + } + + //NEW + switch(in_current_building_type) + { + case BildingType_FireGuild: + case BildingType_AirGuild: + case BildingType_WaterGuild: + case BildingType_EarthGuild: + case BildingType_SpiritGuild: + case BildingType_MindGuild: + case BildingType_BodyGuild: + case BildingType_LightGuild: + case BildingType_DarkGuild: + case BildingType_14: + case BildingType_15: + case BildingType_16: + { + if ( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472] >= (signed __int64)pParty->uTimePlayed && + *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468] >= (signed __int64)pParty->uTimePlayed ) + { + v32 = 0; + do + { + //v33 = *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v32 + 12 * (unsigned int)v8->ptr_1C)); + v33 = pParty->SpellBooksInGuilds[v8->par1C-139][v32].uItemID; + if ( v33 ) + { + v34 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v33].pIconName, TEXTURE_16BIT_PALETTE); + v8 = window_SpeakInHouse; + ItemsInShopTexture[v32] = &pIcons_LOD->pTextures[v34]; + } + ++v32; + } + while ( v32 < 12 ); + } + else + { + SpellBookGenerator(); + v30 = window_SpeakInHouse->ptr_1C; + v31 = pParty->uTimePlayed + (signed __int64)((double)(0xA8C000 + //* (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C]) + * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335); + *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44468] = v31; + *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44472] = HIDWORD(v31); + } + //return; + break; + } + case BildingType_TownHall: + { + if ( uMessageParam == 99 ) + { + v10 = (int)((char *)v8->ptr_1C - 102); + v56 = v10; + v11 = 8 * v10 + 11325428; + if ( pParty->field_3C.field_0[2 * v10 + 1] >= (signed __int64)pParty->uTimePlayed + && pParty->field_3C.field_0[2 * v10] >= (signed __int64)pParty->uTimePlayed ) + { + v13 = 0; + } + else + { + v12 = v10; + v13 = 0; + pParty->field_75A[v12] = 0; + *(_QWORD *)v11 = (signed __int64)((double)(309657600 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335); + v14 = rand() % 258; + v15 = window_SpeakInHouse; + pParty->field_750[v12] = v14 + 1; + v16 = (int)((char *)v15->ptr_1C - 102); + if ( v16 ) + { + v17 = v16 - 1; + if ( v17 ) + { + v18 = v17 - 1; + if ( v18 ) + { + v19 = v18 - 1; + if ( v19 ) + { + if ( v19 == 1 ) + { + while ( 1 ) + { + v20 = pParty->field_750[v12]; + if ( (unsigned __int16)v20 < 0x73u || (unsigned __int16)v20 > 0x84u ) + { + if ( ((unsigned __int16)v20 < 0xE8u || (unsigned __int16)v20 > 0xF9u) + && ((unsigned __int16)v20 < 0x85u || (unsigned __int16)v20 > 0x96u) + && ((unsigned __int16)v20 < 0x97u || (unsigned __int16)v20 > 0xBAu) + && ((unsigned __int16)v20 < 0xBEu || (unsigned __int16)v20 > 0xC0u) + && ((unsigned __int16)v20 < 0xC4u || (unsigned __int16)v20 > 0xC6u) + && ((unsigned __int16)v20 < 0x2Bu || (unsigned __int16)v20 > 0x2Du) + && ((unsigned __int16)v20 < 0x6Du || (unsigned __int16)v20 > 0x6Fu) + && ((unsigned __int16)v20 < 0x46u || (unsigned __int16)v20 > 0x48u) + && ((unsigned __int16)v20 < 0x100u || (unsigned __int16)v20 > 0x102u) + && ((unsigned __int16)v20 < 0xD9u || (unsigned __int16)v20 > 0xDBu) + && ((unsigned __int16)v20 < 0xC7u || (unsigned __int16)v20 > 0xC9u) + && ((unsigned __int16)v20 < 0xE5u || (unsigned __int16)v20 > 0xE7u) + && ((unsigned __int16)v20 < 0xDFu || (unsigned __int16)v20 > 0xE1u) + && ((unsigned __int16)v20 < 0x5Bu || (unsigned __int16)v20 > 0x5Du) + && ((unsigned __int16)v20 < 0x49u || (unsigned __int16)v20 > 0x4Bu) + && ((unsigned __int16)v20 < 0xFDu || (unsigned __int16)v20 > 0xFFu) + && ((unsigned __int16)v20 < 0x61u || (unsigned __int16)v20 > 0x63u) + && ((unsigned __int16)v20 < 0x10u || (unsigned __int16)v20 > 0x12u) ) + break; + } + pParty->field_750[v12] = rand() % 258 + 1; + } + } + } + else + { + while ( 1 ) + { + v21 = pParty->field_750[v12]; + if ( (unsigned __int16)v21 < 0x73u || (unsigned __int16)v21 > 0x84u ) + { + if ( ((unsigned __int16)v21 < 0xE8u || (unsigned __int16)v21 > 0xF9u) + && ((unsigned __int16)v21 < 0x85u || (unsigned __int16)v21 > 0x96u) + && ((unsigned __int16)v21 < 0x97u || (unsigned __int16)v21 > 0xBAu) + && ((unsigned __int16)v21 < 0xBEu || (unsigned __int16)v21 > 0xC0u) + && ((unsigned __int16)v21 < 0xC4u || (unsigned __int16)v21 > 0xC6u) + && ((unsigned __int16)v21 < 0x2Bu || (unsigned __int16)v21 > 0x2Du) + && ((unsigned __int16)v21 < 0x5Eu || (unsigned __int16)v21 > 0x60u) + && ((unsigned __int16)v21 < 0x43u || (unsigned __int16)v21 > 0x45u) + && ((unsigned __int16)v21 < 0x4Fu || (unsigned __int16)v21 > 0x51u) + && ((unsigned __int16)v21 < 0xC1u || (unsigned __int16)v21 > 0xC3u) + && ((unsigned __int16)v21 < 0x13u || (unsigned __int16)v21 > 0x15u) + && ((unsigned __int16)v21 < 0xFDu || (unsigned __int16)v21 > 0xFFu) + && ((unsigned __int16)v21 < 0x61u || (unsigned __int16)v21 > 0x63u) + && ((unsigned __int16)v21 < 0x6Au || (unsigned __int16)v21 > 0x6Cu) ) + break; + } + pParty->field_750[v12] = rand() % 258 + 1; + } + } + } + else + { + while ( 1 ) + { + v22 = pParty->field_750[v12]; + if ( (unsigned __int16)v22 < 0x73u || (unsigned __int16)v22 > 0x84u ) + { + if ( ((unsigned __int16)v22 < 0xE8u || (unsigned __int16)v22 > 0xF9u) + && ((unsigned __int16)v22 < 0x85u || (unsigned __int16)v22 > 0x96u) + && ((unsigned __int16)v22 < 0x97u || (unsigned __int16)v22 > 0xBAu) + && ((unsigned __int16)v22 < 0xBEu || (unsigned __int16)v22 > 0xC0u) + && ((unsigned __int16)v22 < 0xC4u || (unsigned __int16)v22 > 0xC6u) + && ((unsigned __int16)v22 < 0x2Bu || (unsigned __int16)v22 > 0x2Du) + && ((unsigned __int16)v22 < 0x31u || (unsigned __int16)v22 > 0x33u) + && ((unsigned __int16)v22 < 0x34u || (unsigned __int16)v22 > 0x36u) + && ((unsigned __int16)v22 < 0xFDu || (unsigned __int16)v22 > 0xFFu) + && ((unsigned __int16)v22 < 0x61u || (unsigned __int16)v22 > 0x63u) + && ((unsigned __int16)v22 < 0x1Cu || (unsigned __int16)v22 > 0x1Eu) ) + break; + } + pParty->field_750[v12] = rand() % 258 + 1; + } + } + } + else + { + while ( 1 ) + { + v23 = pParty->field_750[v12]; + if ( (unsigned __int16)v23 < 0x73u || (unsigned __int16)v23 > 0x84u ) + { + if ( ((unsigned __int16)v23 < 0xE8u || (unsigned __int16)v23 > 0xF9u) + && ((unsigned __int16)v23 < 0x85u || (unsigned __int16)v23 > 0x96u) + && ((unsigned __int16)v23 < 0x97u || (unsigned __int16)v23 > 0xBAu) + && ((unsigned __int16)v23 < 0xBEu || (unsigned __int16)v23 > 0xC0u) + && ((unsigned __int16)v23 < 0xC4u || (unsigned __int16)v23 > 0xC6u) + && ((unsigned __int16)v23 < 0x2Bu || (unsigned __int16)v23 > 0x2Du) + && ((unsigned __int16)v23 < 0x52u || (unsigned __int16)v23 > 0x54u) + && ((unsigned __int16)v23 < 4u || (unsigned __int16)v23 > 6u) + && ((unsigned __int16)v23 < 0x37u || (unsigned __int16)v23 > 0x39u) + && ((unsigned __int16)v23 < 0x3Au || (unsigned __int16)v23 > 0x3Cu) + && ((unsigned __int16)v23 < 0x3Du || (unsigned __int16)v23 > 0x3Fu) + && ((unsigned __int16)v23 < 0xFDu || (unsigned __int16)v23 > 0xFFu) + && ((unsigned __int16)v23 < 0x61u || (unsigned __int16)v23 > 0x63u) + && ((unsigned __int16)v23 < 0xCDu || (unsigned __int16)v23 > 0xCFu) ) + break; + } + pParty->field_750[v12] = rand() % 258 + 1; + } + } + } + else + { + while ( 1 ) + { + v24 = pParty->field_750[v12]; + if ( (unsigned __int16)v24 < 0x73u || (unsigned __int16)v24 > 0x84u ) + { + if ( ((unsigned __int16)v24 < 0xEBu || (unsigned __int16)v24 > 0xFCu) + && ((unsigned __int16)v24 < 0x85u || (unsigned __int16)v24 > 0x96u) + && ((unsigned __int16)v24 < 0x97u || (unsigned __int16)v24 > 0xBAu) + && ((unsigned __int16)v24 < 0xBEu || (unsigned __int16)v24 > 0xC0u) + && ((unsigned __int16)v24 < 0xC4u || (unsigned __int16)v24 > 0xC6u) + && ((unsigned __int16)v24 < 0x2Bu || (unsigned __int16)v24 > 0x2Du) + && ((unsigned __int16)v24 < 0xCDu || (unsigned __int16)v24 > 0xCFu) + && ((unsigned __int16)v24 < 0x5Eu || (unsigned __int16)v24 > 0x60u) + && ((unsigned __int16)v24 < 0xFDu || (unsigned __int16)v24 > 0xFFu) + && ((unsigned __int16)v24 < 0x6Du || (unsigned __int16)v24 > 0x6Fu) + && ((unsigned __int16)v24 < 0x61u || (unsigned __int16)v24 > 0x63u) ) + break; + } + pParty->field_750[v12] = rand() % 258 + 1; + } + } + v10 = v56; + } + v25 = v10; + v26 = pParty->field_750[v25]; + v27 = pParty->field_75A[v25] == v13; + word_F8B1A0 = pParty->field_750[v25]; + if ( v27 ) + { + //v1 = 0; + v27 = v26 == v13; + v29 = (int)pNPCTopics[351].pText; + if ( v27 ) + v29 = (int)pNPCTopics[353].pText; + dword_F8B1A4 = (char *)v29; + } + else + { + if ( v26 != v13 ) + { + party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v26].uLevel, 0); + v28 = pParty->pPlayers; + do + { + v28->SetVariable(VAR_Award, 86); + ++v28; + } + while ( (signed int)v28 < (signed int)pParty->pHirelings ); + pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v25]].uLevel; + pParty->field_750[v25] = v13; + pParty->field_75A[v25] = v13; + } + //v1 = 0; + dword_F8B1A4 = pNPCTopics[352].pText; + } + } + else if ( uMessageParam == HOUSE_DIALOGUE_TOWNHALL_100 ) + { + pKeyActionMap->EnterText(1, 10, v8); + } + break; + } + case BildingType_Bank: + { + if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 ) + pKeyActionMap->EnterText(1, 10, v8); + return; + break; + } + case BildingType_WeaponShop: + case BildingType_ArmorShop: + case BildingType_MagicShop: + case BildingType_AlchemistShop: + case BildingType_Tavern: + case BildingType_Temple: + case BildingType_Training: + { + break; + } + default: + { + return; + break; + } + } + + /* + if ( in_current_building_type > BildingType_Tavern ) + { + if ( in_current_building_type == BildingType_Bank ) + { + if ( dialog_menu_id >= 7 && dialog_menu_id <= 8 ) + pKeyActionMap->EnterText(1, 10, v8); + return; + } + if ( in_current_building_type != BildingType_Temple && in_current_building_type != BildingType_Training ) + return; + } + //else + if ( in_current_building_type < BildingType_Tavern ) + { + if (in_current_building_type <= 0) + return; + if ( in_current_building_type > BildingType_AlchemistShop ) + { + if ( in_current_building_type <= BildingType_16 ) + { + if ( (signed __int64)__PAIR__( + *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472], + *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44468]) >= (signed __int64)pParty->uTimePlayed ) + { + v32 = 0; + do + { + //v33 = *(&pParty->pPlayers[1].pInstalledBeacons[0].field_18 + 9 * (v32 + 12 * (unsigned int)v8->ptr_1C)); + v33 = pParty->SpellBooksInGuilds[v8->par1C-139][v32].uItemID; + if ( v33 ) + { + v34 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v33].pIconName, TEXTURE_16BIT_PALETTE); + v8 = window_SpeakInHouse; + ItemsInShopTexture[v32] = &pIcons_LOD->pTextures[v34]; + } + ++v32; + } + while ( v32 < 12 ); + } + else + { + SpellBookGenerator(); + v30 = window_SpeakInHouse->ptr_1C; + v31 = pParty->uTimePlayed + + (signed __int64)((double)(0xA8C000 + //* (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C]) + * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) + * 0.033333335); + *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44468] = v31; + *(int *)&stru_AA1058[3].pSounds[8 * (int)v30 + 44472] = HIDWORD(v31); + } + return; + } + if ( in_current_building_type != BildingType_TownHall ) + return; + if ( in_current_building_type == BildingType_TownHall ) + { + if ( uMessageParam == 99 ) + { + v10 = (int)((char *)v8->ptr_1C - 102); + v56 = v10; + v11 = 8 * v10 + 11325428; + if ( (signed __int64)__PAIR__(pParty->field_3C.field_0[2 * v10 + 1], pParty->field_3C.field_0[2 * v10]) >= (signed __int64)pParty->uTimePlayed ) + { + v13 = 0; + } + else + { + v12 = v10; + v13 = 0; + pParty->field_75A[v12] = 0; + *(_QWORD *)v11 = (signed __int64)((double)(309657600 * (pParty->uCurrentMonth + 12i64 * pParty->uCurrentYear - 14015)) * 0.033333335); + v14 = rand() % 258; + v15 = window_SpeakInHouse; + pParty->field_750[v12] = v14 + 1; + v16 = (int)((char *)v15->ptr_1C - 102); + if ( v16 ) + { + v17 = v16 - 1; + if ( v17 ) + { + v18 = v17 - 1; + if ( v18 ) + { + v19 = v18 - 1; + if ( v19 ) + { + if ( v19 == 1 ) + { + while ( 1 ) + { + v20 = pParty->field_750[v12]; + if ( (unsigned __int16)v20 < 0x73u || (unsigned __int16)v20 > 0x84u ) + { + if ( ((unsigned __int16)v20 < 0xE8u || (unsigned __int16)v20 > 0xF9u) + && ((unsigned __int16)v20 < 0x85u || (unsigned __int16)v20 > 0x96u) + && ((unsigned __int16)v20 < 0x97u || (unsigned __int16)v20 > 0xBAu) + && ((unsigned __int16)v20 < 0xBEu || (unsigned __int16)v20 > 0xC0u) + && ((unsigned __int16)v20 < 0xC4u || (unsigned __int16)v20 > 0xC6u) + && ((unsigned __int16)v20 < 0x2Bu || (unsigned __int16)v20 > 0x2Du) + && ((unsigned __int16)v20 < 0x6Du || (unsigned __int16)v20 > 0x6Fu) + && ((unsigned __int16)v20 < 0x46u || (unsigned __int16)v20 > 0x48u) + && ((unsigned __int16)v20 < 0x100u || (unsigned __int16)v20 > 0x102u) + && ((unsigned __int16)v20 < 0xD9u || (unsigned __int16)v20 > 0xDBu) + && ((unsigned __int16)v20 < 0xC7u || (unsigned __int16)v20 > 0xC9u) + && ((unsigned __int16)v20 < 0xE5u || (unsigned __int16)v20 > 0xE7u) + && ((unsigned __int16)v20 < 0xDFu || (unsigned __int16)v20 > 0xE1u) + && ((unsigned __int16)v20 < 0x5Bu || (unsigned __int16)v20 > 0x5Du) + && ((unsigned __int16)v20 < 0x49u || (unsigned __int16)v20 > 0x4Bu) + && ((unsigned __int16)v20 < 0xFDu || (unsigned __int16)v20 > 0xFFu) + && ((unsigned __int16)v20 < 0x61u || (unsigned __int16)v20 > 0x63u) + && ((unsigned __int16)v20 < 0x10u || (unsigned __int16)v20 > 0x12u) ) + break; + } + pParty->field_750[v12] = rand() % 258 + 1; + } + } + } + else + { + while ( 1 ) + { + v21 = pParty->field_750[v12]; + if ( (unsigned __int16)v21 < 0x73u || (unsigned __int16)v21 > 0x84u ) + { + if ( ((unsigned __int16)v21 < 0xE8u || (unsigned __int16)v21 > 0xF9u) + && ((unsigned __int16)v21 < 0x85u || (unsigned __int16)v21 > 0x96u) + && ((unsigned __int16)v21 < 0x97u || (unsigned __int16)v21 > 0xBAu) + && ((unsigned __int16)v21 < 0xBEu || (unsigned __int16)v21 > 0xC0u) + && ((unsigned __int16)v21 < 0xC4u || (unsigned __int16)v21 > 0xC6u) + && ((unsigned __int16)v21 < 0x2Bu || (unsigned __int16)v21 > 0x2Du) + && ((unsigned __int16)v21 < 0x5Eu || (unsigned __int16)v21 > 0x60u) + && ((unsigned __int16)v21 < 0x43u || (unsigned __int16)v21 > 0x45u) + && ((unsigned __int16)v21 < 0x4Fu || (unsigned __int16)v21 > 0x51u) + && ((unsigned __int16)v21 < 0xC1u || (unsigned __int16)v21 > 0xC3u) + && ((unsigned __int16)v21 < 0x13u || (unsigned __int16)v21 > 0x15u) + && ((unsigned __int16)v21 < 0xFDu || (unsigned __int16)v21 > 0xFFu) + && ((unsigned __int16)v21 < 0x61u || (unsigned __int16)v21 > 0x63u) + && ((unsigned __int16)v21 < 0x6Au || (unsigned __int16)v21 > 0x6Cu) ) + break; + } + pParty->field_750[v12] = rand() % 258 + 1; + } + } + } + else + { + while ( 1 ) + { + v22 = pParty->field_750[v12]; + if ( (unsigned __int16)v22 < 0x73u || (unsigned __int16)v22 > 0x84u ) + { + if ( ((unsigned __int16)v22 < 0xE8u || (unsigned __int16)v22 > 0xF9u) + && ((unsigned __int16)v22 < 0x85u || (unsigned __int16)v22 > 0x96u) + && ((unsigned __int16)v22 < 0x97u || (unsigned __int16)v22 > 0xBAu) + && ((unsigned __int16)v22 < 0xBEu || (unsigned __int16)v22 > 0xC0u) + && ((unsigned __int16)v22 < 0xC4u || (unsigned __int16)v22 > 0xC6u) + && ((unsigned __int16)v22 < 0x2Bu || (unsigned __int16)v22 > 0x2Du) + && ((unsigned __int16)v22 < 0x31u || (unsigned __int16)v22 > 0x33u) + && ((unsigned __int16)v22 < 0x34u || (unsigned __int16)v22 > 0x36u) + && ((unsigned __int16)v22 < 0xFDu || (unsigned __int16)v22 > 0xFFu) + && ((unsigned __int16)v22 < 0x61u || (unsigned __int16)v22 > 0x63u) + && ((unsigned __int16)v22 < 0x1Cu || (unsigned __int16)v22 > 0x1Eu) ) + break; + } + pParty->field_750[v12] = rand() % 258 + 1; + } + } + } + else + { + while ( 1 ) + { + v23 = pParty->field_750[v12]; + if ( (unsigned __int16)v23 < 0x73u || (unsigned __int16)v23 > 0x84u ) + { + if ( ((unsigned __int16)v23 < 0xE8u || (unsigned __int16)v23 > 0xF9u) + && ((unsigned __int16)v23 < 0x85u || (unsigned __int16)v23 > 0x96u) + && ((unsigned __int16)v23 < 0x97u || (unsigned __int16)v23 > 0xBAu) + && ((unsigned __int16)v23 < 0xBEu || (unsigned __int16)v23 > 0xC0u) + && ((unsigned __int16)v23 < 0xC4u || (unsigned __int16)v23 > 0xC6u) + && ((unsigned __int16)v23 < 0x2Bu || (unsigned __int16)v23 > 0x2Du) + && ((unsigned __int16)v23 < 0x52u || (unsigned __int16)v23 > 0x54u) + && ((unsigned __int16)v23 < 4u || (unsigned __int16)v23 > 6u) + && ((unsigned __int16)v23 < 0x37u || (unsigned __int16)v23 > 0x39u) + && ((unsigned __int16)v23 < 0x3Au || (unsigned __int16)v23 > 0x3Cu) + && ((unsigned __int16)v23 < 0x3Du || (unsigned __int16)v23 > 0x3Fu) + && ((unsigned __int16)v23 < 0xFDu || (unsigned __int16)v23 > 0xFFu) + && ((unsigned __int16)v23 < 0x61u || (unsigned __int16)v23 > 0x63u) + && ((unsigned __int16)v23 < 0xCDu || (unsigned __int16)v23 > 0xCFu) ) + break; + } + pParty->field_750[v12] = rand() % 258 + 1; + } + } + } + else + { + while ( 1 ) + { + v24 = pParty->field_750[v12]; + if ( (unsigned __int16)v24 < 0x73u || (unsigned __int16)v24 > 0x84u ) + { + if ( ((unsigned __int16)v24 < 0xEBu || (unsigned __int16)v24 > 0xFCu) + && ((unsigned __int16)v24 < 0x85u || (unsigned __int16)v24 > 0x96u) + && ((unsigned __int16)v24 < 0x97u || (unsigned __int16)v24 > 0xBAu) + && ((unsigned __int16)v24 < 0xBEu || (unsigned __int16)v24 > 0xC0u) + && ((unsigned __int16)v24 < 0xC4u || (unsigned __int16)v24 > 0xC6u) + && ((unsigned __int16)v24 < 0x2Bu || (unsigned __int16)v24 > 0x2Du) + && ((unsigned __int16)v24 < 0xCDu || (unsigned __int16)v24 > 0xCFu) + && ((unsigned __int16)v24 < 0x5Eu || (unsigned __int16)v24 > 0x60u) + && ((unsigned __int16)v24 < 0xFDu || (unsigned __int16)v24 > 0xFFu) + && ((unsigned __int16)v24 < 0x6Du || (unsigned __int16)v24 > 0x6Fu) + && ((unsigned __int16)v24 < 0x61u || (unsigned __int16)v24 > 0x63u) ) + break; + } + pParty->field_750[v12] = rand() % 258 + 1; + } + } + v10 = v56; + } + v25 = v10; + v26 = pParty->field_750[v25]; + v27 = pParty->field_75A[v25] == v13; + word_F8B1A0 = pParty->field_750[v25]; + if ( v27 ) + { + //v1 = 0; + v27 = v26 == v13; + v29 = (int)pNPCTopics[351].pText; + if ( v27 ) + v29 = (int)pNPCTopics[353].pText; + dword_F8B1A4 = (char *)v29; + } + else + { + if ( v26 != v13 ) + { + party_finds_gold(100 * pMonsterStats->pInfos[(unsigned __int16)v26].uLevel, 0); + v28 = pParty->pPlayers; + do + { + v28->SetVariable(VAR_Award, 86); + ++v28; + } + while ( (signed int)v28 < (signed int)pParty->pHirelings ); + pParty->uNumBountiesCollected += 100 * pMonsterStats->pInfos[pParty->field_750[v25]].uLevel; + pParty->field_750[v25] = v13; + pParty->field_75A[v25] = v13; + } + //v1 = 0; + dword_F8B1A4 = pNPCTopics[352].pText; + } + } + else if ( uMessageParam == 100 ) + { + pKeyActionMap->EnterText(1, 10, v8); + } + } + } + } + */ + + +//LABEL_196: + switch ( uMessageParam ) + { + case HOUSE_DIALOGUE_LEARN_SKILLS: + { + pDialogueWindow->eWindowType = WINDOW_MainMenu; + UI_CreateEndConversationButton(); + FillAviableSkillsToTeach(in_current_building_type); + break; + } + case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN: + { + pDialogueWindow->eWindowType = WINDOW_MainMenu; + UI_CreateEndConversationButton(); + sub_4B3A72(in_current_building_type); + break; + } + case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES: + case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_VICTORY_CONDITIONS: + { + dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam; + break; + } + case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT: + { + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_PlayArcomage; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v1; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = v1; + ++pMessageQueue_50CBD0->uNumMessages; + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_PlayArcomage, 0, 0); + dialog_menu_id = HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT; + break; + } + case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: + case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: + { + if ( pParty->field_3C.field_50[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed ) + { + GenerateStandartShopItems(); + GenerateSpecialShopItems(); + pParty->field_3C.field_50[window_SpeakInHouse->par1C] = pParty->uTimePlayed + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) * 0.033333335); + } + if ( uMessageParam == HOUSE_DIALOGUE_SHOP_BUY_STANDARD ) + { + if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) + { + for ( v43 = 0; v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType]; ++v43 ) + { + if ( pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v43].uItemID ) + { + v46 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v43].uItemID].pIconName, TEXTURE_16BIT_PALETTE); + ItemsInShopTexture[v43] = &pIcons_LOD->pTextures[v46]; + } + } + } + if ( in_current_building_type == BildingType_WeaponShop ) + { + v48 = 0; + if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) + { + do + { + if ( pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v48].uItemID) + word_F8B158[v48] = rand() % (300 - ItemsInShopTexture[v48]->uTextureHeight); + ++v48; + } + while ( v48 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ); + } + } + } + if ( uMessageParam == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL ) + { + if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) + { + for ( v43 = 0; v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType]; ++v43 ) + { + if ( pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v43].uItemID ) + { + v51 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v43].uItemID].pIconName, TEXTURE_16BIT_PALETTE); + ItemsInShopTexture[v43] = &pIcons_LOD->pTextures[v51]; + } + } + } + if ( in_current_building_type == BildingType_WeaponShop ) + { + v53 = 0; + if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType] ) + { + do + { + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v53].uItemID) + word_F8B158[v53] = rand() % (300 - ItemsInShopTexture[v53]->uTextureHeight); + ++v53; + } + while ( v53 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType ] ); + } + } + } + break; + } + case HOUSE_DIALOGUE_SHOP_SELL: + case HOUSE_DIALOGUE_SHOP_IDENTIFY: + case HOUSE_DIALOGUE_SHOP_REPAIR: + { + dialog_menu_id = (HOUSE_DIALOGUE_MENU)uMessageParam; + sub_421B2C_PlaceInInventory_or_DropPickedItem(); + break; + } + case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: + { + pDialogueWindow->eWindowType = WINDOW_MainMenu; + UI_CreateEndConversationButton(); + sub_4B3AD4(in_current_building_type); + break; + } + default: + { + if( uMessageParam >= HOUSE_DIALOGUE_36 && uMessageParam <= HOUSE_DIALOGUE_GUILD_LEARN_SKILL ) + { + //v35 = pPlayers[uActiveCharacter]; + //v36 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)v8->ptr_1C] * 500.0); + v36 = (signed __int64)(p2DEvents[(unsigned int)v8->ptr_1C - 1].flt_24 * 500.0); + v37 = v36 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; + if ( v37 < v36 / 3 ) + v37 = v36 / 3; + //if (false) + if(byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][uMessageParam-36]) + //if ( *(&byte_4ED94C[37 * v35->uClass] + v55) ) + { + //v38 = (int)(&pPlayers[uActiveCharacter]->uIntelligence + uMessageParam); + if ( !pPlayers[uActiveCharacter]->pActiveSkills[uMessageParam - 36] ) + { + if ( pParty->uNumGold < v37 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); + if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern ) + v39 = 4; + else + v39 = 2; + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v39); + } + else + { + Party::TakeGold(v37); + dword_F8B1E4 = 1; + pPlayers[uActiveCharacter]->pActiveSkills[uMessageParam - 36] = 1; + pPlayers[uActiveCharacter]->PlaySound(SPEECH_78, 0); + } + } + } + } + break; + } + } + /* + if ( uMessageParam != 95 && uMessageParam != 2 ) + { + if ( uMessageParam == 3 ) + { + dialog_menu_id = 3; + } + else + { + if ( uMessageParam == 4 ) + { + dialog_menu_id = 4; + } + else + { + if ( uMessageParam != 5 ) + { + if ( uMessageParam > 35 ) + { + if ( uMessageParam <= 72 ) + { + v35 = pPlayers[uActiveCharacter]; + //v36 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)v8->ptr_1C] * 500.0); + v36 = (signed __int64)(p2DEvents[(unsigned int)v8->ptr_1C - 1].flt_24 * 500.0); + v37 = v36 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; + if ( v37 < v36 / 3 ) + v37 = v36 / 3; + + __debugbreak(); + //pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23] + // or + //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36] + // or + //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1] + + if (false) + //if ( *(&byte_4ED94C[37 * v35->uClass] + v55) ) + { + v38 = (int)(&v35->uIntelligence + uMessageParam); + if ( !*(short *)v38 ) + { + if ( pParty->uNumGold < v37 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); + if ( in_current_building_type == BildingType_Training || in_current_building_type == BildingType_Tavern ) + v39 = 4; + else + v39 = 2; + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, v39); + } + else + { + Party::TakeGold(v37); + dword_F8B1E4 = 1; + *(short *)v38 = 1; + v35->PlaySound(SPEECH_78, 0); + } + } + } + } + else + { + if ( uMessageParam == 94 ) + { + pDialogueWindow->eWindowType = WINDOW_MainMenu; + UI_CreateEndConversationButton(); + sub_4B3AD4(in_current_building_type); + } + } + } + return; + } + dialog_menu_id = 5; + } + } + sub_421B2C_PlaceInInventory_or_DropPickedItem(); + return; + } + if ( pParty->field_3C.field_50[(unsigned int)v8->ptr_1C] < (signed __int64)pParty->uTimePlayed ) + { + GenerateStandartShopItems(); + GenerateSpecialShopItems(); + v8 = window_SpeakInHouse; + v40 = window_SpeakInHouse->par1C; + //v3 = dword_F8B198; + v41 = pParty->uTimePlayed + //+ (signed __int64)((double)(11059200 * (signed int)p2DEvents_minus1[26 * (unsigned int)ptr_507BC0->ptr_1C]) + + (signed __int64)((double)(11059200 * (signed int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].field_1C) + * 0.033333335); + pParty->field_3C.field_50[v40] = v41; + + } + v42 = v8->ptr_1C; + v43 = 0; + //v44 = p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]; + v44 = p2DEvents[(unsigned int)v8->ptr_1C - 1].uType; + if ( uMessageParam == 2 ) + { + if ( uItemsAmountPerShopType[v44] ) + { + do + { + v45 = pParty->StandartItemsInShops[(int)v42][v43].uItemID; + if ( v45 ) + { + v46 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v45].pIconName, TEXTURE_16BIT_PALETTE); + //v3 = dword_F8B198; + v8 = window_SpeakInHouse; + ItemsInShopTexture[v43] = &pIcons_LOD->pTextures[v46]; + } + v42 = v8->ptr_1C; + ++v43; + } + //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); + while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ); + } + if ( in_current_building_type == BildingType_WeaponShop ) + { + v47 = v8->ptr_1C; + v48 = 0; + //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ) + if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ) + { + do + { + // if ( pParty->field_777C[9 * (v48 + 12 * (int)v47)] ) + if ( pParty->StandartItemsInShops[(int)v47][v48].uItemID); + { + v49 = rand(); + v8 = window_SpeakInHouse; + word_F8B158[v48] = v49 % (300 - ItemsInShopTexture[v48]->uTextureHeight); + } + v47 = v8->ptr_1C; + ++v48; + } + //while ( v48 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); + while ( v48 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ); + } + } + } + if ( uMessageParam == 95 ) + { + if ( uItemsAmountPerShopType[v44] ) + { + do + { + //v50 = pParty->field_C59C[9 * (v43 + 12 * (int)v42) + 724]; + v50=pParty->SpecialItemsInShops[(unsigned int)v42][(signed int)v43].uItemID; + if ( v50 ) + { + v51 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v50].pIconName, TEXTURE_16BIT_PALETTE); + //v3 = dword_F8B198; + v8 = window_SpeakInHouse; + ItemsInShopTexture[v43] = &pIcons_LOD->pTextures[v51]; + } + v42 = v8->ptr_1C; + ++v43; + } + //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); + while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ); + } + if ( in_current_building_type == BildingType_WeaponShop ) + { + v52 = v8->ptr_1C; + v53 = 0; + //if ( _4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ) + if ( uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ) + { + do + { + // if ( pParty->field_C59C[9 * (v53 + 12 * (int)v52) + 724] ) + if (pParty->SpecialItemsInShops[(unsigned int)v52][v53].uItemID) + { + v54 = rand(); + v8 = window_SpeakInHouse; + word_F8B158[v53] = v54 % (300 - ItemsInShopTexture[v53]->uTextureHeight); + } + v52 = v8->ptr_1C; + ++v53; + } + //while ( v53 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); + while ( v53 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType ] ); + } + } + } +*/ +} + + + +//----- (004B6943) -------------------------------------------------------- +void __cdecl TravelByTransport() +{ + GUIWindow *v0; // ebx@1 + Player *v1; // esi@1 + signed int v2; // edi@1 + unsigned int v3; // eax@1 + signed int v4; // ebx@1 + stru365_travel_info *v5; // esi@7 + //int v6; // eax@9 + //int v7; // eax@9 + //int v8; // eax@12 + //int v9; // edi@12 + //int v10; // edx@12 + int v11; // ecx@12 + signed int v12; // esi@13 + signed int v13; // edi@14 + DWORD v14; // eax@26 + DWORD v15; // edi@26 + GUIWindow *v16; // ebx@36 + int v17; // esi@36 + int v18; // eax@36 + int v19; // ecx@36 + int v20; // esi@36 + int v21; // eax@36 + void *v22; // eax@39 + int v23; // esi@39 + GUIButton *v24; // ebx@39 + signed int v25; // eax@41 + //int v26; // esi@44 + //const char *v27; // eax@46 + char *v28; // eax@62 + int v29; // eax@62 + unsigned int v30; // ecx@62 + char *v31; // eax@63 + MapInfo v32; // [sp-3Ch] [bp-2CCh]@62 + /*int v33; // [sp-38h] [bp-2C8h]@62 + int v34; // [sp-34h] [bp-2C4h]@62 + int v35; // [sp-30h] [bp-2C0h]@62 + int v36; // [sp-2Ch] [bp-2BCh]@62 + int v37; // [sp-28h] [bp-2B8h]@62 + int v38; // [sp-24h] [bp-2B4h]@62 + int v39; // [sp-20h] [bp-2B0h]@62 + int v40; // [sp-1Ch] [bp-2ACh]@62 + int v41; // [sp-18h] [bp-2A8h]@62 + int v42; // [sp-14h] [bp-2A4h]@62 + char *v43; // [sp-10h] [bp-2A0h]@62 + char *v44; // [sp-Ch] [bp-29Ch]@62 + unsigned int v45; // [sp-8h] [bp-298h]@62 + char *v46; // [sp-4h] [bp-294h]@62 + const char *v47[5]; // [sp+0h] [bp-290h]@7*/ + char v48[5][100]; // [sp+14h] [bp-27Ch]@37 + //char v49[100]; // [sp+78h] [bp-218h]@68 + //char v50[100]; // [sp+DCh] [bp-1B4h]@68 + //char v51[100]; // [sp+140h] [bp-150h]@68 + //char Dest[100]; // [sp+1A4h] [bp-ECh]@36 + GUIWindow v53; // [sp+208h] [bp-88h]@1 + int v54; // [sp+25Ch] [bp-34h]@36 + int v55; // [sp+260h] [bp-30h]@36 + //unsigned int v56; // [sp+264h] [bp-2Ch]@1 + //int v57; // [sp+268h] [bp-28h]@1 + int v58; // [sp+26Ch] [bp-24h]@36 + //GUIWindow *v59; // [sp+270h] [bp-20h]@1 + unsigned int v60; // [sp+274h] [bp-1Ch]@36 + //Player *v61; // [sp+278h] [bp-18h]@1 + int v62; // [sp+27Ch] [bp-14h]@36 + int v63; // [sp+280h] [bp-10h]@14 + char *a1; // [sp+284h] [bp-Ch]@37 + unsigned int s1; // [sp+288h] [bp-8h]@1 + int v66; // [sp+28Ch] [bp-4h]@48 + + v0 = window_SpeakInHouse; + memcpy(&v53, window_SpeakInHouse, sizeof(v53)); + v2 = 255; + //v61 = pPlayers[uActiveCharacter]; + v1 = pPlayers[uActiveCharacter]; + v53.uFrameX = 483; + v53.uFrameWidth = 148; + v53.uFrameZ = 334; + auto color_default = TargetColor(255, 255, 255); + auto color_selected = TargetColor(255, 255, 155); + v3 = 52 * (unsigned int)v0->ptr_1C; + //v59 = (GUIWindow *)((((p2DEvents_minus1___00[v3 / 2] != 27) - 1) & 0xFFFFFFE7) + 50); + //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BildingType_Stables) - 1) & 0xFFFFFFE7) + 50); + //v4 = (signed __int64)((double)(signed int)v59 * p2DEvents_minus1__20[v3 / 4]); + + v4 = p2DEvents[(unsigned int)v0->ptr_1C - 1].uType == BildingType_Stables ? 25 : 50; + v4 *= p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier; + + s1 = v4 * (100 - v1->GetMerchant()) / 100; + if ( (signed int)s1 < v4 / 3 ) + s1 = v4 / 3; + if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN) + { + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v16 = pDialogueWindow; + v58 = 255; + v62 = 0; + v17 = LOBYTE(pFontArrus->uFontHeight) - 3; + //v59 = pDialogueWindow; + v54 = v17; + strcpy(v48[4], ""); + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[405], s1); // Price: %lu gold + v18 = pFontArrus->CalcTextHeight(pTmpBuf2.data(), &v53, 0, 0); + v19 = v16->pNumPresenceButton; + v20 = v18 + v17 + 146; + v21 = v16->pStartingPosActiveItem; + v63 = v20; + v55 = v20; + v60 = v21; + if ( v21 >= v21 + v19 ) + goto LABEL_71; + s1 = 2; + a1 = (char *)v48; + while ( 1 ) + { + int v47 = v60; + v22 = window_SpeakInHouse->ptr_1C; + v23 = transport_routes[(unsigned int)v22 - HOUSE_STABLES_HARMONDALE][v62]; + //v23 = (unsigned __int8)*(&_4F0D38_TravelInfo[4 * (unsigned int)v22] + v62); // negindex. actual address is around + 0x36 + //v61 = (Player *)(unsigned __int8)*(&_4F0D38_TravelInfo[4 * (unsigned int)v22] + v62); // + 0x3F for sea travels, less for land + v24 = v16->GetControl(v60); + + if (v23 != v58) + { + if (v23 >= 25) + Log::Warning(L"Transport UI: scedule overflow"); + if (s1 >= 6) + v25 = true; + else + v25 = transport_schedule[v23].pSchedule[pParty->uDaysPlayed % 7]; + } + + if (v23 != v58 && v25 && (!transport_schedule[v23].uQuestBit || _449B57_test_bit(pParty->_quest_bits, transport_schedule[v23].uQuestBit)) ) + { + v58 = v23; + if ( pDialogueWindow->pCurrentPosActiveItem == s1 ) + sprintf(a1, "\f%05d", color_selected); + else + sprintf(a1, "\f%05d", color_default); + + //v32.uRedbookTrackID = v27; + v66 = transport_schedule[v23].uTravelTime; + if ( (unsigned int)window_SpeakInHouse->ptr_1C >= HOUSE_BOATS_63 ) + { + if ( CheckHiredNPCSpeciality(Sailor) ) + v66 -= 2; + if ( CheckHiredNPCSpeciality(Navigator) ) + v66 -= 3; + if ( CheckHiredNPCSpeciality(Pirate) ) + v66 -= 2; + } + else + { + if ( CheckHiredNPCSpeciality(Horseman) ) + v66 -= 2; + } + if ( CheckHiredNPCSpeciality(Explorer) ) + --v66; + if ( v66 < 1 ) + v66 = 1; + if ( v23 != v2 ) + { + memcpy(&v32, &pMapStats->pInfos[transport_schedule[v23].uMapInfoID], 0x44u); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[404], // Time - %d days, destination %s + v66, v32.pName); + strcat(a1, pTmpBuf.data()); + v28 = a1; + a1 += 100; + ++v62; + ++s1; + strcat(v28, "\n \n"); + v24->uY = v63; + v29 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &v53, 0, 0); + v30 = v24->uY; + v24->uHeight = v29; + v2 = 255; + v24->uW = v30 + v29 - 1; + v63 += v54 + v29; + } + } + else + { + v31 = a1; + ++v62; + ++s1; + a1 += 100; + strcpy(v31, ""); + if ( v24 ) + { + v24->uW = 0; + v24->uHeight = 0; + v24->uY = 0; + } + } + ++v60; + if ( (signed int)v60 >= v16->pNumPresenceButton + v16->pStartingPosActiveItem ) + break; + //v16 = v59; + } + if ( v63 != v55 ) + { + /*v47[1] = &Dest; + v47[0] = &v51; + v46 = &v50; + v45 = (unsigned int)&v49; + v44 = &v48; + v43 = pTmpBuf2.data();*/ + sprintf(pTmpBuf.data(), "%s\n \n%s%s%s%s%s", pTmpBuf2.data(), v48[0], v48[1], v48[2], v48[3], v48[4]); + v53.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3u); + } + else + { +LABEL_71: + v53.DrawTitleText(pFontArrus, 0, (174 - pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[561], &v53, 0, 0)) / 2 + 138, + color_default, pGlobalTXT_LocalizationStrings[561], 3); + pAudioPlayer->StopChannels(-1, -1); + } + } + } + else + { + if ( dialog_menu_id >= HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1 && dialog_menu_id <= HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_4 ) + { + if ( pParty->uNumGold < s1 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Greeting_2); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + + Party::TakeGold(s1); + + v5 = &transport_schedule[transport_routes[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_STABLES_HARMONDALE][dialog_menu_id - HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1]]; + if ( v5->pSchedule[pParty->uDaysPlayed % 7] ) + { + if ( _stricmp(pCurrentMapName.data(), pMapStats->pInfos[v5->uMapInfoID].pFilename) ) + { + SaveGame(1, 0); + strcpy(pCurrentMapName.data(), pMapStats->pInfos[v5->uMapInfoID].pFilename); + + dword_6BE364_game_settings_1 |= 1u; + _5B65B8_npcdata_hiword_house_or_other = 0; + dword_5B65BC = 0; + _5B65B4_npcdata_loword_house_or_other = v5->arrival_rot_y; + v11 = *((int *)v5 + 3); + uGameState = GAME_STATE_2; + _5B65A8_npcdata_uflags_or_other = v11; + _5B65AC_npcdata_fame_or_other = v5->arrival_y; + _5B65B0_npcdata_rep_or_other = v5->arrival_z; + dword_5B65C0 = v11 | v5->arrival_y | v5->arrival_z | v5->arrival_rot_y; + } + else + { + pIndoorCamera->sRotationY = 0; + pParty->uFlags |= 2u; + pParty->vPosition.x = v5->arrival_x; + pParty->vPosition.y = v5->arrival_y; + pParty->vPosition.z = v5->arrival_z; + pParty->uFallStartY = pParty->vPosition.z; + pParty->sRotationX = 0; + pParty->sRotationY = v5->arrival_rot_y; + } + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); + v12 = v5->uTravelTime; + int _v47; + if ( (signed int)window_SpeakInHouse->ptr_1C >= 63 ) + { + v63 = SPEECH_SetSail; + v13 = 2500; + if ( CheckHiredNPCSpeciality(Sailor) ) + v12 -= 2; + if ( CheckHiredNPCSpeciality(Navigator) ) + v12 -= 3; + //_v47 = 45; + if ( CheckHiredNPCSpeciality(Pirate) ) + v12 -= 2; + } + else + { + v63 = SPEECH_CarriageReady; + v13 = 1500; + //_v47 = 35; + if ( CheckHiredNPCSpeciality(Horseman) ) + v12 -= 2; + } + if ( CheckHiredNPCSpeciality(Explorer) ) + --v12; + if ( v12 < 1 ) + v12 = 1; + RestAndHeal(1440 * v12); + v1->PlaySound((PlayerSpeech)v63, 0); + v14 = GetTickCount(); + v15 = v14 + v13; + if ( v15 < v14 ) + v15 = v14; + while ( GetTickCount() < v15 ) + sqrt(3.1415926); + while ( sub_4BD8B5() ) + ; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 0, 0); + return; + } + else + { + dialog_menu_id = HOUSE_DIALOGUE_MAIN; + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + } + } + } +} + + + + + + +//----- (004B68EA) -------------------------------------------------------- +bool __fastcall IsTravelAvailable(int a1) +{ + for (uint i = 0; i < 4; ++i) + { + uint route = transport_routes[a1][i]; + if (transport_schedule[route].pSchedule[pParty->uDaysPlayed % 7]) + { + if (!transport_schedule[route].uQuestBit || _449B57_test_bit(pParty->_quest_bits, transport_schedule[route].uQuestBit)) + return true; + } + } + return false; +} + + + +//----- (004B7911) -------------------------------------------------------- +void __cdecl TownHallDialog() +{ + GUIWindow *v0; // eax@4 + int v1; // eax@10 + int v2; // esi@10 + GUIFont *v3; // ST20_4@20 + int v4; // eax@20 + MonsterInfo *v5; // edi@21 + unsigned int v6; // ST20_4@21 + char *v7; // ST1C_4@21 + unsigned int v8; // eax@21 + int v9; // esi@21 + char *v10; // eax@23 + signed int v11; // ebx@24 + signed int i; // esi@26 + int v13; // eax@27 + GUIWindow *v14; // ecx@28 + __int64 v15; // qax@28 + signed int v16; // ebx@28 + int v17; // ebx@28 + unsigned __int8 v18; // sf@28 + char **v19; // edi@29 + GUIButton *v20; // eax@30 + GUIButton *v21; // esi@30 + int v22; // eax@30 + unsigned int v23; // ecx@30 + unsigned __int16 v24; // ax@30 + GUIWindow a1; // [sp+Ch] [bp-110h]@21 + GUIWindow w; // [sp+60h] [bp-BCh]@21 + GUIWindow _this; // [sp+B4h] [bp-68h]@1 + int v28; // [sp+108h] [bp-14h]@1 + int v29; // [sp+10Ch] [bp-10h]@28 + int v30; // [sp+110h] [bp-Ch]@1 + int v31; // [sp+114h] [bp-8h]@29 + GUIFont *pOutString; // [sp+118h] [bp-4h]@21 + + memcpy(&_this, window_SpeakInHouse, sizeof(_this)); + _this.uFrameX = 483; + _this.uFrameWidth = 148; + _this.uFrameZ = 334; + v28 = TargetColor(0xFFu, 0xFFu, 0xFFu); + v30 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine); + _this.DrawTitleText(pFontArrus, 0, 0x104u, v30, pTmpBuf.data(), 3u); + switch(dialog_menu_id) + { + case HOUSE_DIALOGUE_MAIN: + { + v11 = 1; + pOutString = 0; + pShopOptions[0] = pGlobalTXT_LocalizationStrings[604]; + if ( pParty->uFine ) + { + pShopOptions[1] = pGlobalTXT_LocalizationStrings[603]; + v11 = 2; + } + for ( i = 0; i < v11; ++i ) + { + v13 = pFontArrus->CalcTextHeight(pShopOptions[i], &_this, 0, 0); + pOutString = (GUIFont *)((char *)pOutString + v13); + } + v29 = (100 - (signed int)pOutString) / v11; + v14 = pDialogueWindow; + v15 = 80 - v11 * (100 - (signed int)pOutString) / v11 - (signed int)pOutString; + v16 = v15 - HIDWORD(v15); + LODWORD(v15) = pDialogueWindow->pStartingPosActiveItem; + HIDWORD(v15) = v15 + pDialogueWindow->pNumPresenceButton; + v17 = (v16 >> 1) - v29 / 2 + 158; + v18 = -pDialogueWindow->pNumPresenceButton < 0; + pOutString = (GUIFont *)pDialogueWindow->pStartingPosActiveItem; + if ( v18 ^ __OFSUB__((int)v15, HIDWORD(v15)) ) + { + v31 = 2; + v19 = pShopOptions.data(); + do + { + v20 = v14->GetControl((unsigned int)pOutString); + v21 = v20; + v20->uY = v29 + v17; + v22 = pFontArrus->CalcTextHeight(*v19, &_this, 0, 0); + v23 = v21->uY; + v21->uHeight = v22; + v17 = v23 + v22 - 1; + v21->uW = v17; + v24 = v30; + if ( pDialogueWindow->pCurrentPosActiveItem != v31 ) + v24 = v28; + _this.DrawTitleText(pFontArrus, 0, v23, v24, *v19, 3u); + v14 = pDialogueWindow; + ++v31; + ++v19; + pOutString = (GUIFont *)((char *)pOutString + 1); + } + while ( (signed int)pOutString < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + } + break; + } + + case HOUSE_DIALOGUE_TOWNHALL_99: + { + v5 = &pMonsterStats->pInfos[word_F8B1A0]; + v6 = TargetColor(0xFFu, 0xFFu, 0xFFu); + v7 = v5->pName; + v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + sprintf(pTmpBuf.data(), "\f%05d%s\f%05d", v8, v7, v6); + sprintf(pTmpBuf2.data(), dword_F8B1A4, pTmpBuf.data(), 100 * v5->uLevel); + current_npc_text = pTmpBuf2.data(); + memcpy(&a1, pDialogueWindow, sizeof(a1)); + w.uFrameWidth = 458; + w.uFrameZ = 457; + pOutString = pFontArrus; + v9 = pFontArrus->CalcTextHeight(pTmpBuf2.data(), &w, 13, 0) + 7; + if ( 352 - v9 < 8 ) + { + pOutString = pFontCreate; + v9 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; + } + + auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather); + pRenderer->_4A6A68(8u, 352 - v9, pTex, pTex->uTextureHeight - v9); + pRenderer->DrawTextureIndexed(8u, 347 - v9, pTexture_591428); + v10 = FitTextInAWindow(current_npc_text, pOutString, &w, 0xDu, 0); + a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0); + break; + } + case HOUSE_DIALOGUE_TOWNHALL_100: + { + v0 = window_SpeakInHouse; + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) + { + sprintfex(pTmpBuf.data(), "%s\n%s", pGlobalTXT_LocalizationStrings[606], pGlobalTXT_LocalizationStrings[112]); // "Pay" "How Much?" + _this.DrawTitleText(pFontArrus, 0, 0x92u, v30, pTmpBuf.data(), 3u); + _this.DrawTitleText(pFontArrus, 0, 0xBAu, v28, (const char *)pKeyActionMap->pPressedKeysBuffer, 3); + v3 = pFontArrus; + v4 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer); + _this.DrawFlashingInputCursor(v4 / 2 + 80, 185, v3); + return; + } + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) + { + v1 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); + v2 = v1; + if ( v1 <= 0 ) + { + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + if ( v1 > pParty->uNumGold ) + { + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); + v2 = pParty->uNumGold; + } + if ( v2 > pParty->uFine ) + v2 = pParty->uFine; + Party::TakeGold(v2); + pParty->uFine -= v2; + if ( pParty->uFine < 0 ) + pParty->uFine = 0; + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0); + v0 = window_SpeakInHouse; + } + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED) + { + v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + } + break; + } + default: + { + break; + } + } + return; +} + + + +//----- (004B7D7E) -------------------------------------------------------- +void __cdecl BankDialog() +{ + GUIWindow *v0; // eax@4 + //int v1; // ecx@5 + int v2; // eax@6 + unsigned int v3; // esi@6 + GUIFont *v4; // ST10_4@12 + int v5; // eax@12 + int v6; // eax@19 + unsigned int v7; // esi@19 + unsigned __int16 v8; // ax@27 + unsigned __int16 v9; // ax@29 + char *v10; // [sp-8h] [bp-70h]@11 + char *v11; // [sp-4h] [bp-6Ch]@11 + GUIWindow _this; // [sp+Ch] [bp-5Ch]@1 + __int16 v13[2]; // [sp+60h] [bp-8h]@1 + __int16 v14[2]; // [sp+64h] [bp-4h]@1 + + memcpy(&_this, window_SpeakInHouse, sizeof(_this)); + _this.uFrameX = 483; + _this.uFrameWidth = 148; + _this.uFrameZ = 334; + *(int *)v13 = TargetColor(0xFFu, 0xFFu, 0xFFu); + *(int *)v14 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[25], pParty->uNumGoldInBank); + _this.DrawTitleText(pFontArrus, 0, 0xDCu, v14[0], pTmpBuf.data(), 3u); + switch(dialog_menu_id) + { + case HOUSE_DIALOGUE_MAIN: + { + v8 = v14[0]; + if ( pDialogueWindow->pCurrentPosActiveItem != 2 ) + v8 = v13[0]; + _this.DrawTitleText(pFontArrus, 0, 0x92u, v8, pGlobalTXT_LocalizationStrings[60], 3u); + v9 = v14[0]; + if ( pDialogueWindow->pCurrentPosActiveItem != 3 ) + v9 = v13[0]; + _this.DrawTitleText(pFontArrus, 0, 0xB0u, v9, pGlobalTXT_LocalizationStrings[244], 3u); + break; + } + case HOUSE_DIALOGUE_BANK_7: + { + v0 = window_SpeakInHouse; + if ( window_SpeakInHouse->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS) + { + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) + { + v6 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); + v7 = v6; + if ( !v6 ) + { + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + if ( v6 > pParty->uNumGold ) + { + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); + v7 = pParty->uNumGold; + } + if ( v7 ) + { + Party::TakeGold(v7); + pParty->uNumGoldInBank += v7; + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_81, 0); + } + v0 = window_SpeakInHouse; + v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + if (window_SpeakInHouse->receives_keyboard_input_2 != WINDOW_INPUT_CANCELLED) + return; + v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + v11 = pGlobalTXT_LocalizationStrings[112]; + v10 = pGlobalTXT_LocalizationStrings[60]; + sprintf(pTmpBuf.data(), "%s\n%s", v10, v11); + _this.DrawTitleText(pFontArrus, 0, 0x92u, v14[0], pTmpBuf.data(), 3u); + _this.DrawTitleText(pFontArrus, 0, 0xBAu, v13[0], (const char *)pKeyActionMap->pPressedKeysBuffer, 3u); + v4 = pFontArrus; + v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer); + _this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4); + break; + } + + case HOUSE_DIALOGUE_BANK_8: + { + v0 = window_SpeakInHouse; + if ( window_SpeakInHouse->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS) + { + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) + { + window_SpeakInHouse->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + v2 = atoi((const char *)pKeyActionMap->pPressedKeysBuffer); + v3 = v2; + if ( v2 ) + { + if ( v2 > pParty->uNumGoldInBank ) + { + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); + v3 = pParty->uNumGoldInBank; + } + if ( v3 ) + { + Party::SetGold(pParty->uNumGold + v3); + pParty->uNumGoldInBank -= v3; + } + } + v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + if ( window_SpeakInHouse->receives_keyboard_input_2 != WINDOW_INPUT_CANCELLED) + return; + v0->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + v11 = pGlobalTXT_LocalizationStrings[112]; + v10 = pGlobalTXT_LocalizationStrings[244]; + sprintfex(pTmpBuf.data(), "%s\n%s", v10, v11); + _this.DrawTitleText(pFontArrus, 0, 0x92u, v14[0], pTmpBuf.data(), 3u); + _this.DrawTitleText(pFontArrus, 0, 0xBAu, v13[0], (const char *)pKeyActionMap->pPressedKeysBuffer, 3u); + v4 = pFontArrus; + v5 = pFontArrus->GetLineWidth((const char *)pKeyActionMap->pPressedKeysBuffer); + _this.DrawFlashingInputCursor(v5 / 2 + 80, 185, v4); + return; + break; + } + + default: + { + break; + } + } +} +// F8B19C: using guessed type int dword_F8B19C; + +//----- (004B8285) -------------------------------------------------------- +void __cdecl TavernDialog() +{ + int v0; + int pItemNum; + double v2; // st7@1 + signed int v3; // ebx@1 + int v4; // ecx@1 + int v5; // esi@3 + signed int v6; // edi@5 + int v7; // ecx@5 + int pNumString; // edi@16 + signed int v9; // esi@16 + unsigned int pNumActiveItem; // esi@18 + int v11; // eax@18 + unsigned int v12; // eax@19 + int v13; // eax@21 + int v14; // ecx@26 + //GUIButton *v15; // eax@28 + //GUIButton *v16; // esi@28 + int v17; // eax@28 + char *v18; // eax@30 + int v19; // eax@30 + unsigned int v20; // ecx@30 + int v21; // edx@30 + int v22; // eax@30 + unsigned __int16 v23; // ax@30 + int v24; // eax@34 + int v25; // eax@34 + char *v26; // esi@36 + int v27; // edi@46 + unsigned int pColorText; // eax@57 + signed int v31; // eax@59 + //GUIWindow *v33; // edi@64 + int v34; // eax@64 + int v35; // ecx@64 + int v36; // esi@64 + char v37; // sf@64 + GUIButton *pButton; // eax@65 + int v39; // edx@69 + int v40; // ecx@69 + int v41; // ecx@69 + int v42; // ecx@70 + unsigned int v43; // edx@70 + int v44; // edx@71 + int v45; // ecx@71 + int v46; // ecx@72 + int v47; // eax@74 + signed int v48; // edi@77 + signed int i; // esi@79 + int v50; // eax@80 + //GUIWindow *v51; // ecx@81 + _QWORD v52; // qax@81 + signed int v53; // edi@81 + int v54; // edi@81 + //GUIButton *v55; // esi@83 + const char **v56; // eax@83 + int v57; // eax@83 + unsigned int v58; // ecx@83 + //Player *v59; // edx@83 + unsigned __int16 v60; // ax@83 + int v61; // eax@99 + char *v63; // eax@99 + GUIFont *v64; // edx@99 + GUIFont *v65; // edi@100 + unsigned int v66; // [sp-10h] [bp-284h]@75 + unsigned __int16 v67; // [sp-Ch] [bp-280h]@75 + int v68; // [sp-Ch] [bp-280h]@99 + char *v69; // [sp-8h] [bp-27Ch]@75 + int v70; // [sp-8h] [bp-27Ch]@99 + unsigned int v71; // [sp-4h] [bp-278h]@75 + const char *v72; // [sp-4h] [bp-278h]@93 + unsigned int v73; // [sp-4h] [bp-278h]@99 + char pTopic1[100]; // [sp+Ch] [bp-268h]@55 + char pTopic4[100]; // [sp+70h] [bp-204h]@59 + char pTopic2[100]; // [sp+D4h] [bp-1A0h]@57 + char pTopic3[100]; // [sp+138h] [bp-13Ch]@59 + //GUIWindow v78; // [sp+19Ch] [bp-D8h]@99 + GUIWindow dialog_window; // [sp+1F0h] [bp-84h]@1 + char *Str[2]; // [sp+244h] [bp-30h]@30 + unsigned int pColorWhite; // [sp+24Ch] [bp-28h]@1 + unsigned __int8 pTopic3Height; // [sp+253h] [bp-21h]@59 + int v83; // [sp+254h] [bp-20h]@1 + int pColorYellow; // [sp+258h] [bp-1Ch]@1 + Player *pPlayer; // [sp+25Ch] [bp-18h]@1 + int all_text_height; // [sp+260h] [bp-14h]@18 + unsigned __int8 v87; // [sp+266h] [bp-Eh]@59 + unsigned __int8 pTopic2Height; // [sp+267h] [bp-Dh]@57 + int v89; // [sp+268h] [bp-Ch]@1 + unsigned int pTopic1Height; // [sp+26Fh] [bp-5h]@55 + int v91; // [sp+270h] [bp-4h]@3 + GUIFont *pOutString; + unsigned __int8 pTopic4Height; + int pTextHeight; + + pPlayer = pPlayers[uActiveCharacter]; + memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); + dialog_window.uFrameX = 483; + dialog_window.uFrameWidth = 148; + dialog_window.uFrameZ = 334; + pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu); + pColorYellow = TargetColor(0xFFu, 0xFFu, 0x9Bu); + v2 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; + *(float *)&v83 = v2; + *(float *)&v89 = v2 * v2; + v3 = (signed __int64)(*(float *)&v89 * 0.1); + pItemNum = v3 * (100 - pPlayer->GetMerchant()) / 100; + if ( pItemNum < v3 / 3 ) + pItemNum = v3 / 3; + v5 = 1; + pOutString = (GUIFont *)pItemNum; + if ( pItemNum <= 0 ) + pOutString = (GUIFont *)1; + v6 = (signed __int64)(*(float *)&v89 * *(float *)&v83 * 0.0099999998); + v7 = v6 * (100 - pPlayer->GetMerchant()) / 100; + if ( v7 < v6 / 3 ) + v7 = v6 / 3; + v83 = v7; + if ( v7 <= 0 ) + { + v7 = 1; + v83 = 1; + } + + switch(dialog_menu_id) + { + case HOUSE_DIALOGUE_MAIN: + { + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + + sprintf(pTopic1, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 2 ? pColorYellow : pColorWhite); + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[178], pOutString); // Rent room for %d gold + strcat(pTopic1, pTmpBuf2.data()); + pTopic1Height = pFontArrus->CalcTextHeight(pTopic1, &dialog_window, 0, 0); + strcat(pTopic1, "\n \n"); + + sprintf(pTopic2, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 3 ? pColorYellow : pColorWhite); + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[86], // Buy food for %d days for %d gold + (unsigned int)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier, v83); + strcat(pTopic2, pTmpBuf2.data()); + pTopic2Height = pFontArrus->CalcTextHeight(pTopic2, &dialog_window, 0, 0); + strcat(pTopic2, "\n \n"); + + sprintf(pTopic3, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 4 ? pColorYellow : pColorWhite); + strcat(pTopic3, pGlobalTXT_LocalizationStrings[160]); // Learn Skills + pTopic3Height = pFontArrus->CalcTextHeight(pTopic3, &dialog_window, 0, 0); + strcat(pTopic3, "\n \n"); + pTopic4[0] = 0; + if ( (signed int)window_SpeakInHouse->par1C >= 108 && (signed int)window_SpeakInHouse->par1C <= 120 ) + { + sprintf(pTopic4, "\f%05d", pDialogueWindow->pCurrentPosActiveItem == 5 ? pColorYellow : pColorWhite); + strcat(pTopic4, pGlobalTXT_LocalizationStrings[611]); // Play Arcomage + pTopic4Height = pFontArrus->CalcTextHeight(pTopic4, &dialog_window, 0, 0); + } + pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; + v36 = LOBYTE(pFontArrus->uFontHeight) - 3; + v37 = -pDialogueWindow->pNumPresenceButton < 0; + if ( !(v37 ^ (pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton)) ) + { + do + { + pButton = pDialogueWindow->GetControl(pNumActiveItem); + if ( pButton->msg_param == 15 ) + { + v46 = pTopic1Height; + pButton->uHeight = pTopic1Height; + pButton->uY = 146; + v41 = v46 + 145; + pButton->uW = v41; + } + else if ( pButton->msg_param == 16 ) + { + v44 = pTopic2Height; + v45 = pTopic1Height + v36 + 146; + pButton->uHeight = pTopic2Height; + pButton->uY = v45; + v41 = v45 + v44 - 1; + pButton->uW = v41; + } + else if ( pButton->msg_param == 96 ) + { + v42 = pTopic1Height + pTopic2Height + 2 * v36 + 146; + v43 = pTopic3Height; + pButton->uY = v42; + pButton->uHeight = v43; + v41 = v43 + v42 - 1; + pButton->uW = v41; + } + else if ( pButton->msg_param == 101 ) + { + v39 = pTopic1Height + 3 * v36 + pTopic4Height + pTopic2Height + 146; + v40 = pTopic4Height; + pButton->uHeight = pTopic4Height; + pButton->uY = v39; + v41 = v39 + v40 - 1; + pButton->uW = v41; + } + pNumActiveItem++; + if ( pNumActiveItem >= pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ) + { + sprintfex(pTmpBuf.data(), "%s%s%s%s", &pTopic1, &pTopic2, &pTopic3, &pTopic4); + dialog_window.DrawTitleText(pFontArrus, 0, 146, 0, pTmpBuf.data(), 3); + } + } + while ( pNumActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ); + } + break; + } + case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES: + { + pOutString = pFontArrus; + strcpy(pTmpBuf.data(), pNPCTopics[354].pText); + dialog_window.uFrameWidth = game_viewport_width; + dialog_window.uFrameZ = 452; + pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 12, 0) + 7; + if ( 352 - pTextHeight < 8 ) + { + pOutString = pFontCreate; + pTextHeight = pFontCreate->CalcTextHeight(pTmpBuf.data(), &dialog_window, 12, 0) + 7; + } + auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather); + pRenderer->_4A6A68(8, 352 - pTextHeight, pTex, pTex->uTextureHeight - pTextHeight); + pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428); + v63 = FitTextInAWindow(pTmpBuf.data(), pOutString, &dialog_window, 0xCu, 0); + window_SpeakInHouse->DrawText(pOutString, 12, 354 - pTextHeight, 0, v63, 0, 0, 0); + break; + } + case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_VICTORY_CONDITIONS: + { + strcpy(pTmpBuf.data(), pNPCTopics[(uint)window_SpeakInHouse->ptr_1C + 247].pText); + dialog_window.uFrameWidth = game_viewport_width; + dialog_window.uFrameZ = 452; + v61 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 12, 0); + pTextHeight = v61 + 7; + auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather); + pRenderer->_4A6A68(8, 352 - (v61 + 7), pTex, pTex->uTextureHeight - (v61 + 7)); + pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428); + v63 = FitTextInAWindow(pTmpBuf.data(), pFontArrus, &dialog_window, 0xCu, 0); + window_SpeakInHouse->DrawText(pFontArrus, 12, 354 - pTextHeight, 0, v63, 0, 0, 0); + break; + } + case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT: + { + if ( pArcomageGame->bGameInProgress == 1 ) + return; + if ( pArcomageGame->uGameResult ) + { + if ( pArcomageGame->uGameResult == 1 ) + v72 = pGlobalTXT_LocalizationStrings[640];// You won! + else + v72 = pGlobalTXT_LocalizationStrings[641];// You lost! + } + else + { + v72 = pGlobalTXT_LocalizationStrings[639];// A tie! + } + strcpy(pTmpBuf.data(), v72); + v66 = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, 0, v66, pColorYellow, pTmpBuf.data(), 3); + break; + } + case HOUSE_DIALOGUE_TAVERN_REST: + { + if ( pParty->uNumGold >= (unsigned int)pOutString ) + { + Party::TakeGold((unsigned int)pOutString); + v27 = (int)window_SpeakInHouse->ptr_1C;//107 + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); + dialog_menu_id = HOUSE_DIALOGUE_NULL; + sub_4BD8B5(); + sub_4B1D27(); + pVideoPlayer->Unload(); + window_SpeakInHouse->Release(); + window_SpeakInHouse = 0; + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + pMessageQueue_50CBD0->pMessages[0].eType = UIMSG_RentRoom; + pMessageQueue_50CBD0->pMessages[0].param = v27; + pMessageQueue_50CBD0->pMessages[0].field_8 = 1; + ++pMessageQueue_50CBD0->uNumMessages; + return; + } + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Goodbye); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0); + break; + } + + case HOUSE_DIALOGUE_LEARN_SKILLS: + { + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + v0 = 0; + v9 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); + pItemNum = v9 * (100 - pPlayer->GetMerchant()) / 100; + if ( pItemNum < v9 / 3 ) + pItemNum = v9 / 3; + pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; + all_text_height = 0; + if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton ) + { + do + { + v12 = pDialogueWindow->GetControl(pNumActiveItem)->msg_param - 36; + if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v12] && !pPlayer->pActiveSkills[v12] ) + { + all_text_height = pFontArrus->CalcTextHeight(pSkillNames[v12], &dialog_window, 0, 0); + v0++; + } + ++pNumActiveItem; + } + while ( pNumActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ); + if ( v0 ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pItemNum); + dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); + v91 = (149 - all_text_height) / v0; + if ( (149 - all_text_height) / v0 > 32 ) + v91 = 32; + v14 = (149 - v0 * v91 - all_text_height) / 2 - v91 / 2 + 162; + pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; + if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton ) + { + pItemNum = 2; + do + { + pButton = pDialogueWindow->GetControl(pItemNum); + v17 = pButton->msg_param - 36; + if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v17] || pPlayer->pActiveSkills[v17] ) + { + pButton->uW = 0; + pButton->uHeight = 0; + pButton->uY = 0; + } + else + { + pButton->uY = v91 + v14; + pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v17], &dialog_window, 0, 0); + pButton->uHeight = pTextHeight; + v14 = pTextHeight + pButton->uY - 1; + pButton->uW = v14; + pColorText = pColorYellow; + if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) + pColorText = pColorWhite; + dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v17], 3); + } + pNumActiveItem = pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton; + pItemNum++; + } + while ( pItemNum < pNumActiveItem ); + } + return; + } + } + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]); + strcat(pTmpBuf.data(), "\n \n"); + strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); + pTextHeight = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, pColorYellow, pTmpBuf.data(), 3); + return; + } + + case HOUSE_DIALOGUE_TAVERN_BUY_FOOD: + { + *(_QWORD *)Str = pParty->uNumFoodRations; + //if ( (double)pParty->uNumFoodRations >= p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C] ) + if ( (double)pParty->uNumFoodRations >= p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[140], 2); + if ( uActiveCharacter ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_67, 0); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0); + return; + } + if ( pParty->uNumGold >= v7 ) + { + Party::TakeGold(v7); + //pParty->uNumFoodRations = (signed __int64)p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C]; + pParty->uNumFoodRations = (signed __int64)p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Greeting_2); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); // "You don't have enough gold" + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_Goodbye); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, v5, 0); + break; + } + + case HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN: + { + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v48 = 2; + pShopOptions[0] = pGlobalTXT_LocalizationStrings[620]; + pShopOptions[1] = pGlobalTXT_LocalizationStrings[622]; + pOutString = 0; + if ( pParty->HasItem(0x28Bu) ) + { + pShopOptions[2] = pGlobalTXT_LocalizationStrings[621]; + v48 = 3; + } + for ( i = 0; i < v48; ++i ) + all_text_height = pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); + all_text_height = (174 - all_text_height) / v48; + pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; + v54 = (174 - v48 * (174 - all_text_height) / v48 - all_text_height) / 2 - (174 - all_text_height) / v48 / 2 + 138; + v37 = -pDialogueWindow->pNumPresenceButton < 0; + if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton ) + { + pItemNum = 2; + pNumString = 0; + do + { + pButton = pDialogueWindow->GetControl(pItemNum); + pButton->uY = all_text_height + v54; + pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0); + pButton->uHeight = pTextHeight; + v54 = pButton->uY + pTextHeight - 1; + pButton->uW = v54; + pColorText = pColorYellow; + if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) + pColorText = pColorWhite; + dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3); + pItemNum++; + ++pNumString; + pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; + } + while ( pItemNum < pNumActiveItem ); + } + } + break; + } + default: + { + break; + } + } +} + + +//----- (004B910F) -------------------------------------------------------- +void __cdecl WeaponShopDialog() +{ + int v0; // ebx@1 + int pNumActiveItem; // eax@6 + signed int v2; // esi@8 + ItemGen *v4; // eax@11 + char *v5; // ecx@12 + unsigned __int8 v6; // dl@13 + char *v7; // edx@14 + int v9; // ST08_4@16 + int v10; // eax@16 + signed int v11; // esi@18 + int v12; // ST08_4@21 + int v13; // eax@21 + int v14; // edi@23 + char **v15; // esi@23 + int v16; // eax@24 + //int v18; // edx@25 + int v19; // edi@25 + unsigned __int8 v20; // sf@25 + GUIButton *pButton; // esi@27 + int pNewItem; // eax@27 + unsigned int v24; // ecx@27 + int v25; // edx@27 + unsigned int pColorText; // ax@27 + signed int v27; // esi@32 + int v28; // ST08_4@36 + int v29; // eax@36 + signed int v32; // esi@41 + unsigned int v33; // esi@43 + int v34; // eax@43 + unsigned int v35; // eax@44 + int v36; // eax@46 + __int32 v37; // ecx@51 + int v40; // eax@53 + char *v41; // eax@55 + unsigned int v43; // ecx@55 + const char **v44; // edx@55 + int v45; // eax@55 + int v47; // eax@59 + const char **v48; // eax@63 + unsigned int v49; // esi@65 + Texture *v50; // eax@65 + int v51; // edi@65 + int v52; // esi@70 + Texture *v53; // ST1C_4@70 + int v54; // edi@70 + signed int v55; // ecx@73 + SHORT v56; // di@82 + bool v57; // eax@82 + const char *v58; // ecx@84 + POINT *v59; // esi@89 + LONG v60; // ecx@90 + int v61; // eax@90 + int v62; // ecx@90 + ItemGen *pItemInShop; // esi@90 + int v64; // eax@95 + int all_text_height; // esi@96 + char **v66; // edi@96 + int v67; // eax@97 + int v69; // edx@98 + int v70; // edi@98 + int v71; + const char **v72; // eax@100 + int pTextHeight; // eax@100 + unsigned int v74; // ecx@100 + int v78; // [sp-14h] [bp-10Ch]@14 + ItemGen *v79; // [sp-10h] [bp-108h]@12 + int v80; // [sp-10h] [bp-108h]@14 + void *v81; // [sp-Ch] [bp-104h]@12 + unsigned __int16 v82; // [sp-Ch] [bp-104h]@14 + int v83; // [sp-8h] [bp-100h]@11 + char *v84; // [sp-8h] [bp-100h]@14 + __int64 *v85; // [sp-4h] [bp-FCh]@11 + unsigned int v86; // [sp-4h] [bp-FCh]@14 + POINT v87; // [sp+Ch] [bp-ECh]@8 + POINT v88; // [sp+14h] [bp-E4h]@18 + POINT v89; // [sp+1Ch] [bp-DCh]@89 + POINT v90; // [sp+24h] [bp-D4h]@19 + POINT v91; // [sp+2Ch] [bp-CCh]@89 + POINT v92; // [sp+34h] [bp-C4h]@9 + POINT v93; // [sp+3Ch] [bp-BCh]@33 + POINT v94; // [sp+44h] [bp-B4h]@18 + POINT v95; // [sp+4Ch] [bp-ACh]@32 + POINT v96; // [sp+54h] [bp-A4h]@18 + POINT v97; // [sp+5Ch] [bp-9Ch]@32 + POINT a2; // [sp+64h] [bp-94h]@8 + POINT v99; // [sp+6Ch] [bp-8Ch]@32 + POINT v100; // [sp+74h] [bp-84h]@8 + GUIWindow dialog_window; // [sp+7Ch] [bp-7Ch]@1 + char *Str; // [sp+D0h] [bp-28h]@55 + __int32 v103; // [sp+D4h] [bp-24h]@25 + int pColorYellow; // [sp+D8h] [bp-20h]@1 + int pColorWhite; // [sp+DCh] [bp-1Ch]@1 + POINT v106; // [sp+E0h] [bp-18h]@8 + Player *pPlayer; // [sp+E8h] [bp-10h]@1 + int pItemNum; // [sp+ECh] [bp-Ch]@26 + const char **v109; // [sp+F0h] [bp-8h]@26 + unsigned __int8 v110; // [sp+F7h] [bp-1h]@16 + int pNumString; + + pPlayer = pPlayers[uActiveCharacter]; + memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); + dialog_window.uFrameX = 483; + dialog_window.uFrameWidth = 148; + dialog_window.uFrameZ = 334; + pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu); + pColorYellow = TargetColor(0xE1u, 0xCDu, 0x23u); + + switch(dialog_menu_id) + { + case HOUSE_DIALOGUE_MAIN: + { + pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); + if ( pNumActiveItem ) + { + pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; + pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; + pShopOptions[2] = pGlobalTXT_LocalizationStrings[159]; + pShopOptions[3] = pGlobalTXT_LocalizationStrings[160]; + all_text_height = 0; + for (int i = 0; i < 4; ++i)//while ( (signed int)v15 < (signed int)&unk_F8B1C8 ); + all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); + v103 = (174 - all_text_height) / 4; + pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; + v19 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138; + v20 = -pDialogueWindow->pNumPresenceButton < 0; + if ( v20 ^ (pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton )) + { + pItemNum = 2; + pNumString = 0; + do + { + pButton = pDialogueWindow->GetControl(pItemNum); + pButton->uY = v103 + v19; + pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0); + pButton->uHeight = pTextHeight; + v19 = pButton->uY + pTextHeight - 1; + pButton->uW = v19; + pColorText = pColorYellow; + if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) + pColorText = pColorWhite; + dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3); + ++pItemNum; + ++pNumString; + pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; + } + while ( pItemNum < pNumActiveItem ); + } + } + break; + } + + case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: + { + pRenderer->DrawTextureIndexed(8, 8, ShopTexture); + v48 = 0; + pItemNum = 0; + v109 = 0; + do + { + // if ( pParty->field_777C[9 * (int)&v48[3 * (unsigned int)window_SpeakInHouse->ptr_1C]] ) + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(int)v48].uItemID) + { + v49 = word_F8B158[(signed int)v48]; + v50 = ItemsInShopTexture[(signed int)v48]; + v49 += 30; + v51 = 60 - ((signed int)v50->uTextureWidth >> 1); + pRenderer->DrawTextureTransparent(v51 + pItemNum, v49, v50); + sub_40F92A(&pRenderer->pActiveZBuffer[v51 + pItemNum + 640 * v49], ItemsInShopTexture[(signed int)v109], (int)((char *)v109 + 1)); + v48 = v109; + } + pItemNum += 70; + v48 = (const char **)((char *)v48 + 1); + v109 = v48; + } + while ( (signed int)v48 < 6 ); + pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); + if ( pNumActiveItem ) + { + v55 = 0; + v106.x = 0; + v106.x = 0; + do + { + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID)//9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + ++v106.x; + ++v55; + } + while ( v55 < 6 ); + v56 = GetAsyncKeyState(17); + v57 = pPlayer->CanSteal(); + Str = (char *)v57; + if ( v56 && v57 ) + { + v58 = pGlobalTXT_LocalizationStrings[185]; + } + else + { + v58 = pGlobalTXT_LocalizationStrings[195]; + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + v58 = pGlobalTXT_LocalizationStrings[196]; + } + DrawTextAtStatusBar(v58, 0); + if ( v106.x ) + { + v59 = pMouse->GetCursorPos(&v91); + pNumActiveItem = v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y]; + if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF ) + { + v60 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1; + v106.x = v60; + v61 = (int)window_SpeakInHouse->ptr_1C;//maybe ptr_1C - BuildID_2Events + // v62 = 9 * (v60 + 12 * v61); + pItemInShop = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60]; + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60]; + if ( !v56 || !Str ) + { + v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2); + v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); + } + else + { + v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); + } + } + } + else + { + dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + pNumActiveItem = 0; //added + } + } + break; + } + + case HOUSE_DIALOGUE_SHOP_SELL: + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0); + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + if((v11 = pMouse->GetCursorPos(&v96)->x - 14, v106.x = (v11 >> 5) + 14 * ((pMouse->GetCursorPos(&v88)->y - 17) >> 5), + pMouse->GetCursorPos(&v94)->x <= 13) || pMouse->GetCursorPos(&v90)->x >= 462 + || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) ) + return; + v79 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; + v13 = pPlayer->SelectPhrasesTransaction(v79, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 3); + v7 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, v79, (char *)window_SpeakInHouse->ptr_1C, 3, 0); + pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); + break; + } + + case HOUSE_DIALOGUE_SHOP_IDENTIFY: + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + if((v2 = pMouse->GetCursorPos(&a2)->x - 14, v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5), + pMouse->GetCursorPos(&v100)->x <= 13) || pMouse->GetCursorPos(&v92)->x >= 462 + || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) ) + return; + v4 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; + if (!v4->Identified()) + { + v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_WeaponShop, (int)window_SpeakInHouse->ptr_1C, 4); + v7 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); + } + else + { + v7 = BuilDialogueString("%24", uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); + } + break; + } + + case HOUSE_DIALOGUE_SHOP_REPAIR: + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0); + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + return; + if( (v2 = pMouse->GetCursorPos(&a2)->x - 14, v106.x = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v87)->y - 17) >> 5), + pMouse->GetCursorPos(&v100)->x <= 13) || pMouse->GetCursorPos(&v92)->x >= 462 + || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v106.x), !pNumActiveItem) + || (!(pPlayer->pOwnItems[pNumActiveItem-1].uAttributes& 2)) ) + return; + v4 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; + v10 = pPlayer->SelectPhrasesTransaction(v4, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 5); + v7 = BuilDialogueString((char *)pMerchantsRepairPhrases[v10], uActiveCharacter - 1, v4, (char *)window_SpeakInHouse->ptr_1C, 5, 0); + pTextHeight = (174 - pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, 0, pTextHeight, pColorWhite, v7, 3); + return; + } + break; + + case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];//sell + pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];//identify + pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];//repair + all_text_height = 0; + for ( int i = 0; i < 3; ++i ) + all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); + v103 = (174 - all_text_height) / 3; + pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; + v70 = (3 * (58 - (signed int)v103) - all_text_height) / 2 - ((174 - all_text_height) / 3) / 2 + 138; + v20 = -pDialogueWindow->pNumPresenceButton < 0; + if ( v20 ^ (pNumActiveItem > pNumActiveItem + pDialogueWindow->pNumPresenceButton )) + { + pItemNum = 2; + pNumString = 0; + do + { + pButton = pDialogueWindow->GetControl(pItemNum); + pButton->uY = v103 + v70; + pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0); + pButton->uHeight = pTextHeight; + v70 = pButton->uY + pTextHeight - 1; + pButton->uW = v70; + pColorText = pColorYellow; + if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) + pColorText = pColorWhite; + dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3); + ++pItemNum; + ++pNumString; + pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; + } + while ( pItemNum < pNumActiveItem ); + } + break; + } + + case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: + { + pRenderer->DrawTextureIndexed(8, 8, ShopTexture); + v109 = 0; + pItemNum = 0; + do + { + // if ( pParty->field_C59C[9 * (int)&v109[3 * (unsigned int)window_SpeakInHouse->ptr_1C] + 724] ) + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v109].uItemID) + { + v52 = word_F8B158[(signed int)v109] + 30; + v53 = ItemsInShopTexture[(signed int)v109]; + v54 = 60 - ((signed int)v53->uTextureWidth >> 1); + pRenderer->DrawTextureTransparent(v54 + pItemNum, word_F8B158[(signed int)v109] + 30, v53); + sub_40F92A(&pRenderer->pActiveZBuffer[v54 + pItemNum + 640 * v52], ItemsInShopTexture[(signed int)v109], (int)((char *)v109 + 1)); + } + v109 = (const char **)((char *)v109 + 1); + pItemNum += 70; + } + while ( (signed int)v109 < 6 ); + pNumActiveItem = sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win(); + if ( pNumActiveItem ) + { + v55 = 0; + v106.x = 0; + do + { + // if ( pParty->field_C59C[9 * (v55 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v55].uItemID) + ++v106.x; + ++v55; + } + while ( v55 < 6 ); + v56 = GetAsyncKeyState(17); + v57 = pPlayer->CanSteal(); + Str = (char *)v57; + if ( v56 && v57 ) + { + v58 = pGlobalTXT_LocalizationStrings[185]; + } + else + { + v58 = pGlobalTXT_LocalizationStrings[195]; + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + v58 = pGlobalTXT_LocalizationStrings[196]; + } + DrawTextAtStatusBar(v58, 0); + if ( v106.x ) + { + v59 = pMouse->GetCursorPos(&v91); + pNumActiveItem = v59->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v89)->y]; + if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF ) + { + v60 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1; + v106.x = v60; + v61 = (int)window_SpeakInHouse->ptr_1C; + // v62 = 9 * (v60 + 12 * v61); + pItemInShop = (ItemGen *)&pParty->StandartItemsInShops[(int)v61][v60]; + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + pItemInShop = &pParty->SpecialItemsInShops[(int)v61][v60];//v63 = (ItemGen *)&pParty->field_C59C[v62 + 724]; + if ( !v56 || !Str ) + { + v64 = pPlayer->SelectPhrasesTransaction(pItemInShop, BildingType_WeaponShop, v61, 2); + v7 = BuilDialogueString((char *)pMerchantsBuyPhrases[v64], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); + } + else + { + v7 = BuilDialogueString(pGlobalTXT_LocalizationStrings[181], uActiveCharacter - 1, pItemInShop, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + pTextHeight = pFontArrus->CalcTextHeight(v7, &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v7, 3); + } + } + } + else + { + dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + pNumActiveItem = 0; //added + } + } + break; + } + + case HOUSE_DIALOGUE_LEARN_SKILLS: + { + if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + return; + v0 = 0; + all_text_height = 0; + //v32 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v31] * 500.0); + v32 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); + pItemNum = v32 * (100 - pPlayer->GetMerchant()) / 100; + if ( pItemNum < v32 / 3 ) + pItemNum = v32 / 3; + pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; + if ( pNumActiveItem >= pNumActiveItem + pDialogueWindow->pNumPresenceButton ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]); + strcat(pTmpBuf.data(), "\n \n"); + strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); + pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); + return; + } + do + { + v35 = pDialogueWindow->GetControl(pNumActiveItem)->msg_param - 36; + if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v35] && !pPlayer->pActiveSkills[v35] ) + { + all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v35], &dialog_window, 0, 0); + v0++; + } + ++pNumActiveItem; + } + while ( pNumActiveItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + if ( !v0 ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]); + strcat(pTmpBuf.data(), "\n \n"); + strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); + pTextHeight = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); + return; + } + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pItemNum); + dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); + v103 = (149 - all_text_height) / v0; + if ( (149 - all_text_height) / v0 > 32 ) + v103 = 32; + pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; + v37 = (149 - v0 * v103 - all_text_height) / 2 - v103 / 2 + 162; + if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton ) + { + pItemNum = 2; + do + { + pButton = pDialogueWindow->GetControl(pItemNum); + v40 = pButton->msg_param - 36; + if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v40] || pPlayer->pActiveSkills[v40] ) + { + pButton->uW = 0; + pButton->uHeight = 0; + pButton->uY = 0; + } + else + { + pButton->uY = v103 + v37; + pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v40], &dialog_window, 0, 0); + pButton->uHeight = pTextHeight; + v37 = pButton->uY + pTextHeight - 1; + pButton->uW = v37; + pColorText = pColorYellow; + if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) + pColorText = pColorWhite; + dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v40], 3); + } + pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; + pItemNum++; + } + while ( pItemNum < pNumActiveItem ); + } + break; + } + default: + { + if( dialog_menu_id > HOUSE_DIALOGUE_SHOP_REPAIR) + pNumActiveItem = dialog_menu_id - 96; + else + pNumActiveItem = dialog_menu_id - 4; + break; + } + } +} + + + +//----- (004B9CC6) -------------------------------------------------------- +void __cdecl AlchemistDialog() +{ + int v0; + int pNumActiveItem; // eax@7 + signed int v5; // esi@9 + unsigned int v6; // esi@11 + int v7; // eax@11 + unsigned int v8; // eax@12 + int v9; // eax@14 + int v10; // ecx@19 + int v13; // eax@21 + char *v14; // eax@23 + int v15; // eax@23 + unsigned int v16; // ecx@23 + int v17; // edx@23 + int v18; // eax@23 + int v20; // eax@27 + char *v21; // edx@29 + int v22; // esi@30 + char **v23; // edi@30 + int v24; // eax@31 + int v26; // edx@32 + int v27; // edi@32 + unsigned __int8 v28; // sf@32 + const char **v30; // eax@34 + int v31; // eax@34 + unsigned int v32; // ecx@34 + int v34; // eax@34 + signed int v36; // esi@39 + ItemGen *v37; // eax@42 + char *v38; // ecx@43 + unsigned __int8 v39; // dl@44 + int v40; // eax@46 + int v41; // ST08_4@47 + int v42; // eax@47 + signed int v43; // esi@49 + int v44; // ST08_4@52 + int v45; // eax@52 + Texture *v46; // ecx@55 + unsigned int v47; // edi@55 + unsigned int v48; // esi@57 + int v49; // edx@61 + Texture *v50; // ecx@67 + unsigned int v51; // edi@67 + unsigned int v52; // esi@69 + int v53; // edx@73 + Texture *v54; // ecx@79 + unsigned int v55; // edi@79 + unsigned int v56; // esi@81 + int v57; // edx@85 + Texture *v58; // ecx@91 + unsigned int v59; // edi@91 + unsigned int v60; // esi@93 + int v61; // edx@97 + signed int v62; // ecx@102 + SHORT v63; // di@110 + bool v64; // eax@110 + const char *v65; // ecx@112 + POINT *v66; // esi@117 + int v67; // ecx@118 + int v68; // eax@118 + int v69; // ecx@118 + ItemGen *v70; // esi@118 + int v71; // eax@123 + int all_text_height; // edi@125 + char **v73; // esi@125 + int v74; // eax@126 + int pItemNum; + int v76; // edx@127 + int v77; // edi@127 + GUIButton *pButton; // esi@129 + const char **v79; // eax@129 + int pTextHeight; // eax@129 + unsigned int v81; // ecx@129 + unsigned int pColorText; // ax@129 + int v85; // [sp-14h] [bp-ECh]@29 + int v86; // [sp-10h] [bp-E8h]@29 + ItemGen *v87; // [sp-10h] [bp-E8h]@43 + unsigned __int16 v88; // [sp-Ch] [bp-E4h]@29 + void *v89; // [sp-Ch] [bp-E4h]@43 + char *v90; // [sp-8h] [bp-E0h]@29 + int v91; // [sp-8h] [bp-E0h]@42 + unsigned int v92; // [sp-4h] [bp-DCh]@29 + __int64 *v93; // [sp-4h] [bp-DCh]@42 + POINT v94; // [sp+Ch] [bp-CCh]@39 + POINT v95; // [sp+14h] [bp-C4h]@49 + POINT v96; // [sp+1Ch] [bp-BCh]@117 + POINT v97; // [sp+24h] [bp-B4h]@40 + POINT v98; // [sp+2Ch] [bp-ACh]@117 + POINT v99; // [sp+34h] [bp-A4h]@49 + POINT v100; // [sp+3Ch] [bp-9Ch]@50 + POINT v101; // [sp+44h] [bp-94h]@39 + POINT v102; // [sp+4Ch] [bp-8Ch]@49 + POINT a2; // [sp+54h] [bp-84h]@39 + GUIWindow dialog_window; // [sp+5Ch] [bp-7Ch]@1 + int v105; // [sp+B0h] [bp-28h]@19 + int pColorYellow; // [sp+B4h] [bp-24h]@1 + int Str; // [sp+B8h] [bp-20h]@23 + int pColorWhite; // [sp+BCh] [bp-1Ch]@1 + __int32 v109; // [sp+C0h] [bp-18h]@39 + Player *pPlayer; // [sp+C4h] [bp-14h]@1 + int pNumString; // [sp+C8h] [bp-10h]@9 + unsigned int v112; // [sp+CCh] [bp-Ch]@9 + unsigned __int8 v113; // [sp+D3h] [bp-5h]@47 + int v114; // [sp+D4h] [bp-4h]@11 + + pPlayer = pPlayers[uActiveCharacter]; + memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); + dialog_window.uFrameX = 483; + dialog_window.uFrameWidth = 148; + dialog_window.uFrameZ = 334; + pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu); + pColorYellow = TargetColor(0xE1u, 0xCDu, 0x23u); + switch(dialog_menu_id) + { + case HOUSE_DIALOGUE_MAIN: + { + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; + pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; + pShopOptions[2] = pGlobalTXT_LocalizationStrings[159]; + pShopOptions[3] = pGlobalTXT_LocalizationStrings[160]; + all_text_height = 0; + for (int i = 0; i < 4; ++i)//while ( (signed int)v15 < (signed int)&unk_F8B1C8 ); + all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); + Str = (174 - all_text_height) / 4; + pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; + v76 = pNumActiveItem + pDialogueWindow->pNumPresenceButton; + v77 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138; + v28 = -pDialogueWindow->pNumPresenceButton < 0; + if ( v28 ^ (pNumActiveItem > v76) ) + { + pItemNum = 2; + pNumString = 0; + do + { + pButton = pDialogueWindow->GetControl(pItemNum); + pButton->uY = Str + v77; + pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0); + pButton->uHeight = pTextHeight; + v77 = pButton->uY + pTextHeight - 1; + pButton->uW = v77; + pColorText = pColorYellow; + if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) + pColorText = pColorWhite; + dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3); + ++pItemNum; + ++pNumString; + pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; + } + while ( pItemNum < pNumActiveItem ); + } + } + return; + } + case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: + { + pRenderer->DrawTextureIndexed(8, 8, ShopTexture); + v114 = 0; + do + { + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID) + { + v46 = ItemsInShopTexture[v114]; + v47 = 152 - v46->uTextureHeight; + if ( (signed int)v47 < 1 ) + v47 = 0; + v48 = 75 * v114 - v46->uTextureWidth / 2 + 40; + if ( v114 ) + { + if ( v114 == 5 ) + { + v49 = ItemsInShopTexture[5]->uTextureWidth; + if ( (signed int)v48 > 457 - v49 ) + v48 = 457 - v49; + } + } + else if ( (signed int)v48 < 18 ) + v48 = 18; + pRenderer->DrawTextureTransparent(v48, v47, v46); + sub_40F92A(&pRenderer->pActiveZBuffer[v48 + 640 * v47], ItemsInShopTexture[v114], v114 + 1); + } + ++v114; + } + while ( v114 < 6 ); + v114 = 0; + do + { + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114 + 6].uItemID) + { + v50 = ItemsInShopTexture[v114 + 6]; + v51 = 308 - v50->uTextureHeight; + if ( (signed int)v51 < 1 ) + v51 = 0; + v52 = 75 * v114 - v50->uTextureWidth / 2 + 40; + if ( v114 ) + { + if ( v114 == 5 ) + { + v53 = ItemsInShopTexture[11]->uTextureWidth; + if ( (signed int)v52 > 457 - v53 ) + v52 = 457 - v53; + } + } + else + { + if ( (signed int)v52 < 18 ) + v52 = 18; + } + pRenderer->DrawTextureTransparent(v52, v51, v50); + sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[v114 + 6], v114 + 7); + } + ++v114; + } + while ( v114 < 6 ); + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v62 = 0; + v109 = 0; + do + { + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID) + ++v109; + ++v62; + } + while ( v62 < 12 ); + v63 = GetAsyncKeyState(17); + v64 = pPlayer->CanSteal(); + Str = v64; + if ( v63 && v64 ) + { + v65 = pGlobalTXT_LocalizationStrings[185]; + } + else if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + { + v65 = pGlobalTXT_LocalizationStrings[195]; + } + else + { + v65 = pGlobalTXT_LocalizationStrings[196]; + } + DrawTextAtStatusBar(v65, 0); + if ( !v109 ) + { + dialog_window.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + return; + } + v66 = pMouse->GetCursorPos(&v98); + pNumActiveItem = v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]; + if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF ) + { + v67 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1; + v70 = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67]; + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + v70 = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; + if ( !v63 || !Str ) + { + v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 2); + v38 = (char *)pMerchantsBuyPhrases[v71]; + } + else + { + v38 = pGlobalTXT_LocalizationStrings[181]; + } + v21 = BuilDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); + return ; + } + } + return; + } + case HOUSE_DIALOGUE_SHOP_SELL: + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0); + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + if ((v43 = pMouse->GetCursorPos(&v99)->x - 14, v109 = (v43 >> 5) + 14 * ((pMouse->GetCursorPos(&v95)->y - 17) >> 5), + pMouse->GetCursorPos(&v102)->x <= 13) || pMouse->GetCursorPos(&v100)->x >= 462 + || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) ) + return; + v87 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; + v45 = pPlayer->SelectPhrasesTransaction(v87, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 3); + v21 = BuilDialogueString((char *)pMerchantsSellPhrases[v45], uActiveCharacter - 1, v87, (char *)window_SpeakInHouse->ptr_1C, 3, 0); + pTextHeight = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - pTextHeight) / 2 + 138, pColorWhite, v21, 3); + return; + } + case HOUSE_DIALOGUE_SHOP_IDENTIFY: + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + if ((v36 = pMouse->GetCursorPos(&a2)->x - 14, v109 = (v36 >> 5) + 14 * ((pMouse->GetCursorPos(&v94)->y - 17) >> 5), + pMouse->GetCursorPos(&v101)->x <= 13) || pMouse->GetCursorPos(&v97)->x >= 462 + || (pNumActiveItem = pPlayer->GetItemIDAtInventoryIndex((int *)&v109), !pNumActiveItem) ) + return; + v37 = (ItemGen *)&pPlayer->pInventoryItems[pNumActiveItem - 1]; + if (!v37->Identified()) + { + v42 = pPlayer->SelectPhrasesTransaction(v37, BildingType_AlchemistShop, (int)window_SpeakInHouse->ptr_1C, 4); + v38 = (char *)pMerchantsIdentifyPhrases[v42]; + } + else + { + v38 = "%24"; + } + v21 = BuilDialogueString(v38, uActiveCharacter - 1, v37, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); + return; + } + case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + pShopOptions[0] = pGlobalTXT_LocalizationStrings[200]; + pShopOptions[1] = pGlobalTXT_LocalizationStrings[113]; + all_text_height = 0; + for ( int i = 0; i < 2; ++i ) + all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); + Str = (174 - all_text_height) / 2; + pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; + v26 = pNumActiveItem + pDialogueWindow->pNumPresenceButton; + v27 = (2 * (87 - (174 - all_text_height) / 2) - all_text_height) / 2 - (174 - all_text_height) / 2 / 2 + 138; + v28 = -pDialogueWindow->pNumPresenceButton < 0; + if ( v28 ^ (pNumActiveItem > v26) ) + { + pItemNum = 2; + pNumString = 0; + do + { + pButton = pDialogueWindow->GetControl(pItemNum); + pButton->uY = Str + v27; + pTextHeight = pFontArrus->CalcTextHeight((const char *)pShopOptions[pNumString], &dialog_window, 0, 0); + pButton->uHeight = pTextHeight; + v27 = pButton->uY + pTextHeight - 1; + pButton->uW = v27; + pColorText = pColorYellow; + if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) + pColorText = pColorWhite; + dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, (const char *)pShopOptions[pNumString], 3); + ++pItemNum; + ++pNumString; + pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; + } + while ( pItemNum < pNumActiveItem ); + } + return; + } + case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: + { + pRenderer->DrawTextureIndexed(8, 8, ShopTexture); + v114 = 0; + do + { + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v114].uItemID) + { + v54 = ItemsInShopTexture[v114]; + v55 = 152 - v54->uTextureHeight; + if ( (signed int)v55 < 1 ) + v55 = 0; + v56 = 75 * v114 - v54->uTextureWidth / 2 + 40; + if ( v114 ) + { + if ( v114 == 5 ) + { + v57 = ItemsInShopTexture[5]->uTextureWidth; + if ( (signed int)v56 > 457 - v57 ) + v56 = 457 - v57; + } + } + else + { + if ( (signed int)v56 < 18 ) + v56 = 18; + } + pRenderer->DrawTextureTransparent(v56, v55, v54); + sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], ItemsInShopTexture[v114], v114 + 1); + } + ++v114; + } + while ( v114 < 6 ); + v114 = 0; + do + { + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][(signed int)v114 + 6].uItemID) //not itemid + { + v58 = ItemsInShopTexture[v114 + 6]; + v59 = 308 - v58->uTextureHeight; + if ( (signed int)v59 < 1 ) + v59 = 0; + v60 = 75 * v114 - v58->uTextureWidth / 2 + 40; + if ( v114 ) + { + if ( v114 == 5 ) + { + v61 = ItemsInShopTexture[11]->uTextureWidth; + if ( (signed int)v60 > 457 - v61 ) + v60 = 457 - v61; + } + } + else + { + if ( (signed int)v60 < 18 ) + v60 = 18; + } + pRenderer->DrawTextureTransparent(v60, v59, v58); + sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], ItemsInShopTexture[v114 + 6], v114 + 7); + } + ++v114; + } + while ( v114 < 6 ); + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v62 = 0; + v109 = 0; + do + { + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v62].uItemID) + ++v109; + ++v62; + } + while ( v62 < 12 ); + v63 = GetAsyncKeyState(17); + v64 = pPlayer->CanSteal(); + Str = v64; + if ( v63 && v64 ) + { + v65 = pGlobalTXT_LocalizationStrings[185]; + } + else + { + v65 = pGlobalTXT_LocalizationStrings[195]; + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + v65 = pGlobalTXT_LocalizationStrings[196]; + } + DrawTextAtStatusBar(v65, 0); + if ( !v109 ) + { + dialog_window.DrawCurrentTime( pParty->field_3C.field_50[ (unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + return; + } + v66 = pMouse->GetCursorPos(&v98); + pNumActiveItem = v66->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v96)->y]; + if ( pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF ) + { + v67 = (pRenderer->pActiveZBuffer[pNumActiveItem] & 0xFFFF) - 1; + v109 = v67; + v68 = (int)window_SpeakInHouse->ptr_1C; + // v69 = 9 * (v67 + 12 * v68); + v70 = (ItemGen *)&pParty->StandartItemsInShops[v68][v67]; + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + v70 = &pParty->SpecialItemsInShops[(int)v68][v67];//v70 = (ItemGen *)&pParty->field_C59C[v69 + 724]; + if ( !v63 || !Str ) + { + v71 = pPlayer->SelectPhrasesTransaction(v70, BildingType_AlchemistShop, v68, 2); + v38 = (char *)pMerchantsBuyPhrases[v71]; + } + else + { + v38 = pGlobalTXT_LocalizationStrings[181]; + } + v21 = BuilDialogueString(v38, uActiveCharacter - 1, v70, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v40 = pFontArrus->CalcTextHeight(v21, &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorWhite, v21, 3); + return; + } + } + return; + } + case HOUSE_DIALOGUE_LEARN_SKILLS: + { + if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + return; + all_text_height = 0; + v5 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); + pItemNum = v5 * (100 - pPlayer->GetMerchant()) / 100; + if ( pItemNum < v5 / 3 ) + pItemNum = v5 / 3; + pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; + v114 = 0; + if ( pNumActiveItem >= pNumActiveItem + pDialogueWindow->pNumPresenceButton ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]); + strcat(pTmpBuf.data(), "\n \n"); + strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); + v40 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); + return; + } + do + { + v8 = pDialogueWindow->GetControl(pNumActiveItem)->msg_param - 36; + if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v8] && !pPlayer->pActiveSkills[v8] ) + { + all_text_height = pFontArrus->CalcTextHeight(pSkillNames[v8], &dialog_window, 0, 0); + ++v114; + } + ++pNumActiveItem; + } + while ( pNumActiveItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + if ( !v114 ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayer->pName, pClassNames[pPlayer->classType]); + strcat(pTmpBuf.data(), "\n \n"); + strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); + v40 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - v40) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); + return; + } + if ( v114 ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pItemNum); + dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); + v18 = (149 - all_text_height) / v114; + if ( (149 - all_text_height) / v114 > 32 ) + v18 = 32; + pNumActiveItem = pDialogueWindow->pStartingPosActiveItem; + v105 = (149 - v114 * v18 - all_text_height) / 2 - v18 / 2 + 162; + if ( pNumActiveItem < pNumActiveItem + pDialogueWindow->pNumPresenceButton ) + { + pItemNum = 2; + do + { + pButton = pDialogueWindow->GetControl(pItemNum); + v13 = pButton->msg_param - 36; + if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayer->classType][v13] || pPlayer->pActiveSkills[v13] ) + { + pButton->uW = 0; + pButton->uHeight = 0; + pButton->uY = 0; + } + else + { + pButton->uY = v18 + v105; + pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v13], &dialog_window, 0, 0); + pButton->uHeight = pTextHeight; + v105 = pButton->uY + pTextHeight - 1; + pButton->uW = v105; + pColorText = pColorYellow; + if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) + pColorText = pColorWhite; + dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pColorText, pSkillNames[v13], 3); + } + pNumActiveItem = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; + pItemNum++; + } + while ( pItemNum < pNumActiveItem ); + } + return; + } + } + default: + { + return;// (POINT *)dialog_menu_id - 96; + } + } +} + +//----- (004BA928) -------------------------------------------------------- +void __cdecl ArmorShopDialog() +{ + signed int v1; // esi@8 + unsigned int v2; // eax@10 + ItemGen *v3; // eax@11 + char *v5; // ecx@12 + char *v6; // eax@13 + int v8; // eax@15 + signed int v9; // esi@17 + unsigned int v10; // eax@19 + char *v11; // edi@19 + int v12; // ST08_4@20 + int v13; // eax@20 + char *v15; // ecx@20 + char **v16; // edi@22 + int all_text_height; // ebx@22 + char **v18; // esi@22 + int v19; // eax@23 + GUIWindow *v20; // ecx@24 + int v21; // eax@24 + int v22; // edx@24 + int v23; // ebx@24 + unsigned __int8 v24; // sf@24 + GUIButton *pButton; // eax@26 + unsigned int v28; // ecx@26 + int v29; // edx@26 + signed int v31; // esi@31 + unsigned int v32; // eax@33 + int v33; // eax@34 + int v35; // eax@35 + char *v36; // edx@36 + signed int v38; // esi@42 + unsigned int v39; // esi@44 + int v40; // eax@44 + unsigned int v41; // eax@45 + int v42; // eax@47 + int v43; // ecx@52 + int v46; // eax@54 + unsigned int v49; // ecx@56 + int v51; // eax@56 + int v53; // eax@60 + int textureH; // eax@60 + signed int textureW; // ebx@65 + Texture *v56; // eax@67 + unsigned int pY_item; // edi@68 + Texture *v58; // ST1C_4@68 + int v59; // eax@68 + int v60; // edi@69 + signed int v61; // ebx@73 + Texture *v62; // eax@75 + int v63; // edi@76 + Texture *v64; // ST1C_4@76 + unsigned int v65; // ST18_4@76 + int v66; // eax@76 + int v67; // edi@77 + signed int v68; // ecx@81 + const char *pStatusText; // ecx@91 + void *v72; // eax@95 + POINT *v73; // esi@97 + int v74; // ecx@97 + int v75; // eax@98 + int v76; // ecx@98 + ItemGen *selected_item; // ecx@99 + unsigned __int8 v78; // bl@104 + int v80; // ebx@105 + char **v81; // esi@105 + int v82; // eax@106 + int v86; // ebx@107 + int pTextHeight; // eax@109 + unsigned int v90; // ecx@109 + int pNumString; // edx@109 + unsigned __int16 pTextColor; // ax@109 + signed int v93; // edx@114 + POINT *v94; // edi@120 + __int32 v95; // ecx@120 + void *v96; // ST14_4@122 + unsigned __int8 v97; // bl@122 + ItemGen *v98; // ST10_4@122 + int v99; // eax@122 + char *v100; // eax@122 + const char *v101; // ST18_4@122 + unsigned __int16 v102; // ST14_2@122 + int v103; // eax@122 + signed int v104; // edi@123 + Texture *v105; // eax@125 + int v106; // ebx@126 + unsigned int v108; // ST18_4@126 + int v109; // eax@126 + int v110; // ebx@127 + GUIWindow *v111; // [sp-18h] [bp-11Ch]@36 + unsigned int v112; // [sp-14h] [bp-118h]@13 + int v113; // [sp-14h] [bp-118h]@36 + unsigned int v115; // [sp-10h] [bp-114h]@13 + ItemGen *v116; // [sp-10h] [bp-114h]@20 + int v117; // [sp-10h] [bp-114h]@36 + unsigned __int16 v119; // [sp-Ch] [bp-110h]@13 + char *v121; // [sp-8h] [bp-10Ch]@13 + int v122; // [sp-8h] [bp-10Ch]@20 + unsigned int v123; // [sp-4h] [bp-108h]@13 + __int64 *v124; // [sp-4h] [bp-108h]@20 + int v125; // [sp-4h] [bp-108h]@68 + int v126; // [sp-4h] [bp-108h]@76 + int v127; // [sp-4h] [bp-108h]@126 + POINT v128; // [sp+Ch] [bp-F8h]@8 + POINT v129; // [sp+14h] [bp-F0h]@18 + char v130; // [sp+1Ch] [bp-E8h]@120 + POINT a2; // [sp+24h] [bp-E0h]@8 + POINT v132; // [sp+2Ch] [bp-D8h]@120 + POINT v133; // [sp+34h] [bp-D0h]@17 + POINT v134; // [sp+3Ch] [bp-C8h]@97 + POINT v135; // [sp+44h] [bp-C0h]@31 + POINT v136; // [sp+4Ch] [bp-B8h]@97 + POINT v137; // [sp+54h] [bp-B0h]@17 + POINT v138; // [sp+5Ch] [bp-A8h]@32 + POINT v139; // [sp+64h] [bp-A0h]@17 + POINT v140; // [sp+6Ch] [bp-98h]@31 + POINT v141; // [sp+74h] [bp-90h]@8 + POINT v142; // [sp+7Ch] [bp-88h]@31 + POINT v143; // [sp+84h] [bp-80h]@9 + GUIWindow dialog_window; // [sp+8Ch] [bp-78h]@1 + int v146; // [sp+E4h] [bp-20h]@24 + int pYellowColor; // [sp+E8h] [bp-1Ch]@1 + int pWhiteColor; // [sp+ECh] [bp-18h]@1 + __int32 pItemCount; // [sp+F0h] [bp-14h]@8 + int v152; // [sp+FCh] [bp-8h]@24 + int v153; // [sp+100h] [bp-4h]@44 + int th; + short text_color; + int pActiveButton; + + memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); + dialog_window.uFrameX = 483; + dialog_window.uFrameWidth = 148; + dialog_window.uFrameZ = 334; + pWhiteColor = TargetColor(0xFFu, 0xFFu, 0xFFu); + pYellowColor = TargetColor(0xE1u, 0xCDu, 0x23u); + switch (dialog_menu_id) + { + case HOUSE_DIALOGUE_MAIN: + { + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; //"Buy Standard" + pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; //"Buy Special" + pShopOptions[2] = pGlobalTXT_LocalizationStrings[159]; //"Display Inventory" + pShopOptions[3] = pGlobalTXT_LocalizationStrings[160]; + all_text_height = 0; + for( int i = 0; i < 4; ++i ) + all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); + v146 = ( 174 - all_text_height ) / 4; + v23 = ( 174 - 4 * ( 174 - all_text_height ) / 4 - all_text_height ) / 2 - ( 174 - all_text_height ) / 4 / 2 + 138; + pNumString = 0; + if ( pDialogueWindow->pNumPresenceButton>=0 ) + { + for (pActiveButton = pDialogueWindow->pStartingPosActiveItem; pActiveButton < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++pActiveButton) + { + pButton = pDialogueWindow->GetControl(pActiveButton); + pButton->uY = v146 + v23; + pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0); + pButton->uHeight = pTextHeight; + v23 = pButton->uY + pButton->uHeight - 1; + pButton->uW = v23; + pTextColor = pYellowColor; + if ( pDialogueWindow->pCurrentPosActiveItem != pActiveButton ) + pTextColor = pWhiteColor; + dialog_window.DrawTitleText(pFontArrus, 0, pButton->uY, pTextColor, pShopOptions[pNumString], 3); + ++pNumString; + } + } + } + break; + case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: + { + pRenderer->DrawTextureIndexed(8, 8, ShopTexture);// ïîäëîæêà + textureW = 0; + v153 = 0; + for ( int i = 0; i < 8; ++i )// ðàçìåñòèòü âåùè + { + if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID) + { + textureW = ItemsInShopTexture[i]->uTextureWidth; + textureH = ItemsInShopTexture[i]->uTextureHeight; + if ( i >= 4 ) //low row + { + v60 = 90 - (textureW/2); + pRenderer->DrawTextureTransparent(v60 + v153 - 420, 126, ItemsInShopTexture[i]); + v59 = v60 + v153 + 80220; + } + else + { + pY_item = 98 - textureH; + v152 = 86 - (textureW/2); + pRenderer->DrawTextureTransparent(v152 + v153, pY_item, ItemsInShopTexture[i]); + v59 = v153 + v152 + 640 * pY_item; + } + ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v59], ItemsInShopTexture[i], i + 1); + } + v153 += 105; + } + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + pItemCount = 0; + for ( int i = 0; i < 8; ++i ) + { + if ( pParty->StandartItemsInShops[window_SpeakInHouse->par1C][i].uItemID ) + ++pItemCount; + } + if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 ) + pStatusText = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy" + else + pStatusText = pGlobalTXT_LocalizationStrings[185];//"Steal item" + DrawTextAtStatusBar(pStatusText, 0); + if ( pItemCount != 0 ) + { + v73 = pMouse->GetCursorPos(&v136); + v74 = pRenderer->pActiveZBuffer[v73->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v134)->y]] & 0xFFFF; + if ( !v74 ) + return; + pItemCount = v74 - 1; + selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][v74-1]; + if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0) + v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; + else + v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24" + v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); + return; + } + dialog_window.DrawCurrentTime( pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed); + return; + } + break; + case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: + { + pRenderer->DrawTextureIndexed(8, 8, ShopTexture); + v11 = 0; + v61 = 0; + v153 = 0; + do + { + if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v61].uItemID) + { + v62 = ItemsInShopTexture[v61]; + if ( v61 >= 4 ) + { + v67 = 90 - ((signed int)v62->uTextureWidth >> 1); + pRenderer->DrawTextureTransparent(v153 + v67 - 420, 0x7Eu, ItemsInShopTexture[v61]); + v66 = v153 + v67 + 80220; + } + else + { + v63 = 98 - v62->uTextureHeight; + v64 = ItemsInShopTexture[v61]; + v65 = 98 - v62->uTextureHeight; + v152 = 86 - ((signed int)v62->uTextureWidth >> 1); + pRenderer->DrawTextureTransparent(v152 + v153, v65, v64); + v66 = v152 + v153 + 640 * v63; + } + ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v66], ItemsInShopTexture[v61], v61 + 1); + } + v153 += 105; + ++v61; + } + while ( v61 < 8 ); + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + v68 = 0; + pItemCount = 0; + do + { + if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][(signed int)v68].uItemID) + ++pItemCount; + ++v68; + } + while ( v68 < 6 ); + if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 ) + pStatusText = pGlobalTXT_LocalizationStrings[196]; //Select the Special Item to Buy" + else + pStatusText = pGlobalTXT_LocalizationStrings[185]; + DrawTextAtStatusBar(pStatusText, 0); + if ( (char *)pItemCount != 0 ) + { + v73 = pMouse->GetCursorPos(&v136); + v74 = pRenderer->pActiveZBuffer[v73->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v134)->y]] & 0xFFFF; + if ( !v74 ) + return; + pItemCount = v74 - 1; + if ( dialog_menu_id == 2 ) + selected_item = &pParty->StandartItemsInShops[window_SpeakInHouse->par1C][v74 - 1]; + else + selected_item = &pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v74 - 1]; + if ( GetAsyncKeyState(17) == 0 || pPlayers[uActiveCharacter]->CanSteal() == 0 ) + v15 = (char *)pMerchantsBuyPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(selected_item, BildingType_ArmorShop, window_SpeakInHouse->par1C, 2)]; + else + v15 = pGlobalTXT_LocalizationStrings[181]; //"Steal %24" + v36 = BuilDialogueString(v15, uActiveCharacter - 1, selected_item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); + return; + } + dialog_window.DrawCurrentTime( pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed); + return; + } + break; + case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + pShopOptions[0] = pGlobalTXT_LocalizationStrings[200]; //"Sell" + pShopOptions[1] = pGlobalTXT_LocalizationStrings[113]; //"Identify" + pShopOptions[2] = pGlobalTXT_LocalizationStrings[179]; //"Repair" + all_text_height = 0; + for ( int i = 0; i < 3; ++i ) + all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); + v152 = (174 - all_text_height) / 3; + v86 = (3 * (58 - v152) - all_text_height) / 2 - v152 / 2 + 138; + v24 = -pDialogueWindow->pNumPresenceButton < 0; + pActiveButton = pDialogueWindow->pStartingPosActiveItem; + if ( v24 ^ (pDialogueWindow->pStartingPosActiveItem > pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton) ) + { + pNumString = 0; + do + { + pButton = pDialogueWindow->GetControl((unsigned int)pActiveButton); + pButton->uY = v152 + v86; + pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[pNumString], &dialog_window, 0, 0); + v90 = pButton->uY; + pButton->uHeight = pTextHeight; + v86 = v90 + pTextHeight - 1; + pButton->uW = v86; + pTextColor = pYellowColor; + if ( pDialogueWindow->pCurrentPosActiveItem != pActiveButton ) + pTextColor = pWhiteColor; + dialog_window.DrawTitleText(pFontArrus, 0, v90, pTextColor, pShopOptions[pNumString], 3); + ++pNumString; + ++pActiveButton; + } + while ( (signed int)pActiveButton < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + } + return; + } + break; + case HOUSE_DIALOGUE_SHOP_SELL: + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);//"Select the Item to Sell" + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + return; + if((v9 = pMouse->GetCursorPos(&v139)->x - 14, pItemCount = (v9 >> 5) + 14 * ((pMouse->GetCursorPos(&v133)->y - 17) >> 5), + pMouse->GetCursorPos(&v137)->x <= 13) || pMouse->GetCursorPos(&v129)->x >= 462 + || (v10 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v10) ) + return; + v116 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v10 - 1]; + v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3); + v15 = (char *)pMerchantsSellPhrases[pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v116, BildingType_ArmorShop, window_SpeakInHouse->par1C, 3)]; + v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *) window_SpeakInHouse->par1C, 3, 0); + v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); + return; + } + break; + case HOUSE_DIALOGUE_SHOP_IDENTIFY: + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0); //"Select the Item to Identify" + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v1 = pMouse->GetCursorPos(&a2)->x - 14; + pItemCount = (v1 >> 5) + 14 * ((pMouse->GetCursorPos(&v128)->y - 17) >> 5); + if ( pMouse->GetCursorPos(&v141)->x > 13 ) + { + if ( pMouse->GetCursorPos(&v143)->x < 462 ) + { + v2 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount); + if ( v2 ) + { + v3 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v2-1]; + if (v3->Identified()) + v5 = "%24"; + else + { + v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(v3, BildingType_ArmorShop, (int)window_SpeakInHouse->ptr_1C, 4); + v5 = (char *)pMerchantsIdentifyPhrases[v8]; + } + v6 = BuilDialogueString(v5, uActiveCharacter - 1, v3, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v115 = (174 - pFontArrus->CalcTextHeight(v6, &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v6, 3); + return; + } + } + } + } + } + break; + case HOUSE_DIALOGUE_SHOP_REPAIR: + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0); + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + return; + if( (v31 = pMouse->GetCursorPos(&v135)->x - 14, + pItemCount = (v31 >> 5) + 14 * ((pMouse->GetCursorPos(&v142)->y - 17) >> 5), + pMouse->GetCursorPos(&v140)->x <= 13) + || pMouse->GetCursorPos(&v138)->x >= 462 + || (v32 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&pItemCount), v11 = 0, !v32) + || (!(pPlayers[uActiveCharacter]->pOwnItems[v32-1].uAttributes& 2)) ) + return; + v116 = &pPlayers[uActiveCharacter]->pInventoryItems[v33 - 1]; + v35 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItems[v32 - 1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 5); + v15 = (char *)pMerchantsRepairPhrases[v35]; + v36 = BuilDialogueString(v15, uActiveCharacter - 1, v116, (char *)window_SpeakInHouse->ptr_1C, 5, 0); + v115 = (174 - pFontArrus->CalcTextHeight(v36, &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, 0, v115, pWhiteColor, v36, 3); + return; + } + break; + case HOUSE_DIALOGUE_SHOP_6: //buy standart ??? + { + pRenderer->DrawTextureIndexed(8u, 8u, ShopTexture); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[195], 0); //"Select the Item to Buy" + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + pItemCount = 0; + for( int i = 0; i < 6 ; ++i ) + if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][i].uItemID) + ++pItemCount; + if ( pItemCount ) + { + v94 = pMouse->GetCursorPos(&v132); + pItemCount = pRenderer->pActiveZBuffer[v94->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v130)->y]]; + v95 = pItemCount; + if ( pItemCount && pItemCount != -65536 ) + { + --pItemCount; + v97 = uActiveCharacter - 1; + v99 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v95-1], BildingType_ArmorShop, window_SpeakInHouse->par1C, 2); + v100 = BuilDialogueString((char *)pMerchantsBuyPhrases[v99], uActiveCharacter - 1, v98, (char *)window_SpeakInHouse->par1C, 2, 0); + v103 = pFontArrus->CalcTextHeight(v100, &dialog_window, 0, 0); + dialog_window.DrawTitleText(pFontArrus, 0, (174 - v103) / 2 + 138, pWhiteColor, v100, 3); + } + v104 = 0; + v153 = 0; + do + { + //if ( pParty->field_C59C[9 * (v104 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 724] ) + if (pParty->SpecialItemsInShops[window_SpeakInHouse->par1C][v104].uItemID) + { + v105 = ItemsInShopTexture[v104]; + if ( v104 >= 4 ) + { + v110 = 90 - ((signed int)v105->uTextureWidth >> 1); + pRenderer->DrawTextureTransparent(v153 + v110 - 420, 0x7Eu, ItemsInShopTexture[v104]); + v127 = v104 + 1; + v109 = v153 + v110 + 80220; + } + else + { + v106 = 98 - v105->uTextureHeight; + v108 = 98 - v105->uTextureHeight; + v152 = 86 - ((signed int)v105->uTextureWidth >> 1); + pRenderer->DrawTextureTransparent(v152 + v153, v108, ItemsInShopTexture[v104]); + v127 = v104 + 1; + v109 = v152 + v153 + 640 * v106; + } + ZBuffer_DoFill(&pRenderer->pActiveZBuffer[v109], ItemsInShopTexture[v104], v127); + } + v153 += 105; + ++v104; + } + while ( v104 < 8 ); + return; + } + dialog_window.DrawCurrentTime(pParty->field_3C.field_50[window_SpeakInHouse->par1C]- pParty->uTimePlayed); + return; + } + break; + case HOUSE_DIALOGUE_LEARN_SKILLS: + { + if (!sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + v152 = 0; + v38 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); + pActiveButton = v38 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; + if ( (signed int)pActiveButton < v38 / 3 ) + pActiveButton = v38 / 3; + v39 = pDialogueWindow->pStartingPosActiveItem; + v40 = pDialogueWindow->pNumPresenceButton; + v153 = 0; + if ( (signed int)v39 < (signed int)(v39 + v40) ) + { + do + { + v41 = pDialogueWindow->GetControl(v39)->msg_param - 36; + if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v41] && !pPlayers[uActiveCharacter]->pActiveSkills[v41] ) + { + v42 = pFontArrus->CalcTextHeight(pSkillNames[v41], &dialog_window, 0, 0); + v152 += v42; + ++v153; + } + ++v39; + } + while ( (signed int)v39 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + if ( v153 ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], pActiveButton); + dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); + pActiveButton = (149 - v152) / v153; + if ( (149 - v152) / v153 > 32 ) + pActiveButton = 32; + v43 = (149 - v153 * (signed int)pActiveButton - v152) / 2 - (signed int)pActiveButton / 2 + 162; + v152 = pDialogueWindow->pStartingPosActiveItem; + v146 = v43; + if ( v152 < v152 + pDialogueWindow->pNumPresenceButton ) + { + v153 = 2; + do + { + pButton = pDialogueWindow->GetControl(v152); + v46 = pButton->msg_param - 36; + if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v46] || pPlayers[uActiveCharacter]->pActiveSkills[v46] ) + { + pButton->uW = 0; + pButton->uHeight = 0; + pButton->uY = 0; + } + else + { + pButton->uY = (unsigned int)((char *)pActiveButton + v146); + pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v46], &dialog_window, 0, 0); + v49 = pButton->uY; + pButton->uHeight = pTextHeight; + v51 = v49 + pTextHeight - 1; + pButton->uW = v51; + v146 = v51; + pTextColor = pYellowColor; + if ( pDialogueWindow->pCurrentPosActiveItem != v153 ) + pTextColor = pWhiteColor; + dialog_window.DrawTitleText(pFontArrus, 0, v49, pTextColor, pSkillNames[v46], 3); + } + v53 = pDialogueWindow->pStartingPosActiveItem; + ++v152; + textureH = pDialogueWindow->pNumPresenceButton + v53; + ++v153; + } + while ( v152 < textureH ); + } + return; + } + } + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); //"Seek knowledge elsewhere %s the %s" + strcat(pTmpBuf.data(), "\n \n"); + strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further." + v115 = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, 0, v115, pYellowColor, pTmpBuf.data(), 3); + return; + } + break; + } +} + +//----- (004B5D7C) -------------------------------------------------------- +void GuildDialog() +{ + signed int base_teach_price; // ebx@1 + int v3; // edi@6 + int result; // eax@11 + int v6; // esi@13 + signed int v7; // esi@17 + int v8; // esi@22 + signed int v9; // ecx@22 + char *v10; // eax@22 + const char *statusbar_string; // ecx@26 + POINT *v12; // esi@30 + int v13; // ecx@30 + void *v14; // ST1C_4@31 + ItemGen *v15; // ST18_4@31 + int v16; // ST10_4@31 + int v17; // eax@31 + char *v18; // edx@31 + int v19; // eax@32 + int pActiveItem; // esi@35 + int v22; // eax@35 + unsigned int v23; // eax@36 + int v24; // eax@39 + int v25; // eax@40 + int v26; // ecx@47 + GUIButton *pButton; // eax@49 + unsigned int v29; // eax@49 + char *pText; // eax@52 + int pTextHeight; // eax@55 + unsigned int v32; // ecx@55 + int v33; // eax@55 + unsigned __int16 pTextColor; // ax@55 + int v35; // eax@58 + const char *v36; // ST20_4@61 + unsigned __int16 v37; // ST1C_2@61 + int v38; // eax@61 + int v40; // [sp-14h] [bp-300h]@31 + int v41; // [sp-10h] [bp-2FCh]@31 + unsigned __int16 v42; // [sp-Ch] [bp-2F8h]@31 + char *v43; // [sp-8h] [bp-2F4h]@31 + unsigned int v44; // [sp-4h] [bp-2F0h]@31 + char Dest[100]; // [sp+Ch] [bp-2E0h]@3 + char v46[100]; // [sp+70h] [bp-27Ch]@3 + char v47[100]; // [sp+D4h] [bp-218h]@3 + char v48[100]; // [sp+138h] [bp-1B4h]@3 + char v49[100]; // [sp+19Ch] [bp-150h]@3 + POINT v50; // [sp+264h] [bp-88h]@30 + POINT v51; // [sp+26Ch] [bp-80h]@30 + GUIWindow working_window; // [sp+274h] [bp-78h]@1 + signed int v53; // [sp+27Ch] [bp-70h]@1 + signed int v54; // [sp+284h] [bp-68h]@1 + int pColorWhite; // [sp+2CCh] [bp-20h]@1 + int pColorYellow; // [sp+2D0h] [bp-1Ch]@1 + int v58; // [sp+2D4h] [bp-18h]@1 + unsigned __int8 uPlayerID; // [sp+2DBh] [bp-11h]@31 + bool pSkillFlag; // [sp+2DCh] [bp-10h]@35 + int v61; // [sp+2E0h] [bp-Ch]@35 + int pItemNum; + unsigned int v62; // [sp+2E4h] [bp-8h]@13 + int v63; // [sp+2E8h] [bp-4h]@1 + int pNumActivItem; + int all_text_height; + + memcpy(&working_window, window_SpeakInHouse, sizeof(GUIWindow)); + working_window.uFrameX = 483; + working_window.uFrameWidth = 148; + working_window.uFrameZ = 334; + pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu); + pColorYellow = TargetColor(0xFFu, 0xFFu, 0x9Bu); + base_teach_price = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * 500.0); + v63 = base_teach_price * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; + if ( v63 < base_teach_price / 3 ) + v63 = base_teach_price / 3; + strcpy(Dest, ""); + strcpy(v46, ""); + strcpy(v47, ""); + strcpy(v48, ""); + strcpy(v49, ""); + if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN ) + { + if ( dialog_menu_id != HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) //buy skill + { + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + if ( pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[403], pClassNames[dialog_menu_id - 16]); //"You already know the %s skill" + ShowStatusBarString(pTmpBuf.data(), 2); + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + } + else + { + if ( pParty->uNumGold < v63 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); //"You don't have enough gold" + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); + } + else + { + Party::TakeGold(v63); + pPlayers[uActiveCharacter]->pActiveSkills[dialog_menu_id-36] = 1; + } + } + } + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + pRenderer->DrawTextureIndexed(8, 8, ShopTexture); + v6 = 0; + v62 = 0; + v63 = 32; + do + { + if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v6].uItemID) + { + pRenderer->DrawTextureTransparent(v63, 0x5Au, ItemsInShopTexture[v6]); + ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 230528), ItemsInShopTexture[v6], v6 + 1); + } + v63 += 70; + v62 += 280; + ++v6; + } + while ( v63 < 452 ); + v62 = 1680; + v7 = 6; + v63 = 32; + do + { + if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v7].uItemID) + { + pRenderer->DrawTextureTransparent(v63, 0xFAu, ItemsInShopTexture[v7]); + ZBuffer_DoFill((int *)((char *)pRenderer->pActiveZBuffer + v62 + 638448), ItemsInShopTexture[v7], v7 + 1); + } + v63 += 70; + v62 += 280; + ++v7; + } + while ( v63 < 452 ); + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v8 = 0; + v9 = 12; + do + { + if (pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][v9].uItemID ) + ++v8; + --v9; + } + while ( v9 ); + GetAsyncKeyState(17); + statusbar_string = pGlobalTXT_LocalizationStrings[195]; //"Select the Item to Buy" + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + statusbar_string = pGlobalTXT_LocalizationStrings[196]; //"Select the Special Item to Buy" + DrawTextAtStatusBar(statusbar_string, 0); + if ( !v8 ) + { + working_window.DrawCurrentTime(__PAIR__( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)window_SpeakInHouse->ptr_1C + 44472], + *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)window_SpeakInHouse->ptr_1C + 44468]) - pParty->uTimePlayed); + return; + } + v12 = pMouse->GetCursorPos(&v51); + result = v12->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v50)->y]; + v13 = pRenderer->pActiveZBuffer[result] & 0xFFFF; + if ( pRenderer->pActiveZBuffer[result] & 0xFFFF ) + { + v14 = window_SpeakInHouse->ptr_1C; + v15 = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v13 + 12 * (int)v14)); + v16 = (int)window_SpeakInHouse->ptr_1C; + uPlayerID = uActiveCharacter - 1; + v17 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction( (ItemGen *)&pParty->pPlayers[1].uExpressionTimeLength + v13 + 12 * (int)v14, BildingType_MagicShop, v16, 2); + v18 = BuilDialogueString((char *)pMerchantsBuyPhrases[v17], uPlayerID, v15, (char *)v14, 2, 0); + v19 = pFontArrus->CalcTextHeight(v18, &working_window, 0, 0); + working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorWhite, v18, 3); + return; + } + } + return; + } + if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)pPlayers[uActiveCharacter]->_guilds_member_bits, + guild_mambership_flags[(unsigned int)window_SpeakInHouse->ptr_1C-139]) ) + { //you must me member + v38 = pFontArrus->CalcTextHeight(pNPCTopics[121].pText, &working_window, 0, 0); + working_window.DrawTitleText(pFontArrus, 0, (212 - v38) / 2 + 101, pColorYellow, pNPCTopics[121].pText, 3u); + pDialogueWindow->pNumPresenceButton = 0; + return; + } + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + v61 = 0; + pSkillFlag = false; + pActiveItem = pDialogueWindow->pStartingPosActiveItem; + v22 = pActiveItem + pDialogueWindow->pNumPresenceButton; + pItemNum = 0; + if ( pDialogueWindow->pStartingPosActiveItem >= pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); // "Seek knowledge elsewhere %s the %s" + strcat(pTmpBuf.data(), "\n \n"); + strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further." + v19 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0); + working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); + return; + } + all_text_height = 0; + do + { + v23 = pDialogueWindow->GetControl(pActiveItem)->msg_param; + if ( v23 == 18 ) + { + all_text_height += pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[400], &working_window, 0, 0); //"Buy Spells" + v61++; + } + else + { + if( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v23 - 36] + && !pPlayers[uActiveCharacter]->pActiveSkills[v23 - 36] ) + { + all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v23 - 36], &working_window, 0, 0); + v61++; + pSkillFlag = true; + } + } + ++pActiveItem; + } + while ( pActiveItem < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + if ( !v61 ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]); // "Seek knowledge elsewhere %s the %s" + strcat(pTmpBuf.data(), "\n \n"); + strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); //"I can offer you nothing further." + v19 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &working_window, 0, 0); + working_window.DrawTitleText(pFontArrus, 0, (174 - v19) / 2 + 138, pColorYellow, pTmpBuf.data(), 3); + return; + } + if ( pSkillFlag ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v63); //"Skill Cost: %lu" + working_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3); + } + v58 = (149 - all_text_height) / v61; + if ( v58 > 32 ) + v58 = 32; + v26 = (149 - v61 * v58 - all_text_height) / 2 - v58 / 2 + 162; + pNumActivItem = pDialogueWindow->pStartingPosActiveItem; + if (pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ) + { + pItemNum = 2; + do + { + pButton = pDialogueWindow->GetControl(pItemNum); + v29 = pButton->msg_param; + if ( v29 == 18 ) + { + pText = pGlobalTXT_LocalizationStrings[400]; //"Buy Spells" + pButton->uY = v58 + v26; + pTextHeight = pFontArrus->CalcTextHeight(pText, &working_window, 0, 0); + v32 = pButton->uY; + pButton->uHeight = pTextHeight; + v33 = v32 + pTextHeight - 1; + pButton->uW = v33; + v26 = v33; + pTextColor = pColorYellow; + if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) + pTextColor = pColorWhite; + working_window.DrawTitleText(pFontArrus, 0, v32, pTextColor, pText, 3); + } + else + { + if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v29 - 36] + && !pPlayers[uActiveCharacter]->pActiveSkills[v29 - 36] ) + { + pButton->uY = v58 + v26; + pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v29 - 36], &working_window, 0, 0); + v32 = pButton->uY; + pButton->uHeight = pTextHeight; + v33 = v32 + pTextHeight - 1; + pButton->uW = v33; + v26 = v33; + pTextColor = pColorYellow; + if ( pDialogueWindow->pCurrentPosActiveItem != pItemNum ) + pTextColor = pColorWhite; + working_window.DrawTitleText(pFontArrus, 0, v32, pTextColor, pSkillNames[v29 - 36], 3); + } + else + { + pButton->uW = 0; + pButton->uHeight = 0; + pButton->uY = 0; + } + } + ++pItemNum; + } + while ( pItemNum < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + } + return; +} + +//----- (004B705E) -------------------------------------------------------- +void TempleDialog() + { + GUIWindow *v0; // ebx@1 + Player *v1; // esi@1 + int v2; // edi@1 + int result; // eax@4 + GUIWindow *v4; // edi@6 + void *v5; // eax@6 + int v6; // eax@6 + unsigned int v7; // eax@8 + int v8; // ecx@8 + unsigned int v9; // eax@9 + int v10; // eax@11 + int v11; // eax@12 + GUIWindow *v12; // ecx@16 + int v13; // edx@16 + GUIButton *v14; // eax@19 + GUIButton *v15; // edi@19 + int v16; // eax@19 + const char *v17; // eax@21 + int v18; // eax@21 + unsigned int v19; // ecx@21 + int v20; // eax@21 + unsigned __int16 v21; // ax@21 + unsigned __int16 v22; // ST14_2@27 + int v23; // eax@27 + double v24; // st7@28 + unsigned int v25; // ebx@28 + DDM_DLV_Header *v26; // edi@29 + int v27; // eax@31 + int v28; // eax@32 + //unsigned int v29; // ecx@34 + unsigned int v30; // edx@36 + unsigned int v31; // edx@38 + unsigned int v32; // edx@40 + unsigned int v33; // edx@42 + unsigned int v34; // edx@44 + int v35; // edi@50 + signed int v36; // eax@50 + unsigned __int8 v37; // al@54 + int v38; // ecx@54 + GUIWindow *v39; // eax@56 + unsigned __int8 v40; // al@61 + GUIButton *v41; // edi@64 + int v42; // esi@66 + GUIWindow *v43; // ecx@66 + int v44; // edi@66 + int v45; // eax@68 + signed int v46; // edi@69 + int v47; // edi@71 + GUIButton *v48; // eax@73 + const char *v49; // edx@73 + GUIButton *v50; // esi@73 + int v51; // eax@73 + unsigned int v52; // ecx@73 + unsigned __int16 v53; // ax@73 + char a1[300]; // [sp+10h] [bp-1B4h]@64 + GUIWindow v57; // [sp+13Ch] [bp-88h]@1 + __int64 v58; // [sp+190h] [bp-34h]@1 + __int64 v59; // [sp+198h] [bp-2Ch]@1 + __int64 v60; // [sp+1A0h] [bp-24h]@1 + GUIWindow *v61; // [sp+1ACh] [bp-18h]@6 + unsigned int v62; // [sp+1B0h] [bp-14h]@8 + unsigned __int8 v63; // [sp+1B7h] [bp-Dh]@64 + int v64; // [sp+1B8h] [bp-Ch]@6 + unsigned int v65; // [sp+1BCh] [bp-8h]@6 + DDM_DLV_Header *v66; // [sp+1C0h] [bp-4h]@6 + + v0 = window_SpeakInHouse; + memcpy(&v57, window_SpeakInHouse, sizeof(v57)); + v57.uFrameX = 483; + v57.uFrameWidth = 148; + v57.uFrameZ = 334; + HIDWORD(v58) = TargetColor(0xFFu, 0xFFu, 0xFFu); + HIDWORD(v59) = TargetColor(0xFFu, 0xFFu, 0x9Bu); + v1 = pPlayers[uActiveCharacter]; + //v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C]); + v2 = pPlayers[uActiveCharacter]->GetTempleHealCostModifier(p2DEvents[v0->par1C - 1].fPriceMultiplier); + HIDWORD(v60) = v2; + if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN ) + { + if ( dialog_menu_id != HOUSE_DIALOGUE_TEMPLE_HEAL ) + { + if ( dialog_menu_id != HOUSE_DIALOGUE_TEMPLE_DONATE ) + { + if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS ) + { + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v4 = pDialogueWindow; + v61 = pDialogueWindow; + v5 = window_SpeakInHouse->ptr_1C; + v66 = 0; + //v65 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (signed int)v5] * 500.0); + v65 = (signed __int64)(p2DEvents[(signed int)v5 - 1].flt_24 * 500.0); + v6 = v1->GetMerchant(); + v64 = (signed int)(v65 * (100 - v6)) / 100; + if ( v64 < (signed int)v65 / 3 ) + v64 = (signed int)v65 / 3; + v7 = v4->pStartingPosActiveItem; + v8 = v7 + v4->pNumPresenceButton; + v65 = 0; + v62 = v7; + if ( (signed int)v7 >= v8 ) + goto LABEL_78; + do + { + v9 = v4->GetControl(v62)->msg_param - 36; + if ( byte_4ED970_skill_learn_ability_by_class_table[v1->classType][v9] && !v1->pActiveSkills[v9] ) + { + v10 = pFontArrus->CalcTextHeight(pSkillNames[v9], &v57, 0, 0); + v66 = (DDM_DLV_Header *)((char *)v66 + v10); + ++v65; + } + v11 = v4->pStartingPosActiveItem; + ++v62; + } + while ( (signed int)v62 < v4->pNumPresenceButton + v11 ); + if ( v65 ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v64); + v57.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3u); + v64 = (149 - (signed int)v66) / (signed int)v65; + if ( v64 > 32 ) + v64 = 32; + v65 = (signed int)(149 - v65 * v64 - (int)v66) / 2 - v64 / 2 + 162; + v12 = v61; + result = v61->pStartingPosActiveItem; + v13 = result + v61->pNumPresenceButton; + v62 = v61->pStartingPosActiveItem; + if ( result < v13 ) + { + v66 = (DDM_DLV_Header *)2; + while ( 1 ) + { + v14 = v12->GetControl(v62); + v15 = v14; + v16 = v14->msg_param - 36; + if ( !byte_4ED970_skill_learn_ability_by_class_table[v1->classType][v16] || v1->pActiveSkills[v16] ) + { + v15->uW = 0; + v15->uHeight = 0; + v15->uY = 0; + } + else + { + v17 = pSkillNames[v16]; + v15->uY = v64 + v65; + HIDWORD(v60) = (uint32)v17; + v18 = pFontArrus->CalcTextHeight(v17, &v57, 0, 0); + v19 = v15->uY; + v15->uHeight = v18; + v20 = v19 + v18 - 1; + v15->uW = v20; + v65 = v20; + v21 = WORD2(v59); + if ( (DDM_DLV_Header *)pDialogueWindow->pCurrentPosActiveItem != v66 ) + v21 = WORD2(v58); + v57.DrawTitleText(pFontArrus, 0, v19, v21, (const char *)HIDWORD(v60), 3u); + } + result = (int)v61; + ++v62; + v66 = (DDM_DLV_Header *)((char *)v66 + 1); + if ( (signed int)v62 >= v61->pNumPresenceButton + v61->pStartingPosActiveItem ) + break; + v12 = v61; + } + } + } + else + { +LABEL_78: + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], v1->pName, pClassNames[v1->classType]); + strcat(pTmpBuf.data(), "\n \n"); + strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); + v22 = WORD2(v59); + v23 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &v57, 0, 0); + v57.DrawTitleText(pFontArrus, 0, (174 - v23) / 2 + 138, v22, pTmpBuf.data(), 3u); + } + } + } + return; + } + // DONATION + //v24 = p2DEvents_minus1__20[13 * (unsigned int)ptr_507BC0->ptr_1C]; + v24 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; + v25 = 0; + if ( pParty->uNumGold >= (unsigned int)(signed __int64)v24 ) + { + Party::TakeGold((signed __int64)v24); + v26 = &pOutdoor->ddm; + if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor ) + v26 = &pIndoor->dlv; + v27 = v26->uReputation; + v66 = v26; + if ( v27 > -5 ) + { + v28 = v27 - 1; + v26->uReputation = v28; + if ( v28 < -5 ) + v26->uReputation = -5; + } + if ( (unsigned __int8)byte_F8B1EF[uActiveCharacter] == pParty->uDaysPlayed % 7 ) + { + if ( v26->uReputation <= -5 ) + { + v30 = pParty->uDaysPlayed % 7 + 1; + LOBYTE(v30) = v30 | 0x80; + _42777D_CastSpell_UseWand_ShootArrow(SPELL_AIR_WIZARD_EYE, uActiveCharacter - 1, v30, 48, 0); + } + if ( v26->uReputation <= -10 ) + { + v31 = pParty->uDaysPlayed % 7 + 1; + LOBYTE(v31) = v31 | 0x80; + _42777D_CastSpell_UseWand_ShootArrow(SPELL_SPIRIT_PRESERVATION, uActiveCharacter - 1, v31, 48, 0); + v26 = v66; + } + if ( v26->uReputation <= -15 ) + { + v32 = pParty->uDaysPlayed % 7 + 1; + LOBYTE(v32) = v32 | 0x80; + _42777D_CastSpell_UseWand_ShootArrow(SPELL_BODY_PROTECTION_FROM_MAGIC, uActiveCharacter - 1, v32, 48, 0); + v26 = v66; + } + if ( v26->uReputation <= -20 ) + { + v33 = pParty->uDaysPlayed % 7 + 1; + LOBYTE(v33) = v33 | 0x80; + _42777D_CastSpell_UseWand_ShootArrow(SPELL_LIGHT_HOUR_OF_POWER, uActiveCharacter - 1, v33, 48, 0); + v26 = v66; + } + if ( v26->uReputation <= -25 ) + { + v34 = pParty->uDaysPlayed % 7 + 1; + LOBYTE(v34) = v34 | 0x80; + _42777D_CastSpell_UseWand_ShootArrow(SPELL_LIGHT_DAY_OF_PROTECTION, uActiveCharacter - 1, v34, 48, 0); + } + } + ++byte_F8B1EF[uActiveCharacter]; + v1->PlaySound(SPEECH_83, 0); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[527], 2u); // "Thank You!" + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25); + return; + } + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25); + return; + } + if ( !v1->IsPlayerHealableByTemple() ) + return; + v25 = 0; + if ( pParty->uNumGold < v2 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25); + return; + } + Party::TakeGold(v2); + v35 = LODWORD(v1->pConditions[17]); + v59 = v1->pConditions[14]; + v58 = v1->pConditions[15]; + v60 = v1->pConditions[16]; + v61 = (GUIWindow *)HIDWORD(v1->pConditions[17]); + memset(v1, 0, 0xA0u); + v1->sHealth = v1->GetMaxHealth(); + v1->sMana = v1->GetMaxMana(); + v36 = (signed int)window_SpeakInHouse->ptr_1C; + if ( v36 != 78 && (v36 <= 80 || v36 > 82) ) + { + if ( (unsigned int)v61 | v35 ) + { + v37 = LOBYTE(v1->uPrevFace); + v38 = v1->uPrevVoiceID; + v1->uCurrentFace = v37; + v1->uVoiceID = v38; + ReloadPlayerPortraits(uActiveCharacter - 1, (char)v37); + } + pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0); + v1->PlaySound(SPEECH_82, 0); + pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25); + return; + } + v39 = v61; + if ( (unsigned int)v61 | v35 ) + { + LODWORD(v1->pConditions[17]) = v35; + } + else + { + if ( !v60 && !v58 && !v59 ) + { + pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0); + v1->PlaySound(SPEECH_82, 0); + pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25); + return; + } + v1->uPrevFace = v1->uCurrentFace; + v1->uPrevVoiceID = v1->uVoiceID; + v1->SetCondition(0x11u, 1); + v1->uVoiceID = (v1->GetSexByVoice() != 0) + 23; + v40 = (v1->GetSexByVoice() != 0) + 23; + v1->uCurrentFace = v40; + ReloadPlayerPortraits(uActiveCharacter - 1, (char)v40); + LODWORD(v1->pConditions[17]) = LODWORD(pParty->uTimePlayed); + v39 = (GUIWindow *)HIDWORD(pParty->uTimePlayed); + } + HIDWORD(v1->pConditions[17]) = (int)v39; + pAudioPlayer->PlaySound((SoundID)(SOUND_GoldReceived|0x2), -1, 0, -1, 0, 0, 0, 0); + v1->PlaySound(SPEECH_82, 0); + pOtherOverlayList->_4418B1(20, uActiveCharacter + 99, 0, 65536); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v25); + return; // void func + } + v63 = 1; + v41 = pDialogueWindow->GetControl(pDialogueWindow->pStartingPosActiveItem); + strcpy(a1, ""); + v41->uHeight = 0; + v41->uY = 0; + if ( v1->IsPlayerHealableByTemple() ) + { + sprintf(a1, "%s %d %s", pGlobalTXT_LocalizationStrings[104], HIDWORD(v60), pGlobalTXT_LocalizationStrings[97]); + v63 = 0; + } + strcpy(&a1[100], pGlobalTXT_LocalizationStrings[68]); + strcpy(&a1[200], pGlobalTXT_LocalizationStrings[160]); + v42 = v63; + v43 = pDialogueWindow; + v44 = v63; + v66 = 0; + if ( v63 < pDialogueWindow->pNumPresenceButton ) + { + v61 = (GUIWindow *)&a1[100 * v63]; + do + { + v45 = pFontArrus->CalcTextHeight((const char *)v61, &v57, 0, 0); + v66 = (DDM_DLV_Header *)((char *)v66 + v45); + v43 = pDialogueWindow; + v61 = (GUIWindow *)((char *)v61 + 100); + ++v44; + } + while ( v44 < pDialogueWindow->pNumPresenceButton ); + } + v46 = v43->pNumPresenceButton - v42; + v64 = (174 - (signed int)v66) / v46; + if ( v64 > 32 ) + v64 = 32; + v47 = (174 - v64 * v46 - (signed int)v66) / 2 - v64 / 2 + 138; + v65 = v42 + v43->pStartingPosActiveItem; + if ( v42 + v43->pStartingPosActiveItem < v43->pStartingPosActiveItem + v43->pNumPresenceButton ) + { + v61 = (GUIWindow *)(v42 + 2); + v66 = (DDM_DLV_Header *)&a1[100 * v42]; + do + { + v48 = v43->GetControl(v65); + v49 = (const char *)v66; + v50 = v48; + v48->uY = v64 + v47; + v51 = pFontArrus->CalcTextHeight(v49, &v57, 0, 0); + v52 = v50->uY; + v50->uHeight = v51; + v47 = v52 + v51 - 1; + v50->uW = v47; + v53 = WORD2(v59); + if ( (GUIWindow *)pDialogueWindow->pCurrentPosActiveItem != v61 ) + v53 = WORD2(v58); + v57.DrawTitleText(pFontArrus, 0, v52, v53, (const char *)v66, 3u); + v43 = pDialogueWindow; + v66 = (DDM_DLV_Header *)((char *)v66 + 100); + v61 = (GUIWindow *)((char *)v61 + 1); + ++v65; + } + while ( (signed int)v65 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + } + return; + } + +//----- (004B4710) -------------------------------------------------------- +void TrainingDialog() +{ + //Player *v0; // ebx@1 + int color2; // eax@1 + //unsigned int v2; // ecx@1 + //int v3; // eax@1 + //signed int v4; // edx@1 + unsigned __int64 v5; // edi@3 + //unsigned int v6; // esi@3 + //void *v7; // ecx@3 + int v8; // edx@4 + double v9; // st7@6 + signed int v10; // esi@6 + int v11; // ecx@6 + //int result; // eax@9 + GUIWindow *v13; // edi@14 + signed int v14; // esi@14 + unsigned int v15; // esi@16 + int v16; // eax@16 + unsigned int v17; // eax@17 + int v18; // eax@19 + int v19; // ecx@24 + GUIButton *v20; // eax@26 + GUIButton *v21; // esi@26 + int v22; // eax@26 + const char *v23; // eax@28 + int v24; // eax@28 + unsigned int v25; // ecx@28 + int v26; // eax@28 + unsigned __int16 v27; // ax@28 + //int v28; // eax@32 + unsigned __int16 v29; // ST14_2@34 + int v30; // eax@34 + //const char *v31; // ST18_4@36 + //unsigned __int16 v32; // ST14_2@36 + int v33; // eax@36 + int v34; // eax@37 + unsigned int v35; // edi@38 + unsigned int v36; // eax@38 + //int v37; // ecx@41 + //char *v38; // eax@41 + //int *v39; // eax@45 + unsigned int v40; // eax@46 + //void *v41; // ecx@46 + unsigned int v42; // eax@46 + GUIWindow *v43; // ecx@59 + int v44; // edx@59 + char **v45; // esi@60 + //int v46; // eax@62 + int v47; // eax@68 + //int v48; // edx@69 + int v49; // ebx@69 + //unsigned __int8 v50; // sf@69 + char **v51; // edi@70 + GUIButton *v52; // eax@71 + GUIButton *v53; // esi@71 + int v54; // eax@71 + unsigned int v55; // ecx@71 + int v56; // eax@71 + unsigned __int16 v57; // ax@71 + unsigned __int16 v58; // [sp-Ch] [bp-90h]@38 + //const char *v59; // [sp-Ch] [bp-90h]@63 + char *v60; // [sp-8h] [bp-8Ch]@38 + //char *v61; // [sp-8h] [bp-8Ch]@63 + unsigned int v62; // [sp-4h] [bp-88h]@38 + int v63; // [sp-4h] [bp-88h]@52 + //char *v64; // [sp-4h] [bp-88h]@63 + GUIWindow v65; // [sp+Ch] [bp-78h]@1 + //__int64 v66; // [sp+60h] [bp-24h]@3 + unsigned int white; // [sp+68h] [bp-1Ch]@1 + int v68; // [sp+6Ch] [bp-18h]@3 + int v69; // [sp+70h] [bp-14h]@6 + //unsigned int i; // [sp+74h] [bp-10h]@1 + //int v71; // [sp+78h] [bp-Ch]@1 + int v72; // [sp+7Ch] [bp-8h]@16 + int v73; // [sp+80h] [bp-4h]@14 + + //v0 = pPlayers[uActiveCharacter]; + memcpy(&v65, window_SpeakInHouse, sizeof(v65)); + v65.uFrameX = 483; + v65.uFrameWidth = 148; + v65.uFrameZ = 334; + white = TargetColor(255, 255, 255); + color2 = TargetColor(0xE1u, 0xCDu, 0x23u); + //v71 = color2; + //v2 = v0->uLevel; + //v3 = 0; + //v4 = 0; + //for ( i = v2; v4 < (signed int)v2; ++v4 ) + // v3 += v4 + 1; + //v5 = 1000 * v3; + v5 = 1000ui64 * pPlayers[uActiveCharacter]->uLevel * (pPlayers[uActiveCharacter]->uLevel + 1) / 2; // E n = n(n + 1) / 2 + //v6 = HIDWORD(v0->uExperience); + //v7 = window_SpeakInHouse->ptr_1C; + v68 = pMaxLevelPerTrainingHallType[(unsigned int)window_SpeakInHouse->ptr_1C - HOUSE_TRAINING_HALL_EMERALD_ISLE]; + //v66 = 1000 * v3; + if (pPlayers[uActiveCharacter]->uExperience >= v5) + { + v8 = pPlayers[uActiveCharacter]->classType % 4 + 1; + if ( v8 == 4 ) + v8 = 3; + v9 = (double)pPlayers[uActiveCharacter]->uLevel; + //i = 0; + v69 = v8; + //v10 = (signed __int64)(v9 * p2DEvents_minus1__20[13 * (signed int)v7] * (double)v8); + v10 = (signed __int64)(v9 * p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * (double)v8); + v11 = v10 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; + if ( v11 < v10 / 3 ) + v11 = v10 / 3; + //i = v11; + } + + if (sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + { + if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN ) + { + if ( dialog_menu_id != HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) + { + if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS ) + { + if (sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + { + //i = 0; + int _v0 = 0; + v13 = pDialogueWindow; + //v14 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0); + v14 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); + v73 = v14 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; + if ( v73 < v14 / 3 ) + v73 = v14 / 3; + v15 = v13->pStartingPosActiveItem; + v16 = v13->pNumPresenceButton; + v72 = 0; + if ( (signed int)v15 >= (signed int)(v15 + v16) ) + goto LABEL_76; + do + { + v17 = v13->GetControl(v15)->msg_param - 36; + if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v17] && !pPlayers[uActiveCharacter]->pActiveSkills[v17] ) + { + v18 = pFontArrus->CalcTextHeight(pSkillNames[v17], &v65, 0, 0); + _v0 += v18; + ++v72; + } + ++v15; + } + while ( (signed int)v15 < v13->pNumPresenceButton + v13->pStartingPosActiveItem ); + if ( v72 ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v73);// "Skill Cost: %lu" + v65.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3u); + v73 = (signed int)(149 - _v0) / v72; + if ( v73 > 32 ) + v73 = 32; + //result = v13->pStartingPosActiveItem; + v19 = (signed int)(149 - v72 * v73 - _v0) / 2 - v73 / 2 + 162; + int _v1 = v13->pStartingPosActiveItem; + v68 = v19; + if (v13->pStartingPosActiveItem < v13->pStartingPosActiveItem + v13->pNumPresenceButton ) + { + v72 = 2; + do + { + v20 = v13->GetControl(_v1); + v21 = v20; + v22 = v20->msg_param - 36; + if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v22] || pPlayers[uActiveCharacter]->pActiveSkills[v22] ) + { + v21->uW = 0; + v21->uHeight = 0; + v21->uY = 0; + } + else + { + v23 = pSkillNames[v22]; + v21->uY = v73 + v68; + //HIDWORD(v66) = (int)v23; + v24 = pFontArrus->CalcTextHeight(v23, &v65, 0, 0); + v25 = v21->uY; + v21->uHeight = v24; + v26 = v25 + v24 - 1; + v21->uW = v26; + v68 = v26; + v27 = color2; + if ( pDialogueWindow->pCurrentPosActiveItem != v72 ) + v27 = white; + v65.DrawTitleText(pFontArrus, 0, v25, v27, v23, 3u); + } + ++_v1; + ++v72; + } + while ( (signed int)_v1 < v13->pStartingPosActiveItem + v13->pNumPresenceButton ); + } + } + else + { +LABEL_76: + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);// + // "Seek knowledge elsewhere %s the %s" + strcat(pTmpBuf.data(), "\n \n"); + strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further." + v29 = color2; + v30 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &v65, 0, 0); + v65.DrawTitleText(pFontArrus, 0, (174 - v30) / 2 + 138, v29, pTmpBuf.data(), 3u); + } + } + } + return; + } + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + //v31 = pNPCTopics[122].pText; + //v32 = color2; + v33 = pFontArrus->CalcTextHeight(pNPCTopics[122].pText, &v65, 0, 0); + v65.DrawTitleText(pFontArrus, 0, (212 - v33) / 2 + 101, color2, pNPCTopics[122].pText, 3); + pDialogueWindow->pNumPresenceButton = 0; + return; + } + v34 = pPlayers[uActiveCharacter]->uLevel; + if ( v34 < v68 ) + { + if ( (signed __int64)pPlayers[uActiveCharacter]->uExperience >= v5 ) + { + if ( pParty->uNumGold >= v11) + { + Party::TakeGold(v11); + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, HouseSound_NotEnoughMoney_TrainingSuccessful); + ++pPlayers[uActiveCharacter]->uLevel; + pPlayers[uActiveCharacter]->uSkillPoints += pPlayers[uActiveCharacter]->uLevel / 10 + 5; + pPlayers[uActiveCharacter]->sHealth = pPlayers[uActiveCharacter]->GetMaxHealth(); + pPlayers[uActiveCharacter]->sMana = pPlayers[uActiveCharacter]->GetMaxMana(); + + uint max_level_in_party = player_levels[0]; + for (uint _it = 1; _it < 4; ++_it) + { + if (player_levels[_it] > max_level_in_party) + max_level_in_party = player_levels[_it]; + } + + ++player_levels[uActiveCharacter - 1]; + if (player_levels[uActiveCharacter - 1] > max_level_in_party) // if we reach new maximum party level + // feature is broken thou, since this array is always zeroed in EnterHouse + { + v40 = _494820_training_time(pParty->uCurrentHour); + //v41 = window_SpeakInHouse->ptr_1C; + v42 = 60 * (v40 + 4) - pParty->uCurrentMinute; + if ((unsigned int)window_SpeakInHouse->ptr_1C == HOUSE_TRAINING_HALL_94 || + (unsigned int)window_SpeakInHouse->ptr_1C == HOUSE_TRAINING_HALL_95) + v42 += 720; + RestAndHeal((signed int)(v42 + 10080)); + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor ) + pOutdoor->SetFog(); + } + pPlayers[uActiveCharacter]->PlaySound(SPEECH_87, 0); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[430], pPlayers[uActiveCharacter]->pName, pPlayers[uActiveCharacter]->uLevel, pPlayers[uActiveCharacter]->uLevel / 10 + 5);// + // "%s is now Level %lu and has earned %lu Skill Points!" + ShowStatusBarString(pTmpBuf.data(), 2); + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" + v63 = 4; +LABEL_55: + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v63); +//LABEL_56: + /*result = pMessageQueue_50CBD0->uNumMessages; + if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; + result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; + *(&pMessageQueue_50CBD0->uNumMessages + result) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + } + return result;*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, 0); + return; + } + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[538], (unsigned int)(v5 - pPlayers[uActiveCharacter]->uExperience), v34 + 1);// + // "You need %d more experience to train to level %d" + v35 = 0; + v62 = 3; + v60 = pTmpBuf.data(); + v58 = color2; + v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &v65, 0, 0)) / 2 + 88; + } + else + { + sprintf(pTmpBuf.data(), "%s\n \n%s", pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]);// + // ""With your skills, you should be working here as a teacher."" + // ""Sorry, but we are unable to train you."" + v35 = 0; + v62 = 3; + v60 = pTmpBuf.data(); + v58 = color2; + v36 = (212 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &v65, 0, 0)) / 2 + 101; + } + v65.DrawTitleText(pFontArrus, v35, v36, v58, v60, v62); + v63 = 3; + goto LABEL_55; + } + + if (sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win()) + { + v43 = pDialogueWindow; + v72 = 0; + pShopOptions[0] = pTmpBuf.data(); + pShopOptions[1] = pGlobalTXT_LocalizationStrings[160];// "Learn Skills" + v44 = pDialogueWindow->pNumPresenceButton; + v73 = pDialogueWindow->pStartingPosActiveItem; + if ( v73 < v73 + v44 ) + { + v45 = pShopOptions.data(); + do + { + if ( v43->GetControl(v73)->msg_param == HOUSE_DIALOGUE_TRAININGHALL_TRAIN ) + { + //v46 = pPlayers[uActiveCharacter]->uLevel; + if (pPlayers[uActiveCharacter]->uLevel >= v68) + sprintfex(*v45, "%s\n \n%s", + pGlobalTXT_LocalizationStrings[536], pGlobalTXT_LocalizationStrings[529]); //"With your skills, you should be working here as a teacher." "Sorry, but we are unable to train you." + else + { + if (pPlayers[uActiveCharacter]->uExperience < v5) + sprintfex(*v45, pGlobalTXT_LocalizationStrings[538], // "You need %d more experience to train to level %d" + (uint)(v5 - pPlayers[uActiveCharacter]->uExperience), pPlayers[uActiveCharacter]->uLevel + 1); + else + sprintfex(*v45, pGlobalTXT_LocalizationStrings[537], // "Train to level %d for %d gold" + pPlayers[uActiveCharacter]->uLevel + 1, v11); + } + } + v47 = pFontArrus->CalcTextHeight(*v45, &v65, 0, 0); + v43 = pDialogueWindow; + v72 += v47; + ++v45; + ++v73; + } + while ( v73 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + } + + v49 = (2 * (87 - (174 - v72) / 2) - v72) / 2 - (174 - v72) / 2 / 2 + 138; + v73 = v43->pStartingPosActiveItem; + if (v43->pStartingPosActiveItem < v43->pStartingPosActiveItem + v43->pNumPresenceButton) + { + int _v3 = 2; + v51 = pShopOptions.data(); + do + { + v52 = v43->GetControl(v73); + v53 = v52; + v52->uY = (174 - v72) / 2 + v49; + v54 = pFontArrus->CalcTextHeight(*v51, &v65, 0, 0); + v55 = v53->uY; + v53->uHeight = v54; + v56 = v54 + v55 - 1; + v53->uW = v56; + v49 = v56; + v57 = color2; + if ( pDialogueWindow->pCurrentPosActiveItem != _v3 ) + v57 = white; + v65.DrawTitleText(pFontArrus, 0, v55, v57, *v51, 3u); + v43 = pDialogueWindow; + ++_v3; + ++v51; + ++v73; + } + while ( v73 < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton); + } + } + } +} + +//----- (004B4FCF) -------------------------------------------------------- +void MagicShopDialog() +{ + int result; // eax@6 + signed int v2; // esi@8 + unsigned int v3; // ebx@10 + char *v4; // eax@11 + char *v5; // eax@12 + unsigned int v6; // eax@12 + int v7; // ST08_4@14 + int v8; // eax@14 + unsigned __int8 v9; // dl@14 + char *v10; // ecx@14 + signed int v11; // esi@16 + int v12; // ST08_4@19 + int v13; // eax@19 + int all_text_height; // edi@21 + char **v15; // esi@21 + int v16; // eax@22 + int v18; // edx@23 + int v19; // edi@23 + unsigned __int8 v20; // sf@23 + GUIButton *control_button; // esi@25 + const char **v22; // eax@25 + int v23; // eax@25 + unsigned int v24; // ecx@25 + const char **v25; // edx@25 + unsigned __int16 text_color; // ax@25 + signed int pTextHeight; // esi@30 + int v28; // ST08_4@34 + int v29; // eax@34 + char *v30; // edx@35 + void *v32; // eax@40 + signed int v33; // esi@40 + unsigned int v34; // esi@42 + int v35; // eax@42 + unsigned int v36; // eax@43 + int v37; // eax@45 + int v38; // ecx@50 + int v41; // eax@52 + char *v42; // eax@54 + int v43; // eax@54 + unsigned int v44; // ecx@54 + int v45; // edx@54 + int v46; // eax@54 + unsigned __int16 v47; // ax@54 + int v48; // eax@58 + signed int v49; // esi@62 + Texture *v50; // ecx@64 + unsigned int v51; // edi@64 + unsigned int v52; // esi@66 + int v53; // edx@70 + Texture *v54; // ecx@76 + unsigned int v55; // edi@76 + unsigned int v56; // esi@76 + int v57; // edx@80 + unsigned int v59; // edi@86 + unsigned int v60; // esi@88 + int v61; // edx@92 + unsigned int v63; // edi@98 + unsigned int v64; // esi@100 + int v65; // edx@104 + signed int v66; // ecx@109 + SHORT v67; // di@117 + bool v68; // eax@117 + const char *v69; // ecx@119 + POINT *v70; // esi@124 + int v71; // ecx@125 + int v73; // ecx@125 + int v75; // eax@130 + int v78; // eax@132 + int v80; // edx@133 + int v81; // edi@133 + const char **v83; // eax@135 + int v84; // eax@135 + unsigned int v85; // ecx@135 + int v86; // edx@135 + int v89; // [sp-14h] [bp-10Ch]@35 + int v91; // [sp-10h] [bp-108h]@35 + unsigned __int16 v92; // [sp-Ch] [bp-104h]@12 + void *v93; // [sp-Ch] [bp-104h]@14 + int v94; // [sp-8h] [bp-100h]@11 + char *v95; // [sp-8h] [bp-100h]@12 + __int64 *v96; // [sp-4h] [bp-FCh]@11 + unsigned int v97; // [sp-4h] [bp-FCh]@12 + POINT v98; // [sp+Ch] [bp-ECh]@8 + POINT v99; // [sp+14h] [bp-E4h]@16 + POINT v100; // [sp+1Ch] [bp-DCh]@124 + POINT v101; // [sp+24h] [bp-D4h]@17 + POINT v102; // [sp+2Ch] [bp-CCh]@124 + POINT v103; // [sp+34h] [bp-C4h]@9 + POINT v104; // [sp+3Ch] [bp-BCh]@31 + POINT v105; // [sp+44h] [bp-B4h]@16 + POINT v106; // [sp+4Ch] [bp-ACh]@30 + POINT v107; // [sp+54h] [bp-A4h]@16 + POINT v108; // [sp+5Ch] [bp-9Ch]@30 + POINT a2; // [sp+64h] [bp-94h]@8 + POINT v110; // [sp+6Ch] [bp-8Ch]@30 + POINT v111; // [sp+74h] [bp-84h]@8 + GUIWindow dialog_window; // [sp+7Ch] [bp-7Ch]@1 + char *Str; // [sp+D0h] [bp-28h]@54 + int v146; // [sp+D4h] [bp-24h]@23 + unsigned int pYellowColor; // [sp+D8h] [bp-20h]@1 + unsigned int pWhiteColor; // [sp+DCh] [bp-1Ch]@1 + __int32 v117; // [sp+E0h] [bp-18h]@8 + int v118; // [sp+E4h] [bp-14h]@40 + const char **v119; // [sp+E8h] [bp-10h]@24 + int _this; // [sp+ECh] [bp-Ch]@1 + unsigned __int8 uPlayerID; // [sp+F3h] [bp-5h]@14 + int v152; // [sp+F4h] [bp-4h]@23 + int v122; + int v114; + int pSrtingNum; + int pActiveItemNum; + ItemGen *item; + + memcpy(&dialog_window, window_SpeakInHouse, sizeof(dialog_window)); + dialog_window.uFrameX = 483; + dialog_window.uFrameWidth = 148; + dialog_window.uFrameZ = 334; + pWhiteColor = TargetColor(255, 255, 255); + pYellowColor = TargetColor(225, 205, 35); + if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN) + { + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + pShopOptions[0] = pGlobalTXT_LocalizationStrings[134]; //"Buy Standard" + pShopOptions[1] = pGlobalTXT_LocalizationStrings[152]; //"Buy Special" + pShopOptions[2] = pGlobalTXT_LocalizationStrings[159]; //"Display Inventory" + pShopOptions[3] = pGlobalTXT_LocalizationStrings[160]; + all_text_height = 0; + for ( int i = 0; i < 4; ++i ) + all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); + v146 = (174 - all_text_height) / 4; + v23 = (174 - 4 * (174 - all_text_height) / 4 - all_text_height) / 2 - (174 - all_text_height) / 4 / 2 + 138; + int j = 0; + if ( pDialogueWindow->pNumPresenceButton>=0 ) + { + int th = 2; + for (v152 = pDialogueWindow->pStartingPosActiveItem; v152 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; ++v152) + { + control_button = pDialogueWindow->GetControl(v152); + control_button->uY = v146 + v23; + pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[j], &dialog_window, 0, 0); + control_button->uHeight = pTextHeight; + v23 = control_button->uY + control_button->uHeight - 1; + control_button->uW = v23; + text_color = pYellowColor; + if ( pDialogueWindow->pCurrentPosActiveItem != th ) + text_color = pWhiteColor; + dialog_window.DrawTitleText(pFontArrus, 0, control_button->uY, text_color, pShopOptions[j], 3); + ++th; + ++j; + } + } + return; + } + if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + { + pRenderer->DrawTextureIndexed(8, 8, ShopTexture); + v3 = 0; + v49 = 0; + v122 = 0; + do + { + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID) + { + v50 = ItemsInShopTexture[v49]; + v51 = 152 - v50->uTextureHeight; + if ( (signed int)v51 < 1 ) + v51 = 0; + v52 = 75 * v49 - v50->uTextureWidth / 2 + 40; + if ( v122 ) + { + if ( v122 == 5 ) + { + v53 = ItemsInShopTexture[5]->uTextureWidth; + if ( (signed int)v52 > 457 - v53 ) + v52 = 457 - v53; + } + } + else + { + if ( (signed int)v52 < 18 ) + v52 = 18; + } + pRenderer->DrawTextureTransparent(v52, v51, v50); + sub_40F92A(&pRenderer->pActiveZBuffer[v52 + 640 * v51], ItemsInShopTexture[v122], v122 + 1); + v49 = v122; + } + ++v49; + v122 = v49; + } + while ( v49 < 6 ); + v122 = 0; + do + { + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v122 + 6].uItemID) + { + v54 = ItemsInShopTexture[v122 + 6]; + v55 = 306 - v54->uTextureHeight; + v56 = 75 * v122 - v54->uTextureWidth / 2 + 40; + if ( v122 ) + { + if ( v122 == 5 ) + { + v57 = ItemsInShopTexture[11]->uTextureWidth; + if ( (signed int)v56 > 457 - v57 ) + v56 = 457 - v57; + } + } + else + { + if ( (signed int)v56 < 18 ) + v56 = 18; + } + pRenderer->DrawTextureTransparent(v56, v55, v54); + sub_40F92A(&pRenderer->pActiveZBuffer[v56 + 640 * v55], ItemsInShopTexture[v122 + 6], v122 + 7); + } + ++v122; + } + while ( v122 < 6 ); + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v66 = 0; + v117 = 0; + if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + { + do + { + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID) //9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + ++v117; + ++v66; + } + while ( v66 < 12 ); + } + else + { + do + { + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID) + ++v117; + ++v66; + } + while ( v66 < 12 ); + } + v67 = GetAsyncKeyState(VK_CONTROL); + v68 = pPlayers[uActiveCharacter]->CanSteal(); + Str = (char *)v68; + if ( v67 && v68 ) + { + v69 = pGlobalTXT_LocalizationStrings[185];// "Steal item" + } + else + { + v69 = pGlobalTXT_LocalizationStrings[195];// "Select the Item to Buy" + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + v69 = pGlobalTXT_LocalizationStrings[196];// "Select the Special Item to Buy" + } + DrawTextAtStatusBar(v69, 0); + if ( !v117 ) + { + dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + return; + } + v70 = pMouse->GetCursorPos(&v102); + result = v70->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v100)->y]; + if ( pRenderer->pActiveZBuffer[result] & 0xFFFF ) + { + v71 = (pRenderer->pActiveZBuffer[result] & 0xFFFF) - 1; + item = &pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v71]; + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v71]; + if ( v67 && Str ) + v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24" + else + { + v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); + v10 = (char *)pMerchantsBuyPhrases[v75]; + } + v30 = BuilDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); + return; + } + } + return; + } + if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_SPECIAL) + { + pRenderer->DrawTextureIndexed(8, 8, ShopTexture); + v3 = 0; + v49 = 0; + v122 = 0; + do + { + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v49].uItemID) + { + v59 = 152 - ItemsInShopTexture[v49]->uTextureHeight; + if ( (signed int)v59 < 1 ) + v59 = 0; + v60 = 75 * v49 - ItemsInShopTexture[v49]->uTextureWidth / 2 + 40; + if ( v122 ) + { + if ( v122 == 5 ) + { + v61 = ItemsInShopTexture[5]->uTextureWidth; + if ( (signed int)v60 > 457 - v61 ) + v60 = 457 - v61; + } + } + else + { + if ( (signed int)v60 < 18 ) + v60 = 18; + } + pRenderer->DrawTextureTransparent(v60, v59, ItemsInShopTexture[v49]); + sub_40F92A(&pRenderer->pActiveZBuffer[v60 + 640 * v59], ItemsInShopTexture[v122], v122 + 1); + v49 = v122; + } + ++v49; + v122 = v49; + } + while ( v49 < 6 ); + v122 = 0; + do + { + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v122 + 6].uItemID) + { + v63 = 306 - ItemsInShopTexture[v122 + 6]->uTextureHeight; + if ( (signed int)v63 < 1 ) + v63 = 0; + v64 = 75 * v122 - ItemsInShopTexture[v122 + 6]->uTextureWidth / 2 + 40; + if ( v122 ) + { + if ( v122 == 5 ) + { + v65 = ItemsInShopTexture[11]->uTextureWidth; + if ( (signed int)v64 > 457 - v65 ) + v64 = 457 - v65; + } + } + else + { + if ( (signed int)v64 < 18 ) + v64 = 18; + } + pRenderer->DrawTextureTransparent(v64, v63, ItemsInShopTexture[v122 + 6]); + sub_40F92A(&pRenderer->pActiveZBuffer[v64 + 640 * v63], ItemsInShopTexture[v122 + 6], v122 + 7); + } + ++v122; + } + while ( v122 < 6 ); + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v66 = 0; + v117 = 0; + if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + { + do + { + if ( pParty->StandartItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID) //9 * (v66 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)] ) + ++v117; + ++v66; + } + while ( v66 < 12 ); + } + else + { + do + { + if (pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v66].uItemID) + ++v117; + ++v66; + } + while ( v66 < 12 ); + } + v67 = GetAsyncKeyState(VK_CONTROL); + v68 = pPlayers[uActiveCharacter]->CanSteal(); + Str = (char *)v68; + if ( v67 && v68 ) + { + v69 = pGlobalTXT_LocalizationStrings[185];// "Steal item" + } + else + { + v69 = pGlobalTXT_LocalizationStrings[195];// "Select the Item to Buy" + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + v69 = pGlobalTXT_LocalizationStrings[196];// "Select the Special Item to Buy" + } + DrawTextAtStatusBar(v69, 0); + if ( !v117 ) + { + dialog_window.DrawCurrentTime( pParty->field_3C.field_50[(unsigned int)window_SpeakInHouse->ptr_1C] - pParty->uTimePlayed); + return; + } + v70 = pMouse->GetCursorPos(&v102); + result = v70->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v100)->y]; + if ( pRenderer->pActiveZBuffer[result] & 0xFFFF ) + { + v71 = (pRenderer->pActiveZBuffer[result] & 0xFFFF) - 1; + item = &pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v71]; + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v71]; + if ( v67 && Str ) + v10 = pGlobalTXT_LocalizationStrings[181];// "Steal %24" + else + { + v75 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 2); + v10 = (char *)pMerchantsBuyPhrases[v75]; + } + v30 = BuilDialogueString(v10, uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 2, 0); + v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); + return; + } + } + return; + } + if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT ) + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + pShopOptions[0] = pGlobalTXT_LocalizationStrings[200];// "Sell" + pShopOptions[1] = pGlobalTXT_LocalizationStrings[113];// "Identify" + pShopOptions[2] = pGlobalTXT_LocalizationStrings[179];// "Repair" + all_text_height = 0; + for ( uint i = 0; i < 3; ++i ) + all_text_height += pFontArrus->CalcTextHeight(pShopOptions[i], &dialog_window, 0, 0); + _this = ((174 - all_text_height) / 3); + v81 = (3 * (58 - (signed int)_this) - all_text_height) / 2 - (174 - all_text_height) / 3 / 2 + 138; + v20 = -pDialogueWindow->pNumPresenceButton < 0; + v118 = pDialogueWindow->pStartingPosActiveItem; + if ( v20 ^ (pDialogueWindow->pStartingPosActiveItem > pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton) ) + { + v122 = 2; + pSrtingNum = 0; + do + { + control_button = pDialogueWindow->GetControl(v118); + control_button->uY = (unsigned int)((char *)_this + v81); + pTextHeight = pFontArrus->CalcTextHeight(pShopOptions[pSrtingNum], &dialog_window, 0, 0); + v85 = control_button->uY; + control_button->uHeight = pTextHeight; + v81 = pTextHeight + v85 - 1; + control_button->uW = v81; + text_color = pYellowColor; + if ( pDialogueWindow->pCurrentPosActiveItem != v122 ) + text_color = pWhiteColor; + dialog_window.DrawTitleText(pFontArrus, 0, v85, text_color, pShopOptions[pSrtingNum], 3); + ++v122; + ++pSrtingNum; + ++v118; + } + while ( v118 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + } + return; + } + if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_SELL) + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[199], 0);// "Select the Item to Sell" + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() + || (v11 = pMouse->GetCursorPos(&v107)->x - 14, + v117 = (v11 >> 5) + 14 * ((pMouse->GetCursorPos(&v99)->y - 17) >> 5), + result = (int)pMouse->GetCursorPos(&v105), + *(int *)result <= 13) + || (result = (int)pMouse->GetCursorPos(&v101), *(int *)result >= 462) + || (result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result) ) + return; + item = &pPlayers[uActiveCharacter]->pInventoryItems[result - 1]; + v13 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 3); + v30 = BuilDialogueString((char *)pMerchantsSellPhrases[v13], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 3, 0); + v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); + return; + } + if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_IDENTIFY) + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[197], 0);// "Select the Item to Identify" + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v2 = pMouse->GetCursorPos(&a2)->x - 14; + v117 = (v2 >> 5) + 14 * ((pMouse->GetCursorPos(&v98)->y - 17) >> 5); + result = (int)pMouse->GetCursorPos(&v111); + if ( *(int *)result > 13 ) + { + result = (int)pMouse->GetCursorPos(&v103); + if ( *(int *)result < 462 ) + { + result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117); + if ( result ) + { + item = &pPlayers[uActiveCharacter]->pInventoryItems[result-1]; + if ( item->uAttributes & 1 ) + { + v5 = BuilDialogueString("%24", uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v6 = (212 - pFontArrus->CalcTextHeight(v5, &dialog_window, 0, 0)) / 2 + 101; + dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v5, 3); + return; + } + v8 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(item, BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 4); + v30 = BuilDialogueString((char *)pMerchantsIdentifyPhrases[v8], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 4, 0); + v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, 0, v6, pWhiteColor, v30, 3); + return; + } + } + } + } + return; + } + if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_REPAIR) + { + draw_leather(); + CharacterUI_InventoryTab_Draw(pPlayers[uActiveCharacter], true); + DrawTextAtStatusBar(pGlobalTXT_LocalizationStrings[198], 0);// "Select the Item to Repair" + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() + || (pTextHeight = pMouse->GetCursorPos(&v110)->x - 14, + v117 = (pTextHeight >> 5) + 14 * ((pMouse->GetCursorPos(&v108)->y - 17) >> 5), + result = (int)pMouse->GetCursorPos(&v106), + *(int *)result <= 13) + || (result = (int)pMouse->GetCursorPos(&v104), *(int *)result >= 462) + || (result = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v117), v3 = 0, !result) + // || (result *= 9, !(pPlayers[uActiveCharacter]->field_1F5[4 * result + 15] & 2)) ) + || (!(pPlayers[uActiveCharacter]->pOwnItems[result-1].uAttributes& 2)) ) + return; + item = &pPlayers[uActiveCharacter]->pInventoryItems[result - 1]; + v29 = pPlayers[uActiveCharacter]->SelectPhrasesTransaction(&pPlayers[uActiveCharacter]->pInventoryItems[result - 1], BildingType_MagicShop, (int)window_SpeakInHouse->ptr_1C, 5); + v30 = BuilDialogueString((char *)pMerchantsRepairPhrases[v29], uActiveCharacter - 1, item, (char *)window_SpeakInHouse->ptr_1C, 5, 0); + v6 = (174 - pFontArrus->CalcTextHeight(v30, &dialog_window, v3, v3)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, v3, v6, pWhiteColor, v30, 3); + return; + } + if ( dialog_menu_id == HOUSE_DIALOGUE_LEARN_SKILLS ) + { + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v3 = 0; + all_text_height = 0; + v33 = (signed __int64)(p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); + v119 = (const char **)(v33 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100); + if ( (signed int)v119 < v33 / 3 ) + v119 = (const char **)(v33 / 3); + pActiveItemNum = pDialogueWindow->pStartingPosActiveItem; + v122 = 0; + if ( (signed int)pDialogueWindow->pStartingPosActiveItem >= pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);// + // "Seek knowledge elsewhere %s the %s" + strcat(pTmpBuf.data(), "\n \n"); + strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further." + v6 = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, v3, v6, pYellowColor, pTmpBuf.data(), 3); + return; + } + do + { + v36 = pDialogueWindow->GetControl(pActiveItemNum)->msg_param - 36; + if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v36] && !pPlayers[uActiveCharacter]->pActiveSkills[v36] ) + { + all_text_height += pFontArrus->CalcTextHeight(pSkillNames[v36], &dialog_window, 0, 0); + ++v122; + } + ++pActiveItemNum; + } + while ( pActiveItemNum < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + if ( !v122 ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], pPlayers[uActiveCharacter]->pName, pClassNames[pPlayers[uActiveCharacter]->classType]);// + // "Seek knowledge elsewhere %s the %s" + strcat(pTmpBuf.data(), "\n \n"); + strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]);// "I can offer you nothing further." + v6 = (174 - pFontArrus->CalcTextHeight(pTmpBuf.data(), &dialog_window, 0, 0)) / 2 + 138; + dialog_window.DrawTitleText(pFontArrus, v3, v6, pYellowColor, pTmpBuf.data(), 3); + return; + } + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v119);// "Skill Cost: %lu" + dialog_window.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3u); + v119 = (const char **)((149 - all_text_height) / v122); + if ( (149 - all_text_height) / v122 > 32 ) + v119 = (const char **)32; + v38 = (149 - v122 * (signed int)v119 - all_text_height) / 2 - (signed int)v119 / 2 + 162; + v118 = 2; + if ( pDialogueWindow->pStartingPosActiveItem < pDialogueWindow->pStartingPosActiveItem + pDialogueWindow->pNumPresenceButton ) + { + v122 = 2; + do + { + control_button = pDialogueWindow->GetControl(v122); + v41 = control_button->msg_param - 36; + if ( !byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v41] || pPlayers[uActiveCharacter]->pActiveSkills[v41] ) + { + control_button->uW = 0; + control_button->uHeight = 0; + control_button->uY = 0; + } + else + { + control_button->uY = (unsigned int)((char *)v119 + v38); + pTextHeight = pFontArrus->CalcTextHeight(pSkillNames[v41], &dialog_window, 0, 0); + v44 = control_button->uY; + control_button->uHeight = pTextHeight; + v38 = v44 + pTextHeight - 1; + control_button->uW = v38; + text_color = pYellowColor; + if ( pDialogueWindow->pCurrentPosActiveItem != v122 ) + text_color = pWhiteColor; + dialog_window.DrawTitleText(pFontArrus, 0, v44, text_color, pSkillNames[v41], 3); + } + ++v122; + } + while ( v122 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + } + } + return; + } + return; +} + + +//----- (004B6478) -------------------------------------------------------- +void sub_4B6478() + { + GUIWindow *v0; // ebx@1 + Player *v1; // edi@1 + unsigned int v2; // eax@1 + signed int v3; // esi@1 + int v4; // ebx@1 + unsigned int v5; // esi@5 + int v6; // edi@6 + int result; // eax@13 + GUIWindow *v8; // ebx@17 + int v9; // eax@17 + int v10; // ecx@17 + unsigned int v11; // ecx@18 + int v12; // eax@20 + int v13; // eax@21 + GUIButton *v14; // esi@27 + int v15; // ecx@27 + unsigned int v16; // eax@28 + const char *v17; // ebx@29 + int v18; // eax@29 + unsigned int v19; // ecx@29 + int v20; // eax@29 + unsigned __int16 v21; // ax@29 + unsigned __int16 v22; // ST14_2@36 + int v23; // eax@36 + const char *v24; // ST18_4@37 + unsigned __int16 v25; // ST14_2@37 + int v26; // eax@37 + int v27; // [sp-4h] [bp-80h]@8 + GUIWindow v28; // [sp+Ch] [bp-70h]@1 + GUIWindow *v29; // [sp+60h] [bp-1Ch]@17 + unsigned int v30; // [sp+64h] [bp-18h]@1 + int v31; // [sp+68h] [bp-14h]@1 + int v32; // [sp+6Ch] [bp-10h]@1 + int v33; // [sp+70h] [bp-Ch]@17 + int v34; // [sp+74h] [bp-8h]@17 + int v35; // [sp+78h] [bp-4h]@17 + + v0 = window_SpeakInHouse; + memcpy(&v28, window_SpeakInHouse, sizeof(v28)); + v1 = pPlayers[uActiveCharacter]; + v28.uFrameX = 483; + v28.uFrameWidth = 148; + v28.uFrameZ = 334; + v30 = TargetColor(0xFFu, 0xFFu, 0xFFu); + v31 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + v2 = 52 * (unsigned int)v0->ptr_1C; + //v32 = (unsigned __int8)(((p2DEvents_minus1___00[v2 / 2] != 18) - 1) & 0x96) + 100; + v32 = (unsigned __int8)(((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != 18) - 1) & 0x96) + 100; + //v3 = (signed __int64)((double)v32 * p2DEvents_minus1__20[v2 / 4]); + v3 = (signed __int64)((double)v32 * p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier); + v4 = v3 * (100 - v1->GetMerchant()) / 100; + v32 = v4; + if ( v4 < v3 / 3 ) + { + v4 = v3 / 3; + v32 = v3 / 3; + } + if ( dialog_menu_id != HOUSE_DIALOGUE_MAIN) + { + if ( sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + v5 = 0; + + __debugbreak(); + //pSkillAvailabilityPerClass[8 + v58->uClass][4 + v23] + // or + //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass][v23 - 36] + // or + //byte_4ED970_skill_learn_ability_by_class_table[v58->uClass - 1][v23 + 1] + __debugbreak(); // whacky condition - fix + if (false + //if ( !*(&byte_4ED94C[37 * v1->uClass / 3] + dword_F8B19C) + || (v6 = (int)(&v1->uIntelligence + dialog_menu_id), *(short *)v6) ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + } + else + { + if ( pParty->uNumGold < v4 ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); + v27 = 4; + } + else + { + Party::TakeGold(v4); + *(short *)v6 = 1; + v27 = 2; + } + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v27); + } + } + else + { + v5 = 0; + } + /*result = pMessageQueue_50CBD0->uNumMessages; + if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = UIMSG_Escape; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; + result = 3 * pMessageQueue_50CBD0->uNumMessages + 3; + *(&pMessageQueue_50CBD0->uNumMessages + result) = v5; + ++pMessageQueue_50CBD0->uNumMessages; + }*/ + pMessageQueue_50CBD0->AddMessage(UIMSG_Escape, 1, v5); + return; // void func + } + if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v1->_guilds_member_bits, word_4F0754[2 * (unsigned int)window_SpeakInHouse->ptr_1C]) ) + { + v24 = pNPCTopics[171].pText; + v25 = v31; + v26 = pFontArrus->CalcTextHeight(pNPCTopics[171].pText, &v28, 0, 0); + v28.DrawTitleText(pFontArrus, 0, (212 - v26) / 2 + 101, v25, v24, 3u); + pDialogueWindow->pNumPresenceButton = 0; + return ; + } + + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + return; + v8 = pDialogueWindow; + v33 = 0; + v34 = 0; + v29 = pDialogueWindow; + v9 = pDialogueWindow->pStartingPosActiveItem; + v10 = v9 + pDialogueWindow->pNumPresenceButton; + v35 = pDialogueWindow->pStartingPosActiveItem; + if ( v9 >= v10 ) + goto LABEL_40; + do + { + v11 = v8->GetControl(v35)->msg_param - 36; + if ( byte_4ED970_skill_learn_ability_by_class_table[v1->classType / 3][v11] && !v1->pActiveSkills[v11] ) + { + v12 = pFontArrus->CalcTextHeight(pSkillNames[v11], &v28, 0, 0); + v33 += v12; + ++v34; + } + v13 = v8->pStartingPosActiveItem; + ++v35; + } + while ( v35 < v8->pNumPresenceButton + v13 ); + if ( !v34 ) + { +LABEL_40: + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[544], v1->pName, pClassNames[v1->classType]); + strcat(pTmpBuf.data(), "\n \n"); + strcat(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[528]); + v22 = v31; + v23 = pFontArrus->CalcTextHeight(pTmpBuf.data(), &v28, 0, 0); + v28.DrawTitleText(pFontArrus, 0, (174 - v23) / 2 + 138, v22, pTmpBuf.data(), 3u); + return; + } + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[401], v32); + v28.DrawTitleText(pFontArrus, 0, 0x92u, 0, pTmpBuf.data(), 3u); + v32 = (149 - v33) / v34; + if ( (149 - v33) / v34 > 32 ) + v32 = 32; + + v35 = v8->pStartingPosActiveItem; + v34 = (149 - v34 * v32 - v33) / 2 - v32 / 2 + 162; + if ( v8->pStartingPosActiveItem < v8->pStartingPosActiveItem+ v8->pNumPresenceButton ) + { + v33 = 2; + do + { + v14 = v8->GetControl(v35); + v15 = v14->msg_param - 36; + if ( byte_4ED970_skill_learn_ability_by_class_table[v1->classType / 3][v15] ) + { + v16 = 0; + if ( !v1->pActiveSkills[v15] ) + { + v17 = pSkillNames[v15]; + v14->uY = v32 + v34; + v18 = pFontArrus->CalcTextHeight(v17, &v28, 0, 0); + v19 = v14->uY; + v14->uHeight = v18; + v20 = v19 + v18 - 1; + v14->uW = v20; + v34 = v20; + v21 = v31; + if ( pDialogueWindow->pCurrentPosActiveItem != v33 ) + v21 = v30; + v28.DrawTitleText(pFontArrus, 0, v19, v21, v17, 3u); + goto LABEL_34; + } + } + else + { + v16 = 0; + } + v14->uW = v16; + v14->uHeight = v16; + v14->uY = v16; +LABEL_34: + v8 = v29; + ++v35; + ++v33; + } + while ( v35 <v29->pNumPresenceButton + v29->pStartingPosActiveItem ); + } + return; +} +//----- (004B1A2D) -------------------------------------------------------- +void __cdecl ShowPopupShopItem() +{ + POINT *v1; // esi@5 + unsigned int v2; // eax@5 + int v3; // ecx@5 + POINT *v4; // esi@12 + int v5; // eax@12 + unsigned int v6; // eax@13 + ItemGen *v7; // ecx@13 + signed int v8; // esi@17 + unsigned int v9; // eax@19 + POINT v10; // [sp+8h] [bp-44h]@12 + POINT v11; // [sp+10h] [bp-3Ch]@12 + POINT v12; // [sp+18h] [bp-34h]@18 + POINT v13; // [sp+20h] [bp-2Ch]@17 + POINT v14; // [sp+28h] [bp-24h]@17 + POINT v15; // [sp+30h] [bp-1Ch]@17 + POINT v16; // [sp+38h] [bp-14h]@5 + POINT a2; // [sp+40h] [bp-Ch]@5 + + if ( in_current_building_type <= 0 ) + return; + if ( in_current_building_type <= BildingType_AlchemistShop ) + { + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + { + if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + return; + if ( dialog_menu_id <= HOUSE_DIALOGUE_SHOP_REPAIR || dialog_menu_id == HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT ) + { + v8 = pMouse->GetCursorPos(&v15)->x - 14; + v5 = (v8 >> 5) + 14 * ((pMouse->GetCursorPos(&v14)->y - 17) >> 5); + if ( pMouse->GetCursorPos(&v13)->x <= 13 + || pMouse->GetCursorPos(&v12)->x >= 462 + || (v9 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v5)) == 0 ) + return; + GameUI_DrawItemInfo(&pPlayers[uActiveCharacter]->pInventoryItems[v9 - 1]); + return; + } + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_SPECIAL ) + return; + } + v4 = pMouse->GetCursorPos(&v11); + v5 = pRenderer->pActiveZBuffer[v4->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v10)->y]] & 0xFFFF; + if ( !v5 ) + return; + v6 = 9 * (v5 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C); + v7 = (ItemGen *)((char *)&pParty->pPickedItem + 4 * v6 + 4); + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + v7 = &pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v5 - 1]; + GameUI_DrawItemInfo(v7); + return; + } + if ( in_current_building_type <= BildingType_16 && dialog_menu_id == HOUSE_DIALOGUE_GUILD_BUY_BOOKS ) + { + v1 = pMouse->GetCursorPos(&a2); + v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y]; + v3 = pRenderer->pActiveZBuffer[v2] & 0xFFFF; + v5 = pRenderer->pActiveZBuffer[v2] & 0xFFFF; + if ( v5 ) + sub_4B1523((int *)&pParty->pPlayers[1].uExpressionTimeLength + 9 * (v3 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C)); + } +} +//----- (004B1D27) -------------------------------------------------------- +void __cdecl sub_4B1D27() +{ + int v0; // edx@2 + unsigned int v1; // ecx@7 + signed int v2; // edi@10 + int v3; // esi@10 + __int16 v4; // ax@15 + signed int v5; // edi@20 + int v6; // esi@20 + int v7[4]; // [sp+Ch] [bp-10h]@12 + + if ( in_current_building_type > 0 ) + { + v0 = 3; + if ( in_current_building_type > BildingType_MagicShop ) + { + if ( in_current_building_type == BildingType_Bank ) + { + if ( !dword_F8B1E4 ) + return; + } + else + { + if ( in_current_building_type != BildingType_Temple ) + return; + } + v1 = (unsigned int)window_SpeakInHouse->ptr_1C; + PlayHouseSound(v1, (HouseSoundID)v0); + return; + } + v1 = (unsigned int)window_SpeakInHouse->ptr_1C; + if ( (signed __int64)pParty->field_3C._shop_ban_times[v1 ]<= (signed __int64)pParty->uTimePlayed ) + { + if ( pParty->uNumGold <= 0x2710 ) + { + if ( !dword_F8B1E4 ) + return; + v0 = 4; + PlayHouseSound(v1, (HouseSoundID)v0); + return; + } + PlayHouseSound(v1, (HouseSoundID)(dword_F8B1E4 + 3)); + if ( !dword_F8B1E4 && !qword_A750D8 ) + { + v5 = 0; + v6 = 1; + do + { + if ( pPlayers[v6]->CanAct() ) + v7[v5++] = v6; + ++v6; + } + while ( v6 <= 4 ); + if ( v5 ) + { + qword_A750D8 = 256i64; + word_A750E0 = 80; + v4 = LOWORD(v7[rand() % v5]); + word_A750E2 = v4; + return; + } + } + } + else + { + if ( !qword_A750D8 ) + { + v2 = 0; + v3 = 1; + do + { + if ( pPlayers[v3]->CanAct() ) + v7[v2++] = v3; + ++v3; + } + while ( v3 <= 4 ); + if ( v2 ) + { + qword_A750D8 = 256i64; + word_A750E0 = 80; + v4 = LOWORD(v7[rand() % v2]); + word_A750E2 = v4; + return; + } + } + } + } +} +//----- (004B2A74) -------------------------------------------------------- +void SimpleHouseAndBoatsDialog() +{ + char *v0; // esi@3 + char *v1; // ST1C_4@3 + char *v2; // eax@3 + const char *v3; // ST1C_4@5 + int v4; // eax@5 + unsigned int i; // eax@5 + NPCData *v6; // esi@6 + unsigned __int16 v7; // bx@6 + unsigned int v8; // eax@6 + int v9; // eax@11 + unsigned int v10; // ecx@12 + int v11; // eax@12 + int v12; // esi@12 + char *v13; // eax@12 + GUIWindow *v14; // ebx@13 + char *v15; // esi@14 + GUIButton *v16; // eax@15 + unsigned int v17; // ecx@15 + int v18; // ecx@17 + int v19; // ecx@18 + int v20; // ecx@19 + int v21; // ecx@20 + int v22; // ecx@21 + unsigned int v23; // ecx@23 + int v24; // ecx@35 + int v25; // ecx@36 + int v26; // ecx@37 + int v27; // ecx@38 + int v28; // ecx@39 + char *v29; // esi@42 + unsigned int v30; // ST20_4@42 + int v31; // ST1C_4@42 + unsigned int v32; // eax@42 + char *v33; // eax@43 + int v34; // esi@51 + int v35; // eax@51 + unsigned int v36; // edi@51 + GUIButton *v37; // eax@52 + int v38; // eax@52 + signed int v39; // ecx@54 + int v40; // edi@57 + GUIButton *v41; // eax@60 + GUIButton *v42; // esi@60 + const char *v43; // ebx@60 + int v44; // eax@60 + unsigned int v45; // ecx@60 + unsigned __int16 v46; // ax@60 + GUIFont *v47; // ebx@64 + int v48; // esi@64 + char *v49; // eax@66 + GUIWindow w; // [sp+Ch] [bp-110h]@64 + GUIWindow v52; // [sp+60h] [bp-BCh]@13 + GUIWindow a1; // [sp+B4h] [bp-68h]@1 + unsigned int v54; // [sp+108h] [bp-14h]@14 + int v55; // [sp+10Ch] [bp-10h]@6 + int v56; // [sp+110h] [bp-Ch]@13 + char *pInString; // [sp+114h] [bp-8h]@12 + NPCData *v58; // [sp+118h] [bp-4h]@6 + + memcpy(&a1, pDialogueWindow, sizeof(a1)); + if ( pDialogueNPCCount == uNumDialogueNPCPortraits && uHouse_ExitPic ) + { + v0 = pMapStats->pInfos[uHouse_ExitPic].pName; + v1 = pMapStats->pInfos[uHouse_ExitPic].pName; + a1.uFrameX = 493; + a1.uFrameWidth = 126; + a1.uFrameZ = 366; + a1.DrawTitleText(pFontCreate, 0, 2u, 0, v1, 3u); + a1.uFrameX = 483; + a1.uFrameWidth = 148; + a1.uFrameZ = 334; + v2 = pTransitionStrings[uHouse_ExitPic]; + if ( !v2 ) + { + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[411], v0); + v2 = pTmpBuf.data(); + } + v3 = v2; + v4 = pFontCreate->CalcTextHeight(v2, &a1, 0, 0); + a1.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, v3, 3u); + return; + } + a1.uFrameWidth -= 10; + a1.uFrameZ -= 10; + v58 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) )];//- 1 + v6 = v58; + v55 = TargetColor(0xE1u, 0xCDu, 0x23u); + v7 = TargetColor(0x15u, 0x99u, 0xE9u); + v8 = v6->uProfession; + if ( v8 ) + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], v6->pName, aNPCProfessionNames[v8]); + else + strcpy(pTmpBuf.data(), v6->pName); + a1.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, v7, pTmpBuf.data(), 3u); + if ( !dword_591080 ) + { + if ( !uDialogueType ) + { + v9 = v6->greet; + if ( v9 ) + { + v10 = v6->uFlags; + a1.uFrameWidth = game_viewport_width; + a1.uFrameZ = 452; + pInString = (char *)*(&pNPCStats->field_17884 + ((v10 & 3) == 2) + 2 * v9); + v11 = pFontArrus->CalcTextHeight(pInString, &a1, 13, 0); + v12 = v11 + 7; + pRenderer->_4A6A68(8, 352 - (v11 + 7), + pIcons_LOD->GetTexture(uTextureID_Leather), + pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - (v11 + 7)); + pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); + v13 = FitTextInAWindow(pInString, pFontArrus, &a1, 0xDu, 0); + pDialogueWindow->DrawText(pFontArrus, 13, 354 - v12, 0, v13, 0, 0, 0); + } + } + } + v14 = pDialogueWindow; + memcpy(&v52, pDialogueWindow, sizeof(v52)); + v52.uFrameX = 483; + v52.uFrameWidth = 148; + v52.uFrameZ = 334; + v56 = v52.pStartingPosActiveItem; + if ( v52.pStartingPosActiveItem < v52.pStartingPosActiveItem + v52.pNumPresenceButton ) + { + v15 = "";//(char *)v54; + while ( 1 ) + { + v16 = v52.GetControl(v56); + v17 = v16->msg_param; + pInString = (char *)v16; + if ( (signed int)v17 > 24 ) + { + v24 = v17 - 76; + if ( !v24 ) + { + v15 = pGlobalTXT_LocalizationStrings[406]; + goto LABEL_49; + } + v25 = v24 - 1; + if ( !v25 ) + { + v15 = pGlobalTXT_LocalizationStrings[407]; + goto LABEL_49; + } + v26 = v25 - 2; + if ( !v26 ) + { + v33 = _4B254D_SkillMasteryTeacher((int)v52.ptr_1C); +LABEL_44: + v15 = v33; +LABEL_45: + v16 = (GUIButton *)pInString; + goto LABEL_49; + } + v27 = v26 - 3; + if ( !v27 ) + { + v33 = (char *)ContractSelectText((int)v52.ptr_1C); + goto LABEL_44; + } + v28 = v27 - 1; + if ( !v28 ) + { + v29 = (char *)&pMonsterStats + 88 * word_F8B1A0; + v30 = TargetColor(0xFFu, 0xFFu, 0xFFu); + v31 = *(int *)v29; + v32 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + sprintfex(pTmpBuf.data(), "\f%05d%s\f%05d", v32, v31, v30); + sprintfex(pTmpBuf2.data(), dword_F8B1A4, pTmpBuf.data(), 100 * (unsigned __int8)v29[8]); + current_npc_text = pTmpBuf2.data(); + v15 = ""; + goto LABEL_45; + } + if ( v28 != 10 ) + goto LABEL_41; + } + else + { + if ( v17 == 24 ) + { + v23 = v58->evt_F; +LABEL_33: + v15 = (char *)pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; + if ( !v15 ) + { + v16->msg_param = 0; + v15 = ""; + } + goto LABEL_49; + } + v18 = v17 - 13; + if ( v18 ) + { + v19 = v18 - 6; + if ( !v19 ) + { + v23 = v58->evt_A; + goto LABEL_33; + } + v20 = v19 - 1; + if ( !v20 ) + { + v15 = (char *)pNPCTopics[v58->evt_B-1].pTopic;//(&dword_721660)[8 * v58->evtb]; + if ( !v15 ) + { + v16->msg_param = 0; + v15 = ""; + } + if ( uDialogueType != 84 ) + goto LABEL_49; + sprintf(pTmpBuf.data(), format_4E2D80, v55, pItemsTable->pItems[contract_approved].pUnidentifiedName); + sprintf(pTmpBuf2.data(), current_npc_text, pTmpBuf.data()); + current_npc_text = pTmpBuf2.data(); + goto LABEL_45; + } + v21 = v20 - 1; + if ( !v21 ) + { + v23 = v58->evt_C; + goto LABEL_33; + } + v22 = v21 - 1; + if ( !v22 ) + { + v23 = v58->evt_D; + goto LABEL_33; + } + if ( v22 == 1 ) + { + v23 = v58->evt_E; + goto LABEL_33; + } +LABEL_41: + v15 = ""; + goto LABEL_49; + } + v15 = pGlobalTXT_LocalizationStrings[122]; + } +LABEL_49: + strcpy(v16->pButtonName, v15); + ++v56; + if ( v56 >= v52.pStartingPosActiveItem + v52.pNumPresenceButton ) + { + v14 = pDialogueWindow; + break; + } + } + } + v34 = 0; + v54 = TargetColor(0xFFu, 0xFFu, 0xFFu); + v35 = TargetColor(0xE1u, 0xCDu, 0x23u); + v36 = v14->pStartingPosActiveItem; + v55 = v35; + for ( i = v36 + v14->pNumPresenceButton; (signed int)v36 < (signed int)i; i = pDialogueWindow->pNumPresenceButton + + pDialogueWindow->pStartingPosActiveItem ) + { + v37 = v14->GetControl(v36); + v38 = pFontArrus->CalcTextHeight(v37->pButtonName, &v52, 0, 0); + v14 = pDialogueWindow; + v34 += v38; + ++v36; + } + v39 = v14->pNumPresenceButton; + if ( v39 ) + { + v58 = (NPCData *)((174 - v34) / v39); + if ( (signed int)v58 > 32 ) + v58 = (NPCData *)32; + pInString = (char *)2; + v40 = (174 - (signed int)v58 * v39 - v34) / 2 - (signed int)v58 / 2 + 138; + v56 = v14->pStartingPosActiveItem; + i = v56; + if ( (signed int)i < (signed int)(i + v39) ) + { + while ( 1 ) + { + v41 = v14->GetControl(i); + v42 = v41; + v43 = v41->pButtonName; + v41->uY = (unsigned int)((char *)v58 + v40); + v44 = pFontArrus->CalcTextHeight(v41->pButtonName, &v52, 0, 0); + v45 = v42->uY; + v42->uHeight = v44; + v40 = v45 + v44 - 1; + v42->uW = v40; + v46 = v55; + if ( (char *)pDialogueWindow->pCurrentPosActiveItem != pInString ) + v46 = v54; + v52.DrawTitleText(pFontArrus, 0, v45, v46, v43, 3u); + v14 = pDialogueWindow; + ++pInString; + ++v56; + i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem; + if ( v56 >= (signed int)i ) + break; + i = v56; + } + } + } + if ( current_npc_text ) + { + w.uFrameWidth = 458; + w.uFrameZ = 457; + v47 = pFontArrus; + v48 = pFontArrus->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; + if ( 352 - v48 < 8 ) + { + v47 = pFontCreate; + v48 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7; + } + pRenderer->_4A6A68(8, 352 - v48, + pIcons_LOD->GetTexture(uTextureID_Leather), + pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - v48); + pRenderer->DrawTextureIndexed(8u, 347 - v48, pTexture_591428); + v49 = FitTextInAWindow(current_npc_text, v47, &w, 0xDu, 0); + a1.DrawText(v47, 13, 354 - v48, 0, v49, 0, 0, 0); + } +} +//----- (004BDB56) -------------------------------------------------------- +void __cdecl UIShop_Buy_Identify_Repair() +{ + int v8; // eax@15 + unsigned int pItemID; // esi@20 + ItemGen *item; // esi@21 + unsigned int v15; // eax@33 + POINT *pCursorPos; // esi@37 + int v18; // ecx@37 + float pPriceMultiplier; // ST1C_4@38 + int taken_item; // eax@40 + ItemGen *bought_item; // esi@51 + int party_reputation; // eax@55 + int v39; // eax@63 + int v42; // esi@74 + signed int v43; // ebx@74 + unsigned __int16 *pSkill; // esi@77 + int v55; // [sp+0h] [bp-B4h]@26 + POINT cursor; // [sp+40h] [bp-74h]@37 + int a6; // [sp+98h] [bp-1Ch]@57 + int a3; // [sp+9Ch] [bp-18h]@53 + unsigned int uNumSeconds; // [sp+A4h] [bp-10h]@53 + unsigned int v79; // [sp+A8h] [bp-Ch]@9 + int uPriceItemService; // [sp+ACh] [bp-8h]@12 + + if ( pCurrentScreen == SCREEN_E ) + { + OnInventoryLeftClick(); + return; + } + if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) + { + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + return; + } + + switch(dialog_menu_id) + { + case HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT: + { + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; + OnInventoryLeftClick(); + break; + } + case HOUSE_DIALOGUE_GUILD_BUY_BOOKS: + { + pCursorPos = pMouse->GetCursorPos(&cursor); + v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&cursor)->y]] & 0xFFFF; + if ( !v18 ) + return; + bought_item = (ItemGen *)(&pParty->pPlayers[1].uExpressionTimeLength + 18 * (v18 + 12 * (int)window_SpeakInHouse->ptr_1C)); + pPriceMultiplier = p2DEvents[(signed int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; + uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), pPriceMultiplier); + GetAsyncKeyState(VK_CONTROL); + if ( pParty->uNumGold < uPriceItemService ) + { + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2); + return; + } + taken_item = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID); + if ( taken_item ) + { + bought_item->SetIdentified(); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[taken_item - 1], bought_item, 0x24u); + dword_F8B1E4 = 1; + Party::TakeGold(uPriceItemService); + viewparams->bRedrawGameUI = 1; + bought_item->Reset(); + pRenderer->ClearZBuffer(0, 479); + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); + return; + } + pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 5); // "Pack is Full!" + break; + } + case HOUSE_DIALOGUE_SHOP_SELL: + { + v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); + if ( pMouse->GetCursorPos(&cursor)->x <= 13 + || pMouse->GetCursorPos(&cursor)->x >= 462 + || (v15 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79), !v15) ) + return; + if ( MerchandiseTest(&pPlayers[uActiveCharacter]->pInventoryItems[v15 - 1], (int)window_SpeakInHouse->ptr_1C) ) + { + dword_F8B1E4 = 1; + pPlayers[uActiveCharacter]->SalesProcess(v79, v15 - 1, (int)window_SpeakInHouse->ptr_1C); + viewparams->bRedrawGameUI = 1; + pRenderer->ClearZBuffer(0, 479); + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)77, 0); + return; + } + pPlayers[uActiveCharacter]->PlaySound(SPEECH_79, 0); + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + break; + } + case HOUSE_DIALOGUE_SHOP_IDENTIFY: + { + pMouse->GetCursorPos(&cursor); + v79 = ((cursor.x - 14) >> 5) + 14 * ((cursor.y - 17) >> 5); + if (cursor.x > 13 && cursor.x < 462) + { + pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); + if ( pItemID ) + { + uPriceItemService = pPlayers[uActiveCharacter]->GetPriceIdentification(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); + item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + if ( !(item->uAttributes & 1) ) + { + if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) ) + { + if ( pParty->uNumGold >= uPriceItemService ) + { + dword_F8B1E4 = 1; + Party::TakeGold(uPriceItemService); + item->uAttributes |= 1; + pPlayers[uActiveCharacter]->PlaySound(SPEECH_73, 0); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[569], 2); + return; + } + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); + return; + } + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0); + return; + } + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0); + return; + } + } + break; + } + case HOUSE_DIALOGUE_SHOP_REPAIR: + { + v79 = ((pMouse->GetCursorPos(&cursor)->x - 14) >> 5) + 14 * ((pMouse->GetCursorPos(&cursor)->y - 17) >> 5); + if ( pMouse->GetCursorPos(&cursor)->x > 13 ) + { + if ( pMouse->GetCursorPos(&cursor)->x < 462 ) + { + pItemID = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex((int *)&v79); + if ( pItemID ) + { + item = &pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + pPriceMultiplier = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier; + auto _v = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[pItemID - 1]; + uPriceItemService = pPlayers[uActiveCharacter]->GetPriceRepair(_v->GetValue(), pPriceMultiplier); + if ( item->uAttributes & 2 ) + { + if ( MerchandiseTest(item, (int)window_SpeakInHouse->ptr_1C) ) + { + if ( pParty->uNumGold >= uPriceItemService ) + { + dword_F8B1E4 = 1; + Party::TakeGold(uPriceItemService); + v8 = item->uAttributes; + LOBYTE(v8) = v8 & 0xFD; + item->uAttributes = v8 | 1; + pPlayers[uActiveCharacter]->PlaySound(SPEECH_74, 0); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[570], 2); + return; + } + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); + return; + } + pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)79, 0); + return; + } + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)76, 0); + return; + } + } + } + break; + } + case HOUSE_DIALOGUE_SHOP_BUY_STANDARD: + case HOUSE_DIALOGUE_SHOP_BUY_SPECIAL: + { + pCursorPos = pMouse->GetCursorPos(&cursor); + v18 = pRenderer->pActiveZBuffer[pCursorPos->x + pSRZBufferLineOffsets[pCursorPos->y]] & 0xFFFF; + if ( !v18 ) + return; + if ( dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD) + bought_item = (ItemGen *)&pParty->StandartItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1]; + else + bought_item = &pParty->SpecialItemsInShops[(int)window_SpeakInHouse->ptr_1C][v18 - 1];//(ItemGen *)&pParty->field_C59C[v31 + 724]; + uPriceItemService = pPlayers[uActiveCharacter]->GetBuyingPrice(bought_item->GetValue(), p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier); + uNumSeconds = 0; + a3 = 0; + if ( pMapStats->GetMapInfo(pCurrentMapName.data()) ) + a3 = pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName.data())]._steal_perm; + party_reputation = GetPartyReputation(); + if (pPlayers[uActiveCharacter]->CanSteal()) + { + if ( GetAsyncKeyState(VK_CONTROL) ) + { + uNumSeconds = pPlayers[uActiveCharacter]->StealFromShop(bought_item, a3, party_reputation, 0, &a6); + if ( !uNumSeconds ) + { + sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, 0, a6); + return; + } + } + } + if ( pParty->uNumGold < uPriceItemService ) + { + if ( uNumSeconds != 2 ) + { + if ( uNumSeconds != 1 ) + { + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)2); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" + return; + } + } + } + v39 = pPlayers[uActiveCharacter]->AddItem(-1, bought_item->uItemID); + if ( v39 ) + { + bought_item->SetIdentified(); + memcpy(&pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1], bought_item, sizeof(ItemGen)); + if ( pPlayers[uActiveCharacter]->CanSteal() ) + { + if ( GetAsyncKeyState(VK_CONTROL) ) + { + if ( uNumSeconds == 1 || uNumSeconds == 2 ) + { + pPlayers[uActiveCharacter]->pInventoryItems[v39 - 1].SetStolen(); + sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, uNumSeconds, a6); + viewparams->bRedrawGameUI = 1; + bought_item->Reset(); + pRenderer->ClearZBuffer(0, 479); + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); + return; + } + } + } + dword_F8B1E4 = 1; + Party::TakeGold(uPriceItemService); + viewparams->bRedrawGameUI = 1; + bought_item->Reset(); + pRenderer->ClearZBuffer(0, 479); + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)SPEECH_75, 0); + return; + } + pPlayers[uActiveCharacter]->PlaySound(SPEECH_NoRoom, 0); + ShowStatusBarString(pGlobalTXT_LocalizationStrings[563], 2); // "Pack is Full!" + break; + } + default:// if click video screen in shop + { + __debugbreak(); // please do record these dialogue ids to the HOUSE_DIALOGUE_MENU enum + if( dialog_menu_id >= 36 && dialog_menu_id <= 72 ) + { + v42 = dialog_menu_id - 36; + //v43 = (signed __int64)(*(float *)&p2DEvents_minus1__24[13 * (unsigned int)ptr_507BC0->ptr_1C] * 500.0); + v43 = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].flt_24 * 500.0); + uPriceItemService = v43 * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100; + if ( uPriceItemService < v43 / 3 ) + uPriceItemService = v43 / 3; + if ( byte_4ED970_skill_learn_ability_by_class_table[pPlayers[uActiveCharacter]->classType][v42] ) + { + pSkill = &pPlayers[uActiveCharacter]->pActiveSkills[v42]; + if ( !*pSkill ) + { + if ( pParty->uNumGold < uPriceItemService ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2);// "You don't have enough gold" + if ( in_current_building_type == BildingType_Training ) + v55 = 4; + else + v55 = 2; + PlayHouseSound((unsigned int)window_SpeakInHouse->ptr_1C, (HouseSoundID)v55); + return; + } + Party::TakeGold(uPriceItemService); + dword_F8B1E4 = 1; + *pSkill = 1; + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)78, 0); + return; + } + } + } + break; + } + } +} +//----- (004BC8D5) -------------------------------------------------------- +void SpellBookGenerator()//for GuildDialogs +{ + int pItemNum; // esi@1 + int v4; // esi@7 + + for( int i = 0; i < 12; ++i ) + { + if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType >= 5 ) + { + if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 13 ) + pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType + 345; + else + { + if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 14 ) + v4 = rand() % 4; + else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 15 ) + v4 = rand() % 3 + 4; + else if ( p2DEvents[window_SpeakInHouse->par1C - 1].uType == 16 ) + v4 = rand() % 2 + 7; + if( p2DEvents[window_SpeakInHouse->par1C - 1].uType <= 16 ) + pItemNum = rand() % word_4F0F30[(signed int)window_SpeakInHouse->par1C - 139] + 11 * v4 + 400; + } + } + if ( pItemNum == 487 ) + { + if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) ) + pItemNum = 486; + } + ItemGen * item_spellbook = &pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i]; + item_spellbook->Reset(); + pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].uItemID = pItemNum; + pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].Identified(); + ItemsInShopTexture[i] = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[pItemNum].pIconName, TEXTURE_16BIT_PALETTE); + } + return; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/UIHouses.h Wed Jun 19 17:18:35 2013 +0600 @@ -0,0 +1,138 @@ +#pragma once + +enum HOUSE_DIALOGUE_MENU: __int32 +{ + HOUSE_DIALOGUE_NULL = 0, + HOUSE_DIALOGUE_MAIN = 1, + HOUSE_DIALOGUE_SHOP_BUY_STANDARD = 2, + HOUSE_DIALOGUE_SHOP_SELL = 3, + HOUSE_DIALOGUE_SHOP_IDENTIFY = 4, + HOUSE_DIALOGUE_SHOP_REPAIR = 5, + HOUSE_DIALOGUE_SHOP_6 = 6, + HOUSE_DIALOGUE_BANK_7 = 7, + HOUSE_DIALOGUE_BANK_8 = 8, + HOUSE_DIALOGUE_9 = 9, + HOUSE_DIALOGUE_TEMPLE_HEAL = 10, + HOUSE_DIALOGUE_TEMPLE_DONATE = 11, + HOUSE_DIALOGUE_12 = 12, + HOUSE_DIALOGUE_13 = 13, + HOUSE_DIALOGUE_14 = 14, + HOUSE_DIALOGUE_TAVERN_REST = 15, + HOUSE_DIALOGUE_TAVERN_BUY_FOOD = 16, + HOUSE_DIALOGUE_TRAININGHALL_TRAIN = 17, + HOUSE_DIALOGUE_GUILD_BUY_BOOKS = 18, + //... + HOUSE_DIALOGUE_36 = 36, + //.. + HOUSE_DIALOGUE_GUILD_LEARN_SKILL = 72, + //... + HOUSE_DIALOGUE_SHOP_DISPLAY_EQUIPMENT = 94, + HOUSE_DIALOGUE_SHOP_BUY_SPECIAL = 95, + HOUSE_DIALOGUE_LEARN_SKILLS = 96, + HOUSE_DIALOGUE_97 = 97, + HOUSE_DIALOGUE_98 = 98, + HOUSE_DIALOGUE_TOWNHALL_99 = 99, + HOUSE_DIALOGUE_TOWNHALL_100 = 100, + HOUSE_DIALOGUE_TAVERN_ARCOMAGE_MAIN = 101, + HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RULES = 102, + HOUSE_DIALOGUE_TAVERN_ARCOMAGE_VICTORY_CONDITIONS = 103, + HOUSE_DIALOGUE_TAVERN_ARCOMAGE_RESULT = 104, + HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_1 = 105, + HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_2 = 106, + HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_3 = 107, + HOUSE_DIALOGUE_TRANSPORT_SCHEDULE_4 = 108, + HOUSE_DIALOGUE_OTHER = -1 +}; + +/* 349 */ +enum HOUSE_ID +{ + HOUSE_SMITH_EMERALD_ISLE = 1, + HOUSE_ARMOURER_EMERALD_ISLE = 15, + HOUSE_MAGE_EMERALD_ISLE = 29, + HOUSE_MAGE_HARMONDALE = 30, + HOUSE_ALCHEMIST_EMERALD_ISLE = 42, + HOUSE_ALCHEMIST_HARMONDALE = 43, + HOUSE_STABLES_HARMONDALE = 54, + HOUSE_STABLES_STEADWICK = 55, + HOUSE_STABLES_56 = 56, + HOUSE_STABLES_57 = 57, + HOUSE_STABLES_58 = 58, + HOUSE_STABLES_59 = 59, + HOUSE_STABLES_60 = 60, + HOUSE_STABLES_61 = 61, + HOUSE_STABLES_62 = 62, + HOUSE_BOATS_63 = 63, + HOUSE_BOATS_64 = 64, + HOUSE_BOATS_65 = 65, + HOUSE_BOATS_66 = 66, + HOUSE_BOATS_67 = 67, + HOUSE_BOATS_68 = 68, + HOUSE_BOATS_69 = 69, + HOUSE_BOATS_70 = 70, + HOUSE_BOATS_71 = 71, + HOUSE_BOATS_72 = 72, + HOUSE_BOATS_73 = 73, + HOUSE_TEMPLE_EMERALD_ISLE = 74, + HOUSE_TEMPLE_HARMONDALE = 75, + HOUSE_TRAINING_HALL_EMERALD_ISLE = 89, + HOUSE_TRAINING_HALL_HARMONDALE = 90, + HOUSE_TRAINING_HALL_91 = 91, + HOUSE_TRAINING_HALL_92 = 92, + HOUSE_TRAINING_HALL_93 = 93, + HOUSE_TRAINING_HALL_94 = 94, + HOUSE_TRAINING_HALL_95 = 95, + + HOUSE_TOWNHALL_HARMONDALE = 102, + HOUSE_TAVERN_EMERALD_ISLE = 107, + HOUSE_BANK_HARMONDALE = 128, + HOUSE_FIRE_GUILD_INITIATE_EMERALD_ISLE = 139, + HOUSE_AIR_GUILD_INITIATE_EMERALD_ISLE = 143, + HOUSE_SPIRIT_GUILD_INITIATE_EMERALD_ISLE = 155, + HOUSE_BODY_GUILD_INITIATE_EMERALD_ISLE = 163, + HOUSE_BODY_GUILD_ERATHIA = 165, + HOUSE_DARK_GUILD_PIT = 170, + HOUSE_LORD_AND_JUDGE_EMERALD_ISLE = 186, + HOUSE_JAIL = 187, + HOUSE_JUDGE_HARMONDALE = 190, + HOUSE_224_EMERALD_ISLE = 224, + HOUSE_225_EMERALD_ISLE = 225, + HOUSE_238_EMERALD_ISLE = 238, + HOUSE_466_HARMONDALE = 466, + HOUSE_467_HARMONDALE = 467, + HOUSE_468_HARMONDALE = 468, + HOUSE_472_HARMONDALE = 472, + HOUSE_488_HARMONDALE = 488, + HOUSE_489_HARMONDALE = 489, + HOUSE_600 = 600,//??? + HOUSE_601 = 601//??? +}; + +enum HouseSoundID: unsigned __int32 +{ + HouseSound_Greeting = 1, // General greeting + HouseSound_NotEnoughMoney_TrainingSuccessful = 2, + HouseSound_Greeting_2 = 3, // Polite Greeting when you're guild member + HouseSound_Goodbye = 4 // farewells when bought something +}; + +void TrainingDialog(); +void JailDialog(); +void MagicShopDialog(); +void GuildDialog(); +void sub_4B6478(); +bool __fastcall IsTravelAvailable(int a1); +void __cdecl TravelByTransport(); +void TempleDialog(); +void __cdecl TownHallDialog(); +void __cdecl BankDialog(); +void __cdecl TavernDialog(); +void PlayHouseSound(unsigned int uHouseID, HouseSoundID sound); // idb +void __cdecl WeaponShopDialog(); +void __cdecl AlchemistDialog(); +void __cdecl ArmorShopDialog(); + +extern int uHouse_ExitPic; // weak +extern int dword_591080; // weak +extern int in_current_building_type; // 00F8B198 +extern HOUSE_DIALOGUE_MENU dialog_menu_id; // 00F8B19C \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/UIMainMenu.cpp Wed Jun 19 17:18:35 2013 +0600 @@ -0,0 +1,359 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include <assert.h> + + +#include "Mouse.h" +#include "Keyboard.h" + +#include "GUIWindow.h" +#include "GUIFont.h" +#include "AudioPlayer.h" +#include "Render.h" +#include "LOD.h" +#include "Allocator.h" +#include "PaletteManager.h" +#include "IconFrameTable.h" +#include "texts.h" + +#include "mm7_data.h" + + + +//----- (0041B578) -------------------------------------------------------- +void MainMenuUI_LoadFontsAndSomeStuff() +{ + pIcons_LOD->SetupPalettes(pRenderer->uTargetRBits, + pRenderer->uTargetGBits, + pRenderer->uTargetBBits); + pPaletteManager->SetColorChannelInfo(pRenderer->uTargetRBits, + pRenderer->uTargetGBits, + pRenderer->uTargetBBits); + pPaletteManager->RecalculateAll(); + + for (uint i = 0; i < 480; ++i) + pSRZBufferLineOffsets[i] = 640 * i; + + pRenderer->ResetTextureClipRect(); + + uTextureID_FONTPAL = pIcons_LOD->LoadTexture("FONTPAL", TEXTURE_16BIT_PALETTE); + + pFontArrus = LoadFont("arrus.fnt", "FONTPAL", nullptr); + pFontArrus->field_3 = 0; + + pFontLucida = LoadFont("lucida.fnt", "FONTPAL", nullptr); + pFontLucida->field_3 = 0; + + pFontCreate = LoadFont("create.fnt", "FONTPAL", nullptr); + pFontCreate->field_3 = 0; + + pFontSmallnum = LoadFont("smallnum.fnt", "FONTPAL", nullptr); + pFontComic = LoadFont("comic.fnt", "FONTPAL", nullptr); + + for (uint i = 0; i < 20; ++i) + pWindowList[i].eWindowType = WINDOW_null; + + uNumVisibleWindows = -1; + memset(pVisibleWindowsIdxs.data(), 0, sizeof(pVisibleWindowsIdxs)); +} + +//----- (004415C5) -------------------------------------------------------- +static void LoadPartyBuffIcons() +{ + for (uint i = 0; i < 14; ++i) + { + char filename[200]; + sprintf(filename, "isn-%02d", i + 1); + pTextureIDs_PartyBuffIcons[i] = pIcons_LOD->LoadTexture(filename, TEXTURE_16BIT_PALETTE); + } + + uIconIdx_FlySpell = pIconsFrameTable->FindIcon("spell21"); + uIconIdx_WaterWalk = pIconsFrameTable->FindIcon("spell27"); +} + +//----- (0041B690) -------------------------------------------------------- +void MainMenuUI_Create() +{ + //unsigned int v0; // eax@1 + //unsigned int v1; // eax@1 + //unsigned int v2; // eax@1 + //unsigned int v3; // eax@1 + //unsigned int v4; // eax@1 + //unsigned int v5; // eax@1 + Texture *v6; // ST78_4@1 + //const char *v7; // ST5C_4@1 + unsigned __int8 v8; // al@1 + //Texture *v9; // ST60_4@1 + Texture *v10; // ST78_4@1 + //const char *v11; // ST5C_4@1 + unsigned __int8 v12; // al@1 + //Texture *v13; // ST60_4@1 + unsigned int v14; // eax@1 + Texture *v15; // ST78_4@1 + //const char *v16; // ST5C_4@1 + unsigned __int8 v17; // al@1 + //Texture *v18; // ST60_4@1 + unsigned int uTextureID_ib_td4_A; // eax@1 + Texture *v20; // ST78_4@1 + unsigned __int8 v22; // al@1 + //Texture *v23; // ST60_4@1 + Texture *v24; // eax@1 + //Texture *v25; // esi@1 + //Texture *v26; // ST60_4@1 + //const char *v27; // ST5C_4@1 + unsigned __int8 v28; // al@1 + Texture *v29; // eax@1 + //Texture *v30; // esi@1 + //Texture *v31; // ST60_4@1 + //const char *v32; // ST5C_4@1 + unsigned __int8 v33; // al@1 + + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("wizeyeC")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("wizeyeB")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("wizeyeA")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("torchC")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("torchB")); + pIconsFrameTable->InitializeAnimation(pIconsFrameTable->FindIcon("torchA")); + + pTextureIDs_pMapDirs[0] = pIcons_LOD->LoadTexture("MAPDIR8", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[1] = pIcons_LOD->LoadTexture("MAPDIR1", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[2] = pIcons_LOD->LoadTexture("MAPDIR2", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[3] = pIcons_LOD->LoadTexture("MAPDIR3", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[4] = pIcons_LOD->LoadTexture("MAPDIR4", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[5] = pIcons_LOD->LoadTexture("MAPDIR5", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[6] = pIcons_LOD->LoadTexture("MAPDIR6", TEXTURE_16BIT_PALETTE); + pTextureIDs_pMapDirs[7] = pIcons_LOD->LoadTexture("MAPDIR7", TEXTURE_16BIT_PALETTE); + + uTextureID_BarBlue = pIcons_LOD->LoadTexture("ib-statB", TEXTURE_16BIT_PALETTE); + uTextureID_BarGreen = pIcons_LOD->LoadTexture("ib-statG", TEXTURE_16BIT_PALETTE); + uTextureID_BarYellow = pIcons_LOD->LoadTexture("ib-statY", TEXTURE_16BIT_PALETTE); + uTextureID_BarRed = pIcons_LOD->LoadTexture("ib-statR", TEXTURE_16BIT_PALETTE); + uTextureID_mhp_bd = pIcons_LOD->LoadTexture("mhp_bg", TEXTURE_16BIT_PALETTE); + uTextureID_mhp_capl = pIcons_LOD->LoadTexture("mhp_capl", TEXTURE_16BIT_PALETTE); + uTextureID_mhp_capr = pIcons_LOD->LoadTexture("mhp_capr", TEXTURE_16BIT_PALETTE); + uTextureID_mhp_grn = pIcons_LOD->LoadTexture("mhp_grn", TEXTURE_16BIT_PALETTE); + uTextureID_mhp_red = pIcons_LOD->LoadTexture("mhp_red", TEXTURE_16BIT_PALETTE); + uTextureID_mhp_yel = pIcons_LOD->LoadTexture("mhp_yel", TEXTURE_16BIT_PALETTE); + uTextureID_Leather = pIcons_LOD->LoadTexture("LEATHER", TEXTURE_16BIT_PALETTE); + pTexture_Leather = pIcons_LOD->LoadTexturePtr("ibground", TEXTURE_16BIT_PALETTE); + uTextureID_x_x_u = pIcons_LOD->LoadTexture("x_x_u", TEXTURE_16BIT_PALETTE); + uTextureID_BUTTDESC2 = pIcons_LOD->LoadTexture("BUTTESC2", TEXTURE_16BIT_PALETTE); + uTextureID_x_ok_u = pIcons_LOD->LoadTexture("x_ok_u", TEXTURE_16BIT_PALETTE); + uTextureID_BUTTYES2 = pIcons_LOD->LoadTexture("BUTTYES2", TEXTURE_16BIT_PALETTE); + uTextureID_BUTTMAKE = pIcons_LOD->LoadTexture("BUTTMAKE", TEXTURE_16BIT_PALETTE); + uTextureID_BUTTMAKE2 = pIcons_LOD->LoadTexture("BUTTMAKE2", TEXTURE_16BIT_PALETTE); + + pPrimaryWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); + pPrimaryWindow->CreateButton(7u, 8u, 0x1CCu, 0x157u, 1, 0, UIMSG_MouseLeftClickInGame, 0, 0, "", 0); + pPrimaryWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); + pPrimaryWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); + pPrimaryWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); + pPrimaryWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); + pPrimaryWindow->CreateButton(0x18u, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 1, 0, "", 0); + pPrimaryWindow->CreateButton(0x8Bu, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 2, 0, "", 0); + pPrimaryWindow->CreateButton(0xFFu, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 3, 0, "", 0); + pPrimaryWindow->CreateButton(0x172u, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 4, 0, "", 0); + pPrimaryWindow->CreateButton(0x61u, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 1, 0, "", 0); + pPrimaryWindow->CreateButton(0xD4u, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 2, 0, "", 0); + pPrimaryWindow->CreateButton(0x148u, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 3, 0, "", 0); + pPrimaryWindow->CreateButton(0x1BBu, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 4, 0, "", 0); + + uTextureID_ib_td1_A = pIcons_LOD->LoadTexture("ib-td1-A", TEXTURE_16BIT_PALETTE); + v6 = pIcons_LOD->GetTexture(uTextureID_ib_td1_A); + v8 = pKeyActionMap->GetActionVKey(INPUT_Quest); + pBtn_Quests = pPrimaryWindow->CreateButton(0x1EBu, 0x161u, v6->uTextureWidth, v6->uTextureHeight, 1, 0, UIMSG_OpenQuestBook, 0, v8, pGlobalTXT_LocalizationStrings[174], v6, 0); //Quests + + uTextureID_ib_td2_A = pIcons_LOD->LoadTexture("ib-td2-A", TEXTURE_16BIT_PALETTE); + v10 = pIcons_LOD->GetTexture(uTextureID_ib_td2_A); + v12 = pKeyActionMap->GetActionVKey(INPUT_Autonotes); + pBtn_Autonotes = pPrimaryWindow->CreateButton(0x20Fu, 0x161u, v10->uTextureWidth, v10->uTextureHeight, 1, 0, UIMSG_OpenAutonotes, 0, v12, pGlobalTXT_LocalizationStrings[154], v10, 0);//Autonotes + + v14 = pIcons_LOD->LoadTexture("ib-td3-A", TEXTURE_16BIT_PALETTE); + v15 = pIcons_LOD->GetTexture(v14); + v17 = pKeyActionMap->GetActionVKey(INPUT_Mapbook); + pBtn_Maps = pPrimaryWindow->CreateButton(0x222u, 0x161u, v15->uTextureWidth, v15->uTextureHeight, 1, 0, UIMSG_OpenMapBook, 0, v17, pGlobalTXT_LocalizationStrings[139], v15, 0); //Maps + + uTextureID_ib_td4_A = pIcons_LOD->LoadTexture("ib-td4-A", TEXTURE_16BIT_PALETTE); + v20 = pIcons_LOD->GetTexture(uTextureID_ib_td4_A); + v22 = pKeyActionMap->GetActionVKey(INPUT_TimeCal); + pBtn_Calendar = pPrimaryWindow->CreateButton(0x23Au, 0x161u, v20->uTextureWidth, v20->uTextureHeight, 1, 0, UIMSG_OpenCalendar, 0, v22, + pGlobalTXT_LocalizationStrings[78],//Calendar + v20, 0); + + uTextureID_ib_td5_A = pIcons_LOD->LoadTexture("ib-td5-A", TEXTURE_16BIT_PALETTE); + pBtn_History = pPrimaryWindow->CreateButton(0x258u, 0x169u, + pIcons_LOD->GetTexture(uTextureID_ib_td5_A)->uTextureWidth, + pIcons_LOD->GetTexture(uTextureID_ib_td5_A)->uTextureHeight, + 1, 0, UIMSG_OpenHistoryBook, 0, 0x48u, pGlobalTXT_LocalizationStrings[602],//History + pIcons_LOD->GetTexture(uTextureID_ib_td5_A), 0); + + bFlashAutonotesBook = 0; + bFlashQuestBook = 0; + bFlashHistoryBook = 0; + + v24 = &pIcons_LOD->pTextures[uTextureID_Btn_ZoomIn]; + v28 = pKeyActionMap->GetActionVKey(INPUT_ZoomIn); + pBtn_ZoomIn = pPrimaryWindow->CreateButton(574, 136, v24->uTextureWidth, v24->uTextureHeight, 2, 0, UIMSG_ClickZoomInBtn, 0, v28, pGlobalTXT_LocalizationStrings[252], // Zoom In + v24, 0); + v29 = &pIcons_LOD->pTextures[uTextureID_Btn_ZoomOut]; + v33 = pKeyActionMap->GetActionVKey(INPUT_ZoomOut); + pBtn_ZoomOut = pPrimaryWindow->CreateButton(519, 136, v29->uTextureWidth, v29->uTextureHeight, 2, 0, UIMSG_ClickZoomOutBtn, 0, v33, pGlobalTXT_LocalizationStrings[251], // Zoom Out + v29, 0); + pPrimaryWindow->CreateButton(0x1E1u, 0, 0x99u, 0x43u, 1, 92, UIMSG_0, 0, 0, "", 0); + pPrimaryWindow->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, UIMSG_StartHireling1Dialogue, 0, '5', "", 0); + pPrimaryWindow->CreateButton(0x231u, 0x95u, 0x40u, 0x4Au, 1, 0, UIMSG_StartHireling2Dialogue, 0, '6', "", 0); + pPrimaryWindow->CreateButton(0x1DCu, 0x142u, 0x4Du, 0x11u, 1, 100, UIMSG_0, 0, 0, "", 0); + pPrimaryWindow->CreateButton(0x22Bu, 0x142u, 0x4Du, 0x11u, 1, 101, UIMSG_0, 0, 0, "", 0); + pBtn_CastSpell = pPrimaryWindow->CreateButton(0x1DCu, 0x1C2u, + pIcons_LOD->GetTexture(uTextureID_Btn_CastSpell)->uTextureWidth, + pIcons_LOD->GetTexture(uTextureID_Btn_CastSpell)->uTextureHeight, + 1, 0, UIMSG_SpellBookWindow, 0, 0x43u, pGlobalTXT_LocalizationStrings[38], pIcons_LOD->GetTexture(uTextureID_Btn_CastSpell), + 0); + pBtn_Rest = pPrimaryWindow->CreateButton(0x206u, 0x1C2u, + pIcons_LOD->GetTexture(uTextureID_Btn_Rest)->uTextureWidth, + pIcons_LOD->GetTexture(uTextureID_Btn_Rest)->uTextureHeight, + 1, 0, UIMSG_RestWindow, 0, 0x52u, pGlobalTXT_LocalizationStrings[182], pIcons_LOD->GetTexture(uTextureID_Btn_Rest), 0); + pBtn_QuickReference = pPrimaryWindow->CreateButton(0x230u, 0x1C2u, + pIcons_LOD->GetTexture(uTextureID_Btn_QuickReference)->uTextureWidth, + pIcons_LOD->GetTexture(uTextureID_Btn_QuickReference)->uTextureHeight, + 1, 0, UIMSG_QuickReference, 0, 0x5Au, pGlobalTXT_LocalizationStrings[173], pIcons_LOD->GetTexture(uTextureID_Btn_QuickReference), 0); + pBtn_GameSettings = pPrimaryWindow->CreateButton(0x25Au, 0x1C2u, + pIcons_LOD->GetTexture(uTextureID_Btn_GameSettings)->uTextureWidth, + pIcons_LOD->GetTexture(uTextureID_Btn_GameSettings)->uTextureHeight, + 1, 0, UIMSG_GameMenuButton, 0, 0, pGlobalTXT_LocalizationStrings[93], pIcons_LOD->GetTexture(uTextureID_Btn_GameSettings), 0); + pBtn_NPCLeft = pPrimaryWindow->CreateButton(0x1D5u, 0xB2u, + pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureWidth, + pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureHeight, + 1, 0, UIMSG_ScrollNPCPanel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft), 0); + pBtn_NPCRight = pPrimaryWindow->CreateButton(0x272u, 0xB2u, + pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureWidth, + pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureHeight, + 1, 0, UIMSG_ScrollNPCPanel, 1u, 0, "", pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight), 0); + LoadPartyBuffIcons(); +} + +//----- (004979D2) -------------------------------------------------------- +MENU_STATE MainMenuUI_Credits_Loop() +{ + char *v0; // eax@5 + char *v1; // edi@5 + FILE *pFile; // eax@5 + unsigned int pSize; // esi@7 + GUIFont *pFont; // edx@9 + GUIFont *pFont2; // ecx@9 + __int16 pHeight; // ax@9 + void *v7; // eax@9 + unsigned int pNumPixels; // ST2C_4@9 + unsigned int teal; // eax@9 + unsigned int v10; // ST2C_4@19 + MSG Msg; // [sp+84h] [bp-B8h]@10 + int v17; // [sp+A0h] [bp-9Ch]@9 + GUIWindow a2; + int pColor2; // [sp+F8h] [bp-44h]@9 + int pColor1; // [sp+FCh] [bp-40h]@9 + int a5; // [sp+128h] [bp-14h]@1 + char *pString; // [sp+12Ch] [bp-10h]@9 + char *ptr; // [sp+130h] [bp-Ch]@5 + GUIFont *pFontQuick; // [sp+134h] [bp-8h]@1 + GUIFont *pFontCChar; // [sp+138h] [bp-4h]@1 + RGBTexture pTexture; // [sp+54h] [bp-E8h]@1 + RGBTexture pTexture2; // [sp+100h] [bp-3Ch]@1 + Texture pTexture3; // [sp+Ch] [bp-130h]@5 + + a5 = 0; + pFontQuick = LoadFont("quick.fnt", "FONTPAL", NULL); + pFontCChar = LoadFont("cchar.fnt", "FONTPAL", NULL); + if ( pMessageQueue_50CBD0->uNumMessages ) + pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0; + ++pIcons_LOD->uTexturePacksCount; + if ( !pIcons_LOD->uNumPrevLoadedFiles ) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + dword_A74C88 = 0; + pAudioPlayer->PlayMusicTrack(MUSIC_Credits); + pTexture.Load("mm6title.pcx", 0); + v0 = (char *)pEvents_LOD->LoadRaw("credits.txt", 0); + v1 = v0; + ptr = v0; + pFile = pEvents_LOD->FindContainer("credits.txt", 0); + if ( !pFile ) + Abortf(pGlobalTXT_LocalizationStrings[63]); // "Might and Magic VII is having trouble loading files. + // Please re-install to fix this problem. Note: Re-installing will not destroy your save games." + fread(&pTexture3, 1, 0x30, pFile); + pSize = pTexture3.uDecompressedSize; + if ( !pTexture3.uDecompressedSize ) + pSize = pTexture3.uTextureSize; + memset(&pTexture3, 0, 0x48); + pFont = pFontCChar; + pFont2 = pFontQuick; + v1[pSize] = 0; + + a2.uFrameWidth = 250; + a2.uFrameHeight = 440; + a2.uFrameX = 389; + a2.uFrameY = 19; + + pTexture2.uWidth = 250; + pHeight = pFont2->GetStringHeight2(pFont, v1, &a2, 0, 1); + pTexture2.uHeight = pHeight + 2 * a2.uFrameHeight; + pTexture2.uNumPixels = (signed __int16)pTexture2.uWidth * (signed __int16)pTexture2.uHeight; + v7 = pAllocator->AllocNamedChunk(pTexture2.pPixels, 2 * pTexture2.uNumPixels, "scrollermap"); + pNumPixels = pTexture2.uNumPixels; + pTexture2.pPixels = (unsigned __int16 *)v7; + teal = TargetColor(0, 0xFFu, 0xFFu); + fill_pixels_fast(teal, pTexture2.pPixels, pNumPixels); + pTexture2.field_20 = 0; + pTexture2.field_22 = 0; + pColor1 = TargetColor(0x70u, 0x8Fu, 0xFEu); + pColor2 = TargetColor(0xECu, 0xE6u, 0x9Cu); + pString = (char *)operator new(2 * pSize); + strncpy(pString, ptr, pSize); + pString[pSize]=0; + pFontQuick->_44D2FD_prolly_draw_credits_entry(pFontCChar, 0, a2.uFrameHeight, (signed __int16)pTexture2.uWidth, (signed __int16)pTexture2.uHeight, pColor1, + pColor2, pString, pTexture2.pPixels, (signed __int16)pTexture2.uWidth); + free(pString); + pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, ptr); + pWindow_MainMenu->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_Escape, 0, 0x1Bu, "", 0); + pCurrentScreen = SCREEN_CREATORS; + SetCurrentMenuID(MENU_CREDITSPROC); + do + { + while ( PeekMessageA(&Msg, 0, 0, 0, 1) ) + { + if ( Msg.message == 18 ) + Game_DeinitializeAndTerminate(0); + TranslateMessage(&Msg); + DispatchMessageA(&Msg); + } + if ( BYTE1(dword_6BE364_game_settings_1) & 1 ) + { + WaitMessage(); + } + else + { + pRenderer->BeginScene(); + pRenderer->DrawTextureRGB(0, 0, &pTexture); + pRenderer->SetTextureClipRect(a2.uFrameX, a2.uFrameY, a2.uFrameX + a2.uFrameWidth, a2.uFrameY + a2.uFrameHeight); + pRenderer->_4A5D33(a2.uFrameX, a2.uFrameY, 0, a5, &pTexture2); + pRenderer->ResetTextureClipRect(); + pRenderer->EndScene(); + ++a5; + if ( a5 >= (signed __int16)pTexture2.uHeight ) + SetCurrentMenuID(MENU_MAIN); + pRenderer->Present(); + pCurrentScreen = SCREEN_GAME;//Ritor1: temporarily, must be corrected GUI_MainMenuMessageProc() + GUI_MainMenuMessageProc(); + } + } + while ( GetCurrentMenuID() == MENU_CREDITSPROC ); + pAudioPlayer->_4AA258(1); + pAllocator->FreeChunk(ptr); + pAllocator->FreeChunk(pFontQuick); + pAllocator->FreeChunk(pFontCChar); + pWindow_MainMenu->Release(); + pIcons_LOD->_4114F2(); + pTexture.Release(); + pTexture2.Release(); + return MENU_MAIN; // return MENU_Main + }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/UIOptions.cpp Wed Jun 19 17:18:35 2013 +0600 @@ -0,0 +1,269 @@ +#include <assert.h> + +#include "MM7.h" + +#include "Keyboard.h" +#include "IndoorCameraD3D.h" +#include "CShow.h" +#include "GammaControl.h" +#include "Render.h" + +#include "Game.h" +#include "GUIWindow.h" +#include "GUIFont.h" +#include "AudioPlayer.h" +#include "LOD.h" +#include "texts.h" + +#include "mm7_data.h" + + + + +OptionsMenuSkin options_menu_skin; // 507C60 + + +std::array<bool, 28> GameMenuUI_InvaligKeyBindingsFlags; // 506E6C +//----- (00414D24) -------------------------------------------------------- +static unsigned int GameMenuUI_GetKeyBindingColor(int key_index) +{ + if (uGameMenuUI_CurentlySelectedKeyIdx == key_index) + { + if (GetTickCount() % 1000 < 500) + return ui_gamemenu_keys_key_selection_blink_color_1; + else + return ui_gamemenu_keys_key_selection_blink_color_2; + } + else if (GameMenuUI_InvaligKeyBindingsFlags[key_index]) + { + int intensity; + + int time = GetTickCount() % 800; + if (time < 400) + intensity = - 70 + 70 * time / 400; + else + intensity = + 70 - 70 * time / 800; + + return TargetColor(185 + intensity, 40 + intensity / 4, 40 + intensity / 4); + } + + return ui_gamemenu_keys_key_default_color; +} + +//----- (004142D3) -------------------------------------------------------- +void GameMenuUI_DrawKeyBindings() +{ + signed int v4; // ecx@7 + signed int v5; // eax@8 + + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) + { + pPrevVirtualCidesMapping[uGameMenuUI_CurentlySelectedKeyIdx] = pKeyActionMap->pPressedKeysBuffer[0]; + memset(GameMenuUI_InvaligKeyBindingsFlags.data(), 0, sizeof(GameMenuUI_InvaligKeyBindingsFlags)); + v4 = 0; + do + { + v5 = 0; + do + { + if ( v4 != v5 && pPrevVirtualCidesMapping[v4] == pPrevVirtualCidesMapping[v5] ) + { + GameMenuUI_InvaligKeyBindingsFlags[v4] = true; + GameMenuUI_InvaligKeyBindingsFlags[v5] = true; + } + ++v5; + } + while ( v5 < 28 ); + ++v4; + } + while ( v4 < 28 ); + uGameMenuUI_CurentlySelectedKeyIdx = -1; + pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + } + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_Optkb[0])); + if ( KeyboardPageNum == 1 ) + { + pRenderer->DrawTextureIndexed(0x13, 0x12E, pIcons_LOD->GetTexture(uTextureID_Optkb[3])); + + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, ui_gamemenu_keys_action_name_color, "ÂÏÅШÄ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 142, GameMenuUI_GetKeyBindingColor(0), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[0]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, ui_gamemenu_keys_action_name_color, "ÍÀÇÀÄ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 163, GameMenuUI_GetKeyBindingColor(1), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[1]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, ui_gamemenu_keys_action_name_color, "ÂËÅÂÎ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 184, GameMenuUI_GetKeyBindingColor(2), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[2]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, ui_gamemenu_keys_action_name_color, "ÂÏÐÀÂÎ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 205, GameMenuUI_GetKeyBindingColor(3), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[3]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, ui_gamemenu_keys_action_name_color, "ÊÐÈÊ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 226, GameMenuUI_GetKeyBindingColor(4), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[4]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, ui_gamemenu_keys_action_name_color, "ÏÐÛÆÎÊ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 247, GameMenuUI_GetKeyBindingColor(5), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[5]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, ui_gamemenu_keys_action_name_color, "Ï.ÐÅÆÈÌ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 268, GameMenuUI_GetKeyBindingColor(6), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[6]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, ui_gamemenu_keys_action_name_color, "ÏÐÈÌ. ÇÀÊË.", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 142, GameMenuUI_GetKeyBindingColor(7), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[7]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, ui_gamemenu_keys_action_name_color, "ÀÒÀÊÀ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 163, GameMenuUI_GetKeyBindingColor(8), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[8]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, ui_gamemenu_keys_action_name_color, "ÄÅÉÑÒÂ.", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 184, GameMenuUI_GetKeyBindingColor(9), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[9]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, ui_gamemenu_keys_action_name_color, "ÇÀÊËÈÍ.", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 205, GameMenuUI_GetKeyBindingColor(10), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[10]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, ui_gamemenu_keys_action_name_color, "ÈÃÐÎÊ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 226, GameMenuUI_GetKeyBindingColor(11), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[11]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, ui_gamemenu_keys_action_name_color, "ÑËÅÄ. ÈÃÐÎÊ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 247, GameMenuUI_GetKeyBindingColor(12), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[12]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, ui_gamemenu_keys_action_name_color, "ÇÀÄÀÍÈß", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 268, GameMenuUI_GetKeyBindingColor(13), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[13]), 0, 0, 0); + } + else + { + pRenderer->DrawTextureIndexed(0x7F, 0x12E, pIcons_LOD->GetTexture(uTextureID_Optkb[4])); + + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, ui_gamemenu_keys_action_name_color, "Á. ÑÏÐÀÂÊÀ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 142, GameMenuUI_GetKeyBindingColor(14), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[14]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, ui_gamemenu_keys_action_name_color, "ÎÒÄÛÕ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 163, GameMenuUI_GetKeyBindingColor(15), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[15]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, ui_gamemenu_keys_action_name_color, "ÒÅÊ. ÂÐÅÌß", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 184, GameMenuUI_GetKeyBindingColor(16), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[16]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, ui_gamemenu_keys_action_name_color, "ÀÂÒÎÇÀÌÅÒÊÈ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 205, GameMenuUI_GetKeyBindingColor(17), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[17]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, ui_gamemenu_keys_action_name_color, "ÊÀÐÒÀ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 226, GameMenuUI_GetKeyBindingColor(18), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[18]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, ui_gamemenu_keys_action_name_color, "ÁÅÆÀÒÜ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 247, GameMenuUI_GetKeyBindingColor(19), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[19]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, ui_gamemenu_keys_action_name_color, "ÑÌ. ÂÂÅÐÕ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 268, GameMenuUI_GetKeyBindingColor(20), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[20]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, ui_gamemenu_keys_action_name_color, "ÑÌ. ÂÍÈÇ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 142, GameMenuUI_GetKeyBindingColor(21), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[21]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, ui_gamemenu_keys_action_name_color, "ÑÌ. ÂÏÅШÄ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 163, GameMenuUI_GetKeyBindingColor(22), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[22]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, ui_gamemenu_keys_action_name_color, "ÏÐÈÁËÈÇ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 184, GameMenuUI_GetKeyBindingColor(23), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[23]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, ui_gamemenu_keys_action_name_color, "ÎÒÄÀËÈÒÜ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 205, GameMenuUI_GetKeyBindingColor(24), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[24]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, ui_gamemenu_keys_action_name_color, "Ï. ÂÂÅÐÕ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 226, GameMenuUI_GetKeyBindingColor(25), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[25]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, ui_gamemenu_keys_action_name_color, "Ï. ÂÍÈÇ", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 247, GameMenuUI_GetKeyBindingColor(26), pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[26]), 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, ui_gamemenu_keys_action_name_color, "ÏÐÈÇÅÌË", 0, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 268, GameMenuUI_GetKeyBindingColor(27), pKeyActionMap->GetVKeyDisplayName(pWindowList_at_506F50_minus1_indexing[0]), 0, 0, 0); + } +} + + + + +//----- (00414D9A) -------------------------------------------------------- +void GameMenuUI_DrawVideoOptions() +{ + const char *v0; // ST0C_4@3 + //unsigned __int16 v1; // ax@3 + //int v2; // eax@10 + GUIWindow v3; // [sp+8h] [bp-54h]@3 + + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_507C10)); + if ( !pRenderer->bWindowMode && GammaController::IsGammaSupported() ) + { + pRenderer->DrawTextureIndexed( + 17 * uGammaPos + 42, + 162, + pIcons_LOD->GetTexture(pTextureIDs_GammaPositions[uGammaPos])); + pRenderer->DrawTextureRGB(0x112u, 0xA9u, &stru_506E40); + v3.uFrameX = 22; + v0 = pGlobalTXT_LocalizationStrings[226]; // "Gamma controls the relative ""brightness"" of the game. May vary depending on your monitor." + v3.uFrameY = 190; + v3.uFrameWidth = 211; + v3.uFrameHeight = 79; + v3.uFrameZ = 232; + v3.uFrameW = 268; + //v1 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + v3.DrawTitleText(pFontSmallnum, 0, 0, ui_gamemenu_video_gamma_title_color, v0, 3u); + } + + if (!pRenderer->pRenderD3D) + { + pRenderer->DrawTextureIndexed(20, 281, pIcons_LOD->GetTexture(uTextureID_507C50)); + pRenderer->DrawTextureIndexed(20, 303, pIcons_LOD->GetTexture(uTextureID_507C54)); + pRenderer->DrawTextureIndexed(20, 325, pIcons_LOD->GetTexture(uTextureID_507C58)); + } + else + { + if (pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS) + pRenderer->DrawTextureIndexed(20, 281, pIcons_LOD->GetTexture(uTextureID_507C14)); + if (pRenderer->bUseColoredLights) + pRenderer->DrawTextureIndexed(20, 303, pIcons_LOD->GetTexture(uTextureID_507C18)); + if (pRenderer->bTinting) + pRenderer->DrawTextureIndexed(20, 325, pIcons_LOD->GetTexture(uTextureID_507C1C)); + } +} + + + +//----- (00414F82) -------------------------------------------------------- +void GameMenuUI_Options_Draw() +{ + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_Options)); + pRenderer->DrawTextureIndexed(8, 132, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_Background)); + + switch (uTurnSpeed) + { + case 64: pRenderer->DrawTextureIndexed(BtnTurnCoord[1], 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1])); break; + case 128: pRenderer->DrawTextureIndexed(BtnTurnCoord[2], 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])); break; + default: pRenderer->DrawTextureIndexed(BtnTurnCoord[0], 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0])); break; + } + + if (bWalkSound) pRenderer->DrawTextureIndexed( 20, 303, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_WalkSound)); + if (bShowDamage) pRenderer->DrawTextureIndexed(128, 303, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ShowDamage)); + if (bFlipOnExit) pRenderer->DrawTextureIndexed(128, 325, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_FlipOnExit)); + if (bAlwaysRun) pRenderer->DrawTextureIndexed( 20, 325, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_AlwaysRun)); + + pRenderer->DrawTextureIndexed(265 + 17 * uSoundVolumeMultiplier, 162, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_SoundLevels[uSoundVolumeMultiplier])); + pRenderer->DrawTextureIndexed(265 + 17 * uMusicVolimeMultiplier, 216, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_SoundLevels[uMusicVolimeMultiplier])); + pRenderer->DrawTextureIndexed(265 + 17 * uVoicesVolumeMultiplier, 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_SoundLevels[uVoicesVolumeMultiplier])); +} + + + + + + + + + + +OptionsMenuSkin::OptionsMenuSkin(): + uTextureID_Background(0), + uTextureID_ArrowLeft(0), + uTextureID_ArrowRight(0), + uTextureID_unused_0(0), uTextureID_unused_1(0), uTextureID_unused_2(0), + uTextureID_FlipOnExit(0), + uTextureID_AlwaysRun(0), + uTextureID_WalkSound(0), + uTextureID_ShowDamage(0) +{ + for (uint i = 0; i < 3; ++i) uTextureID_TurnSpeed[i] = 0; + for (uint i = 0; i < 10; ++i) uTextureID_SoundLevels[i] = 0; +} + +void OptionsMenuSkin::Relaease() +{ + #define RELEASE(id) \ + {\ + if (id)\ + pIcons_LOD->GetTexture(id)->Release();\ + id = 0;\ + } + + RELEASE(uTextureID_Background); + for (uint i = 0; i < 3; ++i) + RELEASE(uTextureID_TurnSpeed[i]); + RELEASE(uTextureID_ArrowLeft); + RELEASE(uTextureID_ArrowRight); + RELEASE(uTextureID_FlipOnExit); + for (uint i = 0; i < 10; ++i) + RELEASE(uTextureID_SoundLevels[i]); + RELEASE(uTextureID_AlwaysRun); + RELEASE(uTextureID_WalkSound); + RELEASE(uTextureID_ShowDamage); + + #undef RELEASE +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/UIPartyCreation.cpp Wed Jun 19 17:18:35 2013 +0600 @@ -0,0 +1,877 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include <assert.h> + + +#include "Mouse.h" +#include "Keyboard.h" + +#include "Game.h" +#include "GUIWindow.h" +#include "GUIFont.h" +#include "Party.h" +#include "AudioPlayer.h" +#include "Render.h" +#include "LOD.h" +#include "Allocator.h" +#include "Time.h" +#include "IconFrameTable.h" +#include "texts.h" + +#include "mm7_data.h" + + + +//----- (004908DE) -------------------------------------------------------- +signed int __cdecl PlayerCreation_Chose4Skills() + { + Player *v0; // esi@1 + signed int v1; // edx@2 + unsigned short *v2; // eax@2 + signed int v3; // ecx@2 + + v0 = pParty->pPlayers;//[0].pActiveSkills; + while ( 1 ) + { + v1 = 0; + v2 = v0->pActiveSkills; + v3 = 37; + do + { + if ( *v2 ) + ++v1; + ++v2; + --v3; + } + while ( v3 ); + if ( v1 < 4 ) + break; + ++v0; + if ( v0 > &pParty->pPlayers[3] ) + return 1; + } + return 0; + } + + + + +//----- (00491CB5) -------------------------------------------------------- +void __cdecl LoadPlayerPortraintsAndVoices() + { + //Texture **v0; // ebx@1 + //int v1; // eax@2 + //int v2; // edi@3 + char *v3; // esi@5 + char *v4; // [sp+10h] [bp-4h]@1 + + pIcons_LOD->pFacesLock = pIcons_LOD->uNumLoadedFiles; + + for (uint i = 0; i < 4; ++i) + for (uint j = 0; j < 56; ++j) + { + sprintf(pTmpBuf.data(), "%s%02d", pPlayerPortraitsNames[pParty->pPlayers[i].uCurrentFace], j + 1); + pTextures_PlayerFaces[i][j] = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); + } + + pTexture_PlayerFaceEradicated = pIcons_LOD->LoadTexturePtr("ERADCATE", TEXTURE_16BIT_PALETTE); + pTexture_PlayerFaceDead = pIcons_LOD->LoadTexturePtr("DEAD", TEXTURE_16BIT_PALETTE); + pTexture_PlayerFaceMask = pIcons_LOD->LoadTexturePtr("FACEMASK", TEXTURE_16BIT_PALETTE); + + if (SoundSetAction[24][0]) + for (uint i = 0; i < 4; ++i) + { + pSoundList->LoadSound(2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4998, 0); + pSoundList->LoadSound(2 * (SoundSetAction[24][0] + 50 * pParty->pPlayers[i].uVoiceID) + 4999, 0); + } + } + +//----- (00491DE7) -------------------------------------------------------- +int __fastcall ReloadPlayerPortraits(int a1, int a2) + { + int result; // eax@1 + const char **v3; // ebp@1 + Texture **v4; // ebx@1 + int v5; // esi@2 + + result = 0; + v3 = &pPlayerPortraitsNames[a2]; + v4 = pTextures_PlayerFaces[a1].data(); + do + { + v5 = result + 1; + sprintf(pTmpBuf.data(), "%s%02d", *v3, result + 1); + pIcons_LOD->ReloadTexture(*v4, pTmpBuf.data(), 2); + result = v5; + ++v4; + } + while ( v5 < 56 ); + return result; + } +//----- (00495B39) -------------------------------------------------------- +void PlayerCreationUI_Draw() +{ + int pTextCenter; // eax@3 + IconFrame *pFrame; // eax@3 + int pX; // ecx@7 + GUIButton *uPosActiveItem; // edi@12 + int uNumLet; // eax@14 + char v8; // al@17 + int v9; // ecx@17 + char v10; // sf@17 + size_t v16; // eax@28 + int v17; // eax@33 + int uStatLevel; // eax@44 + unsigned int pStatColor; // eax@44 + PLAYER_SKILL_TYPE pSkillsType; // eax@44 + int v51; // eax@49 + char *v52; // edi@52 + char v53; // al@52 + PLAYER_CLASS_TYPE uClassType; // edi@53 + int pColorText; // eax@53 + PLAYER_SKILL_TYPE pSkillId; // edi@72 + size_t pLenText; // eax@72 + signed int v104; // ecx@72 + int pTextY; // ST08_4@81 + signed int pBonusNum; // edi@82 + const char *uRaceName; // [sp+0h] [bp-170h]@39 + char pText[200]; // [sp+10h] [bp-160h]@14 + GUIWindow pWindow; // [sp+D8h] [bp-98h]@83 + size_t v120; // [sp+130h] [bp-40h]@25 + int uColor1; // [sp+144h] [bp-2Ch]@1 + int v126; // [sp+148h] [bp-28h]@25 + int uColorGreen; // [sp+14Ch] [bp-24h]@1 + int pIntervalY; // [sp+150h] [bp-20h]@14 + int pX_Numbers; // [sp+154h] [bp-1Ch]@18 + int uColorTeal; // [sp+158h] [bp-18h]@1 + int uColorWhite; // [sp+15Ch] [bp-14h]@1 + int uX; // [sp+160h] [bp-10h]@18 + unsigned int v133; // [sp+164h] [bp-Ch]@25 + int pOrder; // [sp+168h] [bp-8h]@14 + int pIntervalX; + int pCorrective; + const char *pSkillName; + + uColor1 = TargetColor(0xD1, 0xBB, 0x61); + uColorTeal = TargetColor(0, 0xF7, 0xF7); + uColorGreen = TargetColor(0, 0xFF, 0); + uColorWhite = TargetColor(0xFF, 0xFF, 0xFF); + pRenderer->BeginScene(); + pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX); + uPlayerCreationUI_SkySliderPos = (GetTickCount() % 12800) / 20; + pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos, 2, pTexture_MAKESKY); + pRenderer->DrawTextureIndexed(uPlayerCreationUI_SkySliderPos - 640, 2, pTexture_MAKESKY); + pRenderer->DrawTextureTransparent(0, 0, pTexture_MAKETOP); + + uPlayerCreationUI_SelectedCharacter = (pGUIWindow_CurrentMenu->pCurrentPosActiveItem - pGUIWindow_CurrentMenu->pStartingPosActiveItem) / 7; + switch (uPlayerCreationUI_SelectedCharacter) + { + case 0: pX = 12; break; + case 1: pX = 171; break; + case 2: pX = 329; break; + case 3: pX = 488; break; + default: + assert(false && "Invalid selected character"); + } + + pTextCenter = pFontCChar->AlignText_Center(640, pGlobalTXT_LocalizationStrings[51]); + pGUIWindow_CurrentMenu->DrawText(pFontCChar, pTextCenter + 1, 0, 0, pGlobalTXT_LocalizationStrings[51], 0, 0, 0); + pRenderer->DrawTextureTransparent(17, 35, pPlayerPortraits[pParty->pPlayers[0].uCurrentFace]); + pRenderer->DrawTextureTransparent(176, 35, pPlayerPortraits[pParty->pPlayers[1].uCurrentFace]); + pRenderer->DrawTextureTransparent(335, 35, pPlayerPortraits[pParty->pPlayers[2].uCurrentFace]); + pRenderer->DrawTextureTransparent(494, 35, pPlayerPortraits[pParty->pPlayers[3].uCurrentFace]); + pFrame = pIconsFrameTable->GetFrame(uIconID_CharacterFrame, pEventTimer->uStartTime); + + + pRenderer->DrawTextureTransparent(pX, 29, &pIcons_LOD->pTextures[pFrame->uTextureID]); + uPosActiveItem = pGUIWindow_CurrentMenu->GetControl(pGUIWindow_CurrentMenu->pCurrentPosActiveItem); + uPlayerCreationUI_ArrowAnim = 19 - (GetTickCount() % 500) / 25; + pRenderer->DrawTextureTransparent(uPosActiveItem->uZ - 4, uPosActiveItem->uY, pTextures_arrowl[uPlayerCreationUI_ArrowAnim]); + pRenderer->DrawTextureTransparent(uPosActiveItem->uX - 12, uPosActiveItem->uY, pTextures_arrowr[uPlayerCreationUI_ArrowAnim]); + + memset(pText, 0, 200); + strcpy(pText, pGlobalTXT_LocalizationStrings[205]);// "Skills" + uNumLet = strlen(pText) - 1; + pOrder = uNumLet; + if ( uNumLet >= 0 ) + { + while ( 1 ) + { + v8 = toupper((unsigned __int8)pText[uNumLet]); + v9 = pOrder; + v10 = pOrder-- - 1 < 0; + pText[v9] = v8; + if ( v10 ) + break; + uNumLet = pOrder; + } + } + + pIntervalX = 18; + pIntervalY = pFontCreate->uFontHeight - 2; + //v124 = 0; + uX = 32; + pX_Numbers = 493; + + for (int i = 0; i < 4; ++i) + { + auto player = pParty->pPlayers + i; + + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pIntervalX + 73, 100, 0, pClassNames[player->classType], 0, 0, 0); + pRenderer->DrawTextureTransparent(pIntervalX + 77, 50, pTexture_IC_KNIGHT[player->classType / 4]); + + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 != WINDOW_INPUT_NONE && pGUIWindow_CurrentMenu->ptr_1C == (void *)i ) + { + switch ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 ) + { + case WINDOW_INPUT_IN_PROGRESS://press name panel + v17 = pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, 159 * (int)pGUIWindow_CurrentMenu->ptr_1C + 18, 124, 0, (const char *)pKeyActionMap->pPressedKeysBuffer, 120, 1); + pGUIWindow_CurrentMenu->DrawFlashingInputCursor(159 * (unsigned int)pGUIWindow_CurrentMenu->ptr_1C + v17 + 20, 124, pFontCreate); + break; + case WINDOW_INPUT_CONFIRMED: // press enter + pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + v120 = strlen((const char *)pKeyActionMap->pPressedKeysBuffer); + v126 = 0; + v133 = 0; + if ( strlen((const char *)pKeyActionMap->pPressedKeysBuffer) )//edit name + { + do + { + if ( pKeyActionMap->pPressedKeysBuffer[v133] == ' ' ) + ++v126; + ++v133; + v16 = strlen((const char *)pKeyActionMap->pPressedKeysBuffer); + } + while ( v133 < v16 ); + } + if ( v120 && v126 != v120 ) + strcpy(player->pName, (const char *)pKeyActionMap->pPressedKeysBuffer); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, pIntervalX, 124, 0, player->pName, 130, 0); + *(short *)&player->field_1988[27] = 1; + break; + case WINDOW_INPUT_CANCELLED: // press escape + pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, pIntervalX, 124, 0, player->pName, 130, 0); + SetCurrentMenuID(MENU_NAMEPANELESC); + break; + } + } + else + { + pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, pIntervalX, 124, 0, player->pName, 130, 0); + } + + switch (player->GetRace()) + { + case 0: uRaceName = pGlobalTXT_LocalizationStrings[99]; break; // "Human" + case 1: uRaceName = pGlobalTXT_LocalizationStrings[103]; break; // "Dwarf" + case 2: uRaceName = pGlobalTXT_LocalizationStrings[106]; break; // "Goblin" + case 3: uRaceName = pGlobalTXT_LocalizationStrings[101]; break; // "Elf" + }; + strcpy(pTmpBuf.data(), uRaceName); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontCreate, pIntervalX + 72, pIntervalY + 12, 0, pTmpBuf.data(), 130, 0);//Race Name + + pTextCenter = pFontCreate->AlignText_Center(150, pText); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + uX - 24, 291, uColor1, pText, 0, 0, 0); // Skills + + uStatLevel = player->GetActualMight(); + sprintf(pTmpBuf.data(), "%s\r%03d%d", pGlobalTXT_LocalizationStrings[144], pX_Numbers, uStatLevel);// "Might" + pStatColor = player->GetStatColor(0); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, 169, pStatColor, pTmpBuf.data(), 0, 0, 0); + + uStatLevel = player->GetActualIntelligence(); + sprintf(pTmpBuf.data(), "%s\r%03d%d", pGlobalTXT_LocalizationStrings[116], pX_Numbers, uStatLevel);// "Intellect" + pStatColor = player->GetStatColor(1); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, pIntervalY + 169, pStatColor, pTmpBuf.data(), 0, 0, 0); + + uStatLevel = player->GetActualWillpower(); + sprintf(pTmpBuf.data(), "%s\r%03d%d", pGlobalTXT_LocalizationStrings[163], pX_Numbers, uStatLevel);// "Personality" + pStatColor = player->GetStatColor(2); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, 2 * pIntervalY + 169, pStatColor, pTmpBuf.data(), 0, 0, 0); + + uStatLevel = player->GetActualEndurance(); + sprintf(pTmpBuf.data(), "%s\r%03d%d", pGlobalTXT_LocalizationStrings[75], pX_Numbers, uStatLevel);// "Endurance" + pStatColor = player->GetStatColor(3); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, 3 * pIntervalY + 169, pStatColor, pTmpBuf.data(), 0, 0, 0); + + uStatLevel = player->GetActualAccuracy(); + sprintf(pTmpBuf.data(), "%s\r%03d%d", pGlobalTXT_LocalizationStrings[1], pX_Numbers, uStatLevel);// "Accuracy" + pStatColor = player->GetStatColor(4); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, 4 * pIntervalY + 169, pStatColor, pTmpBuf.data(), 0, 0, 0); + + uStatLevel = player->GetActualSpeed(); + sprintf(pTmpBuf.data(), "%s\r%03d%d", pGlobalTXT_LocalizationStrings[211], pX_Numbers, uStatLevel);// "Speed" + pStatColor = player->GetStatColor(5); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, 5 * pIntervalY + 169, pStatColor, pTmpBuf.data(), 0, 0, 0); + + uStatLevel = player->GetActualLuck(); + sprintf(pTmpBuf.data(), "%s\r%03d%d", pGlobalTXT_LocalizationStrings[136], pX_Numbers, uStatLevel);// "Luck" + pStatColor = player->GetStatColor(6); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX, 6 * pIntervalY + 169, pStatColor, pTmpBuf.data(), 0, 0, 0); + + + pSkillsType = player->GetSkillIdxByOrder(0); + pTextCenter = pFontCreate->AlignText_Center(150, pSkillNames[pSkillsType]); + sprintf(pTmpBuf.data(), "\t%03u%s", pTextCenter, pSkillNames[pSkillsType]); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, 311, uColorWhite, pTmpBuf.data(), 0, 0, 0); + + pSkillsType = player->GetSkillIdxByOrder(1); + pTextCenter = pFontCreate->AlignText_Center(150, pSkillNames[pSkillsType]); + sprintf(pTmpBuf.data(), "\t%03u%s", pTextCenter, pSkillNames[pSkillsType]); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, pIntervalY + 311, uColorWhite, pTmpBuf.data(), 0, 0, 0); + + pSkillsType = player->GetSkillIdxByOrder(2); + pTextCenter = pFontCreate->AlignText_Center(150, pSkillNames[pSkillsType]); + sprintf(pTmpBuf.data(), "\t%03u%s", pTextCenter, pSkillNames[pSkillsType]); + pColorText = uColorGreen; + if ( (signed int)pSkillsType >= 37 ) + pColorText = uColorTeal; + pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, 2 * pIntervalY + 311, pColorText, pTmpBuf.data(), 0, 0, 0); + + pSkillsType = player->GetSkillIdxByOrder(3); + pTextCenter = pFontCreate->AlignText_Center(150, pSkillNames[pSkillsType]); + sprintf(pTmpBuf.data(), "\t%03u%s", pTextCenter, pSkillNames[pSkillsType]); + pColorText = uColorGreen; + if ( (signed int)pSkillsType >= 37 ) + pColorText = uColorTeal; + pGUIWindow_CurrentMenu->DrawText(pFontCreate, uX - 24, 3 * pIntervalY + 311, pColorText, pTmpBuf.data(), 0, 0, 0); + + //v124 = (char *)v124 + 1; + pIntervalX += 159; + pX_Numbers -= 158; + uX += 158; + } + + strcpy(pText, pGlobalTXT_LocalizationStrings[41]);// "Class" + v51 = strlen(pText) - 1; + pOrder = v51; + if ( v51 >= 0 ) + { + while ( 1 ) + { + v52 = &pText[v51]; + v53 = toupper((unsigned __int8)pText[v51]); + v10 = pOrder-- - 1 < 0; + *v52 = v53; + if ( v10 ) + break; + v51 = pOrder; + } + } + uClassType = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].classType; + pTextCenter = pFontCreate->AlignText_Center(193, pText); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 324, 395, uColor1, pText, 0, 0, 0);//Classes + + pColorText = uColorTeal; + if ( uClassType ) + pColorText = uColorWhite; + pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[0]); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 323, 417, pColorText, pClassNames[0], 0, 0, 0); + + pColorText = uColorTeal; + if ( uClassType != PLAYER_CLASS_PALADIN ) + pColorText = uColorWhite; + pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[12]); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 323, pIntervalY + 417, pColorText, pClassNames[12], 0, 0, 0); + + pColorText = uColorTeal; + if ( uClassType != PLAYER_CLASS_DRUID ) + pColorText = uColorWhite; + pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[20]); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 323, 2 * pIntervalY + 417, pColorText, pClassNames[20], 0, 0, 0); + + pColorText = uColorTeal; + if ( uClassType != PLAYER_CLASS_CLERIC ) + pColorText = uColorWhite; + pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[24]); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 388, 417, pColorText, pClassNames[24], 0, 0, 0); + + pColorText = uColorTeal; + if ( uClassType != PLAYER_CLASS_DRUID) + pColorText = uColorWhite; + pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[28]); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 388, pIntervalY + 417, pColorText, pClassNames[28], 0, 0, 0); + + pColorText = uColorTeal; + if ( uClassType != PLAYER_CLASS_SORCERER ) + pColorText = uColorWhite; + pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[32]); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 388, 2 * pIntervalY + 417, pColorText, pClassNames[32], 0, 0, 0); + + pColorText = uColorTeal; + if ( uClassType != PLAYER_CLASS_ARCHER ) + pColorText = uColorWhite; + pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[16]); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 453, 417, pColorText, pClassNames[16], 0, 0, 0); + + pColorText = uColorTeal; + if ( uClassType != PLAYER_CLASS_MONK ) + pColorText = uColorWhite; + pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[8]); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 453, pIntervalY + 417, pColorText, pClassNames[8], 0, 0, 0); + + pColorText = uColorTeal; + if ( uClassType != PLAYER_CLASS_THEIF ) + pColorText = uColorWhite; + pTextCenter = pFontCreate->AlignText_Center(65, pClassNames[4]); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 453, 2 * pIntervalY + 417, pColorText, pClassNames[4], 0, 0, 0); + + pTextCenter = pFontCreate->AlignText_Center(236, pGlobalTXT_LocalizationStrings[20]); // "Available Skills" + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 37, 395, uColor1, pGlobalTXT_LocalizationStrings[20], 0, 0, 0); + for (uint i = 0; i < 9; ++i) + { + pSkillId = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(i + 4); + strcpy(pText, pSkillNames[pSkillId]); + pLenText = strlen(pText); + v104 = 0; + if ( (signed int)pLenText > 0 ) + { + if ( pText[v104] == 32 ) + { + pText[v104] = 0; + } + else + { + while ( pText[v104] != 32 ) + { + ++v104; + if ( v104 >= (signed int)pLenText ) + break; + } + } + } + pCorrective = -10;//-5 + if ( (signed int)pLenText < 8 )//if ( (signed int)v124 > 2 ) + pCorrective = 0; + pColorText = uColorTeal; + if ( !pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].pActiveSkills[pSkillId] ) + pColorText = uColorWhite; + pTextCenter = pFontCreate->AlignText_Center(100, pText); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, 100 * (i / 3) + pTextCenter + pCorrective + 17, pIntervalY * (i % 3) + 417, pColorText, pText, 0, 0, 0); + } + + pTextCenter = pFontCreate->AlignText_Center(0x5C, pGlobalTXT_LocalizationStrings[30]);// "Bonus" + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 533, 394, uColor1, pGlobalTXT_LocalizationStrings[30], 0, 0, 0); + pBonusNum = PlayerCreation_GetUnspentAttributePointCount(); + sprintf(pTmpBuf.data(), "%d", pBonusNum); + pTextCenter = pFontCreate->AlignText_Center(84, pTmpBuf.data()); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, pTextCenter + 530, 410, uColorWhite, pTmpBuf.data(), 0, 0, 0); + if ( GameUI_Footer_TimeLeft > GetTickCount() ) + { + pWindow.Hint = pGlobalTXT_LocalizationStrings[412];// "Create Party cannot be completed unless you have assigned all characters 2 extra skills and have spent all of your bonus points." + if ( pBonusNum < 0 ) + pWindow.Hint = pGlobalTXT_LocalizationStrings[413];// "You can't spend more than 50 points." + pWindow.uFrameWidth = 300; + pWindow.uFrameHeight = 100; + pWindow.uFrameX = 170; + pWindow.uFrameY = 140; + pWindow.uFrameZ = 469; + pWindow.uFrameW = 239; + pWindow.DrawMessageBox(0); + } + pRenderer->EndScene(); +} + +//----- (0049695A) -------------------------------------------------------- +void __cdecl PlayerCreationUI_Initialize() +{ + unsigned int v0; // ebx@5 + unsigned int v1; // eax@6 + int v2; // ecx@6 + //unsigned int v3; // eax@8 + //signed int v4; // ecx@8 + signed int uControlParam; // [sp+10h] [bp-Ch]@7 + unsigned int uControlParama; // [sp+10h] [bp-Ch]@9 + unsigned int uControlParamb; // [sp+10h] [bp-Ch]@11 + unsigned int uControlParamc; // [sp+10h] [bp-Ch]@13 + signed int uControlParamd; // [sp+10h] [bp-Ch]@15 + signed int uX; // [sp+14h] [bp-8h]@5 + unsigned int uXa; // [sp+14h] [bp-8h]@9 + unsigned int uXb; // [sp+14h] [bp-8h]@11 + unsigned int uXc; // [sp+14h] [bp-8h]@13 + signed int uXd; // [sp+14h] [bp-8h]@16 + + pMessageQueue_50CBD0->Flush(); + + pAudioPlayer->SetMusicVolume(pSoundVolumeLevels[uMusicVolimeMultiplier] * 64.0f); + ++pIcons_LOD->uTexturePacksCount; + if ( !pIcons_LOD->uNumPrevLoadedFiles ) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + pCurrentScreen = SCREEN_PARTY_CREATION; + uPlayerCreationUI_ArrowAnim = 0; + uPlayerCreationUI_SkySliderPos = 0; + uPlayerCreationUI_SelectedCharacter = 0; + v0 = LOBYTE(pFontCreate->uFontHeight) - 2; + pTexture_IC_KNIGHT[0] = pIcons_LOD->LoadTexturePtr("IC_KNIGHT", TEXTURE_16BIT_PALETTE); + pTexture_IC_KNIGHT[1] = pIcons_LOD->LoadTexturePtr("IC_THIEF", TEXTURE_16BIT_PALETTE); + pTexture_IC_KNIGHT[2] = pIcons_LOD->LoadTexturePtr("IC_MONK", TEXTURE_16BIT_PALETTE); + pTexture_IC_KNIGHT[3] = pIcons_LOD->LoadTexturePtr("IC_PALAD", TEXTURE_16BIT_PALETTE); + pTexture_IC_KNIGHT[4] = pIcons_LOD->LoadTexturePtr("IC_ARCH", TEXTURE_16BIT_PALETTE); + pTexture_IC_KNIGHT[5] = pIcons_LOD->LoadTexturePtr("IC_RANGER", TEXTURE_16BIT_PALETTE); + pTexture_IC_KNIGHT[6] = pIcons_LOD->LoadTexturePtr("IC_CLER", TEXTURE_16BIT_PALETTE); + pTexture_IC_KNIGHT[7] = pIcons_LOD->LoadTexturePtr("IC_DRUID", TEXTURE_16BIT_PALETTE); + pTexture_IC_KNIGHT[8] = pIcons_LOD->LoadTexturePtr("IC_SORC", TEXTURE_16BIT_PALETTE); + pTexture_MAKETOP = pIcons_LOD->LoadTexturePtr("MAKETOP", TEXTURE_16BIT_PALETTE); + pTexture_MAKESKY = pIcons_LOD->LoadTexturePtr("MAKESKY", TEXTURE_16BIT_PALETTE); + for(uX=0;uX < 22;++uX ) // load PlayerPortraits texture + { + sprintf(pTmpBuf.data(), "%s01", pPlayerPortraitsNames[uX]); + v1 = pIcons_LOD->LoadTexture(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); + pPlayerPortraits[uX] = &pIcons_LOD->pTextures[v1]; + + } + pTexture_PlayerFaceMask = pIcons_LOD->LoadTexturePtr("FACEMASK", TEXTURE_16BIT_PALETTE); + pTexture_buttminu = pIcons_LOD->LoadTexturePtr("buttminu", TEXTURE_16BIT_PALETTE); + pTexture_buttplus = pIcons_LOD->LoadTexturePtr("buttplus", TEXTURE_16BIT_PALETTE); + pTexture_pressrigh = pIcons_LOD->LoadTexturePtr("presrigh", TEXTURE_16BIT_PALETTE); + pTexture_presleft = pIcons_LOD->LoadTexturePtr("presleft", TEXTURE_16BIT_PALETTE); + uControlParam = 1; + do + { + sprintf(pTmpBuf.data(), "arrowl%d", uControlParam); + pTextures_arrowl[uControlParam] = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); + + sprintf(pTmpBuf.data(), "arrowr%d", uControlParam); + pTextures_arrowr[uControlParam] = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); + } + while ( ++uControlParam < 20 ); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0); + uControlParama = 0; + uXa = 8; + do + { + pGUIWindow_CurrentMenu->CreateButton(uXa, 120, 145, 25, 1, 0, UIMSG_PlayerCreationChangeName, uControlParama, 0, "", 0); + uXa += 158; + ++uControlParama; + } + while ( (signed int)uXa < 640 ); + + pCreationUI_BtnPressLeft[0] = pGUIWindow_CurrentMenu->CreateButton( 10, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev, 0, 0, "", pTexture_presleft, 0); + pCreationUI_BtnPressLeft[1] = pGUIWindow_CurrentMenu->CreateButton(169, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev, 1, 0, "", pTexture_presleft, 0); + pCreationUI_BtnPressLeft[2] = pGUIWindow_CurrentMenu->CreateButton(327, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev, 2, 0, "", pTexture_presleft, 0); + pCreationUI_BtnPressLeft[3] = pGUIWindow_CurrentMenu->CreateButton(486, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev, 3, 0, "", pTexture_presleft, 0); + pCreationUI_BtnPressRight[0] = pGUIWindow_CurrentMenu->CreateButton( 74, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext, 0, 0, "", pTexture_pressrigh, 0); + pCreationUI_BtnPressRight[1] = pGUIWindow_CurrentMenu->CreateButton(233, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext, 1, 0, "", pTexture_pressrigh, 0); + pCreationUI_BtnPressRight[2] = pGUIWindow_CurrentMenu->CreateButton(391, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext, 2, 0, "", pTexture_pressrigh, 0); + pCreationUI_BtnPressRight[3] = pGUIWindow_CurrentMenu->CreateButton(549, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext, 3, 0, "", pTexture_pressrigh, 0); + pCreationUI_BtnPressLeft2[0] = pGUIWindow_CurrentMenu->CreateButton( 10, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 0, 0, "", pTexture_presleft, 0); + pCreationUI_BtnPressLeft2[1] = pGUIWindow_CurrentMenu->CreateButton(169, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 1, 0, "", pTexture_presleft, 0); + pCreationUI_BtnPressLeft2[2] = pGUIWindow_CurrentMenu->CreateButton(327, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 2, 0, "", pTexture_presleft, 0); + pCreationUI_BtnPressLeft2[3] = pGUIWindow_CurrentMenu->CreateButton(486, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 3, 0, "", pTexture_presleft, 0); + pCreationUI_BtnPressRight2[0] = pGUIWindow_CurrentMenu->CreateButton( 74, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 0, 0, "", pTexture_pressrigh, 0); + pCreationUI_BtnPressRight2[1] = pGUIWindow_CurrentMenu->CreateButton(233, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 1, 0, "", pTexture_pressrigh, 0); + pCreationUI_BtnPressRight2[2] = pGUIWindow_CurrentMenu->CreateButton(391, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 2, 0, "", pTexture_pressrigh, 0); + pCreationUI_BtnPressRight2[3] = pGUIWindow_CurrentMenu->CreateButton(549, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 3, 0, "", pTexture_pressrigh, 0); + + uControlParamb = 0; + uXb = 8; + do + { + pGUIWindow_CurrentMenu->CreateButton(uXb, 308, 150, v0, 1, 0, UIMSG_48, uControlParamb, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(uXb, v0 + 308, 150, v0, 1, 0, UIMSG_49, uControlParamb, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(uXb, 2 * v0 + 308, 150, v0, 1, 0, UIMSG_PlayerCreationRemoveUpSkill, uControlParamb, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(uXb, 3 * v0 + 308, 150, v0, 1, 0, UIMSG_PlayerCreationRemoveDownSkill, uControlParamb, 0, "", 0); + uXb += 158; + ++uControlParamb; + } + while ( (signed int)uXb < 640 ); + + pGUIWindow_CurrentMenu->CreateButton( 5, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 0, '1', "", 0); + pGUIWindow_CurrentMenu->CreateButton(163, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 1, '2', "", 0); + pGUIWindow_CurrentMenu->CreateButton(321, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 2, '3', "", 0); + pGUIWindow_CurrentMenu->CreateButton(479, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 3, '4', "", 0); + + uXc = 23; + uControlParamc = 2; + do + { + pGUIWindow_CurrentMenu->CreateButton(uXc, 169, 120, 20, 1, 0, UIMSG_0, uControlParamc - 2, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(uXc, v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc - 1, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(uXc, 2 * v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(uXc, 3 * v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc + 1, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(uXc, 4 * v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc + 2, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(uXc, 5 * v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc + 3, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(uXc, 6 * v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc + 4, 0, "", 0); + uControlParamc += 7; + uXc += 158; + } + while ( (signed int)uControlParamc < 30 ); + pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(28, 0, 7, 40); + + pGUIWindow_CurrentMenu->CreateButton(323, 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(323, v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0xC, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(323, 2 * v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x14, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(388, 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x18, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(388, v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x1C, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(388, 2 * v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x20, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(453, 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x10, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(453, v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 8, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(453, 2 * v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 4, 0, "", 0); + + uControlParamd = 0; + do + { + uXd = -5; + if ( uControlParamd <= 3 ) + uXd = 0; + pGUIWindow_CurrentMenu->CreateButton(100 * (uControlParamd / 3) + uXd + 17, v0 * (uControlParamd % 3) + 417, 100, v0, 1, 0, UIMSG_PlayerCreationSelectActiveSkill, + uControlParamd, 0, "", 0); + ++uControlParamd; + } + while ( uControlParamd < 9 ); + + pPlayerCreationUI_BtnOK = pGUIWindow_CurrentMenu->CreateButton(580, 431, 51, 39, 1, 0, UIMSG_PlayerCreationClickOK, 0, '\r', "", pIcons_LOD->GetTexture(uTextureID_BUTTMAKE), 0); + pPlayerCreationUI_BtnReset = pGUIWindow_CurrentMenu->CreateButton(527, 431, 51, 39, 1, 0, UIMSG_PlayerCreationClickReset, 0, 'C', "", pIcons_LOD->GetTexture(uTextureID_BUTTMAKE2), 0); + pPlayerCreationUI_BtnMinus = pGUIWindow_CurrentMenu->CreateButton(523, 393, 20, 35, 1, 0, UIMSG_PlayerCreationClickMinus, 0, '-', "", pTexture_buttminu, 0); + pPlayerCreationUI_BtnPlus = pGUIWindow_CurrentMenu->CreateButton(613, 393, 20, 35, 1, 0, UIMSG_PlayerCreationClickPlus, 1, '+', "", pTexture_buttplus, 0); + + pFontCChar = LoadFont("cchar.fnt", "FONTPAL", NULL); +} +// 4E28F8: using guessed type int pCurrentScreen; + +//----- (0049750E) -------------------------------------------------------- +void DeleteCCharFont() +{ + pAllocator->FreeChunk(pFontCChar); + pFontCChar = 0; +} +//----- (00497526) -------------------------------------------------------- +bool PlayerCreationUI_Loop() +{ + //RGBTexture *pTexture; // ebx@1 + //UINT v1; // esi@1 + unsigned int v2; // ecx@3 + LONG uMouseX; // edi@6 + LONG uMouseY; // eax@6 + GUIButton *pControlsHead; // edx@6 + //unsigned int pNumMessage; // ecx@7 + int pControlParam; // esi@12 + signed int v8; // edi@30 + int v9; // edx@31 + char *v10; // ebx@37 + Player *v11; // esi@38 + //signed int uSpellBookPageCount; // ecx@40 + int v13; // eax@40 + //signed int uSkillIdx; // eax@45 + int v15; // eax@70 + signed int v16; // ecx@70 + //unsigned int v18; // [sp-4h] [bp-84h]@48 + ItemGen item; // [sp+Ch] [bp-74h]@37 + char v20[32]; // [sp+30h] [bp-50h]@29 + //char v21; // [sp+31h] [bp-4Fh]@29 + //__int16 v22; // [sp+4Dh] [bp-33h]@29 + char v23; // [sp+4Fh] [bp-31h]@29 + MSG Msg; // [sp+50h] [bp-30h]@17 + POINT v25; // [sp+6Ch] [bp-14h]@6 + bool v26; // [sp+74h] [bp-Ch]@1 + //POINT v24; // [sp+78h] [bp-8h]@6 + //Player *pPlayer; + + //pTexture = &pTexture_PCX; + v26 = 0; + pTexture_PCX.Release(); + pTexture_PCX.Load("makeme.pcx", 0); + + v2 = 6; + pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE; +//LABEL_27: + SetCurrentMenuID((MENU_STATE)v2); + while ( GetCurrentMenuID() == MENU_CREATEPARTY ) + { + uMouseX = pMouse->GetCursorPos(&v25)->x; + uMouseY = pMouse->GetCursorPos(&v25)->y; + pControlsHead = pGUIWindow_CurrentMenu->pControlsHead; + + //does nothing actually + /*if ( pControlsHead != (GUIButton *)v1 ) + { + pNumMessage = pMessageQueue_50CBD0->uNumMessages; + do + { + if ( uMouseX >= (signed int)pControlsHead->uX && uMouseX <= (signed int)pControlsHead->uZ + && uMouseY >= (signed int)pControlsHead->uY && uMouseY <= (signed int)pControlsHead->uW )//mouse movement + { + pControlParam = pControlsHead->uControlParam; + pMessageQueue_50CBD0->AddMessage((UIMessageType)pControlsHead->field_1C, pControlParam, 0); + v1 = 0; + } + pControlsHead = pControlsHead->pNext; + } + while ( pControlsHead != (GUIButton *)v1 ); + }*/ + + while ( PeekMessageA(&Msg, 0, 0, 0, PM_REMOVE) ) + { + if ( Msg.message == WM_QUIT ) + Game_DeinitializeAndTerminate(0); + TranslateMessage(&Msg); + DispatchMessageA(&Msg); + } + if ( BYTE1(dword_6BE364_game_settings_1) & 1 ) + { + WaitMessage(); + } + else + { + PlayerCreationUI_Draw(); + GUI_MainMenuMessageProc(); + pRenderer->BeginScene(); + GUI_UpdateWindows(); + pRenderer->EndScene(); + pRenderer->Present(); + if ( uGameState == GAME_FINISHED )//if click Esc in PlayerCreation Window + { + v26 = 1; + //v2 = 0; + //goto LABEL_27; + SetCurrentMenuID(MENU_MAIN); + continue; + } + if ( uGameState == GAME_STATE_STARTING_NEW_GAME )//if click OK in PlayerCreation Window + { + uGameState = GAME_STATE_PLAYING; + //v2 = 1; + //goto LABEL_27; + SetCurrentMenuID(MENU_NEWGAME); + continue; + } + } + } + pTexture_PCX.Release(); + pGUIWindow_CurrentMenu->Release(); + pIcons_LOD->_4114F2(); + + int v1 = 0; + memset(v20, 0, 32); + do + { + v8 = 0; + do + { + v9 = rand() % 32; + if ( !v20[v9] ) + break; + ++v8; + } + while ( v8 < 10 ); + if ( v8 == 10 ) + { + v9 = 0; + if ( v20[0] ) + { + do + ++v9; + while ( v20[v9] ); + } + } + pParty->field_854[v1++] = v9; + v20[v9] = 1; + } + while ( (signed int)v1 < 32 ); + //v10 = (char *)&pParty->pPlayers[0].sResMagicBase; + + item.Reset(); + //for ( pPlayer = &pParty->pPlayers[0]; pPlayer < &pParty->pPlayers[4]; pPlayer++) + for (uint i = 0; i < 4; ++i) + { + auto player = &pParty->pPlayers[i]; + //v11 = pPlayer; + if (player->classType == PLAYER_CLASS_KNIGHT) + player->sResMagicBase = 10; + //*((short *)v10 + 400) = 0; + player->pPlayerBuffs[22].uExpireTime = 0; + for (uint j = 0; j < 9; j++) + { + if (player->pActiveSkills[PLAYER_SKILL_FIRE + j]) + { + player->lastOpenedSpellbookPage = j; + break; + } + } + pItemsTable->GenerateItem(2, 40, &item); + player->AddItem2(-1, &item); + //uSkillIdx = 0; + //v24.y = 0; + + player->sHealth = player->GetMaxHealth(); + player->sMana = player->GetMaxMana(); + for (uint j = 0; j < 37; ++j) + { + if (!player->pActiveSkills[j]) + continue; + + switch (j) + { + case PLAYER_SKILL_STAFF: player->AddItem(-1, 61); break; + case PLAYER_SKILL_SWORD: player->AddItem(-1, 1); break; + case PLAYER_SKILL_DAGGER: player->AddItem(-1, 15); break; + case PLAYER_SKILL_AXE: player->AddItem(-1, 23); break; + case PLAYER_SKILL_SPEAR: player->AddItem(-1, 31); break; + case PLAYER_SKILL_BOW: player->AddItem(-1, 47); break; + case PLAYER_SKILL_MACE: player->AddItem(-1, 50); break; + case PLAYER_SKILL_BLASTER: assert(false); break; + case PLAYER_SKILL_SHIELD: player->AddItem(-1, 84); break; + case PLAYER_SKILL_LEATHER: player->AddItem(-1, 66); break; + case PLAYER_SKILL_CHAIN: player->AddItem(-1, 71); break; + case PLAYER_SKILL_PLATE: player->AddItem(-1, 76); break; + case PLAYER_SKILL_FIRE: + player->AddItem(-1, 0x191); + player->spellbook.pFireSpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_AIR: + player->AddItem(-1, 0x19C); + player->spellbook.pAirSpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_WATER: + player->AddItem(-1, 0x1A7); + player->spellbook.pWaterSpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_EARTH: + player->AddItem(-1, 0x1B2); + player->spellbook.pEarthSpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_SPIRIT: + player->AddItem(-1, 0x1BD); + player->spellbook.pSpiritSpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_MIND: + player->AddItem(-1, 0x1C8); + player->spellbook.pMindSpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_BODY: + player->AddItem(-1, 0x1D3); + player->spellbook.pBodySpellbook.bIsSpellAvailable[0] = true; + break; + case PLAYER_SKILL_LIGHT: + case PLAYER_SKILL_DARK: + case PLAYER_SKILL_DIPLOMACY: + assert(false); + break; + case PLAYER_SKILL_ITEM_ID: + case PLAYER_SKILL_REPAIR: + case PLAYER_SKILL_MEDITATION: + case PLAYER_SKILL_PERCEPTION: + case PLAYER_SKILL_TRAP_DISARM: + case PLAYER_SKILL_LEARNING: + player->AddItem(-1, 0xDC); + player->AddItem(-1, 5 * (rand() % 3 + 40)); + break; + case PLAYER_SKILL_DODGE: player->AddItem(-1, 115); break; + case PLAYER_SKILL_UNARMED: player->AddItem(-1, 110); break; + default: + break; + } + + for (uint k = 0; k < 138; k++) + { + if (player->pOwnItems[k].uItemID) + player->pOwnItems[k].SetIdentified(); + } + } + } + + pAudioPlayer->StopChannels(-1, -1); + return v26; +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/UIPopup.cpp Wed Jun 19 17:18:35 2013 +0600 @@ -0,0 +1,2193 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include <assert.h> + +#include "MM7.h" + +#include "Mouse.h" + +#include "Sprites.h" +#include "Vis.h" +#include "Game.h" +#include "GUIWindow.h" +#include "GUIFont.h" +#include "Party.h" +#include "AudioPlayer.h" +#include "LOD.h" +#include "Actor.h" +#include "Viewport.h" +#include "SpriteObject.h" +#include "ObjectList.h" +#include "Chest.h" +#include "PaletteManager.h" +#include "Time.h" +#include "texts.h" + +#include "mm7_data.h" + +static char static_sub_417BB5_out_string[1200]; // static to a file, not sub actually + +//----- (004151D9) -------------------------------------------------------- +void __fastcall DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight) + { + unsigned int v4; // ebx@1 + Texture *v5; // edi@1 + signed int uTileWidth; // ecx@1 + int v7; // eax@5 + int v8; // ecx@10 + unsigned int v9; // ebx@14 + int v10; // [sp+10h] [bp-28h]@5 + signed int uTileHeight; // [sp+18h] [bp-20h]@1 + int v12; // [sp+1Ch] [bp-1Ch]@7 + int v13; // [sp+20h] [bp-18h]@1 + int a5; // [sp+24h] [bp-14h]@5 + unsigned int a5a; // [sp+24h] [bp-14h]@11 + unsigned int a4; // [sp+28h] [bp-10h]@1 + int uNumXTiles; // [sp+2Ch] [bp-Ch]@3 + unsigned int uNumXTilesa; // [sp+2Ch] [bp-Ch]@6 + unsigned int uNumXTilesb; // [sp+2Ch] [bp-Ch]@11 + unsigned int a2a; // [sp+30h] [bp-8h]@1 + unsigned int v21; // [sp+34h] [bp-4h]@5 + unsigned int v22; // [sp+34h] [bp-4h]@11 + + v4 = uY; + a2a = uX; + a4 = uX + uWidth; + pRenderer->SetTextureClipRect(uX, v4, uX + uWidth, v4 + uHeight); + v5 = pIcons_LOD->GetTexture(uTextureID_Parchment); + uTileWidth = v5->uTextureWidth; + v13 = v5->uTextureWidth; + uTileHeight = v5->uTextureHeight; + if ( v5->uTextureWidth && v5->uTextureHeight) + { + uNumXTiles = (signed int)uWidth / uTileWidth; + if ( (signed int)uWidth % uTileWidth ) + ++uNumXTiles; + a5 = 0; + v21 = v4; + v7 = uNumXTiles + 1; + v10 = uNumXTiles + 1; + do + { + uNumXTilesa = a2a - v13; + if ( v7 > 0 ) + { + v12 = v7; + do + { + uNumXTilesa += v13; + pRenderer->DrawTextureIndexed(uNumXTilesa, v21, v5); + --v12; + } + while ( v12 ); + v7 = v10; + } + v21 += uTileHeight; + v8 = a5++; + } + while ( v8 < (signed int)uHeight / uTileHeight ); + a5a = v4 + uHeight - 32; + pRenderer->DrawTextureTransparent(a2a, v4, pIcons_LOD->GetTexture(uTextureID_5076AC)); + pRenderer->DrawTextureTransparent(a2a, a5a, pIcons_LOD->GetTexture(uTextureID_5076B4)); + pRenderer->DrawTextureTransparent(a4 - 32, v4, pIcons_LOD->GetTexture(uTextureID_5076A8)); + pRenderer->DrawTextureTransparent(a4 - 32, a5a, pIcons_LOD->GetTexture(uTextureID_5076B0)); + uNumXTilesb = a2a + 32; + v22 = v4 + uHeight - 10; + if ( (signed int)uWidth > 64 ) + { + pRenderer->SetTextureClipRect(a2a + 32, v4, a4 - 32, v4 + uHeight); + pRenderer->DrawTextureTransparent(uNumXTilesb, v4, pIcons_LOD->GetTexture(uTextureID_507698)); + pRenderer->DrawTextureTransparent(uNumXTilesb, v22, pIcons_LOD->GetTexture(uTextureID_5076A4)); + if ( (signed int)uWidth > 512 ) + { + pRenderer->DrawTextureTransparent(a2a + 544, v4, pIcons_LOD->GetTexture(uTextureID_507698)); + pRenderer->DrawTextureTransparent(a2a + 544, v22, pIcons_LOD->GetTexture(uTextureID_5076A4)); + } + } + v9 = v4 + 32; + if ( (signed int)uHeight > 64 ) + { + pRenderer->SetTextureClipRect(a2a, v9, a4, a5a); + pRenderer->DrawTextureTransparent(a2a, v9, pIcons_LOD->GetTexture(uTextureID_5076A0)); + pRenderer->DrawTextureTransparent(a4 - 10, v9, pIcons_LOD->GetTexture(uTextureID_50769C)); + } + pRenderer->ResetTextureClipRect(); + } + } + + + +//----- (0041D895) -------------------------------------------------------- +void GameUI_DrawItemInfo( struct ItemGen* inspect_item ) + { + ItemGen *v1; // esi@1 + unsigned int v2; // eax@3 + //char *v3; // edi@5 + //unsigned int v4; // eax@5 + //unsigned int v5; // esi@5 + signed int v6; // eax@5 + int v7; // edx@5 + //unsigned int v9; // eax@12 + char v10; // zf@16 + ItemGen *v11; // eax@16 + ItemGen *v12; // eax@25 + //unsigned int v13; // ecx@32 + //unsigned int v14; // eax@32 + //Render *v15; // edi@33 + const char *v16; // eax@34 + int v17; // eax@36 + int v18; // esi@37 + unsigned __int16 v19; // ax@37 + //char v20; // al@40 + char v21; // al@44 + //char v22; // al@48 + //char v23; // al@51 + int v24; // eax@52 + int v25; // eax@57 + int v26; // eax@60 + int v27; // eax@67 + const char *v28; // edi@69 + int v29; // eax@70 + char v30; // edi@78 + const char *v31; // eax@78 + int v32; // ecx@81 + unsigned int v33; // eax@81 + int v34; // esi@81 + const char *v35; // eax@85 + const char *v36; // eax@87 + unsigned int v37; // eax@109 + unsigned int v38; // eax@109 + int v39; // eax@113 + GUIFont *v40; // edx@113 + signed int v41; // [sp-20h] [bp-298h]@113 + int v42; // [sp-1Ch] [bp-294h]@113 + //char *v43; // [sp-18h] [bp-290h]@46 + unsigned int v44; // [sp-18h] [bp-290h]@113 + //int v45; // [sp-14h] [bp-28Ch]@46 + const char *v46; // [sp-14h] [bp-28Ch]@58 + char *v47; // [sp-14h] [bp-28Ch]@110 + //char *v48; // [sp-10h] [bp-288h]@46 + const char *v49; // [sp-10h] [bp-288h]@56 + char *v50; // [sp-10h] [bp-288h]@58 + int v51; // [sp-10h] [bp-288h]@110 + const char *v52; // [sp-Ch] [bp-284h]@36 + //int v53; // [sp-Ch] [bp-284h]@46 + char *v54; // [sp-Ch] [bp-284h]@56 + int v55; // [sp-Ch] [bp-284h]@58 + int v56; // [sp-Ch] [bp-284h]@110 + unsigned int v57; // [sp-8h] [bp-280h]@36 + //int v58; // [sp-8h] [bp-280h]@46 + int v59; // [sp-8h] [bp-280h]@56 + int v60; // [sp-8h] [bp-280h]@58 + unsigned int v61; // [sp-8h] [bp-280h]@110 + char out_text[300]; // [sp+8h] [bp-270h]@40 + //char Dest[100]; // [sp+6Ch] [bp-20Ch]@40 + //char v64[100]; // [sp+D0h] [bp-1A8h]@40 + char v65[120]; // [sp+134h] [bp-144h]@92 + char Source[40]; // [sp+1ACh] [bp-CCh]@49 + stru351_summoned_item v67; + //int v67; // [sp+1D4h] [bp-A4h]@91 + //int v68; // [sp+1D8h] [bp-A0h]@106 + //int v69; // [sp+1DCh] [bp-9Ch]@101 + //int v70; // [sp+1E0h] [bp-98h]@97 + //int v71; // [sp+1E8h] [bp-90h]@93 + //int v72; // [sp+1ECh] [bp-8Ch]@91 + int var88; // [sp+1F0h] [bp-88h]@1 + Texture *v73; // [sp+1F4h] [bp-84h]@5 + //unsigned int v75; // [sp+1F8h] [bp-80h]@5 + //char *v76; // [sp+1FCh] [bp-7Ch]@5 + int v77; // [sp+200h] [bp-78h]@12 + int v78; // [sp+204h] [bp-74h]@5 + GUIWindow wHintWindow; // [sp+208h] [bp-70h]@2 + POINT a2; // [sp+25Ch] [bp-1Ch]@2 + int v81; // [sp+264h] [bp-14h]@5 + // GUIFont *pFontComic; // [sp+268h] [bp-10h]@1 + PlayerSpeech v83; // [sp+26Ch] [bp-Ch]@18 + char* v84; + int v85; + char *Str; // [sp+270h] [bp-8h]@65 + + v1 = inspect_item; + var88 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + if (!inspect_item->uItemID) + return; + + wHintWindow.Hint = 0; + wHintWindow.uFrameWidth = 384; + wHintWindow.uFrameHeight = 180; + wHintWindow.uFrameY = 40; + if ( pMouse->GetCursorPos(&a2)->x <= 320 ) + v2 = pMouse->GetCursorPos(&a2)->x + 30; + else + v2 = pMouse->GetCursorPos(&a2)->x - wHintWindow.uFrameWidth - 30; + wHintWindow.uFrameX = v2; + auto item_desc = &pItemsTable->pItems[inspect_item->uItemID]; + //v3 = (char *)&pItemsTable->pItems[_this->uItemID].pIconName; + //v76 = v3; + //v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[_this->uItemID].pIconName, TEXTURE_16BIT_PALETTE); + //v5 = v4; + //v4 *= 72; + //v75 = v4; + //v73 = &pIcons_LOD->pTextures[v4]; + v73 = pIcons_LOD->LoadTexturePtr(item_desc->pIconName, TEXTURE_16BIT_PALETTE); + v6 = 100 - v73->uTextureWidth; + v7 = v73->uTextureHeight; + v78 = v6; + v81 = 144 - v7; + if ( v6 > 0 ) + v78 = v6 >> 1; + if ( v81 <= 0 ) + v81 = 0; + else + v81 >>= 1; + if ( !item_desc->uItemID_Rep_St ) + inspect_item->SetIdentified(); + //v9 = v8->uAttributes; + v77 = 0; + //a2.y = v8->uAttributes & 2; + if (pItemsTable->pItems[inspect_item->uItemID].uEquipType == EQUIP_GOLD) + v77 = inspect_item->uSpecEnchantmentType; + if ( uActiveCharacter ) + { + //try to identify + if (!inspect_item->Identified()) + { + + v11 = inspect_item; + if ( pPlayers[uActiveCharacter]->CanIdentify(inspect_item) == 1 ) + inspect_item->SetIdentified(); + v83 = SPEECH_9; + if ( !inspect_item->Identified() ) + { + ShowStatusBarString(pGlobalTXT_LocalizationStrings[446], 2u);//"Identify Failed" + } + else + { + v83 = SPEECH_8; + if ( inspect_item->GetValue() < 100 * (pPlayers[uActiveCharacter]->uLevel + 5) ) + v83 = SPEECH_7; + } + if ( dword_4E455C ) + { + pPlayers[uActiveCharacter]->PlaySound((PlayerSpeech)(int)v83, 0); + dword_4E455C = 0; + } + } + inspect_item->UpdateTempBonus(pParty->uTimePlayed); + if (inspect_item->Broken()) + { + if ( pPlayers[uActiveCharacter]->CanRepair(inspect_item) == 1 ) + inspect_item->uAttributes = inspect_item->uAttributes & 0xFFFFFFFD | 1; + v83 = SPEECH_11; + if ( !inspect_item->Broken() ) + v83 = SPEECH_10; + else + ShowStatusBarString(pGlobalTXT_LocalizationStrings[448], 2u);//"Repair Failed" + if ( dword_4E455C ) + { + pPlayers[uActiveCharacter]->PlaySound(v83, 0); + dword_4E455C = 0; + } + } + } + //v13 = _this->uAttributes; + //v14 = _this->Identified(); + //a2.y = inspect_item->Identified(); + if (inspect_item->Broken()) + { + wHintWindow.DrawMessageBox(0); + //v15 = &; + pRenderer->SetTextureClipRect(wHintWindow.uFrameX + 12, wHintWindow.uFrameY + 12, + wHintWindow.uFrameX + wHintWindow.uFrameWidth - 12, + wHintWindow.uFrameY + wHintWindow.uFrameHeight - 12); + wHintWindow.uFrameWidth -= 24; + wHintWindow.uFrameHeight -= 12; + wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1; + wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1; + pRenderer->DrawTransparentRedShade(wHintWindow.uFrameX + v78, v81 + wHintWindow.uFrameY + 30, v73); + if ( inspect_item->Identified()) + v16 = inspect_item->GetIdentifiedName(); + else + v16 = item_desc->pUnidentifiedName; + wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, v16, 3u); + v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[32], &wHintWindow, 0, 0); //"Broken Item" + v18 = v17 >> 1; + v19 = TargetColor(0xFFu, 0x19u, 0x19u); + wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[32], 3); //"Broken Item" + pRenderer->ResetTextureClipRect(); + if ( !areWeLoadingTexture ) + { + v73->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return; + } + if (!inspect_item->Identified()) + { + wHintWindow.DrawMessageBox(0); + pRenderer->SetTextureClipRect(wHintWindow.uFrameX + 12, wHintWindow.uFrameY + 12, + wHintWindow.uFrameX + wHintWindow.uFrameWidth - 12, + wHintWindow.uFrameY + wHintWindow.uFrameHeight - 12); + wHintWindow.uFrameWidth -= 24; + wHintWindow.uFrameHeight -= 12; + wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1; + wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1; + pRenderer->DrawTextureTransparent(wHintWindow.uFrameX + v78, v81 + wHintWindow.uFrameY + 30, v73); + wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, item_desc->pUnidentifiedName, 3u); + v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[232], &wHintWindow, 0, 0); ///"Not Identified" + v18 = v17 >> 1; + v19 = TargetColor(0xFFu, 0x19u, 0x19u); + wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[232], 3); + pRenderer->ResetTextureClipRect(); + if ( !areWeLoadingTexture ) + { + v73->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return; + } + + sprintfex(out_text, pGlobalTXT_LocalizationStrings[463], item_desc->pUnidentifiedName); //"Type: %s" + out_text[100] = 0; + out_text[200] = 0; + //v20 = item_desc->uEquipType; + switch (item_desc->uEquipType) + { + case EQUIP_OFF_HAND: + case EQUIP_MAIN_HAND: + sprintfex(out_text + 100, "%s: +%d %s: %dd%d", pGlobalTXT_LocalizationStrings[LOCSTR_ATTACK], + (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll); //"Damage" + if (item_desc->uDamageMod) + { + char mod[16]; + sprintf(mod, "+%d", (int)item_desc->uDamageMod); + strcat(out_text + 100, mod); + } + break; + + case EQUIP_BOW: + sprintfex(out_text + 100, "%s: +%d %s: %dd%d", pGlobalTXT_LocalizationStrings[203], //"Shoot" + (int)item_desc->uDamageMod, pGlobalTXT_LocalizationStrings[53], //"Damage" + (int)item_desc->uDamageDice, (int)item_desc->uDamageRoll); + if (item_desc->uDamageMod) + { + char mod[16]; + sprintf(mod, "+%d", (int)item_desc->uDamageMod); + strcat(out_text + 100, mod); + } + break; + + case EQUIP_ARMOUR: + case EQUIP_SHIELD: + case EQUIP_HELMET: + case EQUIP_BELT: + case EQUIP_CLOAK: + case EQUIP_GAUNTLETS: + case EQUIP_BOOTS: + case EQUIP_RING: + case EQUIP_AMULET: + if (item_desc->uDamageDice) //"Armor" + sprintfex(out_text + 100, "%s: +%d", pGlobalTXT_LocalizationStrings[11], item_desc->uDamageDice + item_desc->uDamageMod); + break; + + } + + if ( !v77 ) + { + if (item_desc->uEquipType ==EQUIP_POTION) //this is CORRECT! do not move to switch! + { + if ( inspect_item->uEnchantmentType ) + sprintf(out_text + 200, "%s: %d",pGlobalTXT_LocalizationStrings[449] , inspect_item->uEnchantmentType); //"Power" + } + else if (item_desc->uEquipType == EQUIP_REAGENT) + { + sprintf(out_text + 200, "%s: %d", pGlobalTXT_LocalizationStrings[449], pItemsTable->pItems[inspect_item->uItemID].uDamageDice); //"Power" + } + + else if ( inspect_item->uEnchantmentType ) + { + sprintf(out_text + 200, "%s: %s +%d", pGlobalTXT_LocalizationStrings[210], + pItemsTable->pEnchantments[inspect_item->uEnchantmentType-1].pBonusStat, inspect_item->_bonus_strength); //"Special" + } + else if ( inspect_item->uSpecEnchantmentType ) + { + sprintf(out_text + 200, "%s: %s", pGlobalTXT_LocalizationStrings[210], + pItemsTable->pSpecialEnchantments[inspect_item->uSpecEnchantmentType-1].pBonusStatement, inspect_item->_bonus_strength); + } + + else if ( inspect_item->uNumCharges ) + { + sprintf(out_text + 200, "%s: %lu", pGlobalTXT_LocalizationStrings[464], inspect_item->uNumCharges); //"Charges" + + } + } + wHintWindow.uFrameWidth -= 12; + v85 = 3; + wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1; + wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1; + Str = (char *)(3 * (LOBYTE(pFontArrus->uFontHeight) + 8)); + v84 = &out_text[0]; + do + { + if ( *v84 ) + { + v27 = pFontComic->CalcTextHeight(v84, &wHintWindow, 100, 0); + Str += v27 + 3; + } + v84 += 100; + --v85; + } + while ( v85 ); + v28 = item_desc->pDescription; + if ( *v28 ) + { + v29 = pFontSmallnum->CalcTextHeight(v28, &wHintWindow, 100, 0); + Str += v29; + } + wHintWindow.uFrameHeight = v73->uTextureHeight + v81 + 54; + if ( (signed int)Str > (signed int)wHintWindow.uFrameHeight ) + wHintWindow.uFrameHeight = (unsigned int)Str; + if ( inspect_item->uAttributes & 8 && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) ) + wHintWindow.uFrameHeight += LOBYTE(pFontComic->uFontHeight); + v85 = 0; + if ( pFontArrus->uFontHeight ) + { + wHintWindow.uFrameWidth -= 24; + v30 = pFontArrus->uFontHeight; + v31 = inspect_item->GetIdentifiedName(); + if ( pFontArrus->CalcTextHeight(v31, &wHintWindow, 0, 0) / (signed int)v30 ) + v85 = v30; + wHintWindow.uFrameWidth += 24; + } + wHintWindow.uFrameWidth += 12; + wHintWindow.uFrameHeight += (unsigned int)v85; + wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1; + wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1; + wHintWindow.DrawMessageBox(0); + //v15 = pRenderer; + pRenderer->SetTextureClipRect(wHintWindow.uFrameX + 12, wHintWindow.uFrameY + 12, + wHintWindow.uFrameX + wHintWindow.uFrameWidth - 12, wHintWindow.uFrameY + wHintWindow.uFrameHeight - 12); + wHintWindow.uFrameWidth -= 12; + v32 = v73->uTextureHeight; + v33 = wHintWindow.uFrameHeight; + wHintWindow.uFrameHeight -= 12; + wHintWindow.uFrameZ = wHintWindow.uFrameX + wHintWindow.uFrameWidth - 1; + wHintWindow.uFrameW = wHintWindow.uFrameY + wHintWindow.uFrameHeight - 1; + pRenderer->DrawTextureTransparent( + wHintWindow.uFrameX + v78, + wHintWindow.uFrameY + (signed int)(v33 - v32) / 2, + v73); + + v34 = (int)(v85 + 35); + v85 = 3; + Str = out_text; + do + { + if ( *Str ) + { + wHintWindow.DrawText(pFontComic, 100, v34, 0, Str, 0, 0, 0); + v34 += pFontComic->CalcTextHeight(Str, &wHintWindow, 100, 0) + 3; + } + Str += 100; + --v85; + } + while (v85 ); + v35 = item_desc->pDescription; + if ( *v35 ) + wHintWindow.DrawText(pFontSmallnum, 100, v34, 0, v35, 0, 0, 0); + wHintWindow.uFrameX += 12; + wHintWindow.uFrameWidth -= 24; + v36 = inspect_item->GetIdentifiedName(); + wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, v36, 3u); + wHintWindow.uFrameWidth += 24; + wHintWindow.uFrameX -= 12; + if ( v77 ) + { + sprintf(pTmpBuf.data(), "%s: %lu", pGlobalTXT_LocalizationStrings[465], v77);//"Value" + v40 = pFontComic; + v61 = 0; + v56 = 0; + v51 = 0; + v47 = pTmpBuf.data(); + v44 = 0; + v42 = wHintWindow.uFrameHeight - LOBYTE(pFontComic->uFontHeight); + v41 = 100; + } + else + { + if ( (inspect_item->uAttributes & 8) && (inspect_item->uSpecEnchantmentType || inspect_item->uEnchantmentType) ) + { + sub_493F79(&v67, inspect_item->uExpireTime - pParty->uTimePlayed); + strcpy(pTmpBuf.data(), "Duration:"); + Str = (char *)(v67.field_18_expire_year - game_starting_year); + if (v67.field_18_expire_year != 1168 ) + { + sprintf(v65, " %d:yr", v67.field_18_expire_year - game_starting_year); + strcat(pTmpBuf.data(), v65); + } + if ( (((v67.field_14_exprie_month || Str) && + ((sprintf(v65, " %d:mo", v67.field_14_exprie_month), strcat(pTmpBuf.data(), v65), v67.field_14_exprie_month) || Str) + || v67.field_C_expire_day) + && ((sprintf(v65, " %d:dy", v67.field_C_expire_day), strcat(pTmpBuf.data(), v65), v67.field_14_exprie_month) || Str || + v67.field_C_expire_day) + || v67.field_8_expire_hour) + && ((sprintf(v65, " %d:hr", v67.field_8_expire_hour), strcat(pTmpBuf.data(), v65), v67.field_14_exprie_month) || Str || + v67.field_C_expire_day || v67.field_8_expire_hour) + || v67.field_4_expire_minute ) + { + sprintf(v65, " %d:mn", v67.field_4_expire_minute); + strcat(pTmpBuf.data(), v65); + } + wHintWindow.DrawText(pFontComic, 100, wHintWindow.uFrameHeight - 2 * LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf.data(), 0, 0, 0); + } + v37 = inspect_item->GetValue(); + sprintf(pTmpBuf.data(), "%s: %lu", pGlobalTXT_LocalizationStrings[465], v37); + wHintWindow.DrawText(pFontComic, 100, wHintWindow.uFrameHeight - LOBYTE(pFontComic->uFontHeight), 0, pTmpBuf.data(), 0, 0, 0); + v38 = inspect_item->uAttributes; + if ( BYTE1(v38) & 1 ) + { + v61 = 0; + v56 = 0; + v51 = 0; + v47 = pGlobalTXT_LocalizationStrings[187]; //"Stolen" + } + else + { + if ( !(BYTE1(v38) & 2) ) + { + pRenderer->ResetTextureClipRect(); + if ( !areWeLoadingTexture ) + { + v73->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return; + } + v61 = 0; + v56 = 0; + v51 = 0; + v47 = pGlobalTXT_LocalizationStrings[651]; //"Hardened" + } + LOWORD(v38) = LOWORD(pRenderer->uTargetRMask); + v44 = v38; + v42 = wHintWindow.uFrameHeight - LOBYTE(pFontComic->uFontHeight); + v39 = pFontComic->GetLineWidth(pTmpBuf.data()); + v40 = pFontComic; + v41 = v39 + 132; + } + wHintWindow.DrawText(v40, v41, v42, v44, v47, v51, v56, v61); + pRenderer->ResetTextureClipRect(); + if ( !areWeLoadingTexture ) + { + v73->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + return; + } +// 4E455C: using guessed type int dword_4E455C; +// 506128: using guessed type int areWeLoadingTexture; + + + +//----- (0041E360) -------------------------------------------------------- +void MonsterPopup_Draw(unsigned int uActorID, GUIWindow *edx0) +{ + unsigned int v2; // esi@1 + Actor *v3; // esi@3 + int v4; // eax@3 + //unsigned int v5; // ecx@3 + NPCData *v6; // eax@3 + unsigned __int16 v7; // cx@3 + int v8; // eax@4 + unsigned __int16 v9; // dx@4 + SpriteFrame *v10; // edi@17 + LODSprite *v11; // esi@17 + unsigned int v12; // ecx@17 + Sprite *v13; // edi@18 + //int v14; // ecx@18 + //int v15; // edx@18 + //int v16; // edx@18 + //int v17; // eax@18 + unsigned int v18; // ecx@19 + unsigned int v19; // eax@21 + char *v20; // esi@28 + int v21; // edx@29 + unsigned __int16 *v22; // ecx@29 + int v23; // eax@29 + int v24; // eax@32 + int v25; // esi@32 + char *v26; // edx@34 + unsigned __int8 v27; // sf@36 + unsigned __int8 v28; // of@36 + //int v29; // esi@40 + //unsigned __int16 *v30; // ecx@40 + //int v31; // eax@40 + //int v32; // esi@43 + //unsigned __int16 v33; // ax@45 + //int v34; // edx@45 + //int v35; // eax@45 + int v36; // eax@49 + //char *v37; // eax@52 + int v38; // eax@55 + unsigned __int16 v39; // ax@59 + SpellBuff *v40; // eax@60 + int v41; // edi@61 + unsigned int v42; // eax@61 + int v43; // eax@62 + int v44; // eax@63 + signed int v45; // edi@65 + unsigned __int16 v46; // ax@73 + Player *v47; // ecx@77 + //unsigned int v48; // eax@85 + GUIFont *v49; // edi@90 + int v50; // edi@90 + SpellBuff *v51; // eax@91 + char *v52; // ecx@98 + char *v53; // ecx@101 + char *v54; // ST0C_4@118 + unsigned int v55; // eax@118 + GUIFont *v56; // edi@124 + unsigned __int8 v57; // al@128 + int v58; // eax@132 + Actor *v59; // ecx@133 + unsigned __int8 v60; // dl@138 + char *v62; // eax@147 + int v63; // eax@152 + //char *result; // eax@152 + int v65; // eax@155 + const char *v66; // [sp-10h] [bp-1FCh]@121 + const char *v67; // [sp-10h] [bp-1FCh]@125 + const char *v68; // [sp-10h] [bp-1FCh]@142 + int v69; // [sp-Ch] [bp-1F8h]@121 + char *v70; // [sp-Ch] [bp-1F8h]@125 + char *v71; // [sp-Ch] [bp-1F8h]@142 + char *v72; // [sp-8h] [bp-1F4h]@54 + int v73; // [sp-8h] [bp-1F4h]@79 + int v74; // [sp-8h] [bp-1F4h]@121 + int v75; // [sp-8h] [bp-1F4h]@125 + int v76; // [sp-8h] [bp-1F4h]@142 + size_t v77; // [sp-4h] [bp-1F0h]@54 + unsigned int v78; // [sp-4h] [bp-1F0h]@121 + unsigned int v79; // [sp-4h] [bp-1F0h]@125 + char *v80; // [sp-4h] [bp-1F0h]@142 + char *v81; // [sp-4h] [bp-1F0h]@148 + DDBLTFX Dst; // [sp+Ch] [bp-1E0h]@18 + DDSURFACEDESC2 pDesc; // [sp+70h] [bp-17Ch]@18 + RECT v84; // [sp+ECh] [bp-100h]@26 + char *v85[10]; // [sp+FCh] [bp-F0h]@145 + char *v95[11]; // [sp+124h] [bp-C8h]@127 + RenderBillboardTransform_local0 v106; // [sp+150h] [bp-9Ch]@3 + unsigned int v107; // [sp+1A0h] [bp-4Ch]@18 + unsigned __int16 *v108; // [sp+1A4h] [bp-48h]@34 + unsigned int v109; // [sp+1A8h] [bp-44h]@32 + LPVOID v110; // [sp+1ACh] [bp-40h]@28 + unsigned int v111; // [sp+1B0h] [bp-3Ch]@29 + int v112; // [sp+1B4h] [bp-38h]@3 + int v222; // [sp+1B8h] [bp-34h]@18 + unsigned __int8 v114; // [sp+1BFh] [bp-2Dh]@133 + int v115; // [sp+1C0h] [bp-2Ch]@3 + unsigned int v116; // [sp+1C4h] [bp-28h]@18 + int i; // [sp+1C8h] [bp-24h]@18 + int a2; // [sp+1CCh] [bp-20h]@28 + int v119; // [sp+1D0h] [bp-1Ch]@18 + SpellBuff *v120; // [sp+1D4h] [bp-18h]@18 + Actor *v121; // [sp+1D8h] [bp-14h]@3 + int a5; // [sp+1DCh] [bp-10h]@3 + GUIWindow *a1; // [sp+1E0h] [bp-Ch]@1 + int v124; // [sp+1E4h] [bp-8h]@18 + int a4; // [sp+1E8h] [bp-4h]@18 + + a1 = edx0; + v2 = uActorID; + + static Actor pMonsterInfoUI_Doll; + /*if ( !(bMonsterInfoUI_bDollInitialized & 1) ) + { + bMonsterInfoUI_bDollInitialized |= 1u; + Actor::Actor(&pMonsterInfoUI_Doll); + atexit(nullsub_3); + }*/ + v106.uParentBillboardID = -1; + v3 = &pActors[v2]; + v121 = v3; + v4 = TargetColor(0xE1u, 255, 0x9Bu); + //v5 = v3->sNPC_ID; + a5 = v4; + v6 = GetNPCData(v3->sNPC_ID); + v7 = v3->pMonsterInfo.uID; + //v112 = (char **)v6; + v115 = monster_popup_y_offsets[((signed __int16)v7 - 1) / 3] - 40; + if ( v7 == pMonsterInfoUI_Doll.pMonsterInfo.uID ) + { + v9 = pMonsterInfoUI_Doll.uCurrentActionLength; + } + else + { + memcpy(&pMonsterInfoUI_Doll, v3, sizeof(pMonsterInfoUI_Doll)); + pMonsterInfoUI_Doll.uCurrentActionAnimation = ANIM_Bored; + pMonsterInfoUI_Doll.uCurrentActionTime = 0; + v8 = rand(); + v3 = v121; + v9 = v8 % 256 + 128; + pMonsterInfoUI_Doll.uCurrentActionLength = v8 % 256 + 128; + } + + if ( (signed int)pMonsterInfoUI_Doll.uCurrentActionTime > (signed __int16)v9 ) + { + pMonsterInfoUI_Doll.uCurrentActionTime = 0; + if ( pMonsterInfoUI_Doll.uCurrentActionAnimation == ANIM_Bored || pMonsterInfoUI_Doll.uCurrentActionAnimation == ANIM_AtkMelee) + { + pMonsterInfoUI_Doll.uCurrentActionAnimation = ANIM_Standing; + pMonsterInfoUI_Doll.uCurrentActionLength = rand() % 128 + 128; + } + else + { + //rand(); + pMonsterInfoUI_Doll.uCurrentActionAnimation = ANIM_Bored; + if ( (pMonsterInfoUI_Doll.pMonsterInfo.uID < 115 || pMonsterInfoUI_Doll.pMonsterInfo.uID > 186) && + (pMonsterInfoUI_Doll.pMonsterInfo.uID < 232 || pMonsterInfoUI_Doll.pMonsterInfo.uID > 249) && rand() % 30 < 100 ) + pMonsterInfoUI_Doll.uCurrentActionAnimation = ANIM_AtkMelee; + pMonsterInfoUI_Doll.uCurrentActionLength = 8 * pSpriteFrameTable->pSpriteSFrames[v3->pSpriteIDs[(signed __int16)pMonsterInfoUI_Doll.uCurrentActionAnimation]].uAnimLength; + } + } + v10 = pSpriteFrameTable->GetFrame( v3->pSpriteIDs[pMonsterInfoUI_Doll.uCurrentActionAnimation], pMonsterInfoUI_Doll.uCurrentActionTime); + v11 = &pSprites_LOD->pSpriteHeaders[v10->pHwSpriteIDs[0]];//40 * v10->pHwSpriteIDs[0] + 7218180; + v106.pTarget = pRenderer->pTargetSurface; + v106.pTargetZ = pRenderer->pActiveZBuffer; + v106.uTargetPitch = pRenderer->uTargetSurfacePitch; + v12 = a1->uFrameY + 52; + v106.uViewportX = a1->uFrameX + 13; + v106.uViewportY = v12; + v106.uViewportW = v12 + 128; + v106.uViewportZ = v106.uViewportX + 128; + v106.uScreenSpaceX = (signed int)(v106.uViewportX + 128 + v106.uViewportX) / 2; + v106._screenspace_x_scaler_packedfloat = 65536; + v106._screenspace_y_scaler_packedfloat = 65536; + v106.uScreenSpaceY = v115 + v12 + v11->uHeight; + v106.pPalette = PaletteManager::Get_Dark_or_Red_LUT(v10->uPaletteIndex, 0, 1); + v106.sZValue = 0; + v106.uFlags = 0; + pRenderer->SetRasterClipRect(0, 0, 0x27Fu, 0x1DFu); + pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportY - 1, a5); + pRenderer->RasterLine2D( v106.uViewportX + 129, v106.uViewportY - 1, v106.uViewportX + 129, v106.uViewportW + 1, a5); + pRenderer->RasterLine2D(v106.uViewportX + 129, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportW + 1, a5); + pRenderer->RasterLine2D(v106.uViewportX - 1, v106.uViewportW + 1, v106.uViewportX - 1, v106.uViewportY - 1, a5); + if ( pRenderer->pRenderD3D ) + { + v13 = &pSprites_LOD->pHardwareSprites[v10->pHwSpriteIDs[0]]; + v106.uScreenSpaceY = v115 + v106.uViewportY + v13->uBufferHeight; + //v222 = (IDirectDrawSurface *)v13->pTextureSurface; + memset(&Dst, 0, 0x64u); + Dst.dwSize = 100; + Dst.dwFillColor = 0; + memset(&pDesc, 0, 0x7Cu); + pDesc.dwSize = 124; + v13->pTextureSurface->GetSurfaceDesc(&pDesc); + //v14 = v13->uBufferHeight; + //v120 = (SpellBuff *)v13->uBufferWidth; + v107 = 0; + //v15 = v13->uAreaX; + //v119 = v13->uBufferWidth / 2; + i = 0; + //a4 = v106.uScreenSpaceX + v15 - v13->uBufferWidth / 2; + int dst_x = v106.uScreenSpaceX + v13->uAreaX - v13->uBufferWidth / 2; + //v115 = v13->uAreaY; + //v16 = v13->uAreaWidth + v13->uBufferWidth / 2 + v13->uAreaX - v13->uBufferWidth; + //v124 = v106.uScreenSpaceY + v115 - v14; + int dst_y = v106.uScreenSpaceY + v13->uAreaY - v13->uBufferHeight; + //v17 = v13->uAreaHeight + v13->uAreaY - v14; + //v116 = v106.uScreenSpaceX + v16; + uint dst_z = v106.uScreenSpaceX + v13->uAreaX + v13->uAreaWidth + v13->uBufferWidth / 2 - v13->uBufferWidth; + //v119 = v106.uScreenSpaceY + v17; + uint dst_w = v106.uScreenSpaceY + v13->uAreaY + v13->uAreaHeight - v13->uBufferHeight; + if (dst_x < v106.uViewportX) + { + v18 = v106.uViewportX - dst_x; + dst_x = v106.uViewportX; + v107 = v18; + } + if (dst_y < v106.uViewportY) + { + v19 = v106.uViewportY - dst_y; + dst_y = v106.uViewportY; + i = v19; + } + if (dst_z > v106.uViewportZ) + dst_z = v106.uViewportZ; + if (dst_w > v106.uViewportW) + dst_w = v106.uViewportW; + pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, pRenderer->uTargetBMask | pRenderer->uTargetGMask); + pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, pRenderer->uTargetBMask | pRenderer->uTargetGMask); + v84.left = v106.uViewportX; + v84.top = v106.uViewportY; + v84.right = v106.uViewportZ; + v84.bottom = v106.uViewportW; + ErrD3D(pRenderer->pBackBuffer4->Blt(&v84, 0, 0, 16778240u, &Dst)); + if ( pRenderer->uTargetGBits == 5 ) + { + __debugbreak(); // no monster popup for r5g5b5 yet + memset(&pDesc, 0, 0x7Cu); + pDesc.dwSize = 124; + if ( pRenderer->LockSurface_DDraw4(v13->pTextureSurface, &pDesc, DDLOCK_WAIT)) + { + v20 = (char *)dst_y; + v110 = pDesc.lpSurface; + a2 = dst_y; + if (dst_y < dst_w) + { + //v111 = 2 * pRenderer->uTargetSurfacePitch; + v21 = dst_x; + v22 = &pRenderer->pTargetSurface[dst_y * pRenderer->uTargetSurfacePitch + dst_x]; + auto _v22_2 = v22; + v23 = i - dst_y; + //v120 = (SpellBuff *)&pRenderer->pTargetSurface[(int)&a4[v124 * pRenderer->uTargetSurfacePitch]]; + v115 = i - dst_y; + while ( 1 ) + { + dst_y = v21; + if ( v21 < dst_z ) + { + v24 = (int)&v20[v23]; + v25 = v107 - v21; + v109 = v24; + for ( i = v107 - v21; ; v25 = i ) + { + v108 = (unsigned __int16 *)((pDesc.lPitch >> 1) * pDesc.dwHeight * v109 / v13->uAreaHeight); + v26 = (char *)v108 + pDesc.dwWidth * (v25 + dst_y++) / v13->uAreaWidth; + *v22 = *((short *)v110 + (int)v26); + ++v22; + if ( dst_y >= dst_z ) + break; + } + v23 = v115; + } + v22 = (unsigned __int16 *)((char *)_v22_2 + 2 * pRenderer->uTargetSurfacePitch); + _v22_2 = v22; + v20 = (char *)(a2 + 1); + v28 = __OFSUB__(a2 + 1, dst_w); + v27 = (signed int)(a2++ + 1 - dst_w) < 0; + //a2 = (Player *)((char *)a2 + 1); + //v120 = (SpellBuff *)((char *)v120 + v111); + if ( !(v27 ^ v28) ) + break; + v21 = dst_x; + } + } + v13->pTextureSurface->Unlock(0); + } + } + else + { + memset(&pDesc, 0, 0x7Cu); + pDesc.dwSize = 124; + if ( pRenderer->LockSurface_DDraw4(v13->pTextureSurface, &pDesc, DDLOCK_WAIT) ) + { + auto src = (unsigned __int16 *)pDesc.lpSurface; + + uint num_top_scanlines_above_frame_y = i - dst_y; + for (uint y = dst_y; y < dst_w; ++y) + { + auto dst = &pRenderer->pTargetSurface[y * pRenderer->uTargetSurfacePitch + dst_x]; + + uint src_y = num_top_scanlines_above_frame_y + y; + for (uint x = dst_x; x < dst_z; ++x) + { + uint src_x = v107 - dst_x + x; // num scanlines left to frame_x + current x + + uint idx = pDesc.dwHeight * src_y / v13->uAreaHeight * (pDesc.lPitch / sizeof(short)) + + pDesc.dwWidth * src_x / v13->uAreaWidth; + uint b = src[idx] & 0x1F; + *dst++ = b | 2 * (src[idx] & 0xFFE0); + } + } + v13->pTextureSurface->Unlock(0); + } + } + } + else + { + pRenderer->FillRectFast(v106.uViewportX, v106.uViewportY, v106.uViewportZ - v106.uViewportX, v106.uViewportW - v106.uViewportY, 0); + v36 = v10->pHwSpriteIDs[0]; + if ( v36 >= 0 ) + pSprites_LOD->pSpriteHeaders[v36].DrawSprite_sw(&v106, 0); + } + + if ( v121->sNPC_ID ) + { + //v37 = v6->uProfession; + if (v6->uProfession) + { + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], v6->pName, aNPCProfessionNames[v6->uProfession]); // "%s the %s" / ^Pi[%s] %s + } + else + { + v77 = 2000; + v72 = v6->pName; + } + } + else + { + v38 = v121->dword_000334_unique_name; + v77 = 2000; + if ( v38 ) + v72 = pMonsterStats->pPlaceStrings[v38]; + else + v72 = pMonsterStats->pInfos[v121->pMonsterInfo.uID].pName; + } + if(!v121->sNPC_ID || (v121->sNPC_ID && !v6->uProfession)) + strncpy(pTmpBuf.data(), v72, v77); + v39 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + a1->DrawTitleText(pFontComic, 0, 0xCu, v39, pTmpBuf.data(), 3u); + Actor::DrawHealthBar(v121, a1); + v119 = 0; + pMonsterInfoUI_Doll.uCurrentActionTime += pMiscTimer->uTimeElapsed; + v115 = 0; + v116 = 0; + i = 0; + v112 = 0; + if ( !uActiveCharacter ) + { + v45 = 1; + } + else + { + LOBYTE(v40) = pPlayers[uActiveCharacter]->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID); + v120 = v40; + if ( !v40 ) + v45 = 1; + else + { + v41 = (unsigned __int8)v40 & 0x3F; + v42 = SkillToMastery((unsigned __int16)v40) - 1; + if ( !v42 ) + { + if ( v41 + 10 >= v121->pMonsterInfo.uLevel ) + { + v45 = 1; + v119 = 1; + } + else + v45 = 1; + } + else + { + v43 = v42 - 1; + if ( !v43 ) + { + if ( 2 * v41 + 10 >= v121->pMonsterInfo.uLevel ) + { + v45 = 1; + v119 = 1; + v116 = 1; + } + else + v45 = 1; + } + else + { + v44 = v43 - 1; + if ( !v44 ) + { + if ( 3 * v41 + 10 >= v121->pMonsterInfo.uLevel ) + { + v45 = 1; + v119 = 1; + v116 = 1; + i = 1; + } + else + { + v45 = 1; + } + } + else + { + if ( v44 != 1 ) + v45 = 1; + else + { + v45 = 1; + v119 = 1; + v116 = 1; + i = 1; + v112 = 1; + } + } + } + } + } + // LABEL_73: + v46 = v121->uAIState; + if ( v46 != 5 && v46 != 4 && !dword_507BF0_is_there_popup_onscreen && v120 ) + { + v47 = pPlayers[uActiveCharacter]; + if ( v119 | v116 | i | (unsigned int)v112 ) + { + if ( v121->pMonsterInfo.uLevel >= v47->uLevel - 5 ) + v73 = SPEECH_105; + else + v73 = SPEECH_104; + } + else + { + v73 = SPEECH_106; + } + v47->PlaySound((PlayerSpeech)v73, 0); + } + } + + for (uint _it = 0; _it < 4; ++_it) + { + auto player = pParty->pPlayers + _it; + + //LOBYTE(v48) = player->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID); + //v111 = v48; + v111 = player->GetActualSkillLevel(PLAYER_SKILL_MONSTER_ID); + v120 = (SpellBuff *)138; + do + { + if ( (signed int)SkillToMastery(v111) >= 3 ) + v115 = v45; + v120 = (SpellBuff *)((char *)v120 - 1); + } + while ( v120 ); + //++a2; + } + //while ( (signed int)a2 < (signed int)pParty->pHirelings ); + + v49 = pFontSmallnum; + a2 = (int)pFontSmallnum; + a1->DrawText(pFontSmallnum, 12, 196, a5, pGlobalTXT_LocalizationStrings[631], 0, 0, 0); + v50 = LOBYTE(v49->uFontHeight) + 193; + if ( !v115 ) + { + v78 = 0; + v74 = 0; + v69 = 0; + v66 = pGlobalTXT_LocalizationStrings[630]; + a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78); + } + else + { + a4 = 0; + v51 = &v121->pActorBuffs[1]; + v222 = 0; + v120 = &v121->pActorBuffs[1]; + do + { + if ( (signed __int64)v51->uExpireTime > 0 ) + { + switch ( (int)v51 ) + { + case 0u: + v124 = 60; + a4 = (int)pGlobalTXT_LocalizationStrings[591]; + break; + case 1u: + v124 = 82; + a4 = (int)pGlobalTXT_LocalizationStrings[649]; + break; + case 2u: + v124 = 92; + a4 = (int)pGlobalTXT_LocalizationStrings[592]; + break; + case 3u: + v124 = 63; + a4 = (int)pGlobalTXT_LocalizationStrings[4]; + break; + case 4u: + v52 = pGlobalTXT_LocalizationStrings[220]; + a4 = (int)v52; + v124 = 81; + break; + case 5u: + v52 = pGlobalTXT_LocalizationStrings[162]; + a4 = (int)v52; + v124 = 81; + break; + case 6u: + v53 = pGlobalTXT_LocalizationStrings[593]; + v124 = 35; + a4 = (int)v53; + break; + case 8u: + v53 = pGlobalTXT_LocalizationStrings[608]; + v124 = 62; + a4 = (int)v53; + break; + case 7u: + case 9u: + a4 = 0; + v124 = 0; + ++v51; + v222 = v222 + 1; + v120 = v51; + __debugbreak(); // fix condition + continue; + case 0xAu: + v124 = 47; + a4 = (int)pGlobalTXT_LocalizationStrings[221]; + break; + case 0xBu: + v124 = 66; + a4 = (int)pGlobalTXT_LocalizationStrings[607]; + break; + case 0xCu: + v124 = 85; + a4 = (int)pGlobalTXT_LocalizationStrings[610]; + break; + case 0xDu: + v124 = 86; + a4 = (int)pGlobalTXT_LocalizationStrings[609]; + break; + case 0xEu: + v124 = 17; + a4 = (int)pGlobalTXT_LocalizationStrings[279]; + break; + case 0xFu: + v124 = 38; + a4 = (int)pGlobalTXT_LocalizationStrings[442]; + break; + case 0x10u: + v124 = 46; + a4 = (int)pGlobalTXT_LocalizationStrings[443]; + break; + case 0x11u: + v124 = 51; + a4 = (int)pGlobalTXT_LocalizationStrings[440]; + break; + case 0x12u: + v124 = 5; + a4 = (int)pGlobalTXT_LocalizationStrings[441]; + break; + case 0x13u: + v124 = 95; + a4 = (int)pGlobalTXT_LocalizationStrings[229]; + break; + case 0x14u: + v124 = 73; + a4 = (int)pGlobalTXT_LocalizationStrings[228]; + break; + default: + a4 = 0; + break; + } + if ( a4 ) + { + v54 = (char *)a4; + v55 = GetSpellColor(v124); + a1->DrawText((GUIFont *)a2, 28, v50, v55, v54, 0, 0, 0); + v50 = v50 + *(char *)(a2 + 5) - 3; + v51 = v120; + } + } + + ++v51; + v222 = v222 + 1; + v120 = v51; + + __debugbreak(); // fix condition + } + //while ( (signed int)((char *)&v222->lpVtbl + 1) < 22 ); + while (true); + + if ( !a4 ) + { + v78 = 0; + v74 = 0; + v69 = 0; + v66 = pGlobalTXT_LocalizationStrings[153]; + a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78); + } + } + v56 = pFontSmallnum; + a4 = v106.uViewportY; + if ( v119 ) + { + sprintf(pTmpBuf.data(), "%s\f%05u\t100%d\n", pGlobalTXT_LocalizationStrings[108], 0, v121->pMonsterInfo.uHP); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + a4 = a4 + LOBYTE(v56->uFontHeight) - 3; + v79 = v121->pMonsterInfo.uAC; + v75 = 0; + v70 = pGlobalTXT_LocalizationStrings[12]; + v67 = "%s\f%05u\t100%d\n"; + } + else + { + sprintf(pTmpBuf.data(), "%s\f%05u\t100%s\n", pGlobalTXT_LocalizationStrings[108], 0, pGlobalTXT_LocalizationStrings[630]); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + v79 = (unsigned int)pGlobalTXT_LocalizationStrings[630]; + v75 = 0; + v70 = pGlobalTXT_LocalizationStrings[12]; + a4 = a4 + LOBYTE(v56->uFontHeight) - 3; + v67 = "%s\f%05u\t100%s\n"; + } + sprintf(pTmpBuf.data(), v67, v70, v75, v79); + a1->DrawText(v56, 150, a4, a5, pTmpBuf.data(), 0, 0, 0); + a4 = a4 + LOBYTE(v56->uFontHeight) - 6 + LOBYTE(v56->uFontHeight); + v95[0] = pGlobalTXT_LocalizationStrings[87]; + v95[1] = pGlobalTXT_LocalizationStrings[6]; + v95[2] = pGlobalTXT_LocalizationStrings[240]; + v95[3] = pGlobalTXT_LocalizationStrings[70]; + v95[4] = pGlobalTXT_LocalizationStrings[624]; + v95[5] = pGlobalTXT_LocalizationStrings[138]; + v95[6] = pGlobalTXT_LocalizationStrings[214]; + v95[7] = pGlobalTXT_LocalizationStrings[142]; + v95[8] = pGlobalTXT_LocalizationStrings[29]; + v95[9] = pGlobalTXT_LocalizationStrings[133]; + v95[10] = pGlobalTXT_LocalizationStrings[54]; + if ( v116 ) + { + sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, v95[v121->pMonsterInfo.uAttack1Type]); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + a4 = a4 + LOBYTE(v56->uFontHeight) - 3; + v57 = v121->pMonsterInfo.uAttack1DamageBonus; + if ( v57 ) + sprintf(pTmpBuf.data(), "%s\f%05u\t080%dd%d+%d\n", pGlobalTXT_LocalizationStrings[53], + 0, v121->pMonsterInfo.uAttack1DamageDiceRolls, v121->pMonsterInfo.uAttack1DamageDiceSides, v57); + else + sprintf(pTmpBuf.data(), "%s\f%05u\t080%dd%d\n", pGlobalTXT_LocalizationStrings[53], + 0, v121->pMonsterInfo.uAttack1DamageDiceRolls, v121->pMonsterInfo.uAttack1DamageDiceSides); + } + else + { + sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[18], 0, pGlobalTXT_LocalizationStrings[630]); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + a4 = a4 + LOBYTE(v56->uFontHeight) - 3; + sprintf(pTmpBuf.data(), "%s\f%05u\t080%s\n", pGlobalTXT_LocalizationStrings[53], 0, pGlobalTXT_LocalizationStrings[630]); + } + a1->DrawText(v56, 150, a4, a5, pTmpBuf.data(), 0, 0, 0); + v58 = LOBYTE(v56->uFontHeight); + a4 = a4 + v58 - 6 + v58; + if ( !i ) + { + v80 = pGlobalTXT_LocalizationStrings[630]; + v76 = 0; + v71 = pGlobalTXT_LocalizationStrings[628]; + v68 = "%s\f%05u\t080%s\n"; + sprintf(pTmpBuf.data(), v68, v71, v76, v80); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + v58 = LOBYTE(v56->uFontHeight); + a4 = a4 + v58 - 3; + } + else + { + v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[628]; + v59 = v121; + v114 = v121->pMonsterInfo.uSpell1ID; + if ( v114 && v121->pMonsterInfo.uSpell2ID ) + v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[629]; + if ( v114 ) + { + sprintf(pTmpBuf.data(), "%s\f%05u\t060%s\n", v120, 0, pSpellStats->pInfos[v114].pShortName); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + v58 = LOBYTE(v56->uFontHeight); + a4 = a4 + v58 - 3; + v59 = v121; + } + v60 = v59->pMonsterInfo.uSpell2ID; + if ( v60 ) + { + sprintf(pTmpBuf.data(), "\f%05u\t060%s\n", 0, pSpellStats->pInfos[v60].pShortName); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + v58 = LOBYTE(v56->uFontHeight); + a4 = a4 + v58 - 3; + v59 = v121; + } + if ( !v59->pMonsterInfo.uSpell1ID && !v59->pMonsterInfo.uSpell2ID ) + { + v80 = pGlobalTXT_LocalizationStrings[153]; + v76 = 0; + v71 = pGlobalTXT_LocalizationStrings[628]; + v68 = "%s\f%05u\t060%s\n"; + sprintf(pTmpBuf.data(), v68, v71, v76, v80); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf.data(), 0, 0, 0); + v58 = LOBYTE(v56->uFontHeight); + a4 = a4 + v58 - 3; + } + } + a4 = a4 + v58 - 3; + a1->DrawText(v56, 150, a4, a5, pGlobalTXT_LocalizationStrings[626], 0, 0, 0); + a4 = a4 + LOBYTE(v56->uFontHeight) - 3; + v85[0] = pGlobalTXT_LocalizationStrings[87]; + v85[1] = pGlobalTXT_LocalizationStrings[6]; + v85[2] = pGlobalTXT_LocalizationStrings[240]; + v85[3] = pGlobalTXT_LocalizationStrings[70]; + v85[4] = pGlobalTXT_LocalizationStrings[142]; + v85[5] = pGlobalTXT_LocalizationStrings[214]; + v85[6] = pGlobalTXT_LocalizationStrings[29]; + v85[7] = pGlobalTXT_LocalizationStrings[133]; + v85[8] = pGlobalTXT_LocalizationStrings[54]; + v85[9] = pGlobalTXT_LocalizationStrings[624]; + v95[1] = (char *)v121->pMonsterInfo.uResFire; + v95[2] = (char *)v121->pMonsterInfo.uResAir; + v95[3] = (char *)v121->pMonsterInfo.uResWater; + v95[4] = (char *)v121->pMonsterInfo.uResEarth; + v95[5] = (char *)v121->pMonsterInfo.uResMind; + v95[6] = (char *)v121->pMonsterInfo.uResSpirit; + v95[7] = (char *)v121->pMonsterInfo.uResBody; + v95[8] = (char *)v121->pMonsterInfo.uResLight; + v95[9] = (char *)v121->pMonsterInfo.uResPhysical; + v95[10] = (char *)v121->pMonsterInfo.uResDark; + if ( v112 ) + { + v124 = 0; + do + { + v62 = v95[v124+1]; + if ( v62 == (char *)200 ) + { + v81 = pGlobalTXT_LocalizationStrings[625]; + } + else + { + if ( v62 ) + v81 = pGlobalTXT_LocalizationStrings[627]; + else + v81 = pGlobalTXT_LocalizationStrings[153]; + } + sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", v85[v124], 0, v81); + a1->DrawText(v56, 170, a4, a5, pTmpBuf.data(), 0, 0, 0); + v63 = LOBYTE(v56->uFontHeight); + v124 += 4; + a4 = a4 + v63 - 3; + } + while ( v124 < 40 ); + } + else + { + i = 0; + do + { + sprintf(pTmpBuf.data(), "%s\f%05u\t070%s\n", v85[i], 0, pGlobalTXT_LocalizationStrings[630]); // "?" + a1->DrawText(v56, 170, a4, a5, pTmpBuf.data(), 0, 0, 0); + v65 = LOBYTE(v56->uFontHeight); + ++i; + a4 = a4 + v65 - 3; + } + while ( i < 10 ); + } + if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_DETECT_LIFE].uExpireTime > 0 ) + { + sprintf(pTmpBuf.data(), "%s: %d", pGlobalTXT_LocalizationStrings[650], v121->sCurrentHP); + pFontSmallnum->GetLineWidth(pTmpBuf.data()); + a1->DrawTitleText(pFontSmallnum, 0, a1->uFrameHeight - LOBYTE(pFontSmallnum->uFontHeight) - 12, 0, pTmpBuf.data(), 3); + } +} + + +//----- (00417BB5) -------------------------------------------------------- +const char *CharacterUI_GetSkillDescText(unsigned int uPlayerID, PLAYER_SKILL_TYPE uPlayerSkillType) +{ + //enum PLAYER_SKILL_TYPE v2; // esi@1 + //unsigned int v3; // ebx@1 + int v4; // edi@1 + int v5; // eax@1 + Player *pPlayer; // ebx@7 + char v7; // al@7 + char v8; // cl@7 + unsigned int v9; // eax@8 + unsigned int v10; // eax@8 + unsigned int v11; // eax@8 + PLAYER_SKILL_TYPE v12; // edi@8 + unsigned int v13; // eax@8 + unsigned int v14; // eax@8 + PLAYER_SKILL_TYPE v15; // esi@8 + int v16; // edi@8 + char v17; // al@8 + int v18; // ST5C_4@8 + int v19; // ST4C_4@8 + int v20; // ST3C_4@8 + int v21; // ST2C_4@8 + int v22; // ST1C_4@8 + char *v23; // esi@8 + unsigned int v24; // eax@9 + unsigned int v25; // eax@9 + unsigned int v26; // eax@9 + unsigned int v27; // ecx@9 + PLAYER_SKILL_TYPE v28; // ebx@9 + unsigned int v29; // eax@9 + char a2[1200]; // [sp+Ch] [bp-538h]@7 + char Source[120]; // [sp+4BCh] [bp-88h]@7 + unsigned __int16 *v33; // [sp+534h] [bp-10h]@1 + int v34; // [sp+538h] [bp-Ch]@1 + unsigned __int16 *v35; // [sp+53Ch] [bp-8h]@1 + //enum PLAYER_SKILL_TYPE v36; // [sp+540h] [bp-4h]@1 + + //v2 = uPlayerSkillType; + //v3 = uPlayerID; + //v36 = uPlayerSkillType; + v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[431]);// Normal + v34 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[433]);// Expert + v33 = (unsigned __int16 *)pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[432]);// Master + v5 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[96]);// Grand + v35 = (unsigned __int16 *)v4; + if ( v34 > v4 ) + v35 = (unsigned __int16 *)v34; + if ( (signed int)v33 > (signed int)v35 ) + v35 = v33; + if ( v5 > (signed int)v35 ) + v35 = (unsigned __int16 *)v5; + pPlayer = &pParty->pPlayers[uPlayerID]; + //v33 = &pPlayer->pActiveSkills[uPlayerSkillType]; + v7 = pPlayer->GetActualSkillLevel(uPlayerSkillType); + v8 = pPlayer->pActiveSkills[uPlayerSkillType]; + a2[0] = 0; + Source[0] = 0; + if ( (v8 & 0x3F) == (v7 & 0x3F) ) + { + strcpy(a2, "%s\n\n"); + v24 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 1); + sprintf(Source, "\f%05d", v24); + strcat(a2, Source); + strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); + v25 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 2); + sprintf(Source, "\f%05d", v25); + strcat(a2, Source); + strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); + v26 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 3); + sprintf(Source, "\f%05d", v26); + strcat(a2, Source); + strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); + v27 = pPlayer->classType; + v28 = uPlayerSkillType; + v29 = GetSkillColor(v27, uPlayerSkillType, 4); + sprintf(Source, "\f%05d", v29); + strcat(a2, Source); + strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); + + v23 = static_sub_417BB5_out_string; + sprintf(static_sub_417BB5_out_string, a2, pSkillDesc[v28], pGlobalTXT_LocalizationStrings[431], // Normal + (char *)v35 + 3, v35 + 5, pNormalSkillDesc[v28], pGlobalTXT_LocalizationStrings[433], // Expert + (char *)v35 + 3, v35 + 5, pExpertSkillDesc[v28], pGlobalTXT_LocalizationStrings[432], // Master + (char *)v35 + 3, v35 + 5, pMasterSkillDesc[v28], pGlobalTXT_LocalizationStrings[96], // Grand + (char *)v35 + 3, v35 + 5, pGrandSkillDesc[v28]); + } + else + { + strcpy(a2, "%s\n\n"); + v9 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 1); + sprintf(Source, "\f%05d", v9); + strcat(a2, Source); + strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); + v10 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 2); + sprintf(Source, "\f%05d", v10); + strcat(a2, Source); + strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); + v11 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 3); + sprintf(Source, "\f%05d", v11); + strcat(a2, Source); + strcat(a2, "%s\t%03d:\t%03d%s\t000\n"); + v12 = uPlayerSkillType; + v13 = GetSkillColor(pPlayer->classType, uPlayerSkillType, 4); + sprintf(Source, "\f%05d", v13); + strcat(a2, Source); + strcat(a2, "%s\t%03d:\t%03d%s\t000\n\n"); + v14 = TargetColor(0xFFu, 0xFFu, 0xFFu); + sprintf(Source, "\f%05d", v14); + strcat(a2, Source); + strcat(a2, "%s: +%d"); + v15 = v12; + v16 = (int)(v35 + 5); + v15 = (PLAYER_SKILL_TYPE)((int)v15 * 4); + v34 = (int)((char *)v35 + 3); + v17 = pPlayer->GetActualSkillLevel(uPlayerSkillType); + v18 = *(int *)(pGrandSkillDesc[v15]); + v19 = *(int *)(pMasterSkillDesc[v15]); + v20 = *(int *)(pExpertSkillDesc[v15]); + v21 = *(int *)(pNormalSkillDesc[v15]); + v22 = *(int *)(pSkillDesc[v15]); + v23 = static_sub_417BB5_out_string; + sprintf( + static_sub_417BB5_out_string, + a2, + v22, + pGlobalTXT_LocalizationStrings[431], + v34, + v16, + v21, + pGlobalTXT_LocalizationStrings[433], + v34, + v16, + v20, + pGlobalTXT_LocalizationStrings[432], + v34, + v16, + v19, + pGlobalTXT_LocalizationStrings[96], + v34, + v16, + v18, + pGlobalTXT_LocalizationStrings[623], + (v17 & 0x3F) - (*(char *)v33 & 0x3F)); + } + return v23; + } + +//----- (00417FE5) -------------------------------------------------------- + void CharacterUI_SkillsTab_ShowHint() + { + unsigned int v0; // ecx@1 + unsigned int v1; // eax@1 + GUIButton *i; // esi@6 + const char *v3; // eax@12 + unsigned int pX; // [sp+4h] [bp-8h]@1 + unsigned int pY; // [sp+8h] [bp-4h]@1 + + pMouse->GetClickPos(&pX, &pY); + v0 = pX; + v1 = pY; + if ( (signed int)pX < 24 || (signed int)pX > 455 || (signed int)pY < 18 || (signed int)pY > 36 ) + { + for ( i = pGUIWindow_CurrentMenu->pControlsHead; i; i = i->pNext ) + { + if ( i->msg == UIMSG_SkillUp + && (signed int)v0 >= (signed int)i->uX + && (signed int)v0 <= (signed int)i->uZ + && (signed int)v1 >= (signed int)i->uY + && (signed int)v1 <= (signed int)i->uW ) + { + v3 = CharacterUI_GetSkillDescText(uActiveCharacter - 1, (PLAYER_SKILL_TYPE)i->msg_param); + sub_4179BC_draw_tooltip(pSkillNames[i->msg_param], v3); + v1 = pY; + v0 = pX; + } + } + } + else + { + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[207], pSkillPointsAttributeDescription); + } + + } + +//----- (00418083) -------------------------------------------------------- +void __cdecl CharacterUI_StatsTab_ShowHint() + { + LONG _x; // esi@1 + LONG _y; // eax@1 + int pStringNum; // edi@1 + signed int pTextColor; // eax@15 + char *pHourWord; // ecx@17 + char *pDayWord; // eax@20 + int v15; // ebx@28 + int v16; // eax@33 + POINT a2; // [sp+Ch] [bp-24h]@1 + int pHour; // [sp+14h] [bp-1Ch]@15 + unsigned int pDay; // [sp+24h] [bp-Ch]@15 + + _x = pMouse->GetCursorPos(&a2)->x; + _y = pMouse->GetCursorPos(&a2)->y; + for ( pStringNum = 0; pStringNum < (signed int)&off_4E2A12; ++pStringNum ) + { + if ( _x >= stat_string_coord[pStringNum].x && _x <= stat_string_coord[pStringNum].x + stat_string_coord[pStringNum].width ) + { + if ( _y >= stat_string_coord[pStringNum].y && _y <= stat_string_coord[pStringNum].y + stat_string_coord[pStringNum].height ) + break; + } + } + switch ( pStringNum ) + { + case 0:// Attributes + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + if ( aAttributeNames[pStringNum] && pAttributeDescriptions[pStringNum] ) + sub_4179BC_draw_tooltip(aAttributeNames[pStringNum], pAttributeDescriptions[pStringNum]); + break; + case 7:// Health Points + if ( pGlobalTXT_LocalizationStrings[108] && pHealthPointsAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[108], pHealthPointsAttributeDescription); + break; + case 8:// Spell Points + if ( pGlobalTXT_LocalizationStrings[212] && pSpellPointsAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[212], pSpellPointsAttributeDescription); + break; + case 9:// Armor Class + if ( pGlobalTXT_LocalizationStrings[12] && pArmourClassAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[12], pArmourClassAttributeDescription); + break; + case 10:// Player Condition + strcpy(pTmpBuf2.data(), pPlayerConditionAttributeDescription); + strcat(pTmpBuf2.data(), "\n"); + extern std::array<unsigned int, 18> pConditionImportancyTable; + for ( uint i = 0; i < 18; ++i ) + { + if ( pPlayers[uActiveCharacter]->pConditions[pConditionImportancyTable[i]] ) + { + strcat(pTmpBuf2.data(), " \n"); + pHour = pParty->uTimePlayed - pPlayers[uActiveCharacter]->pConditions[pConditionImportancyTable[i]]; + pHour = (unsigned int)((pHour * 0.234375) / 60 / 60); + pDay = (unsigned int)pHour / 24; + pHour %= 24i64; + pTextColor = GetConditionDrawColor(pConditionImportancyTable[i]); + sprintfex(pTmpBuf.data(), format_4E2DE8, pTextColor, aCharacterConditionNames[pConditionImportancyTable[i]]); + strcat(pTmpBuf2.data(), pTmpBuf.data()); + if ( pHour && pHour <= 1 ) + pHourWord = pGlobalTXT_LocalizationStrings[109]; + else + pHourWord = pGlobalTXT_LocalizationStrings[110]; + if ( !pDay || (pDayWord = pGlobalTXT_LocalizationStrings[56], pDay > 1) ) + pDayWord = pGlobalTXT_LocalizationStrings[57]; + sprintfex(pTmpBuf.data(), "%lu %s, %lu %s", pDay, pDayWord, pHour, pHourWord); + strcat(pTmpBuf2.data(), pTmpBuf.data()); + } + } + if ( pGlobalTXT_LocalizationStrings[47] && pTmpBuf2.data() ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[47], pTmpBuf2.data()); + break; + case 11:// Fast Spell + if ( pGlobalTXT_LocalizationStrings[172] && pFastSpellAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[172], pFastSpellAttributeDescription); + break; + case 12:// Player Age + if ( pGlobalTXT_LocalizationStrings[5] && pPlayerAgeAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[5], pPlayerAgeAttributeDescription); + break; + case 13:// Player Level + if ( pGlobalTXT_LocalizationStrings[131] && pPlayerLevelAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[131], pPlayerLevelAttributeDescription); + break; + case 14://Experience + v15 = pPlayers[uActiveCharacter]->uLevel; + do + { + if ( (signed __int64)pPlayers[uActiveCharacter]->uExperience < (unsigned int)sub_4B46F8(v15) ) + break; + ++v15; + } + while ( v15 <= 10000 ); + pTmpBuf[0] = 0; + pTmpBuf2[0] = 0; + if ( v15 > pPlayers[uActiveCharacter]->uLevel ) + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[147], v15); + v16 = sub_4B46F8(v15) - LODWORD(pPlayers[uActiveCharacter]->uExperience); + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[538], v16, v15 + 1); + strcat(pTmpBuf.data(), "\n"); + strcat(pTmpBuf.data(), pTmpBuf2.data()); + sprintf(pTmpBuf2.data(), "%s\n \n%s", pPlayerExperienceAttributeDescription, pTmpBuf.data()); + if ( pGlobalTXT_LocalizationStrings[83] && pTmpBuf2.data() ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[83], pTmpBuf2.data()); + break; + case 15:// Attack Bonus + if ( pGlobalTXT_LocalizationStrings[587] && pAttackBonusAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[587], pAttackBonusAttributeDescription); + break; + case 16:// Attack Damage + if ( pGlobalTXT_LocalizationStrings[588] && pAttackDamageAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[588], pAttackDamageAttributeDescription); + break; + case 17:// Missle Bonus + if ( pGlobalTXT_LocalizationStrings[589] && pMissleBonusAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[589], pMissleBonusAttributeDescription); + break; + case 18:// Missle Damage + if ( pGlobalTXT_LocalizationStrings[590] && pMissleDamageAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[590], pMissleDamageAttributeDescription); + break; + case 19:// Fire Resistance + if ( pGlobalTXT_LocalizationStrings[87] && pFireResistanceAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[87], pFireResistanceAttributeDescription); + break; + case 20:// Air Resistance + if ( pGlobalTXT_LocalizationStrings[6] && pAirResistanceAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[6], pAirResistanceAttributeDescription); + break; + case 21:// Water Resistance + if ( pGlobalTXT_LocalizationStrings[240] && pWaterResistanceAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[240], pWaterResistanceAttributeDescription); + break; + case 22:// Earth Resistance + if ( pGlobalTXT_LocalizationStrings[70] && pEarthResistanceAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[70], pEarthResistanceAttributeDescription); + break; + case 23:// Mind Resistance + if ( pGlobalTXT_LocalizationStrings[142] && pMindResistanceAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[142], pMindResistanceAttributeDescription); + break; + case 24:// Body Resistance + if ( pGlobalTXT_LocalizationStrings[29] && pBodyResistanceAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[29], pBodyResistanceAttributeDescription); + break; + case 25: // Skill Points + if ( pGlobalTXT_LocalizationStrings[207] && pSkillPointsAttributeDescription ) + sub_4179BC_draw_tooltip(pGlobalTXT_LocalizationStrings[207], pSkillPointsAttributeDescription); + break; + case 26: + __debugbreak(); + //_y = (Player *)(4 * pPlayers[uActiveCharacter]->classType); + //v24 = *(char **)((char *)_y->pConditions + (int)pClassNames); + //v7 = *(char **)((char *)_y->pConditions + (int)pClassDescriptions); + //if ( v24 && v7 ) + //sub_4179BC_draw_tooltip(v24, v7); + break; + default: + break; + } +} + + //----- (00410B28) -------------------------------------------------------- + void __thiscall DrawSpellDescriptionPopup(int spell_index) + { + Player *v1; // edi@1 + SpellInfo *v2; // esi@1 + unsigned int v3; // eax@2 + int v4; // eax@4 + LONG v5; // ecx@4 + int v6; // eax@10 + char *v7; // ST44_4@12 + unsigned __int16 v8; // ax@12 + GUIWindow a1; // [sp+Ch] [bp-68h]@4 + int v10; // [sp+60h] [bp-14h]@1 + POINT a2; // [sp+64h] [bp-10h]@1 + int v12; // [sp+6Ch] [bp-8h]@4 + int v13; // [sp+70h] [bp-4h]@4 + + v1 = pPlayers[uActiveCharacter]; + v10 = spell_index; + v2 = &pSpellStats->pInfos[spell_index + 11 * v1->lastOpenedSpellbookPage + 1]; + if ( pMouse->GetCursorPos(&a2)->y <= 250 ) + v3 = pMouse->GetCursorPos(&a2)->y + 30; + else + v3 = 30; + a1.uFrameY = v3; + a1.uFrameWidth = 328; + a1.uFrameHeight = 68; + a1.uFrameX = 90; + a1.uFrameZ = 417; + a1.uFrameW = v3 + 67; + a1.Hint = 0; + a2.y = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_NORMAL]); + v13 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_MASTER]); + v12 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_EXPERT]); + v4 = pFontSmallnum->GetLineWidth(pGlobalTXT_LocalizationStrings[LOCSTR_GRAND]); + v5 = a2.y; + if ( v13 > a2.y ) + v5 = v13; + if ( v12 > v5 ) + v5 = v12; + if ( v4 > v5 ) + v5 = v4; + sprintf( pTmpBuf2.data(), + "%s\n\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s\t000\n%s\t%03d:\t%03d%s", + v2->pDescription, + pGlobalTXT_LocalizationStrings[LOCSTR_NORMAL], + v5 + 3, v5 + 10, + v2->pBasicSkillDesc, + pGlobalTXT_LocalizationStrings[LOCSTR_EXPERT], + v5 + 3, v5 + 10, + v2->pExpertSkillDesc, + pGlobalTXT_LocalizationStrings[LOCSTR_MASTER], + v5 + 3, v5 + 10, + v2->pMasterSkillDesc, + pGlobalTXT_LocalizationStrings[LOCSTR_GRAND], + v5 + 3, v5 + 10, + v2->pGrandmasterSkillDesc); + v6 = pFontSmallnum->CalcTextHeight(pTmpBuf2.data(), &a1, 0, 0); + a1.uFrameHeight += v6; + if ( (signed int)a1.uFrameHeight < 150 ) + a1.uFrameHeight = 150; + a1.uFrameWidth = game_viewport_width; + a1.DrawMessageBox(0); + a1.uFrameWidth -= 12; + a1.uFrameHeight -= 12; + v7 = v2->pName; + a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1; + a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1; + v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u); + a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2.data(), 0, 0, 0); + a1.uFrameWidth = 108; + a1.uFrameZ = a1.uFrameX + 107; + a1.DrawTitleText(pFontComic, 0xCu, 0x4Bu, 0, pSkillNames[v1->lastOpenedSpellbookPage + 12], 3u); + sprintf( pTmpBuf.data(), "%s\n%d", pGlobalTXT_LocalizationStrings[LOCSTR_SP_COST], + pSpellDatas[spell_index + 11 * v1->lastOpenedSpellbookPage + 1].mana_per_skill[v1->pActiveSkills[v1->lastOpenedSpellbookPage + PLAYER_SKILL_FIRE]]); + // *(&[0].field_12 //temp_fix field_14 + // + ((unsigned int)LOBYTE(v1->pActiveSkills[v1->lastOpenedSpellbookPage + 12]) >> 6) + // + 10 * (int)((char *)v10 + 11 * v1->lastOpenedSpellbookPage))); + a1.DrawTitleText(pFontComic, 0xCu, a1.uFrameHeight - LOBYTE(pFontComic->uFontHeight) - 16, 0, pTmpBuf.data(), 3u); + dword_507B00_spell_info_to_draw_in_popup = 0; + } + // 507B00: using guessed type int dword_507B00_spell_info_to_draw_in_popup; + + + + + +//----- (00416D62) -------------------------------------------------------- +void sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(Vec2_int_ *_this) +{ + signed int pPlayerNum; // eax@12 + char *v2; // eax@32 + void *v3; // ecx@52 + unsigned int v4; // eax@59 + int v5; // esi@62 + signed int v6; // esi@64 + signed int v7; // esi@69 + ItemGen *v8; // ecx@70 + unsigned int v9; // eax@72 + unsigned int v10; // eax@76 + //char v11; // zf@83 + GUIButton *pButton; // esi@84 + unsigned int v13; // ecx@85 + char *pStr; // edi@85 + //signed int pControlID; // eax@92 + int v16; // eax@95 + int v17; // eax@96 + PLAYER_SKILL_TYPE v18; // eax@98 + char *pStr2; // eax@99 + unsigned int v20; // eax@108 + unsigned int pSkillId; // eax@109 + const char *pSkillInfo; // eax@111 + //char *v23; // ebx@112 + char *pHint; // edx@113 + unsigned int pColor; // eax@113 + GUIWindow pWindow; // [sp+4h] [bp-74h]@32 + double v27; // [sp+58h] [bp-20h]@33 + struct tagPOINT Point; // [sp+60h] [bp-18h]@6 + char *v29; // [sp+68h] [bp-10h]@33 + float v30; // [sp+6Ch] [bp-Ch]@33 + unsigned int pX; // [sp+70h] [bp-8h]@3 + unsigned int pY; // [sp+74h] [bp-4h]@3 + + if ( pCurrentScreen == SCREEN_VIDEO ) + return; + if ( _this ) + { + pX = _this->x; + pY = _this->y; + } + else + { + pMouse->GetClickPos(&pX, &pY); + } + if ( pRenderer->bWindowMode ) + { + GetCursorPos(&Point); + ScreenToClient(hWnd, &Point); + if ( Point.x < 1 || Point.y < 1 || Point.x > 638 || Point.y > 478 ) + { + back_to_game(); + return; + } + } + + if ( pParty->pPickedItem.uItemID )//íàæàòèå íà ïîðòðåò ïåðñà ïðàâîé êíîïêîé ìûøè ñ ðàñòâîðîì + { + //v1 = 0; + //do + for ( pPlayerNum = 0; pPlayerNum < 4; ++pPlayerNum) + { + if ( (signed int)pX > RightClickPortraitXmin[pPlayerNum] && (signed int)pX < RightClickPortraitXmax[pPlayerNum] + && (signed int)pY > 375 && (signed int)pY < 466 ) + { + pPlayers[uActiveCharacter]->UseItem_DrinkPotion_etc(pPlayerNum + 1, 1); + return; + } + //++v1; + } + //while ( v1 < 4 ); + } + + pEventTimer->Pause(); + + switch(pCurrentScreen) + { + case SCREEN_CASTING: + { + identify_item(); + break; + } + + case SCREEN_CHEST: + { + if ( !pPlayers[uActiveCharacter]->CanAct() ) + { + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[427],//%s íå â ñîñòîÿíèè %s + pPlayers[uActiveCharacter]->pName, pGlobalTXT_LocalizationStrings[541]);//Îïîçíàòü ïðåäìåòû + pWindow.Hint = pTmpBuf.data(); + pWindow.uFrameWidth = 384; + pWindow.uFrameHeight = 180; + pWindow.uFrameY = 40; + if ( (signed int)pX <= 320 ) + v10 = pX + 30; + else + v10 = pX - 414; + pWindow.uFrameX = v10; + pWindow.DrawMessageBox(0); + } + else + { + v9 = pX + pSRZBufferLineOffsets[pY]; + if ( pRenderer->pActiveZBuffer[v9] & 0xFFFF ) + { + + // __debugbreak(); // invalid indexing will result in invalid object ptr + // v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].igChestItems[139].uExpireTime + // + (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); + v10=pChests[pChestWindow->par1C].pInventoryIndices[(pRenderer->pActiveZBuffer[v9] & 0xFFFF)-1]; + v8 =&pChests[pChestWindow->par1C].igChestItems[v10-1]; + GameUI_DrawItemInfo(v8); + } + } + break; + } + case SCREEN_GAME: + { + if (GetCurrentMenuID() > 0) + break; + + if ( (signed int)pY > (signed int)pViewport->uViewportBR_Y ) + { + pWindow.ptr_1C = (void *)((signed int)pX / 118); + if ( (signed int)pX / 118 < 4 ) + { + pWindow.Hint = 0; + pWindow.uFrameWidth = 400; + pWindow.uFrameHeight = 200; + pWindow.uFrameX = 38; + pWindow.uFrameY = 60; + pAudioPlayer->StopChannels(-1, -1); + GameUI_CharacterQuickRecord_Draw(&pWindow, pPlayers[(int)pWindow.ptr_1C + 1]); + } + } + else if ( (signed int)pX > (signed int)pViewport->uViewportBR_X ) + { + if ( (signed int)pY >= 130 ) + { + if ( (signed int)pX >= 476 && (signed int)pX <= 636 && (signed int)pY >= 240 && (signed int)pY <= 300 ) + { + pWindow.Hint = 0; + pWindow.uFrameWidth = 400; + pWindow.uFrameHeight = 200; + pWindow.uFrameX = 38; + pWindow.uFrameY = 60; + pAudioPlayer->StopChannels(-1, -1); + pWindow._41D73D_draw_buff_tooltip(); + } + else if ( (signed int)pX < 485 || (signed int)pX > 548 || (signed int)pY < 156 || (signed int)pY > 229 ) + { + if (!( (signed int)pX < 566 || (signed int)pX > 629 || (signed int)pY < 156 || (signed int)pY > 229 )) + { + pAudioPlayer->StopChannels(-1, -1); + v3 = (void *)1; + GameUI_DrawNPCPopup(v3); + } + } + else + { + pAudioPlayer->StopChannels(-1, -1); + v3 = 0; + GameUI_DrawNPCPopup(v3); + } + } + else + { + pWindow.Hint = (char *)GameUI_GetMinimapHintText(); + pWindow.uFrameWidth = 256; + pWindow.uFrameX = 130; + pWindow.uFrameY = 140; + pWindow.uFrameHeight = 64; + pAudioPlayer->StopChannels(-1, -1); + pWindow.DrawMessageBox(0); + } + } + else + { + pWindow.Hint = 0; + pWindow.uFrameWidth = 320; + pWindow.uFrameHeight = 320; + v4 = pX - 350; + if ( (signed int)pX <= 320 ) + v4 = pX + 30; + pWindow.uFrameX = v4; + pWindow.uFrameY = 40; + if ( pRenderer->pRenderD3D ) + LOWORD(v5) = pGame->pVisInstance->get_picked_object_zbuf_val(); + else + v5 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; + v6 = (unsigned __int16)v5; + if (PID_TYPE(v6) != OBJECT_Item) + { + if (PID_TYPE(v6) == OBJECT_Actor) + { + if ( pRenderer->uNumSceneBegins ) + { + pWindow.DrawMessageBox(1); + MonsterPopup_Draw(PID_ID(v6), &pWindow); + } + else + { + pRenderer->BeginScene(); + pWindow.DrawMessageBox(1); + MonsterPopup_Draw(PID_ID(v6), &pWindow); + pRenderer->EndScene(); + } + } + } + else + { + v7 = PID_ID(v6); + if ( ! (pObjectList->pObjects[pSpriteObjects[v7].uObjectDescID].uFlags & 0x10 ) ) + { + v8 = &pSpriteObjects[v7].stru_24; + GameUI_DrawItemInfo(v8); + } + } + } + break; + } + case SCREEN_BOOKS: + { + if ( !dword_506364 + || (signed int)pX < (signed int)pViewport->uViewportTL_X + || (signed int)pX > (signed int)pViewport->uViewportBR_X + || (signed int)pY < (signed int)pViewport->uViewportTL_Y + || (signed int)pY > (signed int)pViewport->uViewportBR_Y + || (v2 = (char *)sub_444564(), (pWindow.Hint = v2) == 0) ) + break; + v30 = (double)(pFontArrus->GetLineWidth(v2) + 32); + v27 = v30 + 6.7553994e15; + v29 = (char *)LODWORD(v27); + pWindow.uFrameWidth = LODWORD(v27); + pWindow.uFrameX = pX + 5; + pWindow.uFrameY = pY + 5; + pWindow.uFrameHeight = 64; + pAudioPlayer->StopChannels(-1, -1); + pWindow.DrawMessageBox(0); + break; + } + case SCREEN_CHARACTERS: + case SCREEN_E: + case SCREEN_CHEST_INVENTORY: + { + if ( (signed int)pX > 467 && pCurrentScreen != SCREEN_E ) + { + identify_item(); + } + else if ( (signed int)pY >= 345 ) + break; + else if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 100 )//2DEvent - CharacerScreenStats + { + CharacterUI_StatsTab_ShowHint(); + } + else if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 101 )//2DEvent - CharacerScreenSkills + { + CharacterUI_SkillsTab_ShowHint(); + } + else + { + if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 103 )//2DEvent - CharacerScreenInventory + identify_item(); + } + break; + } + case SCREEN_SPELL_BOOK: + { + if ( dword_507B00_spell_info_to_draw_in_popup ) + DrawSpellDescriptionPopup(dword_507B00_spell_info_to_draw_in_popup - 1); + break; + } + case SCREEN_HOUSE: + { + if ( (signed int)pY < 345 && (signed int)pX < 469 ) + ShowPopupShopItem(); + break; + } + case SCREEN_PARTY_CREATION: + { + pWindow.Hint = 0; + pStr = 0; + for ( pButton = pGUIWindow_CurrentMenu->pControlsHead; pButton; pButton = pButton->pNext) + { + if ( pButton->uButtonType == 1 && pButton->uButtonType != 3 && (signed int)pX > (signed int)pButton->uX && (signed int)pX < (signed int)pButton->uZ + && (signed int)pY > (signed int)pButton->uY && (signed int)pY < (signed int)pButton->uW ) + { + switch ( pButton->msg ) + { + case UIMSG_0: //stats info + pWindow.Hint = pAttributeDescriptions[(signed int)pButton->msg_param % 7]; + pStr = aAttributeNames[(signed int)pButton->msg_param % 7]; + break; + case UIMSG_PlayerCreationClickPlus: //Plus button info + pStr = pGlobalTXT_LocalizationStrings[670];//Äîáàâèòü + pWindow.Hint = pGlobalTXT_LocalizationStrings[671];//"Äîáàâëÿåò î÷êî ê âûäåëåííîìó íàâûêó, çàáèðàÿ åãî èç íàêîïèòåëÿ î÷êîâ" + break; + case UIMSG_PlayerCreationClickMinus: //Minus button info + pStr = pGlobalTXT_LocalizationStrings[668];//Âû÷åñòü + pWindow.Hint = pGlobalTXT_LocalizationStrings[669];//"Âû÷èòàåò î÷êî èç âûäåëåííîãî íàâûêà, âîçâðàùàÿ åãî â íàêîïèòåëü î÷êîâ" + break; + case UIMSG_PlayerCreationSelectActiveSkill: //Available skill button info + v18 = pParty->pPlayers[uPlayerCreationUI_SelectedCharacter].GetSkillIdxByOrder(pButton->msg_param + 4); + pStr = pSkillNames[v18]; + pWindow.Hint = pSkillDesc[v18]; + break; + case UIMSG_PlayerCreationSelectClass: //Available Class Info + pWindow.Hint = pClassDescriptions[pButton->msg_param]; + pStr = pClassNames[pButton->msg_param]; + break; + case UIMSG_PlayerCreationClickOK: //OK Info + pWindow.Hint = pGlobalTXT_LocalizationStrings[664];//Ùåëêíèòå çäåñü äëÿ óòâåðæäåíèÿ ñîñòàâà îòðÿäà è ïðîäîëæåíèÿ èãðû. + pStr = pGlobalTXT_LocalizationStrings[665];//Êíîïêà ÎÊ + break; + case UIMSG_PlayerCreationClickReset: //Clear info + pWindow.Hint = pGlobalTXT_LocalizationStrings[666];//Ñáðàñûâàåò âñå ïàðàìåòðû è íàâûêè îòðÿäà. + pStr = pGlobalTXT_LocalizationStrings[667];//Êíîïêà Î÷èñòèòü + break; + case UIMSG_PlayerCreation_SelectAttribute: // Character info + pStr = pParty->pPlayers[pButton->msg_param].pName; + pWindow.Hint = pClassDescriptions[pParty->pPlayers[pButton->msg_param].classType]; + break; + } + if ( pButton->msg > UIMSG_44 && pButton->msg <= UIMSG_PlayerCreationRemoveDownSkill ) //Sellected skills info + { + pSkillId = pParty->pPlayers[pButton->msg_param].GetSkillIdxByOrder(pButton->msg - UIMSG_48); + pY = 0; + if ( (signed int)pSkillId < 37 ) + { + pSkillInfo = CharacterUI_GetSkillDescText(pButton->msg_param, (PLAYER_SKILL_TYPE)pSkillId); + strcpy(pTmpBuf2.data(), pSkillInfo); + pWindow.Hint = pTmpBuf2.data(); + pStr = pSkillNames[pSkillId]; + } + } + } + } + if ( pWindow.Hint ) + { + pHint = (char*)pWindow.Hint; + pWindow.Hint = 0; + pWindow.uFrameWidth = 384; + pWindow.uFrameHeight = 256; + pWindow.uFrameX = 128; + pWindow.uFrameY = 40; + pWindow.uFrameHeight = pFontSmallnum->CalcTextHeight(pHint, &pWindow, 24, 0) + 2 * LOBYTE(pFontLucida->uFontHeight) + 24; + pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1; + pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1; + pWindow.DrawMessageBox(0); + pWindow.uFrameX += 12; + pWindow.uFrameWidth -= 24; + pWindow.uFrameY += 12; + pWindow.uFrameHeight -= 12; + pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1; + pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1; + pColor = TargetColor(0xFF, 0xFF, 0x9B); + sprintf(pTmpBuf.data(), format_4E2D80, pColor, pStr);//"\f%05d%s\f00000\n" + pWindow.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf.data(), 3); + pWindow.DrawText(pFontSmallnum, 1, pFontLucida->uFontHeight, 0, pHint, 0, 0, 0); + } + break; + } + default: + { + break; + } + } + dword_507BF0_is_there_popup_onscreen = 1; + viewparams->bRedrawGameUI = 1; + } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/UIRest.cpp Wed Jun 19 17:18:35 2013 +0600 @@ -0,0 +1,197 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include <assert.h> + + +#include "GUIWindow.h" +#include "GUIFont.h" +#include "Party.h" +#include "AudioPlayer.h" +#include "Outdoor.h" +#include "LOD.h" +#include "Viewport.h" +#include "Time.h" +#include "texts.h" + +#include "mm7_data.h" + + + +//----- (0041F6C1) -------------------------------------------------------- +void RestUI_Load() +{ + Player *v0; // eax@10 + + if ( !dword_506F14 ) + pAudioPlayer->StopChannels(-1, -1); + if ( pCurrentScreen != SCREEN_GAME) + { + pGUIWindow_CurrentMenu->Release(); + pCurrentScreen = SCREEN_GAME; + viewparams->bRedrawGameUI = true; + } + pEventTimer->Pause(); + if ( dword_506F14 != 2 ) + GUIWindow::Create(518, 450, 0, 0, WINDOW_PressedButton2, (int)pBtn_Rest, 0); + _506F18_num_hours_to_sleep = 0; + dword_506F14 = 0; + uRestUI_FoodRequiredToRest = 2; + if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor) + uRestUI_FoodRequiredToRest = pOutdoor->GetNumFoodRequiredToRestInCurrentPos(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z); + if ( PartyHasDragon() ) + { + v0 = pParty->pPlayers;//[0].uClass; + while ( v0 <= &pParty->pPlayers[3] ) + { + ++v0; + if ( v0 > &pParty->pPlayers[3] ) + break; + } + if(v0->classType == PLAYER_CLASS_WARLOCK) + ++uRestUI_FoodRequiredToRest; + } + if ( CheckHiredNPCSpeciality(Porter) ) + --uRestUI_FoodRequiredToRest; + if ( CheckHiredNPCSpeciality(QuarterMaster) ) + uRestUI_FoodRequiredToRest -= 2; + if ( CheckHiredNPCSpeciality(Gypsy) ) + --uRestUI_FoodRequiredToRest; + if ( uRestUI_FoodRequiredToRest < 1 ) + uRestUI_FoodRequiredToRest = 1; + if ( !_stricmp(pCurrentMapName.data(), "d29.blv") && _449B57_test_bit(pParty->_quest_bits, 98) ) + uRestUI_FoodRequiredToRest = 0; + + ++pIcons_LOD->uTexturePacksCount; + if ( !pIcons_LOD->uNumPrevLoadedFiles ) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + + pCurrentScreen = SCREEN_REST; + _507CD4_RestUI_hourglass_anim_controller = 0; + uTextureID_RestUI_restmain = pIcons_LOD->LoadTexture("restmain", TEXTURE_16BIT_PALETTE); + uTextureID_RestUI_restb1 = pIcons_LOD->LoadTexture("restb1", TEXTURE_16BIT_PALETTE); + uTextureID_RestUI_restb2 = pIcons_LOD->LoadTexture("restb2", TEXTURE_16BIT_PALETTE); + uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE); + uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE); + uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE); + + LoadActualSkyFrame(); + + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Rest, 0, 0); + pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0); + pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour, 0, 'R', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0); + pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 'D', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0); + pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour, 0, 'H', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0); + pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes, 0, 'M', "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0); +} + +//----- (0041FA01) -------------------------------------------------------- +void RestUI_Draw() +{ + int live_characters; // esi@1 + unsigned int v3; // eax@15 + //char v4; // al@17 + bool v5; // eax@21 + GUIButton tmp_button; // [sp+8h] [bp-DCh]@19 + //double v7; // [sp+C4h] [bp-20h]@17 + float v8; // [sp+CCh] [bp-18h]@17 + __int64 v9; // [sp+D0h] [bp-14h]@17 + unsigned int am_pm_hours; // [sp+D8h] [bp-Ch]@9 + __int16 shadow_color; // [sp+DCh] [bp-8h]@1 + int text_color; // [sp+E0h] [bp-4h]@1 + + live_characters = 0; + text_color = TargetColor(10, 0, 0); + shadow_color = TargetColor(230, 214, 193); + for(int i=1; i<5; ++i) + if ( !pPlayers[i]->pConditions[Player::Condition_Dead] && !pPlayers[i]->pConditions[Player::Condition_Eradicated] && pPlayers[i]->sHealth > 0 ) + ++live_characters; + + if ( live_characters ) + { + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain)); + am_pm_hours = pParty->uCurrentHour; + dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem; + if ( (signed int)pParty->uCurrentHour <= 12 ) + { + if ( !am_pm_hours ) + am_pm_hours = 12; + } + else + { + am_pm_hours -= 12; + } + pRenderer->DrawTextureIndexed(16u, 26u, pTexture_RestUI_CurrentSkyFrame); + if ( pTexture_RestUI_CurrentHourglassFrame ) + { + pTexture_RestUI_CurrentHourglassFrame->Release(); + pIcons_LOD->SyncLoadedFilesCount(); + } + v3 = pEventTimer->uTimeElapsed + _507CD4_RestUI_hourglass_anim_controller; + _507CD4_RestUI_hourglass_anim_controller += pEventTimer->uTimeElapsed; + if ( (unsigned int)_507CD4_RestUI_hourglass_anim_controller >= 512 ) + { + v3 = 0; + _507CD4_RestUI_hourglass_anim_controller = 0; + } + v9 = v3; + v8 = (double)v3 / 512.0 * 120.0; + //v7 = v8 + 6.7553994e15; + HIDWORD(v9) = floorf(v8 + 0.5f);//LODWORD(v7); + hourglass_icon_idx = (int)floorf(v8 + 0.5f) % 256 + 1;//LOBYTE(v7) + 1; + //hourglass_icon_idx = v4; + if (hourglass_icon_idx >= 120 ) + hourglass_icon_idx = 1; + + sprintf(pTmpBuf.data(), "hglas%03d", hourglass_icon_idx); + pTexture_RestUI_CurrentHourglassFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf.data(), TEXTURE_16BIT_PALETTE); + pRenderer->DrawTextureIndexed(267, 159, pTexture_RestUI_CurrentHourglassFrame); + memset(&tmp_button, 0, sizeof(GUIButton)); + tmp_button.uX = 24; + tmp_button.uY = 154; + + tmp_button.uZ = 194; + tmp_button.uW = 190; + + tmp_button.uWidth = 171; + tmp_button.uHeight = 37; + + tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; + tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[183], pFontCreate, text_color, shadow_color); + tmp_button.pParent = 0; + sprintf(pTmpBuf.data(), "\r408%d", uRestUI_FoodRequiredToRest); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, 0, 164, text_color, pTmpBuf.data(), 0, 0, shadow_color); + pButton_RestUI_WaitUntilDawn->DrawLabel(pGlobalTXT_LocalizationStrings[237], pFontCreate, text_color, shadow_color); + pButton_RestUI_Wait1Hour->DrawLabel(pGlobalTXT_LocalizationStrings[239], pFontCreate, text_color, shadow_color); + pButton_RestUI_Wait5Minutes->DrawLabel(pGlobalTXT_LocalizationStrings[238], pFontCreate, text_color, shadow_color); + pButton_RestUI_Exit->DrawLabel(pGlobalTXT_LocalizationStrings[81], pFontCreate, text_color, shadow_color); + memset(&tmp_button, 0, sizeof(GUIButton)); + tmp_button.uX = 45; + tmp_button.uY = 199; + + tmp_button.uZ = 229; + tmp_button.uW = 228; + + tmp_button.uWidth = 185; + tmp_button.uHeight = 30; + + tmp_button.pParent = pButton_RestUI_WaitUntilDawn->pParent; + tmp_button.DrawLabel(pGlobalTXT_LocalizationStrings[236], pFontCreate, text_color, shadow_color); + tmp_button.pParent = 0; + v5 = (pParty->uCurrentHour >= 12 && pParty->uCurrentHour < 24)? 1:0; + sprintf(pTmpBuf.data(), "%d:%02d %s", am_pm_hours, pParty->uCurrentMinute, aAMPMNames[v5]); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, 368, 168, text_color, pTmpBuf.data(), 0, 0, shadow_color); + sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[56], pParty->uDaysPlayed + 1); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 190, text_color, pTmpBuf.data(), 0, 0, shadow_color); + sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[146], pParty->uCurrentMonth + 1); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 222, text_color, pTmpBuf.data(), 0, 0, shadow_color); + sprintf(pTmpBuf.data(), "%s\r190%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear); + pGUIWindow_CurrentMenu->DrawText(pFontCreate, 350, 254, text_color, pTmpBuf.data(), 0, 0, shadow_color); + if ( dword_506F14 ) + Sleep6Hours(); + } + else + GUIWindow::Create(pButton_RestUI_Exit->uX, pButton_RestUI_Exit->uY, 0, 0, WINDOW_CloseRestWindowBtn, + (int)pButton_RestUI_Exit, pGlobalTXT_LocalizationStrings[81]); // "Exit Rest" + } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/UISaveLoad.cpp Wed Jun 19 17:18:35 2013 +0600 @@ -0,0 +1,441 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include <assert.h> +#include <io.h> +#include "MM7.h" + +#include "Keyboard.h" + +#include "MapInfo.h" +#include "GUIWindow.h" +#include "GUIFont.h" +#include "Render.h" +#include "IndoorCamera.h" +#include "LOD.h" +#include "Allocator.h" +#include "SaveLoad.h" +#include "texts.h" + +#include "mm7_data.h" + + +//----- (004601B7) -------------------------------------------------------- +static void UI_DrawSaveLoad(bool save) +{ + unsigned __int16 v1; // bx@1 + unsigned int v2; // edi@4 + unsigned int v3; // eax@4 + unsigned int v4; // eax@8 + int v5; // edi@8 + unsigned int v6; // eax@8 + unsigned int pMapID; // eax@10 + signed __int64 v8; // qax@10 + unsigned int v9; // ebx@10 + unsigned __int64 v10; // qax@10 + __int64 v11; // qax@10 + char v12; // di@10 + unsigned __int64 v13; // qtt@10 + unsigned int v14; // ecx@10 + __int64 pOurHour; // qax@10 + int v16; // edi@10 + signed int pHour; // ebx@22 + //const char *v18; // ST14_4@32 + int v19; // eax@32 + const char *v20; // ST18_4@32 + int v21; // eax@32 + //const char *v22; // ST14_4@32 + int v23; // eax@32 + const char *pSlotName; // edi@36 + int v25; // eax@43 + GUIWindow pWindow; // [sp+Ch] [bp-78h]@8 + /*unsigned int Dst; // [sp+Ch] [bp-78h]@8 + unsigned int v27; // [sp+10h] [bp-74h]@8 + int v28; // [sp+14h] [bp-70h]@8 + int v29; // [sp+18h] [bp-6Ch]@8 + unsigned int v30; // [sp+1Ch] [bp-68h]@8 + unsigned int v31; // [sp+20h] [bp-64h]@8*/ + int pMinutes; // [sp+60h] [bp-24h]@10 + int pMonthNum; // [sp+68h] [bp-1Ch]@10 + unsigned int pSaveFiles; // [sp+70h] [bp-14h]@10 + __int64 pAMPM2; // [sp+74h] [bp-10h]@10 + int pYear; // [sp+7Ch] [bp-8h]@10 + //int a4; // [sp+80h] [bp-4h]@1 + int pFilesID; + + v1 = 255; + TargetColor(0xFF, 0xFF, 0xFF); + TargetColor(0xFF, 0xFF, 0x9B); + pRenderer->BeginScene(); + if ( GetCurrentMenuID() != MENU_SAVELOAD && GetCurrentMenuID() != MENU_LoadingProcInMainMenu ) + { + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); + if (save) + { + v2 = uTextureID_save_up; + v3 = uTextureID_LS_saveU; + } + else + { + v2 = uTextureID_load_up; + v3 = uTextureID_LS_loadU; + } + pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(v3)); + pRenderer->DrawTextureIndexed (18, 139, pIcons_LOD->GetTexture(v2)); + pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u)); + v1 = 255; + } + if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] ) + { + memset(&pWindow, 0, 0x54); + pWindow.uFrameX = pGUIWindow_CurrentMenu->uFrameX + 240; + v4 = pGUIWindow_CurrentMenu->uFrameY - pFontSmallnum->uFontHeight; + pWindow.uFrameWidth = 220; + v4 += 157; + pWindow.uFrameY = v4; + v5 = pFontSmallnum->uFontHeight; + pWindow.uFrameZ = pWindow.uFrameX + 219; + pWindow.uFrameHeight = v5; + pWindow.uFrameW = v5 + v4 - 1; + v6 = uLoadGameUI_SelectedSlot; + if (pSavegameThumbnails[uLoadGameUI_SelectedSlot].pPixels) + { + pRenderer->DrawTextureRGB(pGUIWindow_CurrentMenu->uFrameX + 276, pGUIWindow_CurrentMenu->uFrameY + 171, &pSavegameThumbnails[uLoadGameUI_SelectedSlot]); + v6 = uLoadGameUI_SelectedSlot; + } + pMapID = pMapStats->GetMapInfo(pSavegameHeader[v6].pLocationName); + pWindow.DrawTitleText(pFontSmallnum, 0, 0, 0, pMapStats->pInfos[pMapID].pName, 3); + v8 = (signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60; + pMinutes = (int)(((signed __int64)(pSavegameHeader[uLoadGameUI_SelectedSlot].uWordTime * 0.234375) / 60) >> 32); + v9 = v8; + v8 /= 60i64; + pAMPM2 = v8; + v10 = (unsigned int)v8 / 24; + pSaveFiles = v10; + v11 = (unsigned int)(v10 / 7); + v12 = v11; + LODWORD(v13) = (unsigned int)v11 >> 2; + HIDWORD(v13) = HIDWORD(v11); + pMonthNum = v13 % 12; + pYear = v13 / 12; + pMinutes = (int)__PAIR__(pMinutes, v9) % 60; + pOurHour = pAMPM2 % 24; + v14 = (unsigned __int64)(pAMPM2 % 24) >> 32; + LODWORD(pAMPM2) = pAMPM2 % 24; + HIDWORD(pOurHour) = pSaveFiles % 28; + pYear += game_starting_year; + v16 = v12 & 3; + pWindow.uFrameY = pGUIWindow_CurrentMenu->uFrameY + 261; + HIDWORD(pAMPM2) = v14 == 0 && ((signed int)v14 > 0 || (unsigned int)pOurHour >= 12) + && (signed int)v14 <= 0 && (v14 != 0 || (unsigned int)pOurHour < 24); + if ( v14 != 0 || ((signed int)v14 <= 0) && (unsigned int)pOurHour <= 12 ) + { + if ( !(v14 | (unsigned int)pOurHour) ) + { + pSaveFiles = 0; + pHour = 12; + goto LABEL_23; + } + } + else + { + v14 = (__PAIR__(v14, (unsigned int)pOurHour) - 12) >> 32; + LODWORD(pOurHour) = pOurHour - 12; + } + pHour = pOurHour; + pSaveFiles = v14; +LABEL_23: + auto day = aDayNames[HIDWORD(pOurHour) % 7]; + auto ampm = aAMPMNames[HIDWORD(pAMPM2)]; + auto month = aMonthNames[pMonthNum]; + //sprintf(pTmpBuf.data(), "%s %d:%02d%s\n%d %s %d", _d, v17, (int)32, _a, 3, _m, pFilesID); + sprintf(pTmpBuf.data(), "%s %d:%02d%s\n%d %s %d", day, pHour, pMinutes, ampm, 7 * v16 + HIDWORD(pOurHour) % 7 + 1, month, pYear); + pWindow.DrawTitleText(pFontSmallnum, 0, 0, 0, pTmpBuf.data(), 3u); + v1 = 255; + } + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) + { + pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + strcpy((char *)&pSavegameHeader + 100 * uLoadGameUI_SelectedSlot, (const char *)pKeyActionMap->pPressedKeysBuffer); + pMessageQueue_50CBD0->AddMessage(UIMSG_SaveGame, 0, 0); + } + else + { + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 == WINDOW_INPUT_CANCELLED) + pGUIWindow_CurrentMenu->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + } + if (GetCurrentMenuID() == MENU_LoadingProcInMainMenu) + { + //v18 = pGlobalTXT_LocalizationStrings[135]; + v19 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[135]);//"Çàãðóçêà" + pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v19 + 25, 220, 0, pGlobalTXT_LocalizationStrings[135], 0, 0, 0); + v20 = (const char *)(&pSavegameHeader[uLoadGameUI_SelectedSlot]); + v21 = pFontSmallnum->AlignText_Center(0xBA, (const char *)pSavegameHeader.data() + 100 * uLoadGameUI_SelectedSlot); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, v21 + 25, 0x106, 0, v20, 185, 0); + //v22 = pGlobalTXT_LocalizationStrings[165]; + v23 = pFontSmallnum->AlignText_Center(0xBA, pGlobalTXT_LocalizationStrings[165]);//"Ïîæàëóéñòà, ïîæîæäèòå" + pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, v23 + 25, 304, 0, pGlobalTXT_LocalizationStrings[165], 0, 0, 0); + } + else + { + if ( save ) + pSaveFiles = 40; + else + pSaveFiles = uNumSavegameFiles; + int a4 = 199; + pFilesID = pSaveListPosition; + pSlotName = (const char *)(&pSavegameHeader[pSaveListPosition]);//draw name for save slot + do + { + if ( pFilesID >= (signed int)pSaveFiles ) + break; + short clr; + HIDWORD(pAMPM2) = clr = (pFilesID == uLoadGameUI_SelectedSlot ? TargetColor(v1, v1, 0x64) : 0); + if ( pGUIWindow_CurrentMenu->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS || pFilesID != uLoadGameUI_SelectedSlot ) + { + pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 0x1B, a4, clr, pSlotName, 185, 0); + } + else + { + v25 = pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 0x1B, a4, clr, (const char *)pKeyActionMap->pPressedKeysBuffer, 175, 1); + pGUIWindow_CurrentMenu->DrawFlashingInputCursor(v25 + 27, a4, pFontSmallnum); + } + a4 += 21; + ++pFilesID; + pSlotName += 100; + } + while ( a4 < 346 ); + } + pRenderer->EndScene(); +} +// 6A0C9C: using guessed type int dword_6A0C9C; + +//----- (004606F7) -------------------------------------------------------- +void LoadUI_Draw() +{ + UI_DrawSaveLoad(false); +} + +//----- (004606FE) -------------------------------------------------------- +void SaveUI_Draw() +{ + UI_DrawSaveLoad(true); +} + + +//----- (0045E361) -------------------------------------------------------- +void LoadUI_Load(unsigned int uDialogueType) +{ + unsigned int v1; // ebp@5 + unsigned int v2; // eax@5 + //signed int v3; // ebp@11 + FILE *v4; // eax@14 + FILE *v5; // eax@18 + unsigned int v6; // eax@25 + GUIButton *v7; // eax@27 + const char *v8; // [sp-8h] [bp-26Ch]@25 + //char *v9; // [sp-4h] [bp-268h]@19 + enum TEXTURE_TYPE v10; // [sp-4h] [bp-268h]@25 + unsigned int uDialogueType_; // [sp+10h] [bp-254h]@1 + //RGBTexture *pTex; // [sp+10h] [bp-254h]@12 + //SavegameHeader *Dest; // [sp+14h] [bp-250h]@12 + //const char *Str1; // [sp+18h] [bp-24Ch]@12 + LODWriteableFile pLODFile; // [sp+1Ch] [bp-248h]@1 + int v16; // [sp+260h] [bp-4h]@1 + + uDialogueType_ = uDialogueType; + dword_6BE138 = -1; + pIcons_LOD->_inlined_sub2(); + + memset(pSavegameUsedSlots.data(), 0, sizeof(pSavegameUsedSlots)); + memset(pSavegameThumbnails.data(), 0, 45 * sizeof(RGBTexture)); + uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE); + uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE); + uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE); + uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); + uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); + uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); + if ( uDialogueType_ ) + { + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); + if ( pCurrentScreen == SCREEN_SAVEGAME ) + { + v1 = uTextureID_save_up; + v2 = uTextureID_LS_saveU; + } + else + { + v1 = uTextureID_load_up; + v2 = uTextureID_LS_loadU; + } + pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(v2)); + pRenderer->DrawTextureIndexed( 18, 141, pIcons_LOD->GetTexture(v1)); + pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u)); + } + else + { + pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX); + } + pGUIWindow_CurrentMenu = GUIWindow::Create(saveload_dlg_xs[uDialogueType_], saveload_dlg_ys[uDialogueType_], saveload_dlg_zs[uDialogueType_], + saveload_dlg_ws[uDialogueType_], WINDOW_MainMenu_Load, 0, 0); + pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);// "Reading..." + pRenderer->Present(); + pSavegameList->Initialize(0); + if ( pSaveListPosition > (signed int)uNumSavegameFiles ) + { + pSaveListPosition = 0; + uLoadGameUI_SelectedSlot = 0; + } + pLODFile.AllocSubIndicesAndIO(0x12C, 0); + assert(sizeof(SavegameHeader) == 0x64); + //v3 = 0; + for (uint i = 0; i < uNumSavegameFiles; ++i) + { + + sprintf(pTmpBuf.data(), "saves\\%s", pSavegameList->pFileList[i].pSaveFileName); + if (_access(pTmpBuf.data(), 6)) + { + pSavegameUsedSlots[i] = 0; + strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[72]); // "Empty" + continue; + } + pLODFile.LoadFile(pTmpBuf.data(), 1); + v4 = pLODFile.FindContainer("header.bin", true); + if ( v4 ) + fread(&pSavegameHeader[i], 0x64, 1, v4); + if ( !_stricmp(pSavegameList->pFileList[i].pSaveFileName, pGlobalTXT_LocalizationStrings[613]) )// "AutoSave.MM7" + strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[16]);// "Autosave" + v5 = pLODFile.FindContainer("image.pcx", true); + if ( !v5 ) + { + pSavegameUsedSlots[i] = 0; + strcpy(pSavegameList->pFileList[i].pSaveFileName, ""); + } + else + { + pSavegameThumbnails[i].LoadFromFILE(v5, 0, true); + pLODFile.CloseWriteFile(); + pSavegameUsedSlots[i] = 1; + } + } + + //LABEL_24: + pLODFile.FreeSubIndexAndIO(); + if ( pCurrentScreen == SCREEN_SAVEGAME ) + { + uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); + uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD",TEXTURE_16BIT_PALETTE); + } + else + { + uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); + uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_loadD",TEXTURE_16BIT_PALETTE); + } + uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE); + uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE); + pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 219, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 240, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 261, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 282, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 303, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 324, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0); + pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_SaveLoadBtn, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_LS_), 0); + pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_x_d), 0); + pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0); + pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 323, 17, 17, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0); +} + +//----- (0045E93E) -------------------------------------------------------- +void SaveUI_Load() +{ + unsigned int v0; // ebp@4 + unsigned int v1; // eax@4 + char *v3; // eax@7 + FILE *v4; // eax@11 + FILE *v5; // eax@11 + LODWriteableFile v11; // [sp+1Ch] [bp-248h]@1 + + ++pIcons_LOD->uTexturePacksCount; + if ( !pIcons_LOD->uNumPrevLoadedFiles ) + pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles; + memset(pSavegameUsedSlots.data(), 0, 0xB4u); + memset(&pSavegameThumbnails, 0, 0x708u); + uTextureID_loadsave = pIcons_LOD->LoadTexture("loadsave", TEXTURE_16BIT_PALETTE); + uTextureID_load_up = pIcons_LOD->LoadTexture("load_up", TEXTURE_16BIT_PALETTE); + uTextureID_save_up = pIcons_LOD->LoadTexture("save_up", TEXTURE_16BIT_PALETTE); + uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE); + uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE); + uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE); + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave)); + if ( pCurrentScreen == SCREEN_SAVEGAME ) + { + v0 = uTextureID_save_up; + v1 = uTextureID_LS_saveU; + } + else + { + v0 = uTextureID_load_up; + v1 = uTextureID_LS_loadU; + } + pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, pIcons_LOD->GetTexture(v1)); + pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu, pIcons_LOD->GetTexture(uTextureID_x_u)); + pRenderer->DrawTextureIndexed(0x12u, 0x8Du, pIcons_LOD->GetTexture(v0)); + pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0); + pRenderer->Present(); + pSavegameList->Initialize(1u); + v11.AllocSubIndicesAndIO(0x12Cu, 0); + //v2 = pSavegameUsedSlots; + // Dest = pSavegameHeader; + // this_ = pSavegameThumbnails; + // v8 = (char *)pSavegameList->pSavesNames; + for (uint i = 0; i < 40; ++i) + { + v3 = pSavegameList->pFileList[i].pSaveFileName; + if ( !*pSavegameList->pFileList[i].pSaveFileName ) + v3 = "1.mm7"; + sprintf(pTmpBuf.data(), "saves\\%s", v3); + if ( _access(pTmpBuf.data(), 0) || _access(pTmpBuf.data(), 6) ) + { + pSavegameUsedSlots[i] = 0; + strcpy(pSavegameHeader[i].pName, pGlobalTXT_LocalizationStrings[LOCSTR_EMPTY]); + } + else + { + v11.LoadFile(pTmpBuf.data(), 1); + v4 = v11.FindContainer("header.bin", 1); + fread(&pSavegameHeader[i], 100, 1u, v4); + v5 = v11.FindContainer("image.pcx", 1); + if ( v5 ) + { + pSavegameThumbnails[i].LoadFromFILE(v5, 0, 1u); + v11.CloseWriteFile(); + pSavegameUsedSlots[i] = 1; + } + else + { + pSavegameUsedSlots[i] = 0; + } + } + + } + + v11.FreeSubIndexAndIO(); + uTextureID_x_d = pIcons_LOD->LoadTexture("x_d", TEXTURE_16BIT_PALETTE); + uTextureID_LS_ = pIcons_LOD->LoadTexture("LS_saveD", TEXTURE_16BIT_PALETTE); + uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE); + uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE); + pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_SaveLoadButtons, 0, 0); + pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 218, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 238, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 258, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 278, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 298, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0); + pGUIWindow_CurrentMenu->CreateButton(21, 318, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0); + pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_SaveLoadBtn, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_LS_), 0); + pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_x_d), 0); + pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0); + pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 323, 17, 17, 1, 0, UIMSG_DownArrow, 34, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/UITransition.cpp Wed Jun 19 17:18:35 2013 +0600 @@ -0,0 +1,254 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include <assert.h> +#include <io.h> + +#include "mm7_data.h" +#include "VideoPlayer.h" +#include "MapInfo.h" +#include "GUIWindow.h" +#include "GUIFont.h" +#include "GUIProgressBar.h" +#include "Party.h" +#include "AudioPlayer.h" +#include "Outdoor.h" +#include "LOD.h" +#include "Time.h" +#include "stru159.h" +#include "Events2D.h" +#include "texts.h" +#include "UIHouses.h" + + + + + +//----- (00444839) -------------------------------------------------------- +void TransitionUI_Load(uint anim_id, uint exit_pic_id, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName) +{ + //unsigned int v9; // ebx@1 + //int v10; // edi@1 + //signed int v11; // eax@1 + unsigned int v12; // eax@6 + const char *v13; // ST0C_4@6 + unsigned int v14; // eax@8 + const char *v15; // eax@14 + unsigned int v16; // eax@16 + //unsigned int result; // eax@26 + const char *v18; // [sp-8h] [bp-40h]@9 + //const char *v19; // [sp-4h] [bp-3Ch]@2 + char *v20; // [sp-4h] [bp-3Ch]@9 + const char *v21; // [sp-4h] [bp-3Ch]@11 + char pContainer[40]; // [sp+Ch] [bp-2Ch]@1 + unsigned int v23; // [sp+34h] [bp-4h]@1 + + //v9 = a1; + //v10 = a2; + v23 = IndoorLocation::GetLocationIndex(pLocationName); + dword_59117C_teleportx = x; + dword_591178_teleporty = y; + dword_591174_teleportz = z; + dword_591170_teleport_directiony = directiony; + dword_59116C_teleport_directionx = directionx; + dword_591168_teleport_speedz = a8; + dword_591164_teleport_map_name = (char *)pLocationName; + uCurrentHouse_Animation = anim_id; + pEventTimer->Pause(); + pAudioPlayer->StopChannels(-1, -1); + + switch (pParty->alignment) + { + case PartyAlignment_Good: sprintfex(pContainer, "evt%02d-b", const_2()); break; + case PartyAlignment_Neutral: sprintfex(pContainer, "evt%02d", const_2()); break; + case PartyAlignment_Evil: sprintfex(pContainer, "evt%02d-c", const_2()); break; + default: assert(false); + } + + v12 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + v13 = pHouse_ExitPictures[exit_pic_id]; + pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v12]; + pTexture_outside = pIcons_LOD->LoadTexturePtr(v13, TEXTURE_16BIT_PALETTE); + if (anim_id) + { + if ( !v23 ) + //pVideoPlayer->OpenHouseMovie(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_0, 1u); + pVideoPlayer->OpenHouseMovie(pAnimatedRooms[p2DEvents[anim_id - 1].uAnimationID].video_name, 1); + } + else if ( !v23 ) + { + v14 = pMapStats->GetMapInfo(pCurrentMapName.data()); + if ( v14 ) + { + sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v14].pName); // "Leave %s" + goto LABEL_20; + } + v21 = pGlobalTXT_LocalizationStrings[79]; + goto LABEL_19; + } + v15 = pLocationName; + if ( *pLocationName == 48 ) + v15 = pCurrentMapName.data(); + v16 = pMapStats->GetMapInfo(v15); + if ( v16 ) + { + sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[v16].pName); + goto LABEL_20; + } + v21 = pGlobalTXT_LocalizationStrings[73]; +LABEL_19: + strcpy(sHouseName.data(), v21); +LABEL_20: + pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Transition, 0, sHouseName.data()); + //if ( BYTE1(pAnimatedRooms[p2DEvents_minus1___02[26 * v9]].field_C) ) + if ( pAnimatedRooms[p2DEvents[anim_id].uAnimationID].uRoomSoundId ) + PlayHouseSound(anim_id, HouseSound_Greeting); + if ( uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30 ) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0); + if ( v23 ) + uCurrentHouse_Animation = v23; +} + + + + +//----- (00444C8F) -------------------------------------------------------- +void TravelUI_Load() +{ + //signed int v0; // eax@1 + unsigned int v1; // eax@6 + GUIWindow *result; // eax@9 + //const char *v3; // [sp-4h] [bp-2Ch]@2 + char pContainer[32]; // [sp+0h] [bp-28h]@1 + + pEventTimer->Pause(); + + switch (pParty->alignment) + { + case PartyAlignment_Good: sprintfex(pContainer, "evt%02d-b", const_2()); break; + case PartyAlignment_Neutral: sprintfex(pContainer, "evt%02d", const_2()); break; + case PartyAlignment_Evil: sprintfex(pContainer, "evt%02d-c", const_2()); break; + default: assert(false); + } + + pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); + pTexture_outside = pIcons_LOD->LoadTexturePtr("outside", TEXTURE_16BIT_PALETTE); + v1 = pMapStats->GetMapInfo(pCurrentMapName.data()); + if ( v1 ) + sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s" + else + strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[79]);// "Exit" + pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_ChangeLocation, 0, sHouseName.data()); +} + + + +//----- (00444DCA) -------------------------------------------------------- +void TravelUI_Draw() +{ + unsigned int v0; // edi@1 + MapInfo *v1; // edi@2 + signed int v3; // eax@2 + int v4; // eax@5 + const char *v5; // [sp-Ch] [bp-90h]@3 + signed int v6; // [sp-8h] [bp-8Ch]@3 + GUIWindow v7; // [sp+Ch] [bp-78h]@1 + char pDestinationMapName[32]; // [sp+60h] [bp-24h]@1 + unsigned int v9; // [sp+80h] [bp-4h]@1 + + memcpy(&v7, pPrimaryWindow, sizeof(v7)); + v9 = pMapStats->GetMapInfo(pCurrentMapName.data()); + pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pDestinationMapName, 20); + v0 = pMapStats->GetMapInfo(pDestinationMapName); + pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background); + pRenderer->DrawTextureTransparent(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_right_panel_loop]); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside); + pRenderer->DrawTextureIndexed(0x22Cu, 0x1C3u, pIcons_LOD->GetTexture(uTextureID_x_x_u)); + pRenderer->DrawTextureIndexed(0x1DCu, 0x1C3u, pIcons_LOD->GetTexture(uTextureID_x_ok_u)); + if ( v0 ) + { + v1 = &pMapStats->pInfos[v0]; + v7.uFrameX = 493; + v7.uFrameWidth = 126; + v7.uFrameZ = 366; + v7.DrawTitleText(pFontCreate, 0, 4u, 0, v1->pName, 3); + v7.uFrameX = 483; + v7.uFrameWidth = 148; + v7.uFrameZ = 334; + v3 = GetTravelTime(); + if ( v3 == 1 ) + { + v6 = 1; + v5 = pGlobalTXT_LocalizationStrings[663]; // "It will take %d day to cross to %s." + } + else + { + v6 = v3; + v5 = pGlobalTXT_LocalizationStrings[128]; // "It will take %d days to travel to %s." + } + sprintfex(pTmpBuf.data(), v5, v6, v1->pName); + strcat(pTmpBuf.data(), "\n \n"); + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[126], pMapStats->pInfos[v9].pName); + strcat(pTmpBuf.data(), pTmpBuf2.data()); + v4 = pFontCreate->CalcTextHeight(pTmpBuf.data(), &v7, 0, 0); + v7.DrawTitleText(pFontCreate, 0, (212 - v4) / 2 + 101, 0, pTmpBuf.data(), 3); + _unused_5B5924_is_travel_ui_drawn = 1; + } +} + + + +//----- (00444A51) -------------------------------------------------------- +void TransitionUI_Draw() +{ + MapInfo *pMapInfo; // esi@5 + char *v1; // eax@6 + std::string v3; // [sp-18h] [bp-84h]@11 + unsigned int v4; // [sp-10h] [bp-7Ch]@12 + int v5; // [sp-Ch] [bp-78h]@12 + const char *v6; // [sp-8h] [bp-74h]@11 + signed int v7; // [sp-4h] [bp-70h]@11 + GUIWindow v8; // [sp+Ch] [bp-60h]@1 + unsigned int v9; // [sp+60h] [bp-Ch]@1 + unsigned int v10; // [sp+64h] [bp-8h]@1 + int a3; // [sp+6Bh] [bp-1h]@11 + + memcpy(&v8, pPrimaryWindow, sizeof(v8)); + v10 = pMapStats->GetMapInfo(pCurrentMapName.data()); + v9 = IndoorLocation::GetLocationIndex(dword_591164_teleport_map_name); + pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, pIcons_LOD->GetTexture(uTextureID_50795C)); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside); + uTextureID_right_panel_loop = uTextureID_right_panel; + pRenderer->DrawTextureTransparent(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel)); + pRenderer->DrawTextureIndexed(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u)); + pRenderer->DrawTextureIndexed(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u)); + if ( (pVideoPlayer->AnyMovieLoaded() || v9) && *dword_591164_teleport_map_name != ' ' ) + v10 = pMapStats->GetMapInfo(dword_591164_teleport_map_name); + pMapInfo = &pMapStats->pInfos[v10]; + v8.uFrameX = 493; + v8.uFrameWidth = 126; + v8.uFrameZ = 366; + v8.DrawTitleText(pFontCreate, 0, 5u, 0, pMapInfo->pName, 3); + v8.uFrameX = 483; + v8.uFrameWidth = 148; + v8.uFrameZ = 334; + + v1 = ""; + if ( uCurrentHouse_Animation ) + { + v1 = pTransitionStrings[uCurrentHouse_Animation]; + v4 = (212 - pFontCreate->CalcTextHeight(v1, &v8, 0, 0)) / 2 + 101; + v8.DrawTitleText(pFontCreate, 0, v4, 0, v1, 3); + } + else if ( v10 ) + { + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[409], pMapInfo->pName);// "Do you wish to leave %s?" + v4 = (212 - pFontCreate->CalcTextHeight(pTmpBuf.data(), &v8, 0, 0)) / 2 + 101; + v8.DrawTitleText(pFontCreate, 0, v4, 0, pTmpBuf.data(), 3); + } + else assert(false); + + _unused_5B5924_is_travel_ui_drawn = true; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/UiGame.cpp Wed Jun 19 17:18:35 2013 +0600 @@ -0,0 +1,2977 @@ +#ifdef _MSC_VER +#define _CRT_SECURE_NO_WARNINGS +#endif + +#include <assert.h> + +#include "Texture.h" +#include "MM7.h" + +#include "Mouse.h" +#include "Keyboard.h" +#include "mm7_data.h" + +#include "Vis.h" +#include "MapInfo.h" +#include "Game.h" +#include "GUIWindow.h" +#include "GUIFont.h" +#include "Party.h" +#include "AudioPlayer.h" +#include "Outdoor.h" +#include "LOD.h" +#include "Actor.h" +#include "Viewport.h" +#include "SpriteObject.h" +#include "ObjectList.h" +#include "DecorationList.h" +#include "PlayerFrameTable.h" +#include "stru123.h" +#include "Time.h" +#include "IconFrameTable.h" +#include "TurnEngine.h" +#include "texts.h" +#include "UIHouses.h" +#include "BSPModel.h" + + + + + +int uTextureID_GameUI_CharSelectionFrame; // 50C98C + + + + + +//----- (00421D00) -------------------------------------------------------- +void __fastcall GameUI_OnPlayerPortraitLeftClick(unsigned int uPlayerID) +{ + //unsigned int v1; // esi@1 + //int v2; // eax@2 + //Player *v3; // ecx@2 + //Player *v4; // ecx@5 + unsigned int v5; // [sp-4h] [bp-10h]@21 + + //v1 = uPlayerID; + auto player = &pParty->pPlayers[uPlayerID - 1]; + if (pParty->pPickedItem.uItemID) + { + //v3 = player; + if (auto slot = player->AddItem(-1, pParty->pPickedItem.uItemID)) + { + memcpy(&player->pInventoryItems[slot-1], &pParty->pPickedItem, 0x24u); + viewparams->bRedrawGameUI = true; + pMouse->RemoveHoldingItem(); + return; + } + + if (!player->CanAct()) + { + player = pPlayers[uActiveCharacter]; + } + if(player->CanAct() || !pPlayers[uActiveCharacter]->CanAct()) + player->PlaySound(SPEECH_NoRoom, 0); + } + +//LABEL_9: + if (pCurrentScreen == SCREEN_GAME) + { + viewparams->bRedrawGameUI = true; + if ( uActiveCharacter != uPlayerID ) + //goto LABEL_27; + { + if ( pPlayers[uPlayerID]->uTimeToRecovery ) + return; + + uActiveCharacter = uPlayerID; + return; + } + v5 = 7; +//LABEL_22: + pGUIWindow_CurrentMenu = CharacterUI_Initialize(v5); + return; + } + if ( pCurrentScreen == SCREEN_SPELL_BOOK ) + return; + if ( pCurrentScreen == SCREEN_CHEST ) + { +//LABEL_23: + viewparams->bRedrawGameUI = true; + if ( uActiveCharacter == uPlayerID ) + { + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; + pCurrentScreen = SCREEN_CHEST_INVENTORY; + //goto LABEL_28; + uActiveCharacter = uPlayerID; + return; + } +//LABEL_27: + if ( pPlayers[uPlayerID]->uTimeToRecovery ) + return; + //goto LABEL_28; + uActiveCharacter = uPlayerID; + return; + } + if ( pCurrentScreen != SCREEN_HOUSE ) + { + if ( pCurrentScreen == SCREEN_E ) + { +//LABEL_28: + uActiveCharacter = uPlayerID; + return; + } + if ( pCurrentScreen != SCREEN_CHEST_INVENTORY ) + { + viewparams->bRedrawGameUI = true; + uActiveCharacter = uPlayerID; + if ( pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] == 102 ) + FillAwardsData(); + return; + } + //goto LABEL_23; + viewparams->bRedrawGameUI = true; + if ( uActiveCharacter == uPlayerID ) + { + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; + pCurrentScreen = SCREEN_CHEST_INVENTORY; + //goto LABEL_28; + uActiveCharacter = uPlayerID; + return; + } +//LABEL_27: + if ( pPlayers[uPlayerID]->uTimeToRecovery ) + return; + //goto LABEL_28; + uActiveCharacter = uPlayerID; + return; + } + if ( window_SpeakInHouse->receives_keyboard_input_2 == WINDOW_INPUT_IN_PROGRESS) + return; + viewparams->bRedrawGameUI = true; + if ( uActiveCharacter != uPlayerID ) + //goto LABEL_28; + uActiveCharacter = uPlayerID; + return; + if (dialog_menu_id == HOUSE_DIALOGUE_SHOP_BUY_STANDARD || dialog_menu_id == HOUSE_DIALOGUE_SHOP_6) + { + __debugbreak(); // fix indexing + pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; + v5 = 14; + //goto LABEL_22; + pGUIWindow_CurrentMenu = CharacterUI_Initialize(v5); + return; + } +} +// 4E28F8: using guessed type int pCurrentScreen; +// F8B19C: using guessed type int dword_F8B19C; + +//----- (00416B01) -------------------------------------------------------- +void GameUI_DrawNPCPopup(void *_this)//PopupWindowForBenefitAndJoinText +{ + int v1; // edi@2 + int v2; // ecx@2 + NPCData *v3; // eax@2 + NPCData *v4; // esi@7 + NPCData *v5; // eax@16 + NPCData *v6; // esi@16 + const CHAR *v7; // eax@18 + unsigned int v8; // eax@25 + unsigned int v9; // eax@25 + const char *v10; // ST14_4@26 + char *v11; // esi@26 + const char *v12; // ST18_4@27 + unsigned __int16 v13; // ax@28 + char *v14; // eax@28 + GUIWindow a1; // [sp+Ch] [bp-60h]@23 + int a2; // [sp+60h] [bp-Ch]@16 + void *v17; // [sp+64h] [bp-8h]@1 + LPCSTR lpsz; // [sp+68h] [bp-4h]@6 + + v17 = _this; + if ( bNoNPCHiring != 1 ) + { + v1 = 0; + v2 = 0; + v3 = pParty->pHirelings; + /*do + { + if ( v3->pName ) + pTmpBuf[v1++] = v2; + ++v3; + ++v2; + } + while ( (signed int)v3 < (signed int)&pParty->pPickedItem );*/ + for (int i = 0; i < 2; ++i) + { + if (pParty->pHirelings[i].pName) + pTmpBuf[v1++] = i; + } + lpsz = 0; + if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) + { + /*v4 = pNPCStats->pNewNPCData; + do + { + if ( v4->uFlags & 0x80 + && (!pParty->pHirelings[0].pName || strcmp(v4->pName, pParty->pHirelings[0].pName)) + && (!pParty->pHirelings[1].pName || strcmp(v4->pName, pParty->pHirelings[1].pName)) ) + pTmpBuf[v1++] = (char)lpsz + 2; + ++lpsz; + ++v4; + } + while ( (signed int)lpsz < (signed int)pNPCStats->uNumNewNPCs );*/ + for (int i = 0; i < pNPCStats->uNumNewNPCs; ++i) + { + if (pNPCStats->pNewNPCData[i].Hired()) + { + if (!pParty->pHirelings[0].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[0].pName)) + { + if (!pParty->pHirelings[1].pName || strcmp((char *)pNPCStats->pNewNPCData[i].pName, (char *)pParty->pHirelings[1].pName)) + pTmpBuf[v1++] = i + 2; + } + } + } + } + if ( (signed int)((char *)v17 + (unsigned __int8)pParty->field_709) < v1 ) + { + sDialogue_SpeakingActorNPC_ID = -1 - (unsigned __int8)pParty->field_709 - (int)v17; + v5 = GetNewNPCData(sDialogue_SpeakingActorNPC_ID, &a2); + v6 = v5; + if ( v5 ) + { + if ( a2 == 57 ) + v7 = pNPCTopics[512].pText; // Baby dragon + else + v7 = (const CHAR *)pNPCStats->pProfessions[v5->uProfession].pBenefits; + lpsz = v7; + if ( !v7 ) + { + lpsz = (LPCSTR)pNPCStats->pProfessions[v5->uProfession].pJoinText; + if ( !lpsz ) + lpsz = ""; + } + a1.Hint = 0; + a1.uFrameX = 38; + a1.uFrameY = 60; + a1.uFrameWidth = 276; + a1.uFrameZ = 313; + a1.uFrameHeight = pFontArrus->CalcTextHeight(lpsz, &a1, 0, 0) + + 2 * LOBYTE(pFontArrus->uFontHeight) + + 24; + if ( (signed int)a1.uFrameHeight < 130 ) + a1.uFrameHeight = 130; + a1.uFrameWidth = 400; + a1.uFrameZ = a1.uFrameX + 399; + a1.DrawMessageBox(0); + sprintfex(pTmpBuf2.data(), "NPC%03d", v6->uPortraitID); + v8 = pIcons_LOD->LoadTexture(pTmpBuf2.data(), TEXTURE_16BIT_PALETTE); + pRenderer->DrawTextureIndexed( + a1.uFrameX + 22, + a1.uFrameY + 36, + (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0)); + v9 = v6->uProfession; + if ( v9 ) + { + v10 = v6->pName; + v11 = pTmpBuf.data(); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], v10, aNPCProfessionNames[v9]); + } + else + { + v12 = v6->pName; + v11 = pTmpBuf.data(); + strcpy(pTmpBuf.data(), v12); + } + v13 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u); + a1.uFrameWidth -= 24; + a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1; + v14 = BuilDialogueString((char *)lpsz, uActiveCharacter - 1, 0, 0, 0, 0); + a1.DrawText(pFontArrus, 100, 36, 0, v14, 0, 0, 0); + } + } + } +} + + + +//----- (00445D4A) -------------------------------------------------------- +void GameUI_InitializeDialogue(Actor *actor, int bPlayerSaysHello) +{ + NPCData *pNPCInfo; // ebp@1 + int v9; // esi@8 + int pNumberContacts; // eax@11 + char pContainer[32]; // [sp+14h] [bp-28h]@3 + + dword_A74CDC = -1; + dword_AE336C = -1; + pEventTimer->Pause(); + pMiscTimer->Pause(); + pAudioPlayer->StopChannels(-1, -1); + uDialogueType = 0; + sDialogue_SpeakingActorNPC_ID = actor->sNPC_ID; + pDialogue_SpeakingActor = actor; + pNPCInfo = GetNPCData(actor->sNPC_ID); + if ( (pNPCInfo->uFlags & 3) != 2 ) + pNPCInfo->uFlags = pNPCInfo->uFlags + 1; + + switch (pParty->alignment) + { + case PartyAlignment_Good: sprintfex(pContainer, "evt%02d-b", const_2()); break; + case PartyAlignment_Neutral: sprintfex(pContainer, "evt%02d", const_2()); break; + case PartyAlignment_Evil: sprintfex(pContainer, "evt%02d-c", const_2()); break; + } + + pDialogueNPCCount = 0; + uNumDialogueNPCPortraits = 1; + pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); + sprintfex(pContainer, "npc%03u", pNPCInfo->uPortraitID); + v9 = 0; + pDialogueNPCPortraits[0] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); + dword_591084 = areWeLoadingTexture; + uTextureID_right_panel_loop = uTextureID_right_panel; + if ( !pNPCInfo->Hired() && pNPCInfo->Location2D >= 0 ) + { + if ( (signed int)pParty->GetPartyFame() <= pNPCInfo->fame + || (pNumberContacts = pNPCInfo->uFlags & 0xFFFFFF7F, (pNumberContacts & 0x80000000u) != 0) ) + { + v9 = 1; + } + else + { + if ( pNumberContacts > 1 ) + { + if ( pNumberContacts == 2 ) + { + v9 = 3; + } + else + { + if ( pNumberContacts != 3 ) + { + if ( pNumberContacts != 4 ) + v9 = 1; + } + else + { + v9 = 2; + } + } + } + else if ( pNPCInfo->rep ) + { + v9 = 2; + } + } + } + if (sDialogue_SpeakingActorNPC_ID < 0) + v9 = 4; + pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_Dialogue, v9, 0);//pNumberContacts = 1, v9 = 0; pNumberContacts = 2, v9 = 3; + if (pNPCInfo->Hired()) + { + if ( !pNPCInfo->bHasUsedTheAbility ) + { + if ( pNPCInfo->uProfession >= 10 ) + { + if ( pNPCInfo->uProfession <= 12 || pNPCInfo->uProfession > 32 && (pNPCInfo->uProfession <= 34 + || pNPCInfo->uProfession > 38 && (pNPCInfo->uProfession <= 43 || pNPCInfo->uProfession == 52)) ) + { + pDialogueWindow->CreateButton(480, 250, 140, LOBYTE(pFontArrus->uFontHeight) - 3, 1, 0, UIMSG_SelectNPCDialogueOption, 9, 0, "", 0); + pDialogueWindow->_41D08F_set_keyboard_control_group(4, 1, 0, 1); + } + } + } + } + + pDialogueWindow->CreateButton( 61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0); + pDialogueWindow->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0); + pDialogueWindow->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0); + pDialogueWindow->CreateButton(407, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0); + + if (bPlayerSaysHello && uActiveCharacter && !pNPCInfo->Hired()) + { + if (pParty->uCurrentHour < 5 || pParty->uCurrentHour > 21) + pPlayers[uActiveCharacter]->PlaySound(SPEECH_GoodEvening, 0); + else + pPlayers[uActiveCharacter]->PlaySound(SPEECH_GoodDay, 0); + } +} + +//----- (00445350) -------------------------------------------------------- +void GameUI_DrawDialogue() +{ + NPCData *pNPC; // ebx@2 + int pGreetType; // eax@2 + unsigned __int16 v2; // di@2 + //unsigned int v3; // eax@2 + char *v4; // esi@3 + //int v5; // eax@11 + //char *v6; // ecx@13 + //char *v7; // eax@16 + //unsigned int v8; // edi@19 + //char *v9; // ecx@27 + char *v10; // eax@29 + //int v11; // eax@30 + int v12; // esi@39 + char *v13; // eax@41 + GUIButton *v14; // eax@43 + //GUIButton *v15; // edi@43 + signed int v16; // eax@44 + //unsigned int v23; // eax@53 + //const char *v24; // eax@59 + //unsigned __int16 v30; // cx@83 + int v31; // ecx@86 + int v32; // ebx@93 + unsigned int v33; // eax@93 + GUIWindow *v34; // ecx@93 + int v35; // esi@93 + int i; // eax@93 + GUIButton *v37; // eax@94 + int v38; // eax@95 + signed int v39; // esi@99 + signed int v40; // eax@102 + unsigned int v41; // ebx@102 + int v42; // edi@102 + GUIButton *v43; // esi@103 + int v44; // eax@104 + unsigned int v45; // ecx@104 + unsigned __int16 *v46; // edx@104 + unsigned __int16 v47; // ax@104 + GUIWindow pWindow; // [sp+4h] [bp-110h]@39 + int v49; // [sp+Ch] [bp-108h]@39 + int v50; // [sp+14h] [bp-100h]@39 + GUIWindow v51; // [sp+58h] [bp-BCh]@2 + GUIWindow v52; // [sp+ACh] [bp-68h]@42 + char *Str; // [sp+100h] [bp-14h]@104 + //int v54; // [sp+104h] [bp-10h]@2 + //unsigned __int16 *v55; // [sp+108h] [bp-Ch]@82 + GUIFont *pOutString; // [sp+10Ch] [bp-8h]@39 + char *pInString=NULL; // [sp+110h] [bp-4h]@32 + + if ( !pDialogueWindow ) + return; + + memcpy(&v51, pDialogueWindow, sizeof(v51)); + pNPC = GetNPCData(sDialogue_SpeakingActorNPC_ID); + pGreetType = GetGreetType(sDialogue_SpeakingActorNPC_ID); + v51.uFrameWidth -= 10; + v51.uFrameZ -= 10; + //v54 = v1; + TargetColor(0xFFu, 0xFFu, 0xFFu); + TargetColor(0xE1u, 0xCDu, 0x23u); + v2 = TargetColor(0x15u, 0x99u, 0xE9u); + pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background); + pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_right_panel_loop != -1 ? &pIcons_LOD->pTextures[uTextureID_right_panel_loop] : 0)); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0)); + pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pDialogueNPCPortraits[0]); + + if (pNPC->uProfession) + { + assert(pNPC->uProfession < sizeof(aNPCProfessionNames) / sizeof(*aNPCProfessionNames.data())); // sometimes buffer overflows; errors emerge both here and in dialogue text + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[429], pNPC->pName, aNPCProfessionNames[pNPC->uProfession]);//^Pi[%s] %s + } + else + strcpy(pTmpBuf.data(), pNPC->pName); + + v51.DrawTitleText(pFontArrus, 483, 112, v2, pTmpBuf.data(), 3); + pParty->GetPartyFame(); + + pInString = nullptr; + switch (uDialogueType) + { + case DIALOGUE_13: + pInString = BuilDialogueString(pNPCStats->pProfessions[pNPC->uProfession - 1].pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + break; + + case DIALOGUE_PROFESSION_DETAILS: + { + auto prof = pNPCStats->pProfessions + pNPC->uProfession - 1; + + if (dialogue_show_profession_details) + pInString = BuilDialogueString(prof->pBenefits, uActiveCharacter - 1, 0, 0, 0, 0); + else if (pNPC->Hired()) + pInString = BuilDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); + else + pInString = BuilDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + } + break; + + + case DIALOGUE_ARENA_WELCOME: + pInString = pGlobalTXT_LocalizationStrings[574]; // "Welcome to the Arena of Life and Death. Remember, you are only allowed one arena combat per visit. To fight an arena battle, select the option that best describes your abilities and return to me- if you survive:" + break; + + case DIALOGUE_ARENA_FIGHT_NOT_OVER_YET: + pInString = pGlobalTXT_LocalizationStrings[577]; //"Get back in there you wimps:" + break; + + case DIALOGUE_ARENA_REWARD: + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[576], gold_transaction_amount);// "Congratulations on your win: here's your stuff: %u gold." + pInString = pTmpBuf.data(); + break; + + case DIALOGUE_ARENA_ALREADY_WON: + pInString = pGlobalTXT_LocalizationStrings[582]; // "You already won this trip to the Arena:" + break; + + default: + if (uDialogueType > DIALOGUE_18 && uDialogueType < DIALOGUE_23 && !byte_5B0938[0]) + { + pInString = (char *)current_npc_text; + } + else if (pGreetType == 1)//QuestNPC_greet + { + if (pNPC->greet) + { + if ((pNPC->uFlags & 3) == 2) + pInString = pNPCStats->pNPCGreetings[pNPC->greet - 1].pGreeting2; + else + pInString = pNPCStats->pNPCGreetings[pNPC->greet - 1].pGreeting1; + } + } + else if (pGreetType == 2)//HiredNPC_greet + { + auto prof = pNPCStats->pProfessions + pNPC->uProfession - 1; + + if (pNPC->Hired()) + pInString = BuilDialogueString(prof->pDismissText, uActiveCharacter - 1, 0, 0, 0, 0); + else + pInString = BuilDialogueString(prof->pJoinText, uActiveCharacter - 1, 0, 0, 0, 0); + } + break; + } + + if (pInString) + { + pWindow.uFrameWidth = game_viewport_width; + pWindow.uFrameZ = 452; + auto font = pFontArrus; + v12 = pFontArrus->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; + if ( 352 - v12 < 8 ) + { + font = pFontCreate; + v12 = pFontCreate->CalcTextHeight(pInString, &pWindow, 13, 0) + 7; + } + if (uTextureID_Leather != -1) + pRenderer->_4A6A68(8, 352 - v12, &pIcons_LOD->pTextures[uTextureID_Leather], pIcons_LOD->pTextures[uTextureID_Leather].uTextureHeight - v12); + pRenderer->DrawTextureIndexed(8u, 347 - v12, pTexture_591428); + v13 = FitTextInAWindow(pInString, font, &pWindow, 0xDu, 0); + pDialogueWindow->DrawText(font, 13, 354 - v12, 0, v13, 0, 0, 0); + } + + + memcpy(&v52, pDialogueWindow, sizeof(v52)); + v52.uFrameX = 483; + v52.uFrameWidth = 148; + v52.uFrameZ = 334; + for (int i = v52.pStartingPosActiveItem; + i < v52.pStartingPosActiveItem + v52.pNumPresenceButton; ++i) + { + v14 = v52.GetControl(i); + //v15 = v14; + if ( !v14 ) + break; + v16 = v14->msg_param; + + if ( v16 > 88 ) + v14->pButtonName[0] = 0; + else if (v16 == 88) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[581]); // Lord + else if (v16 == 87) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[580]); // Knight + else if (v16 == 86) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[579]); // Squire + else if (v16 == 85) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[578]); // Page + else if (v16 == 77) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[407]); // Details + else if (v16 == 76) + { + if (pNPC->Hired()) + sprintf(v14->pButtonName, (const char*)pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s + else + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[406]); // Hire + } + else if (v16 == 24) + { + __debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->evt_F - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->msg_param = 0; + } + else + strcpy(v14->pButtonName, topic); + } + else if (v16 == 9) + strcpy(v14->pButtonName, GetProfessionActionText(pNPC->uProfession)); + else if (v16 == 19) + { + // __debugbreak(); // learn conditions of this event Scavenger Hunt + auto topic = pNPCTopics[pNPC->evt_A - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->msg_param = 0; + } + else strcpy(v14->pButtonName, topic); + } + else if (v16 == 20) + { + //__debugbreak(); // learn conditions of this event instruments + auto topic = pNPCTopics[pNPC->evt_B - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->msg_param = 0; + } + else strcpy(v14->pButtonName, topic); + } + else if (v16 == 21) + { + //__debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->evt_C - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->msg_param = 0; + } + else strcpy(v14->pButtonName, topic); + } + else if (v16 == 22) + { + //__debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->evt_D - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->msg_param = 0; + } + else strcpy(v14->pButtonName, topic); + } + else if (v16 == 23) + { + //__debugbreak(); // learn conditions of this event + auto topic = pNPCTopics[pNPC->evt_E - 1].pTopic;//(&dword_721660)[8 * v23]; + if (!topic) + { + v14->pButtonName[0] = 0; + v14->msg_param = 0; + } + else strcpy(v14->pButtonName, topic); + } + else if (v16 == 13) + { + if (pNPC->Hired()) + sprintf(v14->pButtonName, pGlobalTXT_LocalizationStrings[408], pNPC->pName); // Release %s + else + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[122]); // Join + } + else + v14->pButtonName[0] = 0; + + + if (pParty->field_7B5_in_arena_quest && pParty->field_7B5_in_arena_quest != -1) + { + int num_dead_actors = 0; + pInString = 0; + for (uint i = 0; i < uNumActors; ++i) + { + if (pActors[i].uAIState == Dead || pActors[i].uAIState == Removed || + pActors[i].uAIState == Disabled) + ++num_dead_actors; + else + { + int sumonner_type = PID_TYPE(pActors[i].uSummonerID); + if (sumonner_type == OBJECT_Player) + ++num_dead_actors; + } + } + if (num_dead_actors == uNumActors) + strcpy(v14->pButtonName, pGlobalTXT_LocalizationStrings[658]); // Collect Prize + } + } + + + v32 = 0; + //pInString = (char *)TargetColor(0xFFu, 0xFFu, 0xFFu); + v33 = TargetColor(0xE1u, 0xCDu, 0x23u); + v34 = pDialogueWindow; + //v54 = v33; + v35 = pDialogueWindow->pStartingPosActiveItem; + for ( i = v35 + pDialogueWindow->pNumPresenceButton; v35 < i; i = pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ) + { + v37 = v34->GetControl(v35); + if ( !v37 ) + { + v34 = pDialogueWindow; + break; + } + v38 = pFontArrus->CalcTextHeight(v37->pButtonName, &v52, 0, 0); + v34 = pDialogueWindow; + v32 += v38; + ++v35; + } + v39 = v34->pNumPresenceButton; + if ( v39 ) + { + pOutString = (GUIFont *)((174 - v32) / v39); + if ( (174 - v32) / v39 > 32 ) + pOutString = (GUIFont *)32; + int v55 = 1; + v40 = 174 - (int)pOutString * v39 - v32; + v41 = v34->pStartingPosActiveItem; + v42 = v40 / 2 - (signed int)pOutString / 2 + 138; + if ( (signed int)v41 < (signed int)(v41 + v39) ) + { + do + { + v43 = v34->GetControl(v41); + if ( !v43 ) + break; + v43->uY = (unsigned int)((char *)pOutString + v42); + Str = v43->pButtonName; + v44 = pFontArrus->CalcTextHeight(v43->pButtonName, &v52, 0, 0); + v45 = v43->uY; + v46 = (unsigned short *)v55; + v43->uHeight = v44; + v42 = v45 + v44 - 1; + v43->uW = v42; + v47 = v33; + if ( (unsigned __int16 *)pDialogueWindow->pCurrentPosActiveItem != v46 ) + v47 = TargetColor(0xFFu, 0xFFu, 0xFFu); + v52.DrawTitleText(pFontArrus, 0, v45, v47, Str, 3u); + v34 = pDialogueWindow; + ++v55; + ++v41; + } + while ( (signed int)v41 < pDialogueWindow->pNumPresenceButton + pDialogueWindow->pStartingPosActiveItem ); + } + } + pRenderer->DrawTextureIndexed(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId)); +} + + + +//----- (00444FBE) -------------------------------------------------------- +void GameUI_DrawBranchlessDialogue() +{ + //GUIFont *v0; // esi@1 + int v1; // esi@4 + char *v2; // eax@6 + int v3; // edi@12 + char Str[200]; // [sp+Ch] [bp-120h]@12 + GUIWindow v5; // [sp+D4h] [bp-58h]@4 + GUIFont *pFont; // [sp+128h] [bp-4h]@1 + + pFont = pFontArrus; + if ( current_npc_text && !byte_5B0938[0] ) + strcpy(byte_5B0938.data(), current_npc_text); + v5.uFrameWidth = game_viewport_width; + v5.uFrameZ = 452; + v1 = pFontArrus->CalcTextHeight(byte_5B0938.data(), &v5, 12, 0) + 7; + if ( 352 - v1 < 8 ) + { + pFont = pFontCreate; + v1 = pFontCreate->CalcTextHeight(byte_5B0938.data(), &v5, 12, 0) + 7; + } + pRenderer->_4A6A68(8, 352 - v1, + pIcons_LOD->GetTexture(uTextureID_Leather), + pIcons_LOD->GetTexture(uTextureID_Leather)->uTextureHeight - v1); + pRenderer->DrawTextureIndexed(8, 347 - v1, pTexture_591428); + v2 = FitTextInAWindow(byte_5B0938.data(), pFont, &v5, 0xCu, 0); + pGUIWindow2->DrawText(pFont, 12, 354 - v1, 0, v2, 0, 0, 0); + pRenderer->DrawTextureRGB(0, 0x160u, pTexture_StatusBar); + if ( pGUIWindow2->receives_keyboard_input_2 != WINDOW_INPUT_IN_PROGRESS) + { + if ( pGUIWindow2->receives_keyboard_input_2 == WINDOW_INPUT_CONFIRMED) + { + pGUIWindow2->receives_keyboard_input_2 = WINDOW_INPUT_NONE; + strcpy(GameUI_Footer_TimedString.data(), (const char *)pKeyActionMap->pPressedKeysBuffer); +LABEL_16: + sub_4452BB(); + return; + } + if ( pGUIWindow2->receives_keyboard_input_2 != WINDOW_INPUT_CANCELLED) + return; + pGUIWindow2->receives_keyboard_input_2 = WINDOW_INPUT_NONE; +LABEL_15: + memset(GameUI_Footer_TimedString.data(), 0, 0xC8u); + goto LABEL_16; + } + if ( pGUIWindow2->ptr_1C == (void *)26 ) + { + sprintf(Str, "%s %s", GameUI_Footer_TimedString, pKeyActionMap->pPressedKeysBuffer); + v3 = pFontLucida->GetLineWidth(Str); + pGUIWindow2->DrawText(pFontLucida, 13, 357, 0, Str, 0, 0, 0); + pGUIWindow2->DrawFlashingInputCursor(v3 + 13, 357, pFontLucida); + return; + } + if ( pKeyActionMap->pPressedKeysBuffer[0] ) + { + pKeyActionMap->SetWindowInputStatus(0); + goto LABEL_15; + } +} + + +//----- (004443D5) -------------------------------------------------------- +const char *GameUI_GetMinimapHintText() +{ + int v0; // ST20_4@1 + unsigned int v1; // esi@1 + signed int v2; // ebx@1 + double v3; // st7@1 + int v4; // esi@3 + int v5; // edi@4 + int v6; // eax@4 + int v7; // eax@4 + BSPModel *v8; // ecx@4 + unsigned __int8 v9; // zf@5 + char v10; // sf@5 + unsigned __int8 v11; // of@5 + ODMFace *v12; // eax@6 + __int16 v13; // cx@6 + const char *v14; // eax@8 + const char *v15; // edi@8 + char *result; // eax@12 + unsigned int v17; // eax@14 + unsigned int v18; // [sp+Ch] [bp-20h]@1 + int v19; // [sp+10h] [bp-1Ch]@1 + int v20; // [sp+14h] [bp-18h]@1 + char *v21; // [sp+18h] [bp-14h]@1 + unsigned int pY; // [sp+1Ch] [bp-10h]@1 + int v23; // [sp+20h] [bp-Ch]@1 + int v24; // [sp+24h] [bp-8h]@1 + int pX; // [sp+28h] [bp-4h]@1 + + v24 = pParty->vPosition.x; + v0 = pParty->vPosition.y; + v1 = pOutdoor->uNumBModels; + *(float *)&v23 = (double)(signed int)viewparams->uMinimapZoom * 0.000015258789; + v2 = 0; + v18 = pOutdoor->uNumBModels; + v21 = 0; + pMouse->GetClickPos((unsigned int *)&pX, &pY); + v3 = 1.0 / *(float *)&v23; + v23 = pX - 557; + v19 = (signed __int64)((double)(pX - 557) * v3 + (double)v24); + v20 = (signed __int64)((double)v0 - (double)(signed int)(pY - 74) * v3); + if ( uCurrentlyLoadedLevelType != LEVEL_Outdoor || (*(float *)&v23 = 0.0, (signed int)v1 <= 0) ) + { +LABEL_14: + v17 = pMapStats->GetMapInfo(pCurrentMapName.data()); + if ( v17 == v2 ) + result = "No Maze Info for this maze on file!"; + else + result = pMapStats->pInfos[v17].pName; + } + else + { + v4 = 0; + while ( 1 ) + { + pX = pOutdoor->pBModels[v4].vBoundingCenter.x - v19; + pY = pOutdoor->pBModels[v4].vBoundingCenter.y - v20; + v5 = abs((signed)pY); + v6 = abs((signed)pX); + v7 = int_get_vector_length(v6, v5, v2); + v8 = &pOutdoor->pBModels[0]; + if ( v7 < 2 * pOutdoor->pBModels[v4].sBoundingRadius ) + { + v11 = __OFSUB__(pOutdoor->pBModels[v4].uNumFaces, v2); + v9 = pOutdoor->pBModels[v4].uNumFaces == v2; + v10 = ((pOutdoor->pBModels[v4].uNumFaces - v2) & 0x80000000u) != 0; + v24 = v2; + if ( !((unsigned __int8)(v10 ^ v11) | v9) ) + { + do + { + v12 = &v8[v4].pFaces[v2 / 0x134u]; + v13 = v12->sCogTriggeredID; + if ( v13 ) + { + if ( !(BYTE2(v12->uAttributes) & 0x10) ) + { + v14 = GetEventHintString(v13); + v15 = v14; + if ( v14 ) + { + if ( _stricmp(v14, "") ) + v21 = (char *)v15; + } + } + } + ++v24; + v8 = pOutdoor->pBModels; + v2 += 308; + } + while ( v24 < (signed int)pOutdoor->pBModels[v4].uNumFaces ); + } + result = v21; + v2 = 0; + if ( v21 ) + break; + } + ++v23; + ++v4; + if ( v23 >= (signed int)v18 ) + goto LABEL_14; + } + } + return result; +} + + + + + +//----- (0041D3B7) -------------------------------------------------------- +void GameUI_CharacterQuickRecord_Draw(GUIWindow *window, Player *player) +{ + //Player *pPlayer; // esi@1 + int v6; // eax@5 + int v7; // ebx@5 + //unsigned int v8; // ecx@5 + int v9; // ebx@5 + //unsigned int v10; // eax@5 + //int v11; // eax@5 + //unsigned int v12; // ecx@5 + Texture *v13; // eax@6 + unsigned int v14; // eax@12 + PlayerFrame *v15; // eax@12 + //unsigned int v16; // eax@15 + unsigned int v20; // eax@15 + unsigned int v24; // eax@15 + unsigned int v25; // eax@15 + unsigned __int8 v28; // al@15 + char *v29; // eax@16 + __int64 v35; // ST38_8@22 + int v36; // esi@22 + unsigned int v38; // eax@22 + char *v39; // eax@24 + signed int uFramesetID; // [sp+20h] [bp-8h]@9 + int uFramesetIDa; // [sp+20h] [bp-8h]@18 + + uint numActivePlayerBuffs = 0; + for (uint i = 0; i < 24; ++i) + if (player->pPlayerBuffs[i].uExpireTime > 0) + ++numActivePlayerBuffs; + + v6 = pFontArrus->uFontHeight + 162; + v7 = (numActivePlayerBuffs - 1) * pFontArrus->uFontHeight; + v9 = v6 + v7; + window->uFrameHeight = v9; + window->uFrameZ = window->uFrameWidth + window->uFrameX - 1; + window->uFrameW = v9 + window->uFrameY - 1; + window->DrawMessageBox(0); + + if (player->Eradicated()) + v13 = pTexture_PlayerFaceEradicated; + else if (player->Dead()) + v13 = pTexture_PlayerFaceDead; + else + { + uFramesetID = pPlayerFrameTable->GetFrameIdByExpression(player->expression); + if ( !uFramesetID ) + uFramesetID = 1; + if ( player->expression == CHARACTER_EXPRESSION_21) + { + v15 = pPlayerFrameTable->GetFrameBy_y(&player->_expression21_frameset, &player->_expression21_animtime, pMiscTimer->uTimeElapsed); + } + else + { + v14 = pMiscTimer->Time(); + v15 = pPlayerFrameTable->GetFrameBy_x(uFramesetID, v14); + } + player->field_1AA2 = v15->uTextureID - 1; + v13 = pTextures_PlayerFaces[(unsigned int)window->ptr_1C][v15->uTextureID - 1]; + } + + pRenderer->DrawTextureTransparent(window->uFrameX + 24, window->uFrameY + 24, v13); + + sprintfex(pTmpBuf.data(), "\f%05d", ui_character_header_text_color); + sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[429], player->pName, pClassNames[player->classType]); // "%s the %s" + strcat(pTmpBuf.data(), pTmpBuf2.data()); + strcat(pTmpBuf.data(), "\f00000\n"); + + v20 = UI_GetHealthManaStringColor(player->sHealth, player->GetMaxHealth()); + sprintf(pTmpBuf2.data(), "%s : \f%05u%d\f00000 / %d\n", + pGlobalTXT_LocalizationStrings[108], // "Hit Points" + v20, player->sHealth, player->GetMaxHealth()); + strcat(pTmpBuf.data(), pTmpBuf2.data()); + + v24 = UI_GetHealthManaStringColor(player->sMana, player->GetMaxMana()); + sprintf(pTmpBuf2.data(), "%s : \f%05u%d\f00000 / %d\n", + pGlobalTXT_LocalizationStrings[212], // "Spell Points" + v24, player->sMana, player->GetMaxMana()); + strcat(pTmpBuf.data(), pTmpBuf2.data()); + + v25 = player->GetMajorConditionIdx(); + sprintf(pTmpBuf2.data(), "%s: \f%05d%s\f00000\n", + pGlobalTXT_LocalizationStrings[47], // "Condition + GetConditionDrawColor(v25), aCharacterConditionNames[v25]); + strcat(pTmpBuf.data(), pTmpBuf2.data()); + + v28 = player->uQuickSpell; + if ( v28 ) + v29 = pSpellStats->pInfos[v28].pShortName; + else + v29 = pGlobalTXT_LocalizationStrings[153]; + sprintfex(pTmpBuf2.data(), "%s: %s", pGlobalTXT_LocalizationStrings[172], v29); // "Quick Spell" + strcat(pTmpBuf.data(), pTmpBuf2.data()); + + window->DrawText(pFontArrus, 120, 22, 0, pTmpBuf.data(), 0, 0, 0); + + uFramesetIDa = 0; + for (uint i = 0; i < 24; ++i) + { + auto buff = player->pPlayerBuffs + i; + if (buff->uExpireTime > 0) + { + v35 = buff->uExpireTime - pParty->uTimePlayed; + v36 = uFramesetIDa++ * pFontComic->uFontHeight + 134; + v38 = ui_game_character_record_playerbuff_colors[i]; + window->DrawText(pFontComic, 52, v36, v38, aSpellNames[20 + i], 0, 0, 0); + sub_41D20D_buff_remaining_time_string(v36, window, v35, pFontComic); + } + } + + v39 = ""; + if ( uFramesetIDa == 0 ) + v39 = pGlobalTXT_LocalizationStrings[153]; // "None" + sprintf(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[450], v39); // "Active Spells: %s" + window->DrawText(pFontArrus, 14, 114, 0, pTmpBuf.data(), 0, 0, 0); +} + + + +//----- (0041A57E) -------------------------------------------------------- +void GameUI_QuickRef_Draw() +{ + //unsigned int v0; // ebx@1 + //unsigned int v1; // eax@1 + //Player *pPlayer; // ebp@2 + //int v3; // eax@6 + //int v4; // edi@6 + unsigned int v5; // eax@7 + unsigned int v6; // edi@9 + unsigned int v7; // edi@11 + //signed int v8; // eax@13 + unsigned int v9; // eax@13 + unsigned int v10; // edi@13 + //int v11; // eax@15 + unsigned int v12; // eax@15 + unsigned int v13; // edi@15 + //int v14; // eax@17 + //int v15; // ST18_4@17 + //int v16; // ebx@17 + //int v17; // eax@17 + unsigned int v18; // eax@17 + unsigned int v19; // edi@17 + //int v20; // eax@19 + unsigned int v21; // edi@19 + char *v22; // eax@21 + unsigned int v23; // edi@21 + //int v24; // eax@23 + unsigned int v25; // edi@23 + char *v26; // eax@25 + unsigned int v27; // edi@25 + int v28; // ecx@27 + char *v29; // eax@27 + signed int v30; // edx@27 + unsigned int v31; // edi@31 + unsigned int v32; // edi@33 + const char *v33; // ST10_4@35 + unsigned int v34; // eax@35 + unsigned int v35; // edi@35 + //unsigned __int8 v36; // al@37 + char *v37; // eax@38 + int v38; // eax@41 + signed int v39; // edi@42 + //char *v40; // eax@45 + //unsigned int v41; // eax@45 + signed int v43; // [sp+10h] [bp-1Ch]@1 + unsigned int v44; // [sp+14h] [bp-18h]@2 + int v45; // [sp+18h] [bp-14h]@1 + //unsigned int v46; // [sp+1Ch] [bp-10h]@1 + //unsigned int v47; // [sp+20h] [bp-Ch]@1 + unsigned int v48; // [sp+24h] [bp-8h]@33 + //unsigned int v49; // [sp+28h] [bp-4h]@1 + + //v0 = 0; + //v47 = TargetColor(0xFFu, 0xFFu, 0x9Bu); + //v49 = TargetColor(0xFFu, 0, 0); + //v46 = TargetColor(0, 0xFFu, 0); + //v1 = pIcons_LOD->LoadTexture("quikref", TEXTURE_16BIT_PALETTE); + pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->LoadTexturePtr("quikref", TEXTURE_16BIT_PALETTE)); + v43 = 0; + v45 = LOBYTE(pFontArrus->uFontHeight) + 1; + do + { + auto player = &pParty->pPlayers[v43]; + v44 = 94 * v43 + 89; + if ( v43 == 0 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, 0x12u, 0, pGlobalTXT_LocalizationStrings[149], 60, 0);//Name + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 94 * v43 + 89, 0x12u, ui_character_header_text_color, player->pName, 84, 0); + if ( v43 == 0 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, 0x2Fu, 0, pGlobalTXT_LocalizationStrings[131], 60, 0); //Óðîâ. + sprintf(pTmpBuf.data(), "%lu", player->GetActualLevel()); + if ( player->GetActualLevel() <= player->GetBaseLevel()) + v5 = player->GetExperienceDisplayColor(); + else + v5 = ui_character_bonus_text_color; + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, 0x2Fu, v5, pTmpBuf.data(), 84, 0); + v6 = v45 + 47; + if ( v43 == 0 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v45 + 47, 0, pGlobalTXT_LocalizationStrings[41], 60, 0);//Êëàññ + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v6, 0, pClassNames[player->classType], 84, 0); + v7 = v45 + v6; + if ( v43 == 0 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v7, 0, pGlobalTXT_LocalizationStrings[107], 60, 0);//Çäîð. + sprintf(pTmpBuf.data(), "%d", player->sHealth); + v9 = UI_GetHealthManaStringColor(player->sHealth, player->GetMaxHealth()); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v7, v9, pTmpBuf.data(), 84, 0); + v10 = v45 + v7; + if ( v43 == 0 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v10, 0, pGlobalTXT_LocalizationStrings[209], 60, 0);//Ìàíà + sprintf(pTmpBuf.data(), "%d", player->sMana); + v12 = UI_GetHealthManaStringColor(player->sMana, player->GetMaxMana()); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v10, v12, pTmpBuf.data(), 84, 0); + v13 = v45 + v10; + if ( v43 == 0 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v13, 0, pGlobalTXT_LocalizationStrings[0], 60, 0);//Êëàññ áðîíè + sprintf(pTmpBuf.data(), "%d", player->GetActualAC()); + v18 = UI_GetHealthManaStringColor(player->GetActualAC(), player->GetBaseAC()); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v13, v18, pTmpBuf.data(), 84, 0); + v19 = v45 + v13; + if ( !v43 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v19, 0, pGlobalTXT_LocalizationStrings[18], 60, 0);//Àòàêà + sprintf(pTmpBuf.data(), "%+d", player->GetActualAttack(0)); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v19, 0, pTmpBuf.data(), 84, 0); + v21 = v45 + v19; + if ( !v43 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v21, 0, pGlobalTXT_LocalizationStrings[66], 60, 0);//Ïîâð. + v22 = player->GetMeleeDamageString(); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v21, 0, v22, 84, 0); + v23 = v45 + v21; + if ( !v43 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v23, 0, pGlobalTXT_LocalizationStrings[203], 60, 0);// Ñòðåëÿòü + sprintf(pTmpBuf.data(), "%+d", player->GetRangedAttack()); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v23, 0, pTmpBuf.data(), 84, 0); + v25 = v45 + v23; + if ( !v43 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v25, 0, pGlobalTXT_LocalizationStrings[66], 60, 0);//Ïîâð. + v26 = player->GetRangedDamageString(); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v25, 0, v26, 84, 0); + v27 = v45 + v25; + if ( !v43 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v27, 0, pGlobalTXT_LocalizationStrings[205], 60, 0);//Íàâûêè + v28 = 0; + v29 = (char *)player->pActiveSkills; + v30 = 36; + do + { + if ( *(short *)v29 ) + ++v28; + v29 += 2; + --v30; + } + while ( v30 ); + sprintf(pTmpBuf.data(), "%lu", v28); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v27, 0, pTmpBuf.data(), 84, 0); + v31 = v45 + v27; + if ( !v43 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v31, 0, pGlobalTXT_LocalizationStrings[168], 60, 0);//Î÷êè + sprintf(pTmpBuf.data(), "%lu", player->uSkillPoints); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v31, player->uSkillPoints ? ui_character_bonus_text_color : ui_character_default_text_color, pTmpBuf.data(), 84, 0); + v32 = v45 + v31; + v48 = player->GetMajorConditionIdx(); + if ( !v43 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v32, 0, pGlobalTXT_LocalizationStrings[45], 60, 0);//Ñîñò. + v33 = aCharacterConditionNames[v48]; + v34 = GetConditionDrawColor(v48); + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v32, v34, v33, 84, 0); + v35 = v45 + v32; + if ( !v43 ) + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x16u, v35, 0, pGlobalTXT_LocalizationStrings[170], 60, 0);//Á.Ïðèì. + if (player->uQuickSpell) + v37 = pSpellStats->pInfos[player->uQuickSpell].pShortName; + else + v37 = pGlobalTXT_LocalizationStrings[153];//Íåò + pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, v35, 0, v37, 84, 0); + ++v43; + } + while ( v43 < 4 ); + + v38 = GetPartyReputation(); + if ( v38 >= 0 ) + { + if ( v38 <= 5 ) + v39 = ui_character_default_text_color; + else + v39 = ui_character_bonus_text_color_neg; + } + else + v39 = ui_character_bonus_text_color; + + sprintf(pTmpBuf.data(), "%s: \f%05d%s\f00000", pGlobalTXT_LocalizationStrings[180], v39, GetReputationString(v38));//Reputation + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 22, 323, 0, pTmpBuf.data(), 0, 0, 0); + + sprintf(pTmpBuf.data(), "\r261%s: %d", pGlobalTXT_LocalizationStrings[84], pParty->GetPartyFame());// Fame Ñëàâà + pGUIWindow_CurrentMenu->DrawText(pFontArrus, 0, 323, 0, pTmpBuf.data(), 0, 0, 0); +} + + + +//----- (0041AD6E) -------------------------------------------------------- +void GameUI_DrawRightPanelItems() +{ + if (GameUI_RightPanel_BookFlashTimer > pParty->uTimePlayed) + GameUI_RightPanel_BookFlashTimer = 0; + + if (pParty->uTimePlayed - GameUI_RightPanel_BookFlashTimer > 128) + { + GameUI_RightPanel_BookFlashTimer = pParty->uTimePlayed; + + static bool byte_50697C = false; // 50697C + byte_50697C = !byte_50697C; + if ( byte_50697C && pCurrentScreen != SCREEN_REST ) + { + if (bFlashQuestBook) pRenderer->DrawTextureTransparent(493, 355, pIcons_LOD->GetTexture(uTextureID_ib_td1_A)); + if (bFlashAutonotesBook) pRenderer->DrawTextureTransparent(527, 353, pIcons_LOD->GetTexture(uTextureID_ib_td2_A)); + if (bFlashHistoryBook) pRenderer->DrawTextureTransparent(600, 361, pIcons_LOD->GetTexture(uTextureID_ib_td5_A)); + } + else + { + pRenderer->DrawTextureRGB(468, 0, pTexture_RightFrame); + GameUI_DrawHiredNPCs(); + } + } +} + +//----- (0041AEBB) -------------------------------------------------------- +void GameUI_DrawFoodAndGold() +{ + int v2; // esi@2 + + if ( uGameState != GAME_STATE_FINAL_WINDOW ) + { + v2 = sub_44100D() != 0 ? 381 : 322; + sprintf(pTmpBuf.data(), "\r087%lu", pParty->uNumFoodRations); + pPrimaryWindow->DrawText(pFontSmallnum, 0, v2, uGameUIFontMain, pTmpBuf.data(), 0, 0, uGameUIFontShadow); + sprintf(pTmpBuf.data(), "\r028%lu", pParty->uNumGold); + pPrimaryWindow->DrawText(pFontSmallnum, 0, v2, uGameUIFontMain, pTmpBuf.data(), 0, 0, uGameUIFontShadow); + } +} + + +//----- (0041B0C9) -------------------------------------------------------- +void GameUI_DrawLifeManaBars() +{ + double v3; // st7@3 + double v7; // st7@25 + Texture *v9; // [sp-4h] [bp-30h]@10 + Texture *v10; // [sp+Ch] [bp-20h]@1 + + + v10 = pIcons_LOD->GetTexture(uTextureID_BarBlue); + + for (uint i = 0; i < 4; ++i) + { + auto player = pParty->pPlayers + i; + + if (player->sHealth > 0) + { + int v17 = 0; + if (i == 2 || i == 3) + v17 = 2; + + v3 = (double)player->sHealth / (double)player->GetMaxHealth(); + if( v3 > 0.5 ) + { + if ( v3 > 1.0 ) + v3 = 1.0; + v9 = pIcons_LOD->GetTexture(uTextureID_BarGreen); + } + else if ( v3 > 0.25 ) + v9 = pIcons_LOD->GetTexture(uTextureID_BarYellow); + else if ( v3 > 0.0 ) + v9 = pIcons_LOD->GetTexture(uTextureID_BarRed); + + + if( v3 > 0.0 ) + { + pRenderer->SetTextureClipRect(v17 + pHealthBarPos[i], + (signed __int64)((1.0 - v3) * v9->uTextureHeight) + 402, + v17 + pHealthBarPos[i] + v9->uTextureWidth, + v9->uTextureHeight + 402); + + pRenderer->DrawTextureIndexed(v17 + pHealthBarPos[i], 402, v9); + pRenderer->ResetTextureClipRect(); + } + } + + + if (player->sMana > 0) + { + v7 = player->sMana / (double)player->GetMaxMana(); + if ( v7 > 1.0 ) + v7 = 1.0; + + int v17 = 0; + if (i == 2) + v17 = 1; + + pRenderer->SetTextureClipRect(v17 + pManaBarPos[i], + (signed __int64)((1.0 - v7) * v10->uTextureHeight) + 402, + v17 + pManaBarPos[i] + v10->uTextureWidth, + v10->uTextureHeight + 402); + pRenderer->DrawTextureIndexed(v17 + pManaBarPos[i], 402, v10); + pRenderer->ResetTextureClipRect(); + } + } +} + +//----- (0041B3B6) -------------------------------------------------------- +void GameUI_DrawRightPanel() +{ + pRenderer->DrawTextureTransparent(pViewport->uViewportBR_X, 0, + pIcons_LOD->GetTexture(uTextureID_right_panel)); +} + +//----- (0041B3E2) -------------------------------------------------------- +void GameUI_DrawRightPanelFrames() +{ + pRenderer->DrawTextureRGB(0, 0, pTexture_TopFrame); + pRenderer->DrawTextureRGB(0, 8, pTexture_LeftFrame); + pRenderer->DrawTextureRGB(468, 0, pTexture_RightFrame); + pRenderer->DrawTextureRGB(0, 352, pTexture_BottomFrame); + GameUI_DrawFoodAndGold(); + GameUI_DrawRightPanelItems(); +} + + +//----- (0041C047) -------------------------------------------------------- +void GameUI_Footer_2() +{ + char *v1; // edx@2 + int v5; // eax@5 + + pRenderer->DrawTextureRGB(0, 352, pTexture_StatusBar); + if (GameUI_Footer_TimeLeft) + v1 = GameUI_Footer_TimedString.data(); + else + { + if (!pFooterString[0]) + return; + v1 = pFooterString.data(); + } + + v5 = pFontLucida->AlignText_Center(450, v1); + pPrimaryWindow->DrawText(pFontLucida, v5 + 11, 357, uGameUIFontMain, v1, 0, 0, uGameUIFontShadow); +} + +//----- (0041C0B8) -------------------------------------------------------- +void GameUI_SetFooterString(const char *pStr) +{ + const char *v1; // esi@1 + int i; // eax@7 + int j; // eax@11 + + v1 = pStr; + if ( pStr && strcmp(pStr, "test") && !IsBadStringPtrA(v1, 1) && (*v1 || GameUI_Footer_TimeLeft) ) + { + if ( GameUI_Footer_TimeLeft ) + { + for ( i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); + i > 450; + i = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()) ) + byte_5C3427[strlen(GameUI_Footer_TimedString.data())] = 0; + } + else + { + strcpy(pFooterString.data(), v1); + for ( j = pFontLucida->GetLineWidth(pFooterString.data()); + j > 450; + j = pFontLucida->GetLineWidth(pFooterString.data()) ) + GameUI_Footer_TimedString[strlen(pFooterString.data()) + 199] = 0; + } + } + } + +//----- (0041C179) -------------------------------------------------------- +void GameUI_Footer() +{ + //unsigned int v0; // ebp@1 + char *v1; // edi@5 + int v2; // eax@5 + unsigned int v3; // esi@5 + size_t v4; // eax@6 + GUIFont *v5; // ecx@6 + int v6; // eax@9 + size_t v7; // eax@10 + GUIFont *v8; // ecx@10 + char v9; // zf@12 + //unsigned int v10; // ST08_4@13 + int v11; // eax@13 + + if ( pFooterString[0] || GameUI_Footer_TimeLeft || bForceDrawFooter ) + { + pRenderer->DrawTextureRGB(0, 352u, pTexture_StatusBar); + if ( GameUI_Footer_TimeLeft ) + { + v1 = GameUI_Footer_TimedString.data(); + v2 = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); + v3 = 450; + while ( v2 > 450 ) + { + v4 = strlen(GameUI_Footer_TimedString.data()); + v5 = pFontLucida; + byte_5C3427[v4] = 0; + v2 = pFontLucida->GetLineWidth(GameUI_Footer_TimedString.data()); + } + } + else + { + v1 = pFooterString.data(); + v6 = pFontLucida->GetLineWidth(pFooterString.data()); + v3 = 450; + while ( v6 > 450 ) + { + v7 = strlen(pFooterString.data()); + v8 = pFontLucida; + GameUI_Footer_TimedString[v7 + 199] = 0; + v6 = pFontLucida->GetLineWidth(pFooterString.data()); + } + } + v9 = *v1 == 0; + bForceDrawFooter = 0; + if ( !v9 ) + { + v11 = pFontLucida->AlignText_Center(v3, v1); + pPrimaryWindow->DrawText(pFontLucida, v11 + 11, 357, uGameUIFontMain, v1, 0, 0, uGameUIFontShadow); + } + } + } +// 5C35BC: using guessed type int bForceDrawFooter; + + +//----- (00420EFF) -------------------------------------------------------- +void __cdecl GameUI_WritePointedObjectStatusString() +{ + int v1; // ebx@6 + GUIWindow *pWindow; // edi@7 + GUIButton *pButton; // ecx@11 + Player *pPlayer; // eax@19 + char v5; // cl@19 + unsigned int v6; // eax@19 + int v7; // ecx@19 + __int16 v8; // fps@23 + unsigned __int8 v9; // c0@23 + unsigned __int8 v10; // c3@23 + enum UIMessageType pMessageType1; // esi@24 + //int v12; // edx@25 + char *v13; // ecx@28 + int v14; // eax@41 + ItemGen *pItemGen; // ecx@44 + int v16; // ecx@46 + const char *v17; // eax@49 + signed int v18; // eax@55 + signed int v18b; + signed int v19; // ecx@63 + BLVFace *pFace; // eax@69 + __int16 v21; // ax@70 + const char *v22; // eax@72 + LevelDecoration *v23; // ecx@75 + LevelDecoration *v24; // esi@75 + __int16 v25; // ax@75 + const char *v26; // ecx@79 + Actor *pActor; // ecx@82 + char *v28; // esi@82 + int v29; // eax@82 + signed int v30; // ecx@88 + const char *v31; // eax@91 + __int16 v32; // fps@109 + //unsigned __int8 v33; // c0@109 + //unsigned __int8 v34; // c3@109 + enum UIMessageType pMessageType2; // esi@110 + //int v36; // edx@111 + enum UIMessageType pMessageType3; // edx@117 + //int v38; // ecx@118 + const char *v39; // [sp-8h] [bp-E8h]@20 + char *v40; // [sp-8h] [bp-E8h]@83 + int v41; // [sp-4h] [bp-E4h]@20 + char Str1[200]; // [sp+Ch] [bp-D4h]@129 + unsigned int pX; // [sp+D4h] [bp-Ch]@1 + unsigned int pY; // [sp+D8h] [bp-8h]@1 + unsigned int v45; // [sp+DCh] [bp-4h]@21 + + v13 = nullptr; + + pMouse->uPointingObjectID = 0; + pMouse->GetClickPos(&pX, &pY); + if ( pX < 0 || (signed int)pX > 639 || pY < 0 || (signed int)pY > 479 )//( (pX & 0x80000000u) != 0 || (signed int)pX > 639 || (pY & 0x80000000u) != 0 || (signed int)pY > 479 ) + return; + if (pCurrentScreen == SCREEN_GAME) + { + if ( (signed int)pX > 467 || (signed int)pY > 351 ) + goto _click_on_game_ui; + if ( pRenderer->pRenderD3D ) // inlined mm8::4C1E01 + { + v18 = pGame->pVisInstance->get_picked_object_zbuf_val(); + if ( (signed int)pX < (signed int)pViewport->uScreen_TL_X + || (signed int)pX > (signed int)pViewport->uScreen_BR_X + || (signed int)pY < (signed int)pViewport->uScreen_TL_Y + || (signed int)pY > (signed int)pViewport->uScreen_BR_Y ) + v18 = -1; + if ( v18 == -1 ) + //goto LABEL_61; + { + pMouse->uPointingObjectID = 0; + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + } + else + { + v18 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; + } + pMouse->uPointingObjectID = (unsigned __int16)v18; + v19 = (signed)PID_ID(v18); + if (PID_TYPE(v18) == OBJECT_Item) + { + v30 = v19; + if ( pObjectList->pObjects[pSpriteObjects[v30].uObjectDescID].uFlags & 0x10 ) + //goto LABEL_73; + { + pMouse->uPointingObjectID = 0; + //goto LABEL_50; + uLastPointedObjectID = 1; + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + if ( v18 >= (signed int)0x2000000u || pParty->pPickedItem.uItemID ) + { + v22 = pSpriteObjects[v30].stru_24.GetDisplayName(); +//LABEL_93: + v26 = v22; + //goto LABEL_87; + GameUI_SetFooterString(v26); + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + v31 = pSpriteObjects[v30].stru_24.GetDisplayName(); + v28 = pTmpBuf.data(); + sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[470], v31);// "Get %s" + } + else + { + if (PID_TYPE(v18) != OBJECT_Actor) + { + if (PID_TYPE(v18) == OBJECT_Decoration) + { + v23 = &pLevelDecorations[v19]; + v24 = v23; + v25 = v23->field_16_event_id; + if ( !v25 ) + { + if ( v23->IsInteractive() ) + v26 = pNPCTopics[stru_5E4C90._decor_events[v24->_idx_in_stru123 - 75] + 379].pTopic; + else + v26 = pDecorationList->pDecorations[v24->uDecorationDescID].field_20; + //goto LABEL_87; + GameUI_SetFooterString(v26); + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + v22 = GetEventHintString(v25); + if ( !v22 ) + //goto _return; + { + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + //goto LABEL_93; + v26 = v22; + //goto LABEL_87; + GameUI_SetFooterString(v26); + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + if (PID_TYPE(v18) == OBJECT_BModel) + { + if ( HIWORD(v18) < 512) + { + if ( uCurrentlyLoadedLevelType != LEVEL_Indoor) + { + v18b = (signed int)(unsigned __int16)v18 >> 9; + v21 = pOutdoor->pBModels[v18b].pFaces[v19 & 0x3F].sCogTriggeredID; + //goto LABEL_71; + if ( !v21 || (v22 = GetEventHintString(v21)) == 0 ) + //goto LABEL_73; + { + pMouse->uPointingObjectID = 0; + //goto LABEL_50; + uLastPointedObjectID = 1; + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + //goto LABEL_93; + v26 = v22; + //goto LABEL_87; + GameUI_SetFooterString(v26); + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + pFace = &pIndoor->pFaces[v19]; + if ( BYTE3(pFace->uAttributes) & 6 ) + { + v21 = pIndoor->pFaceExtras[pFace->uFaceExtraID].uEventID; +//LABEL_71: + if ( !v21 || (v22 = GetEventHintString(v21)) == 0 ) + //goto LABEL_73; + { + pMouse->uPointingObjectID = 0; + //goto LABEL_50; + uLastPointedObjectID = 1; + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + //goto LABEL_93; + v26 = v22; + //goto LABEL_87; + GameUI_SetFooterString(v26); + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + } +//LABEL_73: + pMouse->uPointingObjectID = 0; + //goto LABEL_50; + uLastPointedObjectID = 1; + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } +//LABEL_61: + pMouse->uPointingObjectID = 0; + //goto _return; + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + if ( v18 >= 335544320 ) + //goto LABEL_61; + { + pMouse->uPointingObjectID = 0; + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + pActor = &pActors[v19]; + v28 = pTmpBuf.data(); + v29 = pActor->dword_000334_unique_name; + if ( v29 ) + v40 = pMonsterStats->pPlaceStrings[v29]; + else + v40 = pMonsterStats->pInfos[pActor->pMonsterInfo.uID].pName; + strncpy(pTmpBuf.data(), v40, 0x7D0u); + } + v26 = v28; +//LABEL_87: + GameUI_SetFooterString(v26); + //goto _return; + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + v1 = uNumVisibleWindows; + if ( uNumVisibleWindows > 0 ) + { + while ( 1 ) // some other fullscreen ui + { + pWindow = &pWindowList[pVisibleWindowsIdxs[v1] - 1]; + if ( (signed int)pX >= (signed int)pWindow->uFrameX + && (signed int)pX <= (signed int)pWindow->uFrameZ + && (signed int)pY >= (signed int)pWindow->uFrameY + && (signed int)pY <= (signed int)pWindow->uFrameW ) + { + for ( pButton = pWindow->pControlsHead; ; pButton = pButton->pNext ) + { + if ( !pButton ) + break; + if ( pButton->uButtonType == 1 ) + { + if ( (signed int)pX >= (signed int)pButton->uX + && (signed int)pX <= (signed int)pButton->uZ + && (signed int)pY >= (signed int)pButton->uY + && (signed int)pY <= (signed int)pButton->uW ) + { + //LABEL_24: + pMessageType1 = (UIMessageType)pButton->field_1C; + if ( pMessageType1 ) + { + pMessageQueue_50CBD0->AddMessage(pMessageType1, pButton->msg_param, 0); + } + //LABEL_28: + v13 = pButton->pButtonName; + //_set_status_and_ret: + GameUI_SetFooterString(v13); + //LABEL_131: + uLastPointedObjectID = 1; + return; + } + } + else + { + if ( pButton->uButtonType == 2 ) + { + v45 = pX - pButton->uX; + v45 = pY - pButton->uY; + if ( (double)(signed int)pButton->uWidth != 0.0 ) + { + if ( (double)(signed int)pButton->uHeight != 0.0 ) + { + pMessageType1 = (UIMessageType)pButton->field_1C; + if ( pMessageType1 ) + { + pMessageQueue_50CBD0->AddMessage(pMessageType1, pButton->msg_param, 0); + } + v13 = pButton->pButtonName; + GameUI_SetFooterString(v13); + uLastPointedObjectID = 1; + return; + //} + } + } + } + else // click on skill + { + if ( pButton->uButtonType == 3 + && (signed int)pX >= (signed int)pButton->uX + && (signed int)pX <= (signed int)pButton->uZ + && (signed int)pY >= (signed int)pButton->uY + && (signed int)pY <= (signed int)pButton->uW ) + { + //LABEL_19: + pPlayer = pPlayers[uActiveCharacter]; + v5 = LOBYTE(pPlayer->pActiveSkills[pButton->msg_param]); + v6 = pPlayer->uSkillPoints; + v7 = (v5 & 0x3F) + 1; + if ( v6 < v7 ) + { + v41 = v7 - v6; + v39 = pGlobalTXT_LocalizationStrings[469];// "You need %d more Skill Points to advance here" + } + else + { + v41 = v7; + v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points" + } + sprintf(Str1, v39, v41); + v13 = Str1; + //goto _set_status_and_ret; + GameUI_SetFooterString(v13); + uLastPointedObjectID = 1; + return; + } + } + } + } + } + if ( pWindow->uFrameHeight == 480 ) + break; + --v1; + if ( v1 <= 0 ) + { + break; + } + } + } + if ( uNumVisibleWindows <= 0 || (uNumVisibleWindows > 0 && pWindow->uFrameHeight != 480 && v1 <= 0)) + { + if ( pCurrentScreen == SCREEN_CHEST ) + { + sub_42038D(); + //goto _return; + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + if ( pCurrentScreen == SCREEN_HOUSE ) + { + if ( dialog_menu_id != HOUSE_DIALOGUE_SHOP_BUY_STANDARD + || (v16 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]], v16 == 0) + || v16 == -65536 ) + //goto _return; + { + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + pItemGen = (ItemGen *)((char *)&pParty->pPickedItem + 36 * (v16 + 12 * (unsigned int)window_SpeakInHouse->ptr_1C) + 4); +//LABEL_49: + v17 = pItemGen->GetDisplayName(); + GameUI_SetFooterString(v17); +//LABEL_50: + uLastPointedObjectID = 1; +//_return: + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + if ( (signed int)pY < 350 ) + { + v14 = pRenderer->pActiveZBuffer[pX + pSRZBufferLineOffsets[pY]]; + if ( v14 == 0 || v14 == -65536 || (unsigned int)v14 >= 0x1388 ) + //goto _return; + { + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } + pItemGen = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v14-1]; + //goto LABEL_49; + v17 = pItemGen->GetDisplayName(); + GameUI_SetFooterString(v17); + uLastPointedObjectID = 1; + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } +_click_on_game_ui: + if ( (signed int)pX >= (signed int)pWindowList[0].uFrameX + && (signed int)pX <= (signed int)pWindowList[0].uFrameZ + && (signed int)pY >= (signed int)pWindowList[0].uFrameY + && (signed int)pY <= (signed int)pWindowList[0].uFrameW ) + { + for ( pButton = pWindowList[0].pControlsHead; pButton != (GUIButton *)0; pButton = pButton->pNext ) + { + if ( pButton->uButtonType == 1 ) + { + if ( (signed int)pX >= (signed int)pButton->uX + && (signed int)pX <= (signed int)pButton->uZ + && (signed int)pY >= (signed int)pButton->uY + && (signed int)pY <= (signed int)pButton->uW ) + { + pMessageType3 = (UIMessageType)pButton->field_1C; + if ( pMessageType3 == 0 ) // For books + //goto LABEL_28; + { + v13 = pButton->pButtonName; + GameUI_SetFooterString(v13); + uLastPointedObjectID = 1; + return; + } + + pMessageQueue_50CBD0->AddMessage(pMessageType3, pButton->msg_param, 0); + //goto LABEL_131; + uLastPointedObjectID = 1; + return; + } + } + else + { + if ( pButton->uButtonType == 2 ) + { + v45 = pX - pButton->uX; + v45 = pY - pButton->uY; + + if (pX >= pButton->uX && pX <= pButton->uZ && + pY >= pButton->uY && pY <= pButton->uW) + if ( (double)(signed int)pButton->uWidth != 0.0 ) + { + if ( (double)(signed int)pButton->uHeight != 0.0 ) + { + //UNDEF(v32); + //if ( v33 | v34 ) + //{ + pMessageType2 = (UIMessageType)pButton->field_1C; + if ( pMessageType2 != 0 ) + pMessageQueue_50CBD0->AddMessage(pMessageType2, pButton->msg_param, 0); + + //goto LABEL_28; + v13 = pButton->pButtonName; + GameUI_SetFooterString(v13); + uLastPointedObjectID = 1; + return; + //} + } + } + } + else + { + if ( pButton->uButtonType == 3 + && (signed int)pX >= (signed int)pButton->uX + && (signed int)pX <= (signed int)pButton->uZ + && (signed int)pY >= (signed int)pButton->uY + && (signed int)pY <= (signed int)pButton->uW ) + //goto LABEL_19; + { + pPlayer = pPlayers[uActiveCharacter]; + v5 = LOBYTE(pPlayer->pActiveSkills[pButton->msg_param]); + v6 = pPlayer->uSkillPoints; + v7 = (v5 & 0x3F) + 1; + if ( v6 < v7 ) + { + v41 = v7 - v6; + v39 = pGlobalTXT_LocalizationStrings[469];// "You need %d more Skill Points to advance here" + } + else + { + v41 = v7; + v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points" + } + sprintf(Str1, v39, v41); + v13 = Str1; + //goto _set_status_and_ret; + GameUI_SetFooterString(v13); + uLastPointedObjectID = 1; + return; + } + } + } + } + } + pMouse->uPointingObjectID = sub_46A99B(); + //goto _return; + if ( pMouse->uPointingObjectID == 0 ) + { + if ( uLastPointedObjectID != 0 ) + { + pFooterString[0] = 0; + bForceDrawFooter = 1; + } + } + uLastPointedObjectID = pMouse->uPointingObjectID; + return; + } +} + + +//----- (0044158F) -------------------------------------------------------- +void GameUI_DrawCharacterSelectionFrame() +{ + if ( uActiveCharacter ) + pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[uActiveCharacter - 1] - 9, 380, + pIcons_LOD->GetTexture(uTextureID_GameUI_CharSelectionFrame)); +} + + + +//----- (0044162D) -------------------------------------------------------- +void GameUI_DrawPartySpells() +{ + unsigned int v0; // ebp@1 + //signed int v1; // edi@1 + //int v2; // eax@2 + //int v3; // ecx@5 + //__int16 *v4; // ebx@25 + //Player *v5; // edi@26 + //unsigned int v6; // [sp-4h] [bp-1Ch]@11 + Texture *v7; // [sp-4h] [bp-1Ch]@12 + //unsigned int v8; // [sp-4h] [bp-1Ch]@20 + Texture *v9; // [sp-4h] [bp-1Ch]@21 + //Player **v10; // [sp+10h] [bp-8h]@25 + + v0 = (signed __int64)((double)GetTickCount() * 0.050000001); + //v1 = 0; + for (uint i = 0; i < 14; ++i) + { + //v2 = byte_4E5DD8[v1]; + if (pParty->pPartyBuffs[byte_4E5DD8[i]].uExpireTime) + { + auto tex = pIcons_LOD->GetTexture(pTextureIDs_PartyBuffIcons[i]); + //v3 = pTextureIDs_PartyBuffIcons[i]; + pRenderer->_4A65CC(pPartySpellbuffsUI_XYs[i][0], + pPartySpellbuffsUI_XYs[i][1], tex, tex, + v0 + 20 * pPartySpellbuffsUI_smthns[i], 0, 63); + } + //++v1; + } + //while ( v1 < 14 ); + + if (pCurrentScreen == SCREEN_GAME || pCurrentScreen == SCREEN_NPC_DIALOGUE) + { + if (pParty->FlyActive()) + { + if ( pParty->bFlying ) + v7 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_FlySpell, v0)->uTextureID); + else + v7 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_FlySpell, 0)->uTextureID); + if ( pRenderer->pRenderD3D ) + pRenderer->DrawTextureIndexed(8, 8, v7); + else + pRenderer->DrawTextureTransparent(8, 8, v7); + } + if (pParty->WaterWalkActive()) + { + if ( pParty->uFlags & PARTY_FLAGS_1_STANDING_ON_WATER) + v9 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_WaterWalk, v0)->uTextureID); + else + v9 = pIcons_LOD->GetTexture(pIconsFrameTable->GetFrame(uIconIdx_WaterWalk, 0)->uTextureID); + if ( pRenderer->pRenderD3D ) + pRenderer->DrawTextureIndexed(396u, 8u, v9); + else + pRenderer->DrawTextureTransparent(396u, 8u, v9); + } + } + + for (uint i = 0; i < 4; ++i) + { + auto player = pParty->pPlayers + i; + + if (player->pPlayerBuffs[PLAYER_BUFF_HAMMERHANDS].uExpireTime) + pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 427, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_Hammerhands)); + if (player->pPlayerBuffs[PLAYER_BUFF_BLESS].uExpireTime) + pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 393, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_Bless)); + if (player->pPlayerBuffs[PLAYER_BUFF_PRESERVATION].uExpireTime) + pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 410, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_Preservation)); + if (player->pPlayerBuffs[PLAYER_BUFF_PAIN_REFLECTION].uExpireTime) + pRenderer->DrawTextureIndexed(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] + 72, 444, pIcons_LOD->GetTexture(uTextureID_PlayerBuff_PainReflection)); + } + } + + + +//----- (004921C1) -------------------------------------------------------- +void GameUI_DrawPortraits(unsigned int _this) +{ + Texture *pFace; // eax@10 + unsigned int v7; // eax@17 + PlayerFrame *pFrame; // eax@21 + unsigned int v9; // eax@27 + bool v10; // eax@33 + bool v11; // edi@40 + bool v12; // edx@43 + bool v13; // ecx@46 + int v16; // eax@57 + int v19; // eax@62 + Texture *pPortrait; // [sp-4h] [bp-1Ch]@27 + unsigned int v22; // [sp+14h] [bp-4h]@1 + + v22 = _this; + if ( qword_A750D8 ) + { + qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed; + if ( qword_A750D8 <= 0 ) + { + if ( pPlayers[word_A750E2]->CanAct() ) + pPlayers[word_A750E2]->PlaySound((PlayerSpeech)word_A750E0, 0); + qword_A750D8 = 0i64; + } + } + + for (uint i = 0; i < 4; ++i) + { + auto pPlayer = pParty->pPlayers + i; + + if (pPlayer->Eradicated()) + { + pFace = pTexture_PlayerFaceEradicated; + pPortrait = pFace; + v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i]; + if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) + pRenderer->_4A6E7E(v9, 0x183u, pPortrait); + else + pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, pPortrait); + auto _v1 = 0; + v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0; + if (pPlayer->pPlayerBuffs[1].uExpireTime > 0) + _v1 = 1; + v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0; + v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0; + v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0; + if ( v13 | v12 | v11 | _v1 | v10 ) + sub_441A4E(i); + continue; + } + if (pPlayer->Dead()) + { + pFace = pTexture_PlayerFaceDead; + pPortrait = pFace; + v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i]; + if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) + pRenderer->_4A6E7E(v9, 0x183u, pPortrait); + else + pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, pPortrait); + auto _v1 = 0; + v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0; + if (pPlayer->pPlayerBuffs[1].uExpireTime > 0) + _v1 = 1; + v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0; + v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0; + v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0; + if ( v13 | v12 | v11 | _v1 | v10 ) + sub_441A4E(i); + continue; + } + v7 = 0; + for (uint j = 0; j < pPlayerFrameTable->uNumFrames; ++j) + if (pPlayerFrameTable->pFrames[j].expression == pPlayer->expression) + { + v7 = j; + break; + } + if ( v7 == 0 ) + v7 = 1; + if (pPlayer->expression == CHARACTER_EXPRESSION_21) + pFrame = pPlayerFrameTable->GetFrameBy_y(&pPlayer->_expression21_frameset, &pPlayer->_expression21_animtime, pMiscTimer->uTimeElapsed); + else + pFrame = pPlayerFrameTable->GetFrameBy_x(v7, pPlayer->uExpressionTimePassed); + if (pPlayer->field_1AA2 != pFrame->uTextureID - 1 || v22 ) + { + pPlayer->field_1AA2 = pFrame->uTextureID - 1; + pFace = (Texture *)pTextures_PlayerFaces[i][pPlayer->field_1AA2];//pFace = (Texture *)pTextures_PlayerFaces[i][pFrame->uTextureID]; + pPortrait = pFace; + v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i]; + if ( pParty->pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime ) + pRenderer->_4A6E7E(v9, 0x183u, pPortrait); + else + pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, pPortrait); + auto _v1 = 0; + v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0; + if (pPlayer->pPlayerBuffs[1].uExpireTime > 0) + _v1 = 1; + v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0; + v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0; + v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0; + if ( v13 | v12 | v11 | _v1 | v10 ) + sub_441A4E(i); + continue; + } + } + if ( pParty->bTurnBasedModeOn == 1 ) + { + if ( pTurnEngine->field_4 != 1 ) + { + if (PID_TYPE(pTurnEngine->pQueue[0].uPackedID) == OBJECT_Player) + { + //v14 = 0; + if ( pTurnEngine->uActorQueueSize > 0 ) + { + //v15 = (char *)pTurnEngine->pQueue; + for (uint i = 0; i < pTurnEngine->uActorQueueSize; ++i) + { + auto pElem = pTurnEngine->pQueue + i; + + if (PID_TYPE(pElem->uPackedID) != OBJECT_Player) + break; + v16 = dword_5079D0; + if ( pParty->uFlags & 0x10 ) + { + v16 = dword_5079CC; + } + else + { + if ( pParty->uFlags & 0x20 ) + v16 = dword_5079C8; + } + pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[PID_ID(pElem->uPackedID)] - 4, 0x181u, pIcons_LOD->GetTexture(v16)); + } + } + } + } + } + else + { + for (uint i = 0; i < 4; ++i) + { + auto pPlayer = pParty->pPlayers + i; + if (pPlayer->CanAct() && !pPlayer->uTimeToRecovery) + { + v19 = dword_5079D0; + if ( pParty->uFlags & 0x10 ) + { + v19 = dword_5079CC; + } + else + { + if ( pParty->uFlags & 0x20 ) + v19 = dword_5079C8; + } + pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4, 0x181u, pIcons_LOD->GetTexture(v19)); + } + } + } + } + +//----- (00441D38) -------------------------------------------------------- +void GameUI_DrawMinimap(unsigned int uX, unsigned int uY, unsigned int uZ, unsigned int uW, unsigned int uZoom, unsigned int bRedrawOdmMinimap) +{ + int uHeight; // ebx@6 + __int16 v11; // cx@11 + unsigned int v14; // ebx@23 + int v15; // eax@23 + __int16 v17; // di@30 + double v18; // st7@30 + float v19; // ST38_4@30 + double v20; // st7@30 + double v21; // st6@30 + double v22; // st5@33 + signed int v27; // eax@37 + unsigned __int16 *v28; // ecx@37 + signed int v29; // edi@40 + //signed int v33; // ebx@50 + //unsigned int v34; // eax@50 + //signed int v35; // ecx@50 + //unsigned __int16 v36; // di@66 + int v37; // edi@72 + int v38; // ebx@72 + __int16 v39; // ax@87 + int v40; // edi@91 + int v41; // ebx@91 + unsigned int v42; // eax@101 + unsigned int v43; // ebx@101 + unsigned int v44; // ST30_4@101 + char *v45; // ebx@106 + int v46; // edi@108 + int v47; // eax@108 + unsigned int v48; // ebx@114 + unsigned int v49; // ST64_4@114 + //unsigned int v51; // [sp-10h] [bp-64h]@79 + unsigned int v52; // [sp-10h] [bp-64h]@100 + //unsigned int v53; // [sp-Ch] [bp-60h]@79 + unsigned int v54; // [sp-Ch] [bp-60h]@100 + //unsigned int v55; // [sp-8h] [bp-5Ch]@77 + unsigned int v56; // [sp-8h] [bp-5Ch]@100 + //signed int v57; // [sp-4h] [bp-58h]@54 + //unsigned __int16 v58; // [sp-4h] [bp-58h]@77 + unsigned __int16 v59; // [sp-4h] [bp-58h]@100 + //unsigned __int16 v60; // [sp+10h] [bp-44h]@66 + //unsigned int v61; // [sp+10h] [bp-44h]@85 + //unsigned int v63; // [sp+14h] [bp-40h]@85 + //unsigned int v65; // [sp+18h] [bp-3Ch]@85 + unsigned int lPitch; // [sp+20h] [bp-34h]@1 + unsigned int lPitcha; // [sp+20h] [bp-34h]@23 + char *lPitchb; // [sp+20h] [bp-34h]@106 + unsigned int v69; // [sp+24h] [bp-30h]@23 + signed int v70; // [sp+24h] [bp-30h]@37 + //unsigned __int16 uBlue; // [sp+28h] [bp-2Ch]@1 + signed int uBluea; // [sp+28h] [bp-2Ch]@37 + int v73; // [sp+2Ch] [bp-28h]@30 + int v76; // [sp+34h] [bp-20h]@91 + int v77; // [sp+34h] [bp-20h]@108 + //int v79; // [sp+38h] [bp-1Ch]@72 + //char *a2c; // [sp+40h] [bp-14h]@68 + signed int uCenterY; // [sp+48h] [bp-Ch]@1 + signed int uCenterX; // [sp+4Ch] [bp-8h]@1 + signed int uWidth; // [sp+5Ch] [bp+8h]@30 + //signed int uZe; // [sp+5Ch] [bp+8h]@67 + signed int uZf; // [sp+5Ch] [bp+8h]@85 + signed int uZg; // [sp+5Ch] [bp+8h]@105 + unsigned int uWa; // [sp+60h] [bp+Ch]@23 + float uWb; // [sp+60h] [bp+Ch]@30 + unsigned int uWd; // [sp+60h] [bp+Ch]@95 + float uZooma; // [sp+64h] [bp+10h]@117 + //unsigned int flagsb; // [sp+68h] [bp+14h]@66 + Actor *flagsc; // [sp+68h] [bp+14h]@86 + //unsigned int flagsd; // [sp+68h] [bp+14h]@105 + + uCenterX = (uX + uZ) / 2; + uCenterY = (uY + uW) / 2; + lPitch = pRenderer->uTargetSurfacePitch; + //TargetColor(0, 0, 0); + //uBlue = TargetColor(0, 0, 0xFFu); + auto bWizardEyeActive = pParty->WizardEyeActive(); + auto uWizardEyeSkillLevel = pParty->WizardEyeSkillLevel(); + if (CheckHiredNPCSpeciality(Cartographer)) + { + bWizardEyeActive = true; + uWizardEyeSkillLevel = 2; + } + bWizardEyeActive = true; + uWizardEyeSkillLevel = 3; + pRenderer->SetRasterClipRect(uX, uY, uZ - 1, uW - 1); + uHeight = uW - uY; + uWidth = uZ - uX; + + if ( uCurrentlyLoadedLevelType != LEVEL_Indoor) + { + v17 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uWidthLn2; + auto pMapLod0 = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pLevelOfDetail0_prolly_alpha_mask; + auto pPal = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].pPalette16; + v73 = (1 << (v17 + 16)) / (signed int)uZoom; + v18 = (double)(1 << (16 - v17)); + v19 = v18; + v20 = (double)(pParty->vPosition.x + 32768) / v18; + v21 = (double)(32768 - pParty->vPosition.y) / v19; + uWb = v21; + switch (uZoom) + { + case 512: + { + v20 = v20 - (double)(uWidth / 2); + v22 = (double)(uHeight / 2); + uWb = v21 - v22; + } + break; + + case 1024: + { + v20 = v20 - (double)(uWidth / 4); + v22 = (double)(uHeight / 4); + uWb = v21 - v22; + } + break; + + case 2048: + { + v20 = v20 - (double)(uWidth / 8); + v22 = (double)(uHeight / 8); + uWb = v21 - v22; + } + break; + + default: assert(false); + } + assert(sizeof(pOdmMinimap) == 137 * 117 * sizeof(short)); + + v70 = floorf(v20 * 65536.0 + 0.5f);//LODWORD(v24); + uBluea = floorf(uWb * 65536.0 + 0.5f);//LODWORD(v25); + v27 = uBluea >> 16; + v28 = &pRenderer->pTargetSurface[uX + uY * lPitch]; + if (pMapLod0 && bRedrawOdmMinimap) + { + assert(uWidth == 137 && uHeight == 117); + //auto pMinimap = (unsigned __int16 *)pOdmMinimap; + + auto mapWidth = pIcons_LOD->pTextures[viewparams->uTextureID_LocationMap].uTextureWidth; + + v29 = v70 >> 16; + + for (int y = 0; y < uHeight; ++y) + { + auto pMapLod0Line = &pMapLod0[v27 * mapWidth]; + for (int x = 0; x < uWidth; ++x) + { + //*pMinimap++ = pPal[pMapLod0Line[v29]]; + pOdmMinimap[y][x] = pPal[pMapLod0Line[v29]]; + v29 = (v70 + x * v73) >> 16; + } + + v29 = v70 >> 16; + v28 += 137 - uWidth; + uBluea += v73; + v27 = uBluea >> 16; + } + } + + for (int y = 0; y < 117; ++y) + { + for (int x = 0; x < 137; ++x) + { + *v28++ = pOdmMinimap[y][x]; + } + v28 += lPitch - 137; + } + uNumBlueFacesInBLVMinimap = 0; + } + else + { + pRenderer->FillRectFast(uX, uY, uZ - uX, uHeight, 0xF); + uNumBlueFacesInBLVMinimap = 0; + + for (uint i = 0; i < pIndoor->pMapOutlines->uNumOutlines; ++i) + { + auto pOutline = &pIndoor->pMapOutlines->pOutlines[i]; + + auto pFace1 = pIndoor->pFaces + pOutline->uFace1ID; + auto pFace2 = pIndoor->pFaces + pOutline->uFace2ID; + //v9 = pIndoor->pFaces[pMapVertex->uFace1ID].uAttributes; + //v10 = pIndoor->pFaces[pMapVertex->uFace2ID].uAttributes; + if (pFace1->Visible() && pFace2->Visible()) + { + v11 = pOutline->uFlags; + if ( v11 & 1 ) + goto LABEL_15; + if (pFace1->uAttributes & 0x80 || pFace2->uAttributes & 0x80) + goto LABEL_ABC; + + } + continue; + +LABEL_ABC: + pOutline->uFlags = v11 | 1; + pIndoor->_visible_outlines[i >> 3] |= 1 << (7 - i % 8); + +LABEL_15: + //v12 = &pIndoor->pFaces[pOutline->uFace1ID]; + if (bWizardEyeActive && uWizardEyeSkillLevel >= 3 && + (pFace1->uAttributes & 0x2000 || pFace2->uAttributes & 0x2000) && + (pIndoor->pFaceExtras[pFace1->uFaceExtraID].uEventID || pIndoor->pFaceExtras[pFace2->uFaceExtraID].uEventID)) + { + if (uNumBlueFacesInBLVMinimap < 49) + pBlueFacesInBLVMinimapIDs[uNumBlueFacesInBLVMinimap++] = i; + } + else + { + auto _a = (uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x); + auto _b = ((unsigned int)((unsigned __int64)_a >> 16) << 16); + auto _c = ((signed int)(_b - uZoom * pParty->vPosition.x) >> 16); + v69 = uCenterX + _c; + v69 = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16); + lPitcha = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16); + uWa = uCenterX + ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16) - uZoom * pParty->vPosition.x) >> 16); + v14 = uCenterY - ((signed int)(((unsigned int)((unsigned __int64)(uZoom * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16) - uZoom * pParty->vPosition.y) >> 16); + v15 = abs(pOutline->sZ - pParty->vPosition.z) / 8; + if ( v15 > 100 ) + v15 = 100; + pRenderer->RasterLine2D(v69, lPitcha, uWa, v14, viewparams->pPalette[-v15 + 200]); + } + } + + + for (uint i = 0; i < uNumBlueFacesInBLVMinimap; ++i) + { + //v16 = (uint *)&pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[uZb]]; + auto pOutline = &pIndoor->pMapOutlines->pOutlines[pBlueFacesInBLVMinimapIDs[i]]; + pRenderer->RasterLine2D(uCenterX + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom + * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].x) >> 16) << 16) + - uZoom * pParty->vPosition.x) >> 16), + uCenterY + - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom + * (signed __int64)pIndoor->pVertices[pOutline->uVertex1ID].y) >> 16) << 16) + - uZoom * pParty->vPosition.y) >> 16), + uCenterX + + ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom + * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].x) >> 16) << 16) + - uZoom * pParty->vPosition.x) >> 16), + uCenterY + - ((signed int)(((unsigned int)((unsigned __int64)((signed int)uZoom + * (signed __int64)pIndoor->pVertices[pOutline->uVertex2ID].y) >> 16) << 16) + - uZoom * pParty->vPosition.y) >> 16), + ui_game_minimap_outline_color); + } + } + + + assert(pParty->sRotationY >= 0); + float angle = (pParty->sRotationY % 2048) / 2048.0f; + const float two_pi = 2.0f * 3.14159f; + + uint arrow_idx = floorf(0.5f + 7 * angle); + pRenderer->DrawTextureTransparent(uCenterX - 3, uCenterY - 3, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[arrow_idx])); + + //flagsb = TargetColor(0, 0, 255); + //v60 = TargetColor(255, 0, 0); + if (bWizardEyeActive) + { + //uZe = 0; + if (uWizardEyeSkillLevel >= 2) + for (uint i = 0; i < uNumSpriteObjects; ++i) + //if (uNumSpriteObjects > 0) + { + auto object = &pSpriteObjects[i]; + + //a2c = (char *)&pSpriteObjects[0].uObjectDescID; + //while ( 1 ) + //{ + if (!object->uType || !object->uObjectDescID) + continue; + //if (uWizardEyeSkillLevel == 1 + v37 = uCenterX + ((unsigned __int64)((object->vPosition.x - pParty->vPosition.x) * (signed __int64)uZoom) >> 16); + //v79 = (unsigned __int64)((object->vPosition.y - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16; + //v38 = uCenterY - v79; + v38 = uCenterY - ((signed __int64)((object->vPosition.y - pParty->vPosition.y) * (signed __int64)uZoom) >> 16); + if (v37 < pRenderer->raster_clip_x || v37 > pRenderer->raster_clip_z || + v38 < pRenderer->raster_clip_y || v38 > pRenderer->raster_clip_w) + continue; + + assert(uZoom >= 512); + if (pObjectList->pObjects[object->uObjectDescID].uFlags & OBJECT_DESC_UNPICKABLE) + { + pRenderer->RasterLine2D(v37, v38, v37, v38, ui_game_minimap_projectile_color); + } + else if (uZoom > 512) + { + pRenderer->RasterLine2D(v37 - 1, v38 - 1, v37 - 1, v38 + 1, ui_game_minimap_treasure_color); + pRenderer->RasterLine2D(v37, v38 - 2, v37, v38 + 1, ui_game_minimap_treasure_color); + pRenderer->RasterLine2D(v37 + 1, v38 - 1, v37 + 1, v38 + 1, ui_game_minimap_treasure_color); + pRenderer->RasterLine2D(v37 - 2, v38, v37 - 2, v38 + 1, ui_game_minimap_treasure_color); + pRenderer->RasterLine2D(v37 + 2, v38, + v37 + 2, v38 + 1, ui_game_minimap_treasure_color); + } + else + { + pRenderer->RasterLine2D(v37 - 1, v38 - 1, + v37 - 1, v38, ui_game_minimap_treasure_color); + pRenderer->RasterLine2D(v37, v38 - 1, + v37, v38, ui_game_minimap_treasure_color); + } +//LABEL_82: +//LABEL_83: + //++uZe; + //a2c += 112; + //if ( uZe >= (signed int)uNumSpriteObjects ) + //{ + //goto LABEL_85; + //} + //} + } + + +LABEL_85: + //v63 = TargetColor(255, 0, 0); + //v61 = TargetColor(0, 255, 0); + //v65 = TargetColor(255, 255, 0); + uZf = 0; + if ( (signed int)uNumActors > 0 ) + { + flagsc = pActors.data();//[0].uAIState; + do + { + v39 = flagsc->uAIState; + if ( flagsc->uAIState != 11 && v39 != 19 && (v39 == 5 || BYTE1(flagsc->uAttributes) & 0x80) ) + { + v40 = ((unsigned __int64)(( flagsc->vPosition.x - pParty->vPosition.x) + * (signed __int64)(signed int)uZoom) >> 16) + + uCenterX; + v76 = (unsigned __int64)(( flagsc->vPosition.y - pParty->vPosition.y) + * (signed __int64)(signed int)uZoom) >> 16; + v41 = uCenterY - v76; + if ( v40 >= pRenderer->raster_clip_x ) + { + if ( v40 <= pRenderer->raster_clip_z && v41 >= pRenderer->raster_clip_y && v41 <= pRenderer->raster_clip_w ) + { + uWd = ui_game_minimap_actor_friendly_color; + if ( BYTE3(flagsc->uAttributes) & 1 ) + uWd = ui_game_minimap_actor_hostile_color; + if ( flagsc->uAIState == Dead) + uWd = ui_game_minimap_actor_corpse_color; + if ( (signed int)uZoom > 1024 ) + { + pRenderer->RasterLine2D(v40 - 1, v41 - 2, v40 - 1, v41 + 2, uWd); + pRenderer->RasterLine2D(v40, v41 - 2, v40, v41 + 2, uWd); + pRenderer->RasterLine2D(v40 + 1, v41 - 2, v40 + 1, v41 + 2, uWd); + v42 = v41 + 1; + v43 = v41 - 1; + v44 = v42; + pRenderer->RasterLine2D(v40 - 2, v43, v40 - 2, v42, uWd); + v40 += 2; + v59 = uWd; + v56 = v44; + v54 = v40; + v52 = v43; + } + else + { + pRenderer->RasterLine2D(v40 - 1, v41 - 1, v40 - 1, uCenterY - v76, uWd); + v59 = uWd; + v56 = uCenterY - v76; + v54 = v40; + v52 = v41 - 1; + } + pRenderer->RasterLine2D(v40, v52, v54, v56, v59); + } + } + } + ++uZf; + ++flagsc; + } + while ( uZf < (signed int)uNumActors ); + } + } + + + //flagsd = TargetColor(255, 255, 255); + uZg = 0; + if ( (signed int)uNumLevelDecorations > 0 ) + { + v45 = (char *)&pLevelDecorations[0].vPosition; + lPitchb = (char *)&pLevelDecorations[0].vPosition; + do + { + if ( *(v45 - 2) & 8 ) + { + v46 = ((unsigned __int64)((*(int *)v45 - pParty->vPosition.x) * (signed __int64)(signed int)uZoom) >> 16) + + uCenterX; + v77 = (unsigned __int64)((*((int *)v45 + 1) - pParty->vPosition.y) * (signed __int64)(signed int)uZoom) >> 16; + v47 = uCenterY - v77; + if ( v46 >= pRenderer->raster_clip_x ) + { + if ( v46 <= pRenderer->raster_clip_z && v47 >= pRenderer->raster_clip_y && v47 <= pRenderer->raster_clip_w ) + { + if ( (signed int)uZoom > 512 ) + { + v48 = v47 + 1; + v49 = v47 - 1; + pRenderer->RasterLine2D(v46 - 1, v47 - 1, v46 - 1, v47 + 1, ui_game_minimap_decoration_color_1); + pRenderer->RasterLine2D(v46, v49, v46, v48, ui_game_minimap_decoration_color_1); + pRenderer->RasterLine2D(v46 + 1, v49, v46 + 1, v48, ui_game_minimap_decoration_color_1); + v45 = lPitchb; + } + else + { + pRenderer->RasterLine2D(v46, uCenterY - v77, v46, uCenterY - v77, ui_game_minimap_decoration_color_1); + } + } + } + } + ++uZg; + v45 += 32; + lPitchb = v45; + } + while ( uZg < (signed int)uNumLevelDecorations ); + } + pRenderer->DrawTextureTransparent(0x1D4u, 0, pIcons_LOD->GetTexture(dword_5079D8)); + uZooma = (double)pParty->sRotationY * 0.1171875; + //v50 = uZooma + 6.7553994e15; + pRenderer->SetTextureClipRect(541, 0, 567, 480); + pRenderer->DrawTextureIndexed(floorf(uZooma + 0.5f) + 285, 136, pIcons_LOD->GetTexture(dword_5079B4)); + pRenderer->ResetTextureClipRect(); +} + +//----- (00441498) -------------------------------------------------------- +void __cdecl GameUI_DrawTorchlightAndWizardEye() + { + if (pCurrentScreen == SCREEN_GAME + || pCurrentScreen == SCREEN_MENU + || pCurrentScreen == SCREEN_OPTIONS + || pCurrentScreen == SCREEN_REST + || pCurrentScreen == SCREEN_SPELL_BOOK + || pCurrentScreen == SCREEN_CHEST + || pCurrentScreen == SCREEN_SAVEGAME + || pCurrentScreen == SCREEN_LOADGAME + || pCurrentScreen == SCREEN_CHEST_INVENTORY + || pCurrentScreen == SCREEN_BOOKS + || pCurrentScreen == SCREEN_BRANCHLESS_NPC_DIALOG ) + { + if (pParty->TorchlightActive()) + { + auto icon = pIconsFrameTable->GetFrame((signed __int16)pUIAnum_Torchlight->uIconID, pEventTimer->Time()); + pRenderer->DrawTextureTransparent(pUIAnum_Torchlight->x, pUIAnum_Torchlight->y, pIcons_LOD->GetTexture(icon->uTextureID)); + } + if (pParty->WizardEyeActive()) + { + auto icon = pIconsFrameTable->GetFrame((signed __int16)pUIAnim_WizardEye->uIconID, pEventTimer->Time()); + pRenderer->DrawTextureTransparent(pUIAnim_WizardEye->x, pUIAnim_WizardEye->y, pIcons_LOD->GetTexture(icon->uTextureID)); + } + } + } +// 4E28F8: using guessed type int pCurrentScreen; + + +//----- (00491F87) -------------------------------------------------------- +void GameUI_DrawHiredNPCs() +{ + //int v6; // eax@15 + char v7; // al@17 + unsigned int v8; // eax@18 + int v9; // esi@18 + int v10; // eax@18 + unsigned int v11; // eax@19 + unsigned int v12; // esi@19 + unsigned int v13; // eax@23 + IconFrame *v14; // eax@24 + unsigned int v15; // eax@26 + char pContainer[20]; // [sp+Ch] [bp-30h]@18 + unsigned int v17; // [sp+20h] [bp-1Ch]@19 + signed int uFrameID; // [sp+24h] [bp-18h]@19 + //int i; // [sp+28h] [bp-14h]@15 + unsigned int v20; // [sp+2Ch] [bp-10h]@20 + unsigned int v21; // [sp+30h] [bp-Ch]@19 + int v22; // [sp+34h] [bp-8h]@2 + unsigned __int8 v23; // [sp+3Bh] [bp-1h]@2 + + if ( bNoNPCHiring != 1 ) + { + v23 = 0; + v22 = 0; + /*for (uint i = 0; i < 2; ++i) + { + if (pParty->pHirelings[i].pName) + pTmpBuf[v22++] = i; + }*/ + if (pParty->pHirelings[0].pName) + pTmpBuf[v22++] = 0; + if (pParty->pHirelings[1].pName) + pTmpBuf[v22++] = 1; + + for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i) + { + if (pNPCStats->pNewNPCData[i].uFlags & 128) + { + if (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName)) + { + if (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName)) + pTmpBuf[v22++] = i + 2; + } + } + } + + //v6 = (unsigned __int8)pParty->field_709; + for ( int i = (unsigned __int8)pParty->field_709; i < v22 && v23 < 2; i++ ) + { + v7 = pTmpBuf[i]; + if ( (unsigned __int8)v7 >= 2 ) + { + sprintf(pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID); + v15 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v23], pHiredNPCsIconsOffsetsY[v23], pIcons_LOD->GetTexture(v15)); + } + else + { + sprintf(pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID); + v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); + v9 = v23; + pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v9], pHiredNPCsIconsOffsetsY[v9], pIcons_LOD->GetTexture(v8)); + v10 = (unsigned __int8)pTmpBuf[i]; + if ( pParty->pHirelings[v10].evt_A == 1 ) + { + uFrameID = pParty->pHirelings[v10].evt_B; + v11 = pHiredNPCsIconsOffsetsX[v9]; + v12 = pHiredNPCsIconsOffsetsY[v9]; + v17 = v11; + v21 = 0; + if ( (signed int)pIconsFrameTable->uNumIcons <= 0 ) + { +LABEL_23: + v13 = 0; + } + else + { + v20 = 0; + while ( _stricmp("spell96", pIconsFrameTable->pIcons[v20 / 0x20].pAnimationName) ) + { + ++v21; + v20 += 32; + if ( (signed int)v21 >= (signed int)pIconsFrameTable->uNumIcons ) + goto LABEL_23; + } + v13 = v21; + } + v14 = pIconsFrameTable->GetFrame(v13, uFrameID); + pRenderer->DrawTextureTransparent(v17, v12, &pIcons_LOD->pTextures[v14->uTextureID]); + } + } + ++v23; + } + } +} +// 6BE3C5: using guessed type char bNoNPCHiring; + +//----- (004178FE) -------------------------------------------------------- +unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2) +{ + unsigned __int16 v2; // dx@2 + unsigned __int16 v3; // cx@2 + int v5; // eax@5 + unsigned __int16 v6; // [sp-4h] [bp-8h]@2 + + if ( a1 <= a2 ) + { + if ( a1 == a2 ) + return 0; + v5 = 100 * a1 / a2; + v3 = 255; + if ( v5 >= 25 ) + { + v6 = 100; + v2 = 255; + } + else + { + v6 = 0; + v2 = 0; + } + } + else + { + v6 = 0; + v2 = 255; + v3 = 0; + } + return TargetColor(v3, v2, v6); +} + +//----- (00417939) -------------------------------------------------------- +signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx) +{ + unsigned int v1; // ebx@1 + signed int v2; // edi@1 + unsigned int v3; // esi@1 + unsigned int v4; // eax@1 + unsigned int v6; // [sp+Ch] [bp-4h]@1 + + v1 = uConditionIdx; + v2 = 65535; + v3 = TargetColor(0xE1u, 0xCDu, 0x23u); + v6 = TargetColor(0xFFu, 0x23u, 0); + v4 = TargetColor(0, 0xFFu, 0); + switch ( v1 ) + { + case 0u: + case 1u: + case 3u: + case 4u: + case 5u: + case 6u: + case 7u: + v2 = v4; + break; + case 2u: + case 8u: + case 9u: + case 0xCu: + case 0xDu: + v2 = v3; + break; + case 0xAu: + case 0xBu: + case 0xEu: + case 0xFu: + case 0x10u: + v2 = v6; + break; + default: + return v2; + } + return v2; +}