changeset 951:840b78f6c2d3

Слияние
author Ritor1
date Wed, 01 May 2013 23:36:54 +0600
parents 5e87b0c3f939 (current diff) c0d0656aa662 (diff)
children a92a34f9aef5
files mm7_6.cpp
diffstat 36 files changed, 1390 insertions(+), 1722 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/Actor.cpp	Wed May 01 23:36:54 2013 +0600
@@ -173,7 +173,7 @@
   NPCData *v5; // ebp@1
   unsigned int v6; // eax@1
   //signed int v7; // eax@3
-  unsigned int v8; // eax@8
+  //unsigned int v8; // eax@8
   int v9; // esi@8
   int v10; // eax@11
   GUIWindow *v11; // ecx@19
@@ -202,18 +202,6 @@
   v6 = v4->uFlags;
   if ( (v6 & 3) != 2 )
     v5->uFlags = v6 + 1;
-  /*v7 = const_2();
-  sprintf(pContainer, "evt%02d", v7);
-  if (pParty->alignment == PartyAlignment_Good)
-  {
-    v14 = "-b";
-    strcat(pContainer, v14);
-  }
-  else if ( pParty->uAlignment == 2 )
-  {
-    v14 = "-c";
-    strcat(pContainer, v14);
-  }*/
 
   switch (pParty->alignment)
   {
@@ -222,13 +210,12 @@
     case PartyAlignment_Evil:    sprintf(pContainer, "evt%02d-c", const_2()); break;
   }
 
-  v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
   pDialogueNPCCount = 0;
   uNumDialogueNPCPortraits = 1;
-  pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v8];
+  pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
   sprintf(pContainer, "npc%03u", v5->uPortraitID);
   v9 = 0;
-  pDialogueNPCPortraits[0] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
+  pDialogueNPCPortraits[0] = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
   dword_591084 = areWeLoadingTexture;
   uTextureID_right_panel_loop = uTextureID_right_panel;
   if ( !v5->Hired() && v5->Location2D >= 0 )
@@ -270,7 +257,7 @@
   }
   if ( (sDialogue_SpeakingActorNPC_ID & 0x80000000u) != 0 )
     v9 = 4;
-  v11 = GUIWindow::Create(0, 0, 640, 480, (enum WindowType)10, v9, 0);
+  v11 = GUIWindow::Create(0, 0, 640, 480, WINDOW_Rest, v9, 0);
   pDialogueWindow = v11;
   if (v5->Hired())
   {
@@ -281,15 +268,11 @@
       {
         if ( v12 <= 12 || v12 > 32 && (v12 <= 34 || v12 > 38 && (v12 <= 43 || v12 == 52)) )
         {
-          v11->CreateButton(
-            0x1E0u,
-            0xFAu,
-            0x8Cu,
-            LOBYTE(pFontArrus->uFontHeight) - 3,
+          v11->CreateButton(480, 250, 140, LOBYTE(pFontArrus->uFontHeight) - 3,
             1,
             0,
             UIMSG_SelectNPCDialogueOption,
-            9u,
+            9,
             0,
             "",
             0);
@@ -298,10 +281,12 @@
       }
     }
   }
-  pDialogueWindow->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-  pDialogueWindow->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-  pDialogueWindow->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-  pDialogueWindow->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
+
+  pDialogueWindow->CreateButton( 61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
+  pDialogueWindow->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
+  pDialogueWindow->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
+  pDialogueWindow->CreateButton(407, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0);
+
   if (v17 && uActiveCharacter && !v5->Hired())
   {
     if (pParty->uCurrentHour < 5 || pParty->uCurrentHour > 21)
--- a/Arcomage.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/Arcomage.cpp	Wed May 01 23:36:54 2013 +0600
@@ -5710,13 +5710,13 @@
     do
     {
       if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v11, 1) )
-        _449B7E_toggle_bit((unsigned char *)v11, 103, 1u);
+        _449B7E_toggle_bit((unsigned char *)v11, PLAYER_GUILD_BITS__ARCOMAGE_WIN, 1);
       v11 += 6972;
     }
     while ( (signed int)v11 < (signed int)((char *)&pParty->StandartItemsInShops[36] + 2) );
-    ++pParty->field_874;
-    if ( pParty->field_874 > 1000000 )
-      pParty->field_874 = 1000000;
+    ++pParty->uNumArcomageWins;
+    if ( pParty->uNumArcomageWins > 1000000 )
+      pParty->uNumArcomageWins = 1000000;
   }
   else
   {
@@ -5724,13 +5724,13 @@
     do
     {
       if ( !(unsigned __int16)_449B57_test_bit((unsigned __int8 *)v12, 1) )
-        _449B7E_toggle_bit((unsigned char *)v12, 104, 1u);
+        _449B7E_toggle_bit((unsigned char *)v12, PLAYER_GUILD_BITS__ARCOMAGE_LOSE, 1);
       v12 += 6972;
     }
     while ( (signed int)v12 < (signed int)((char *)&pParty->StandartItemsInShops[36] + 2) );
-    ++pParty->field_878;
-    if ( pParty->field_878 > 1000000 )
-      pParty->field_878 = 1000000;
+    ++pParty->uNumArcomageLoses;
+    if ( pParty->uNumArcomageLoses > 1000000 )
+      pParty->uNumArcomageLoses = 1000000;
   }
   return 0;
 }
--- a/Awards.h	Wed May 01 23:36:40 2013 +0600
+++ b/Awards.h	Wed May 01 23:36:54 2013 +0600
@@ -5,8 +5,123 @@
 #pragma pack(push, 1)
 struct Award
 {
-  const char *pText;
-  unsigned int uSort;
+  const char   *pText;
+  unsigned int  uPriority;
 };
 #pragma pack(pop)
-extern Award pAwards[104];
\ No newline at end of file
+extern Award pAwards[104];
+
+
+
+enum AwardType: unsigned __int32
+{
+    Award_Invalid = 0
+  , Award_Fine = 1
+  , Award_EmeraldIsle_CompletedMainQuest = 2
+  , Award_EmeraldIsle_FoundMissingCompetitors = 3
+  , Award_Harmondale_CastleCleared = 4
+  , Award_BarrowDowns_RescuedMiners = 5
+  , Award_Erathia_RescuedLorenSteel = 6
+  , Award_Avlee_BroughtFakeLorenSteelToErathia = 7
+  , Award_Avlee_BroughtFortRiverstridePlans = 8
+  , Award_Erathia_DeliveredFakePlansToElves = 9
+  , Award_Promotion_Rogue = 10
+  , Award_Promotion_Rogue_Honorary = 11
+  , Award_Promotion_Spy = 12
+  , Award_Promotion_Spy_Honorary = 13
+  , Award_Promotion_Assassin = 14
+  , Award_Promotion_Assassin_Honorary = 15
+  , Award_Promotion_Chevalier = 16
+  , Award_Promotion_Chevalier_Honorary = 17
+  , Award_Promotion_Champion = 18
+  , Award_Promotion_Champion_Honorary = 19
+  , Award_Promotion_BlackKnight = 20
+  , Award_Promotion_BlackKnight_Honorary = 21
+  , Award_Promotion_Initiate = 22
+  , Award_Promotion_Initiate_Honorary = 23
+  , Award_Promotion_Master = 24
+  , Award_Promotion_Master_Honorary = 25
+  , Award_Promotion_Ninja = 26
+  , Award_Promotion_Ninja_Honorary = 27
+  , Award_Promotion_Hunter = 28
+  , Award_Promotion_Hunter_Honorary = 29
+  , Award_Promotion_RangerLord = 30
+  , Award_Promotion_RangerLord_Honorary = 31
+  , Award_Promotion_BountyHunter = 32
+  , Award_Promotion_BountyHunter_Honorary = 33
+  , Award_Promotion_WarriorMage = 34
+  , Award_Promotion_WarriorMage_Honorary = 35
+  , Award_Promotion_MasterArcher = 36
+  , Award_Promotion_MasterArcher_Honorary = 37
+  , Award_Promotion_Sniper = 38
+  , Award_Promotion_Sniper_Honorary = 39
+  , Award_Promotion_Crusader = 40
+  , Award_Promotion_Crusader_Honorary = 41
+  , Award_Promotion_Hero = 42
+  , Award_Promotion_Hero_Honorary = 43
+  , Award_Promotion_Villian = 44
+  , Award_Promotion_Villian_Honorary = 45
+  , Award_Celestia_SurvivedWallOfMist = 46
+  , Award_47 = 47
+  , Award_KilledXenofex = 48
+  , Award_Tatalia_SolvedWineCellarMystery = 49
+  , Award_Membership_ElementalGuilds = 50
+  , Award_Membership_SelfGuilds = 51
+  , Award_Membership_AirGuild = 52
+  , Award_Membership_EarthGuild = 53
+  , Award_Membership_FireGuild = 54
+  , Award_Membership_WaterGuild = 55
+  , Award_Membership_BodyGuild = 56
+  , Award_Membership_MindGuild = 57
+  , Award_Membership_SpiritGuild = 58
+  , Award_Membership_LightGuild = 59
+  , Award_Membership_DarkGuild = 60
+  , Award_Avlee_RetrievedForestHeart = 61
+  , Award_Promotion_Priest = 62
+  , Award_Promotion_Priest_Honorary = 63
+  , Award_Promotion_PriestOfLight = 64
+  , Award_Promotion_PriestOfLight_Honorary = 65
+  , Award_Promotion_PriestOfDark = 66
+  , Award_Promotion_PriestOfDark_Honorary = 67
+  , Award_Promotion_GreatDruid = 68
+  , Award_Promotion_GreatDruid_Honorary = 69
+  , Award_Promotion_ArchDruid = 70
+  , Award_Promotion_ArchDruid_Honorary = 71
+  , Award_Promotion_Warlock = 72
+  , Award_Promotion_Warlock_Honorary = 73
+  , Award_Promotion_Wizard = 74
+  , Award_Promotion_Wizard_Honorary = 75
+  , Award_Promotion_Archmage = 76
+  , Award_Promotion_Archmage_Honorary = 77
+  , Award_Promotion_Lich = 78
+  , Award_Promotion_Lich_Honorary = 79
+  , Award_ThePit_RetrievedSoulJars = 80
+  , Award_Celestia_KilledTolberti = 81
+  , Award_ThePit_ClearedKlankersLab = 82
+  , Award_ThePit_KilledRobertTheWise = 83
+  , Award_ThePit_SurvivedBreedingZone = 84
+  , Award_Deaths = 85
+  , Award_BountiesCollected = 86
+  , Award_PrisonTerms = 87
+  , Award_Arena_PageWins = 88
+  , Award_Arena_SquireWins = 89
+  , Award_Arena_KnightWins = 90
+  , Award_Arena_LordWins = 91
+  , Award_Harmondale_ReturnedLanterOfLight = 92
+  , Award_Nighon_RetrievedHaldarsRemains = 93
+  , Award_Harmondale_ReturnedDavriksSignetRing = 94
+  , Award_Erathia_ReturnedParsonsQuill = 95
+  , Award_RetrievedFaeriePipes = 96
+  , Award_BarrowDowns_KilledTroglodytesInLowerCity = 97
+  , Award_Deyja_KilledAllGriffins = 98
+  , Award_Bracada_RetrievedSeasonsStole = 99
+  , Award_Avlee_PlacedThreeStatuettes = 100
+  , Award_101 = 101
+  , Award_ArcomageChampion = 102
+  , Award_ArcomageWins = 103
+  , Award_ArcomageLoses = 104
+
+};
+extern AwardType achieved_awards[1000];
+extern int       num_achieved_awards;
+extern int       num_achieved_awards_2;
\ No newline at end of file
--- a/Chest.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/Chest.cpp	Wed May 01 23:36:54 2013 +0600
@@ -239,11 +239,11 @@
   }
   dword_507CD8 = 0;
 
-  pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Chest, uChestID, 0);
-  pChestWindow = pGUIWindow_CurrentMenu;
-  pBtn_ExitCancel = pChestWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1,  0,  UIMSG_Escape,  0, 0,  pGlobalTXT_LocalizationStrings[79],// Exit
-                 (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0),   0);
-  pChestWindow->CreateButton(7u, 8u, 460u, 343u, 1, 0, UIMSG_C, 0, 0, "", 0);
+  pChestWindow = pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Chest, uChestID, 0);
+
+  pBtn_ExitCancel = pChestWindow->CreateButton(471, 445, 169,  35, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], pIcons_LOD->GetTexture(uExitCancelTextureId),   0);// Exit
+                    pChestWindow->CreateButton(  7,   8, 460, 343, 1, 0, UIMSG_C,      0, 0, "", 0);
+
   pCurrentScreen = SCREEN_CHEST;
   pEventTimer->Pause();
   return 1;
@@ -282,7 +282,7 @@
     chestHeghtCells = pChestHeightsByType[chestBitmapId];
     sprintf(pTmpBuf, "chest%02d", pChestList->pChests[chestBitmapId].uTextureID);
     v5 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE);
-    pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0));
+    pRenderer->DrawTextureIndexed(8u, 8u, pIcons_LOD->GetTexture(v5));
 
     for (item_counter = 0; item_counter< chestWidthCells * chestHeghtCells; ++item_counter)
         {
@@ -292,9 +292,9 @@
             item_texture_id = pIcons_LOD->LoadTexture(
                 //pItemsTable->pItems[*(int *)((char *)&pOtherOverlayList->pOverlays[49].field_4 + 36 * v6 + v3 * 5324)].pIconName,
                 pItemsTable->pItems[pChests[uChestID].igChestItems[chest_item_index-1].uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-            item_texture = (Texture *)(item_texture_id != -1 ? &pIcons_LOD->pTextures[item_texture_id] : 0);
-            itemPixelWidth = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureWidth : 24);
-            itemPixelHeght = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureHeight : 26);
+            item_texture = pIcons_LOD->GetTexture(item_texture_id);
+            itemPixelWidth = item_texture->uTextureWidth;
+            itemPixelHeght = item_texture->uTextureHeight;
             if ( itemPixelWidth < 14 )
                 itemPixelWidth = 14;
             v12 = itemPixelWidth - 14;
@@ -309,8 +309,7 @@
             sub_40F92A(&v16[itemPixelPosX + pSRZBufferLineOffsets[itemPixelPosY]], item_texture, item_counter + 1);
             }
         }
-    pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY,
-        (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0));
+    pRenderer->DrawTextureIndexed(pBtn_ExitCancel->uX, pBtn_ExitCancel->uY, pIcons_LOD->GetTexture(uExitCancelTextureId));
     }
 
 
@@ -336,8 +335,8 @@
     chest_cell_heght = pChestHeightsByType[pChests[uChestID].uChestBitmapID];
     chest_cell_width = pChestWidthsByType[pChests[uChestID].uChestBitmapID];
     item_texture_id = pIcons_LOD->LoadTexture(pItemsTable->pItems[item_id].pIconName, TEXTURE_16BIT_PALETTE);
-    item_texture = (Texture *)(item_texture_id != -1 ? (int)&pIcons_LOD->pTextures[item_texture_id] : 0);
-    v6 = (item_texture_id != -1 ? pIcons_LOD->pTextures[item_texture_id].uTextureWidth : 24);
+    item_texture = pIcons_LOD->GetTexture(item_texture_id);
+    v6 = item_texture->uTextureWidth;
     if ( v6 < 14 )
         v6 = 14;
     texture_cell_width = (v6 - 14 >> 5) + 1;
@@ -417,7 +416,7 @@
   int result; // eax@11
   unsigned int v7; // eax@12
   int v8; // edx@12
-  int v9; // ecx@12
+  Texture *v9; // ecx@12
   signed int v10; // eax@12
   signed int v11; // edi@14
   unsigned int v12; // esi@14
@@ -464,11 +463,11 @@
     }
     v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v4->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
     HIWORD(v8) = 0;
-    v9 = v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0;
-    v10 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
+    v9 = pIcons_LOD->GetTexture(v7);
+    v10 = v9->uTextureWidth;
     if ( v10 < 14 )
       v10 = 14;
-    v11 = *(short *)(v9 + 26);
+    v11 = v9->uTextureHeight;
     v12 = ((v10 - 14) >> 5) + 1;
     if ( v11 < 14 )
       v11 = 14;
@@ -539,8 +538,8 @@
         pChests[ uChestID].igChestItems[item_at_cell].uMaxCharges = v6;
         }
     v7 = pIcons_LOD->LoadTexture(pItemsTable->pItems[uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-    v8 = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
-    v9 = (v7 != -1 ? pIcons_LOD->pTextures[v7].uTextureWidth : 24);
+    v8 = pIcons_LOD->GetTexture(v7);
+    v9 = v8->uTextureWidth;
     if ( v9 < 14 )
         v9 = 14;
     v10 = v8->uTextureHeight;
@@ -773,8 +772,8 @@
     //v17 = pChestWidthsByType[*(short *)((char *)v2 + (int)pChests)];
 	v17 = pChestWidthsByType[pChests[v20].uChestBitmapID];
     v4 = pIcons_LOD->LoadTexture(pItemsTable->pItems[v3->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
-    v5 = (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0);
-    v6 = (v4 != -1 ? pIcons_LOD->pTextures[v4].uTextureWidth : 24);
+    v5 = pIcons_LOD->GetTexture(v4);
+    v6 = v5->uTextureWidth;
     if ( v6 < 14 )
         v6 = 14;
     v7 = v6 - 14;
--- a/Events.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/Events.cpp	Wed May 01 23:36:54 2013 +0600
@@ -600,11 +600,11 @@
                   {
                     pAudioPlayer->StopChannels(-1, -1);
                     window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, 170, 0);
-                    window_SpeakInHouse->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-                    window_SpeakInHouse->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-                    window_SpeakInHouse->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-                    window_SpeakInHouse->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
-                    window_SpeakInHouse->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9u, "", 0);
+                    window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1',  "", 0);
+                    window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2',  "", 0);
+                    window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3',  "", 0);
+                    window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4',  "", 0);
+                    window_SpeakInHouse->CreateButton(  0,   0,  0, 0, 1,  0, UIMSG_CycleCharacters, 0, '\t', "", 0);
                     current_npc_text = pNPCTopics[90].pText;
                   }
                 }
@@ -1384,11 +1384,11 @@
 					if ( uCurrentHouse_Animation != 167 )
 						v104 = EVT_DWORD(_evt->v5);
 					window_SpeakInHouse = GUIWindow::Create(0, 0, 640, 480, WINDOW_HouseInterior, v104, 0);
-					window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, 49, "", 0);
-					window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, 50, "", 0);
-					window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, 51, "", 0);
-					window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, 52, "", 0);
-					window_SpeakInHouse->CreateButton(  0,   0,  0, 0, 1,  0, UIMSG_CycleCharacters, 0, 9u, "", 0);
+					window_SpeakInHouse->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1,  '1', "", 0);
+					window_SpeakInHouse->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2,  '2', "", 0);
+					window_SpeakInHouse->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3,  '3', "", 0);
+					window_SpeakInHouse->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4,  '4', "", 0);
+					window_SpeakInHouse->CreateButton(  0,   0,  0, 0, 1,  0, UIMSG_CycleCharacters, 0, '\t', "", 0);
 					}
 				++curr_seq_num;
 				v4 = v124;
--- a/GUIWindow.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/GUIWindow.cpp	Wed May 01 23:36:54 2013 +0600
@@ -21,6 +21,7 @@
 #include "UIHouses.h"
 #include "texts.h"
 #include "Autonotes.h"
+#include "Awards.h"
 
 
 #include "mm7_data.h"
@@ -137,7 +138,7 @@
       v12 = v20 * LOBYTE(v1->uFontHeight) + 40;
       v13 = *v16;
       ++v20;
-      v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
+      v14 = TargetColor(
               (unsigned __int8)*(v8 - 1),
               (unsigned __int8)*v8,
               (unsigned __int8)v8[1]);
@@ -224,7 +225,7 @@
   }
 
   pRenderer->DrawTextureTransparent(uFrameX + 24, uFrameY + 24, v13);
-  v16 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v16 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, "\f%05d", v16);
   sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->classType]);
   strcat(pTmpBuf, pTmpBuf2);
@@ -258,7 +259,7 @@
     {
       v35 = buff->uExpireTime - pParty->uTimePlayed;
       v36 = uFramesetIDa++ * pFontComic->uFontHeight + 134;
-      v38 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
+      v38 = TargetColor(
               _4E2AD8_ui_colors[i * 3],
               _4E2AD8_ui_colors[i * 3 + 1],
               _4E2AD8_ui_colors[i * 3 + 2]);
@@ -470,21 +471,23 @@
   InitializeBookFonts();
   v1->CreateButton(0x1DBu, 0x1BDu, 0x9Eu, 0x22u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0); // Close
   pCurrentScreen = SCREEN_BOOKS;
-  awards_count2 = 0;
+  num_achieved_awards_2 = 0;
   dword_506528 = 0;
   dword_50651C = 0;
-  awards_count = 0; 
+  num_achieved_awards = 0; 
   switch (v1->par1C)
       {
   case WINDOW_Lloyd:{
       byte_506360 = 0;
-      pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("lb_bordr", TEXTURE_16BIT_PALETTE)];
-      pTexture_LloydBeacons[0] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
-      pTexture_50635C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6b__zoom_on  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
-      pBtn_Book_1 = v1->CreateButton(415, 13, 39, 36, 1, 0, UIMSG_B2, 0, 0, pGlobalTXT_LocalizationStrings[375], 0);
-      pBtn_Book_2 = v1->CreateButton(415, 48, 39, 36, 1, 0, UIMSG_B2, 1, 0, pGlobalTXT_LocalizationStrings[523], 0);
+      pTexture_CurrentBook = pIcons_LOD->LoadTexturePtr("lb_bordr", TEXTURE_16BIT_PALETTE);
+      pTexture_LloydBeacons[0] = pIcons_LOD->LoadTexturePtr("sbmap", TEXTURE_16BIT_PALETTE);
+      pTexture_50635C = pIcons_LOD->LoadTexturePtr("sbmap", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6b__zoom_on  = pIcons_LOD->LoadTexturePtr("tab-an-6b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6a__zoom_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE);
+
+      pBtn_Book_1 = v1->CreateButton(415, 13, 39, 36, 1, 0, UIMSG_B2, 0, 0, pGlobalTXT_LocalizationStrings[375], 0); // Set Beacon
+      pBtn_Book_2 = v1->CreateButton(415, 48, 39, 36, 1, 0, UIMSG_B2, 1, 0, pGlobalTXT_LocalizationStrings[523], 0); // Recall Beacon
+
       v17 = &pParty->pPlayers[_506348_current_lloyd_playerid];
       v23 = 1;
       v18 = v17->pActiveSkills[14];
@@ -524,8 +527,7 @@
 
     case WINDOW_TownPortal:
     {
-      pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("townport", TEXTURE_16BIT_PALETTE)];
-
+      pTexture_CurrentBook        = pIcons_LOD->LoadTexturePtr("townport", TEXTURE_16BIT_PALETTE);
       pTexture_TownPortalIcons[0] = pIcons_LOD->LoadTexturePtr("tpharmndy", TEXTURE_16BIT_PALETTE);
       pTexture_TownPortalIcons[1] = pIcons_LOD->LoadTexturePtr("tpelf", TEXTURE_16BIT_PALETTE);
       pTexture_TownPortalIcons[2] = pIcons_LOD->LoadTexturePtr("tpwarlock", TEXTURE_16BIT_PALETTE);
@@ -546,74 +548,70 @@
     break;
 
   case WINDOW_QuestBook:
-      {
-      pTexture_CurrentBook = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "sbquiknot", TEXTURE_16BIT_PALETTE)];
-      pSpellBookPagesTextr_10 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture( "divbar", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
-      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, pTex_tab_an_6b__zoom_on->uTextureWidth,
-          pTex_tab_an_6b__zoom_on->uTextureHeight, 1, 0, UIMSG_AutonotesBook, 0xBu, 0, pGlobalTXT_LocalizationStrings[192],// "Scroll Up"
-          pTex_tab_an_6b__zoom_on, 0);
-      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_tab_an_7b__zoot_on->uTextureHeight,
-          pTex_tab_an_7b__zoot_on->uTextureHeight, 1, 0, UIMSG_AutonotesBook, 0xAu, 0, pGlobalTXT_LocalizationStrings[193],// "Scroll Down"
-          pTex_tab_an_7b__zoot_on, 0);
-      awards_count = 0;
-      memset(&achievedAwardsIndex, 0, 4000);
+  {
+      pTexture_CurrentBook    = pIcons_LOD->LoadTexturePtr("sbquiknot", TEXTURE_16BIT_PALETTE);
+      pSpellBookPagesTextr_10 = pIcons_LOD->LoadTexturePtr( "divbar", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6b__zoom_on = pIcons_LOD->LoadTexturePtr("tab-an-6b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7b__zoot_on = pIcons_LOD->LoadTexturePtr("tab-an-7b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6a__zoom_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7a__zoot_off = pIcons_LOD->LoadTexturePtr("tab-an-7a", TEXTURE_16BIT_PALETTE);
+      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398,         pViewport->uViewportTL_Y + 1,
+                                     pTex_tab_an_6b__zoom_on->uTextureWidth, pTex_tab_an_6b__zoom_on->uTextureHeight,
+                                     1, 0, UIMSG_AutonotesBook, 0xBu, 0, pGlobalTXT_LocalizationStrings[192],// "Scroll Up"
+                                     pTex_tab_an_6b__zoom_on, 0);
+      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398,          pViewport->uViewportTL_Y + 38,
+                                     pTex_tab_an_7b__zoot_on->uTextureHeight, pTex_tab_an_7b__zoot_on->uTextureHeight,
+                                     1, 0, UIMSG_AutonotesBook, 0xAu, 0, pGlobalTXT_LocalizationStrings[193],// "Scroll Down"
+                                     pTex_tab_an_7b__zoot_on, 0);
+      num_achieved_awards = 0;
+      memset(achieved_awards, 0, 4000);
       for ( i = dword_506528; i < 512; ++i )
           {
           v14 = (char *)pQuestTable[i-1];//(&dword_722F10)[4 * i];
           if ( _449B57_test_bit(pParty->_quest_bits, i) && v14 )
               {
-              v15 = awards_count++;
-              achievedAwardsIndex[v15] = i;
+              v15 = num_achieved_awards++;
+              achieved_awards[v15] = (AwardType)i;
               }
           }
-      v12 = awards_count;
-      awards_count = 0;
-      awards_count2 = v12;
+      v12 = num_achieved_awards;
+      num_achieved_awards = 0;
+      num_achieved_awards_2 = v12;
       }
       break;
   case WINDOW_AutonotesBook:
       {
-      pTexture_AutonotesBook   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbautnot", TEXTURE_16BIT_PALETTE)];
-      pSpellBookPagesTextr_10     = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("divbar", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6b__zoom_on  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7b__zoot_on  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
-      pTexture_506394 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-1b", TEXTURE_16BIT_PALETTE)];
-      pTexture_506390 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-1a", TEXTURE_16BIT_PALETTE)];
-      pTexture_50638C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-2b", TEXTURE_16BIT_PALETTE)];
-      pTexture_506388 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-2a", TEXTURE_16BIT_PALETTE)];
-      pTexture_506384 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-3b", TEXTURE_16BIT_PALETTE)];
-      pTexture_506380 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-3a", TEXTURE_16BIT_PALETTE)];
-      pTexture_50637C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-5b", TEXTURE_16BIT_PALETTE)];
-      pTexture_506378 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-5a", TEXTURE_16BIT_PALETTE)];
-      pTexture_506374 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-4b", TEXTURE_16BIT_PALETTE)];
-      pTexture_506370 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-4a", TEXTURE_16BIT_PALETTE)];
-      pTexture_50636C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-8b", TEXTURE_16BIT_PALETTE)];
-      pTexture_506368 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-8a", TEXTURE_16BIT_PALETTE)];
-      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 0xBu, 0,
-          pGlobalTXT_LocalizationStrings[193], pTex_tab_an_6b__zoom_on, 0);
-      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 0xAu, 0,
-          pGlobalTXT_LocalizationStrings[192], pTex_tab_an_7b__zoot_on, 0);
-      pBtn_Book_3 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 2u, 0,
-          pGlobalTXT_LocalizationStrings[85], pTexture_506394, 0);// "Potion Notes"
-      pBtn_Book_4 = v1->CreateButton(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 3u, 0,
-          pGlobalTXT_LocalizationStrings[137], pTexture_50638C, 0);// "Fountain Notes"
-      pBtn_Book_5 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 4u, 0,
-          pGlobalTXT_LocalizationStrings[8], pTexture_506384, 0);// "Obelisk Notes"
-      pBtn_Book_6 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 5u, 0,
-          pGlobalTXT_LocalizationStrings[141], pTexture_50637C, 0);// "Seer Notes"
-      pBtn_Autonotes_Misc = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 6u, 0,
-          pGlobalTXT_LocalizationStrings[123], pTexture_506374, 0);// "Miscellaneous Notes"
-      v9 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 7u, 0,
-          pGlobalTXT_LocalizationStrings[662], pTexture_50636C, 0);// "Instructors"
+      pTexture_AutonotesBook   = pIcons_LOD->LoadTexturePtr("sbautnot", TEXTURE_16BIT_PALETTE);
+      pSpellBookPagesTextr_10  = pIcons_LOD->LoadTexturePtr("divbar", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6b__zoom_on  = pIcons_LOD->LoadTexturePtr("tab-an-6b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7b__zoot_on  = pIcons_LOD->LoadTexturePtr("tab-an-7b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6a__zoom_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7a__zoot_off = pIcons_LOD->LoadTexturePtr("tab-an-7a", TEXTURE_16BIT_PALETTE);
+      pTexture_506394 = pIcons_LOD->LoadTexturePtr("tab-an-1b", TEXTURE_16BIT_PALETTE);
+      pTexture_506390 = pIcons_LOD->LoadTexturePtr("tab-an-1a", TEXTURE_16BIT_PALETTE);
+      pTexture_50638C = pIcons_LOD->LoadTexturePtr("tab-an-2b", TEXTURE_16BIT_PALETTE);
+      pTexture_506388 = pIcons_LOD->LoadTexturePtr("tab-an-2a", TEXTURE_16BIT_PALETTE);
+      pTexture_506384 = pIcons_LOD->LoadTexturePtr("tab-an-3b", TEXTURE_16BIT_PALETTE);
+      pTexture_506380 = pIcons_LOD->LoadTexturePtr("tab-an-3a", TEXTURE_16BIT_PALETTE);
+      pTexture_50637C = pIcons_LOD->LoadTexturePtr("tab-an-5b", TEXTURE_16BIT_PALETTE);
+      pTexture_506378 = pIcons_LOD->LoadTexturePtr("tab-an-5a", TEXTURE_16BIT_PALETTE);
+      pTexture_506374 = pIcons_LOD->LoadTexturePtr("tab-an-4b", TEXTURE_16BIT_PALETTE);
+      pTexture_506370 = pIcons_LOD->LoadTexturePtr("tab-an-4a", TEXTURE_16BIT_PALETTE);
+      pTexture_50636C = pIcons_LOD->LoadTexturePtr("tab-an-8b", TEXTURE_16BIT_PALETTE);
+      pTexture_506368 = pIcons_LOD->LoadTexturePtr("tab-an-8a", TEXTURE_16BIT_PALETTE);
+
+      pBtn_Book_1                = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1,   50, 34, 1, 0, UIMSG_AutonotesBook, 11, 0, pGlobalTXT_LocalizationStrings[193], pTex_tab_an_6b__zoom_on, 0);
+      pBtn_Book_2                = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38,  50, 34, 1, 0, UIMSG_AutonotesBook, 10, 0, pGlobalTXT_LocalizationStrings[192], pTex_tab_an_7b__zoot_on, 0);
+      pBtn_Book_3                = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 113, 50, 34, 1, 0, UIMSG_AutonotesBook,  2, 0, pGlobalTXT_LocalizationStrings[85], pTexture_506394, 0); // "Potion Notes"
+      pBtn_Book_4                = v1->CreateButton(pViewport->uViewportTL_X + 399, pViewport->uViewportTL_Y + 150, 50, 34, 1, 0, UIMSG_AutonotesBook,  3, 0, pGlobalTXT_LocalizationStrings[137], pTexture_50638C, 0); // "Fountain Notes"
+      pBtn_Book_5                = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 50, 34, 1, 0, UIMSG_AutonotesBook,  4, 0, pGlobalTXT_LocalizationStrings[8], pTexture_506384, 0); // "Obelisk Notes"
+      pBtn_Book_6                = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 50, 34, 1, 0, UIMSG_AutonotesBook,  5, 0, pGlobalTXT_LocalizationStrings[141], pTexture_50637C, 0); // "Seer Notes"
+      pBtn_Autonotes_Misc        = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 264, 50, 34, 1, 0, UIMSG_AutonotesBook,  6, 0, pGlobalTXT_LocalizationStrings[123], pTexture_506374, 0); // "Miscellaneous Notes"
+      pBtn_Autonotes_Instructors = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 302, 50, 34, 1, 0, UIMSG_AutonotesBook,  7, 0, pGlobalTXT_LocalizationStrings[662], pTexture_50636C, 0); // "Instructors"
+
+      v9 = pBtn_Autonotes_Instructors;
       v10 = dword_506528;
-      pBtn_Autonotes_Instructors = v9;
-      awards_count = 0;
+      num_achieved_awards = 0;
       while ( v10 < 196 )
           {
           if ( dword_506568 == pAutonoteTxt[v10-1].eType)//dword_72371C[2 * v10] )
@@ -624,8 +622,8 @@
                   {
                   if ( _449B57_test_bit(pParty->_autonote_bits, v10) && v25 )
                       {
-                      v11 = awards_count++;
-                      achievedAwardsIndex[v11] = (signed __int16)v10;
+                      v11 = num_achieved_awards++;
+                      achieved_awards[v11] = (AwardType)v10;
                       }
                   }
               }
@@ -633,79 +631,56 @@
           }
       }
       break;
+
   case WINDOW_MapsBook:
-      {
+  {
       dword_506364 = 1;
-      pSpellBookPagesTextr_12 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbmap", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoom-on", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoot-on", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoom-off", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("zoot-off", TEXTURE_16BIT_PALETTE)];
-      pTexture_506394 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabNon", TEXTURE_16BIT_PALETTE)];
-      pTexture_506390 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabNoff", TEXTURE_16BIT_PALETTE)];
-      pTexture_50638C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabSon", TEXTURE_16BIT_PALETTE)];
-      pTexture_506388 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabSoff", TEXTURE_16BIT_PALETTE)];
-      pTexture_506384 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabEon", TEXTURE_16BIT_PALETTE)];
-      pTexture_506380 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabEoff", TEXTURE_16BIT_PALETTE)];
-      pTexture_50637C = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabWon", TEXTURE_16BIT_PALETTE)];
-      pTexture_506378 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tabWoff", TEXTURE_16BIT_PALETTE)];
-      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 0, 0,
-          pGlobalTXT_LocalizationStrings[251], pTex_tab_an_6b__zoom_on, 0);// "Zoom In"
-      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 1, 0,
-          pGlobalTXT_LocalizationStrings[252], pTex_tab_an_7b__zoot_on, 0);// "Zoom Out"
-      pBtn_Book_3 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 113, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 2, 0,
-          pGlobalTXT_LocalizationStrings[192], (Texture *)"", 0);// Scroll Up
-      pBtn_Book_4 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 150, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 3, 0,
-          pGlobalTXT_LocalizationStrings[193], (Texture *)"", 0);// Scroll Down
-      pBtn_Book_5 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 4, 0,
-          pGlobalTXT_LocalizationStrings[573], (Texture *)"", 0);// "Scroll Right"
-      pBtn_Book_6 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 0x32u, 0x22u, 1, 0, UIMSG_AutonotesBook, 5, 0,
-          pGlobalTXT_LocalizationStrings[572], (Texture *)"", 0);// "Scroll Left"
+      pSpellBookPagesTextr_12  = pIcons_LOD->LoadTexturePtr("sbmap", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6b__zoom_on  = pIcons_LOD->LoadTexturePtr("zoom-on", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7b__zoot_on  = pIcons_LOD->LoadTexturePtr("zoot-on", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6a__zoom_off = pIcons_LOD->LoadTexturePtr("zoom-off", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7a__zoot_off = pIcons_LOD->LoadTexturePtr("zoot-off", TEXTURE_16BIT_PALETTE);
+      pTexture_506394 = pIcons_LOD->LoadTexturePtr("tabNon", TEXTURE_16BIT_PALETTE);
+      pTexture_506390 = pIcons_LOD->LoadTexturePtr("tabNoff", TEXTURE_16BIT_PALETTE);
+      pTexture_50638C = pIcons_LOD->LoadTexturePtr("tabSon", TEXTURE_16BIT_PALETTE);
+      pTexture_506388 = pIcons_LOD->LoadTexturePtr("tabSoff", TEXTURE_16BIT_PALETTE);
+      pTexture_506384 = pIcons_LOD->LoadTexturePtr("tabEon", TEXTURE_16BIT_PALETTE);
+      pTexture_506380 = pIcons_LOD->LoadTexturePtr("tabEoff", TEXTURE_16BIT_PALETTE);
+      pTexture_50637C = pIcons_LOD->LoadTexturePtr("tabWon", TEXTURE_16BIT_PALETTE);
+      pTexture_506378 = pIcons_LOD->LoadTexturePtr("tabWoff", TEXTURE_16BIT_PALETTE);
+
+      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1,   50, 34, 1, 0, UIMSG_AutonotesBook, 0, 0, pGlobalTXT_LocalizationStrings[251], pTex_tab_an_6b__zoom_on, 0);// "Zoom In"
+      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38,  50, 34, 1, 0, UIMSG_AutonotesBook, 1, 0, pGlobalTXT_LocalizationStrings[252], pTex_tab_an_7b__zoot_on, 0);// "Zoom Out"
+      pBtn_Book_3 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 113, 50, 34, 1, 0, UIMSG_AutonotesBook, 2, 0, pGlobalTXT_LocalizationStrings[192], (Texture *)"", 0);// Scroll Up
+      pBtn_Book_4 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 150, 50, 34, 1, 0, UIMSG_AutonotesBook, 3, 0, pGlobalTXT_LocalizationStrings[193], (Texture *)"", 0);// Scroll Down
+      pBtn_Book_5 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 188, 50, 34, 1, 0, UIMSG_AutonotesBook, 4, 0, pGlobalTXT_LocalizationStrings[573], (Texture *)"", 0);// "Scroll Right"
+      pBtn_Book_6 = v1->CreateButton(pViewport->uViewportTL_X + 397, pViewport->uViewportTL_Y + 226, 50, 34, 1, 0, UIMSG_AutonotesBook, 5, 0, pGlobalTXT_LocalizationStrings[572], (Texture *)"", 0);// "Scroll Left"
       }
       break;
-  case WINDOW_CalendarBook: {
-      pSpellBookPagesTextr_13 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbdate-time", TEXTURE_16BIT_PALETTE)];
-      pTex_moon_new = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_new", TEXTURE_16BIT_PALETTE)];
-      pTex_moon_4   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_4", TEXTURE_16BIT_PALETTE)];
-      pTex_moon_2   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_2", TEXTURE_16BIT_PALETTE)];
-      pTex_moon_2_2 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_2", TEXTURE_16BIT_PALETTE)];
-      pTex_moon_ful = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("moon_ful", TEXTURE_16BIT_PALETTE)];
+
+  case WINDOW_CalendarBook:
+  {
+      pSpellBookPagesTextr_13 = pIcons_LOD->LoadTexturePtr("sbdate-time", TEXTURE_16BIT_PALETTE);
+      pTex_moon_new = pIcons_LOD->LoadTexturePtr("moon_new", TEXTURE_16BIT_PALETTE);
+      pTex_moon_4   = pIcons_LOD->LoadTexturePtr("moon_4", TEXTURE_16BIT_PALETTE);
+      pTex_moon_2   = pIcons_LOD->LoadTexturePtr("moon_2", TEXTURE_16BIT_PALETTE);
+      pTex_moon_2_2 = pIcons_LOD->LoadTexturePtr("moon_2", TEXTURE_16BIT_PALETTE);
+      pTex_moon_ful = pIcons_LOD->LoadTexturePtr("moon_ful", TEXTURE_16BIT_PALETTE);
       }
       break;
