Mercurial > mm7
view GUI/UI/UIBooks.cpp @ 2548:87e5590d034b
All Books windows are refactored into respective classes
author | a.parshin |
---|---|
date | Tue, 12 May 2015 03:24:19 +0200 |
parents | a902abdfc7f2 |
children | 3121fb54a110 |
line wrap: on
line source
#define _CRTDBG_MAP_ALLOC #define _CRT_SECURE_NO_WARNINGS #include <stdlib.h> #include <crtdbg.h> #include "Engine/Engine.h" #include "Engine/Graphics/Render.h" #include "Engine/LOD.h" #include "Engine/texts.h" #include "Engine/Awards.h" #include "GUI/GUIFont.h" #include "GUI/UI/UIBooks.h" #include "Media/Audio/AudioPlayer.h" //----- (00411597) -------------------------------------------------------- void GUIWindow_Book::Release() { free(pSpellFont); pSpellFont = nullptr; free(pBookFont); pBookFont = nullptr; free(pBook2Font); pBook2Font = nullptr; free(pAutonoteFont); pAutonoteFont = nullptr; pTexture_mapbordr->Release(); pAudioPlayer->PlaySound(SOUND_closebook, 0, 0, -1, 0, 0, 0, 0); pIcons_LOD->RemoveTexturesPackFromTextureList(); dword_506364 = 0; GUIWindow::Release(); } GUIWindow_Book::GUIWindow_Book() : GUIWindow(0, 0, window->GetWidth(), window->GetHeight(), 0, nullptr) { } void GUIWindow_Book::BasicBookInitialization() { // ----- (00411BFC) -------------------------------------------------------- // void GUIWindow::InitializeBookView() --- part // { pAudioPlayer->StopChannels(-1, -1); InitializeFonts(); CreateButton(475, 445, 158, 34, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0); // Close current_screen_type = SCREEN_BOOKS; full_num_items_in_book = 0; books_primary_item_per_page = 0; books_page_number = 0; num_achieved_awards = 0; } //----- (00411AAA) -------------------------------------------------------- void GUIWindow_Book::InitializeFonts() { 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); } //----- (0041192C) -------------------------------------------------------- void InitializeSpellBookTextures() { 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); pSpellBookCloseBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m5-u", TEXTURE_16BIT_PALETTE); pSpellBookClickCloseBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m5-d", TEXTURE_16BIT_PALETTE); pSBQuickSpellBtnTextr = pIcons_LOD->LoadTexturePtr("ib-m6-u",TEXTURE_16BIT_PALETTE); static const char *texNames[9] = // 004E24EC { "SBFB00", "SBAB00", "SBWB00", "SBEB00", "SBSB00", "SBMB00", "SBBB00", "SBLB00", "SBDB00" }; pSBClickQuickSpellBtnTextr = 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); } } //----- (0041140B) -------------------------------------------------------- void OnCloseSpellBookPage() { GUIButton *pNextButton; // esi@4 for ( uint i = 1; i <= 11; i++ ) { SBPageCSpellsTextureList[i]->Release(); SBPageSSpellsTextureList[i]->Release(); } pIcons_LOD->SyncLoadedFilesCount(); if ( pGUIWindow_CurrentMenu->pControlsHead ) { do { pNextButton = pGUIWindow_CurrentMenu->pControlsHead->pNext; free(pGUIWindow_CurrentMenu->pControlsHead); pGUIWindow_CurrentMenu->pControlsHead = pNextButton; } while ( pNextButton ); } pGUIWindow_CurrentMenu->pControlsHead = 0; pGUIWindow_CurrentMenu->pControlsTail = 0; pGUIWindow_CurrentMenu->uNumControls = 0; } //----- (00411473) -------------------------------------------------------- void OnCloseSpellBook() { pTexture_pagemask->Release(); pSpellBookCloseBtnTextr->Release(); pSBQuickSpellBtnTextr->Release(); for ( uint i = 0; i < 9; ++i ) { pSpellBookPagesTextr[i]->Release(); pTextures_tabs[i][0]->Release(); pTextures_tabs[i][1]->Release(); } pAudioPlayer->PlaySound(SOUND_openbook, 0, 0, -1, 0, 0, 0, 0); pIcons_LOD->RemoveTexturesPackFromTextureList(); }