diff UIBooks.cpp @ 1018:9ac94d00012e

Merge
author Grumpy7
date Tue, 21 May 2013 02:24:31 +0200
parents c45d51b3f4f4 e865f349aa41
children 39f42990698f
line wrap: on
line diff
--- a/UIBooks.cpp	Sun May 19 20:41:19 2013 +0200
+++ b/UIBooks.cpp	Tue May 21 02:24:31 2013 +0200
@@ -36,32 +36,59 @@
     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_CalendarBook:  BookUI_Calendar_Draw();   break;
+    case WINDOW_JournalBook:   BookUI_Journal_Draw();    break;
+
     case WINDOW_LloydsBeacon:  DrawLloydBeaconsScreen(); break;
     case WINDOW_TownPortal:    DrawTownPortalScreen();   break;
-    case WINDOW_HistoryBook:   DrawBook_History();       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
+  //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
+  //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;
-  v6 = pMapStats->GetMapInfo(pCurrentMapName);
-  a5 = TargetColor(0x4Bu, 0x4Bu, 0x4Bu);
   pRenderer->DrawTextureIndexed(pViewport->uViewportTL_X, pViewport->uViewportTL_Y, pSpellBookPagesTextr_13);
-  v7 = (unsigned __int8)pDayMoonPhase[pParty->uDaysPlayed];
   if ( (signed int)v0 <= 12 )
   {
     if ( !v0 )
@@ -77,7 +104,9 @@
   a1.uFrameHeight = game_viewport_height;
   a1.uFrameZ = game_viewport_z;
   a1.uFrameW = game_viewport_w;
-  a1.DrawTitleText(pBook2Font, 0, 0x16u, 0, pGlobalTXT_LocalizationStrings[186], 3u);
+  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 )
@@ -85,42 +114,40 @@
 	else
 		v2=1;
   }