+
   case WINDOW_HistoryBook:
-      {
-      pSpellBookPagesTextr_11 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("sbplayrnot", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6b__zoom_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7b__zoot_on = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7b", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_6a__zoom_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-6a", TEXTURE_16BIT_PALETTE)];
-      pTex_tab_an_7a__zoot_off = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("tab-an-7a", TEXTURE_16BIT_PALETTE)];
-      pBtn_Book_1 = v1->CreateButton(
-          pViewport->uViewportTL_X + 398,
-          pViewport->uViewportTL_Y + 1,
-          pTex_tab_an_6b__zoom_on->uTextureWidth,
-          pTex_tab_an_6b__zoom_on->uTextureHeight,
-          1,
-          0,
-          UIMSG_AutonotesBook,
-          0xBu,
-          0,
-          pGlobalTXT_LocalizationStrings[192],
-          pTex_tab_an_6b__zoom_on,
-          0);
-      pBtn_Book_2 = v1->CreateButton(
-          pViewport->uViewportTL_X + 398,
-          pViewport->uViewportTL_Y + 38,
-          pTex_tab_an_7b__zoot_on->uTextureHeight,
-          pTex_tab_an_7b__zoot_on->uTextureHeight,
-          1,
-          0,
-          UIMSG_AutonotesBook,
-          0xAu,
-          0,
-          pGlobalTXT_LocalizationStrings[193],
-          pTex_tab_an_7b__zoot_on,
-          0);
-      awards_count = 0;
+  {
+      pSpellBookPagesTextr_11  = pIcons_LOD->LoadTexturePtr("sbplayrnot", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6b__zoom_on  = pIcons_LOD->LoadTexturePtr("tab-an-6b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7b__zoot_on  = pIcons_LOD->LoadTexturePtr("tab-an-7b", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_6a__zoom_off = pIcons_LOD->LoadTexturePtr("tab-an-6a", TEXTURE_16BIT_PALETTE);
+      pTex_tab_an_7a__zoot_off = pIcons_LOD->LoadTexturePtr("tab-an-7a", TEXTURE_16BIT_PALETTE);
+
+      pBtn_Book_1 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 1,  pTex_tab_an_6b__zoom_on->uTextureWidth,  pTex_tab_an_6b__zoom_on->uTextureHeight, 1, 0, UIMSG_AutonotesBook, 11, 0, pGlobalTXT_LocalizationStrings[192], pTex_tab_an_6b__zoom_on, 0);
+      pBtn_Book_2 = v1->CreateButton(pViewport->uViewportTL_X + 398, pViewport->uViewportTL_Y + 38, pTex_tab_an_7b__zoot_on->uTextureHeight, pTex_tab_an_7b__zoot_on->uTextureHeight, 1, 0, UIMSG_AutonotesBook, 10, 0, pGlobalTXT_LocalizationStrings[193], pTex_tab_an_7b__zoot_on, 0);
+
+      num_achieved_awards = 0;
       v26.uFrameX = 48;
       v26.uFrameY = 70;
       v26.uFrameWidth = 360;
@@ -714,7 +689,7 @@
       v26.uFrameZ = 407;
       v26.uFrameHeight = v2 * 264 / v2;
       v26.uFrameW = v26.uFrameHeight + 69;
-      memset(&achievedAwardsIndex, 0, 4000);
+      memset(&achieved_awards, 0, 4000);
       memset(byte_5C6D50, 0, 0x64u);
       if ( dword_506528 < 29 )
           {
@@ -732,10 +707,10 @@
                       v8 = v7 + 1;
                       if ( (signed int)v7 + 1 > 0 )
                           {
-                          memset32((char *)&achievedAwardsIndex + 4 * awards_count , i, v8);
+                          memset32((char *)&achieved_awards + 4 * num_achieved_awards , i, v8);
                           do
                               {
-                              LODWORD(v7) = awards_count++;
+                              LODWORD(v7) = num_achieved_awards++;
                               byte_5C6D50[(int)v7] = BYTE4(v7);
                               ++HIDWORD(v7);
                               }
@@ -881,11 +856,11 @@
   if ( !pIcons_LOD->uNumPrevLoadedFiles )
     pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
   pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
-  pSpellBookPagesTextr_9 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("book", TEXTURE_16BIT_PALETTE)];
-  pTexture_pagemask = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("pagemask", TEXTURE_16BIT_PALETTE)];
-  pTexture_506448   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m5-u", TEXTURE_16BIT_PALETTE)];
-  ptr_506440        = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m5-d", TEXTURE_16BIT_PALETTE)];
-  pTexture_50643C   = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ib-m6-u",TEXTURE_16BIT_PALETTE)];
+  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] =
@@ -914,7 +889,7 @@
   if ( !pIcons_LOD->uNumPrevLoadedFiles )
     pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
   pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
-  pTexture_mapbordr = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("mapbordr", TEXTURE_16BIT_PALETTE)];
+  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);
@@ -987,31 +962,24 @@
   }
   //while ( (signed int)v3 < 11 );
 
-  CreateButton(0, 0, 0, 0, 1, 0, UIMSG_33, 0, 9u, "", 0);
+  CreateButton(0, 0, 0, 0, 1, 0, UIMSG_33, 0, '\t', "", 0);
   if ( a2 )
     _41D08F(a2, 0, 0, 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_FIRE])
-    CreateButton(0x18Fu, 0xAu, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 0, 0, aSpellSchoolNames[0], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_AIR])
-    CreateButton(0x18Fu, 0x2Eu, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 1u, 0, aSpellSchoolNames[1], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_WATER])
-    CreateButton(0x18Fu, 0x53u, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 2u, 0, aSpellSchoolNames[2], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_EARTH])
-    CreateButton(0x18Fu, 0x79u, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 3u, 0, aSpellSchoolNames[3], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_SPIRIT])
-    CreateButton(0x18Fu, 0x9Eu, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 4u, 0, aSpellSchoolNames[4], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_MIND])
-    CreateButton(0x190u, 0xC4u, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 5u, 0, aSpellSchoolNames[5], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_BODY])
-    CreateButton(0x190u, 0xEAu, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 6u, 0, aSpellSchoolNames[6], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_LIGHT])
-    CreateButton(0x190u, 0x10Fu, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 7u, 0, aSpellSchoolNames[7], 0);
-  if (pPlayer->pActiveSkills[PLAYER_SKILL_DARK])
-    CreateButton(0x190u, 0x133u, 0x32u, 0x24u, 1, 0, UIMSG_OpenSpellbookPage, 8u, 0, aSpellSchoolNames[8], 0);
-  CreateButton(0x1DCu, 0x1C2u, pTexture_506444->uTextureWidth, pTexture_506444->uTextureHeight, 1, 78, UIMSG_58, 0, 0, "", 0);
-  pBtn_InstallRemoveSpell = CreateButton(0x1DCu, 0x1C2u, 0x30u, 0x20u, 1, 78, UIMSG_58, 0, 0, "", pTexture_506444, 0);
-  CreateButton(0x231u, 0x1C2u, ptr_506440->uTextureWidth, ptr_506440->uTextureHeight, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0);
-  pBtn_CloseBook = CreateButton(0x231u, 0x1C2u, 0x30u, 0x20u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], ptr_506440, 0);
+
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_FIRE])   CreateButton(399,  10, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 0, 0, aSpellSchoolNames[0], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_AIR])    CreateButton(399,  46, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 1, 0, aSpellSchoolNames[1], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_WATER])  CreateButton(399,  83, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 2, 0, aSpellSchoolNames[2], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_EARTH])  CreateButton(399, 121, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 3, 0, aSpellSchoolNames[3], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_SPIRIT]) CreateButton(399, 158, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 4, 0, aSpellSchoolNames[4], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_MIND])   CreateButton(400, 196, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 5, 0, aSpellSchoolNames[5], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_BODY])   CreateButton(400, 234, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 6, 0, aSpellSchoolNames[6], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_LIGHT])  CreateButton(400, 271, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 7, 0, aSpellSchoolNames[7], 0);
+  if (pPlayer->pActiveSkills[PLAYER_SKILL_DARK])   CreateButton(400, 307, 50, 36, 1, 0, UIMSG_OpenSpellbookPage, 8, 0, aSpellSchoolNames[8], 0);
+
+                            CreateButton(476, 450, pTexture_506444->uTextureWidth, pTexture_506444->uTextureHeight, 1, 78, UIMSG_58,     0, 0, "", 0);
+  pBtn_InstallRemoveSpell = CreateButton(476, 450, 48,                             32,                              1, 78, UIMSG_58,     0, 0, "", pTexture_506444, 0);
+                            CreateButton(561, 450, ptr_506440->uTextureWidth,      ptr_506440->uTextureHeight,      1,  0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], 0);
+  pBtn_CloseBook          = CreateButton(561, 450, 48,                             32,                              1,  0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79], ptr_506440, 0);
 }
 // 50640C: using guessed type int dword_50640C[];
 
@@ -1038,8 +1006,8 @@
   memcpy(&pWindow, this, sizeof(pWindow));
   pWindow.uFrameWidth -= 18;
   pWindow.uFrameZ -= 18;
-  pWhiteColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pColor2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
+  pWhiteColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  pColor2 = TargetColor(0x15u, 0x99u, 0xE9u);
   pRenderer->DrawTextureIndexed(0x1DDu, 0, pTexture_Dialogue_Background);
   pRenderer->DrawTextureTransparent(0x1D4u, 0, &pIcons_LOD->pTextures[uTextureID_right_panel_loop]);
   if ( pDialogueNPCCount != uNumDialogueNPCPortraits || !uHouse_ExitPic )
@@ -1298,7 +1266,7 @@
     sprintf(pTmpBuf2, "%d %s ", v17, v11);
     strcat(pTmpBuf, pTmpBuf2);
   }
-  v12 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v12 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   v13 = pFontArrus->CalcTextHeight(pTmpBuf, v15, 0, 0);
   v15->DrawTitleText(pFontArrus, 0, (212 - v13) / 2 + 101, v12, pTmpBuf, 3u);
 }
@@ -1894,16 +1862,16 @@
             pWindow->_41D08F(num_menu_buttons, 1, 0, 1);
           }
           break;
+
         case WINDOW_ChangeLocation:
           pMainScreenNum = pCurrentScreen;
           pCurrentScreen = SCREEN_CHANGE_LOCATION;
-          pBtn_ExitCancel = pWindow->CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_5B, 0, 0x4Eu, pGlobalTXT_LocalizationStrings[156],//   
-                         pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
-          pBtn_YES = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_OnTravelByFoot, 0, 0x59u, pWindow->Hint,
-                         pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
-          pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, UIMSG_OnTravelByFoot, 1u, 0x20u, pWindow->Hint, 0, 0, 0);
-          pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, UIMSG_OnTravelByFoot, 1u, 0, pWindow->Hint, 0);
+          pBtn_ExitCancel = pWindow->CreateButton(                  566,                   445,  75,  33, 1, 0, UIMSG_5B,             0, 'N', pGlobalTXT_LocalizationStrings[156], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);//   
+          pBtn_YES        = pWindow->CreateButton(                  486,                   445,  75,  33, 1, 0, UIMSG_OnTravelByFoot, 0, 'Y', pWindow->Hint, pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
+                            pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0],  63,  73, 1, 0, UIMSG_OnTravelByFoot, 1, ' ', pWindow->Hint, 0, 0, 0);
+                            pWindow->CreateButton(                    8,                     8, 460, 344, 1, 0, UIMSG_OnTravelByFoot, 1,   0, pWindow->Hint, 0);
           break;
+
         case WINDOW_SpellBook: //   
           InitializeBookTextures();
           pWindow->OpenSpellBook();
@@ -1917,10 +1885,10 @@
       return pWindow;
     }
 //LABEL_62:
-    pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-    pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-    pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-    pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
+    pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, '1', "", 0);
+    pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, '2', "", 0);
+    pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, '3', "", 0);
+    pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, '4', "", 0);
     pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9u, "", 0);
     return pWindow;
   }
@@ -1969,12 +1937,10 @@
     {
       pMainScreenNum = pCurrentScreen;
       pCurrentScreen = SCREEN_INPUT_BLV;
-      pBtn_ExitCancel = pWindow->CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_19C, 0, 0x4Eu, pGlobalTXT_LocalizationStrings[34],//
-                     pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
-      pBtn_YES = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionUI_Confirm, 0, 0x59u, pWindow->Hint,
-                     pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
-      pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, UIMSG_TransitionUI_Confirm, 1, 0x20u, pWindow->Hint, 0);
-      pWindow->CreateButton(8u, 8u, 0x1CCu, 0x158u, 1, 0, UIMSG_TransitionUI_Confirm, 1u, 0, pWindow->Hint, 0);
+      pBtn_ExitCancel = pWindow->CreateButton(0x236u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_19C, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);//
+      pBtn_YES        = pWindow->CreateButton(0x1E6u, 0x1BDu, 0x4Bu, 0x21u, 1, 0, UIMSG_TransitionUI_Confirm, 0, 'Y', pWindow->Hint, pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
+                        pWindow->CreateButton(pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 0x3Fu, 0x49u, 1, 0, UIMSG_TransitionUI_Confirm, 1, 0x20u, pWindow->Hint, 0);
+                        pWindow->CreateButton(8, 8, 0x1CCu, 0x158u, 1, 0, UIMSG_TransitionUI_Confirm, 1u, 0, pWindow->Hint, 0);
       return pWindow;
     }
     if (eWindowType == WINDOW_1B)
@@ -1988,18 +1954,18 @@
     if (eWindowType == WINDOW_Scroll)
       //goto LABEL_62;
     {
-      pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-      pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-      pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-      pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
-      pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9u, "", 0);
+      pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, '1', "", 0);
+      pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, '2', "", 0);
+      pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, '3', "", 0);
+      pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, '4', "", 0);
+      pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, '\t', "", 0);
       return pWindow;
     }
     if (eWindowType == WINDOW_CastSpell_InInventory)
     {
       pMouse->SetCursorBitmap("MICON2");
       pBtn_ExitCancel = pWindow->CreateButton(0x188u, 0x13Eu, 0x4Bu, 0x21u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],//
-                     (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), 0);
+                     pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);
       ShowStatusBarString(pGlobalTXT_LocalizationStrings[39], 2);// 
       ++pIcons_LOD->uTexturePacksCount;
       pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103;
--- a/GUIWindow.h	Wed May 01 23:36:40 2013 +0600
+++ b/GUIWindow.h	Wed May 01 23:36:54 2013 +0600
@@ -262,7 +262,7 @@
   WINDOW_Book = 0x9,
   WINDOW_Dialogue = 0xA,
   WINDOW_QuickReference = 12,
-  WINDOW_Rest = 0x10,
+  WINDOW_Rest = 16,
   WINDOW_ChangeLocation = 17,
   WINDOW_SpellBook = 0x12,
   WINDOW_GreetingNPC = 19,
--- a/Game.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/Game.cpp	Wed May 01 23:36:54 2013 +0600
@@ -199,17 +199,17 @@
   if (render_framerate)
   {
     sprintf(pTmpBuf, "FPS: % .4f", framerate);
-    pPrimaryWindow->DrawText(pFontArrus, 494, 0, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0), pTmpBuf, 0, 0, 0);
+    pPrimaryWindow->DrawText(pFontArrus, 494, 0, TargetColor(0, 0, 0), pTmpBuf, 0, 0, 0);
   }
 
   if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
   {
     auto sector_id = pIndoor->GetSector(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
     sprintf(pTmpBuf, "Party Sector ID:        %u/%u\n", sector_id, pIndoor->uNumSectors);
-    pPrimaryWindow->DrawText(pFontArrus, 16, 16, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF);
+    pPrimaryWindow->DrawText(pFontArrus, 16, 16, TargetColor(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF);
   }
   sprintf(pTmpBuf, "Party Position:         % d % d % d", pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z);
-  pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF);
+  pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16, TargetColor(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF);
   
   if (uCurrentlyLoadedLevelType == LEVEL_Indoor)
   {
@@ -224,7 +224,7 @@
     auto floor_level = ODM_GetFloorLevel(pParty->vPosition.x, pParty->vPosition.y, pParty->vPosition.z, 0, &on_water, &_a6, false);
     sprintf(pTmpBuf, "ODM_GetFloorLevel: %d   on_water: %s    a6 = %d\n", floor_level, on_water ? "true" : "false", _a6);
   }
-  pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF);
+  pPrimaryWindow->DrawText(pFontArrus, 16, 16 + 16 + 16, TargetColor(255, 255, 255), pTmpBuf, 0, 0, 0xFFFFFFFF);
 
   GUI_UpdateWindows();
   pParty->UpdatePlayersAndHirelingsEmotions();
--- a/Indoor.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/Indoor.cpp	Wed May 01 23:36:54 2013 +0600
@@ -1206,7 +1206,7 @@
 
   v1 = &pIndoor->pFaces[uFaceID];
   v2 = &pIndoor->pFaceExtras[v1->uFaceExtraID];
-  v3 = (Texture *)(v1->uBitmapID != -1 ? (int)&pBitmaps_LOD->pTextures[v1->uBitmapID] : 0);
+  v3 = pBitmaps_LOD->GetTexture(v1->uBitmapID);
   stru_F8AD28.pDeltaUV[0] = v2->sTextureDeltaU;
   stru_F8AD28.pDeltaUV[1] = v2->sTextureDeltaV;
   v4 = GetTickCount();
@@ -1619,7 +1619,7 @@
     v1 = pTextureFrameTable->GetFrameTexture(this->uBitmapID, pBLVRenderParams->field_0_timer_);
   else
     v1 = uBitmapID;
-  return (Texture *)(v1 != -1 ? (int)&pBitmaps_LOD->pTextures[v1] : 0);
+  return pBitmaps_LOD->GetTexture(v1);
 }
 
 
@@ -3705,7 +3705,7 @@
             {
               v52 = v15->uBitmapID;
               if ( v52 != -1 )
-                v28->sTextureDeltaV -= v82 + (v52 != -1 ? pBitmaps_LOD->pTextures[v52].uTextureHeight : 26);
+                v28->sTextureDeltaV -= v82 + pBitmaps_LOD->GetTexture(v52)->uTextureHeight;
             }
           }
           if ( BYTE2(v15->uAttributes) & 4 )
--- a/LOD.h	Wed May 01 23:36:40 2013 +0600
+++ b/LOD.h	Wed May 01 23:36:54 2013 +0600
@@ -162,8 +162,7 @@
   inline Texture *GetTexture(int idx)
   {
     assert(idx < 1000);
-    if (idx == -1)
-      return nullptr;
+    if (idx == -1) return nullptr; // we need to return dummy texture here
     return pTextures + idx;
   }
 
--- a/NPC.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/NPC.cpp	Wed May 01 23:36:54 2013 +0600
@@ -958,8 +958,7 @@
 
 //----- (004763E0) --------------------------------------------------------
 void  InitializeAwards()
-	{
-
+{
 	int i;
 	char* test_string;
 	unsigned char c;
@@ -974,7 +973,7 @@
 	pAwardsTXT_Raw = (char *)pEvents_LOD->LoadRaw("awards.txt", 0);
 	strtok(pAwardsTXT_Raw, "\r");
 
-	for (i=1; i<104; ++i)
+	for (i=1; i<105; ++i)
 		{
 		test_string = strtok(NULL, "\r") + 1;
 		break_loop = false;
@@ -997,7 +996,7 @@
 				if (decode_step==1)
 					pAwards[i].pText=RemoveQuotes(test_string);
 				else if (decode_step==2)
-					pAwards[i].uSort=atoi(test_string);
+					pAwards[i].uPriority = atoi(test_string);
 				}
 			else
 				{ 
@@ -1007,7 +1006,6 @@
 			test_string=tmp_pos+1;
 			} while ((decode_step<3)&&!break_loop);
 		}
-
 	}
 // 7241C8: using guessed type int dword_7241C8;
 
--- a/Party.h	Wed May 01 23:36:40 2013 +0600
+++ b/Party.h	Wed May 01 23:36:54 2013 +0600
@@ -252,8 +252,8 @@
   unsigned char _autonote_bits[12];
   char field_80A[74];
   char field_854[32];
-  int field_874;
-  int field_878;
+  int uNumArcomageWins;
+  int uNumArcomageLoses;
   unsigned int bTurnBasedModeOn;
   int field_880;
   int uFlags2;
--- a/Player.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/Player.cpp	Wed May 01 23:36:54 2013 +0600
@@ -3281,7 +3281,7 @@
   unsigned int result; // eax@2
 
   if ( CanTrainToNextLevel() )
-    result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
+    result = TargetColor(0, 0xFFu, 0);
   else
     result = 0;
   return result;
@@ -6919,9 +6919,9 @@
   __int16 uGreen; // [sp+8h] [bp-8h]@1
   __int16 uRed; // [sp+Ch] [bp-4h]@1
 
-  uRed = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x23u, 0);
-  uGreen = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
-  uWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+  uRed = TargetColor(0xFFu, 0x23u, 0);
+  uGreen = TargetColor(0, 0xFFu, 0);
+  uWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
   pBaseAttrValue = StatTable[GetRace()][uStat].uBaseValue;
 
   switch (uStat)
--- a/Player.h	Wed May 01 23:36:40 2013 +0600
+++ b/Player.h	Wed May 01 23:36:54 2013 +0600
@@ -14,7 +14,9 @@
 #define PLAYER_BUFF_REGENERATION    12
 
 
-#define PLAYER_GUID_BITS__SPIRIT_MEMBERSHIP 58
+#define PLAYER_GUILD_BITS__SPIRIT_MEMBERSHIP 58
+#define PLAYER_GUILD_BITS__ARCOMAGE_WIN      103
+#define PLAYER_GUILD_BITS__ARCOMAGE_LOSE     104
 
 
 /*  301 */
@@ -577,6 +579,26 @@
   inline bool Cursed()     {return pConditions[Condition::Condition_Cursed] != 0;}
   inline bool Pertified()  {return pConditions[Condition::Condition_Pertified] != 0;}
 
+  inline void SetCursed(bool state)      {pConditions[Condition::Condition_Cursed] = state;}
+  inline void SetWeak(bool state)        {pConditions[Condition::Condition_Weak] = state;}
+  inline void SetAsleep(bool state)      {pConditions[Condition::Condition_Sleep] = state;}
+  inline void SetAfraid(bool state)      {pConditions[Condition::Condition_Fear] = state;}
+  inline void SetDrunk(bool state)       {pConditions[Condition::Condition_Drunk] = state;}
+  inline void SetInsane(bool state)      {pConditions[Condition::Condition_Insane] = state;}
+  inline void SetPoison1(bool state)     {pConditions[Condition::Condition_Poison1] = state;}
+  inline void SetDisease1(bool state)    {pConditions[Condition::Condition_Disease1] = state;}
+  inline void SetPoison2(bool state)     {pConditions[Condition::Condition_Poison2] = state;}
+  inline void SetDisease2(bool state)    {pConditions[Condition::Condition_Disease2] = state;}
+  inline void SetPoison3(bool state)     {pConditions[Condition::Condition_Poison3] = state;}
+  inline void SetDisease3(bool state)    {pConditions[Condition::Condition_Disease3] = state;}
+  inline void SetParalyzed(bool state)   {pConditions[Condition::Condition_Paralyzed] = state;}
+  inline void SetUnconcious(bool state)  {pConditions[Condition::Condition_Unconcious] = state;}
+  inline void SetDead(bool state)        {pConditions[Condition::Condition_Dead] = state;}
+  inline void SetPertified(bool state)   {pConditions[Condition::Condition_Pertified] = state;}
+  inline void SetEradicated(bool state)  {pConditions[Condition::Condition_Eradicated] = state;}
+  inline void SetZombie(bool state)      {pConditions[Condition::Condition_Zombie] = state;}
+
+
 
 
   __int64 pConditions[20];
--- a/Render.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/Render.cpp	Wed May 01 23:36:54 2013 +0600
@@ -9427,7 +9427,7 @@
         v11 = v20 - v21;
       }
     }
-    teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
+    teal = TargetColor(0, 0xFFu, 0xFFu);
     if ( v11 > 0 )
     {
       v22 = a4a;
--- a/Texture.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/Texture.cpp	Wed May 01 23:36:54 2013 +0600
@@ -43,11 +43,6 @@
 Texture *pTex_tab_an_7b__zoot_on;
 Texture *pTex_tab_an_6b__zoom_on;
 Texture *pTexture_TownPortalIcons[6]; // [0]Harmonale, [1]Pierpont, [2]Nighon, [3]Evenmorn Island, [4]Celestia, [5]The Pit
-//Texture *pTexture_TownPortalElf;
-//Texture *pTexture_TownPortalWarlock;
-//Texture *pTexture_TownPortalIsland;
-//Texture *pTexture_TownPortalHeaven;
-//Texture *pTexture_TownPortalHell;
 Texture *dword_5063D8[12];
 Texture *dword_506408[12];
 Texture *pTexture_50643C; // idb
@@ -186,15 +181,6 @@
 unsigned int uTextureID_507C50; // weak
 unsigned int uTextureID_507C54; // weak
 unsigned int uTextureID_507C58; // weak
-unsigned int uTextureID_ControlBG[23];
-//unsigned int uTextureID_Con_Smoo[3]; // weak
-//unsigned int uTextureID_Con_ArrL; // weak
-//unsigned int uTextureID_Con_ArrR; // weak
-//unsigned int uTextureID_Option04; // weak
-//unsigned int pTextureIDs_SoundLevels[10];
-//unsigned int uTextureID_Option03; // weak
-//unsigned int uTextureID_Option01;
-//unsigned int uTextureID_Option02; // weak
 
 
 unsigned int uTextureID_detaliz_close_button; // weak
--- a/Texture.h	Wed May 01 23:36:40 2013 +0600
+++ b/Texture.h	Wed May 01 23:36:54 2013 +0600
@@ -145,11 +145,7 @@
 extern Texture *pTex_tab_an_7b__zoot_on;
 extern Texture *pTex_tab_an_6b__zoom_on;
 extern Texture *pTexture_TownPortalIcons[]; // [0]Harmonale, [1]Pierpont, [2]Nighon, [3]Evenmorn Island, [4]Celestia, [5]The Pit
-//extern Texture *pTexture_TownPortalElf;
-//extern Texture *pTexture_TownPortalWarlock;
-//extern Texture *pTexture_TownPortalIsland;
-//extern Texture *pTexture_TownPortalHeaven;
-//extern Texture *pTexture_TownPortalHell;
+
 extern Texture *dword_5063D8[];
 extern Texture *dword_506408[];
 extern Texture *pTexture_50643C; // idb
@@ -288,15 +284,27 @@
 extern unsigned int uTextureID_507C50; // weak
 extern unsigned int uTextureID_507C54; // weak
 extern unsigned int uTextureID_507C58; // weak
-extern unsigned int uTextureID_ControlBG[23]; // weak
-//extern unsigned int uTextureID_Con_Smoo[3]; // weak
-//extern unsigned int uTextureID_Con_ArrL; // weak
-//extern unsigned int uTextureID_Con_ArrR; // weak
-//extern unsigned int uTextureID_Option04; // weak
-//extern unsigned int pTextureIDs_SoundLevels[10];
-//extern unsigned int uTextureID_Option03; // weak
-//extern unsigned int uTextureID_Option01;
-//extern unsigned int uTextureID_Option02; // weak
+
+
+struct OptionsMenuSkin
+{
+       OptionsMenuSkin();
+  void Relaease();
+
+  unsigned int uTextureID_Background;      // 507C60
+  unsigned int uTextureID_TurnSpeed[3];    // 507C64
+  unsigned int uTextureID_ArrowLeft;       // 507C70
+  unsigned int uTextureID_ArrowRight;      // 507C74
+  unsigned int uTextureID_unused_0;        // 507C78
+  unsigned int uTextureID_unused_1;        // 507C7C
+  unsigned int uTextureID_unused_2;        // 507C80
+  unsigned int uTextureID_FlipOnExit;      // 507C84
+  unsigned int uTextureID_SoundLevels[10]; // 507C88
+  unsigned int uTextureID_AlwaysRun;       // 507CB0
+  unsigned int uTextureID_WalkSound;       // 507CB4
+  unsigned int uTextureID_ShowDamage;      // 507CB8
+};
+extern OptionsMenuSkin options_menu_skin; // 507C60
 
 
 extern unsigned int uTextureID_detaliz_close_button; // weak
--- a/UIBooks.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/UIBooks.cpp	Wed May 01 23:36:54 2013 +0600
@@ -409,7 +409,7 @@
     v0 = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(v0, v11, v13);
-  if ( dword_506544 || dword_506528 + awards_count >= awards_count2 )
+  if ( dword_506544 || dword_506528 + num_achieved_awards >= num_achieved_awards_2 )
   {
     v14 = pTex_tab_an_7a__zoot_off;
     v12 = pViewport->uViewportTL_Y + 38;
@@ -424,7 +424,7 @@
   pRenderer->DrawTextureTransparent(v1, v12, v14);
   if ( !byte_5C6D50[dword_506528] )
   {
-    v2 = achievedAwardsIndex[dword_506528];
+    v2 = achieved_awards[dword_506528];
     a1.uFrameWidth = game_viewport_width;
     a1.uFrameX = game_viewport_x;
     a1.uFrameY = game_viewport_y;
@@ -443,12 +443,12 @@
   a1.uFrameZ = 407;
   a1.uFrameHeight = v4 * 264 / v4;
   a1.uFrameW = a1.uFrameHeight + 69;
-  if ( dword_506544 && dword_506528 + awards_count < awards_count2 )
+  if ( dword_506544 && dword_506528 + num_achieved_awards < num_achieved_awards_2 )
   {
     pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
     v5 = dword_50651C++;
-    dword_506528 += awards_count;
-    byte_506130[v5] = awards_count;
+    dword_506528 += num_achieved_awards;
+    byte_506130[v5] = num_achieved_awards;
   }
   if ( dword_506548 && dword_50651C )
   {
@@ -456,15 +456,15 @@
     --dword_50651C;
     dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
   }
-  if ( !awards_count || dword_506528 < 1 )
+  if ( !num_achieved_awards || dword_506528 < 1 )
   {
     dword_506528 = 0;
     dword_50651C = 0;
   }
   dword_506544 = 0;
-  v6 = achievedAwardsIndex[dword_506528];
+  v6 = achieved_awards[dword_506528];
   dword_506548 = 0;
-  awards_count = 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 = BuilDialogueString(
@@ -478,7 +478,7 @@
   {
     v9 = pAutonoteFont->_44C6C2(v8, &a1, 1u, (unsigned __int8)byte_5C6D50[dword_506528]);
     LOBYTE(v8) = a1.DrawText(pAutonoteFont, 1, 0, 0, (const char *)v9, 0, a1.uFrameY + a1.uFrameHeight, 0);
-    ++awards_count;
+    ++num_achieved_awards;
   }
   return (char)v8;
 }
@@ -515,7 +515,7 @@
     v0 = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(v0, v8, v10);
-  if ( dword_506544 || dword_506528 + awards_count >= awards_count2 )
+  if ( dword_506544 || dword_506528 + num_achieved_awards >= num_achieved_awards_2 )
   {
     v11 = pTex_tab_an_7a__zoot_off;
     v9 = pViewport->uViewportTL_Y + 38;
@@ -541,12 +541,12 @@
   a1.uFrameHeight = 264;
   a1.uFrameZ = 407;
   a1.uFrameW = 333;
-  if ( dword_506544 && dword_506528 + awards_count < awards_count2 )
+  if ( dword_506544 && dword_506528 + num_achieved_awards < num_achieved_awards_2 )
   {
     pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
     v2 = dword_50651C++;
-    dword_506528 += awards_count;
-    byte_506130[v2] = awards_count;
+    dword_506528 += num_achieved_awards;
+    byte_506130[v2] = num_achieved_awards;
   }
   if ( dword_506548 && dword_50651C )
   {
@@ -554,7 +554,7 @@
     --dword_50651C;
     dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
   }
-  if ( !awards_count || (v3 = dword_506528, dword_506528 < 1) )
+  if ( !num_achieved_awards || (v3 = dword_506528, dword_506528 < 1) )
   {
     v3 = 0;
     dword_50651C = 0;
@@ -562,11 +562,11 @@
   }
   dword_506544 = 0;
   dword_506548 = 0;
-  awards_count = 0;
-  while ( v3 < awards_count2 )
+  num_achieved_awards = 0;
+  while ( v3 < num_achieved_awards_2 )
   {
-    v4 = achievedAwardsIndex[v3];
-    ++awards_count;
+    v4 = achieved_awards[v3];
+    ++num_achieved_awards;
     v5 = pQuestTable[v4-1];//(&dword_722F10)[4 * v4];
     a1.DrawText(pAutonoteFont, 1, 0, 0, pQuestTable[v4-1], 0, 0, 0);//(&dword_722F10)[4 * v4], 0, 0, 0);
     v6 = pAutonoteFont->CalcTextHeight(v5, &a1, 1, 0);
@@ -633,7 +633,7 @@
     v0 = pViewport->uViewportTL_X + 398;
   }
   pRenderer->DrawTextureTransparent(v0, v17, v24);
-  if ( dword_506544 || dword_506528 + awards_count >= awards_count2 )
+  if ( dword_506544 || dword_506528 + num_achieved_awards >= num_achieved_awards_2 )
   {
     v25 = pTex_tab_an_7a__zoot_off;
     v18 = pViewport->uViewportTL_Y + 38;
@@ -807,10 +807,10 @@
   a1.uFrameW = 333;
   if ( v31 )
   {
-    awards_count2 = 0;
+    num_achieved_awards_2 = 0;
     dword_506528 = 0;
     dword_50651C = 0;
-    awards_count = 0;
+    num_achieved_awards = 0;
     v8 = 0;
     do
     {
@@ -823,25 +823,25 @@
         {
           if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v8) && v32 )
           {
-            v9 = awards_count++;
-            achievedAwardsIndex[v9] = (signed __int16)v8;
+            v9 = num_achieved_awards++;
+            achieved_awards[v9] = (AwardType)v8;
           }
         }
       }
       ++v8;
     }
     while ( v8 < 196 );
-    awards_count2 = awards_count;
+    num_achieved_awards_2 = num_achieved_awards;
   }
   else
   {
     if ( dword_506544 )
     {
-      v10 = awards_count + dword_506528;
-      if ( awards_count + dword_506528 < awards_count2 )
+      v10 = num_achieved_awards + dword_506528;
+      if ( num_achieved_awards + dword_506528 < num_achieved_awards_2 )
       {
         v11 = dword_50651C++;
-        byte_506130[v11] = awards_count;
+        byte_506130[v11] = num_achieved_awards;
         dword_506528 = v10;
         pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
       }
@@ -852,7 +852,7 @@
       dword_506528 -= (unsigned __int8)byte_506130[dword_50651C];
       pAudioPlayer->PlaySound((SoundID)230, 0, 0, -1, 0, 0, 0, 0);
     }
-    if ( !awards_count || dword_506528 < 1 )
+    if ( !num_achieved_awards || dword_506528 < 1 )
     {
       dword_506528 = 0;
       dword_50651C = 0;
@@ -862,16 +862,16 @@
   dword_50652C = 0;
   dword_506544 = 0;
   dword_506548 = 0;
-  awards_count = 0;
+  num_achieved_awards = 0;
   dword_506530 = 0;
   dword_506534 = 0;
   dword_506538 = 0;
   dword_50653C = 0;
   dword_506540 = 0;
-  while ( v12 < awards_count2 )
+  while ( v12 < num_achieved_awards_2 )
   {
-    v13 = achievedAwardsIndex[v12];
-    ++awards_count;
+    v13 = achieved_awards[v12];
+    ++num_achieved_awards;
     //v14 = (&dword_723718_autonote_related)[8 * v13];
 	v14 = pAutonoteTxt[v13-1].pText;
     //a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_723718_autonote_related)[8 * v13], 0, 0, 0);
@@ -1199,8 +1199,8 @@
         }
     else
         {
-        black = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
-        teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
+        black = TargetColor(0, 0, 0);
+        teal = TargetColor(0, 0xFFu, 0xFFu);
         v7 = pIndoor->pMapOutlines;
         uNumBlueFacesInBLVMinimap = 0;
         v8 = pIndoor->pMapOutlines->uNumOutlines == 0;
@@ -1381,7 +1381,7 @@
             }
         pRenderer->DrawTransparentRedShade(v47, v49, (Texture *)(pTextureIDs_pMapDirs[v50] != -1 ? (int)&pIcons_LOD->pTextures[pTextureIDs_pMapDirs[v50]] : 0));
         }
-    result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+    result = TargetColor(0xFFu, 0xFFu, 0xFFu);
     v95 = 0;
     v86 = result;
     if ( (signed int)uNumLevelDecorations > 0 )
@@ -1448,7 +1448,7 @@
         teal = v60 >> 16;
         v63 = (signed __int16)v61;
         a4a = map_texture_16;
-        result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xCu, 0xCu, 0xCu);
+        result = TargetColor(0xCu, 0xCu, 0xCu);
         screenCenter_X = 0;
         for ( i = result; screenCenter_X < (signed int)v95; result = screenCenter_X )
             {
@@ -1520,34 +1520,17 @@
 
 
 //----- (00413CC6) --------------------------------------------------------
-void __thiscall SellectDrawBook(unsigned int uBook)
+void DrawCurrentBook(unsigned int uBook)
 {
-  enum WindowType pWindowType; // esi@1
-
-  pWindowType = (enum WindowType)uBook;
-  pRenderer->DrawTextureIndexed(471u, 445u, (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0));
-  switch ( pWindowType )
+  pRenderer->DrawTextureIndexed(471, 445, pIcons_LOD->GetTexture(uExitCancelTextureId));
+  switch ((enum WindowType)uBook)
   {
-    case WINDOW_Lloyd: // 177
-      DrawLloydBeaconsScreen();
-      break;
-    case WINDOW_TownPortal: //195
-      DrawTownPortalScreen();
-      break;
-    case WINDOW_QuestBook: //200
-      DrawBook_Quests();
-      break;
-    case WINDOW_AutonotesBook: //201
-      DrawBook_Autonotes();
-      break;
-    case WINDOW_MapsBook://202
-      DrawBook_Maps();
-      break;
-    case WINDOW_CalendarBook://203
-      DrawBook_Calendar();
-      break;
-    case WINDOW_HistoryBook://224
-      DrawBook_History();
-      break;
+    case WINDOW_Lloyd:         DrawLloydBeaconsScreen(); break;
+    case WINDOW_TownPortal:    DrawTownPortalScreen();   break;
+    case WINDOW_QuestBook:     DrawBook_Quests();        break;
+    case WINDOW_AutonotesBook: DrawBook_Autonotes();     break;
+    case WINDOW_MapsBook:      DrawBook_Maps();          break;
+    case WINDOW_CalendarBook:  DrawBook_Calendar();      break;
+    case WINDOW_HistoryBook:   DrawBook_History();       break;
   }
 }
--- a/UICharacter.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/UICharacter.cpp	Wed May 01 23:36:54 2013 +0600
@@ -143,14 +143,14 @@
     char *v92; // [sp+3Ch] [bp-4h]@114
 
     v1 = uPlayerID;
-    a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-    v84 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xAFu, 0xFFu);
+    a5 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+    v84 = TargetColor(0, 0xAFu, 0xFFu);
     v85 = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
-    v86 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
-    v79 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
+    v86 = TargetColor(0xFFu, 0, 0);
+    v79 = TargetColor(0, 0xFFu, 0);
     pPlayer = &pParty->pPlayers[v1-1];
     v3 = pIcons_LOD->LoadTexture("fr_skill", TEXTURE_16BIT_PALETTE);
-    pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(v3 != -1 ? (int)&pIcons_LOD->pTextures[v3] : 0));
+    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(v3));
     v4 = v79;
     if ( !pPlayer->uSkillPoints )
         v4 = 65535;
