view UI/Books/UINotesBooks.cpp @ 1450:8ff3c675a726

more renaming TE
author Gloval
date Wed, 07 Aug 2013 08:55:34 +0400
parents 0c462cc807a1
children dfc9484ed94c
line wrap: on
line source


#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#include <assert.h>

#include "..\..\MM7.h"
#include "..\..\Render.h"
#include "..\..\Mouse.h"
#include "..\UIBooks.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"




//----- (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()
{
  int am; // ecx@5
  char *pMapName; // eax@6
  GUIWindow calendar_window; // [sp+Ch] [bp-60h]@5
  unsigned int pMapID; // [sp+60h] [bp-Ch]@1
  unsigned int pHour;

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

  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_13);
  pHour = pParty->uCurrentHour;
  if ( (signed int)pHour >= 12 )
  {
    pHour -= 12;
    if ( !pHour )
      pHour = 12;
    am = 1;
  }
  else
    am = 0;

  calendar_window.uFrameX = game_viewport_x;
  calendar_window.uFrameY = game_viewport_y;
  calendar_window.uFrameWidth = game_viewport_width;
  calendar_window.uFrameHeight = game_viewport_height;
  calendar_window.uFrameZ = game_viewport_z;
  calendar_window.uFrameW = game_viewport_w;
  calendar_window.DrawTitleText(pBook2Font, 0, 22, ui_book_calendar_title_color, pGlobalTXT_LocalizationStrings[186], 3); // "Time in Erathia"

  sprintf(pTmpBuf.data(), "%s\t100:\t110%d:%02d %s - %s", pGlobalTXT_LocalizationStrings[526], // "Time"
     pHour, pParty->uCurrentMinute, aAMPMNames[am], GetDayPart());
  calendar_window.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]);
  calendar_window.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]);
  calendar_window.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"
  calendar_window.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"
  calendar_window.DrawText(pBookFont, 70, 8 * LOBYTE(pBookFont->uFontHeight) + 31, ui_book_calendar_moon_color, pTmpBuf.data(), 0, 0, 0);

  pMapID = pMapStats->GetMapInfo(pCurrentMapName.data());
  if ( pMapID )
    pMapName = pMapStats->pInfos[pMapID].pName;
  else
    pMapName = "Unknown";
  sprintf(pTmpBuf.data(), "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], pMapName); // "Location"
  calendar_window.DrawText(pBookFont, 70, 10 * LOBYTE(pBookFont->uFontHeight) + 25, ui_book_calendar_location_color, pTmpBuf.data(), 0, 0, 0);
}

//----- (00413126) --------------------------------------------------------
void BookUI_Questbook_Draw()
{
  int pTextHeight; // eax@19
  GUIWindow questbook_window; // [sp+Ch] [bp-54h]@9

  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_CurrentBook);
  if ( BtnUp_flag || !books_primary_item_per_page )//Bookmark Up(Закладка вверх)
    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 2, pTex_tab_an_6a__zoom_off);
  else
    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_tab_an_6b__zoom_on);

  if ( BtnDown_flag || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book )//Bookmark Down(Закладка вниз)
    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 38, pTex_tab_an_7a__zoot_off);
  else
    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_tab_an_7b__zoot_on);

  questbook_window.uFrameWidth = game_viewport_width;
  questbook_window.uFrameHeight = game_viewport_height;
  questbook_window.uFrameX = game_viewport_x;
  questbook_window.uFrameY = game_viewport_y;
  questbook_window.uFrameZ = game_viewport_z;
  questbook_window.uFrameW = game_viewport_w;
  questbook_window.DrawTitleText(pBook2Font, 0, 22, ui_book_quests_title_color, pGlobalTXT_LocalizationStrings[174], 3); //"Current Quests"

  questbook_window.uFrameX = 48;
  questbook_window.uFrameY = 70;
  questbook_window.uFrameWidth = 360;
  questbook_window.uFrameHeight = 264;
  questbook_window.uFrameZ = 407;
  questbook_window.uFrameW = 333;
  if ( BtnDown_flag && books_primary_item_per_page + num_achieved_awards < full_num_items_in_book )//Click Bookmark Down
  {
    pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
    books_primary_item_per_page += num_achieved_awards;
    books_num_items_per_page[books_page_number++] = num_achieved_awards;
  }
  if ( BtnUp_flag && books_page_number )//Click Bookmark Up
  {
    pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
    --books_page_number;
    books_primary_item_per_page -= (unsigned __int8)books_num_items_per_page[books_page_number];
  }
  if ( !num_achieved_awards || !books_primary_item_per_page )
  {
    books_page_number = 0;
    books_primary_item_per_page = 0;
  }
  BtnDown_flag = 0;
  BtnUp_flag = 0;
  num_achieved_awards = 0;
  for ( uint i = books_primary_item_per_page; i < full_num_items_in_book; ++i )
  {
    ++num_achieved_awards;
    //v5 = pQuestTable[achieved_awards[v3]];//(&dword_722F10)[4 * v4];
    questbook_window.DrawText(pAutonoteFont, 1, 0, ui_book_quests_text_color, pQuestTable[achieved_awards[i]], 0, 0, 0);//(&dword_722F10)[4 * v4], 0, 0, 0);
    pTextHeight = pAutonoteFont->CalcTextHeight(pQuestTable[achieved_awards[i]], &questbook_window, 1, 0);
    if ( (signed int)(questbook_window.uFrameY + pTextHeight) > (signed int)questbook_window.uFrameHeight )
      break;
    pRenderer->DrawTextureTransparent(100, (questbook_window.uFrameY + pTextHeight) + 12, pSpellBookPagesTextr_10);
    questbook_window.uFrameY = (questbook_window.uFrameY + pTextHeight) + 24;
  }
}