-  else
-    v2=0;
-  v1 = GetDayPart();
-  sprintf(
-    pTmpBuf,
-    "%s\t100:\t110%d:%02d %s - %s",
-    pGlobalTXT_LocalizationStrings[526],
-    v0,
-    pParty->uCurrentMinute,
-    aAMPMNames[v2],
-    v1);
-  a1.DrawText(pBookFont, 70, 55, a5, pTmpBuf, 0, 0, 0);
-  sprintf(
-    pTmpBuf,
-    "%s\t100:\t110%d - %s",
-    pGlobalTXT_LocalizationStrings[56],
-    pParty->uDaysPlayed + 1,
-    aDayNames[pParty->uDaysPlayed % 7]);
-  a1.DrawText(pBookFont, 70, 2 * LOBYTE(pBookFont->uFontHeight) + 49, a5, pTmpBuf, 0, 0, 0);
-  sprintf(
-    pTmpBuf,
-    "%s\t100:\t110%d - %s",
-    pGlobalTXT_LocalizationStrings[146],
-    pParty->uCurrentMonth + 1,
-    aMonthNames[pParty->uCurrentMonth]);
-  a1.DrawText(pBookFont, 70, 4 * LOBYTE(pBookFont->uFontHeight) + 43, a5, pTmpBuf, 0, 0, 0);
-  sprintf(pTmpBuf, "%s\t100:\t110%d", pGlobalTXT_LocalizationStrings[245], pParty->uCurrentYear);
-  a1.DrawText(pBookFont, 70, 6 * LOBYTE(pBookFont->uFontHeight) + 37, a5, pTmpBuf, 0, 0, 0);
-  sprintf(pTmpBuf, "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[530], aMoonPhaseNames[v7]);
-  a1.DrawText(pBookFont, 70, 8 * LOBYTE(pBookFont->uFontHeight) + 31, a5, pTmpBuf, 0, 0, 0);
+
+  sprintf(pTmpBuf, "%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, 0, 0, 0);
+
+  sprintf(pTmpBuf, "%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, 0, 0, 0);
+
+  sprintf(pTmpBuf, "%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, 0, 0, 0);
+
+  sprintf(pTmpBuf, "%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, 0, 0, 0);
+
+  sprintf(pTmpBuf, "%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, 0, 0, 0);
+  
+  v6 = pMapStats->GetMapInfo(pCurrentMapName);
   if ( v6 )
     v3 = pMapStats->pInfos[v6].pName;
   else
     v3 = "Unknown";
-  sprintf(pTmpBuf, "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], v3);
-  a1.DrawText(pBookFont, 70, 10 * LOBYTE(pBookFont->uFontHeight) + 25, a5, pTmpBuf, 0, 0, 0);
+  sprintf(pTmpBuf, "%s\t100:\t110%s", pGlobalTXT_LocalizationStrings[531], v3); // "Location"
+  a1.DrawText(pBookFont, 70, 10 * LOBYTE(pBookFont->uFontHeight) + 25, ui_book_calendar_location_color, pTmpBuf, 0, 0, 0);
 }
 
 
@@ -137,7 +164,7 @@
   if ( !pIcons_LOD->uNumPrevLoadedFiles )
     pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
 
-  pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+  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);
@@ -145,7 +172,7 @@
   pTexture_50643C   = pIcons_LOD->LoadTexturePtr("ib-m6-u",TEXTURE_16BIT_PALETTE);
   //v0 = 1;
 
-  static const char *texNames[9] =
+  static const char *texNames[9] = // 004E24EC
   {
     "SBFB00", "SBAB00", "SBWB00", "SBEB00",
     "SBSB00", "SBMB00", "SBBB00", "SBLB00",
@@ -169,10 +196,12 @@
 void InitializeBookFonts()
 {
   pAudioPlayer->StopChannels(-1, -1);
+
   ++pIcons_LOD->uTexturePacksCount;
   if ( !pIcons_LOD->uNumPrevLoadedFiles )
     pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
-  pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+
+  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);
@@ -221,12 +250,11 @@
 }
 
 //----- (0041140B) --------------------------------------------------------
-GUIWindow *sub_41140B()
+void sub_41140B()
 {
   signed int v0; // esi@1
   GUIButton *v1; // eax@3
   GUIButton *v2; // esi@4
-  GUIWindow *result; // eax@5
 
   v0 = 0;
   do
@@ -236,7 +264,7 @@
     --v0;
   }
   while ( v0 >= -11 );
-  pIcons_LOD->_40F9C5();
+  pIcons_LOD->SyncLoadedFilesCount();
   v1 = pGUIWindow_CurrentMenu->pControlsHead;
   if ( v1 )
   {
@@ -250,9 +278,7 @@
   }
   pGUIWindow_CurrentMenu->pControlsHead = 0;
   pGUIWindow_CurrentMenu->pControlsTail = 0;
-  result = pGUIWindow_CurrentMenu;
   pGUIWindow_CurrentMenu->uNumControls = 0;
-  return result;
 }
 
 //----- (00411473) --------------------------------------------------------
@@ -267,7 +293,7 @@
       pTextures_tabs[i][0]->Release();
       pTextures_tabs[i][1]->Release();
       }
-  pAudioPlayer->PlaySound((SoundID)231, 0, 0, -1, 0, 0, 0, 0);
+  pAudioPlayer->PlaySound(SOUND_CloseBook, 0, 0, -1, 0, 0, 0, 0);
   pIcons_LOD->_4114F2();
 }
 
@@ -276,19 +302,18 @@
 void OnCloseSpellBook()
 {
   pAllocator->FreeChunk(pSpellFont);
-  pSpellFont = 0;
+  pSpellFont = nullptr;
   pAllocator->FreeChunk(pBookFont);
-  pBookFont = 0;
+  pBookFont = nullptr;
   pAllocator->FreeChunk(pBook2Font);
-  pBook2Font = 0;
+  pBook2Font = nullptr;
   pAllocator->FreeChunk(pAutonoteFont);
-  pAutonoteFont = 0;
+  pAutonoteFont = nullptr;
   pTexture_mapbordr->Release();
-  pAudioPlayer->PlaySound((SoundID)231, 0, 0, -1, 0, 0, 0, 0);
+  pAudioPlayer->PlaySound(SOUND_CloseBook, 0, 0, -1, 0, 0, 0, 0);
   pIcons_LOD->_4114F2();
   dword_506364 = 0;
 }
-// 506364: using guessed type int dword_506364;
 
 
 
@@ -296,224 +321,8 @@
 
 
 
-//----- (00412AF9) --------------------------------------------------------
-void sub_412AF9()
-{
-  int v0; // ecx@1
-
-  v0 = 0;
-  if ( uActiveCharacter )
-	  v0 = pParty->pPlayers[uActiveCharacter-1].lastOpenedSpellbookPage;//*((char *)&pParty->pPartyBuffs[5].uExpireTime + 6972 * uActiveCharacter + 2);
-  pRenderer->DrawTextureIndexed(8u, 8u, pSpellBookPagesTextr[v0]);
-  pRenderer->DrawTextureIndexed(0x1DCu, 0x1C2u, pTexture_50643C);
-  pRenderer->DrawTextureIndexed(0x231u, 0x1C2u, pTexture_506448);
-}
-
-//----- (00412B58) --------------------------------------------------------
-void DrawSpellBookContent()
-{
-  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;
-
-  sub_412AF9();
-  v0 = pPlayers[uActiveCharacter];
-  v1 = 11 * v0->lastOpenedSpellbookPage;
-  v2 = pIcons_LOD->FindTextureByName("Pending");
-  v3 = pIcons_LOD->GetTexture(v2);
-  pRenderer->ClearZBuffer(0, 479);
-  v4 = 1;
-  if ( __OFSUB__(v1, v1 + 11) ^ 1 )
-  {
-    do
-    {
-      if ( *(&v0->_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 = v0->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 + v1 - 1 < v1 + 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 = v0->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)&v0->pActiveSkills[12];
-  v14 = (unsigned int)&v0->pActiveSkills[12];
-  v15 = (unsigned int)&v0->pActiveSkills[12];
-  v25 = 0;
-  do
-  {
-    if ( *(short *)a2.x )
-    {
-      if ( v0->lastOpenedSpellbookPage == v13 )
-      {
-        pPageTexture = pTextures_tabs[v13][1];
-        switch ( v13 )
-        {
-          case 0:
-            v14 = 406;
-            v22 = 9;
-            goto LABEL_27;
-          case 1:
-            v14 = 406;
-            goto LABEL_38;
-          case 2:
-            v14 = 406;
-            v22 = 84;
-            goto LABEL_27;
-          case 3:
-            v14 = 406;
-            goto LABEL_26;
-          case 4:
-            v14 = 407;
-            goto LABEL_29;
-          case 5:
-            v15 = 196;
-            goto LABEL_34;
-          case 6:
-            v15 = 234;
-            goto LABEL_34;
-          case 7:
-            v15 = 272;
-            goto LABEL_34;
-          case 8:
-            v15 = 309;
-LABEL_34:
-            v14 = 405;
-            break;
-          default:
-            break;
-        }
-      }
-      else
-      {
-        pPageTexture = pTextures_tabs[v13][0];
-        switch ( v13 )
-        {
-          case 0:
-            v14 = 415;
-            v22 = 10;
-            goto LABEL_27;
-          case 1:
-            v14 = 415;
-LABEL_38:
-            v22 = 46;
-            goto LABEL_27;
-          case 2:
-            v14 = 415;
-            v22 = 83;
-            goto LABEL_27;
-          case 3:
-            v14 = 415;
-LABEL_26:
-            v22 = 121;
-LABEL_27:
-            v15 = v22;
-            break;
-          case 4:
-            v14 = 415;
-LABEL_29:
-            v15 = 158;
-            break;
-          case 5:
-            v15 = 196;
-            goto LABEL_46;
-          case 6:
-            v15 = 234;
-            goto LABEL_46;
-          case 7:
-            v15 = 271;
-            goto LABEL_46;
-          case 8:
-            v15 = 307;
-LABEL_46:
-            v14 = 416;
-            break;
-          default:
-            break;
-        }
-      }
-      pRenderer->DrawTextureTransparent(v14, v15, pPageTexture);
-      v13 = v25;
-    }
-    a2.x += 2;
-    ++v13;
-    v25 = v13;
-  }
-  while ( v13 < 9 );
-}
-// 506408: using guessed type int dword_506408[];
-// 50654C: using guessed type int dword_50654C;
-
 //----- (00412E85) --------------------------------------------------------
-void DrawBook_History()
+void BookUI_Journal_Draw()
 {
   unsigned int v0; // eax@3
   unsigned int v1; // eax@7
@@ -545,6 +354,7 @@
     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;
@@ -558,6 +368,7 @@
     v1 = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(v1, v12, v14);
+
   if ( !byte_5C6D50[dword_506528] )
   {
     v2 = achieved_awards[dword_506528];
@@ -569,8 +380,9 @@
     a1.uFrameZ = game_viewport_z;
     a1.uFrameW = game_viewport_w;
     if ( v3 )
-      a1.DrawTitleText(pBook2Font, 0, 22, 0, v3, 3);
+      a1.DrawTitleText(pBook2Font, 0, 22, ui_book_journal_title_color, v3, 3);
   }
+
   a1.uFrameX = 48;
   a1.uFrameY = 70;
   a1.uFrameWidth = 360;
@@ -581,14 +393,14 @@
   a1.uFrameW = a1.uFrameHeight + 69;
   if ( BtnDown_flag && dword_506528 + num_achieved_awards < num_achieved_awards_2 )
   {
-    pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+    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((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+    pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
     --dword_50651C;
     dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
   }
@@ -613,7 +425,7 @@
   if ( v7 )
   {
     v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[dword_506528]);
-    a1.DrawText(pAutonoteFont, 1, 0, 0, (const char *)v9, 0, a1.uFrameY + a1.uFrameHeight, 0);
+    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;
   }
 }
@@ -679,14 +491,14 @@
   a1.uFrameW = 333;
   if ( BtnDown_flag && dword_506528 + num_achieved_awards < num_achieved_awards_2 )
   {
-    pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+    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((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+    pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
     --dword_50651C;
     dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
   }
@@ -980,14 +792,14 @@
         v11 = dword_50651C++;
         byte_506130[v11] = num_achieved_awards;
         dword_506528 = v10;
-        pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+        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((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
+      pAudioPlayer->PlaySound(SOUND_OpenBook, 0, 0, -1, 0, 0, 0, 0);
     }
     if ( !num_achieved_awards || dword_506528 < 1 )
     {
@@ -1655,3 +1467,225 @@
 
 
 
+
+
+//----- (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;
+
+  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 + v1 - 1 < v1 + 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];
+        switch ( v13 )
+        {
+          case 0:
+            v14 = 406;
+            v22 = 9;
+            goto LABEL_27;
+          case 1:
+            v14 = 406;
+            goto LABEL_38;
+          case 2:
+            v14 = 406;
+            v22 = 84;
+            goto LABEL_27;
+          case 3:
+            v14 = 406;
+            goto LABEL_26;
+          case 4:
+            v14 = 407;
+            goto LABEL_29;
+          case 5:
+            v15 = 196;
+            goto LABEL_34;
+          case 6:
+            v15 = 234;
+            goto LABEL_34;
+          case 7:
+            v15 = 272;
+            goto LABEL_34;
+          case 8:
+            v15 = 309;
+LABEL_34:
+            v14 = 405;
+            break;
+          default:
+            break;
+        }
+      }
+      else
+      {
+        pPageTexture = pTextures_tabs[v13][0];
+        switch ( v13 )
+        {
+          case 0:
+            v14 = 415;
+            v22 = 10;
+            goto LABEL_27;
+          case 1:
+            v14 = 415;
+LABEL_38:
+            v22 = 46;
+            goto LABEL_27;
+          case 2:
+            v14 = 415;
+            v22 = 83;
+            goto LABEL_27;
+          case 3:
+            v14 = 415;
+LABEL_26:
+            v22 = 121;
+LABEL_27:
+            v15 = v22;
+            break;
+          case 4:
+            v14 = 415;
+LABEL_29:
+            v15 = 158;
+            break;
+          case 5:
+            v15 = 196;
+            goto LABEL_46;
+          case 6:
+            v15 = 234;
+            goto LABEL_46;
+          case 7:
+            v15 = 271;
+            goto LABEL_46;
+          case 8:
+            v15 = 307;
+LABEL_46:
+            v14 = 416;
+            break;
+          default:
+            break;
+        }
+      }
+      pRenderer->DrawTextureTransparent(v14, v15, pPageTexture);
+      v13 = v25;
+    }
+    a2.x += 2;
+    ++v13;
+    v25 = v13;
+  }
+  while ( v13 < 9 );
+}
\ No newline at end of file