@@ -218,7 +218,7 @@
             if ( HIBYTE(v87) & 1 )
                 {
                 if ( !v15 )
-                    v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                    v15 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                 v54 = uY;
                 v50 = v58;
                 v46 = pGlobalTXT_LocalizationStrings[96];
@@ -237,7 +237,7 @@
                     v16 = pGlobalTXT_LocalizationStrings[433];
                 v88 = v16;
                 if ( !v15 )
-                    v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                    v15 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                 v54 = uY;
                 v50 = v58;
                 v46 = v88;
@@ -307,7 +307,7 @@
                 if ( HIBYTE(v21) & 1 )
                     {
                     if ( !v24 )
-                        v24 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                        v24 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                     v55 = v23;
                     v51 = v59;
                     v47 = pGlobalTXT_LocalizationStrings[96];
@@ -328,7 +328,7 @@
                         v26 = pGlobalTXT_LocalizationStrings[433];
                     v89 = v26;
                     if ( !v24 )
-                        v24 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                        v24 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                     v55 = v23;
                     v51 = v59;
                     v47 = v89;
@@ -407,7 +407,7 @@
                     if ( (pPlayer->pActiveSkills[v64] >> 8) & 1 )
                         {
                         if ( !v34 )
-                            v34 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                            v34 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                         v56 = uYb;
                         v52 = v60;
                         v48 = pGlobalTXT_LocalizationStrings[96];
@@ -427,7 +427,7 @@
                             v35 = pGlobalTXT_LocalizationStrings[433];
                         v91 = v35;
                         if ( !v34 )
-                            v34 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                            v34 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                         v56 = uYb;
                         v52 = v60;
                         v48 = v91;
@@ -502,7 +502,7 @@
                         if ( HIBYTE(v40) & 1 )
                             {
                             if ( !v43 )
-                                v43 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                                v43 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                             v57 = v42;
                             v53 = v61;
                             v49 = pGlobalTXT_LocalizationStrings[96];
@@ -523,7 +523,7 @@
                                 v44 = pGlobalTXT_LocalizationStrings[433];
                             v92 = v44;
                             if ( !v43 )
-                                v43 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+                                v43 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
                             v57 = v42;
                             v53 = v61;
                             v49 = v92;
@@ -547,40 +547,61 @@
                         0,
                         0);
                     return (char)v38;
-    }
+}
+
+
+
+
+
+    
+unsigned int GetAwardColor(unsigned int priority)
+{
+  static unsigned __int8 pAwardsTextColors[6][3] =
+  {
+    {248, 108, 160},
+    {112, 220, 248},
+    {192, 192, 240},
+    { 64, 244,  96},
+    {232, 244,  96},
+    {240, 252, 192}
+  };
+
+  return TargetColor(pAwardsTextColors[priority % 6][0],
+                     pAwardsTextColors[priority % 6][1],
+                     pAwardsTextColors[priority % 6][2]);
+}
+
 
 //----- (0041A000) --------------------------------------------------------
-void CharacterUI_AwardsTab_Draw( unsigned int uPlayerID )
-    {
+void CharacterUI_AwardsTab_Draw(unsigned int uPlayerID)
+{
     //unsigned int v1; // esi@1
-    unsigned int v2; // ebx@1
-    unsigned int award_texture_id; // eax@1
+    //unsigned int v2; // ebx@1
+    //unsigned int award_texture_id; // eax@1
     unsigned int result; // eax@1
     int v5; // eax@15
     char *v6; // ebx@15
     int v7; // eax@23
     int v8; // eax@24
     int v9; // eax@25
-    int v10; // eax@27
+    //int v10; // eax@27
     int v11; // eax@32
     int v12; // eax@33
     int v13; // eax@34
-    signed int v14; // eax@43
-    unsigned int v15; // eax@43
-    int v16; // eax@43
-    int v17; // [sp-4h] [bp-D4h]@16
+    //signed int v14; // eax@43
+    //unsigned int v15; // eax@43
+    //int v16; // eax@43
+    //int v17; // [sp-4h] [bp-D4h]@16
     char Source[100]; // [sp+Ch] [bp-C4h]@1
     GUIWindow a1; // [sp+70h] [bp-60h]@1
-    unsigned int v20; // [sp+C4h] [bp-Ch]@15
-    int v21; // [sp+C8h] [bp-8h]@14
-    int v22; // [sp+CCh] [bp-4h]@40
+    //unsigned int v20; // [sp+C4h] [bp-Ch]@15
+    //int v21; // [sp+C8h] [bp-8h]@14
+    //int v22; // [sp+CCh] [bp-4h]@40
 
     auto player = &pParty->pPlayers[uPlayerID - 1];
     //v1 = uPlayerID;
-    v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-    award_texture_id = pIcons_LOD->LoadTexture("fr_award", TEXTURE_16BIT_PALETTE);
-    pRenderer->DrawTextureIndexed(8u, 8u, (Texture *)(award_texture_id != -1 ? &pIcons_LOD->pTextures[award_texture_id] : 0));
-    sprintfex(pTmpBuf, "%s \f%05d", pGlobalTXT_LocalizationStrings[LOCSTR_AVARDS_FOR], v2);
+    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->LoadTexturePtr("fr_award", TEXTURE_16BIT_PALETTE));
+    sprintfex(pTmpBuf, "%s \f%05d", pGlobalTXT_LocalizationStrings[LOCSTR_AVARDS_FOR], TargetColor(0xFF, 0xFF, 0x9B));
     sprintfex(Source, pGlobalTXT_LocalizationStrings[LOCSTR_S_THE_S], player->pName, pClassNames[player->classType]);
     strcat(pTmpBuf, Source);
     strcat(pTmpBuf, "\f00000");
@@ -592,7 +613,7 @@
     a1.uFrameHeight = 290;
     a1.uFrameZ = 435;
     a1.uFrameW = 337;
-    if ( dword_506544 && awards_count + dword_506528 < awards_count2 )
+    if ( dword_506544 && num_achieved_awards + dword_506528 < num_achieved_awards_2 )
         result = dword_506528++ + 1;
     if ( dword_506548 && result )
         {
@@ -601,17 +622,17 @@
         }
     if ( dword_50651C < 0 )
         {
-        result += awards_count;
+        result += num_achieved_awards;
         dword_506528 = result;
-        if ( (signed int)(awards_count + result) > awards_count2 )
+        if ( (signed int)(num_achieved_awards + result) > num_achieved_awards_2 )
             {
-            result = awards_count2 - awards_count;
+            result = num_achieved_awards_2 - num_achieved_awards;
             dword_506528 = result;
             }
         }
     else if ( dword_50651C > 0 )
         {
-        result -= awards_count;
+        result -= num_achieved_awards;
         dword_506528 = result;
         if ( (result & 0x80000000u) != 0 )
             {
@@ -622,105 +643,42 @@
     //LABEL_14:
     dword_506544 = 0;
     dword_506548 = 0;
-    awards_count = 0;
+    num_achieved_awards = 0;
     dword_50651C = 0;
-    v21 = result;
-    if ( (signed int)result < awards_count2 )
-        {
-        while ( 1 )
+
+
+    for (uint i = result; i < num_achieved_awards_2; ++i)
+    {
+      v5 = achieved_awards[i];
+      v6 = (char *)pAwards[v5].pText;//(char *)dword_723E80_award_related[v20 / 4];
+
+            pTmpBuf[0] = 0;
+            switch (v5)
             {
-            v5 = achievedAwardsIndex[v21];
-            v20 = achievedAwardsIndex[v21];
-            v6 = (char *)pAwards[v20].pText;//(char *)dword_723E80_award_related[v20 / 4];
-            if ( v5 != 1 )
-                {
-                if (!( (v5 < 85 || v5 > 91) && (v5 < 103 || v5 > 104) ))
-                    {
-                    if ( v5 > 89 )
-                        {
-                        if ( v5 == 90 )
-                            {
-                            v10 = (unsigned __int8)pParty->uNumArenaKnightWins;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 91 )
-                            {
-                            v10 = (unsigned __int8)pParty->uNumArenaLordWins;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 103 )
-                            {
-                            v10 = pParty->field_874;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 104 )
-                            {
-                            v10 = pParty->field_878;
-                            v22 = v10;
-                            }
-                        }
-                    else
-                        {
-                        if ( v5 == 89 )
-                            {
-                            v10 = (unsigned __int8)pParty->uNumArenaSquireWins;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 85 )
-                            {
-                            v10 = pParty->uNumDeaths;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 86 )
-                            {
-                            v10 = pParty->uNumBountiesCollected;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 87 )
-                            {
-                            v10 = pParty->uNumPrisonTerms;
-                            v22 = v10;
-                            }
-                        else if ( v5 == 88)
-                            {
-                            v10 = (unsigned __int8)pParty->uNumArenaPageWins;
-                            v22 = v10;
-                            }
-                        }
-                    v17 = v22;
-                    sprintf(pTmpBuf, v6, v17);
-                    v6 = pTmpBuf;
-                    }
-                }
-            else
-                {
-                v17 = pParty->uFine;
-                sprintf(pTmpBuf, v6, v17);
-                v6 = pTmpBuf;
-                }
-            v14 = pAwards[v20].uSort;//dword_723E84[v20 / 4];
-            ++awards_count;
-            v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(
-                pAwardsTextColors[3 * v14 % 6],
-                pAwardsTextColors[3 * v14 % 6 + 1],
-                pAwardsTextColors[3 * v14 % 6 + 2]);
-            a1.DrawText(pFontArrus, 0, 0, v15, v6, 0, 0, 0);
-            v16 = pFontArrus->CalcTextHeight(v6, &a1, 0, 0);
-            result = v16 + a1.uFrameY + 4;
-            if ( (signed int)result <= (signed int)a1.uFrameHeight )
-                {
-                ++v21;
-                a1.uFrameY = result;
-                result = v21;
-                if ( v21 < awards_count2 )
-                    continue;
-                }
-            return;
+              case Award_Arena_PageWins:    sprintf(pTmpBuf, v6, pParty->uNumArenaPageWins);     break;
+              case Award_Arena_SquireWins:  sprintf(pTmpBuf, v6, pParty->uNumArenaSquireWins);   break;
+              case Award_Arena_KnightWins:  sprintf(pTmpBuf, v6, pParty->uNumArenaKnightWins);   break;
+              case Award_Arena_LordWins:    sprintf(pTmpBuf, v6, pParty->uNumArenaLordWins);     break;
+              case Award_ArcomageWins:      sprintf(pTmpBuf, v6, pParty->uNumArcomageWins);      break;
+              case Award_ArcomageLoses:     sprintf(pTmpBuf, v6, pParty->uNumArcomageLoses);     break;
+              case Award_Deaths:            sprintf(pTmpBuf, v6, pParty->uNumDeaths);            break;
+              case Award_BountiesCollected: sprintf(pTmpBuf, v6, pParty->uNumBountiesCollected); break;
+              case Award_Fine:              sprintf(pTmpBuf, v6, pParty->uFine);                 break;
+              case Award_PrisonTerms:       sprintf(pTmpBuf, v6, pParty->uNumPrisonTerms);       break;
             }
 
+            if (*pTmpBuf)
+              v6 = pTmpBuf;
+
+
+            a1.DrawText(pFontArrus, 0, 0, GetAwardColor(pAwards[v5].uPriority), v6, 0, 0, 0);
+            a1.uFrameY = pFontArrus->CalcTextHeight(v6, &a1, 0, 0) + a1.uFrameY + 4;
+            if (a1.uFrameY > a1.uFrameHeight)
+              break;
+
+            ++num_achieved_awards;
         }
-    return;
-    }
+ }
 
 
 
@@ -771,11 +729,11 @@
         pPlayer = pPlayers[uPlayerID];
         v3 = a2;
         pPlayer2 = pPlayers[uPlayerID];
-        pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_507958 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_507958] : 0));
+        pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_507958));
         if ( v3 )
             {
             v4 = pIcons_LOD->LoadTexture("fr_strip", TEXTURE_16BIT_PALETTE);
-            pRenderer->DrawTextureIndexed(8u, 0x131u, (Texture *)(v4 != -1 ? (int)&pIcons_LOD->pTextures[v4] : 0));
+            pRenderer->DrawTextureIndexed(8u, 0x131u, pIcons_LOD->GetTexture(v4));
             }
         uCellID = 0;
         v26 = (int)pPlayer->pInventoryIndices;
@@ -792,8 +750,8 @@
                     {
                     v6 = pIcons_LOD->LoadTexture(pItemsTable->pItems[pItem->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
                     uTextureId = v6;
-                    v7 = (Texture *)(v6 != -1 ? (int)&pIcons_LOD->pTextures[v6] : 0);
-                    v8 = (v6 != -1 ? pIcons_LOD->pTextures[v6].uTextureWidth : 24);
+                    v7 = pIcons_LOD->GetTexture(v6);
+                    v8 = v7->uTextureWidth;
                     v9 = v7->uTextureHeight;
                     v10 = v7->uTextureWidth;
                     v11 = v7->uTextureWidth;
@@ -837,7 +795,7 @@
                         if ( (unsigned __int8)(v16 & 0xF0) == 32 )
                             {
                             v20 = "sp28a";
-                            pTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v20, TEXTURE_16BIT_PALETTE)];
+                            pTexture = pIcons_LOD->LoadTexturePtr(v20, TEXTURE_16BIT_PALETTE);
                             dword_50C9A8 -= pEventTimer->uTimeElapsed;
                             if ( dword_50C9A8 <= 0 )
                                 {
@@ -857,7 +815,7 @@
                         if ( (unsigned __int8)(v16 & 0xF0) == 64 )
                             {
                             v20 = "sp30a";
-                            pTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v20, TEXTURE_16BIT_PALETTE)];
+                            pTexture = pIcons_LOD->LoadTexturePtr(v20, TEXTURE_16BIT_PALETTE);
                             dword_50C9A8 -= pEventTimer->uTimeElapsed;
                             if ( dword_50C9A8 <= 0 )
                                 {
@@ -877,7 +835,7 @@
                         if ( (unsigned __int8)(v16 & 0xF0) == 128 )
                             {
                             v20 = "sp91a";
-                            pTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v20, TEXTURE_16BIT_PALETTE)];
+                            pTexture = pIcons_LOD->LoadTexturePtr(v20, TEXTURE_16BIT_PALETTE);
                             dword_50C9A8 -= pEventTimer->uTimeElapsed;
                             if ( dword_50C9A8 <= 0 )
                                 {
@@ -896,7 +854,7 @@
                             }
                         }
                     v20 = "sptext01";
-                    pTexture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v20, TEXTURE_16BIT_PALETTE)];
+                    pTexture = pIcons_LOD->LoadTexturePtr(v20, TEXTURE_16BIT_PALETTE);
                     dword_50C9A8 -= pEventTimer->uTimeElapsed;
                     if ( dword_50C9A8 <= 0 )
                         {
@@ -977,9 +935,9 @@
         //unsigned int v49; // [sp+28h] [bp-4h]@1
 
         v0 = 0;
-        v47 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-        //v49 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
-        v46 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
+        v47 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
+        //v49 = TargetColor(0xFFu, 0, 0);
+        v46 = TargetColor(0, 0xFFu, 0);
         //v1 = pIcons_LOD->LoadTexture("quikref", TEXTURE_16BIT_PALETTE);
         pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->LoadTexturePtr("quikref", TEXTURE_16BIT_PALETTE));
         v43 = 0;
@@ -999,7 +957,7 @@
             if ( pPlayer->GetActualLevel() <= v4 )
                 v5 = pPlayer->GetExperienceDisplayColor();
             else
-                v5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, v0);
+                v5 = TargetColor(0, 0xFFu, v0);
             pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, v44, 0x2Fu, v5, pTmpBuf, 84, v0);
             v6 = v45 + 47;
             if ( v43 == v0 )
@@ -1097,9 +1055,9 @@
             if ( v38 >= 0 )
                 {
                 if ( v38 <= 5 )
-                    v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0xFF);
+                    v39 = TargetColor(0xFF, 0xFF, 0xFF);
                 else
-                    v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0, 0);
+                    v39 = TargetColor(0xFF, 0, 0);
                 }
             else
                 v39 = v46;
@@ -1132,7 +1090,7 @@
         sub_419379();
         CharacterUI_StatsTab_Draw(uPlayerIdx);
         v7 = pIcons_LOD->LoadTexture("ib-cd1-d", TEXTURE_16BIT_PALETTE);
-        pTexture = (Texture *)(v7 != -1 ? (int)&pIcons_LOD->pTextures[v7] : 0);
+        pTexture = pIcons_LOD->GetTexture(v7);
         pButton = pCharacterScreen_StatsBtn;
         pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
         break;
@@ -1145,7 +1103,7 @@
         sub_419379();
         CharacterUI_SkillsTab_Draw(uPlayerIdx);
         v6 = pIcons_LOD->LoadTexture("ib-cd2-d", TEXTURE_16BIT_PALETTE);
-        pTexture = (Texture *)(v6 != -1 ? (int)&pIcons_LOD->pTextures[v6] : 0);
+        pTexture = pIcons_LOD->GetTexture(v6);
         pButton = pCharacterScreen_SkillsBtn;
         pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
         break;
@@ -1155,7 +1113,7 @@
         sub_419220();
         CharacterUI_AwardsTab_Draw(uPlayerIdx);
         v5 = pIcons_LOD->LoadTexture("ib-cd4-d", TEXTURE_16BIT_PALETTE);
-        pTexture = (Texture *)(v5 != -1 ? (int)&pIcons_LOD->pTextures[v5] : 0);
+        pTexture = pIcons_LOD->GetTexture(v5);
         pButton = pCharacterScreen_AwardsBtn;
         pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
         break;
@@ -1164,7 +1122,7 @@
         sub_419379();
         CharacterUI_InventoryTab_Draw(uPlayerIdx, 0);
         v2 = pIcons_LOD->LoadTexture("ib-cd3-d", TEXTURE_16BIT_PALETTE);
-        pTexture = (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0);
+        pTexture = pIcons_LOD->GetTexture(v2);
         pButton = pCharacterScreen_InventoryBtn;
         pRenderer->DrawTextureIndexed(pButton->uX, pButton->uY, pTexture);
         break;
@@ -1347,17 +1305,14 @@
   pRenderer->DrawTextureIndexed(0x1D3u, 0, pIcons_LOD->GetTexture(uTextureID_BACKDOLL));//
   if ( IsPlayerWearingWatersuit[uPlayerID] )//
   {
-    pRenderer->DrawTextureTransparent(pPaperdoll_BodyX, pPaperdoll_BodyY,
-            (Texture *)(papredoll_dbods[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbods[uPlayerID - 1]] : 0));
+    pRenderer->DrawTextureTransparent(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]));
     if ( !bRingsShownInCharScreen )
-      pRenderer->DrawMaskToZBuffer(pPaperdoll_BodyX, pPaperdoll_BodyY,
-                 (Texture *)(papredoll_dbods[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbods[uPlayerID - 1]] : 0),
-                 pPlayers[uPlayerID]->pEquipment.uArmor);
+      pRenderer->DrawMaskToZBuffer(pPaperdoll_BodyX, pPaperdoll_BodyY, pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]), pPlayers[uPlayerID]->pEquipment.uArmor);
     v6 = pPlayers[uPlayerID]->pEquipment.uMainHand;
     if ( !v6 || (v7 = *(int *)&pPlayers[uPlayerID]->pInventoryItems[v6-1], pItemsTable->pItems[v7].uEquipType != 1)
          && (pItemsTable->pItems[v7].uSkillType != 4 || pPlayers[uPlayerID]->pEquipment.uShield) )
          pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1],
-         (Texture *)(papredoll_dlads[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dlads[uPlayerID - 1]] : 0));
+         pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1]));
     pMainHandNum4 = pPlayers[uPlayerID]->pEquipment.uMainHand;
     if ( pMainHandNum4 )
     {
@@ -1372,15 +1327,15 @@
       if ( !( item_MainHand4->uAttributes & 0xF0 ) )
       {
         v18 = v14 + 1;
-        v19 = (char *)&pIcons_LOD->pTextures[v14];
+        v19 = (char *)pIcons_LOD->GetTexture(v14);
         if ( item_MainHand4->uAttributes & 2 )
-          pRenderer->DrawTransparentRedShade(pX_MainHand4, pY_MainHand4, (Texture *)(v18 != 0 ? (int)v19 : 0));
+          pRenderer->DrawTransparentRedShade(pX_MainHand4, pY_MainHand4, (Texture *)v19);
         else
         {
           if ( item_MainHand4->uAttributes & 1 )
-            pRenderer->DrawTextureTransparent(pX_MainHand4, pY_MainHand4, (Texture *)(v18 != 0 ? (int)v19 : 0));
+            pRenderer->DrawTextureTransparent(pX_MainHand4, pY_MainHand4, (Texture *)v19);
           else
-            pRenderer->DrawTransparentGreenShade(pX_MainHand4, pY_MainHand4, (Texture *)(v18 != 0 ? (int)v19 : 0));
+            pRenderer->DrawTransparentGreenShade(pX_MainHand4, pY_MainHand4, (Texture *)v19);
         }
       }
       if ( item_MainHand4->uAttributes & 0xF0 )
@@ -1393,7 +1348,7 @@
           v167 = "sp30a";
         if ( (item_MainHand4->uAttributes & 0xF0) == 128 )
           v167 = "sp91a";
-        v16 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v167, TEXTURE_16BIT_PALETTE)];
+        v16 = pIcons_LOD->LoadTexturePtr(v167, TEXTURE_16BIT_PALETTE);
         dword_50C9A8 -= pEventTimer->uTimeElapsed;
         if ( dword_50C9A8 <= 0 )
         {
@@ -1402,10 +1357,10 @@
           ptr_50C9A4 = 0;
         }
         v17 = (double)GetTickCount() * 0.1;
-        pRenderer->_4A63E6(pX_MainHand4, pY_MainHand4, (Texture *)(v14 != -1 ? (int)&pIcons_LOD->pTextures[v14] : 0), v16, (signed __int64)v17, 0, 255);
+        pRenderer->_4A63E6(pX_MainHand4, pY_MainHand4, pIcons_LOD->GetTexture(v14), v16, (signed __int64)v17, 0, 255);
       }
       if ( !bRingsShownInCharScreen )
-        pRenderer->DrawMaskToZBuffer(pX_MainHand4, pY_MainHand4, (Texture *)(v18 != 0 ? (int)v19 : 0), pMainHandNum4);
+        pRenderer->DrawMaskToZBuffer(pX_MainHand4, pY_MainHand4, (Texture *)v19, pMainHandNum4);
     }
   }
   else//  
@@ -1420,14 +1375,14 @@
       if ( !(itemBow->uAttributes & 0xF0) )//    
       {
         if ( itemBow->uAttributes & 2 )
-          pRenderer->DrawTransparentRedShade(pX_Bow, pY_Bow, (Texture *)(pBowTextureNum != -1 ? (int)&pIcons_LOD->pTextures[pBowTextureNum] : 0));
+          pRenderer->DrawTransparentRedShade(pX_Bow, pY_Bow, pIcons_LOD->GetTexture(pBowTextureNum));
         else
         {
-          v30 = (char *)&pIcons_LOD->pTextures[pBowTextureNum];
+          v30 = (char *)pIcons_LOD->GetTexture(pBowTextureNum);
           if ( !(itemBow->uAttributes & 1) )//   
-            pRenderer->DrawTransparentGreenShade(pX_Bow, pY_Bow, (Texture *)(pBowTextureNum != -1 ? (int)v30 : 0));
+            pRenderer->DrawTransparentGreenShade(pX_Bow, pY_Bow, (Texture *)v30);
           else //  
-            pRenderer->DrawTextureTransparent(pX_Bow, pY_Bow, (Texture *)(pBowTextureNum != -1 ? (int)v30 : 0));
+            pRenderer->DrawTextureTransparent(pX_Bow, pY_Bow, (Texture *)v30);
         }
       }
       else
@@ -1440,7 +1395,7 @@
           v168 = "sp30a";
         if ( (itemBow->uAttributes & 0xF0) == 128 )
           v168 = "sp91a";
-        a2b = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v168, TEXTURE_16BIT_PALETTE)];
+        a2b = pIcons_LOD->LoadTexturePtr(v168, TEXTURE_16BIT_PALETTE);
         dword_50C9A8 -= pEventTimer->uTimeElapsed;
         if ( dword_50C9A8 <= 0 )
         {
@@ -1449,10 +1404,10 @@
           ptr_50C9A4 = 0;
         }
         v28 = (double)GetTickCount() * 0.1;
-        pRenderer->_4A63E6(pX_Bow, pY_Bow, (Texture *)(pBowTextureNum != -1 ? (int)&pIcons_LOD->pTextures[pBowTextureNum] : 0), a2b, (signed __int64)v28, 0, 255);
+        pRenderer->_4A63E6(pX_Bow, pY_Bow, pIcons_LOD->GetTexture(pBowTextureNum), a2b, (signed __int64)v28, 0, 255);
       }
       if ( !bRingsShownInCharScreen )
-        pRenderer->DrawMaskToZBuffer(pX_Bow, pY_Bow, (Texture *)(pBowTextureNum != -1 ? (int)&pIcons_LOD->pTextures[pBowTextureNum] : 0), pBowNum);
+        pRenderer->DrawMaskToZBuffer(pX_Bow, pY_Bow, pIcons_LOD->GetTexture(pBowTextureNum), pBowNum);
     }
     pCloakNum = pPlayers[uPlayerID]->pEquipment.uCloak;//  
     if ( pCloakNum )
@@ -1488,9 +1443,9 @@
         {
           v41 = v35 + 1;
           if ( item_Cloak->uAttributes & 2 )
-            pRenderer->DrawTransparentRedShade(pX_Cloak, pY_Cloak, (Texture *)(v41 != 0 ? (int)&pIcons_LOD->pTextures[v35] : 0));
+            pRenderer->DrawTransparentRedShade(pX_Cloak, pY_Cloak, pIcons_LOD->GetTexture(v35));
           else
-            pRenderer->DrawTextureTransparent(pX_Cloak, pY_Cloak, (Texture *)(v41 != 0 ? (int)&pIcons_LOD->pTextures[v35] : 0));
+            pRenderer->DrawTextureTransparent(pX_Cloak, pY_Cloak, pIcons_LOD->GetTexture(v35));
         }
         else
         {
@@ -1502,7 +1457,7 @@
             v169 = "sp30a";
           if ( (item_Cloak->uAttributes & 0xF0) == 128 )
             v169 = "sp91a";
-          v39 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v169, TEXTURE_16BIT_PALETTE)];
+          v39 = pIcons_LOD->LoadTexturePtr(v169, TEXTURE_16BIT_PALETTE);
           dword_50C9A8 -= pEventTimer->uTimeElapsed;
           if ( dword_50C9A8 <= 0 )
           {
@@ -1511,14 +1466,14 @@
             ptr_50C9A4 = 0;
           }
           v40 = (double)GetTickCount() * 0.1;
-          pRenderer->_4A63E6(pX_Cloak, pY_Cloak, (Texture *)(v35 != -1 ? (int)&pIcons_LOD->pTextures[v35] : 0), v39, (signed __int64)v40, 0, 255);
+          pRenderer->_4A63E6(pX_Cloak, pY_Cloak, pIcons_LOD->GetTexture(v35), v39, (signed __int64)v40, 0, 255);
         }
         if ( !bRingsShownInCharScreen )
-          pRenderer->DrawMaskToZBuffer(pX_Cloak, pY_Cloak, (Texture *)(v41 != 0 ? (int)&pIcons_LOD->pTextures[v35] : 0), pCloakNum);
+          pRenderer->DrawMaskToZBuffer(pX_Cloak, pY_Cloak, pIcons_LOD->GetTexture(v35), pCloakNum);
       }
     }
     pRenderer->DrawTextureTransparent(pPaperdoll_BodyX, pPaperdoll_BodyY,// 
-            (Texture *)(papredoll_dbods[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbods[uPlayerID - 1]] : 0));
+            pIcons_LOD->GetTexture(papredoll_dbods[uPlayerID - 1]));
     pArmorNum = pPlayers[uPlayerID]->pEquipment.uArmor;//  
     if ( pArmorNum )
     {
@@ -1550,14 +1505,14 @@
         {
           v53 = v48 + 1;
           if ( item_Armor->uAttributes & 2 )
-            pRenderer->DrawTransparentRedShade(pX_Armor, pY_Armor, (Texture *)(v53 != 0 ? (int)&pIcons_LOD->pTextures[v48] : 0));
+            pRenderer->DrawTransparentRedShade(pX_Armor, pY_Armor, pIcons_LOD->GetTexture(v48));
           else
           {
             v55 = (char *)&pIcons_LOD->pTextures[v48];
             if ( !(item_Armor->uAttributes & 1) )
-              pRenderer->DrawTransparentGreenShade(pX_Armor, pY_Armor, (Texture *)(v53 != 0 ? (int)v55 : 0));
+              pRenderer->DrawTransparentGreenShade(pX_Armor, pY_Armor, (Texture *)v55);
             else
-              pRenderer->DrawTextureTransparent(pX_Armor, pY_Armor, (Texture *)(v53 != 0 ? (int)v55 : 0));
+              pRenderer->DrawTextureTransparent(pX_Armor, pY_Armor, (Texture *)v55);
           }
         }
         else
@@ -1570,7 +1525,7 @@
             v170 = "sp30a";
           if ( (item_Armor->uAttributes & 0xF0) == 128 )
             v170 = "sp91a";
-          v51 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v170, TEXTURE_16BIT_PALETTE)];
+          v51 = pIcons_LOD->LoadTexturePtr(v170, TEXTURE_16BIT_PALETTE);
           dword_50C9A8 -= pEventTimer->uTimeElapsed;
           if ( dword_50C9A8 <= 0 )
           {
@@ -1579,7 +1534,7 @@
             ptr_50C9A4 = 0;
           }
           v52 = (double)GetTickCount() * 0.1;
-          pRenderer->_4A63E6(pX_Armor, pY_Armor, (Texture *)(v48 != -1 ? (int)&pIcons_LOD->pTextures[v48] : 0), v51, (signed __int64)v52, 0, 255);
+          pRenderer->_4A63E6(pX_Armor, pY_Armor, pIcons_LOD->GetTexture(v48), v51, (signed __int64)v52, 0, 255);
         }
         if ( pPlayers[uPlayerID]->pEquipment.uMainHand //  
           && (pPlayers[uPlayerID]->GetEquippedItemEquipType(EQUIP_MAIN_HAND) == EQUIP_MAIN_HAND ||
@@ -1601,15 +1556,15 @@
           if ( !(item_Armor->uAttributes & 0xF0) )
           {
             v98 = v94 + 1;
-            v99 = (char *)&pIcons_LOD->pTextures[v94];
+            v99 = (char *)pIcons_LOD->GetTexture(v94);
             if ( item_Armor->uAttributes & 2 )
-              pRenderer->DrawTransparentRedShade(pX_shoulder, pY_shoulder, (Texture *)(v98 != 0 ? (int)v99 : 0));
+              pRenderer->DrawTransparentRedShade(pX_shoulder, pY_shoulder, (Texture *)v99);
             else
             {
               if ( item_Armor->uAttributes & 1 )
-                pRenderer->DrawTextureTransparent(pX_shoulder, pY_shoulder, (Texture *)(v98 != 0 ? (int)v99 : 0));
+                pRenderer->DrawTextureTransparent(pX_shoulder, pY_shoulder, (Texture *)v99);
               else
-                pRenderer->DrawTransparentGreenShade(pX_shoulder, pY_shoulder, (Texture *)(v98 != 0 ? (int)v99 : 0));
+                pRenderer->DrawTransparentGreenShade(pX_shoulder, pY_shoulder, (Texture *)v99);
             }
           }
           else
@@ -1626,7 +1581,7 @@
                   v173 = "sp30a";
                 if ( (item_Armor->uAttributes & 0xF0) == 128 )
                   v173 = "sp91a";
-                v96 = (char *)&pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v173, TEXTURE_16BIT_PALETTE)];
+                v96 = (char *)pIcons_LOD->LoadTexturePtr(v173, TEXTURE_16BIT_PALETTE);
                 dword_50C9A8 -= pEventTimer->uTimeElapsed;
                 if ( dword_50C9A8 <= 0 )
                 {
@@ -1635,7 +1590,7 @@
                   ptr_50C9A4 = 0;
                 }
                 v97 = (double)GetTickCount();
-                pRenderer->_4A63E6(pX_shoulder, pY_shoulder, (Texture *)(v94 != -1 ? (int)&pIcons_LOD->pTextures[v94] : 0), (Texture *)v96, (signed __int64)(v97 * 0.1), 0, 255);
+                pRenderer->_4A63E6(pX_shoulder, pY_shoulder, pIcons_LOD->GetTexture(v94), (Texture *)v96, (signed __int64)(v97 * 0.1), 0, 255);
               }
             }
           }
@@ -1650,15 +1605,15 @@
             if ( !(item_Armor->uAttributes & 0xF0) )
             {
               v109 = v94 + 1;
-              v110 = (char *)&pIcons_LOD->pTextures[v94];
+              v110 = (char *)pIcons_LOD->GetTexture(v94);
               if ( item_Armor->uAttributes & 2 )
-                pRenderer->DrawTransparentRedShade(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)(v109 != 0 ? (int)v110 : 0));
+                pRenderer->DrawTransparentRedShade(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)v110);
               else
               {
                 if ( item_Armor->uAttributes & 1 )
-                  pRenderer->DrawTextureTransparent(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)(v109 != 0 ? (int)v110 : 0));
+                  pRenderer->DrawTextureTransparent(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)v110);
                 else
-                  pRenderer->DrawTransparentGreenShade(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)(v109 != 0 ? (int)v110 : 0));
+                  pRenderer->DrawTransparentGreenShade(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)v110);
               }
             }
             else
@@ -1671,7 +1626,7 @@
                 v178 = "sp30a";
               if ( (item_Armor->uAttributes & 0xF0) == 128 )
                 v178 = "sp91a";
-              v96 = (char *)&pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v178, TEXTURE_16BIT_PALETTE)];
+              v96 = (char *)pIcons_LOD->LoadTexturePtr(v178, TEXTURE_16BIT_PALETTE);
               dword_50C9A8 -= pEventTimer->uTimeElapsed;
               if ( dword_50C9A8 <= 0 )
               {
@@ -1680,12 +1635,12 @@
                 ptr_50C9A4 = 0;
               }
               v97 = (double)GetTickCount();
-              pRenderer->_4A63E6(pX_ArmorShoulder, pY_ArmorShoulder, (Texture *)(v94 != -1 ? (int)&pIcons_LOD->pTextures[v94] : 0), (Texture *)v96, (signed __int64)(v97 * 0.1), 0, 255);
+              pRenderer->_4A63E6(pX_ArmorShoulder, pY_ArmorShoulder, pIcons_LOD->GetTexture(v94), (Texture *)v96, (signed __int64)(v97 * 0.1), 0, 255);
             }
           }
         }
         if ( !bRingsShownInCharScreen )
-          pRenderer->DrawMaskToZBuffer(pX_Armor, pY_Armor, (Texture *)(v53 != 0 ? (int)v55 : 0), pArmorNum);
+          pRenderer->DrawMaskToZBuffer(pX_Armor, pY_Armor, (Texture *)v55, pArmorNum);
       }
     }
     pBootNum = pPlayers[uPlayerID]->pEquipment.uBoot;// 
@@ -1714,15 +1669,15 @@
         if ( !(item_Boot->uAttributes & 0xF0) )
         {
           v65 = v59 + 1;
-          v66 = (char *)&pIcons_LOD->pTextures[v59];
+          v66 = (char *)pIcons_LOD->GetTexture(v59);
           if ( item_Boot->uAttributes & 2 )
-            pRenderer->DrawTransparentRedShade(pX_Boot, pY_Boot, (Texture *)(v65 != 0 ? (int)v66 : 0));
+            pRenderer->DrawTransparentRedShade(pX_Boot, pY_Boot, (Texture *)v66);
           else
           {
             if ( item_Boot->uAttributes & 1 )
-              pRenderer->DrawTextureTransparent(pX_Boot, pY_Boot, (Texture *)(v65 != 0 ? (int)v66 : 0));
+              pRenderer->DrawTextureTransparent(pX_Boot, pY_Boot, (Texture *)v66);
             else
-              pRenderer->DrawTransparentGreenShade(pX_Boot, pY_Boot, (Texture *)(v65 != 0 ? (int)v66 : 0));
+              pRenderer->DrawTransparentGreenShade(pX_Boot, pY_Boot, (Texture *)v66);
           }
         }
         else
@@ -1735,7 +1690,7 @@
             v171 = "sp30a";
           if ( (item_Boot->uAttributes & 0xF0) == 128 )
             v171 = "sp91a";
-          v63 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v171, TEXTURE_16BIT_PALETTE)];
+          v63 = pIcons_LOD->LoadTexturePtr(v171, TEXTURE_16BIT_PALETTE);
           dword_50C9A8 -= pEventTimer->uTimeElapsed;
           if ( dword_50C9A8 <= 0 )
           {
@@ -1744,10 +1699,10 @@
             ptr_50C9A4 = 0;
           }
           v64 = (double)GetTickCount() * 0.1;
-          pRenderer->_4A63E6(pX_Boot, pY_Boot, (Texture *)(v59 != -1 ? (int)&pIcons_LOD->pTextures[v59] : 0), v63, (signed __int64)v64, 0, 255);
+          pRenderer->_4A63E6(pX_Boot, pY_Boot, pIcons_LOD->GetTexture(v59), v63, (signed __int64)v64, 0, 255);
         }
         if ( !bRingsShownInCharScreen )
-          pRenderer->DrawMaskToZBuffer(pX_Boot, pY_Boot, (Texture *)(v65 != 0 ? (int)v66 : 0), pBootNum);
+          pRenderer->DrawMaskToZBuffer(pX_Boot, pY_Boot, (Texture *)v66, pBootNum);
       }
     }
     pMainHandNum = pPlayers[uPlayerID]->pEquipment.uMainHand;
@@ -1755,7 +1710,7 @@
         && (pItemsTable->pItems[v70].uSkillType != 4 || pPlayers[uPlayerID]->pEquipment.uShield) )
       pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_LeftHand[pBodyComplection][0],
             pPaperdoll_BodyY + pPaperdoll_LeftHand[pBodyComplection][1],
