view UI/UIBooks.cpp @ 1394:8ea496564034

Some LightmapBuilder renames.
author Nomad
date Thu, 18 Jul 2013 16:51:35 +0200
parents ae435824ac4d
children a519a6a412d0
line wrap: on
line source

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <assert.h>

#include "..\MM7.h"

#include "UIBooks.h"
#include "..\Render.h"
#include "..\GUIWindow.h"
#include "..\GUIFont.h"
#include "..\AudioPlayer.h"
#include "..\LOD.h"
#include "..\Allocator.h"


#include "..\mm7_data.h"






//----- (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;
  }
}







//----- (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);
}




//----- (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();
}