//----- (0041338E) --------------------------------------------------------
void BookUI_Autonotes_Draw()
{
  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 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 *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 autonotes_window; // [sp+14h] [bp-54h]@46

  v31 = 0;
  pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pTexture_AutonotesBook);
  if ( BtnUp_flag || !books_primary_item_per_page )
    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 2, pTex_tab_an_6a__zoom_off);
  else
    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_tab_an_6b__zoom_on);

  if ( BtnDown_flag || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book )
    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 407, pViewport->uViewportTL_Y + 38, pTex_tab_an_7a__zoot_off);
  else
    pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_tab_an_7b__zoot_on);

  if ( Book_PageBtn3_flag )//Potions_page_flag
  {
    if (_506568_autonote_type == AUTONOTE_POTION_RECEPIE)//press again(повторное нажатие)
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTexture_506394);
    else//press(нажатие)
    {
      v31 = 1;
      pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
      _506568_autonote_type = AUTONOTE_POTION_RECEPIE;
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTexture_506394);
    }
  }
  else 
  {
    if (_506568_autonote_type == AUTONOTE_POTION_RECEPIE)// default(по умолчанию при запуске окна)
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, pTexture_506394);
    else//Potions_page not active(вкладка снадобья не активна)
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 113, pTexture_506390);
  }

  if ( Book_PageBtn4_flag )//Fontains_page_flag
  {
    if ( _506568_autonote_type == AUTONOTE_STAT_HINT )
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTexture_50638C);
    else
    {
      v31 = 1;
      pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
      _506568_autonote_type = AUTONOTE_STAT_HINT;
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTexture_50638C);
    }
  }
  else
  {
    if ( _506568_autonote_type == AUTONOTE_STAT_HINT )
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, pTexture_50638C);
    else
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 150, pTexture_506388);
  }

  if ( Book_PageBtn5_flag )//Autonotes_Obelisks_page_flag
  {
    if ( _506568_autonote_type == AUTONOTE_OBELISK)
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTexture_506384);
    else
    {
      v31 = 1;
      pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
      _506568_autonote_type = AUTONOTE_OBELISK;
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTexture_506384);
    }
  }
  else
  {
    if ( _506568_autonote_type == AUTONOTE_OBELISK)
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, pTexture_506384);
    else
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 188, pTexture_506380);
  }

  if ( Book_PageBtn6_flag )//Autonotes_Seer_page_flag
  {
    if ( _506568_autonote_type == AUTONOTE_SEER)
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTexture_50637C);
    else
    {
      v31 = 1;
      pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
      _506568_autonote_type = AUTONOTE_SEER;
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTexture_50637C);
    }
  }
  else
  {
    if ( _506568_autonote_type == AUTONOTE_SEER)
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, pTexture_50637C);
    else
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 226, pTexture_506378);
  }

  if ( Autonotes_Misc_page_flag )
  {
    if ( _506568_autonote_type == AUTONOTE_MISC)
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, pTexture_506374);
    else
    {
      v31 = 1;
      pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
      _506568_autonote_type = AUTONOTE_MISC;
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, pTexture_506374);
    }
  }
  else
  {
    if ( _506568_autonote_type == AUTONOTE_MISC)
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, pTexture_506374);
    else
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 263, pTexture_506370);
  }

  if ( Autonotes_Instructors_page_flag )
  {
    if ( _506568_autonote_type == AUTONOTE_TEACHER)
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, pTexture_50636C);
    else
    {
      v31 = 1;
      pAudioPlayer->PlaySound(SOUND_Button2, 0, 0, -1, 0, 0, 0, 0);
      _506568_autonote_type = AUTONOTE_TEACHER;
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, pTexture_50636C);
    }
  }
  else
  {
    if ( _506568_autonote_type == AUTONOTE_TEACHER)
      pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, pTexture_50636C);
    else
     pRenderer->DrawTextureTransparent(pViewport->uViewportTL_X + 408, pViewport->uViewportTL_Y + 302, pTexture_506368);
  }

  autonotes_window.uFrameWidth = game_viewport_width;
  autonotes_window.uFrameHeight = game_viewport_height;
  autonotes_window.uFrameX = game_viewport_x;
  autonotes_window.uFrameY = game_viewport_y;
  autonotes_window.uFrameZ = game_viewport_z;
  autonotes_window.uFrameW = game_viewport_w;
  autonotes_window.DrawTitleText(pBook2Font, 0, 22, ui_book_autonotes_title_color, pGlobalTXT_LocalizationStrings[154], 3); // "Auto notes"

  autonotes_window.uFrameX = 48;
  autonotes_window.uFrameY = 70;
  autonotes_window.uFrameWidth = 360;
  autonotes_window.uFrameHeight = 264;
  autonotes_window.uFrameZ = 407;
  autonotes_window.uFrameW = 333;
  if ( v31 )
  {
    full_num_items_in_book = 0;
    books_primary_item_per_page = 0;
    books_page_number = 0;
    num_achieved_awards = 0;
    v8 = 0;
    do
    {
      //if ( dword_72371C[2 * v8] == dword_506568 )
      if ( pAutonoteTxt[v8].eType == _506568_autonote_type )
      {
        //v32 = (&dword_723718_autonote_related)[8 * (signed __int16)v8];
        v32 = (char *)pAutonoteTxt[v8].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 );
    full_num_items_in_book = num_achieved_awards;
  }
  else
  {
    if ( BtnDown_flag )
    {
      v10 = num_achieved_awards + books_primary_item_per_page;
      if ( num_achieved_awards + books_primary_item_per_page < full_num_items_in_book )
      {
        v11 = books_page_number++;
        books_num_items_per_page[v11] = num_achieved_awards;
        books_primary_item_per_page = v10;
        pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
      }
    }
    if ( BtnUp_flag && books_page_number )
    {
      --books_page_number;
      books_primary_item_per_page -= (unsigned __int8)books_num_items_per_page[books_page_number];
      pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
    }
    if ( !num_achieved_awards || books_primary_item_per_page < 1 )
    {
      books_primary_item_per_page = 0;
      books_page_number = 0;
    }
  }
  v12 = books_primary_item_per_page;
  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 < full_num_items_in_book )
  {
    v13 = achieved_awards[v12];
    ++num_achieved_awards;
    //v14 = (&dword_723718_autonote_related)[8 * v13];
    v14 = pAutonoteTxt[v13].pText;
    //a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_723718_autonote_related)[8 * v13], 0, 0, 0);
    autonotes_window.DrawText(pAutonoteFont, 1, 0, ui_book_autonotes_text_color, pAutonoteTxt[v13].pText, 0, 0, 0);
    v15 = pAutonoteFont->CalcTextHeight(v14, &autonotes_window, 1, 0);
    v16 = autonotes_window.uFrameY + v15;
    if ( (signed int)(autonotes_window.uFrameY + v15) > (signed int)autonotes_window.uFrameHeight )
      break;
    pRenderer->DrawTextureTransparent(0x64u, v16 + 12, pSpellBookPagesTextr_10);
    ++v12;
    autonotes_window.uFrameY = v16 + 24;
  }
}

    //----- (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 || !books_primary_item_per_page )
  {
    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 || books_primary_item_per_page + num_achieved_awards >= full_num_items_in_book )
  {
    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[books_primary_item_per_page] )
  {
    v2 = achieved_awards[books_primary_item_per_page];
    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 && books_primary_item_per_page + num_achieved_awards < full_num_items_in_book )
  {
    pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
    v5 = books_page_number++;
    books_primary_item_per_page += num_achieved_awards;
    books_num_items_per_page[v5] = num_achieved_awards;
  }
  if ( BtnUp_flag && books_page_number )
  {
    pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
    --books_page_number;
    books_primary_item_per_page -= (unsigned __int8)books_num_items_per_page[books_page_number];
  }
  if ( !num_achieved_awards || books_primary_item_per_page < 1 )
  {
    books_primary_item_per_page = 0;
    books_page_number = 0;
  }
  BtnDown_flag = 0;
  v6 = achieved_awards[books_primary_item_per_page];
  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 = BuildDialogueString(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[books_primary_item_per_page]);
    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;
  }
}