-                     (Texture *)(papredoll_dlads[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dlads[uPlayerID - 1]] : 0));
+                     pIcons_LOD->GetTexture(papredoll_dlads[uPlayerID - 1]));
         pBeltNum = pPlayers[uPlayerID]->pEquipment.uBelt;//  
         if ( pBeltNum )
         {
@@ -1783,18 +1738,18 @@
           if ( !(item_Belt->uAttributes & 0xF0) )
           {
             v79 = v75 + 1;
-            v80 = (char *)&pIcons_LOD->pTextures[v75];
+            v80 = (char *)pIcons_LOD->GetTexture(v75);
             if ( item_Belt->uAttributes & 2 )
-              pRenderer->DrawTransparentRedShade(pX_Belt, pY_Belt, (Texture *)(v79 != 0 ? (int)v80 : 0));
+              pRenderer->DrawTransparentRedShade(pX_Belt, pY_Belt, (Texture *)v80);
             else
             {
               if ( item_Belt->uAttributes & 1 )
-                pRenderer->DrawTextureTransparent(pX_Belt, pY_Belt, (Texture *)(v79 != 0 ? (int)v80 : 0));
+                pRenderer->DrawTextureTransparent(pX_Belt, pY_Belt, (Texture *)v80);
               else
-                pRenderer->DrawTransparentGreenShade(pX_Belt, pY_Belt, (Texture *)(v79 != 0 ? (int)v80 : 0));
+                pRenderer->DrawTransparentGreenShade(pX_Belt, pY_Belt, (Texture *)v80);
             }
             if ( !bRingsShownInCharScreen )
-              pRenderer->DrawMaskToZBuffer(pX_Belt, pY_Belt, (Texture *)(v79 != 0 ? (int)v80 : 0), pBeltNum);
+              pRenderer->DrawMaskToZBuffer(pX_Belt, pY_Belt, (Texture *)v80, pBeltNum);
           }
           else
           {
@@ -1806,7 +1761,7 @@
               v172 = "sp30a";
             if ( (item_Belt->uAttributes & 0xF0) == 128 )
               v172 = "sp91a";
-            v77 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v172, TEXTURE_16BIT_PALETTE)];
+            v77 = pIcons_LOD->LoadTexturePtr(v172, TEXTURE_16BIT_PALETTE);
             dword_50C9A8 -= pEventTimer->uTimeElapsed;
             if ( dword_50C9A8 <= 0 )
             {
@@ -1815,7 +1770,7 @@
               ptr_50C9A4 = 0;
             }
             v78 = (double)GetTickCount() * 0.1;
-            pRenderer->_4A63E6(pX_Belt, pY_Belt, (Texture *)(v75 != -1 ? (int)&pIcons_LOD->pTextures[v75] : 0), v77, (signed __int64)v78, 0, 255);
+            pRenderer->_4A63E6(pX_Belt, pY_Belt, pIcons_LOD->GetTexture(v75), v77, (signed __int64)v78, 0, 255);
           }
         }
       }
@@ -1827,7 +1782,7 @@
              || pItemsTable->pItems[v83].uSkillType == 4 && !pPlayers[uPlayerID]->pEquipment.uShield )
           pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0],
              pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1],
-             (Texture *)(papredoll_dlaus[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dlaus[uPlayerID - 1]] : 0));
+             pIcons_LOD->GetTexture(papredoll_dlaus[uPlayerID - 1]));
       }
       pCloakCollarNum = pPlayers[uPlayerID]->pEquipment.uCloak;//  
       if ( pCloakCollarNum )
@@ -1863,13 +1818,13 @@
             if ( !(item_CloakCollar->uAttributes & 0xF0) )
             {
               v119 = v116 + 1;
-              v120 = (char *)&pIcons_LOD->pTextures[v116];
+              v120 = (char *)pIcons_LOD->GetTexture(v116);
               if ( item_CloakCollar->uAttributes & 2 )
-                pRenderer->DrawTransparentRedShade(pX_CloakCollar, pY_CloakCollar, (Texture *)(v119 != 0 ? (int)v120 : 0));
+                pRenderer->DrawTransparentRedShade(pX_CloakCollar, pY_CloakCollar, (Texture *)v120);
               else
-                pRenderer->DrawTextureTransparent(pX_CloakCollar, pY_CloakCollar, (Texture *)(v119 != 0 ? (int)v120 : 0));
+                pRenderer->DrawTextureTransparent(pX_CloakCollar, pY_CloakCollar, (Texture *)v120);
               if ( !bRingsShownInCharScreen )
-                pRenderer->DrawMaskToZBuffer(pX_CloakCollar, pY_CloakCollar, (Texture *)(v119 != 0 ? (int)v120 : 0), pCloakCollarNum);
+                pRenderer->DrawMaskToZBuffer(pX_CloakCollar, pY_CloakCollar, (Texture *)v120, pCloakCollarNum);
             }
             else
             {
@@ -1881,7 +1836,7 @@
                 v179 = "sp30a";
               if ( (item_CloakCollar->uAttributes & 0xF0) == 128 )
                 v179 = "sp91a";
-              a2i = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v179, TEXTURE_16BIT_PALETTE)];
+              a2i = pIcons_LOD->LoadTexturePtr(v179, TEXTURE_16BIT_PALETTE);
               dword_50C9A8 -= pEventTimer->uTimeElapsed;
               if ( dword_50C9A8 <= 0 )
               {
@@ -1890,7 +1845,7 @@
                 ptr_50C9A4 = 0;
               }
               v118 = (double)GetTickCount() * 0.1;
-              pRenderer->_4A63E6(pX_CloakCollar, pY_CloakCollar, (Texture *)(v116 != -1 ? (int)&pIcons_LOD->pTextures[v116] : 0), a2i, (signed __int64)v118, 0, 255);
+              pRenderer->_4A63E6(pX_CloakCollar, pY_CloakCollar, pIcons_LOD->GetTexture(v116), a2i, (signed __int64)v118, 0, 255);
             }
           }
         }
@@ -1901,7 +1856,7 @@
         if ( v122 != pIcons_LOD->FindTextureByName("Pending") )
           pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_Beards[2 * pPlayers[uPlayerID]->uFace - 24],
                      pPaperdoll_BodyY + pPaperdoll_Beards[2 * pPlayers[uPlayerID]->uFace - 23],
-                     (Texture *)(v122 != -1 ? (int)&pIcons_LOD->pTextures[v122] : 0));
+                     pIcons_LOD->GetTexture(v122));
       }
     pHelmNum = pPlayers[uPlayerID]->pEquipment.uHelm;// 
     if ( pHelmNum )
@@ -1945,7 +1900,7 @@
             v180 = "sp30a";
           if ( (item_Helm->uAttributes & 0xF0) == 128 )
             v180 = "sp91a";
-          v129 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v180, TEXTURE_16BIT_PALETTE)];
+          v129 = pIcons_LOD->LoadTexturePtr(v180, TEXTURE_16BIT_PALETTE);
           dword_50C9A8 -= pEventTimer->uTimeElapsed;
           if ( dword_50C9A8 <= 0 )
           {
@@ -1954,24 +1909,24 @@
             ptr_50C9A4 = 0;
           }
           v130 = (double)GetTickCount() * 0.1;
-          pRenderer->_4A63E6(pX_Helm, pY_Helm, (Texture *)(v127 != -1 ? (int)&pIcons_LOD->pTextures[v127] : 0), v129, (signed __int64)v130, 0, 255);
+          pRenderer->_4A63E6(pX_Helm, pY_Helm, pIcons_LOD->GetTexture(v127), v129, (signed __int64)v130, 0, 255);
         }
         else
         {
           v131 = v127 + 1;
-          v132 = (char *)&pIcons_LOD->pTextures[v127];
+          v132 = (char *)pIcons_LOD->GetTexture(v127);
           if ( item_Helm->uAttributes & 2 )
-            pRenderer->DrawTransparentRedShade(pX_Helm, pY_Helm, (Texture *)(v131 != 0 ? (int)v132 : 0));
+            pRenderer->DrawTransparentRedShade(pX_Helm, pY_Helm, (Texture *)v132);
           else
           {
             if ( item_Helm->uAttributes & 1 )
-              pRenderer->DrawTextureTransparent(pX_Helm, pY_Helm, (Texture *)(v131 != 0 ? (int)v132 : 0));
+              pRenderer->DrawTextureTransparent(pX_Helm, pY_Helm, (Texture *)v132);
             else
-              pRenderer->DrawTransparentGreenShade(pX_Helm, pY_Helm, (Texture *)(v131 != 0 ? (int)v132 : 0));
+              pRenderer->DrawTransparentGreenShade(pX_Helm, pY_Helm, (Texture *)v132);
           }
         }
         if ( !bRingsShownInCharScreen )
-          pRenderer->DrawMaskToZBuffer(pX_Helm, pY_Helm, (Texture *)(v131 != 0 ? (int)v132 : 0), pHelmNum);
+          pRenderer->DrawMaskToZBuffer(pX_Helm, pY_Helm, (Texture *)v132, pHelmNum);
       }
     }
     pMainHandNum3 = pPlayers[uPlayerID]->pEquipment.uMainHand;//weapon in right hand
@@ -1988,15 +1943,15 @@
       if ( !(item_MainHand3->uAttributes & 0xF0) )
       {
         v142 = v138 + 1;
-        v143 = (char *)&pIcons_LOD->pTextures[v138];
+        v143 = (char *)pIcons_LOD->GetTexture(v138);
         if ( item_MainHand3->uAttributes & 2 )
-          pRenderer->DrawTransparentRedShade(pX_MainHand3, pY_MainHand3, (Texture *)(v142 != 0 ? (int)v143 : 0));
+          pRenderer->DrawTransparentRedShade(pX_MainHand3, pY_MainHand3, (Texture *)v143);
         else
         {
           if ( item_MainHand3->uAttributes & 1 )
-            pRenderer->DrawTextureTransparent(pX_MainHand3, pY_MainHand3, (Texture *)(v142 != 0 ? (int)v143 : 0));
+            pRenderer->DrawTextureTransparent(pX_MainHand3, pY_MainHand3, (Texture *)v143);
           else
-            pRenderer->DrawTransparentGreenShade(pX_MainHand3, pY_MainHand3, (Texture *)(v142 != 0 ? (int)v143 : 0));
+            pRenderer->DrawTransparentGreenShade(pX_MainHand3, pY_MainHand3, (Texture *)v143);
         }
       }
       else
@@ -2009,7 +1964,7 @@
            v182 = "sp30a";
         if ( (item_MainHand3->uAttributes & 0xF0) == 128 )
           v182 = "sp91a";
-        v140 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v182, TEXTURE_16BIT_PALETTE)];
+        v140 = pIcons_LOD->LoadTexturePtr(v182, TEXTURE_16BIT_PALETTE);
         dword_50C9A8 -= pEventTimer->uTimeElapsed;
         if ( dword_50C9A8 <= 0 )
         {
@@ -2018,10 +1973,10 @@
           ptr_50C9A4 = 0;
         }
         v141 = (double)GetTickCount() * 0.1;
-        pRenderer->_4A63E6(pX_MainHand3, pY_MainHand3, (Texture *)(v138 != -1 ? (int)&pIcons_LOD->pTextures[v138] : 0), v140, (signed __int64)v141, 0, 255);
+        pRenderer->_4A63E6(pX_MainHand3, pY_MainHand3, pIcons_LOD->GetTexture(v138), v140, (signed __int64)v141, 0, 255);
       }
       if ( !bRingsShownInCharScreen )
-        pRenderer->DrawMaskToZBuffer(pX_MainHand3, pY_MainHand3, (Texture *)(v142 != 0 ? (int)v143 : 0), pMainHandNum3);
+        pRenderer->DrawMaskToZBuffer(pX_MainHand3, pY_MainHand3, (Texture *)v143, pMainHandNum3);
     }
     pShieldNum = pPlayers[uPlayerID]->pEquipment.uShield;//  
     if ( pShieldNum )
@@ -2061,14 +2016,14 @@
       if ( !(item_Shield->uAttributes & 0xF0) )
       {
         if ( item_Shield->uAttributes & 2 )
-          pRenderer->DrawTransparentRedShade(pX_Shield, pY_Shield, (Texture *)(v153 != -1 ? (int)&pIcons_LOD->pTextures[v153] : 0));
+          pRenderer->DrawTransparentRedShade(pX_Shield, pY_Shield, pIcons_LOD->GetTexture(v153));
         else
         {
-          v160 = (char *)&pIcons_LOD->pTextures[v153];
+          v160 = (char *)pIcons_LOD->GetTexture(v153);
           if ( !(item_Shield->uAttributes & 1) )
-          pRenderer->DrawTransparentGreenShade(pX_Shield, pY_Shield, (Texture *)(v153 != -1 ? (int)v160 : 0));
+          pRenderer->DrawTransparentGreenShade(pX_Shield, pY_Shield, (Texture *)v160);
           else
-            pRenderer->DrawTextureTransparent(pX_Shield, pY_Shield, (Texture *)(v153 != -1 ? (int)v160 : 0));
+            pRenderer->DrawTextureTransparent(pX_Shield, pY_Shield, (Texture *)v160);
         }
       }
       else
@@ -2081,7 +2036,7 @@
           v183 = "sp30a";
         if ( (item_Shield->uAttributes & 0xF0) == 128 )
           v183 = "sp91a";
-        v157 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v183, TEXTURE_16BIT_PALETTE)];
+        v157 = pIcons_LOD->LoadTexturePtr(v183, TEXTURE_16BIT_PALETTE);
         dword_50C9A8 -= pEventTimer->uTimeElapsed;
         if ( dword_50C9A8 <= 0 )
         {
@@ -2090,29 +2045,26 @@
           ptr_50C9A4 = 0;
         }
         v158 = (double)GetTickCount() * 0.1;
-        pRenderer->_4A63E6(pX_Shield, pY_Shield, (Texture *)(v153 != -1 ? (int)&pIcons_LOD->pTextures[v153] : 0), v157, (signed __int64)v158, 0, 255);
+        pRenderer->_4A63E6(pX_Shield, pY_Shield, pIcons_LOD->GetTexture(v153), v157, (signed __int64)v158, 0, 255);
         if ( v245 )
           pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdollLeftEmptyHand[pBodyComplection][0],
-                 pPaperdoll_BodyY + pPaperdollLeftEmptyHand[pBodyComplection][1],
-                 (Texture *)(papredoll_dlhs[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dlhs[uPlayerID - 1]] : 0));
+                 pPaperdoll_BodyY + pPaperdollLeftEmptyHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlhs[uPlayerID - 1]));
       }
       if ( !bRingsShownInCharScreen )
-        pRenderer->DrawMaskToZBuffer(pX_Shield, pY_Shield, (Texture *)(v153 != -1 ? (int)&pIcons_LOD->pTextures[v153] : 0), pShieldNum);
+        pRenderer->DrawMaskToZBuffer(pX_Shield, pY_Shield, pIcons_LOD->GetTexture(v153), pShieldNum);
     }
   }
-  pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_RightHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_RightHand[pBodyComplection][1],
-             (Texture *)(papredoll_drhs[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_drhs[uPlayerID - 1]] : 0));
+  pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_RightHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_RightHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_drhs[uPlayerID - 1]));
   pMainHandNum5 = pPlayers[uPlayerID]->pEquipment.uMainHand;
   if ( pMainHandNum5 )
   {
     item_MainHand5 = &pPlayers[uPlayerID]->pInventoryItems[pMainHandNum5 - 1];
     if ( pItemsTable->pItems[item_MainHand5->uItemID].uEquipType == 1 || pItemsTable->pItems[item_MainHand5->uItemID].uSkillType == 4 && !pPlayers[uPlayerID]->pEquipment.uShield )
-      pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1],
-                 (Texture *)(papredoll_dlhus[uPlayerID - 1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dlhus[uPlayerID - 1]] : 0));
+      pRenderer->DrawTextureTransparent(pPaperdoll_BodyX + pPaperdoll_SecondLeftHand[pBodyComplection][0], pPaperdoll_BodyY + pPaperdoll_SecondLeftHand[pBodyComplection][1], pIcons_LOD->GetTexture(papredoll_dlhus[uPlayerID - 1]));
   }
   if ( !bRingsShownInCharScreen )// 
-    pRenderer->DrawTextureTransparent(603, 299, (Texture *)(uTextureID_MAGNIF_B != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_MAGNIF_B] : 0));
-  pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_right_panel_loop != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_right_panel_loop] : 0));//
+    pRenderer->DrawTextureTransparent(603, 299, pIcons_LOD->GetTexture(uTextureID_MAGNIF_B));
+  pRenderer->DrawTextureTransparent(468, 0, pIcons_LOD->GetTexture(uTextureID_right_panel_loop));//
 }
 
 //----- (0043E825) --------------------------------------------------------
@@ -2120,13 +2072,13 @@
 {
   int v3; // ecx@1
   unsigned int pItemTextureNum; // ebx@3
-  int v9; // edi@17
+  //int v9; // edi@17
   char v13; // sf@24
   unsigned __int8 v14; // of@24
   unsigned int pItemNum; // eax@25
-  int v20; // edi@40
-  int v21; // eax@41
-  int v33; // esi@61
+  //int v20; // edi@40
+  //int v21; // eax@41
+  //int v33; // esi@61
   const char *spell_texture_name; // [sp-8h] [bp-38h]@8
   Texture *spell_texture; // [sp+10h] [bp-20h]@14
   int v41; // [sp+10h] [bp-20h]@26
@@ -2137,10 +2089,9 @@
 
   pIcons_LOD->LoadTexture("sptext01", TEXTURE_16BIT_PALETTE);
   CharacterUI_DrawPaperdoll(uPlayerID);
-  pRenderer->DrawTextureTransparent(0x1D9u, 0, (Texture *)(uTextureID_BACKHAND != -1 ? &pIcons_LOD->pTextures[uTextureID_BACKHAND] : 0));
-  pRenderer->DrawTextureTransparent(0x1D4u, 0, (Texture *)(uTextureID_right_panel_loop != -1 ? &pIcons_LOD->pTextures[uTextureID_right_panel_loop] : 0));
-  pRenderer->DrawTextureIndexed(pCharacterScreen_DetalizBtn->uX, pCharacterScreen_DetalizBtn->uY,
-     (Texture *)(uTextureID_detaliz_close_button != -1 ? &pIcons_LOD->pTextures[uTextureID_detaliz_close_button] : 0));
+  pRenderer->DrawTextureTransparent(0x1D9u, 0, pIcons_LOD->GetTexture(uTextureID_BACKHAND));
+  pRenderer->DrawTextureTransparent(0x1D4u, 0, pIcons_LOD->GetTexture(uTextureID_right_panel_loop));
+  pRenderer->DrawTextureIndexed(pCharacterScreen_DetalizBtn->uX, pCharacterScreen_DetalizBtn->uY, pIcons_LOD->GetTexture(uTextureID_detaliz_close_button));
   v3 = 0;
   v48 = 0;
   do
@@ -2162,7 +2113,7 @@
           spell_texture_name = "sp30a";
         if ( (item->uAttributes & 0xF0) == 128 )
           spell_texture_name = "sp91a";
-        spell_texture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(spell_texture_name, TEXTURE_16BIT_PALETTE)];
+        spell_texture = pIcons_LOD->LoadTexturePtr(spell_texture_name, TEXTURE_16BIT_PALETTE);
         dword_50C9A8 -= pEventTimer->uTimeElapsed;
         if ( dword_50C9A8 <= 0 )
         {
@@ -2170,21 +2121,18 @@
           item->uAttributes &= 0xFu;
           ptr_50C9A4 = 0;
         }
-        pRenderer->_4A63E6(pX_Ring, pY_Ring, (Texture *)(pItemTextureNum != -1 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0), spell_texture, GetTickCount() * 0.1, 0, 255);
+        pRenderer->_4A63E6(pX_Ring, pY_Ring, pIcons_LOD->GetTexture(pItemTextureNum), spell_texture, GetTickCount() * 0.1, 0, 255);
       }
       else
       {
-        v9 = pItemTextureNum + 1;
-        if ( item->uAttributes & 2 )
-          pRenderer->DrawTransparentRedShade(pX_Ring, pY_Ring, (Texture *)(v9 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0));
+        if (item->Broken())
+          pRenderer->DrawTransparentRedShade(pX_Ring, pY_Ring, pIcons_LOD->GetTexture(pItemTextureNum));
+        else if (!item->Identified())
+          pRenderer->DrawTransparentGreenShade(pX_Ring, pY_Ring, pIcons_LOD->GetTexture(pItemTextureNum));
         else
-        {
-          if ( (item->uAttributes & 1) == 0 )
-            pRenderer->DrawTransparentGreenShade(pX_Ring, pY_Ring, (Texture *)(v9 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0));
-          else
-            pRenderer->DrawTextureTransparent(pX_Ring, pY_Ring, (Texture *)(v9 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0));
-        }
-        pRenderer->_4A601E(pX_Ring, pY_Ring, (Texture *)(v9 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0), pItemNum);
+          pRenderer->DrawTextureTransparent(pX_Ring, pY_Ring, pIcons_LOD->GetTexture(pItemTextureNum));
+
+        pRenderer->_4A601E(pX_Ring, pY_Ring, pIcons_LOD->GetTexture(pItemTextureNum), pItemNum);
       }
     }
     v3++;
@@ -2210,7 +2158,7 @@
         spell_texture_name = "sp30a";
       if ( (item->uAttributes & 0xF0) == 128 )
         spell_texture_name = "sp91a";
-      spell_texture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(spell_texture_name, TEXTURE_16BIT_PALETTE)];
+      spell_texture = pIcons_LOD->LoadTexturePtr(spell_texture_name, TEXTURE_16BIT_PALETTE);
       dword_50C9A8 -= pEventTimer->uTimeElapsed;
       if ( dword_50C9A8 <= 0 )
       {
@@ -2218,25 +2166,18 @@
         item->uAttributes &= 0xFu;
         ptr_50C9A4 = 0;
       }
-      pRenderer->_4A63E6(493, 91, (Texture *)(pItemTextureNum != -1 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0), spell_texture, GetTickCount() * 0.1, 0, 255);
+      pRenderer->_4A63E6(493, 91, pIcons_LOD->GetTexture(pItemTextureNum), spell_texture, GetTickCount() * 0.1, 0, 255);
     }
     else
     {
-      v20 = pItemTextureNum + 1;
-      if ( item->uAttributes & 2 )
-      {
-        v21 = 9 * pItemTextureNum;
-        pRenderer->DrawTransparentRedShade(493, 91, (Texture *)(v20 != 0 ? (int)&pIcons_LOD->pTextures[8 * v21 / 0x48u] : 0));
-      }
+      if (item->Broken())
+        pRenderer->DrawTransparentRedShade(493, 91, pIcons_LOD->GetTexture(pItemTextureNum));
+      else if (!item->Identified())
+        pRenderer->DrawTransparentGreenShade(493, 91, pIcons_LOD->GetTexture(pItemTextureNum));
       else
-      {
-        v21 = 9 * pItemTextureNum;
-        if ( !(item->uAttributes & 1) )
-          pRenderer->DrawTransparentGreenShade(493, 91, (Texture *)(v20 != 0 ? (int)&pIcons_LOD->pTextures[8 * v21 / 0x48u] : 0));
-        else
-          pRenderer->DrawTextureTransparent(493, 91, (Texture *)(v20 != 0 ? (int)&pIcons_LOD->pTextures[8 * v21 / 0x48u] : 0));
-      }
-      pRenderer->_4A601E(493, 91, (Texture *)(v20 != 0 ? (int)&pIcons_LOD->pTextures[8 * v21 / 0x48u] : 0), v41);
+        pRenderer->DrawTextureTransparent(493, 91, pIcons_LOD->GetTexture(pItemTextureNum));
+
+      pRenderer->_4A601E(493, 91, pIcons_LOD->GetTexture(pItemTextureNum), v41);
     }
   }
   pItemNum = pPlayers[uPlayerID]->pEquipment.uGlove;
@@ -2246,17 +2187,14 @@
   pItemTextureNum = pIcons_LOD->LoadTexture(pItemsTable->pItems[item->uItemID].pIconName, TEXTURE_16BIT_PALETTE);
   if ( !(item->uAttributes & 0xF0) )
   {
-    v33 = pItemTextureNum + 1;
-    if ( item->uAttributes & 2 )
-      pRenderer->DrawTransparentRedShade(586, 88, (Texture *)(v33 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0));
+    if (item->Broken())
+      pRenderer->DrawTransparentRedShade(586, 88, pIcons_LOD->GetTexture(pItemTextureNum));
+    else if (!item->Identified())
+      pRenderer->DrawTransparentGreenShade(586, 88, pIcons_LOD->GetTexture(pItemTextureNum));
     else
-    {
-      if ( !(item->uAttributes & 1) )
-        pRenderer->DrawTransparentGreenShade(586, 88, (Texture *)(v33 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0));
-      else
-        pRenderer->DrawTextureTransparent(586, 88, (Texture *)(v33 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0));
-    }
-    pRenderer->_4A601E(586, 88, (Texture *)(v33 != 0 ? (int)&pIcons_LOD->pTextures[pItemTextureNum] : 0), pItemNum);
+      pRenderer->DrawTextureTransparent(586, 88, pIcons_LOD->GetTexture(pItemTextureNum));
+
+    pRenderer->_4A601E(586, 88,pIcons_LOD->GetTexture(pItemTextureNum), pItemNum);
   }
   else
   {
@@ -2268,7 +2206,7 @@
       spell_texture_name = "sp30a";
     if ( (item->uAttributes & 0xF0) == 128 )
       spell_texture_name = "sp91a";
-    spell_texture = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(spell_texture_name, TEXTURE_16BIT_PALETTE)];
+    spell_texture = pIcons_LOD->LoadTexturePtr(spell_texture_name, TEXTURE_16BIT_PALETTE);
     dword_50C9A8 -= pEventTimer->uTimeElapsed;
     if ( dword_50C9A8 <= 0 )
     {
@@ -2654,129 +2592,70 @@
                         pGUIWindow_CurrentMenu->_41D08F(a2, 1, 0, a5);
     }
 
-    //----- (00418511) --------------------------------------------------------
-    char __fastcall CharacterUI_StatsTab_Draw(unsigned int uPlayerID)
-        {
+//----- (00418511) --------------------------------------------------------
+char __fastcall CharacterUI_StatsTab_Draw(unsigned int uPlayerID)
+{
         Player *pPlayer; // edi@1
-        unsigned int v2; // eax@1
-        unsigned int v3; // eax@1
         unsigned int v4; // eax@2
-        int v5; // ST20_4@4
-        int v6; // ST1C_4@4
         int v7; // ebp@4
         int v8; // eax@4
         unsigned int v9; // eax@4
         int v10; // ST34_4@4
-        int v11; // ST20_4@4
-        int v12; // ST1C_4@4
         int v13; // ebp@4
         int v14; // eax@4
         unsigned int v15; // eax@4
-        int v16; // ST34_4@4
-        int v17; // ST20_4@4
-        int v18; // ST1C_4@4
         int v19; // ebp@4
         int v20; // eax@4
         unsigned int v21; // eax@4
-        int v22; // ST34_4@4
-        int v23; // ST20_4@4
-        int v24; // ST1C_4@4
         int v25; // ebp@4
         int v26; // eax@4
         unsigned int v27; // eax@4
-        int v28; // ST34_4@4
-        int v29; // ST20_4@4
-        int v30; // ST1C_4@4
         int v31; // ebp@4
         int v32; // eax@4
         unsigned int v33; // eax@4
-        int v34; // ST34_4@4
-        int v35; // ST20_4@4
-        int v36; // ST1C_4@4
         int v37; // ebp@4
         int v38; // eax@4
         unsigned int v39; // eax@4
-        int v40; // ST34_4@4
-        int v41; // ST20_4@4
-        int v42; // ST1C_4@4
         int v43; // ebp@4
         int v44; // eax@4
         unsigned int v45; // eax@4
-        int v46; // ebp@4
-        signed int v47; // ST20_4@6
-        int v48; // ST1C_4@6
         signed int v49; // eax@6
         unsigned int v50; // eax@6
-        int v51; // ST20_4@8
-        int v52; // ST1C_4@8
         int v53; // eax@8
         unsigned int v54; // eax@8
-        int v55; // ST34_4@8
-        int v56; // ST20_4@8
-        int v57; // ST1C_4@8
         int v58; // ebp@8
         int v59; // eax@8
         unsigned int v60; // eax@8
-        unsigned int v61; // ebp@8
         unsigned int v62; // eax@8
-        char *v63; // ST20_4@8
         signed int v64; // eax@8
-        unsigned int v65; // ebp@8
         unsigned __int8 v66; // al@8
         char *v67; // eax@9
-        unsigned int v68; // ST20_4@11
-        unsigned int v69; // ST1C_4@11
         signed int v70; // ebp@11
         signed int v71; // eax@11
         unsigned int v72; // eax@11
-        int v73; // ST20_4@13
-        int v74; // ST1C_4@13
         int v75; // ebp@13
         int v76; // eax@13
         unsigned int v77; // eax@13
         char *v78; // ecx@14
-        int v79; // ST20_4@16
-        char *v80; // ST40_4@16
         unsigned int v81; // eax@16
-        int v82; // ST34_4@16
         int v83; // eax@16
-        int v84; // ST34_4@16
         char *v85; // eax@16
-        int v86; // ST34_4@16
         int v87; // eax@16
-        int v88; // ST34_4@16
         char *v89; // eax@16
         int v90; // eax@16
-        int v91; // ST20_4@19
         unsigned int v92; // eax@19
         int v93; // eax@19
-        int v94; // ST20_4@22
         unsigned int v95; // eax@22
         int v96; // eax@22
-        int v97; // ST20_4@25
         unsigned int v98; // eax@25
         int v99; // eax@25
-        int v100; // ST20_4@27
         unsigned int v101; // eax@27
         int v102; // eax@27
-        int v103; // ST20_4@30
         unsigned int v104; // eax@30
-        char *v105; // ST20_4@32
         unsigned int v106; // eax@32
         int v107; // eax@33
-        int v108; // ST20_4@36
         unsigned int v109; // eax@36
-        char *v110; // ST20_4@38
         unsigned int v111; // eax@38
-        int uY; // [sp+10h] [bp-10h]@6
-        int uYa; // [sp+10h] [bp-10h]@11
-        int uYb; // [sp+10h] [bp-10h]@13
-        int uYc; // [sp+10h] [bp-10h]@16
-        int uYd; // [sp+10h] [bp-10h]@19
-        int uYe; // [sp+10h] [bp-10h]@22
-        int uYf; // [sp+10h] [bp-10h]@25
-        int uYg; // [sp+10h] [bp-10h]@27
-        int uYh; // [sp+10h] [bp-10h]@33
         const char *a2; // [sp+14h] [bp-Ch]@4
         const char *a2a; // [sp+14h] [bp-Ch]@6
         const char *a2b; // [sp+14h] [bp-Ch]@11
@@ -2792,275 +2671,262 @@
         int v134; // [sp+18h] [bp-8h]@25
         int v135; // [sp+18h] [bp-8h]@27
         int v136; // [sp+18h] [bp-8h]@33
-        int v137; // [sp+1Ch] [bp-4h]@27
-        int v138; // [sp+1Ch] [bp-4h]@33
 
         pPlayer = &pParty->pPlayers[uPlayerID-1];
-        v2 = pIcons_LOD->LoadTexture("fr_stats", TEXTURE_16BIT_PALETTE);
-        pRenderer->DrawTextureIndexed(8, 8, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
-        v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
-        sprintf(pTmpBuf, "\f%05d", v3);
+        pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->LoadTexturePtr("fr_stats", TEXTURE_16BIT_PALETTE));
+        sprintf(pTmpBuf, "\f%05d", TargetColor(0xFF, 0xFF, 0x9B));
         sprintfex(pTmpBuf2, pGlobalTXT_LocalizationStrings[429], pPlayer->pName, pClassNames[pPlayer->classType]);//^Pi[%s] %s
         strcat(pTmpBuf, pTmpBuf2);
         if ( pPlayer->uSkillPoints )
-            v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
+            v4 = TargetColor(0, 0xFFu, 0);
         else
             v4 = 0xFFFFu;
         sprintf(pTmpBuf2,  "\f00000\r180%s: \f%05d%d\f00000\n\n\n", pGlobalTXT_LocalizationStrings[207], v4, pPlayer->uSkillPoints);//Skill points
         strcat(pTmpBuf, pTmpBuf2);
         pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 18, 0, pTmpBuf, 0, 0, 0);
-        v5 = pPlayer->GetBaseStrength();
-        v6 = pPlayer->GetActualMight();
+
+        v10 = 53;
         v7 = pPlayer->GetBaseStrength();
         v8 = pPlayer->GetActualMight();
         v9 = UI_GetHealthManaStringColor(v8, v7);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[144], v9, v6, v5);//Might
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, 53, 0, pTmpBuf, 0, 0, 0);
-        v10 = LOBYTE(pFontArrus->uFontHeight) + 51;
-        v11 = pPlayer->GetBaseIntelligence();
-        v12 = pPlayer->GetActualIntelligence();
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[144], v9, v8, v7);//Might
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v13 = pPlayer->GetBaseIntelligence();
         v14 = pPlayer->GetActualIntelligence();
         v15 = UI_GetHealthManaStringColor(v14, v13);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[116], v15, v12, v11);//Intellect
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[116], v15, v14, v13);//Intellect
         pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
-        v16 = LOBYTE(pFontArrus->uFontHeight) + v10 - 2;
-        v17 = pPlayer->GetBaseWillpower();
-        v18 = pPlayer->GetActualWillpower();
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v19 = pPlayer->GetBaseWillpower();
         v20 = pPlayer->GetActualWillpower();
         v21 = UI_GetHealthManaStringColor(v20, v19);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[163], v21, v18, v17);//
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v16, 0, pTmpBuf, 0, 0, 0);
-        v22 = LOBYTE(pFontArrus->uFontHeight) + v16 - 2;
-        v23 = pPlayer->GetBaseEndurance();
-        v24 = pPlayer->GetActualEndurance();
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[163], v21, v20, v19);//
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v25 = pPlayer->GetBaseEndurance();
         v26 = pPlayer->GetActualEndurance();
         v27 = UI_GetHealthManaStringColor(v26, v25);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[75], v27, v24, v23);//
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v22, 0, pTmpBuf, 0, 0, 0);
-        v28 = LOBYTE(pFontArrus->uFontHeight) + v22 - 2;
-        v29 = pPlayer->GetBaseAccuracy();
-        v30 = pPlayer->GetActualAccuracy();
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[75], v27, v26, v25);//
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v31 = pPlayer->GetBaseAccuracy();
         v32 = pPlayer->GetActualAccuracy();
         v33 = UI_GetHealthManaStringColor(v32, v31);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[1], v33, v30, v29);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v28, 0, pTmpBuf, 0, 0, 0);
-        v34 = LOBYTE(pFontArrus->uFontHeight) + v28 - 2;
-        v35 = pPlayer->GetBaseSpeed();
-        v36 = pPlayer->GetActualSpeed();
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[1], v33, v32, v31);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v37 = pPlayer->GetBaseSpeed();
         v38 = pPlayer->GetActualSpeed();
         v39 = UI_GetHealthManaStringColor(v38, v37);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[211], v39, v36, v35);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v34, 0, pTmpBuf, 0, 0, 0);
-        v40 = LOBYTE(pFontArrus->uFontHeight) + v34 - 2;
-        v41 = pPlayer->GetBaseLuck();
-        v42 = pPlayer->GetActualLuck();
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n", pGlobalTXT_LocalizationStrings[211], v39, v38, v37);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v43 = pPlayer->GetBaseLuck();
         v44 = pPlayer->GetActualLuck();
         v45 = UI_GetHealthManaStringColor(v44, v43);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n\n", pGlobalTXT_LocalizationStrings[136], v45, v42, v41);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v40, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n\n", pGlobalTXT_LocalizationStrings[136], v45, v44, v43);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2 = "%s\f%05u\r424%d\f00000 /\t185%d\n";
-        v46 = v40 + 2 * LOBYTE(pFontArrus->uFontHeight) + 5;
+        v10 += 2 * LOBYTE(pFontArrus->uFontHeight) + 5;
         if ( pPlayer->GetMaxHealth() >= 1000 )
             a2 = "%s\f%05u\r388%d\f00000 / %d\n";
-        v47 = pPlayer->GetMaxHealth();
-        v48 = pPlayer->sHealth;
         v49 = pPlayer->GetMaxHealth();
         v50 = UI_GetHealthManaStringColor(pPlayer->sHealth, v49);
-        sprintf(pTmpBuf, a2, pGlobalTXT_LocalizationStrings[108], v50, v48, v47);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v46, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, a2, pGlobalTXT_LocalizationStrings[108], v50, pPlayer->sHealth, v49);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2a = "%s\f%05u\r424%d\f00000 /\t185%d\n";
-        uY = LOBYTE(pFontArrus->uFontHeight) + v46 - 2;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         if ( pPlayer->GetMaxMana() >= 1000 )
             a2a = "%s\f%05u\r388%d\f00000 / %d\n";
-        v51 = pPlayer->GetMaxMana();
-        v52 = pPlayer->sMana;
         v53 = pPlayer->GetMaxMana();
         v54 = UI_GetHealthManaStringColor(pPlayer->sMana, v53);
-        sprintf(pTmpBuf, a2a, pGlobalTXT_LocalizationStrings[212], v54, v52, v51);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, uY, 0, pTmpBuf, 0, 0, 0);
-        v55 = LOBYTE(pFontArrus->uFontHeight) + uY - 2;
-        v56 = pPlayer->GetBaseAC();
-        v57 = pPlayer->GetActualAC();
+        sprintf(pTmpBuf, a2a, pGlobalTXT_LocalizationStrings[212], v54, pPlayer->sMana, v53);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v58 = pPlayer->GetBaseAC();
         v59 = pPlayer->GetActualAC();
         v60 = UI_GetHealthManaStringColor(v59, v58);
-        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n\n", pGlobalTXT_LocalizationStrings[12], v60, v57, v56);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v55, 0, pTmpBuf, 0, 0, 0);
-        v61 = v55 + 2 * LOBYTE(pFontArrus->uFontHeight) - 2;
+        sprintf(pTmpBuf, "%s\f%05u\r424%d\f00000 /\t185%d\n\n", pGlobalTXT_LocalizationStrings[12], v60, v59, v58);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 26, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += 2 * LOBYTE(pFontArrus->uFontHeight) - 2;
         v62 = pPlayer->GetMajorConditionIdx();
-        v63 = aCharacterConditionNames[v62];
         v64 = GetConditionDrawColor(v62);
-        sprintf(pTmpBuf, "%s: \f%05d%s\n", pGlobalTXT_LocalizationStrings[47], v64, v63);
-        pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v61, 0, pTmpBuf, 226, 0);
-        v65 = LOBYTE(pFontArrus->uFontHeight) + v61 - 1;
+        sprintf(pTmpBuf, "%s: \f%05d%s\n", pGlobalTXT_LocalizationStrings[47], v64, aCharacterConditionNames[v62]);
+        pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v10, 0, pTmpBuf, 226, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) + - 1;
         v66 = pPlayer->uQuickSpell;
         if ( v66 )
             v67 = pSpellStats->pInfos[v66].pShortName;
         else
             v67 = pGlobalTXT_LocalizationStrings[153];
         sprintf(pTmpBuf, "%s: %s", pGlobalTXT_LocalizationStrings[172], v67);
-        pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v65, 0, pTmpBuf, 226, 0);
-        v68 = pPlayer->GetBaseAge();
-        v69 = pPlayer->GetActualAge();
+        pGUIWindow_CurrentMenu->DrawTextInRect(pFontArrus, 0x1Au, v10, 0, pTmpBuf, 226, 0);
+
+        v10 = 50;
         v70 = pPlayer->GetBaseAge();
         v71 = pPlayer->GetActualAge();
         v72 = UI_GetHealthManaStringColor(v71, v70);
