Mercurial > mm7
view GUI/UI/UITransition.cpp @ 2549:3121fb54a110
Rest & Spelbook refactored into class
author | a.parshin |
---|---|
date | Tue, 12 May 2015 11:07:32 +0200 |
parents | 4087cbc62706 |
children | d87bfbd3bb3b |
line wrap: on
line source
#define _CRTDBG_MAP_ALLOC #include <stdlib.h> #include <crtdbg.h> #define _CRT_SECURE_NO_WARNINGS #include <io.h> #include "Engine/Engine.h" #include "Engine/Party.h" #include "Engine/Graphics/Outdoor.h" #include "Engine/LOD.h" #include "Engine/Timer.h" #include "Engine/stru159.h" #include "Engine/Events2D.h" #include "Engine/texts.h" #include "Engine/MapInfo.h" #include "GUI/UI/UITransition.h" #include "GUI/GUIFont.h" #include "GUI/GUIProgressBar.h" #include "GUI/UI/UIHouses.h" #include "Media/Audio/AudioPlayer.h" #include "Media/MediaPlayer.h" void GUIWindow_Travel::Release() { // ----------------------------------------- // 0041C26A void GUIWindow::Release --- part pTexture_outside->Release(); pTexture_Dialogue_Background->Release(); pIcons_LOD->SyncLoadedFilesCount(); current_screen_type = prev_screen_type; GUIWindow::Release(); } void GUIWindow_Transition::Release() { // ----------------------------------------- // 0041C26A void GUIWindow::Release --- part //pVideoPlayer->Unload(); pTexture_outside->Release(); pTexture_Dialogue_Background->Release(); pIcons_LOD->SyncLoadedFilesCount(); current_screen_type = prev_screen_type; GUIWindow::Release(); } //----- (00444839) -------------------------------------------------------- GUIWindow_Transition::GUIWindow_Transition(uint anim_id, uint exit_pic_id, int x, int y, int z, int directiony, int directionx, int a8, const char *pLocationName) : GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, nullptr) { // ---------------------------------- // 00444839 TransitionUI_Load -- part const char *v15; // eax@14 char pContainer[40]; // [sp+Ch] [bp-2Ch]@1 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: Error("Invalid alignment: %u", pParty->alignment); } pTexture_Dialogue_Background = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)]; pTexture_outside = pIcons_LOD->LoadTexturePtr(pHouse_ExitPictures[exit_pic_id], TEXTURE_16BIT_PALETTE); if (anim_id) { if ( !IndoorLocation::GetLocationIndex(pLocationName) ) pMediaPlayer->OpenHouseMovie(pAnimatedRooms[p2DEvents[anim_id - 1].uAnimationID].video_name, 1); v15 = pLocationName; if (*pLocationName == 48) v15 = pCurrentMapName; if (pMapStats->GetMapInfo(v15)) { sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[411], pMapStats->pInfos[pMapStats->GetMapInfo(v15)].pName);//Войти в ^Pv[%s] if (uCurrentlyLoadedLevelType == LEVEL_Indoor && uActiveCharacter && pParty->uFlags & 0x30) pPlayers[uActiveCharacter]->PlaySound(SPEECH_47, 0); if (IndoorLocation::GetLocationIndex(pLocationName)) uCurrentHouse_Animation = IndoorLocation::GetLocationIndex(pLocationName); } else { strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[73]);//Войти //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 (IndoorLocation::GetLocationIndex(pLocationName)) uCurrentHouse_Animation = IndoorLocation::GetLocationIndex(pLocationName); } } else if ( !IndoorLocation::GetLocationIndex(pLocationName) ) { if ( pMapStats->GetMapInfo(pCurrentMapName) ) { sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)].pName); // "Leave %s" //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 ( IndoorLocation::GetLocationIndex(pLocationName) ) uCurrentHouse_Animation = IndoorLocation::GetLocationIndex(pLocationName); } else { strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[79]); //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 (IndoorLocation::GetLocationIndex(pLocationName)) uCurrentHouse_Animation = IndoorLocation::GetLocationIndex(pLocationName); } } auto hint = this->Hint = sHouseName.data(); // // -------------------------------- // 0041C432 GUIWindow c-tor -- part prev_screen_type = current_screen_type; current_screen_type = SCREEN_INPUT_BLV; pBtn_ExitCancel = CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionWindowCloseBtn, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0); // Cancel / Отмена pBtn_YES = CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionUI_Confirm, 0, 'Y', hint, pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0); CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, UIMSG_TransitionUI_Confirm, 1, 0x20u, hint, 0); CreateButton(8, 8, 0x1CCu, 0x158u, 1, 0, UIMSG_TransitionUI_Confirm, 1u, 0, hint, 0); } //----- (00444C8F) -------------------------------------------------------- GUIWindow_Travel::GUIWindow_Travel() : GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, nullptr) { // ------------------------------ // 00444C8F TravelUI_Load -- part 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: Error("Invalid alignment: %u", pParty->alignment); } pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE); pTexture_outside = pIcons_LOD->LoadTexturePtr("outside", TEXTURE_16BIT_PALETTE); if ( pMapStats->GetMapInfo(pCurrentMapName) ) sprintfex(sHouseName.data(), pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)].pName);// "Leave %s" else strcpy(sHouseName.data(), pGlobalTXT_LocalizationStrings[79]);// "Exit" auto hint = this->Hint = sHouseName.data(); // -------------------------------- // 0041C432 GUIWindow c-tor -- part prev_screen_type = current_screen_type; current_screen_type = SCREEN_CHANGE_LOCATION; pBtn_ExitCancel = CreateButton( 566, 445, 75, 33, 1, 0, UIMSG_CHANGE_LOCATION_ClickCencelBtn, 0, 'N', pGlobalTXT_LocalizationStrings[156], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0 );// Stay in this area / Остаться в этой области pBtn_YES = CreateButton( 486, 445, 75, 33, 1, 0, UIMSG_OnTravelByFoot, 0, 'Y', hint, pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0 ); CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63, 73, 1, 0, UIMSG_OnTravelByFoot, 1, ' ', hint, 0, 0, 0); CreateButton(8, 8, 460, 344, 1, 0, UIMSG_OnTravelByFoot, 1, 0, hint, 0); } //----- (00444DCA) -------------------------------------------------------- void GUIWindow_Travel::Update() { // ----------------------------------- // 004156F0 GUI_UpdateWindows --- part GUIWindow travel_window; // [sp+Ch] [bp-78h]@1 char pDestinationMapName[32]; // [sp+60h] [bp-24h]@1 memcpy(&travel_window, pPrimaryWindow, sizeof(travel_window)); pOutdoor->GetTravelDestination(pParty->vPosition.x, pParty->vPosition.y, pDestinationMapName, 20); pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background); pRenderer->DrawTextureIndexedAlpha(468, 0, &pIcons_LOD->pTextures[uTextureID_right_panel_loop]); pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], pTexture_outside); pRenderer->DrawTextureIndexed(556, 451, pIcons_LOD->GetTexture(uTextureID_x_x_u)); pRenderer->DrawTextureIndexed(476, 451, pIcons_LOD->GetTexture(uTextureID_x_ok_u)); if ( pMapStats->GetMapInfo(pDestinationMapName) ) { travel_window.uFrameX = 493; travel_window.uFrameWidth = 126; travel_window.uFrameZ = 366; travel_window.DrawTitleText(pFontCreate, 0, 4, 0, pMapStats->pInfos[pMapStats->GetMapInfo(pDestinationMapName)].pName, 3); travel_window.uFrameX = 483; travel_window.uFrameWidth = 148; travel_window.uFrameZ = 334; if ( GetTravelTime() == 1 ) sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[663], 1, pMapStats->pInfos[pMapStats->GetMapInfo(pDestinationMapName)].pName);// "It will take %d day to cross to %s." else sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[128], GetTravelTime(), pMapStats->pInfos[pMapStats->GetMapInfo(pDestinationMapName)].pName);// "It will take %d days to travel to %s." strcat(pTmpBuf.data(), "\n \n"); sprintfex(pTmpBuf2.data(), pGlobalTXT_LocalizationStrings[126], pMapStats->pInfos[pMapStats->GetMapInfo(pCurrentMapName)].pName); strcat(pTmpBuf.data(), pTmpBuf2.data()); travel_window.DrawTitleText(pFontCreate, 0, (212 - pFontCreate->CalcTextHeight(pTmpBuf.data(), &travel_window, 0, 0)) / 2 + 101, 0, pTmpBuf.data(), 3); _unused_5B5924_is_travel_ui_drawn = 1; } } //----- (00444A51) -------------------------------------------------------- void GUIWindow_Transition::Update() { // ----------------------------------- // 004156F0 GUI_UpdateWindows --- part unsigned int v4; // [sp-10h] [bp-7Ch]@12 GUIWindow transition_window; // [sp+Ch] [bp-60h]@1 unsigned int v9; // [sp+60h] [bp-Ch]@1 unsigned int map_id; // [sp+64h] [bp-8h]@1 memcpy(&transition_window, pPrimaryWindow, sizeof(transition_window)); 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->DrawTextureIndexedAlpha(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)); map_id = pMapStats->GetMapInfo(pCurrentMapName); if ( (pMovie_Track || v9) && *dword_591164_teleport_map_name != ' ' ) map_id = pMapStats->GetMapInfo(dword_591164_teleport_map_name); transition_window.uFrameX = 493; transition_window.uFrameWidth = 126; transition_window.uFrameZ = 366; transition_window.DrawTitleText(pFontCreate, 0, 5, 0, pMapStats->pInfos[map_id].pName, 3); transition_window.uFrameX = 483; transition_window.uFrameWidth = 148; transition_window.uFrameZ = 334; if ( uCurrentHouse_Animation ) { v4 = (212 - pFontCreate->CalcTextHeight(pTransitionStrings[uCurrentHouse_Animation], &transition_window, 0, 0)) / 2 + 101; transition_window.DrawTitleText(pFontCreate, 0, v4, 0, pTransitionStrings[uCurrentHouse_Animation], 3); } else if ( map_id ) { sprintfex(pTmpBuf.data(), pGlobalTXT_LocalizationStrings[409], pMapStats->pInfos[map_id].pName);// "Do you wish to leave %s?" v4 = (212 - pFontCreate->CalcTextHeight(pTmpBuf.data(), &transition_window, 0, 0)) / 2 + 101; transition_window.DrawTitleText(pFontCreate, 0, v4, 0, pTmpBuf.data(), 3); } else Error("Troubles in da house"); _unused_5B5924_is_travel_ui_drawn = true; }