-        sprintf(pTmpBuf, "%s\f%05u\t100%d\f00000 / %d\n", pGlobalTXT_LocalizationStrings[5], v72, v69, v68);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, 50, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, "%s\f%05u\t100%d\f00000 / %d\n", pGlobalTXT_LocalizationStrings[5], v72, v71, v70);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2b = "%s\f%05u\t100%d\f00000 / %d\n";
-        uYa = LOBYTE(pFontArrus->uFontHeight) + 48;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         if ( pPlayer->GetBaseLevel() > 99 )
             a2b = format_4E2E68;
-        v73 = pPlayer->GetBaseLevel();
-        v74 = pPlayer->GetActualLevel();
         v75 = pPlayer->GetBaseLevel();
         v76 = pPlayer->GetActualLevel();
         v77 = UI_GetHealthManaStringColor(v76, v75);
-        sprintf(pTmpBuf, a2b, pGlobalTXT_LocalizationStrings[131], v77, v74, v73);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYa, 0, pTmpBuf, 0, 0, 0);
-        uYb = uYa + LOBYTE(pFontArrus->uFontHeight) - 2;
+        sprintf(pTmpBuf, a2b, pGlobalTXT_LocalizationStrings[131], v77, v76, v75);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         if ( (signed __int64)pPlayer->uExperience <= 9999999 )
             v78 = pGlobalTXT_LocalizationStrings[83];
         else
             v78 = pGlobalTXT_LocalizationStrings[17];
-        v79 = LODWORD(pPlayer->uExperience);
-        v80 = v78;
         v81 = pPlayer->GetExperienceDisplayColor();
-        sprintf(pTmpBuf, "%s\r180\f%05d%lu\f00000\n\n", v80, v81, v79);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYb, 0, pTmpBuf, 0, 0, 0);
-        v82 = uYb + 2 * LOBYTE(pFontArrus->uFontHeight);
+        sprintf(pTmpBuf, "%s\r180\f%05d%lu\f00000\n\n", v78, v81, LODWORD(pPlayer->uExperience));
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += 2 * LOBYTE(pFontArrus->uFontHeight);
         v83 = pPlayer->GetActualAttack(0);
         sprintf(pTmpBuf, "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[18], v83);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v82, 0, pTmpBuf, 0, 0, 0);
-        v84 = v82 + LOBYTE(pFontArrus->uFontHeight) - 2;
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v85 = pPlayer->GetMeleeDamageString();
         sprintf(pTmpBuf, "%s\t100 %s\n", pGlobalTXT_LocalizationStrings[53], v85);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v84, 0, pTmpBuf, 0, 0, 0);
-        v86 = v84 + LOBYTE(pFontArrus->uFontHeight) - 2;
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v87 = pPlayer->GetRangedAttack();
         sprintf(pTmpBuf, "%s\t100%+d\n", pGlobalTXT_LocalizationStrings[203], v87);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v86, 0, pTmpBuf, 0, 0, 0);
-        v88 = v86 + LOBYTE(pFontArrus->uFontHeight) - 2;
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v89 = pPlayer->GetRangedDamageString();
         sprintf(pTmpBuf, "%s\t100 %s\n\n", pGlobalTXT_LocalizationStrings[53], v89);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v88, 0, pTmpBuf, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2c = format_4E2E10;
-        uYc = v88 + 2 * LOBYTE(pFontArrus->uFontHeight) - 4;
+        v10 += 2 * LOBYTE(pFontArrus->uFontHeight) - 4;
         v131 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE);
         v90 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_FIRE);
         if ( v131 > 99 || v90 > 99 )
             a2c = format_4E2E68;
-        v91 = v90;
         v92 = UI_GetHealthManaStringColor(v131, v90);
-        sprintf(pTmpBuf, a2c, pGlobalTXT_LocalizationStrings[87], v92, v131, v91);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYc, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, a2c, pGlobalTXT_LocalizationStrings[87], v92, v131, v90);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2d = format_4E2E10;
-        uYd = uYc + LOBYTE(pFontArrus->uFontHeight) - 2;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v132 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_AIR);
         v93 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_AIR);
         if ( v132 > 99 || v93 > 99 )
             a2d = format_4E2E68;
-        v94 = v93;
         v95 = UI_GetHealthManaStringColor(v132, v93);
-        sprintf(pTmpBuf, a2d, pGlobalTXT_LocalizationStrings[6], v95, v132, v94);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYd, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, a2d, pGlobalTXT_LocalizationStrings[6], v95, v132, v93);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2e = format_4E2E10;
-        uYe = uYd + LOBYTE(pFontArrus->uFontHeight) - 2;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v133 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_WATER);
         v96 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_WATER);
         if ( v133 > 99 || v96 > 99 )
             a2e = format_4E2E68;
-        v97 = v96;
         v98 = UI_GetHealthManaStringColor(v133, v96);
-        sprintf(pTmpBuf, a2e, pGlobalTXT_LocalizationStrings[240], v98, v133, v97);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYe, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, a2e, pGlobalTXT_LocalizationStrings[240], v98, v133, v96);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2f = format_4E2E10;
-        uYf = uYe + LOBYTE(pFontArrus->uFontHeight) - 2;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v134 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH);
         v99 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_EARTH);
         if ( v134 > 99 )
             a2f = format_4E2E68;
-        v100 = v99;
         v101 = UI_GetHealthManaStringColor(v134, v99);
-        sprintf(pTmpBuf, a2f, pGlobalTXT_LocalizationStrings[70], v101, v134, v100);
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYf, 0, pTmpBuf, 0, 0, 0);
+        sprintf(pTmpBuf, a2f, pGlobalTXT_LocalizationStrings[70], v101, v134, v99);
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2g = format_4E2E10;
-        uYg = uYf + LOBYTE(pFontArrus->uFontHeight) - 2;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v135 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_MIND);
         v102 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_MIND);
-        v137 = v102;
         if ( v135 > 99 || v102 > 99 )
             a2g = format_4E2E68;
-        v103 = v102;
         v104 = UI_GetHealthManaStringColor(v135, v102);
-        sprintf(pTmpBuf, a2g, pGlobalTXT_LocalizationStrings[142], v104, v135, v103);
-        if ( pPlayer->classType == PLAYER_CLASS_LICH && v137 == 200 )
-            {
-            v105 = pGlobalTXT_LocalizationStrings[625];
+        sprintf(pTmpBuf, a2g, pGlobalTXT_LocalizationStrings[142], v104, v135, v102);
+        if ( pPlayer->classType == PLAYER_CLASS_LICH && v102 == 200 )
+        {
             v106 = UI_GetHealthManaStringColor(v135, 200);
-            sprintf(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[142], v106, v105);
-            }
-        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYg, 0, pTmpBuf, 0, 0, 0);
+            sprintf(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[142], v106, pGlobalTXT_LocalizationStrings[625]);
+        }
+        pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+
         a2h = format_4E2E10;
-        uYh = uYg + LOBYTE(pFontArrus->uFontHeight) - 2;
+        v10 += LOBYTE(pFontArrus->uFontHeight) - 2;
         v136 = pPlayer->GetActualResistance(CHARACTER_ATTRIBUTE_RESIST_BODY);
         v107 = pPlayer->GetBaseResistance(CHARACTER_ATTRIBUTE_RESIST_BODY);
-        v138 = v107;
         if ( v136 > 99 || v107 > 99 )
             a2h = format_4E2E68;
-        v108 = v107;
         v109 = UI_GetHealthManaStringColor(v136, v107);
-        sprintf(pTmpBuf, a2h, pGlobalTXT_LocalizationStrings[29], v109, v136, v108);
-        if ( pPlayer->classType == PLAYER_CLASS_LICH && v138 == 200 )
-            {
-            v110 = pGlobalTXT_LocalizationStrings[625];
+        sprintf(pTmpBuf, a2h, pGlobalTXT_LocalizationStrings[29], v109, v136, v107);
+        if ( pPlayer->classType == PLAYER_CLASS_LICH && v107 == 200 )
+        {
             v111 = UI_GetHealthManaStringColor(v136, 200);
-            sprintf(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[29], v111, v110);
-            }
-        return pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, uYh, 0, pTmpBuf, 0, 0, 0);
+            sprintf(pTmpBuf, format_4E2E00, pGlobalTXT_LocalizationStrings[29], v111, pGlobalTXT_LocalizationStrings[625]);
         }
+        return pGUIWindow_CurrentMenu->DrawText(pFontArrus, 266, v10, 0, pTmpBuf, 0, 0, 0);
+}
 
-    //----- (00419100) --------------------------------------------------------
-    void FillAwardsData()
-        {
-        Player *pPlayer; // esi@1
+//----- (00419100) --------------------------------------------------------
+void FillAwardsData()
+{
+        auto pPlayer = pPlayers[uActiveCharacter];
 
-        pPlayer = pPlayers[uActiveCharacter];
-        memset(&achievedAwardsIndex, 0, 4000);
+        memset(achieved_awards, 0, 4000);
+        num_achieved_awards = 0;
+
         memset(pTmpBuf2, 0, 0x7D0u);
         dword_506544 = 0;
         dword_506548 = 0;
-        awards_count = 0;
         dword_50651C = 0;
         dword_506528 = 0;
-        for(int i=0; i<105; ++i)
-            {
-            if ( _449B57_test_bit((unsigned char*)&pPlayer->_guilds_member_bits, i) && pAwards[i].pText )
-                achievedAwardsIndex[awards_count++] = i;
-            }
-        awards_count2 = awards_count;
-        awards_count = 0;
+        for (int i = 0; i < 105; ++i)
+        {
+            if ( _449B57_test_bit(pPlayer->_guilds_member_bits, i) && pAwards[i].pText )
+                achieved_awards[num_achieved_awards++] = (AwardType)i;
+        }
+        num_achieved_awards_2 = num_achieved_awards;
+        num_achieved_awards = 0;
+
         //sort awards index 
-        if ( awards_count2>0 )
-            {
-            for(int i=0; i<awards_count2; ++i)
-                achievedAwardsIndex[awards_count2 + i] = rand() % 16;
+        if (num_achieved_awards_2 > 0)
+        {
+            for(int i=0; i<num_achieved_awards_2; ++i)
+                achieved_awards[num_achieved_awards_2 + i] = (AwardType)(rand() % 16);
 
-            for(int i=1; i<awards_count2-1; ++i)
+            for(int i=1; i<num_achieved_awards_2-1; ++i)
                 {
-                for (int j = i; j < awards_count2-1; ++j )
+                for (int j = i; j < num_achieved_awards_2-1; ++j )
                     {
-                    int tmp=achievedAwardsIndex[j];
-                    if(pAwards[j].uSort < pAwards[i].uSort)
+                    auto tmp=achieved_awards[j];
+                    if (pAwards[j].uPriority < pAwards[i].uPriority)
                         {
-                        achievedAwardsIndex[j] = achievedAwardsIndex[i];
-                        achievedAwardsIndex[i] = tmp;
+                        achieved_awards[j] = achieved_awards[i];
+                        achieved_awards[i] = tmp;
                         }
                     }
                 }
--- a/UIHouses.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/UIHouses.cpp	Wed May 01 23:36:54 2013 +0600
@@ -621,7 +621,7 @@
   v5.uFrameX = 483;
   v5.uFrameWidth = 148;
   v5.uFrameZ = 334;
-  v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v2 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   v3 = pFontArrus->CalcTextHeight(v0, &v5, 0, 0);
   v5.DrawTitleText(pFontArrus, 0, (310 - v3) / 2 + 18, v2, v1, 3u);
 }
@@ -1733,8 +1733,8 @@
   v53.uFrameX = 483;
   v53.uFrameWidth = 148;
   v53.uFrameZ = 334;
-  auto color_default = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255);
-  auto color_selected = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 155);
+  auto color_default = TargetColor(255, 255, 255);
+  auto color_selected = TargetColor(255, 255, 155);
   v3 = 52 * (unsigned int)v0->ptr_1C;
   //v59 = (GUIWindow *)((((p2DEvents_minus1___00[v3 / 2] != 27) - 1) & 0xFFFFFFE7) + 50);
   //v59 = (GUIWindow *)((((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != BildingType_Stables) - 1) & 0xFFFFFFE7) + 50);
@@ -2031,8 +2031,8 @@
   _this.uFrameX = 483;
   _this.uFrameWidth = 148;
   _this.uFrameZ = 334;
-  v28 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v28 = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  v30 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[605], pParty->uFine);
   _this.DrawTitleText(pFontArrus, 0, 0x104u, v30, pTmpBuf, 3u);
   switch(dialog_menu_id)
@@ -2092,9 +2092,9 @@
 	case HOUSE_DIALOGUE_TOWNHALL_99:
 		{
 		v5 = &pMonsterStats->pInfos[word_F8B1A0];
-		v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+		v6 = TargetColor(0xFFu, 0xFFu, 0xFFu);
 		v7 = v5->pName;
-		v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+		v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
 		sprintf(pTmpBuf, &byte_4F0F98, v8, v7, v6);
 		sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * v5->uLevel);
 		current_npc_text = pTmpBuf2;
@@ -2109,8 +2109,8 @@
 			v9 = pFontCreate->CalcTextHeight(current_npc_text, &w, 13, 0) + 7;
 		}
 
-		auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
-		pRenderer->_4A6A68(8u, 352 - v9, pTex, (pTex ? pTex->uTextureHeight : 26) - v9);
+		auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather);
+		pRenderer->_4A6A68(8u, 352 - v9, pTex, pTex->uTextureHeight - v9);
 		pRenderer->DrawTextureIndexed(8u, 347 - v9, pTexture_591428);
 		v10 = FitTextInAWindow(current_npc_text, pOutString, &w, 0xDu, 0);
 		a1.DrawText(pOutString, 13, 354 - v9, 0, v10, 0, 0, 0);
@@ -2201,8 +2201,8 @@
   _this.uFrameX = 483;
   _this.uFrameWidth = 148;
   _this.uFrameZ = 334;
-  *(int *)v13 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  *(int *)v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  *(int *)v13 = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  *(int *)v14 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, "%s: %d", pGlobalTXT_LocalizationStrings[25], pParty->uNumGoldInBank);
   _this.DrawTitleText(pFontArrus, 0, 0xDCu, v14[0], pTmpBuf, 3u);
   switch(dialog_menu_id)
@@ -2429,8 +2429,8 @@
   dialog_window.uFrameX = 483;
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
-  pColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  pColorYellow = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   v2 = p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier;
   *(float *)&v83 = v2;
   *(float *)&v89 = v2 * v2;
@@ -2550,8 +2550,8 @@
         pOutString = pFontCreate;
         pTextHeight = pFontCreate->CalcTextHeight(pTmpBuf, &dialog_window, 12, 0) + 7;
       }
-      auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : 0);
-      pRenderer->_4A6A68(8, 352 - pTextHeight, pTex, (pTex ? pTex->uTextureHeight : 26) - pTextHeight);
+      auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather);
+      pRenderer->_4A6A68(8, 352 - pTextHeight, pTex, pTex->uTextureHeight - pTextHeight);
       pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428);
       v63 = FitTextInAWindow(pTmpBuf, pOutString, &dialog_window, 0xCu, 0);
       window_SpeakInHouse->DrawText(pOutString, 12, 354 - pTextHeight, 0, v63, 0, 0, 0);
@@ -2564,8 +2564,8 @@
       dialog_window.uFrameZ = 452;
       v61 = pFontArrus->CalcTextHeight(pTmpBuf, &dialog_window, 12, 0);
       pTextHeight = v61 + 7;
-      auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
-      pRenderer->_4A6A68(8, 352 - (v61 + 7), pTex, (pTex ? pTex->uTextureHeight : 26) - (v61 + 7));
+      auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather);
+      pRenderer->_4A6A68(8, 352 - (v61 + 7), pTex, pTex->uTextureHeight - (v61 + 7));
       pRenderer->DrawTextureIndexed(8, 347 - pTextHeight, pTexture_591428);
       v63 = FitTextInAWindow(pTmpBuf, pFontArrus, &dialog_window, 0xCu, 0);
       window_SpeakInHouse->DrawText(pFontArrus, 12, 354 - pTextHeight, 0, v63, 0, 0, 0);
@@ -2878,8 +2878,8 @@
   dialog_window.uFrameX = 483;
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
-  pColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  pColorYellow = TargetColor(0xE1u, 0xCDu, 0x23u);
 
   switch(dialog_menu_id)
   {
@@ -3409,8 +3409,8 @@
   dialog_window.uFrameX = 483;
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
-  pColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  pColorYellow = TargetColor(0xE1u, 0xCDu, 0x23u);
   switch(dialog_menu_id)
   {
     case HOUSE_DIALOGUE_MAIN:
@@ -3998,8 +3998,8 @@
   dialog_window.uFrameX = 483;
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
-  pWhiteColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pYellowColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  pWhiteColor = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  pYellowColor = TargetColor(0xE1u, 0xCDu, 0x23u);
   switch (dialog_menu_id)
   {
     case HOUSE_DIALOGUE_MAIN:
@@ -4496,8 +4496,8 @@
   working_window.uFrameX = 483;
   working_window.uFrameWidth = 148;
   working_window.uFrameZ = 334;
-  pColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  pColorYellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  pColorWhite = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  pColorYellow = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   base_teach_price = (signed __int64)(p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].fPriceMultiplier * 500.0);
   v63 = base_teach_price * (100 - pPlayers[uActiveCharacter]->GetMerchant()) / 100;
   if ( v63 < base_teach_price / 3 )
@@ -4799,8 +4799,8 @@
     v57.uFrameX = 483;
     v57.uFrameWidth = 148;
     v57.uFrameZ = 334;
-    HIDWORD(v58) = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-    HIDWORD(v59) = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+    HIDWORD(v58) = TargetColor(0xFFu, 0xFFu, 0xFFu);
+    HIDWORD(v59) = TargetColor(0xFFu, 0xFFu, 0x9Bu);
     v1 = pPlayers[uActiveCharacter];
     //v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents_minus1__20[13 * (unsigned int)v0->ptr_1C]);
     v2 = pPlayers[uActiveCharacter]->_4B807C(p2DEvents[(unsigned int)v0->ptr_1C - 1].fPriceMultiplier);
@@ -5190,8 +5190,8 @@
   v65.uFrameX = 483;
   v65.uFrameWidth = 148;
   v65.uFrameZ = 334;
-  white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255);
-  color2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  white = TargetColor(255, 255, 255);
+  color2 = TargetColor(0xE1u, 0xCDu, 0x23u);
   //v71 = color2;
   //v2 = v0->uLevel;
   //v3 = 0;
@@ -5600,8 +5600,8 @@
   dialog_window.uFrameX = 483;
   dialog_window.uFrameWidth = 148;
   dialog_window.uFrameZ = 334;
-  pWhiteColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255);
-  pYellowColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(225, 205, 35);
+  pWhiteColor = TargetColor(255, 255, 255);
+  pYellowColor = TargetColor(225, 205, 35);
   if ( dialog_menu_id == HOUSE_DIALOGUE_MAIN)
   {
     if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() )
--- a/UIMainMenu.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/UIMainMenu.cpp	Wed May 01 23:36:54 2013 +0600
@@ -142,7 +142,7 @@
     uTextureID_mhp_red = pIcons_LOD->LoadTexture("mhp_red", TEXTURE_16BIT_PALETTE);
     uTextureID_mhp_yel = pIcons_LOD->LoadTexture("mhp_yel", TEXTURE_16BIT_PALETTE);
     uTextureID_Leather = pIcons_LOD->LoadTexture("LEATHER", TEXTURE_16BIT_PALETTE);
-    pTexture_Leather = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("ibground", TEXTURE_16BIT_PALETTE)];
+    pTexture_Leather = pIcons_LOD->LoadTexturePtr("ibground", TEXTURE_16BIT_PALETTE);
     uTextureID_x_x_u = pIcons_LOD->LoadTexture("x_x_u", TEXTURE_16BIT_PALETTE);
     uTextureID_BUTTDESC2 = pIcons_LOD->LoadTexture("BUTTESC2", TEXTURE_16BIT_PALETTE);
     uTextureID_x_ok_u = pIcons_LOD->LoadTexture("x_ok_u", TEXTURE_16BIT_PALETTE);
@@ -152,10 +152,10 @@
 
     pPrimaryWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
     pPrimaryWindow->CreateButton(7u, 8u, 0x1CCu, 0x157u, 1, 0, UIMSG_A, 0, 0, "", 0);
-    pPrimaryWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 1, 0x31u, "", 0);
-    pPrimaryWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 2, 0x32u, "", 0);
-    pPrimaryWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 3, 0x33u, "", 0);
-    pPrimaryWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 4, 0x34u, "", 0);
+    pPrimaryWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
+    pPrimaryWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
+    pPrimaryWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
+    pPrimaryWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0);
     pPrimaryWindow->CreateButton(0x18u, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 1u, 0, "", 0);
     pPrimaryWindow->CreateButton(0x8Bu, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 2u, 0, "", 0);
     pPrimaryWindow->CreateButton(0xFFu, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 3u, 0, "", 0);
@@ -166,22 +166,22 @@
     pPrimaryWindow->CreateButton(0x1BBu, 0x194u, 5u, 0x31u, 1, 93, UIMSG_0, 4u, 0, "", 0);
 
     uTextureID_ib_td1_A = pIcons_LOD->LoadTexture("ib-td1-A", TEXTURE_16BIT_PALETTE);
-    v6 = (Texture *)(uTextureID_ib_td1_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td1_A] : 0);
+    v6 = pIcons_LOD->GetTexture(uTextureID_ib_td1_A);
     v8 = pKeyActionMap->GetActionVKey(INPUT_Quest);
     pBtn_Quests = pPrimaryWindow->CreateButton(0x1EBu, 0x161u, v6->uTextureWidth, v6->uTextureHeight, 1, 0, UIMSG_OpenQuestBook, 0, v8, pGlobalTXT_LocalizationStrings[174], v6, 0); //Quests
 
     uTextureID_ib_td2_A = pIcons_LOD->LoadTexture("ib-td2-A", TEXTURE_16BIT_PALETTE);
-    v10 = (Texture *)(uTextureID_ib_td2_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td2_A] : 0);
+    v10 = pIcons_LOD->GetTexture(uTextureID_ib_td2_A);
     v12 = pKeyActionMap->GetActionVKey(INPUT_Autonotes);
     pBtn_Autonotes = pPrimaryWindow->CreateButton(0x20Fu, 0x161u, v10->uTextureWidth, v10->uTextureHeight, 1, 0, UIMSG_OpenAutonotes, 0, v12, pGlobalTXT_LocalizationStrings[154], v10, 0);//Autonotes
 
     v14 = pIcons_LOD->LoadTexture("ib-td3-A", TEXTURE_16BIT_PALETTE);
-    v15 = (Texture *)(v14 != -1 ? &pIcons_LOD->pTextures[v14] : 0);
+    v15 = pIcons_LOD->GetTexture(v14);
     v17 = pKeyActionMap->GetActionVKey(INPUT_Mapbook);
     pBtn_Maps = pPrimaryWindow->CreateButton(0x222u, 0x161u, v15->uTextureWidth, v15->uTextureHeight, 1, 0, UIMSG_OpenMapBook, 0, v17, pGlobalTXT_LocalizationStrings[139], v15, 0); //Maps
 
     uTextureID_ib_td4_A = pIcons_LOD->LoadTexture("ib-td4-A", TEXTURE_16BIT_PALETTE);
-    v20 = (Texture *)(uTextureID_ib_td4_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td4_A] : 0);
+    v20 = pIcons_LOD->GetTexture(uTextureID_ib_td4_A);
     v22 = pKeyActionMap->GetActionVKey(INPUT_TimeCal);
     pBtn_Calendar = pPrimaryWindow->CreateButton(0x23Au, 0x161u, v20->uTextureWidth, v20->uTextureHeight, 1, 0, UIMSG_OpenCalendar, 0, v22,
         pGlobalTXT_LocalizationStrings[78],//Calendar
@@ -189,10 +189,10 @@
 
     uTextureID_ib_td5_A = pIcons_LOD->LoadTexture("ib-td5-A", TEXTURE_16BIT_PALETTE);
     pBtn_History = pPrimaryWindow->CreateButton(0x258u, 0x169u,
-        (uTextureID_ib_td5_A != -1 ? pIcons_LOD->pTextures[uTextureID_ib_td5_A].uTextureWidth : 24),
-        (uTextureID_ib_td5_A != -1 ? pIcons_LOD->pTextures[uTextureID_ib_td5_A].uTextureHeight : 26),
+        pIcons_LOD->GetTexture(uTextureID_ib_td5_A)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_ib_td5_A)->uTextureHeight,
         1, 0, UIMSG_OpenHistoryBook, 0, 0x48u, pGlobalTXT_LocalizationStrings[602],//History
-        (Texture *)(uTextureID_ib_td5_A != -1 ? &pIcons_LOD->pTextures[uTextureID_ib_td5_A] : 0), 0);
+        pIcons_LOD->GetTexture(uTextureID_ib_td5_A), 0);
 
     bFlashAutonotesBook = 0;
     bFlashQuestBook = 0;
@@ -207,41 +207,35 @@
     pBtn_ZoomOut = pPrimaryWindow->CreateButton(519, 136, v29->uTextureWidth, v29->uTextureHeight, 2, 0, UIMSG_16F, 0, v33, pGlobalTXT_LocalizationStrings[251], // Zoom Out
         v29, 0);
     pPrimaryWindow->CreateButton(0x1E1u, 0, 0x99u, 0x43u, 1, 92, UIMSG_0, 0, 0, "", 0);
-    pPrimaryWindow->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, UIMSG_StartHireling1Dialogue, 0, 0x35u, "", 0);
-    pPrimaryWindow->CreateButton(0x231u, 0x95u, 0x40u, 0x4Au, 1, 0, UIMSG_StartHireling2Dialogue, 0, 0x36u, "", 0);
+    pPrimaryWindow->CreateButton(0x1EBu, 0x95u, 0x40u, 0x4Au, 1, 0, UIMSG_StartHireling1Dialogue, 0, '5', "", 0);
+    pPrimaryWindow->CreateButton(0x231u, 0x95u, 0x40u, 0x4Au, 1, 0, UIMSG_StartHireling2Dialogue, 0, '6', "", 0);
     pPrimaryWindow->CreateButton(0x1DCu, 0x142u, 0x4Du, 0x11u, 1, 100, UIMSG_0, 0, 0, "", 0);
     pPrimaryWindow->CreateButton(0x22Bu, 0x142u, 0x4Du, 0x11u, 1, 101, UIMSG_0, 0, 0, "", 0);
     pBtn_CastSpell = pPrimaryWindow->CreateButton(0x1DCu, 0x1C2u,
-        (uTextureID_Btn_CastSpell != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_CastSpell].uTextureWidth : 24),
-        (uTextureID_Btn_CastSpell != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_CastSpell].uTextureHeight : 26),
-        1, 0, UIMSG_SpellBookWindow, 0, 0x43u, pGlobalTXT_LocalizationStrings[38],
-        (Texture *)(uTextureID_Btn_CastSpell != -1 ? &pIcons_LOD->pTextures[uTextureID_Btn_CastSpell] : 0),
+        pIcons_LOD->GetTexture(uTextureID_Btn_CastSpell)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_Btn_CastSpell)->uTextureHeight,
+        1, 0, UIMSG_SpellBookWindow, 0, 0x43u, pGlobalTXT_LocalizationStrings[38], pIcons_LOD->GetTexture(uTextureID_Btn_CastSpell),
         0);
     pBtn_Rest = pPrimaryWindow->CreateButton(0x206u, 0x1C2u,
-        (uTextureID_Btn_Rest != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_Rest].uTextureWidth : 24),
-        (uTextureID_Btn_Rest != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_Rest].uTextureHeight : 26),
-        1, 0, UIMSG_RestWindow, 0, 0x52u, pGlobalTXT_LocalizationStrings[182],
-        (Texture *)(uTextureID_Btn_Rest != -1 ? &pIcons_LOD->pTextures[uTextureID_Btn_Rest] : 0), 0);
+        pIcons_LOD->GetTexture(uTextureID_Btn_Rest)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_Btn_Rest)->uTextureHeight,
+        1, 0, UIMSG_RestWindow, 0, 0x52u, pGlobalTXT_LocalizationStrings[182], pIcons_LOD->GetTexture(uTextureID_Btn_Rest), 0);
     pBtn_QuickReference = pPrimaryWindow->CreateButton(0x230u, 0x1C2u,
-        (uTextureID_Btn_QuickReference != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_QuickReference].uTextureWidth : 24),
-        (uTextureID_Btn_QuickReference != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_QuickReference].uTextureHeight : 26),
-        1, 0, UIMSG_QuickReference, 0, 0x5Au, pGlobalTXT_LocalizationStrings[173],
-        (Texture *)(uTextureID_Btn_QuickReference != -1 ? &pIcons_LOD->pTextures[uTextureID_Btn_QuickReference] : 0), 0);
+        pIcons_LOD->GetTexture(uTextureID_Btn_QuickReference)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_Btn_QuickReference)->uTextureHeight,
+        1, 0, UIMSG_QuickReference, 0, 0x5Au, pGlobalTXT_LocalizationStrings[173], pIcons_LOD->GetTexture(uTextureID_Btn_QuickReference), 0);
     pBtn_GameSettings = pPrimaryWindow->CreateButton(0x25Au, 0x1C2u,
-        (uTextureID_Btn_GameSettings != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_GameSettings].uTextureWidth : 24),
-        (uTextureID_Btn_GameSettings != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_GameSettings].uTextureHeight : 26),
-        1, 0, UIMSG_GameMenuButton, 0, 0, pGlobalTXT_LocalizationStrings[93],
-        (Texture *)(uTextureID_Btn_GameSettings != -1 ? &pIcons_LOD->pTextures[uTextureID_Btn_GameSettings] : 0), 0);
+        pIcons_LOD->GetTexture(uTextureID_Btn_GameSettings)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_Btn_GameSettings)->uTextureHeight,
+        1, 0, UIMSG_GameMenuButton, 0, 0, pGlobalTXT_LocalizationStrings[93], pIcons_LOD->GetTexture(uTextureID_Btn_GameSettings), 0);
     pBtn_NPCLeft = pPrimaryWindow->CreateButton(0x1D5u, 0xB2u,
-        (uTextureID_Btn_NPCLeft != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_NPCLeft].uTextureWidth : 24),
-        (uTextureID_Btn_NPCLeft != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_NPCLeft].uTextureHeight : 26),
-        1, 0, UIMSG_ScrollNPCPanel, 0, 0, "",
-        pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft), 0);
+        pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft)->uTextureHeight,
+        1, 0, UIMSG_ScrollNPCPanel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_Btn_NPCLeft), 0);
     pBtn_NPCRight = pPrimaryWindow->CreateButton(0x272u, 0xB2u,
-        (uTextureID_Btn_NPCRight != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_NPCRight].uTextureWidth : 24),
-        (uTextureID_Btn_NPCRight != -1 ? pIcons_LOD->pTextures[uTextureID_Btn_NPCRight].uTextureHeight : 26),
-        1, 0, UIMSG_ScrollNPCPanel, 1u, 0, "",
-        pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight), 0);
+        pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureWidth,
+        pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight)->uTextureHeight,
+        1, 0, UIMSG_ScrollNPCPanel, 1u, 0, "", pIcons_LOD->GetTexture(uTextureID_Btn_NPCRight), 0);
     LoadPartyBuffIcons();
 }
 
@@ -313,12 +307,12 @@
         v7 = pAllocator->AllocNamedChunk(pTexture2.pPixels, 2 * pTexture2.uNumPixels, "scrollermap");
         pNumPixels = pTexture2.uNumPixels;
         pTexture2.pPixels = (unsigned __int16 *)v7;
-        teal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0xFFu);
+        teal = TargetColor(0, 0xFFu, 0xFFu);
         fill_pixels_fast(teal, pTexture2.pPixels, pNumPixels);
         pTexture2.field_20 = 0;
         pTexture2.field_22 = 0;
-        pColor1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x70u, 0x8Fu, 0xFEu);
-        pColor2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xECu, 0xE6u, 0x9Cu);
+        pColor1 = TargetColor(0x70u, 0x8Fu, 0xFEu);
+        pColor2 = TargetColor(0xECu, 0xE6u, 0x9Cu);
         pString = (char *)operator new(2 * pSize);
         strncpy(pString, ptr, pSize);
         pString[pSize]=0;
--- a/UIOptions.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/UIOptions.cpp	Wed May 01 23:36:54 2013 +0600
@@ -45,6 +45,12 @@
 
 
 
+
+OptionsMenuSkin options_menu_skin; // 507C60
+
+
+
+
 //----- (004142D3) --------------------------------------------------------
 char __cdecl GameMenuUI_DrawKeyBindings()
     {
@@ -108,14 +114,11 @@
     const char *v57; // ST0C_4@17
     unsigned int v58; // eax@17
     unsigned int v59; // eax@18
-    int v61; // [sp-14h] [bp-28h]@16
+    //int v61; // [sp-14h] [bp-28h]@16
     const char *v62; // [sp-10h] [bp-24h]@16
-    int v63; // [sp-Ch] [bp-20h]@16
-    int v64; // [sp-8h] [bp-1Ch]@16
-    unsigned int v65; // [sp-4h] [bp-18h]@16
     unsigned int a5; // [sp+10h] [bp-4h]@1
 
-    v0 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+    v0 = TargetColor(0xFFu, 0xFFu, 0xFFu);
     a5 = v0;
     if ( byte_4E28FC )
         {
@@ -131,7 +134,7 @@
         if ( v1 == 15 )
             byte_4E28FC = 1;
         }
-    v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v1, 0, 0);
+    v2 = TargetColor(v1, 0, 0);
     v3 = pGUIWindow_CurrentMenu;
     dword_507C08 = v2;
     if ( pGUIWindow_CurrentMenu->field_40 == 2 )
@@ -158,135 +161,130 @@
             dword_506E68 = -1;
             v3->field_40 = 0;
         }
-    pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_Optkb[0] != -1 ? &pIcons_LOD->pTextures[uTextureID_Optkb[0]] : 0));
+    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_Optkb[0]));
     if ( KeyboardPageNum == 1 )
-        {
-        pRenderer->DrawTextureIndexed(0x13, 0x12E, (Texture *)(uTextureID_Optkb[3] != -1 ? &pIcons_LOD->pTextures[uTextureID_Optkb[3]] : 0));
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ascii_4E2D5C, 0, 0, 0);
+    {
+        pRenderer->DrawTextureIndexed(0x13, 0x12E, pIcons_LOD->GetTexture(uTextureID_Optkb[3]));
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, "Ш", 0, 0, 0);
         v6 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[0]);
         v7 = sub_414D24(0);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 142, v7, v6, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, ascii_4E2D50, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, "", 0, 0, 0);
         v8 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[1]);
         v9 = sub_414D24(1);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 163, v9, v8, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, ascii_4E2D48, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, "", 0, 0, 0);
         v10 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[2]);
         v11 = sub_414D24(2);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 184, v11, v10, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, ascii_4E2D40, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, "", 0, 0, 0);
         v12 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[3]);
         v13 = sub_414D24(3);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 205, v13, v12, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, ascii_4E2D38, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, "", 0, 0, 0);
         v14 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[4]);
         v15 = sub_414D24(4);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 226, v15, v14, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, ascii_4E2D30, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, "", 0, 0, 0);
         v16 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[5]);
         v17 = sub_414D24(5);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 247, v17, v16, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ascii_4E2D28, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ".", 0, 0, 0);
         v18 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[6]);
         v19 = sub_414D24(6);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 268, v19, v18, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ascii_4E2D1C, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ". .", 0, 0, 0);
         v20 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[7]);
         v21 = sub_414D24(7);
         v22 = 350;
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 142, v21, v20, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, ascii_4E2D14, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, "", 0, 0, 0);
         v23 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[8]);
         v24 = sub_414D24(8);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 163, v24, v23, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, ascii_4E2D0C, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, ".", 0, 0, 0);
         v25 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[9]);
         v26 = sub_414D24(9);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 184, v26, v25, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, ascii_4E2D04, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, ".", 0, 0, 0);
         v27 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[10]);
         v28 = sub_414D24(10);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 205, v28, v27, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, ascii_4E2CFC, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, "", 0, 0, 0);
         v29 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[11]);
         v30 = sub_414D24(11);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 226, v30, v29, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ascii_4E2CF0, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ". ", 0, 0, 0);
         v31 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[12]);
         v32 = sub_414D24(12);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 247, v32, v31, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, ascii_4E2CE8, 0, 0, 0);
-        v65 = 0;
-        v64 = 0;
-        v63 = 0;
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, "", 0, 0, 0);
+
         v62 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[13]);
-        v61 = 13;
+        v59 = sub_414D24(13);
         }
     else
         {
-        pRenderer->DrawTextureIndexed(0x7F, 0x12E, (Texture *)(uTextureID_Optkb[4] != -1 ? &pIcons_LOD->pTextures[uTextureID_Optkb[4]] : 0));
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ascii_4E2CDC, 0, 0, 0);
+        pRenderer->DrawTextureIndexed(0x7F, 0x12E, pIcons_LOD->GetTexture(uTextureID_Optkb[4]));
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 142, v0, ". ", 0, 0, 0);
         v33 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[14]);
         v34 = sub_414D24(14);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 142, v34, v33, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, ascii_4E2CD4, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 163, v0, "", 0, 0, 0);
         v35 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[15]);
         v36 = sub_414D24(15);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 163, v36, v35, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, ascii_4E2CC8, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 184, v0, ". ", 0, 0, 0);
         v37 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[16]);
         v38 = sub_414D24(16);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 184, v38, v37, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, ascii_4E2CBC, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 205, v0, "", 0, 0, 0);
         v39 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[17]);
         v40 = sub_414D24(17);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 205, v40, v39, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, ascii_4E2CB0, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 226, v0, "", 0, 0, 0);
         v41 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[18]);
         v42 = sub_414D24(18);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 226, v42, v41, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, ascii_4E2CA4, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 247, v0, "", 0, 0, 0);
         v43 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[19]);
         v44 = sub_414D24(19);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 247, v44, v43, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ascii_4E2C9C, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 23, 268, v0, ". ", 0, 0, 0);
         v45 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[20]);
         v46 = sub_414D24(20);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 127, 268, v46, v45, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ascii_4E2C90, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 142, v0, ". ", 0, 0, 0);
         v47 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[21]);
         v48 = sub_414D24(21);
         v22 = 350;
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 142, v48, v47, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, ascii_4E2C84, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 163, a5, ". Ш", 0, 0, 0);
         v49 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[22]);
         v50 = sub_414D24(22);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 163, v50, v49, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, ascii_4E2C7C, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 184, a5, "", 0, 0, 0);
         v51 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[23]);
         v52 = sub_414D24(23);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 184, v52, v51, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, ascii_4E2C70, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 205, a5, "", 0, 0, 0);
         v53 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[24]);
         v54 = sub_414D24(24);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 205, v54, v53, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, ascii_4E2C68, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 226, a5, ". ", 0, 0, 0);
         v55 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[25]);
         v56 = sub_414D24(25);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 226, v56, v55, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ascii_4E2C5C, 0, 0, 0);
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 247, a5, ". ", 0, 0, 0);
         v57 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[26]);
         v58 = sub_414D24(26);
         pGUIWindow_CurrentMenu->DrawText(pFontLucida, 350, 247, v58, v57, 0, 0, 0);
-        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, ascii_4E2C54, 0, 0, 0);
-        v65 = 0;
-        v64 = 0;
-        v63 = 0;
+        pGUIWindow_CurrentMenu->DrawText(pFontLucida, 247, 268, a5, "", 0, 0, 0);
+
         v62 = pKeyActionMap->GetVKeyDisplayName(pWindowList_at_506F50_minus1_indexing[0]);
-        v61 = 27;
+        v59 = sub_414D24(27);
         }
-    v59 = sub_414D24(v61);
-    return pGUIWindow_CurrentMenu->DrawText(pFontLucida, v22, 268, v59, v62, v63, v64, v65);
+    return pGUIWindow_CurrentMenu->DrawText(pFontLucida, v22, 268, v59, v62, 0, 0, 0);
     }
 
 
@@ -299,9 +297,9 @@
     unsigned int result; // eax@1
 
     v1 = _this;
-    v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-    v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFu, 0, 0);
-    result = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+    v2 = TargetColor(0xE1u, 0xCDu, 0x23u);
+    v3 = TargetColor(0xFu, 0, 0);
+    result = TargetColor(0xFFu, 0xFFu, 0xFFu);
     if ( dword_506E68 == v1 )
         {
         if ( GetTickCount() % 0x3E8 <= 0x1F4 )
@@ -316,102 +314,119 @@
         }
     return result;
     }
-// 506E68: using guessed type int dword_506E68;
-// 506E6C: using guessed type __int16 word_506E6C[18];
-// 507C08: using guessed type int dword_507C08;
 
 //----- (00414D9A) --------------------------------------------------------
-void __cdecl GameMenuUI_DrawVideoOptions()
-    {
+void GameMenuUI_DrawVideoOptions()
+{
     const char *v0; // ST0C_4@3
     unsigned __int16 v1; // ax@3
-    int v2; // eax@10
+    //int v2; // eax@10
     GUIWindow v3; // [sp+8h] [bp-54h]@3
 
-    pRenderer->DrawTextureIndexed(
-        8u,
-        8u,
-        (Texture *)(uTextureID_507C10 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C10] : 0));
+    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_507C10));
     if ( !pRenderer->bWindowMode && GammaController::IsGammaSupported() )
         {
         pRenderer->DrawTextureIndexed(
             17 * uGammaPos + 42,
-            162u,
-            (Texture *)(pTextureIDs_GammaPositions[uGammaPos] != -1 ? &pIcons_LOD->pTextures[pTextureIDs_GammaPositions[uGammaPos]] : 0));
+            162,
+            pIcons_LOD->GetTexture(pTextureIDs_GammaPositions[uGammaPos]));
         pRenderer->DrawTextureRGB(0x112u, 0xA9u, &stru_506E40);
         v3.uFrameX = 22;
-        v0 = pGlobalTXT_LocalizationStrings[226];
+        v0 = pGlobalTXT_LocalizationStrings[226]; // "Gamma controls the relative ""brightness"" of the game.  May vary depending on your monitor."
         v3.uFrameY = 190;
         v3.uFrameWidth = 211;
         v3.uFrameHeight = 79;
         v3.uFrameZ = 232;
         v3.uFrameW = 268;
-        v1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+        v1 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
         v3.DrawTitleText(pFontSmallnum, 0, 0, v1, v0, 3u);
         }
-    if ( !pRenderer->pRenderD3D )
-        {
-        pRenderer->DrawTextureIndexed(
-            0x14u,
-            0x119u,
-            (Texture *)(uTextureID_507C50 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C50] : 0));
-        pRenderer->DrawTextureIndexed(
-            0x14u,
-            0x12Fu,
-            (Texture *)(uTextureID_507C54 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C54] : 0));
-        v2 = uTextureID_507C58;
-        goto LABEL_12;
-        }
-    if ( pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS )
-        pRenderer->DrawTextureIndexed(
-        0x14u,
-        0x119u,
-        (Texture *)(uTextureID_507C14 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C14] : 0));
-    if ( pRenderer->bUseColoredLights )
-        pRenderer->DrawTextureIndexed(
-        0x14u,
-        0x12Fu,
-        (Texture *)(uTextureID_507C18 != -1 ? &pIcons_LOD->pTextures[uTextureID_507C18] : 0));
-    if ( pRenderer->bTinting )
-        {
-        v2 = uTextureID_507C1C;
-LABEL_12:
-        pRenderer->DrawTextureIndexed(0x14u, 0x145u, (Texture *)(v2 != -1 ? &pIcons_LOD->pTextures[v2] : 0));
-        }
+
+    if (!pRenderer->pRenderD3D)
+    {
+      pRenderer->DrawTextureIndexed(20, 281, pIcons_LOD->GetTexture(uTextureID_507C50));
+      pRenderer->DrawTextureIndexed(20, 303, pIcons_LOD->GetTexture(uTextureID_507C54));
+      pRenderer->DrawTextureIndexed(20, 325, pIcons_LOD->GetTexture(uTextureID_507C58));
     }
+    else
+    {
+      if (pGame->uFlags2 & GAME_FLAGS_2_DRAW_BLOODSPLATS)
+        pRenderer->DrawTextureIndexed(20, 281, pIcons_LOD->GetTexture(uTextureID_507C14));
+      if (pRenderer->bUseColoredLights)
+        pRenderer->DrawTextureIndexed(20, 303, pIcons_LOD->GetTexture(uTextureID_507C18));
+      if (pRenderer->bTinting)
+        pRenderer->DrawTextureIndexed(20, 325, pIcons_LOD->GetTexture(uTextureID_507C1C));
+    }
+}
 
 
 
 //----- (00414F82) --------------------------------------------------------
-void __cdecl DrawGameOptions()
-    {
-    signed int v0; // eax@1
+void DrawGameOptions()
+{
+  pRenderer->DrawTextureIndexed(8,   8, pIcons_LOD->GetTexture(uTextureID_Options));
+  pRenderer->DrawTextureIndexed(8, 132, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_Background));
+
+  switch (uTurnSpeed)
+  {
+    default:   pRenderer->DrawTextureIndexed(BtnTurnCoord[0], 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0]));
+    case 64:   pRenderer->DrawTextureIndexed(BtnTurnCoord[1], 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1]));
+    case 128:  pRenderer->DrawTextureIndexed(BtnTurnCoord[2], 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2]));
+  }
+
+  if (bWalkSound)  pRenderer->DrawTextureIndexed( 20, 303, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_WalkSound));
+  if (bShowDamage) pRenderer->DrawTextureIndexed(128, 303, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ShowDamage));
+  if (bFlipOnExit) pRenderer->DrawTextureIndexed(128, 325, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_FlipOnExit));
+  if (bAlwaysRun)  pRenderer->DrawTextureIndexed( 20, 325, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_AlwaysRun));
+
+  pRenderer->DrawTextureIndexed(265 + 17 * uSoundVolumeMultiplier,  162, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_SoundLevels[uSoundVolumeMultiplier]));
+  pRenderer->DrawTextureIndexed(265 + 17 * uMusicVolimeMultiplier,  216, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_SoundLevels[uMusicVolimeMultiplier]));
+  pRenderer->DrawTextureIndexed(265 + 17 * uVoicesVolumeMultiplier, 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_SoundLevels[uVoicesVolumeMultiplier]));
+}
+
+
+
+
+
+
+
+
+
 
-    pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_Options != -1 ? &pIcons_LOD->pTextures[uTextureID_Options] : 0));
-    pRenderer->DrawTextureIndexed(8, 132, (Texture *)(uTextureID_ControlBG[0] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[0]] : 0));
-    v0 = 0;
-    if ( uTurnSpeed == 128 )
-        {
-        v0 = 2;
-        }
-    else
-        {
-        if ( uTurnSpeed == 64 )
-            v0 = 1;
-        }
-    pRenderer->DrawTextureIndexed(BtnTurnCoord[v0], 270, (Texture *)(uTextureID_ControlBG[v0 + 1] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[v0 + 1]] : 0));
-    if ( bWalkSound )
-        pRenderer->DrawTextureIndexed(20, 303, (Texture *)(uTextureID_ControlBG[21] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[21]] : 0));
-    if ( bShowDamage )
-        pRenderer->DrawTextureIndexed(128, 303, (Texture *)(uTextureID_ControlBG[22] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[22]] : 0));
-    if ( bFlipOnExit )
-        pRenderer->DrawTextureIndexed(128, 325, (Texture *)(uTextureID_ControlBG[9] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[9]] : 0));
-    if ( bAlwaysRun )
-        pRenderer->DrawTextureIndexed(20, 325, (Texture *)(uTextureID_ControlBG[20] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[20]] : 0));
-    pRenderer->DrawTextureIndexed(17 * (char)uSoundVolumeMultiplier + 265, 162,
-        (Texture *)(uTextureID_ControlBG[(char)uSoundVolumeMultiplier + 10] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[(char)uSoundVolumeMultiplier + 10]] : 0));
-    pRenderer->DrawTextureIndexed(17 * (char)uMusicVolimeMultiplier + 265, 216,
-        (Texture *)(uTextureID_ControlBG[(char)uMusicVolimeMultiplier + 10] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[(char)uMusicVolimeMultiplier + 10]] : 0));
-    pRenderer->DrawTextureIndexed(17 * (char)uVoicesVolumeMultiplier + 265, 270,
-        (Texture *)(uTextureID_ControlBG[(char)uVoicesVolumeMultiplier + 10] != -1 ? &pIcons_LOD->pTextures[uTextureID_ControlBG[(char)uVoicesVolumeMultiplier + 10]] : 0));
-    }
\ No newline at end of file
+OptionsMenuSkin::OptionsMenuSkin():
+  uTextureID_Background(0),
+  uTextureID_ArrowLeft(0),
+  uTextureID_ArrowRight(0),
+  uTextureID_unused_0(0), uTextureID_unused_1(0), uTextureID_unused_2(0),
+  uTextureID_FlipOnExit(0),
+  uTextureID_AlwaysRun(0),
+  uTextureID_WalkSound(0),
+  uTextureID_ShowDamage(0)
+{
+    for (uint i = 0; i < 3; ++i)  uTextureID_TurnSpeed[i] = 0;
+    for (uint i = 0; i < 10; ++i) uTextureID_SoundLevels[i] = 0;
+} 
+
+void OptionsMenuSkin::Relaease()
+{
+  #define RELEASE(id) \
+  {\
+    if (id)\
+      pIcons_LOD->GetTexture(id)->Release();\
+    id = 0;\
+  }
+
+  RELEASE(uTextureID_Background);
+  for (uint i = 0; i < 3; ++i)
+    RELEASE(uTextureID_TurnSpeed[i]);
+  RELEASE(uTextureID_ArrowLeft);
+  RELEASE(uTextureID_ArrowRight);
+  RELEASE(uTextureID_FlipOnExit);
+  for (uint i = 0; i < 10; ++i)
+    RELEASE(uTextureID_SoundLevels[i]);
+  RELEASE(uTextureID_AlwaysRun);
+  RELEASE(uTextureID_WalkSound);
+  RELEASE(uTextureID_ShowDamage);
+
+  #undef RELEASE
+}
--- a/UIPartyCreation.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/UIPartyCreation.cpp	Wed May 01 23:36:54 2013 +0600
@@ -225,10 +225,10 @@
   //Player *pPlayer;
   const char *pSkillName;
 
-  uColor1 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xD1, 0xBB, 0x61);
-  uColorTeal = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xF7, 0xF7);
-  uColorGreen = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFF, 0);
-  uColorWhite = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0xFF);
+  uColor1 = TargetColor(0xD1, 0xBB, 0x61);
+  uColorTeal = TargetColor(0, 0xF7, 0xF7);
+  uColorGreen = TargetColor(0, 0xFF, 0);
+  uColorWhite = TargetColor(0xFF, 0xFF, 0xFF);
   pRenderer->BeginScene();
   pRenderer->DrawTextureRGB(0, 0, &pTexture_PCX);
   uPlayerCreationUI_SkySliderPos = (GetTickCount() % 12800) / 20;
@@ -563,8 +563,8 @@
   unsigned int v0; // ebx@5
   unsigned int v1; // eax@6
   int v2; // ecx@6
-  unsigned int v3; // eax@8
-  signed int v4; // ecx@8
+  //unsigned int v3; // eax@8
+  //signed int v4; // ecx@8
   signed int uControlParam; // [sp+10h] [bp-Ch]@7
   unsigned int uControlParama; // [sp+10h] [bp-Ch]@9
   unsigned int uControlParamb; // [sp+10h] [bp-Ch]@11
@@ -605,70 +605,73 @@
     pPlayerPortraits[uX] = &pIcons_LOD->pTextures[v1];
 
   }
-  pTexture_PlayerFaceMask = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("FACEMASK", TEXTURE_16BIT_PALETTE)];
-  pTexture_buttminu  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("buttminu", TEXTURE_16BIT_PALETTE)];
-  pTexture_buttplus  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("buttplus", TEXTURE_16BIT_PALETTE)];
-  pTexture_pressrigh = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("presrigh", TEXTURE_16BIT_PALETTE)];
-  pTexture_presleft  = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("presleft", TEXTURE_16BIT_PALETTE)];
+  pTexture_PlayerFaceMask = pIcons_LOD->LoadTexturePtr("FACEMASK", TEXTURE_16BIT_PALETTE);
+  pTexture_buttminu  = pIcons_LOD->LoadTexturePtr("buttminu", TEXTURE_16BIT_PALETTE);
+  pTexture_buttplus  = pIcons_LOD->LoadTexturePtr("buttplus", TEXTURE_16BIT_PALETTE);
+  pTexture_pressrigh = pIcons_LOD->LoadTexturePtr("presrigh", TEXTURE_16BIT_PALETTE);
+  pTexture_presleft  = pIcons_LOD->LoadTexturePtr("presleft", TEXTURE_16BIT_PALETTE);
   uControlParam = 1;
   do
   {
     sprintf(pTmpBuf, "arrowl%d", uControlParam);
-    pTextures_arrowl[uControlParam] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)];
+    pTextures_arrowl[uControlParam] = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
+
     sprintf(pTmpBuf, "arrowr%d", uControlParam);
-    v3 = pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE);
-    v4 = uControlParam++;
-    pTextures_arrowr[v4] = &pIcons_LOD->pTextures[v3];
+    pTextures_arrowr[uControlParam] = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
   }
-  while ( uControlParam < 20 );
+  while ( ++uControlParam < 20 );
   pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
   uControlParama = 0;
   uXa = 8;
   do
   {
-    pGUIWindow_CurrentMenu->CreateButton(uXa, 120u, 145u, 25u, 1, 0, UIMSG_PlayerCreationChangeName, uControlParama, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXa, 120, 145, 25, 1, 0, UIMSG_PlayerCreationChangeName, uControlParama, 0, "", 0);
     uXa += 158;
     ++uControlParama;
   }
   while ( (signed int)uXa < 640 );
-  pCreationUI_BtnPressLeft[0] = pGUIWindow_CurrentMenu->CreateButton(10, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev, 0, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft[1] = pGUIWindow_CurrentMenu->CreateButton(169, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev, 1, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft[2] = pGUIWindow_CurrentMenu->CreateButton(327, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev, 2, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft[3] = pGUIWindow_CurrentMenu->CreateButton(486, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev, 3, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressRight[0] = pGUIWindow_CurrentMenu->CreateButton(74, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext, 0, 0, "", pTexture_pressrigh, 0);
-  pCreationUI_BtnPressRight[1] = pGUIWindow_CurrentMenu->CreateButton(233, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext, 1, 0, "", pTexture_pressrigh, 0);
-  pCreationUI_BtnPressRight[2] = pGUIWindow_CurrentMenu->CreateButton(391, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext, 2, 0, "", pTexture_pressrigh, 0);
-  pCreationUI_BtnPressRight[3] = pGUIWindow_CurrentMenu->CreateButton(549, 32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext, 3, 0, "", pTexture_pressrigh, 0);
-  pCreationUI_BtnPressLeft2[0] = pGUIWindow_CurrentMenu->CreateButton(10, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 0, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft2[1] = pGUIWindow_CurrentMenu->CreateButton(169, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 1, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft2[2] = pGUIWindow_CurrentMenu->CreateButton(327, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 2, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressLeft2[3] = pGUIWindow_CurrentMenu->CreateButton(486, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 3, 0, "", pTexture_presleft, 0);
-  pCreationUI_BtnPressRight2[0] = pGUIWindow_CurrentMenu->CreateButton(74, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 0, 0, "", pTexture_pressrigh, 0);
+
+  pCreationUI_BtnPressLeft[0]   = pGUIWindow_CurrentMenu->CreateButton( 10,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev,  0, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressLeft[1]   = pGUIWindow_CurrentMenu->CreateButton(169,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev,  1, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressLeft[2]   = pGUIWindow_CurrentMenu->CreateButton(327,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev,  2, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressLeft[3]   = pGUIWindow_CurrentMenu->CreateButton(486,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FacePrev,  3, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressRight[0]  = pGUIWindow_CurrentMenu->CreateButton( 74,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext,  0, 0, "", pTexture_pressrigh, 0);
+  pCreationUI_BtnPressRight[1]  = pGUIWindow_CurrentMenu->CreateButton(233,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext,  1, 0, "", pTexture_pressrigh, 0);
+  pCreationUI_BtnPressRight[2]  = pGUIWindow_CurrentMenu->CreateButton(391,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext,  2, 0, "", pTexture_pressrigh, 0);
+  pCreationUI_BtnPressRight[3]  = pGUIWindow_CurrentMenu->CreateButton(549,  32, 11, 13, 1, 0, UIMSG_PlayerCreation_FaceNext,  3, 0, "", pTexture_pressrigh, 0);
+  pCreationUI_BtnPressLeft2[0]  = pGUIWindow_CurrentMenu->CreateButton( 10, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 0, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressLeft2[1]  = pGUIWindow_CurrentMenu->CreateButton(169, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 1, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressLeft2[2]  = pGUIWindow_CurrentMenu->CreateButton(327, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 2, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressLeft2[3]  = pGUIWindow_CurrentMenu->CreateButton(486, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoicePrev, 3, 0, "", pTexture_presleft, 0);
+  pCreationUI_BtnPressRight2[0] = pGUIWindow_CurrentMenu->CreateButton( 74, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 0, 0, "", pTexture_pressrigh, 0);
   pCreationUI_BtnPressRight2[1] = pGUIWindow_CurrentMenu->CreateButton(233, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 1, 0, "", pTexture_pressrigh, 0);
   pCreationUI_BtnPressRight2[2] = pGUIWindow_CurrentMenu->CreateButton(391, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 2, 0, "", pTexture_pressrigh, 0);
   pCreationUI_BtnPressRight2[3] = pGUIWindow_CurrentMenu->CreateButton(549, 103, 11, 13, 1, 0, UIMSG_PlayerCreation_VoiceNext, 3, 0, "", pTexture_pressrigh, 0);
+
   uControlParamb = 0;
   uXb = 8;
   do
   {
-    pGUIWindow_CurrentMenu->CreateButton(uXb, 308, 150, v0, 1, 0, UIMSG_48, uControlParamb, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXb, v0 + 308, 150, v0, 1, 0, UIMSG_49, uControlParamb, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXb, 2 * v0 + 308, 150u, v0, 1, 0, UIMSG_PlayerCreationRemoveUpSkill, uControlParamb, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXb, 3 * v0 + 308, 150u, v0, 1, 0, UIMSG_PlayerCreationRemoveDownSkill, uControlParamb, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXb, 308,          150, v0, 1, 0, UIMSG_48,                            uControlParamb, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXb, v0 + 308,     150, v0, 1, 0, UIMSG_49,                            uControlParamb, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXb, 2 * v0 + 308, 150, v0, 1, 0, UIMSG_PlayerCreationRemoveUpSkill,   uControlParamb, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXb, 3 * v0 + 308, 150, v0, 1, 0, UIMSG_PlayerCreationRemoveDownSkill, uControlParamb, 0, "", 0);
     uXb += 158;
     ++uControlParamb;
   }
   while ( (signed int)uXb < 640 );
-  pGUIWindow_CurrentMenu->CreateButton(5u, 21u, 0x99u, 0x16Du, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 0, 0x31u, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(163u, 21u, 0x99u, 0x16Du, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 1u, 0x32u, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(321u, 21u, 0x99u, 0x16Du, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 2u, 0x33u, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(479u, 21u, 0x99u, 0x16Du, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 3u, 0x34u, "", 0);
+
+  pGUIWindow_CurrentMenu->CreateButton(  5, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 0, 0x31u, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(163, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 1, 0x32u, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(321, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 2, 0x33u, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(479, 21, 153, 365, 1, 0, UIMSG_PlayerCreation_SelectAttribute, 3, 0x34u, "", 0);
+
   uXc = 23;
   uControlParamc = 2;
   do
   {
-    pGUIWindow_CurrentMenu->CreateButton(uXc, 169, 120, 20, 1, 0, UIMSG_0, uControlParamc - 2, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(uXc, v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc - 1, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXc, 169,          120, 20, 1, 0, UIMSG_0, uControlParamc - 2, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(uXc, v0 + 169,     120, 20, 1, 0, UIMSG_0, uControlParamc - 1, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(uXc, 2 * v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(uXc, 3 * v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc + 1, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(uXc, 4 * v0 + 169, 120, 20, 1, 0, UIMSG_0, uControlParamc + 2, 0, "", 0);
@@ -679,15 +682,15 @@
   }
   while ( (signed int)uControlParamc < 30 );
   pGUIWindow_CurrentMenu->_41D08F(28, 0, 7, 40);
-  pGUIWindow_CurrentMenu->CreateButton(323, 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(323, v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0xC, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(323, 417,          65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0,    0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(323, v0 + 417,     65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0xC,  0, "", 0);
   pGUIWindow_CurrentMenu->CreateButton(323, 2 * v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x14, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(388, 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x18, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(388, v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x1C, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(388, 417,          65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x18, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(388, v0 + 417,     65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x1C, 0, "", 0);
   pGUIWindow_CurrentMenu->CreateButton(388, 2 * v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x20, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(453, 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x10, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(453, v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 8, 0, "", 0);
-  pGUIWindow_CurrentMenu->CreateButton(453, 2 * v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 4, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(453, 417,          65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 0x10, 0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(453, v0 + 417,     65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 8,    0, "", 0);
+  pGUIWindow_CurrentMenu->CreateButton(453, 2 * v0 + 417, 65, v0, 1, 0, UIMSG_PlayerCreationSelectClass, 4,    0, "", 0);
   uControlParamd = 0;
   do
   {
@@ -699,12 +702,11 @@
     ++uControlParamd;
   }
   while ( uControlParamd < 9 );
-  pPlayerCreationUI_BtnOK = pGUIWindow_CurrentMenu->CreateButton(580, 431, 51, 39, 1, 0, UIMSG_PlayerCreationClickOK, 0, 0xD, "",
-                              (Texture *)(uTextureID_BUTTMAKE != -1 ? &pIcons_LOD->pTextures[uTextureID_BUTTMAKE] : 0), 0);
-  pPlayerCreationUI_BtnReset = pGUIWindow_CurrentMenu->CreateButton(527, 431, 51, 39, 1, 0, UIMSG_PlayerCreationClickReset, 0, 0x43, "",
-                                 (Texture *)(uTextureID_BUTTMAKE2 != -1 ? &pIcons_LOD->pTextures[uTextureID_BUTTMAKE2] : 0), 0);
+  pPlayerCreationUI_BtnOK    = pGUIWindow_CurrentMenu->CreateButton(580, 431, 51, 39, 1, 0, UIMSG_PlayerCreationClickOK, 0, 0xD, "", pIcons_LOD->GetTexture(uTextureID_BUTTMAKE), 0);
+  pPlayerCreationUI_BtnReset = pGUIWindow_CurrentMenu->CreateButton(527, 431, 51, 39, 1, 0, UIMSG_PlayerCreationClickReset, 0, 0x43, "", pIcons_LOD->GetTexture(uTextureID_BUTTMAKE2), 0);
   pPlayerCreationUI_BtnMinus = pGUIWindow_CurrentMenu->CreateButton(523, 393, 20, 35, 1, 0, UIMSG_PlayerCreationClickMinus, 0, 0x2D, "", pTexture_buttminu, 0);
-  pPlayerCreationUI_BtnPlus = pGUIWindow_CurrentMenu->CreateButton(613, 393, 20, 35, 1, 0, UIMSG_PlayerCreationClickPlus, 1, 0x2B, "", pTexture_buttplus, 0);
+  pPlayerCreationUI_BtnPlus  = pGUIWindow_CurrentMenu->CreateButton(613, 393, 20, 35, 1, 0, UIMSG_PlayerCreationClickPlus, 1, 0x2B, "", pTexture_buttplus, 0);
+
   pFontCChar = LoadFont("cchar.fnt", "FONTPAL", NULL);
 }
 // 4E28F8: using guessed type int pCurrentScreen;
--- a/UIPopup.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/UIPopup.cpp	Wed May 01 23:36:54 2013 +0600
@@ -72,13 +72,12 @@
     a2a = uX;
     a4 = uX + uWidth;
     pRenderer->SetTextureClipRect(uX, v4, uX + uWidth, v4 + uHeight);
-    v5 = (Texture *)(uTextureID_Parchment != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_Parchment] : 0);
-    uTileWidth = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24);
-    v13 = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24);
-    uTileHeight = (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureHeight : 26);
-    if ( (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureWidth : 24)
-        && (uTextureID_Parchment != -1 ? pIcons_LOD->pTextures[uTextureID_Parchment].uTextureHeight : 26) )
-        {
+    v5 = pIcons_LOD->GetTexture(uTextureID_Parchment);
+    uTileWidth = v5->uTextureWidth;
+    v13 = v5->uTextureWidth;
+    uTileHeight = v5->uTextureHeight;
+    if ( v5->uTextureWidth && v5->uTextureHeight)
+    {
         uNumXTiles = (signed int)uWidth / uTileWidth;
         if ( (signed int)uWidth % uTileWidth )
             ++uNumXTiles;
@@ -106,59 +105,29 @@
             }
             while ( v8 < (signed int)uHeight / uTileHeight );
             a5a = v4 + uHeight - 32;
-            pRenderer->DrawTextureTransparent(
-                a2a,
-                v4,
-                (Texture *)(uTextureID_5076AC != -1 ? &pIcons_LOD->pTextures[uTextureID_5076AC] : 0));
-            pRenderer->DrawTextureTransparent(
-                a2a,
-                a5a,
-                (Texture *)(uTextureID_5076B4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076B4] : 0));
-            pRenderer->DrawTextureTransparent(
-                a4 - 32,
-                v4,
-                (Texture *)(uTextureID_5076A8 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A8] : 0));
-            pRenderer->DrawTextureTransparent(
-                a4 - 32,
-                a5a,
-                (Texture *)(uTextureID_5076B0 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_5076B0] : 0));
+            pRenderer->DrawTextureTransparent(a2a, v4, pIcons_LOD->GetTexture(uTextureID_5076AC));
+            pRenderer->DrawTextureTransparent(a2a, a5a, pIcons_LOD->GetTexture(uTextureID_5076B4));
+            pRenderer->DrawTextureTransparent(a4 - 32, v4, pIcons_LOD->GetTexture(uTextureID_5076A8));
+            pRenderer->DrawTextureTransparent(a4 - 32, a5a, pIcons_LOD->GetTexture(uTextureID_5076B0));
             uNumXTilesb = a2a + 32;
             v22 = v4 + uHeight - 10;
             if ( (signed int)uWidth > 64 )
                 {
                 pRenderer->SetTextureClipRect(a2a + 32, v4, a4 - 32, v4 + uHeight);
-                pRenderer->DrawTextureTransparent(
-                    uNumXTilesb,
-                    v4,
-                    (Texture *)(uTextureID_507698 != -1 ? &pIcons_LOD->pTextures[uTextureID_507698] : 0));
-                pRenderer->DrawTextureTransparent(
-                    uNumXTilesb,
-                    v22,
-                    (Texture *)(uTextureID_5076A4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A4] : 0));
+                pRenderer->DrawTextureTransparent(uNumXTilesb, v4, pIcons_LOD->GetTexture(uTextureID_507698));
+                pRenderer->DrawTextureTransparent(uNumXTilesb, v22, pIcons_LOD->GetTexture(uTextureID_5076A4));
                 if ( (signed int)uWidth > 512 )
                     {
-                    pRenderer->DrawTextureTransparent(
-                        a2a + 544,
-                        v4,
-                        (Texture *)(uTextureID_507698 != -1 ? &pIcons_LOD->pTextures[uTextureID_507698] : 0));
-                    pRenderer->DrawTextureTransparent(
-                        a2a + 544,
-                        v22,
-                        (Texture *)(uTextureID_5076A4 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A4] : 0));
+                    pRenderer->DrawTextureTransparent(a2a + 544, v4, pIcons_LOD->GetTexture(uTextureID_507698));
+                    pRenderer->DrawTextureTransparent(a2a + 544, v22, pIcons_LOD->GetTexture(uTextureID_5076A4));
                     }
                 }
             v9 = v4 + 32;
             if ( (signed int)uHeight > 64 )
                 {
                 pRenderer->SetTextureClipRect(a2a, v9, a4, a5a);
-                pRenderer->DrawTextureTransparent(
-                    a2a,
-                    v9,
-                    (Texture *)(uTextureID_5076A0 != -1 ? &pIcons_LOD->pTextures[uTextureID_5076A0] : 0));
-                pRenderer->DrawTextureTransparent(
-                    a4 - 10,
-                    v9,
-                    (Texture *)(uTextureID_50769C != -1 ? &pIcons_LOD->pTextures[uTextureID_50769C] : 0));
+                pRenderer->DrawTextureTransparent(a2a, v9, pIcons_LOD->GetTexture(uTextureID_5076A0));
+                pRenderer->DrawTextureTransparent(a4 - 10, v9, pIcons_LOD->GetTexture(uTextureID_50769C));
                 }
             pRenderer->ResetTextureClipRect();
         }
@@ -257,7 +226,7 @@
     char *Str; // [sp+270h] [bp-8h]@65
 
     v1 = inspect_item;
-    var88 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+    var88 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
     if (!inspect_item->uItemID)
         return;
 
@@ -361,7 +330,7 @@
         wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, v16, 3u);
         v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[32], &wHintWindow, 0, 0); //"Broken Item"
         v18 = v17 >> 1;
-        v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x19u, 0x19u);
+        v19 = TargetColor(0xFFu, 0x19u, 0x19u);
         wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[32], 3); //"Broken Item"
         pRenderer->ResetTextureClipRect();
         if ( !areWeLoadingTexture )
@@ -385,7 +354,7 @@
         wHintWindow.DrawTitleText(pFontArrus, 0, 0xCu, var88, item_desc->pUnidentifiedName, 3u);
         v17 = pFontArrus->CalcTextHeight(pGlobalTXT_LocalizationStrings[232], &wHintWindow, 0, 0); ///"Not Identified"
         v18 = v17 >> 1;
-        v19 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x19u, 0x19u);
+        v19 = TargetColor(0xFFu, 0x19u, 0x19u);
         wHintWindow.DrawTitleText(pFontArrus, 0x64u, ((signed int)wHintWindow.uFrameHeight >> 1) - v18, v19, pGlobalTXT_LocalizationStrings[232], 3);
         pRenderer->ResetTextureClipRect();
         if ( !areWeLoadingTexture )
@@ -759,7 +728,7 @@
   v106.uParentBillboardID = -1;
   v3 = &pActors[v2];
   v121 = v3;
-  v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 255, 0x9Bu);
+  v4 = TargetColor(0xE1u, 255, 0x9Bu);
   //v5 = v3->sNPC_ID;
   a5 = v4;
   v6 = GetNPCData(v3->sNPC_ID);
@@ -985,7 +954,7 @@
   }
   if(!v121->sNPC_ID || (v121->sNPC_ID && !v6->uProfession))
     strncpy(pTmpBuf, v72, v77);
-  v39 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v39 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   a1->DrawTitleText(pFontComic, 0, 0xCu, v39, pTmpBuf, 3u);
   Actor::DrawHealthBar(v121, a1);
   v119 = 0;
@@ -1532,7 +1501,7 @@
         sprintf(Source, "\f%05d", v13);
         strcat(a2, Source);
         strcat(a2, "%s\t%03d:\t%03d%s\t000\n\n");
-        v14 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+        v14 = TargetColor(0xFFu, 0xFFu, 0xFFu);
         sprintf(Source, "\f%05d", v14);
         strcat(a2, Source);
         strcat(a2, "%s: +%d");
@@ -1846,7 +1815,7 @@
         v7 = v2->pName;
         a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
         a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
-        v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+        v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
         a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u);
         a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2, 0, 0, 0);
         a1.uFrameWidth = 108;
@@ -2223,7 +2192,7 @@
                 pWindow.uFrameHeight -= 12;
                 pWindow.uFrameZ = pWindow.uFrameX + pWindow.uFrameWidth - 1;
                 pWindow.uFrameW = pWindow.uFrameY + pWindow.uFrameHeight - 1;
-                pColor = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0x9B);
+                pColor = TargetColor(0xFF, 0xFF, 0x9B);
                 sprintf(pTmpBuf, format_4E2D80, pColor, pStr);//"\f%05d%s\f00000\n"
                 pWindow.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3);
                 pWindow.DrawText(pFontSmallnum, 1, pFontLucida->uFontHeight, 0, pHint, 0, 0, 0);
--- a/UIRest.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/UIRest.cpp	Wed May 01 23:36:54 2013 +0600
@@ -102,74 +102,16 @@
     uTextureID_RestUI_restb3 = pIcons_LOD->LoadTexture("restb3", TEXTURE_16BIT_PALETTE);
     uTextureID_RestUI_restb4 = pIcons_LOD->LoadTexture("restb4", TEXTURE_16BIT_PALETTE);
     uTextureID_RestUI_restexit = pIcons_LOD->LoadTexture("restexit", TEXTURE_16BIT_PALETTE);
+
     LoadActualSkyFrame();
-    pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, (enum WindowType)16, 0, 0);
-    pButton_RestUI_Exit = pGUIWindow_CurrentMenu->CreateButton(
-        280u,
-        297u,
-        154u,
-        37u,
-        1,
-        0,
-        UIMSG_ExitRest,
-        0,
-        0,
-        "",
-        (Texture *)(uTextureID_RestUI_restexit != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restexit] : 0),
-        0);
-    pButton_RestUI_Main = pGUIWindow_CurrentMenu->CreateButton(
-        24u,
-        154u,
-        225u,
-        37u,
-        1,
-        0,
-        UIMSG_Rest8Hour,
-        0,
-        0x52u,
-        "",
-        (Texture *)(uTextureID_RestUI_restb4 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb4] : 0),
-        0);
-    pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton(
-        61u,
-        232u,
-        154u,
-        33u,
-        1,
-        0,
-        UIMSG_AlreadyResting,
-        0,
-        0x44u,
-        "",
-        (Texture *)(uTextureID_RestUI_restb1 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb1] : 0),
-        0);
-    pButton_RestUI_Wait1Hour = pGUIWindow_CurrentMenu->CreateButton(
-        61u,
-        264u,
-        154u,
-        33u,
-        1,
-        0,
-        UIMSG_Wait1Hour,
-        0,
-        0x48u,
-        "",
-        (Texture *)(uTextureID_RestUI_restb2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb2] : 0),
-        0);
-    pButton_RestUI_Wait5Minutes = pGUIWindow_CurrentMenu->CreateButton(
-        61u,
-        296u,
-        154u,
-        33u,
-        1,
-        0,
-        UIMSG_Wait5Minutes,
-        0,
-        0x4Du,
-        "",
-        (Texture *)(uTextureID_RestUI_restb3 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restb3] : 0),
-        0);
-    }
+
+    pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_Rest, 0, 0);
+    pButton_RestUI_Exit          = pGUIWindow_CurrentMenu->CreateButton(280, 297, 154, 37, 1, 0, UIMSG_ExitRest,       0, 0,     "", pIcons_LOD->GetTexture(uTextureID_RestUI_restexit), 0);
+    pButton_RestUI_Main          = pGUIWindow_CurrentMenu->CreateButton( 24, 154, 225, 37, 1, 0, UIMSG_Rest8Hour,      0, 0x52u, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb4), 0);
+    pButton_RestUI_WaitUntilDawn = pGUIWindow_CurrentMenu->CreateButton( 61, 232, 154, 33, 1, 0, UIMSG_AlreadyResting, 0, 0x44u, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb1), 0);
+    pButton_RestUI_Wait1Hour     = pGUIWindow_CurrentMenu->CreateButton( 61, 264, 154, 33, 1, 0, UIMSG_Wait1Hour,      0, 0x48u, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb2), 0);
+    pButton_RestUI_Wait5Minutes  = pGUIWindow_CurrentMenu->CreateButton( 61, 296, 154, 33, 1, 0, UIMSG_Wait5Minutes,   0, 0x4Du, "", pIcons_LOD->GetTexture(uTextureID_RestUI_restb3), 0);
+}
 
 //----- (0041FA01) --------------------------------------------------------
 void __cdecl RestUI_Draw()
@@ -189,8 +131,8 @@
     int a5; // [sp+E0h] [bp-4h]@1
 
     v0 = 0;
-    a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xAu, 0, 0);
-    *(int *)a9 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE6u, 0xD6u, 0xC1u);
+    a5 = TargetColor(0xAu, 0, 0);
+    *(int *)a9 = TargetColor(0xE6u, 0xD6u, 0xC1u);
     ppPlayers = &pPlayers[1];
     do
         {
@@ -202,10 +144,7 @@
         while ( (signed int)ppPlayers <= (signed int)&pPlayers[4] );
         if ( v0 )
             {
-            pRenderer->DrawTextureIndexed(
-                8u,
-                8u,
-                (Texture *)(uTextureID_RestUI_restmain != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_RestUI_restmain] : 0));
+            pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_RestUI_restmain));
             v10 = pParty->uCurrentHour;
             dword_506F1C = pGUIWindow_CurrentMenu->pCurrentPosActiveItem;
             if ( (signed int)pParty->uCurrentHour <= 12 )
--- a/UISaveLoad.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/UISaveLoad.cpp	Wed May 01 23:36:54 2013 +0600
@@ -89,12 +89,12 @@
 
   v1 = 255;
   a4 = a1;
-  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0xFF);
-  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFF, 0xFF, 0x9B);
+  TargetColor(0xFF, 0xFF, 0xFF);
+  TargetColor(0xFF, 0xFF, 0x9B);
   pRenderer->BeginScene();
   if ( GetCurrentMenuID() != MENU_SAVELOAD && GetCurrentMenuID() != MENU_LOADINGPROC )
   {
-    pRenderer->DrawTextureIndexed(8, 8, uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0);
+    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
     if ( a4 )
     {
       v2 = uTextureID_save_up;
@@ -105,9 +105,9 @@
       v2 = uTextureID_load_up;
       v3 = uTextureID_LS_loadU;
     }
-    pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v3 != -1 ? &pIcons_LOD->pTextures[v3] : 0));
-    pRenderer->DrawTextureIndexed(18, 139, (Texture *)(v2 != -1 ? &pIcons_LOD->pTextures[v2] : 0));
-    pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0));
+    pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(v3));
+    pRenderer->DrawTextureIndexed (18, 139, pIcons_LOD->GetTexture(v2));
+    pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u));
     v1 = 255;
   }
   if ( pSavegameUsedSlots[uLoadGameUI_SelectedSlot] )
@@ -222,7 +222,7 @@
       if ( pFilesID >= (signed int)pSaveFiles )
         break;
       short clr;
-      HIDWORD(pAMPM2) = clr = (pFilesID == uLoadGameUI_SelectedSlot ? GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v1, v1, 0x64) : 0);
+      HIDWORD(pAMPM2) = clr = (pFilesID == uLoadGameUI_SelectedSlot ? TargetColor(v1, v1, 0x64) : 0);
       if ( pGUIWindow_CurrentMenu->field_40 != 1 || pFilesID != uLoadGameUI_SelectedSlot )
       {
         pGUIWindow_CurrentMenu->DrawTextInRect(pFontSmallnum, 0x1B, a4, clr, pSlotName, 185, 0);
@@ -264,7 +264,7 @@
 
 //----- (0045E361) --------------------------------------------------------
 void __fastcall GameUI_DrawLoadMenu(unsigned int uDialogueType)
-    {
+{
     unsigned int v1; // ebp@5
     unsigned int v2; // eax@5
     //signed int v3; // ebp@11
@@ -296,7 +296,7 @@
     uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
     if ( uDialogueType_ )
         {
-        pRenderer->DrawTextureIndexed(8, 8, (Texture *)(uTextureID_loadsave != -1 ? &pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
+        pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
         if ( pCurrentScreen == SCREEN_SAVEGAME )
             {
             v1 = uTextureID_save_up;
@@ -307,9 +307,9 @@
             v1 = uTextureID_load_up;
             v2 = uTextureID_LS_loadU;
             }
-        pRenderer->DrawTextureIndexed(241, 302, (Texture *)(v2 != -1 ? (int)&pIcons_LOD->pTextures[v2] : 0));
-        pRenderer->DrawTextureIndexed(18, 141, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
-        pRenderer->DrawTextureIndexed(351, 302, (Texture *)(uTextureID_x_u != -1 ? &pIcons_LOD->pTextures[uTextureID_x_u] : 0));
+        pRenderer->DrawTextureIndexed(241, 302, pIcons_LOD->GetTexture(v2));
+        pRenderer->DrawTextureIndexed( 18, 141, pIcons_LOD->GetTexture(v1));
+        pRenderer->DrawTextureIndexed(351, 302, pIcons_LOD->GetTexture(uTextureID_x_u));
         }
     else
         {
@@ -379,20 +379,15 @@
     pGUIWindow_CurrentMenu->CreateButton(21, 282, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(21, 303, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0);
     pGUIWindow_CurrentMenu->CreateButton(21, 324, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0);
-    pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_LoadSlot, 0, 0, "",
-        pIcons_LOD->GetTexture(uTextureID_LS_), 0);
-    pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "",
-        pIcons_LOD->GetTexture(uTextureID_x_d), 0);
-    pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton(215, 199, 17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "",
-        pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0);
-    pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 0x143, 0x11, 0x11, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "",
-        pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0);
-
-    }
+    pBtnLoadSlot  = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_LoadSlot, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_LS_), 0);
+    pBtnCancel    = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_x_d), 0);
+    pBtnArrowUp   = pGUIWindow_CurrentMenu->CreateButton(215, 199,  17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0);
+    pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 323,  17, 17, 1, 0, UIMSG_DownArrow, uNumSavegameFiles, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0);
+}
 
 //----- (0045E93E) --------------------------------------------------------
 void  GameUI_DrawSaveMenu()
-    {
+{
     unsigned int v0; // ebp@4
     unsigned int v1; // eax@4
     char *v3; // eax@7
@@ -411,22 +406,20 @@
     uTextureID_LS_loadU = pIcons_LOD->LoadTexture("LS_loadU", TEXTURE_16BIT_PALETTE);
     uTextureID_LS_saveU = pIcons_LOD->LoadTexture("LS_saveU", TEXTURE_16BIT_PALETTE);
     uTextureID_x_u = pIcons_LOD->LoadTexture("x_u", TEXTURE_16BIT_PALETTE);
-    pRenderer->DrawTextureIndexed( 8u, 8u,
-        (Texture *)(uTextureID_loadsave != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_loadsave] : 0));
+    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_loadsave));
     if ( pCurrentScreen == SCREEN_SAVEGAME )
-        {
+    {
         v0 = uTextureID_save_up;
         v1 = uTextureID_LS_saveU;
         }
     else
-        {
+    {
         v0 = uTextureID_load_up;
         v1 = uTextureID_LS_loadU;
         }
-    pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, (Texture *)(v1 != -1 ? (int)&pIcons_LOD->pTextures[v1] : 0));
-    pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu,
-        (Texture *)(uTextureID_x_u != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_u] : 0));
-    pRenderer->DrawTextureIndexed(0x12u, 0x8Du, (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0));
+    pRenderer->DrawTextureIndexed(0xF1u, 0x12Eu, pIcons_LOD->GetTexture(v1));
+    pRenderer->DrawTextureIndexed(0x15Fu, 0x12Eu, pIcons_LOD->GetTexture(uTextureID_x_u));
+    pRenderer->DrawTextureIndexed(0x12u, 0x8Du, pIcons_LOD->GetTexture(v0));
     pGUIWindow_CurrentMenu->DrawText(pFontSmallnum, 25, 199, 0, pGlobalTXT_LocalizationStrings[505], 0, 0, 0);
     pRenderer->Present();
     pSavegameList->Initialize(1u);
@@ -472,19 +465,15 @@
     uTextureID_AR_UP_DN = pIcons_LOD->LoadTexture("AR_UP_DN", TEXTURE_16BIT_PALETTE);
     uTextureID_AR_DN_DN = pIcons_LOD->LoadTexture("AR_DN_DN", TEXTURE_16BIT_PALETTE);
     pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_17, 0, 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 198u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 218u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 1u, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 238u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 2u, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 258u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 3u, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 278u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 4u, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 298u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 5u, 0, "", 0);
-    pGUIWindow_CurrentMenu->CreateButton(21u, 318u, 0xBFu, 0x12u, 1, 0, UIMSG_SelectLoadSlot, 6u, 0, "", 0);
-    pBtnLoadSlot = pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_LoadSlot, 0, 0, "",
-        (Texture *)(uTextureID_LS_ != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_LS_] : 0), 0);
-    pBtnCancel = pGUIWindow_CurrentMenu->CreateButton(0x15Eu, 0x12Eu, 0x69u, 0x28u, 1, 0, UIMSG_Cancel, 0, 0, "",
-        (Texture *)(uTextureID_x_d != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_x_d] : 0), 0);
-    pBtnArrowUp = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0xC7u, 0x11u, 0x11u, 1, 0, UIMSG_ArrowUp, 0, 0, "",
-        (Texture *)(uTextureID_AR_UP_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_UP_DN] : 0), 0);
-    pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton( 0xD7u, 0x143u, 0x11u, 0x11u, 1, 0, UIMSG_DownArrow, 0x22u, 0, "",
-        (Texture *)(uTextureID_AR_DN_DN != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_AR_DN_DN] : 0), 0);
-    }
+    pGUIWindow_CurrentMenu->CreateButton(21, 198, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 0, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 218, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 1, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 238, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 2, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 258, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 3, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 278, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 4, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 298, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 5, 0, "", 0);
+    pGUIWindow_CurrentMenu->CreateButton(21, 318, 191, 18, 1, 0, UIMSG_SelectLoadSlot, 6, 0, "", 0);
+    pBtnLoadSlot  = pGUIWindow_CurrentMenu->CreateButton(241, 302, 105, 40, 1, 0, UIMSG_LoadSlot, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_LS_), 0);
+    pBtnCancel    = pGUIWindow_CurrentMenu->CreateButton(350, 302, 105, 40, 1, 0, UIMSG_Cancel, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_x_d), 0);
+    pBtnArrowUp   = pGUIWindow_CurrentMenu->CreateButton(215, 199,  17, 17, 1, 0, UIMSG_ArrowUp, 0, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_UP_DN), 0);
+    pBtnDownArrow = pGUIWindow_CurrentMenu->CreateButton(215, 323,  17, 17, 1, 0, UIMSG_DownArrow, 34, 0, "", pIcons_LOD->GetTexture(uTextureID_AR_DN_DN), 0);
+}
--- a/UiGame.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/UiGame.cpp	Wed May 01 23:36:54 2013 +0600
@@ -131,26 +131,15 @@
     }
   }
   v8 = a2->uFrameX + (signed int)(a2->uFrameWidth - v4) / 2;
+
   pRenderer->SetTextureClipRect(v8, a2->uFrameY + 32, v8 + v4, a2->uFrameY + 52);
-  pRenderer->DrawTextureIndexed(
-    v8,
-    v3->uFrameY + 32,
-    (Texture *)(uTextureID_mhp_bd != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_mhp_bd] : 0));
+  pRenderer->DrawTextureIndexed(v8, v3->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_bd));
   pRenderer->SetTextureClipRect(v8, v3->uFrameY + 32, v8 + v10, v3->uFrameY + 52);
-  pRenderer->DrawTextureIndexed(
-    v8,
-    v3->uFrameY + 34,
-    (Texture *)(v9 != -1 ? (int)&pIcons_LOD->pTextures[v9] : 0));
-  pRenderer->ResetTextureClipRect();
+  pRenderer->DrawTextureIndexed(v8, v3->uFrameY + 34, pIcons_LOD->GetTexture(v9));
 
-  pRenderer->DrawTextureIndexed(
-    v8 - 5,
-    v3->uFrameY + 32,
-    (Texture *)(uTextureID_mhp_capl != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_mhp_capl] : 0));
-  pRenderer->DrawTextureIndexed(
-    v8 + v4,
-    v3->uFrameY + 32,
-    (Texture *)(uTextureID_mhp_capr != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_mhp_capr] : 0));
+  pRenderer->ResetTextureClipRect();
+  pRenderer->DrawTextureIndexed(v8 - 5, v3->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_capl));
+  pRenderer->DrawTextureIndexed(v8 + v4, v3->uFrameY + 32, pIcons_LOD->GetTexture(uTextureID_mhp_capr));
 }
 
 //----- (0041B0C9) --------------------------------------------------------
@@ -175,12 +164,12 @@
   signed int v16; // [sp+24h] [bp-8h]@1
   signed int v17; // [sp+28h] [bp-4h]@8
 
-  v0 = (Texture *)(uTextureID_BarGreen != -1 ? &pIcons_LOD->pTextures[uTextureID_BarGreen] : 0);
-  v14 = (Texture *)(uTextureID_BarYellow != -1 ? &pIcons_LOD->pTextures[uTextureID_BarYellow] : 0);
-  v13 = (Texture *)(uTextureID_BarRed != -1 ? &pIcons_LOD->pTextures[uTextureID_BarRed] : 0);
+  v0 = pIcons_LOD->GetTexture(uTextureID_BarGreen);
+  v14 = pIcons_LOD->GetTexture(uTextureID_BarYellow);
+  v13 = pIcons_LOD->GetTexture(uTextureID_BarRed);
   v16 = 0;
-  v10 = (Texture *)(uTextureID_BarBlue != -1 ? &pIcons_LOD->pTextures[uTextureID_BarBlue] : 0);
-  v15 = (double)(uTextureID_BarGreen != -1 ? pIcons_LOD->pTextures[uTextureID_BarGreen].uTextureHeight : 26);
+  v10 = pIcons_LOD->GetTexture(uTextureID_BarBlue);
+  v15 = v0->uTextureHeight;
   do
   {
     v1 = &pParty->pPlayers[v16];
@@ -263,8 +252,7 @@
 //----- (0041B3B6) --------------------------------------------------------
 void __cdecl draw_right_panel()
 {
-  pRenderer->DrawTextureTransparent(pViewport->uViewportBR_X, 0,
-    (Texture *)(uTextureID_right_panel != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_right_panel] : 0));
+  pRenderer->DrawTextureTransparent(pViewport->uViewportBR_X, 0, pIcons_LOD->GetTexture(uTextureID_right_panel));
 }
 
 //----- (0041B3E2) --------------------------------------------------------
@@ -1238,45 +1226,46 @@
   bRingsShownInCharScreen = 0;
   CharacterUI_LoadPaperdollTextures();
   pCurrentScreen = v1;
+
   pWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_CharacterRecord, uActiveCharacter, 0);
   pCharacterScreen_StatsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 12, pViewport->uViewportTL_Y + 308,
-                                (papredoll_dbrds[9] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[9]].uTextureWidth : 24),
-                                (papredoll_dbrds[9] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[9]].uTextureHeight : 26),
-                                1, 0, UIMSG_73, 0, 0x53u, pGlobalTXT_LocalizationStrings[216],// Stats
-                                (Texture *)(papredoll_dbrds[10] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[10]] : 0),
-                                papredoll_dbrds[9] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[9]] : 0, 0);
+                                pIcons_LOD->GetTexture(papredoll_dbrds[9])->uTextureWidth,
+                                pIcons_LOD->GetTexture(papredoll_dbrds[9])->uTextureHeight,
+                                1, 0, UIMSG_73, 0, 'S', pGlobalTXT_LocalizationStrings[216],// Stats
+                                pIcons_LOD->GetTexture(papredoll_dbrds[10]),
+                                pIcons_LOD->GetTexture(papredoll_dbrds[9]), 0);
   pCharacterScreen_SkillsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 102, pViewport->uViewportTL_Y + 308,
-                                 (papredoll_dbrds[7] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[7]].uTextureWidth : 24),
-                                 (papredoll_dbrds[7] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[7]].uTextureHeight : 26),
-                                 1, 0, UIMSG_72, 0, 0x4Bu, pGlobalTXT_LocalizationStrings[205],//Skills
-                                 (Texture *)(papredoll_dbrds[8] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[8]] : 0),
-                                 papredoll_dbrds[7] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[7]] : 0, 0);
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[7])->uTextureWidth,
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[7])->uTextureHeight,
+                                 1, 0, UIMSG_72, 0, 'K', pGlobalTXT_LocalizationStrings[205],//Skills
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[8]),
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[7]), 0);
   pCharacterScreen_InventoryBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 192, pViewport->uViewportTL_Y + 308,
-                                    (papredoll_dbrds[5] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[5]].uTextureWidth : 24),
-                                    (papredoll_dbrds[5] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[5]].uTextureHeight : 26),
-                                    1, 0, UIMSG_74, 0, 0x49u, pGlobalTXT_LocalizationStrings[120], //Inventory
-                                    (Texture *)(papredoll_dbrds[6] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[6]] : 0),
-                                    papredoll_dbrds[5] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[5]] : 0, 0);
+                                    pIcons_LOD->GetTexture(papredoll_dbrds[5])->uTextureWidth,
+                                    pIcons_LOD->GetTexture(papredoll_dbrds[5])->uTextureHeight,
+                                    1, 0, UIMSG_74, 0, 'I', pGlobalTXT_LocalizationStrings[120], //Inventory
+                                    pIcons_LOD->GetTexture(papredoll_dbrds[6]),
+                                    pIcons_LOD->GetTexture(papredoll_dbrds[5]), 0);
   pCharacterScreen_AwardsBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 282, pViewport->uViewportTL_Y + 308,
-                                 (papredoll_dbrds[3] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[3]].uTextureWidth : 24),
-                                 (papredoll_dbrds[3] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[3]].uTextureHeight : 26),
-                                 1, 0, UIMSG_75, 0, 0x41u, pGlobalTXT_LocalizationStrings[22], //Awards
-                                 (Texture *)(papredoll_dbrds[4] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[4]] : 0),
-                                 papredoll_dbrds[3] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[3]] : 0, 0);
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[3])->uTextureWidth,
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[3])->uTextureHeight,
+                                 1, 0, UIMSG_75, 0, 'A', pGlobalTXT_LocalizationStrings[22], //Awards
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[4]),
+                                 pIcons_LOD->GetTexture(papredoll_dbrds[3]), 0);
   pCharacterScreen_ExitBtn = pWindow->CreateButton(pViewport->uViewportTL_X + 371, pViewport->uViewportTL_Y + 308,
-                 (papredoll_dbrds[1] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[1]].uTextureWidth : 24),
-                 (papredoll_dbrds[1] != -1 ? pIcons_LOD->pTextures[papredoll_dbrds[1]].uTextureHeight : 26),
+                 pIcons_LOD->GetTexture(papredoll_dbrds[1])->uTextureWidth,
+                 pIcons_LOD->GetTexture(papredoll_dbrds[1])->uTextureHeight,
                  1, 0, UIMSG_A8, 0, 0, pGlobalTXT_LocalizationStrings[79],//Exit
-                 (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
-                 papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0, 0);
+                 pIcons_LOD->GetTexture(papredoll_dbrds[2]),
+                 pIcons_LOD->GetTexture(papredoll_dbrds[1]), 0);
   pWindow->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, UIMSG_InventoryLeftClick, 0, 0, "", 0);
   pCharacterScreen_DetalizBtn = pWindow->CreateButton(0x258u, 0x12Cu, 0x1Eu, 0x1Eu, 1, 0, UIMSG_ChangeDetaliz, 0, 0, pGlobalTXT_LocalizationStrings[64], 0);
   pCharacterScreen_DollBtn = pWindow->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 0);
-  pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-  pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-  pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-  pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
-  pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, 9u, "", 0);
+  pWindow->CreateButton(0x3Du, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
+  pWindow->CreateButton(0xB1u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
+  pWindow->CreateButton(0x124u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
+  pWindow->CreateButton(0x197u, 0x1A8u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0);
+  pWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_CycleCharacters, 0, '\t', "", 0);
   FillAwardsData();
   return pWindow;
 }
@@ -1415,8 +1404,7 @@
                             if ( pParty->uFlags & 0x20 )
                                 v16 = dword_5079C8;
                             }
-                        pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[PID_ID(pElem->uPackedID)] - 4,
-                            0x181u, (Texture *)(v16 != -1 ? &pIcons_LOD->pTextures[v16] : 0));
+                        pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[PID_ID(pElem->uPackedID)] - 4, 0x181u, pIcons_LOD->GetTexture(v16));
                         }
                     }
                 }
@@ -1439,8 +1427,7 @@
                     if ( pParty->uFlags & 0x20 )
                         v19 = dword_5079C8;
                     }
-                pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4,
-                    0x181u, (Texture *)(v19 != -1 ? &pIcons_LOD->pTextures[v19] : 0));
+                pRenderer->DrawTextureTransparent(pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4, 0x181u, pIcons_LOD->GetTexture(v19));
                 }
             }
         }
@@ -1521,8 +1508,8 @@
   uCenterX = (uX + uZ) / 2;
   uCenterY = (uY + uW) / 2;
   lPitch = pRenderer->uTargetSurfacePitch;
-  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0);
-  uBlue = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xFFu);
+  TargetColor(0, 0, 0);
+  uBlue = TargetColor(0, 0, 0xFFu);
   auto bWizardEyeActive = pParty->WizardEyeActive();
   auto uWizardEyeSkillLevel = pParty->WizardEyeSkillLevel();
   if (CheckHiredNPCSpeciality(Cartographer))
@@ -1703,8 +1690,8 @@
   uint arrow_idx = floorf(0.5f + 7 * angle);
   pRenderer->DrawTextureTransparent(uCenterX - 3, uCenterY - 3, pIcons_LOD->GetTexture(pTextureIDs_pMapDirs[arrow_idx]));
 
-  flagsb = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 255);
-  v60 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 0, 0);
+  flagsb = TargetColor(0, 0, 255);
+  v60 = TargetColor(255, 0, 0);
   if (bWizardEyeActive)
   {
     //uZe = 0;
@@ -1763,9 +1750,9 @@
 
 
 LABEL_85:
-    v63 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 0, 0);
-    v61 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 255, 0);
-    v65 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 0);
+    v63 = TargetColor(255, 0, 0);
+    v61 = TargetColor(0, 255, 0);
+    v65 = TargetColor(255, 255, 0);
     uZf = 0;
     if ( (signed int)uNumActors > 0 )
     {
@@ -1825,7 +1812,7 @@
   }
 
 
-  flagsd = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 255);
+  flagsd = TargetColor(255, 255, 255);
   uZg = 0;
   if ( (signed int)uNumLevelDecorations > 0 )
   {
@@ -1865,11 +1852,11 @@
     }
     while ( uZg < (signed int)uNumLevelDecorations );
   }
-  pRenderer->DrawTextureTransparent(0x1D4u, 0, (Texture *)(dword_5079D8 != -1 ? &pIcons_LOD->pTextures[dword_5079D8] : 0));
+  pRenderer->DrawTextureTransparent(0x1D4u, 0, pIcons_LOD->GetTexture(dword_5079D8));
   uZooma = (double)pParty->sRotationY * 0.1171875;
   //v50 = uZooma + 6.7553994e15;
   pRenderer->SetTextureClipRect(541, 0, 567, 480);
-  pRenderer->DrawTextureIndexed(floorf(uZooma + 0.5f) + 285, 136, (Texture *)(dword_5079B4 != -1 ? &pIcons_LOD->pTextures[dword_5079B4] : 0));
+  pRenderer->DrawTextureIndexed(floorf(uZooma + 0.5f) + 285, 136, pIcons_LOD->GetTexture(dword_5079B4));
   pRenderer->ResetTextureClipRect();
 }
 
@@ -1959,14 +1946,14 @@
       {
         sprintf(pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID);
         v15 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
-        pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v23], pHiredNPCsIconsOffsetsY[v23], (Texture *)(v15 != -1 ? &pIcons_LOD->pTextures[v15] : 0));
+        pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v23], pHiredNPCsIconsOffsetsY[v23], pIcons_LOD->GetTexture(v15));
       }
       else
       {
         sprintf(pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID);
         v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
         v9 = v23;
-        pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v9], pHiredNPCsIconsOffsetsY[v9], (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0));
+        pRenderer->DrawTextureIndexed(pHiredNPCsIconsOffsetsX[v9], pHiredNPCsIconsOffsetsY[v9], pIcons_LOD->GetTexture(v8));
         v10 = (unsigned __int8)pTmpBuf[i];
         if ( pParty->pHirelings[v10].evt_A == 1 )
         {
--- a/Viewport.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/Viewport.cpp	Wed May 01 23:36:54 2013 +0600
@@ -172,7 +172,7 @@
 void ViewingParams::InitGrayPalette()
     {
     for  (unsigned short i=0; i<256; ++i)
-        pPalette[i]=GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(i, i, i);
+        pPalette[i]=TargetColor(i, i, i);
     }
 
 //----- (00443365) --------------------------------------------------------
--- a/mm7_1.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/mm7_1.cpp	Wed May 01 23:36:54 2013 +0600
@@ -446,7 +446,7 @@
     pTexture_RestUI_CurrentHourglassFrame->Release();
   pIcons_LOD->_40F9C5();
   sprintf(pTmpBuf, "TERRA%03d", pParty->uCurrentMinute / 6 + 10 * pParty->uCurrentHour);
-  pTexture_RestUI_CurrentSkyFrame = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pTmpBuf, TEXTURE_16BIT_PALETTE)];
+  pTexture_RestUI_CurrentSkyFrame = pIcons_LOD->LoadTexturePtr(pTmpBuf, TEXTURE_16BIT_PALETTE);
 }
 
 //----- (0041F5BE) --------------------------------------------------------
@@ -694,15 +694,14 @@
   v2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_CastSpell_InInventory, v1, 0);
   pCharacterScreen_ExitBtn = v2->CreateButton(394, 318, 75, 33, 1, 0, UIMSG_A8, 0, 0,
                  pGlobalTXT_LocalizationStrings[79], // Close
-                 (Texture *)(papredoll_dbrds[2] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[2]] : 0),
-                 papredoll_dbrds[1] != -1 ? (int)&pIcons_LOD->pTextures[papredoll_dbrds[1]] : 0,
-                 0);
+                 pIcons_LOD->GetTexture(papredoll_dbrds[2]),
+                 pIcons_LOD->GetTexture(papredoll_dbrds[1]), 0);
   v2->CreateButton(0, 0, 0x1DCu, 0x159u, 1, 122, UIMSG_InventoryLeftClick, 0, 0, "", 0);
   pCharacterScreen_DollBtn = v2->CreateButton(0x1DCu, 0, 0xA4u, 0x159u, 1, 0, UIMSG_ClickPaperdoll, 0, 0, "", 0);
-  v2->CreateButton(61u, 424u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-  v2->CreateButton(177u, 424u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-  v2->CreateButton(292u, 424u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-  v2->CreateButton(407u, 424u, 0x1Fu, 0, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
+  v2->CreateButton( 61, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
+  v2->CreateButton(177, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
+  v2->CreateButton(292, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
+  v2->CreateButton(407, 424, 31, 0, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0);
   return v2;
 }
 
@@ -727,7 +726,7 @@
   v0 = pIcons_LOD->LoadTexture(
          pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName,
          TEXTURE_16BIT_PALETTE);
-  v1 = (Texture *)(v0 != -1 ? (int)&pIcons_LOD->pTextures[v0] : 0);
+  v1 = pIcons_LOD->GetTexture(v0);
   v11 = areWeLoadingTexture;
   if ( uActiveCharacter
     && (v2 = pPlayers[uActiveCharacter]->AddItem(0xFFFFFFFFu, pParty->pPickedItem.uItemID)) != 0 )
@@ -1411,7 +1410,7 @@
         pUIAnum_Torchlight->uIconID = pIconsFrameTable->FindIcon("torchC");
         pIconsFrameTable->InitializeAnimation((signed __int16)pUIAnum_Torchlight->uIconID);
       }
-      v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xC8u, 0, 0);
+      v3 = TargetColor(0xC8u, 0, 0);
       v4 = 0;
       v6 = 0;
       v5 = 10;
@@ -1504,10 +1503,10 @@
         uTextureID_5076A0 = pIcons_LOD->LoadTexture("edge_lf", TEXTURE_16BIT_PALETTE);
         uTextureID_50769C = pIcons_LOD->LoadTexture("edge_rt", TEXTURE_16BIT_PALETTE);
         uTextureID_507698 = pIcons_LOD->LoadTexture("edge_top", TEXTURE_16BIT_PALETTE);
-        pTexture_591428 = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("endcap", TEXTURE_16BIT_PALETTE)];
+        pTexture_591428 = pIcons_LOD->LoadTexturePtr("endcap", TEXTURE_16BIT_PALETTE);
 
       }
-      v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xAu, 0, 0);
+      v3 = TargetColor(0xAu, 0, 0);
       v4 = 214;
       v5 = 230;
       v6 = 193;
@@ -1558,7 +1557,7 @@
       pIcons_LOD->ReloadTexture(&pIcons_LOD->pTextures[uTextureID_507698], "edge_top-b", 2);
       pIcons_LOD->ReloadTexture(pTexture_591428, "endcap-b", 2);
     }
-    v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0, 0xC8u);
+    v3 = TargetColor(0, 0, 0xC8u);
     v5 = 255;
     v4 = 225;
     v6 = 255;
@@ -1566,7 +1565,7 @@
   else assert(false);
 
   uGameUIFontMain = v3;
-  uGameUIFontShadow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v5, v4, v6);
+  uGameUIFontShadow = TargetColor(v5, v4, v6);
 }
 
 //----- (00423AEE) --------------------------------------------------------
--- a/mm7_2.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/mm7_2.cpp	Wed May 01 23:36:54 2013 +0600
@@ -290,7 +290,7 @@
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 350, WINDOW_MainMenu, 0, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton(471u, 445u, 169u, 35u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34],// "Cancel"
-                 (Texture *)(uExitCancelTextureId != -1 ? &pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0);
+                 pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
   pDialogueWindow->CreateButton(480u, 160u, 140u, 30u, 1, 0, UIMSG_0, 0x53u, 0, "", 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
@@ -433,7 +433,7 @@
     pDialogueWindow->pControlsTail = 0;
     pDialogueWindow->uNumControls = 0;
     pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7u, 0x1BDu, 0xA9u, 0x23u, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[79],
-                   (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0), 0);
+                   pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x55u, 0, "", 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xBEu, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x56u, 0, "", 0);
     pDialogueWindow->CreateButton(0x1E0u, 0xDCu, 0x8Cu, 0x1Eu, 1, 0, UIMSG_SelectNPCDialogueOption, 0x57u, 0, "", 0);
@@ -578,12 +578,8 @@
       pViewport->uViewportBR_Y - pViewport->uViewportTL_Y + 1,
       pRenderer->uTargetGMask | pRenderer->uTargetBMask);
 
-  auto pTex = (uTextureID_Leather != -1 ? &pIcons_LOD->pTextures[uTextureID_Leather] : nullptr);
-  pRenderer->_4A6A68(
-    8u,
-    352 - v0,
-    pTex,
-    (pTex ? pTex->uTextureHeight : 26) - v0);
+  auto pTex = pIcons_LOD->GetTexture(uTextureID_Leather);
+  pRenderer->_4A6A68(8, 352 - v0, pTex, pTex->uTextureHeight - v0);
 
   pRenderer->DrawTextureIndexed(8u, 347 - v0, pTexture_591428);
   v1 = FitTextInAWindow(pGlobalTXT_LocalizationStrings[575], pFontArrus, &window, 0xDu, 0);
@@ -770,7 +766,7 @@
     item_spellbook->Reset();
     pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].uItemID = pItemNum;
     pParty->SpellBooksInGuilds[window_SpeakInHouse->par1C-139][i].Identified();
-    ItemsInShopTexture[i] = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pItemsTable->pItems[pItemNum].pIconName, TEXTURE_16BIT_PALETTE)];
+    ItemsInShopTexture[i] = pIcons_LOD->LoadTexturePtr(pItemsTable->pItems[pItemNum].pIconName, TEXTURE_16BIT_PALETTE);
   }
   return;
 }
@@ -5529,7 +5525,7 @@
               v4 = 255;
               v1 = 15;
               v2 = 235;
-              return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+              return TargetColor(v2, v1, v4);
             }
             goto LABEL_21;
           }
@@ -5549,7 +5545,7 @@
           v4 = v2;
 LABEL_30:
           v1 = v2;
-          return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+          return TargetColor(v2, v1, v4);
         }
         goto LABEL_15;
       }
@@ -5560,7 +5556,7 @@
         v1 = 128;
 LABEL_32:
         v2 = 0;
-        return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+        return TargetColor(v2, v1, v4);
       }
       goto LABEL_11;
     }
@@ -5573,7 +5569,7 @@
       v1 = 85;
 LABEL_23:
       v2 = 255;
-      return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+      return TargetColor(v2, v1, v4);
     }
   }
   if ( a1 >= 23 )
@@ -5581,7 +5577,7 @@
   v4 = 255;
   v1 = 212;
   v2 = 150;
-  return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v2, v1, v4);
+  return TargetColor(v2, v1, v4);
 }
 
 //----- (004583B0) --------------------------------------------------------
@@ -6650,17 +6646,15 @@
 
   pWindow_MainMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
   auto pNew = pIcons_LOD->LoadTexturePtr("title_new", TEXTURE_16BIT_PALETTE);
-  pMainMenu_BtnNew = pWindow_MainMenu->CreateButton(495, 172, pNew->uTextureWidth, pNew->uTextureHeight, 1, 0, 
-                                                    UIMSG_MainMenu_ShowPartyCreationWnd, 0, 78, "", pNew, 0);
   auto pLoad = pIcons_LOD->LoadTexturePtr("title_load", TEXTURE_16BIT_PALETTE);
-  pMainMenu_BtnLoad = pWindow_MainMenu->CreateButton(495, 227, pLoad->uTextureWidth, pLoad->uTextureHeight, 1, 0, 
-                                                     UIMSG_MainMenu_ShowLoadWindow, 1, 76, "", pLoad, 0);
   auto pCredits = pIcons_LOD->LoadTexturePtr("title_cred", TEXTURE_16BIT_PALETTE);
-  pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, 
-                                                         UIMSG_ShowCredits, 2, 67, "", pCredits, 0);
   auto pExit = pIcons_LOD->LoadTexturePtr("title_exit", TEXTURE_16BIT_PALETTE);
-  pMainMenu_BtnExit = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth, pExit->uTextureHeight, 1, 0, 
-                                                        UIMSG_ExitToWindows, 3, 0, "", pExit, 0);
+
+  pMainMenu_BtnNew     = pWindow_MainMenu->CreateButton(495, 172, pNew->uTextureWidth,     pNew->uTextureHeight,     1, 0, UIMSG_MainMenu_ShowPartyCreationWnd, 0, 'N', "", pNew, 0);
+  pMainMenu_BtnLoad    = pWindow_MainMenu->CreateButton(495, 227, pLoad->uTextureWidth,    pLoad->uTextureHeight,    1, 0, UIMSG_MainMenu_ShowLoadWindow,       1, 'L', "", pLoad, 0);
+  pMainMenu_BtnCredits = pWindow_MainMenu->CreateButton(495, 282, pCredits->uTextureWidth, pCredits->uTextureHeight, 1, 0, UIMSG_ShowCredits,                   2, 'C', "", pCredits, 0);
+  pMainMenu_BtnExit    = pWindow_MainMenu->CreateButton(495, 337, pExit->uTextureWidth,    pExit->uTextureHeight,    1, 0, UIMSG_ExitToWindows,                 3, 0, "", pExit, 0);
+
   pTexture_PCX.Release();
   pTexture_PCX.Load("title.pcx", 0);
   SetCurrentMenuID(MENU_MAIN);
@@ -6827,7 +6821,9 @@
     {
       switch (wParam)
       {
-        case 101:
+        case 103:  pRenderer->SavePCXScreenshot();  return 0;
+
+        case 101:  // Quit game
         case 40001:
         {
           v38 = 0;
@@ -6838,9 +6834,6 @@
         }
         return 0;
 
-        case 103:
-          pRenderer->SavePCXScreenshot();
-        return 0;
 
         case 104:
           pRenderer->ChangeBetweenWinFullscreenModes();
@@ -6848,95 +6841,33 @@
             pArcomageGame->field_F6 = 1;
         return 0;
 
-        case 40007:
-          pParty->SetGold(pParty->uNumGold + 10000);
-        return 0;
-
-        case 40008:
-          GivePartyExp(20000);
-        return 0;
-
-        case 40013:
-          pParty->SetGold(0);
-        return 0;
+        case 40007:  pParty->SetGold(pParty->uNumGold + 10000); return 0;
+        case 40008:  GivePartyExp(20000);  return 0;
+        case 40013:  pParty->SetGold(0);   return 0;
 
         case 40059:
           for (uint i = 0; i < 4; ++i)
             pParty->pPlayers[i].uSkillPoints = 50;
         return 0;
-
-        case 40044://condition Afraid/fear
-          pPlayers[uActiveCharacter]->pConditions[3] = 1;
-        return 0;
-
-        case 40043://condition Asleep
-          pPlayers[uActiveCharacter]->pConditions[2] = 1;
-        return 0;
-
-        case 40037://condition Curse
-          pPlayers[uActiveCharacter]->pConditions[0] = 1;
-        return 0;
-
-        case 40036://condition Disease1
-          pPlayers[uActiveCharacter]->pConditions[7] = 1;
-        return 0;
-
-        case 40035://condition Disease2
-          pPlayers[uActiveCharacter]->pConditions[9] = 1;
-        return 0;
-
-        case 40034://condition Disease3
-          pPlayers[uActiveCharacter]->pConditions[11] = 1;
-        return 0;
-
-        case 40041://condition Dead
-          pPlayers[uActiveCharacter]->pConditions[14] = 1;
-        return 0;
-
-        case 40039://condition Drunk
-          pPlayers[uActiveCharacter]->pConditions[4] = 1;
-        return 0;
-
-        case 40042://condition Eradicated
-          pPlayers[uActiveCharacter]->pConditions[16] = 1;
-        return 0;
-
-        case 40038://condition Isane
-          pPlayers[uActiveCharacter]->pConditions[5] = 1;
-        return 0;
-
-        case 40045://condition Paralized
-          pPlayers[uActiveCharacter]->pConditions[12] = 1;
-        return 0;
-
-        case 40033://condition Poison1
-          pPlayers[uActiveCharacter]->pConditions[6] = 1;
-        return 0;
-
-        case 40032://condition Poison2
-          pPlayers[uActiveCharacter]->pConditions[8] = 1;
-        return 0;
-
-        case 40031://condition Poison3
-          pPlayers[uActiveCharacter]->pConditions[10] = 1;
-        return 0;
-
-        case 40029://condition Stone
-          pPlayers[uActiveCharacter]->pConditions[15] = 1;
-        return 0;
-
-        case 40040://condition Unconscious
-          pPlayers[uActiveCharacter]->pConditions[13] = 1;
-        return 0;
-
-        case 40030://condition Weak
-          pPlayers[uActiveCharacter]->pConditions[1] = 1;
-        return 0;
-
-        case 40073://condition Zombie
-          pPlayers[uActiveCharacter]->pConditions[17] = 1;
-        return 0;
-
+        
+        case 40029:  pPlayers[uActiveCharacter]->SetPertified(true);  return 0;
+        case 40030:  pPlayers[uActiveCharacter]->SetWeak(true);       return 0;
+        case 40031:  pPlayers[uActiveCharacter]->SetPoison3(true);    return 0;
+        case 40032:  pPlayers[uActiveCharacter]->SetPoison2(true);    return 0;
+        case 40033:  pPlayers[uActiveCharacter]->SetPoison1(true);    return 0;
+        case 40034:  pPlayers[uActiveCharacter]->SetDisease3(true);   return 0;
+        case 40035:  pPlayers[uActiveCharacter]->SetDisease2(true);   return 0;
+        case 40036:  pPlayers[uActiveCharacter]->SetDisease1(true);   return 0;
+        case 40037:  pPlayers[uActiveCharacter]->SetCursed(true);     return 0;
+        case 40038:  pPlayers[uActiveCharacter]->SetInsane(true);     return 0;
+        case 40039:  pPlayers[uActiveCharacter]->SetDrunk(true);      return 0;
+        case 40040:  pPlayers[uActiveCharacter]->SetUnconcious(true); return 0;
+        case 40041:  pPlayers[uActiveCharacter]->SetDead(true);       return 0;
+        case 40042:  pPlayers[uActiveCharacter]->SetEradicated(true); return 0;
+        case 40043:  pPlayers[uActiveCharacter]->SetAsleep(true);     return 0;
+        case 40044:  pPlayers[uActiveCharacter]->SetAfraid(true);     return 0;
+        case 40045:  pPlayers[uActiveCharacter]->SetParalyzed(true);  return 0;
+        case 40073:  pPlayers[uActiveCharacter]->SetZombie(true);     return 0;
       }
     }
     return DefWindowProcA(hWnd, Msg, wParam, lParam);
@@ -9944,7 +9875,7 @@
   a1.uFrameZ = a1.uFrameWidth + a1.uFrameX - 1;
   a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
   v1 = pItemsTable->pItems[(unsigned int)pGUIWindow_ScrollWindow->ptr_1C + 700].pName;
-  v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v2 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, format_4E2D80, v2, v1);
   a1.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3u);
   return a1.DrawText(
--- a/mm7_3.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/mm7_3.cpp	Wed May 01 23:36:54 2013 +0600
@@ -4548,9 +4548,9 @@
         v48 = pTextureFrameTable->GetFrameTexture(v9, pEventTimer->uTotalGameTimeElapsed);
         v9 = v48;
       }
-      pFaceTexture = (Texture *)(v9 != -1 ? (int)&pBitmaps_LOD->pTextures[v9] : 0);
+      pFaceTexture = pBitmaps_LOD->GetTexture(v9);
       v7->pTexture = pFaceTexture;
-      v12 = (v9 != -1 ? pBitmaps_LOD->pTextures[v9].uTextureWidth : 24);
+      v12 = pFaceTexture->uTextureWidth;
       v49 = v12;
       v49 = pFaceTexture->uTextureHeight;
       v10 = (pFace->uAttributes & 0x10) == 0;
@@ -12316,8 +12316,8 @@
     default: assert(false);
   }
 
-  pTexture_Dialogue_Background = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE)];
-  pTexture_outside = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture("outside", TEXTURE_16BIT_PALETTE)];
+  pTexture_Dialogue_Background = pIcons_LOD->LoadTexturePtr(pContainer, TEXTURE_16BIT_PALETTE);
+  pTexture_outside = pIcons_LOD->LoadTexturePtr("outside", TEXTURE_16BIT_PALETTE);
   v1 = pMapStats->GetMapInfo(pCurrentMapName);
   if ( v1 )
     sprintfex(sHouseName, pGlobalTXT_LocalizationStrings[410], pMapStats->pInfos[v1].pName);// "Leave %s"
@@ -12482,11 +12482,11 @@
     dword_5C3418 = v4;
     dword_5C341C = v3;
     _591094_decoration = activeLevelDecoration;
-    pGUIWindow2 = GUIWindow::Create(0, 0, 640u, 480u, WINDOW_GreetingNPC, a4, 0);
-    pGUIWindow2->CreateButton(61u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 1u, 0x31u, "", 0);
-    pGUIWindow2->CreateButton(177u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 2u, 0x32u, "", 0);
-    pGUIWindow2->CreateButton(292u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 3u, 0x33u, "", 0);
-    pGUIWindow2->CreateButton(407u, 424u, 0x1Fu, 0x28u, 2, 94, UIMSG_SelectCharacter, 4u, 0x34u, "", 0);
+    pGUIWindow2 = GUIWindow::Create(0, 0, 640, 480, WINDOW_GreetingNPC, a4, 0);
+    pGUIWindow2->CreateButton( 61, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 1, '1', "", 0);
+    pGUIWindow2->CreateButton(177, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 2, '2', "", 0);
+    pGUIWindow2->CreateButton(292, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 3, '3', "", 0);
+    pGUIWindow2->CreateButton(407, 424, 31, 40, 2, 94, UIMSG_SelectCharacter, 4, '4', "", 0);
   }
 }
 
@@ -12581,9 +12581,9 @@
   v51.uFrameWidth -= 10;
   v51.uFrameZ -= 10;
   //v54 = v1;
-  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
+  TargetColor(0xFFu, 0xFFu, 0xFFu);
+  TargetColor(0xE1u, 0xCDu, 0x23u);
+  v2 = TargetColor(0x15u, 0x99u, 0xE9u);
   pRenderer->DrawTextureIndexed(477, 0, pTexture_Dialogue_Background);
   pRenderer->DrawTextureTransparent(468, 0, (Texture *)(uTextureID_right_panel_loop != -1 ? &pIcons_LOD->pTextures[uTextureID_right_panel_loop] : 0));
   pRenderer->DrawTextureIndexed(pNPCPortraits_x[0][0] - 4, pNPCPortraits_y[0][0] - 4, (Texture *)(uTextureID_50795C != -1 ? &pIcons_LOD->pTextures[uTextureID_50795C] : 0));
@@ -12819,8 +12819,8 @@
 
 
   v32 = 0;
-  //pInString = (char *)GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  v33 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  //pInString = (char *)TargetColor(0xFFu, 0xFFu, 0xFFu);
+  v33 = TargetColor(0xE1u, 0xCDu, 0x23u);
   v34 = pDialogueWindow;
   //v54 = v33;
   v35 = pDialogueWindow->pStartingPosActiveItem;
@@ -12864,7 +12864,7 @@
         v43->uW = v42;
         v47 = v33;
         if ( (unsigned __int16 *)pDialogueWindow->pCurrentPosActiveItem != v46 )
-          v47 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+          v47 = TargetColor(0xFFu, 0xFFu, 0xFFu);
         v52.DrawTitleText(pFontArrus, 0, v45, v47, Str, 3u);
         v34 = pDialogueWindow;
         ++v55;
--- a/mm7_4.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/mm7_4.cpp	Wed May 01 23:36:54 2013 +0600
@@ -3485,7 +3485,7 @@
 
   a1[0] = 0;
   pPlayer = &pParty->pPlayers[v6];
-  v59 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 155);
+  v59 = TargetColor(255, 255, 155);
   //v61 = pPlayer;
   memset(pTmpBuf2, 0, sizeof(pTmpBuf2));
 
@@ -6218,7 +6218,7 @@
   v7 = pSpellStats->pInfos[v1].pName;
   a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
   a1.uFrameW = a1.uFrameHeight + a1.uFrameY - 1;
-  v8 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v8 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   a1.DrawTitleText(pFontArrus, 0x78u, 0xCu, v8, v7, 3u);
   a1.DrawText(pFontSmallnum, 120, 44, 0, pTmpBuf2, 0, 0, 0);
   a1.uFrameZ = a1.uFrameX + 107;
@@ -6253,7 +6253,7 @@
     sprintf(pTmpBuf, pGlobalTXT_LocalizationStrings[427], pPlayer->pName, pGlobalTXT_LocalizationStrings[562]);// 
                                                 // "%s is in no condition to %s"
                                                 // "do anything"
-    v2 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(255, 255, 0x9Bu);
+    v2 = TargetColor(255, 255, 0x9Bu);
     v3 = pFontArrus->CalcTextHeight(pTmpBuf, &v4, 0, 0);
     v4.DrawTitleText(pFontArrus, 0, (212 - v3) / 2 + 101, v2, pTmpBuf, 3u);
     result = 0;
@@ -7286,8 +7286,8 @@
   a1.uFrameZ -= 10;
   v58 = HouseNPCData[(unsigned int)((char *)pDialogueNPCCount + -(dword_591080 != 0) - 1)];
   v6 = v58;
-  v55 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  v7 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x15u, 0x99u, 0xE9u);
+  v55 = TargetColor(0xE1u, 0xCDu, 0x23u);
+  v7 = TargetColor(0x15u, 0x99u, 0xE9u);
   v8 = v6->uProfession;
   if ( v8 )
     sprintfex(pTmpBuf, pGlobalTXT_LocalizationStrings[429], v6->pName, aNPCProfessionNames[v8]);
@@ -7366,9 +7366,9 @@
         if ( !v28 )
         {
           v29 = (char *)&pMonsterStats + 88 * word_F8B1A0;
-          v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
+          v30 = TargetColor(0xFFu, 0xFFu, 0xFFu);
           v31 = *(int *)v29;
-          v32 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+          v32 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
           sprintf(pTmpBuf, &byte_4F0F98, v32, v31, v30);
           sprintf(pTmpBuf2, dword_F8B1A4, pTmpBuf, 100 * (unsigned __int8)v29[8]);
           current_npc_text = pTmpBuf2;
@@ -7451,8 +7451,8 @@
     }
   }
   v34 = 0;
-  v54 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  v35 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
+  v54 = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  v35 = TargetColor(0xE1u, 0xCDu, 0x23u);
   v36 = v14->pStartingPosActiveItem;
   v55 = v35;
   for ( i = v36 + v14->pNumPresenceButton; (signed int)v36 < (signed int)i; i = pDialogueWindow->pNumPresenceButton
@@ -7802,10 +7802,9 @@
   ContractSelectText(pEventCode);
   pDialogueWindow->Release();
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15E, WINDOW_MainMenu, pEventCode, 0);
-  pBtn_ExitCancel = pDialogueWindow->CreateButton(0x1D7, 0x1BD, 0xA9, 0x23, 1, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[34], // Cancel
-                 pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
-  pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
-  pDialogueWindow->CreateButton(0x1E0u, 0xA0u, 0x8Cu, 0x1Eu, 1, 0, UIMSG_ClickNPCTopic, 0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0);
+  pBtn_ExitCancel = pDialogueWindow->CreateButton(471, 445, 169, 35, 1, 0, UIMSG_Escape,                    0, 0, pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uExitCancelTextureId), 0); // Cancel
+                    pDialogueWindow->CreateButton(  0,   0,   0,  0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
+                    pDialogueWindow->CreateButton(480, 160, 140, 30, 1, 0, UIMSG_ClickNPCTopic,             0x52u, 0, pGlobalTXT_LocalizationStrings[122], 0);
   pDialogueWindow->_41D08F(1, 1, 0, 2);
   dialog_menu_id = HOUSE_DIALOGUE_OTHER;
 }
@@ -7825,9 +7824,7 @@
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, v1, 0);
   v2 = "";
   pBtn_ExitCancel = pDialogueWindow->CreateButton( 0x1D7u, 0x1BDu, 0xA9u,  0x23u,   1,  0, UIMSG_Escape, 0,   0,
-                 pGlobalTXT_LocalizationStrings[34],
-                 (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0),
-                 0);
+                 pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uExitCancelTextureId), 0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
   if ( contract_approved )
     v2 = pGlobalTXT_LocalizationStrings[535];
@@ -7850,7 +7847,7 @@
   pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x15Eu, WINDOW_MainMenu, 0, 0);
   pBtn_ExitCancel = pDialogueWindow->CreateButton( 0x1D7u, 0x1BDu,  0xA9u,   0x23u,  1,  0,  UIMSG_Escape,  0,   0,
                  pGlobalTXT_LocalizationStrings[34], //"Cancel"
-                 (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0),
+                 pIcons_LOD->GetTexture(uExitCancelTextureId),
                  0);
   pDialogueWindow->CreateButton(0, 0, 0, 0, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
   if ( pNPCStats->pProfessions[v1->uProfession].pBenefits)//*(&pNPCStats->field_13A5C + 5 * v1->uProfession) )
@@ -7886,14 +7883,10 @@
     pDialogueWindow->Release();
     pDialogueWindow = GUIWindow::Create(0, 0, 640, 480, WINDOW_MainMenu, 0, 0);
     sprintfex(sHouseName, pGlobalTXT_LocalizationStrings[LOCSTR_ENTER_S], pMapStats->pInfos[uHouse_ExitPic].pName);
-    pBtn_ExitCancel = pDialogueWindow->CreateButton( 566, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 0x4Eu,
-                   pGlobalTXT_LocalizationStrings[34],// "Cancel"
-                   (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0),0);
-    pBtn_YES = pDialogueWindow->CreateButton( 486u, 445u,  75u, 33u, 1, 0,  UIMSG_BF,  1u,  0x59u,
-                   sHouseName,
-                   (Texture *)(uTextureID_BUTTYES2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTYES2] : 0), 0);
+    pBtn_ExitCancel = pDialogueWindow->CreateButton(566, 445, 75, 33, 1, 0, UIMSG_Escape, 0, 'N', pGlobalTXT_LocalizationStrings[34], pIcons_LOD->GetTexture(uTextureID_BUTTDESC2), 0);// "Cancel"
+    pBtn_YES        = pDialogueWindow->CreateButton(486, 445, 75, 33, 1, 0, UIMSG_BF,     1, 'Y', sHouseName, pIcons_LOD->GetTexture(uTextureID_BUTTYES2), 0);
     pDialogueWindow->CreateButton( pNPCPortraits_x[0][0], pNPCPortraits_y[0][0], 63u, 73u, 1, 0,  UIMSG_BF, 1u, 0x20u,  sHouseName, 0);
-    pDialogueWindow->CreateButton(8u, 8u, 460u, 344u, 1, 0, UIMSG_BF, 1u, 0x59u, sHouseName, 0);
+    pDialogueWindow->CreateButton(8, 8, 460, 344, 1, 0, UIMSG_BF, 1, 0x59u, sHouseName, 0);
   }
   else
   {
@@ -7910,7 +7903,7 @@
     pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, 0, 0);
     pBtn_ExitCancel = pDialogueWindow->CreateButton(  471u,  445u,  169u, 35u,  1,   0, UIMSG_Escape,  0,  0,
                    pGlobalTXT_LocalizationStrings[74],// "End Conversation"
-                   (Texture *)(uExitCancelTextureId != -1 ? (int)&pIcons_LOD->pTextures[uExitCancelTextureId] : 0),   0);
+                   pIcons_LOD->GetTexture(uExitCancelTextureId),   0);
     pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, UIMSG_BuyInShop_Identify_Repair, 0, 0, "", 0);
     if ( pDialogueNPCCount == 1 && dword_591080 )
     {
@@ -8372,8 +8365,8 @@
   v28.uFrameX = 483;
   v28.uFrameWidth = 148;
   v28.uFrameZ = 334;
-  v30 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  v31 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v30 = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  v31 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   v2 = 52 * (unsigned int)v0->ptr_1C;
   //v32 = (unsigned __int8)(((p2DEvents_minus1___00[v2 / 2] != 18) - 1) & 0x96) + 100;
   v32 = (unsigned __int8)(((p2DEvents[(unsigned int)v0->ptr_1C - 1].uType != 18) - 1) & 0x96) + 100;
@@ -9109,7 +9102,7 @@
   v12 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
   v13 = pHouse_ExitPictures[v10];
   pTexture_Dialogue_Background = &pIcons_LOD->pTextures[v12];
-  pTexture_outside = &pIcons_LOD->pTextures[pIcons_LOD->LoadTexture(v13, TEXTURE_16BIT_PALETTE)];
+  pTexture_outside = pIcons_LOD->LoadTexturePtr(v13, TEXTURE_16BIT_PALETTE);
   if ( v9 )
   {
     if ( !v23 )
--- a/mm7_5.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/mm7_5.cpp	Wed May 01 23:36:54 2013 +0600
@@ -529,78 +529,76 @@
           pGUIWindow_CurrentMenu->Release();
           viewparams->field_48 = v0;
           pCurrentScreen = SCREEN_OPTIONS;
-          uTextureID_ControlBG[0] = pIcons_LOD->LoadTexture("ControlBG", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[3] = pIcons_LOD->LoadTexture("con_16x", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[2] = pIcons_LOD->LoadTexture("con_32x", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[4] = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[5] = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[1] = pIcons_LOD->LoadTexture("con_Smoo", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[19] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[10] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[11] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[12] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[13] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[14] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[15] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[16] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[17] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[18] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[9] = pIcons_LOD->LoadTexture("option04", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[20] = pIcons_LOD->LoadTexture("option03", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[22] = pIcons_LOD->LoadTexture("option02", TEXTURE_16BIT_PALETTE);
-          uTextureID_ControlBG[21] = pIcons_LOD->LoadTexture("option01", TEXTURE_16BIT_PALETTE);
+
+          options_menu_skin.uTextureID_Background     = pIcons_LOD->LoadTexture("ControlBG", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_TurnSpeed[2]   = pIcons_LOD->LoadTexture("con_16x", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_TurnSpeed[1]   = pIcons_LOD->LoadTexture("con_32x", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_TurnSpeed[0]   = pIcons_LOD->LoadTexture("con_Smoo", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_ArrowLeft      = pIcons_LOD->LoadTexture("con_ArrL", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_ArrowRight     = pIcons_LOD->LoadTexture("con_ArrR", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[0] = pIcons_LOD->LoadTexture("convol10", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[1] = pIcons_LOD->LoadTexture("convol20", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[2] = pIcons_LOD->LoadTexture("convol30", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[3] = pIcons_LOD->LoadTexture("convol40", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[4] = pIcons_LOD->LoadTexture("convol50", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[5] = pIcons_LOD->LoadTexture("convol60", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[6] = pIcons_LOD->LoadTexture("convol70", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[7] = pIcons_LOD->LoadTexture("convol80", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[8] = pIcons_LOD->LoadTexture("convol90", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_SoundLevels[9] = pIcons_LOD->LoadTexture("convol00", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_FlipOnExit     = pIcons_LOD->LoadTexture("option04", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_AlwaysRun      = pIcons_LOD->LoadTexture("option03", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_ShowDamage     = pIcons_LOD->LoadTexture("option02", TEXTURE_16BIT_PALETTE);
+          options_menu_skin.uTextureID_WalkSound      = pIcons_LOD->LoadTexture("option01", TEXTURE_16BIT_PALETTE);
+
           pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, 640, 480, WINDOW_Options, 0, 0);
           pGUIWindow_CurrentMenu->CreateButton(22, 270,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[3])->uTextureWidth,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[3])->uTextureHeight,
-                                               v0, 0,
-                                               UIMSG_SetTurnSpeed, 0x80,
-                                               0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x5Du, 270,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[2])->uTextureWidth,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[2])->uTextureHeight,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])->uTextureHeight,
+                                               v0, 0, UIMSG_SetTurnSpeed, 0x80, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(93, 270,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1])->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1])->uTextureHeight,
                                                v0, 0, UIMSG_SetTurnSpeed, 0x40u, 0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0xA4u, 270,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[1])->uTextureWidth,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[1])->uTextureHeight,
+          pGUIWindow_CurrentMenu->CreateButton(164, 270,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0])->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0])->uTextureHeight,
                                                v0, 0, UIMSG_SetTurnSpeed, 0, 0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x14u, 0x12Fu,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[21])->uTextureWidth,
-                                               pIcons_LOD->GetTexture(uTextureID_ControlBG[21])->uTextureHeight,
+
+          pGUIWindow_CurrentMenu->CreateButton(20, 303,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_WalkSound)->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_WalkSound)->uTextureHeight,
                                                v0, 0, UIMSG_ToggleWalkSound, 0, 0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x80u, 0x12Fu,
-            (uTextureID_ControlBG[22] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[22]].uTextureWidth : 24),
-            (uTextureID_ControlBG[22] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[22]].uTextureHeight : 26),
-            v0, 0, UIMSG_ToggleShowDamage, 0, 0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x14u, 0x145u,
-            (uTextureID_ControlBG[20] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[20]].uTextureWidth : 24),
-            (uTextureID_ControlBG[20] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[20]].uTextureHeight : 26),
-            v0, 0, UIMSG_ToggleAlwaysRun, 0, 0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x80u, 0x145u,
-            (uTextureID_ControlBG[9] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[9]].uTextureWidth : 24),
-            (uTextureID_ControlBG[9] != -1 ? pIcons_LOD->pTextures[uTextureID_ControlBG[9]].uTextureHeight : 26),
-            v0, 0, UIMSG_ToggleFlipOnExit, 0, 0, v1, 0);
-          pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(243, 162, 16, 16, v0, 0, UIMSG_ChangeSoundVolume, 4, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_ControlBG[4]], 0);
-          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0xA2u, 0x10u, 0x10u, v0, 0, UIMSG_ChangeSoundVolume, 5, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_ControlBG[5]], 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x107u, 0xA2u, 0xACu, 0x11u, v0, 0, UIMSG_ChangeSoundVolume, 0, 0, v1, 0);
-          pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0xF3u, 0xD8u, 0x10u, 0x10u, v0, 0, UIMSG_ChangeMusicVolume, 4, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_ControlBG[4]], 0);
-          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0xD8u, 0x10u, 0x10u, v0, 0, UIMSG_ChangeMusicVolume, 5, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_ControlBG[5]], 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x107u, 0xD8u, 0xACu, 0x11u, v0, 0, UIMSG_ChangeMusicVolume, 0, 0, v1, 0);
-          pBtn_SliderLeft = pGUIWindow_CurrentMenu->CreateButton(0xF3u, 0x10Eu, 0x10u, 0x10u, v0, 0, UIMSG_ChangeVoiceVolume, 4, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_ControlBG[4]], 0);
-          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(0x1B3u, 0x10Eu, 0x10u, 0x10u, v0, 0, UIMSG_ChangeVoiceVolume, 5u, 0, v1,
-                         &pIcons_LOD->pTextures[uTextureID_ControlBG[5]], 0);
-          pGUIWindow_CurrentMenu->CreateButton(0x107u, 0x10Eu, 0xACu, 0x11u, v0, 0, UIMSG_ChangeVoiceVolume, 0, 0, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(0xF1u, 0x12Eu, 0xD6u, 0x28u, v0, 0, UIMSG_Escape, 0, 0,
-            pGlobalTXT_LocalizationStrings[619],// "Return to Game"
-            0);
-          pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x8Cu, 0xD6u, 0x28u, v0, 0, UIMSG_OpenKeyMappingOptions, 0, 0x4Bu, v1, 0);
-          pGUIWindow_CurrentMenu->CreateButton(19, 194, 214, 40, v0, 0, UIMSG_OpenVideoOptions, 0, 86, v1, 0);
-          continue;
+          pGUIWindow_CurrentMenu->CreateButton(128, 303,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ShowDamage)->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ShowDamage)->uTextureHeight,
+                                               v0, 0, UIMSG_ToggleShowDamage, 0, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(20, 325,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_AlwaysRun)->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_AlwaysRun)->uTextureHeight,
+                                               v0, 0, UIMSG_ToggleAlwaysRun, 0, 0, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton(128, 325,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_FlipOnExit)->uTextureWidth,
+                                               pIcons_LOD->GetTexture(options_menu_skin.uTextureID_FlipOnExit)->uTextureHeight,
+                                               v0, 0, UIMSG_ToggleFlipOnExit, 0, 0, v1, 0);
+
+          pBtn_SliderLeft  = pGUIWindow_CurrentMenu->CreateButton(243, 162, 16, 16, v0, 0, UIMSG_ChangeSoundVolume, 4, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0);
+          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 162, 16, 16, v0, 0, UIMSG_ChangeSoundVolume, 5, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0);
+          pGUIWindow_CurrentMenu->CreateButton(263, 162, 172, 17, v0, 0, UIMSG_ChangeSoundVolume, 0, 0, v1, 0);
+
+          pBtn_SliderLeft  = pGUIWindow_CurrentMenu->CreateButton(243, 216, 16, 16, v0, 0, UIMSG_ChangeMusicVolume, 4, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0);
+          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 216, 16, 16, v0, 0, UIMSG_ChangeMusicVolume, 5, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0);
+          pGUIWindow_CurrentMenu->CreateButton(263, 216, 172, 17, v0, 0, UIMSG_ChangeMusicVolume, 0, 0, v1, 0);
+
+          pBtn_SliderLeft  = pGUIWindow_CurrentMenu->CreateButton(243, 270, 16, 16, v0, 0, UIMSG_ChangeVoiceVolume, 4, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowLeft), 0);
+          pBtn_SliderRight = pGUIWindow_CurrentMenu->CreateButton(435, 270, 16, 16, v0, 0, UIMSG_ChangeVoiceVolume, 5, 0, v1, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_ArrowRight), 0);
+          pGUIWindow_CurrentMenu->CreateButton(263, 270, 172, 17, v0, 0, UIMSG_ChangeVoiceVolume, 0, 0, v1, 0);
+
+          pGUIWindow_CurrentMenu->CreateButton(241, 302, 214, 40, v0, 0, UIMSG_Escape, 0, 0, pGlobalTXT_LocalizationStrings[619], 0); // "Return to Game"
+          pGUIWindow_CurrentMenu->CreateButton( 19, 140, 214, 40, v0, 0, UIMSG_OpenKeyMappingOptions, 0, 0x4Bu, v1, 0);
+          pGUIWindow_CurrentMenu->CreateButton( 19, 194, 214, 40, v0, 0, UIMSG_OpenVideoOptions, 0, 86, v1, 0);
+          continue;
+
         case UIMSG_OpenKeyMappingOptions://Open
           if ( pMessageQueue_50CBD0->uNumMessages )
             pMessageQueue_50CBD0->uNumMessages = pMessageQueue_50CBD0->pMessages[0].field_8 != 0;
@@ -1126,15 +1124,8 @@
                       pEventTimer->Resume();
                       continue;
                     case SCREEN_OPTIONS://Close
-                      thisa = (signed int)&uTextureID_ControlBG;
-                      do
-                      {
-                        if ( *(int *)thisa )
-                          pIcons_LOD->pTextures[*(int *)thisa].Release();
-                        thisa += 4;
-                      }
-                      while ( thisa < (signed int)&dword_507CBC );
-                      memset(&uTextureID_ControlBG, 0, 0x5Cu);
+                      options_menu_skin.Relaease();
+
                       pIcons_LOD->_40F9C5();
                       WriteWindowsRegistryInt("soundflag", (char)uSoundVolumeMultiplier);
                       WriteWindowsRegistryInt("musicflag", (char)uMusicVolimeMultiplier);
@@ -9390,11 +9381,11 @@
 //----- (0040DEDB) --------------------------------------------------------
 unsigned int __stdcall R8G8B8_to_TargetFormat(int uColor)
 {
-  return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat((unsigned __int8)uColor, BYTE1(uColor), BYTE2(uColor));
+  return TargetColor((unsigned __int8)uColor, BYTE1(uColor), BYTE2(uColor));
 }
 
 //----- (0040DEF3) --------------------------------------------------------
-unsigned short GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat( unsigned __int16 r, unsigned __int16 g, unsigned __int16 b )
+unsigned short TargetColor( unsigned __int16 r, unsigned __int16 g, unsigned __int16 b )
     {
   return ((unsigned int)b >> (8 - LOBYTE(pRenderer->uTargetBBits))) | pRenderer->uTargetGMask & (g << (LOBYTE(pRenderer->uTargetGBits) + 
                            LOBYTE(pRenderer->uTargetBBits) - 8)) | pRenderer->uTargetRMask & (r << (LOBYTE(pRenderer->uTargetGBits) + 
@@ -10159,7 +10150,7 @@
 
   v0 = pParty->uCurrentHour;
   v6 = pMapStats->GetMapInfo(pCurrentMapName);
-  a5 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0x4Bu, 0x4Bu, 0x4Bu);
+  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 )
@@ -10281,13 +10272,13 @@
 //----- (00414162) --------------------------------------------------------
 void __cdecl uGameUIFontMain_initialize()
 {
-  uGameUIFontMain = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xAu, 0, 0);
+  uGameUIFontMain = TargetColor(0xAu, 0, 0);
 }
 
 //----- (00414174) --------------------------------------------------------
 void __cdecl uGameUIFontShadow_initialize()
 {
-  uGameUIFontShadow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE6u, 214u, 193u);
+  uGameUIFontShadow = TargetColor(0xE6u, 214u, 193u);
 }
 
 
@@ -10486,7 +10477,7 @@
 			}
 		case WINDOW_Book:
 			{
-			SellectDrawBook((unsigned int)pWindow->ptr_1C);
+			DrawCurrentBook((unsigned int)pWindow->ptr_1C);
 			break;
 			}
 		case WINDOW_QuickReference:
@@ -11239,7 +11230,7 @@
           v11 = pTmpBuf;
           strcpy(pTmpBuf, v12);
         }
-        v13 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+        v13 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
         a1.DrawTitleText(pFontArrus, 0, 0xCu, v13, v11, 3u);
         a1.uFrameWidth -= 24;
         a1.uFrameZ = a1.uFrameX + a1.uFrameWidth - 1;
@@ -11460,7 +11451,7 @@
     v2 = 255;
     v3 = 0;
   }
-  return GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(v3, v2, v6);
+  return TargetColor(v3, v2, v6);
 }
 
 //----- (00417939) --------------------------------------------------------
@@ -11474,9 +11465,9 @@
 
   v1 = uConditionIdx;
   v2 = 65535;
-  v3 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xE1u, 0xCDu, 0x23u);
-  v6 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0x23u, 0);
-  v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0, 0xFFu, 0);
+  v3 = TargetColor(0xE1u, 0xCDu, 0x23u);
+  v6 = TargetColor(0xFFu, 0x23u, 0);
+  v4 = TargetColor(0, 0xFFu, 0);
   switch ( v1 )
   {
     case 0u:
@@ -11534,7 +11525,7 @@
   Dst.uFrameHeight -= 12;
   Dst.uFrameZ = Dst.uFrameX + Dst.uFrameWidth - 1;
   Dst.uFrameW = Dst.uFrameY + Dst.uFrameHeight - 1;
-  v4 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0x9Bu);
+  v4 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
   sprintf(pTmpBuf, format_4E2D80, v4, v3);
   Dst.DrawTitleText(pFontCreate, 0, 0, 0, pTmpBuf, 3u);
   return Dst.DrawText(pFontSmallnum, 1, LOBYTE(pFontLucida->uFontHeight), 0, v2, 0, 0, 0);
@@ -11549,9 +11540,9 @@
   unsigned int red; // [sp+10h] [bp-8h]@1
   unsigned int white; // [sp+14h] [bp-4h]@1
 
-  white = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0xFFu);
-  red = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0, 0);
-  yellow = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(0xFFu, 0xFFu, 0);
+  white = TargetColor(0xFFu, 0xFFu, 0xFFu);
+  red = TargetColor(0xFFu, 0, 0);
+  yellow = TargetColor(0xFFu, 0xFFu, 0);
   if ( !(uPlayerClass % 4) )
   {
     if ( byte_4ED970_skill_learn_ability_by_class_table[uPlayerClass][uPlayerSkillType] >= skill_level )
--- a/mm7_6.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/mm7_6.cpp	Wed May 01 23:36:54 2013 +0600
@@ -7291,7 +7291,7 @@
 		if ( !pPlayer->CanCastSpell(uRequiredMana) )
 			break;
 		HIDWORD(v733) = 0;
-		memset(&achievedAwardsIndex, 0, 4000);
+		memset(&achieved_awards, 0, 4000);
 		_this = 0;
 		v605 = (char *)pParty->pHirelings;
 		do
@@ -7299,7 +7299,7 @@
 			if ( *(int *)v605)
 			{
 			v606 = HIDWORD(v733)++;
-			achievedAwardsIndex[v606] = (int)((char *)&_this->uItemID + 1);
+			achieved_awards[v606] = (AwardType)(int)((char *)&_this->uItemID + 1);
 			}
 			_this = (ItemGen *)((char *)_this + 1);
 			v605 += 76;
@@ -7309,6 +7309,7 @@
 		if ( (signed int)pNPCStats->uNumNewNPCs > 0)
 		{
 			v730 = (int)pNPCStats->pNewNPCData;
+            __debugbreak(); // data offset
 			HIDWORD(v733) = 4 * HIDWORD(v733) + 6043152;
 			do
 			{
--- a/mm7_data.cpp	Wed May 01 23:36:40 2013 +0600
+++ b/mm7_data.cpp	Wed May 01 23:36:54 2013 +0600
@@ -43,7 +43,6 @@
 struct ViewingParams *viewparams = new ViewingParams;
 
 
-int achievedAwardsIndex[1000];
 
 #include "stru123.h"
 stru123 stru_5E4C90;
@@ -56,6 +55,9 @@
 
 #include "Awards.h"
 Award pAwards[104];
+AwardType achieved_awards[1000];
+int num_achieved_awards;
+int num_achieved_awards_2;
 
 #include "stru159.h"
 
@@ -509,7 +511,6 @@
 int pWeaponSkills[9]={3, 5, 2, 6, 4, 0, 1, 31, 7};
 int pMiscSkills[12]={35, 33, 24, 21, 32, 36, 29, 25, 22, 26, 23, 34};
 int pMagicSkills[9]={12, 13, 14, 15, 16, 17, 18, 19, 20};
-unsigned __int8 pAwardsTextColors[20];
 unsigned int pHealthBarPos[4] = {22, 137, 251, 366};
 unsigned int pManaBarPos[4] = {102, 217, 331, 447};
 char _4E2AD8_ui_colors[72];
@@ -527,37 +528,7 @@
 };
 unsigned char hourglass_icon_idx = 12; // weak
 
-char aSS[777]; // idb
-char ascii_4E2C54[6];
-char ascii_4E2C5C[7];
-char ascii_4E2C68[8];
-char ascii_4E2C70[9];
-char ascii_4E2C7C[8];
-char ascii_4E2C84[11];
-char ascii_4E2C90[12];
-char ascii_4E2C9C[8];
-char ascii_4E2CA4[7];
-char ascii_4E2CB0[12];
-char ascii_4E2CBC[12];
-char ascii_4E2CC8[12];
-char ascii_4E2CD4[6];
-char ascii_4E2CDC[11];
-char ascii_4E2CE8[8];
-char ascii_4E2CF0[12];
-char ascii_4E2CFC[6];
-char ascii_4E2D04[8];
-char ascii_4E2D0C[8];
-char ascii_4E2D14[6];
-char ascii_4E2D1C[12];
-char ascii_4E2D28[8];
-char ascii_4E2D30[7];
-char ascii_4E2D38[5];
-char ascii_4E2D40[8];// = {0xC2, 0xCF, 0xD0, 0xC0, 0xC2, 0xCE, 0};//russian text in keyboard options
-char ascii_4E2D48[6];// = {0xC2, 0xCB, 0xC5, 0xC2, 0xCE, 0};
-char ascii_4E2D50[6];// = {0xCD, 0xC0, 0xC7, 0xC0, 0xC4, 0};
-char ascii_4E2D5C[7];// = {0xC2, 0xCF, 0xC5, 0xD0, 0xC5, 0xC4, 0};
-char aMakingItemNumb[777]; // idb
-char aNpc03d[777]; // idb
+
 const char *format_4E2D80 = "\f%05d%s\f00000\n";
 char format_4E2D90[8];
 char aS03d03dS000_0[777]; // idb
@@ -1519,8 +1490,6 @@
 Texture *dword_50640C[12]; // weak
 unsigned int uExitCancelTextureId;
 int dword_50651C; // weak
-int awards_count; // weak
-int awards_count2; // weak
 int dword_506528; // weak
 int dword_50652C; // weak
 int dword_506530; // weak
--- a/mm7_data.h	Wed May 01 23:36:40 2013 +0600
+++ b/mm7_data.h	Wed May 01 23:36:54 2013 +0600
@@ -442,7 +442,6 @@
 extern int pWeaponSkills[9];
 extern int pMiscSkills[12];
 extern int pMagicSkills[9];
-extern unsigned __int8 pAwardsTextColors[20];
 extern unsigned int pHealthBarPos[4];
 extern unsigned int pManaBarPos[4];
 extern char _4E2AD8_ui_colors[72];
@@ -450,44 +449,10 @@
 extern char monster_popup_y_offsets[]; // weak
 extern unsigned char hourglass_icon_idx; // weak
 
-extern char aSS[]; // idb
-extern char ascii_4E2C54[6];
-extern char ascii_4E2C5C[7];
-extern char ascii_4E2C68[8];
-extern char ascii_4E2C70[9];
-extern char ascii_4E2C7C[8];
-extern char ascii_4E2C84[11];
-extern char ascii_4E2C90[12];
-extern char ascii_4E2C9C[8];
-extern char ascii_4E2CA4[7];
-extern char ascii_4E2CB0[12];
-extern char ascii_4E2CBC[12];
-extern char ascii_4E2CC8[12];
-extern char ascii_4E2CD4[6];
-extern char ascii_4E2CDC[11];
-extern char ascii_4E2CE8[8];
-extern char ascii_4E2CF0[12];
-extern char ascii_4E2CFC[6];
-extern char ascii_4E2D04[8];
-extern char ascii_4E2D0C[8];
-extern char ascii_4E2D14[6];
-extern char ascii_4E2D1C[12];
-extern char ascii_4E2D28[8];
-extern char ascii_4E2D30[7];
-extern char ascii_4E2D38[5];
-extern char ascii_4E2D40[8];
-extern char ascii_4E2D48[6];
-extern char ascii_4E2D50[6];
-extern char ascii_4E2D5C[7];
-extern char aMakingItemNumb[]; // idb
-extern char aNpc03d[]; // idb
+
 extern const char *format_4E2D80;
 extern char format_4E2D90[8];
-extern char aS03d03dS000_0[]; // idb
-extern char aS03d03dS000[]; // idb
 //extern const char *format_4E2DC8;
-extern char aS[]; // idb
-extern char aLuSLuS[]; // idb
 extern const char *format_4E2DE8; // idb
 extern char asc_4E2DFC[3]; // idb
 extern const char *format_4E2E00; // idb
@@ -953,8 +918,6 @@
 extern Texture *dword_50640C[]; // weak
 extern unsigned int uExitCancelTextureId;
 extern int dword_50651C; // weak
-extern int awards_count; // weak
-extern int awards_count2; // weak
 extern int dword_506528; // weak
 extern int dword_50652C; // weak
 extern int dword_506530; // weak
@@ -1209,7 +1172,6 @@
 extern char *pClassTXT_Raw;
 extern char *pStatsTXT_Raw;
 extern char *pSkillDescTXT_Raw;
-extern int achievedAwardsIndex[1000];
 extern struct FactionTable *pFactionTable;
 extern char byte_5C8D1A[]; // weak
 
@@ -1578,7 +1540,7 @@
 void __fastcall intToString(int val, char *pOut);
 // int __cdecl crt_retnull_sub();
 unsigned int __stdcall R8G8B8_to_TargetFormat(int uColor); // idb
-unsigned short GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat(unsigned __int16 r, unsigned __int16 g, unsigned __int16 b); // idb
+unsigned short TargetColor(unsigned __int16 r, unsigned __int16 g, unsigned __int16 b); // idb
 void __cdecl CallRenderPresent();
 void __thiscall DoBlt_Copy(unsigned __int16 *pPixels); // idb
 int __stdcall retzero_sub_40DFA7(int); // weak
@@ -1600,34 +1562,34 @@
 void __cdecl InitializeBookFonts();
 void __fastcall LoadThumbnailLloydTexture(unsigned int uSlot, unsigned int uPlayer);
 void  sub_412AF9();
-void __cdecl DrawSpellBookContent();
-char __cdecl DrawBook_History();
-void __cdecl DrawBook_Quests();
-void __cdecl DrawBook_Autonotes();
+void DrawSpellBookContent();
+char DrawBook_History();
+void DrawBook_Quests();
+void DrawBook_Autonotes();
 void DrawBook_Maps();
-void __thiscall SellectDrawBook(unsigned int uBook); // idb
-char *__cdecl GetDayPart();
-char __cdecl DrawBook_Calendar();
-void __cdecl SetAttributeNames();
-void __cdecl uGameUIFontMain_initialize();
-void __cdecl uGameUIFontShadow_initialize();
-void __cdecl sub_41420D_press_esc();
-void __cdecl sub_41426F();
-char __cdecl GameMenuUI_DrawKeyBindings();
+void DrawCurrentBook(unsigned int uBook); // idb
+char *GetDayPart();
+char DrawBook_Calendar();
+void SetAttributeNames();
+void uGameUIFontMain_initialize();
+void uGameUIFontShadow_initialize();
+void sub_41420D_press_esc();
+void sub_41426F();
+char GameMenuUI_DrawKeyBindings();
 unsigned int __thiscall sub_414D24(int _this);
-void __cdecl GameMenuUI_DrawVideoOptions();
-void __cdecl DrawGameOptions();
+void GameMenuUI_DrawVideoOptions();
+void DrawGameOptions();
 void __fastcall DrawPopupWindow(unsigned int uX, unsigned int uY, unsigned int uWidth, unsigned int uHeight); // idb
 void DrawCopyrightWindow();
 void LoadFonts_and_DrawCopyrightWindow();
-void __cdecl GUI_UpdateWindows();
-void __cdecl identify_item();
+void GUI_UpdateWindows();
+void identify_item();
 void __thiscall sub_416B01(void *_this);
 void __thiscall sub_416D62_ShowPopupWindow_MonsterRecord_ItemInfo_etcsub_416D62(struct Vec2_int_ *_this);
 void UI_OnMouseLeftClick(int *pXY); // idb
 void __thiscall sub_417871(int *pXY);
-void __cdecl sub_4178C4();
-void __cdecl sub_4178E1();
+void sub_4178C4();
+void sub_4178E1();
 unsigned int __fastcall UI_GetHealthManaStringColor(signed int a1, signed int a2);
 signed int __thiscall GetConditionDrawColor(unsigned int uConditionIdx); // idb
 char __fastcall sub_4179BC_draw_tooltip(const char *a1, const char *a2); // idb