changeset 2542:bacf9809126a

.
author a.parshin
date Sun, 10 May 2015 02:04:52 +0200
parents a902abdfc7f2
children b6140dfeac27
files Engine/Party.cpp Engine/mm7_data.cpp Engine/mm7_data.h GUI/GUIWindow.cpp GUI/GUIWindow.h GUI/UI/UICharacter.cpp GUI/UI/UIOptions.cpp Game/Game.cpp
diffstat 8 files changed, 113 insertions(+), 76 deletions(-) [+]
line wrap: on
line diff
--- a/Engine/Party.cpp	Sun May 10 01:29:11 2015 +0200
+++ b/Engine/Party.cpp	Sun May 10 02:04:52 2015 +0200
@@ -860,7 +860,7 @@
       _506F18_num_minutes_to_sleep = 0;
       OutdoorLocation::LoadActualSkyFrame();
     }
-    if ( dword_506F14 == 2 )
+    if ( _506F14_resting_stage == 2 )
     {
       pMessageQueue_50CBD0->AddGUIMessage(UIMSG_Escape, 0, 0);
     }
--- a/Engine/mm7_data.cpp	Sun May 10 01:29:11 2015 +0200
+++ b/Engine/mm7_data.cpp	Sun May 10 02:04:52 2015 +0200
@@ -769,7 +769,7 @@
 std::array<unsigned int, 28> pPrevVirtualCidesMapping;
 int KeyboardPageNum; // weak
 int uRestUI_FoodRequiredToRest;
-int dword_506F14; // weak
+int _506F14_resting_stage; // weak
 int _506F18_num_minutes_to_sleep; // weak
 int dword_506F1C; // weak
 std::array<int, 20> pVisibleWindowsIdxs; // weak
--- a/Engine/mm7_data.h	Sun May 10 01:29:11 2015 +0200
+++ b/Engine/mm7_data.h	Sun May 10 02:04:52 2015 +0200
@@ -432,7 +432,7 @@
 extern std::array<unsigned int, 28> pPrevVirtualCidesMapping;
 extern int KeyboardPageNum; // weak
 extern int uRestUI_FoodRequiredToRest;
-extern int dword_506F14; // weak
+extern int _506F14_resting_stage; // weak
 extern int _506F18_num_minutes_to_sleep; // weak
 extern int dword_506F1C; // weak
 extern std::array<int, 20> pVisibleWindowsIdxs; // weak
--- a/GUI/GUIWindow.cpp	Sun May 10 01:29:11 2015 +0200
+++ b/GUI/GUIWindow.cpp	Sun May 10 02:04:52 2015 +0200
@@ -1693,7 +1693,7 @@
     pWindow = &pWindowList[pVisibleWindowsIdxs[i] - 1];
     switch (pWindow->eWindowType)
     {
-      case WINDOW_OptionsButtons:
+      case WINDOW_GameMenu:
       {
         pRenderer->DrawTextureIndexed(pViewport->uViewportTL_Y,
                                       pViewport->uViewportTL_X, pIcons_LOD->GetTexture(uTextureID_Options));
--- a/GUI/GUIWindow.h	Sun May 10 01:29:11 2015 +0200
+++ b/GUI/GUIWindow.h	Sun May 10 02:04:52 2015 +0200
@@ -267,7 +267,7 @@
 {
   WINDOW_null            = 0,
   WINDOW_MainMenu        = 1,
-  WINDOW_OptionsButtons  = 3,
+  WINDOW_GameMenu  = 3,
   WINDOW_CharacterRecord = 4,
   WINDOW_Options         = 6,
   WINDOW_8               = 8,
@@ -390,32 +390,36 @@
 
 enum CURRENT_SCREEN
 {
-  SCREEN_GAME = 0x0,
-  SCREEN_MENU = 0x1,
-  SCREEN_OPTIONS = 0x2,
-  SCREEN_BOOKS = 0x3,
-  SCREEN_NPC_DIALOGUE = 0x4,
-  SCREEN_REST = 0x5,
+  SCREEN_GAME = 0,
+  SCREEN_MENU = 1,
+  SCREEN_OPTIONS = 2,
+  SCREEN_BOOKS = 3,
+  SCREEN_NPC_DIALOGUE = 4,
+  SCREEN_REST = 5,
+  SCREEN_6 = 6,
   SCREEN_CHARACTERS = 7,
-  SCREEN_SPELL_BOOK = 0x8,
-  SCREEN_CREATORS = 0x9,
+  SCREEN_SPELL_BOOK = 8,
+  SCREEN_CREATORS = 9,
   SCREEN_CHEST = 10,
   SCREEN_SAVEGAME = 11,
   SCREEN_LOADGAME = 12,
   SCREEN_HOUSE = 13,
   SCREEN_E = 14,
   SCREEN_CHEST_INVENTORY = 15,
-  SCREEN_VIDEO = 0x10,
-  SCREEN_CHANGE_LOCATION = 0x11,
-  SCREEN_INPUT_BLV = 0x12,
-  SCREEN_BRANCHLESS_NPC_DIALOG = 0x13,
-  SCREEN_PARTY_CREATION = 0x15,
-  SCREEN_MODAL_WINDOW = 0x16,
-  SCREEN_CASTING = 0x17,
-  SCREEN_19 = 0x19,
-  SCREEN_KEYBOARD_OPTIONS = 0x1A,
-  SCREEN_1B = 0x1B,
-  SCREEN_VIDEO_OPTIONS = 0x1C,
+  SCREEN_VIDEO = 16,
+  SCREEN_CHANGE_LOCATION = 17,
+  SCREEN_INPUT_BLV = 18,
+  SCREEN_BRANCHLESS_NPC_DIALOG = 19,
+  SCREEN_20 = 20,
+  SCREEN_PARTY_CREATION = 21,
+  SCREEN_MODAL_WINDOW = 22,
+  SCREEN_CASTING = 23,
+  SCREEN_24 = 24,
+  SCREEN_19 = 25,
+  SCREEN_KEYBOARD_OPTIONS = 26,
+  SCREEN_1B = 27,
+  SCREEN_VIDEO_OPTIONS = 28,
+
   SCREEN_63 = 0x63,
   SCREEN_64 = 0x64,
   SCREEN_67 = 0x67,
@@ -524,12 +528,16 @@
 
 
 // game menu ui
-void GameMenuUI_DrawKeyBindings();
-void GameMenuUI_DrawVideoOptions();
+GUIWindow *GameMenuUI_Load();
+
 GUIWindow *GameMenuUI_Options_Load();
+void GameMenuUI_Options_Draw();
+
 GUIWindow *GameMenuUI_OptionsKeymapping_Load();
+void GameMenuUI_DrawKeyBindings();
+
 GUIWindow *GameMenuUI_OptionsVideo_Load();
-void GameMenuUI_Options_Draw();
+void GameMenuUI_DrawVideoOptions();
 
 
 
--- a/GUI/UI/UICharacter.cpp	Sun May 10 01:29:11 2015 +0200
+++ b/GUI/UI/UICharacter.cpp	Sun May 10 02:04:52 2015 +0200
@@ -328,58 +328,75 @@
     };
 
 const char *dlad_texnames_by_face[25] =
-    {
+{
     "pc01lad", "pc02lad", "pc03lad", "pc04lad", "pc05lad", "pc06lad",
     "pc07lad", "pc08lad", "pc09lad", "pc10lad", "pc11lad", "pc12lad",
     "pc13lad", "pc14lad", "pc15lad", "pc16lad", "pc17lad", "pc18lad",
     "pc19lad", "pc20lad", "pc21lad", "pc22lad", "pc23lad", "pc24lad",
     "pc25lad"
-    };
+};
 const char *dlau_texnames_by_face[25] =
-    {
+{
     "pc01lau", "pc02lau", "pc03lau", "pc04lau", "pc05lau", "pc06lau",
     "pc07lau", "pc08lau", "pc09lau", "pc10lau", "pc11lau", "pc12lau",
     "pc13lau", "pc14lau", "pc15lau", "pc16lau", "pc17lau", "pc18lau",
     "pc19lau", "pc20lau", "pc21lau", "pc22lau", "pc23lau", "pc24lau",
     "pc25lau"
-    };
+};
 const char *dbod_texnames_by_face[25] =
-    {
+{
     "pc01bod", "pc02bod", "pc03bod", "pc04bod", "pc05bod", "pc06bod",
     "pc07bod", "pc08bod", "pc09bod", "pc10bod", "pc11bod", "pc12bod",
     "pc13bod", "pc14bod", "pc15bod", "pc16bod", "pc17bod", "pc18bod",
     "pc19bod", "pc20bod", "pc21bod", "pc22bod", "pc23bod", "pc24bod",
     "pc25bod"
-    };
+};
 const char *drh_texnames_by_face[25] =
-    {
+{
 
     "pc01rh", "pc02rh", "pc03rh", "pc04rh", "pc05rh", "pc06rh",
     "pc07rh", "pc08rh", "pc09rh", "pc10rh", "pc11rh", "pc12rh",
     "pc13rh", "pc14rh", "pc15rh", "pc16rh", "pc17rh", "pc18rh",
     "pc19rh", "pc20rh", "pc21rh", "pc22rh", "pc23rh", "pc24rh",
     "pc25rh"
-    };
+};
 const char *dlh_texnames_by_face[25] =
-    {
+{
     "pc01lh", "pc02lh", "pc03lh", "pc04lh", "pc05lh", "pc06lh",
     "pc07lh", "pc08lh", "pc09lh", "pc10lh", "pc11lh", "pc12lh",
     "pc13lh", "pc14lh", "pc15lh", "pc16lh", "pc17lh", "pc18lh",
     "pc19lh", "pc20lh", "pc21lh", "pc22lh", "pc23lh", "pc24lh",
     "pc25lh"
-    };
+};
 const char *dlhu_texnames_by_face[25] =
-    {
+{
     "pc01lhu", "pc02lhu", "pc03lhu", "pc04lhu", "pc05lhu", "pc06lhu",
     "pc07lhu", "pc08lhu", "pc09lhu", "pc10lhu", "pc11lhu", "pc12lhu",
     "pc13lhu", "pc14lhu", "pc15lhu", "pc16lhu", "pc17lhu", "pc18lhu",
     "pc19lhu", "pc20lhu", "pc21lhu", "pc22lhu", "pc23lhu", "pc24lhu",
     "pc25lhu"
-    };
+};
 
-const  int pArmorSkills[5]  = {PLAYER_SKILL_LEATHER, PLAYER_SKILL_CHAIN,      PLAYER_SKILL_PLATE,        PLAYER_SKILL_SHIELD,  PLAYER_SKILL_DODGE};
-const int pWeaponSkills[9] = {PLAYER_SKILL_AXE,     PLAYER_SKILL_BOW,        PLAYER_SKILL_DAGGER,       PLAYER_SKILL_MACE,    PLAYER_SKILL_SPEAR,      
-    PLAYER_SKILL_STAFF,    PLAYER_SKILL_SWORD,       PLAYER_SKILL_UNARMED,    PLAYER_SKILL_BLASTER};
+const int pArmorSkills[5] =
+{
+    PLAYER_SKILL_LEATHER,
+    PLAYER_SKILL_CHAIN,
+    PLAYER_SKILL_PLATE,
+    PLAYER_SKILL_SHIELD,
+    PLAYER_SKILL_DODGE
+};
+const int pWeaponSkills[9] =
+{
+    PLAYER_SKILL_AXE,
+    PLAYER_SKILL_BOW,
+    PLAYER_SKILL_DAGGER,
+    PLAYER_SKILL_MACE,
+    PLAYER_SKILL_SPEAR,
+    PLAYER_SKILL_STAFF,
+    PLAYER_SKILL_SWORD,
+    PLAYER_SKILL_UNARMED,
+    PLAYER_SKILL_BLASTER
+};
 const  int pMiscSkills[12]  = {PLAYER_SKILL_ALCHEMY, PLAYER_SKILL_ARMSMASTER, PLAYER_SKILL_BODYBUILDING, PLAYER_SKILL_ITEM_ID, PLAYER_SKILL_MONSTER_ID, 
     PLAYER_SKILL_LEARNING, PLAYER_SKILL_TRAP_DISARM, PLAYER_SKILL_MEDITATION, PLAYER_SKILL_MERCHANT, PLAYER_SKILL_PERCEPTION,
     PLAYER_SKILL_REPAIR, PLAYER_SKILL_STEALING};
--- a/GUI/UI/UIOptions.cpp	Sun May 10 01:29:11 2015 +0200
+++ b/GUI/UI/UIOptions.cpp	Sun May 10 02:04:52 2015 +0200
@@ -24,6 +24,40 @@
 OptionsMenuSkin options_menu_skin; // 507C60
 
 
+GUIWindow *GameMenuUI_Load()
+{
+    auto wnd = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_GameMenu, 0, 0);
+    uTextureID_Options = pIcons_LOD->LoadTexture("options", TEXTURE_16BIT_PALETTE);
+    uTextureID_New1 = pIcons_LOD->LoadTexture("new1", TEXTURE_16BIT_PALETTE);
+    uTextureID_Load1 = pIcons_LOD->LoadTexture("load1", TEXTURE_16BIT_PALETTE);
+    uTextureID_Save1 = pIcons_LOD->LoadTexture("save1", TEXTURE_16BIT_PALETTE);
+    uTextureID_Controls1 = pIcons_LOD->LoadTexture("controls1", TEXTURE_16BIT_PALETTE);
+    uTextureID_Resume1 = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE);
+    uTextureID_Quit1 = pIcons_LOD->LoadTexture("quit1", TEXTURE_16BIT_PALETTE);
+    pBtn_NewGame = wnd->CreateButton(0x13u, 0x9Bu, 0xD6u, 0x28u, 1, 0, UIMSG_StartNewGame, 0, 0x4Eu,
+        pGlobalTXT_LocalizationStrings[614],// "New Game"
+        pIcons_LOD->GetTexture(uTextureID_New1), 0);
+    pBtn_SaveGame = wnd->CreateButton(0x13u, 0xD1u, 0xD6u, 0x28u, 1, 0, UIMSG_Game_OpenSaveGameDialog, 0, 0x53u,
+        pGlobalTXT_LocalizationStrings[615],// "Save Game"
+        pIcons_LOD->GetTexture(uTextureID_Save1), 0);
+    pBtn_LoadGame = wnd->CreateButton(19, 263, 0xD6u, 0x28u, 1, 0, UIMSG_Game_OpenLoadGameDialog, 0, 0x4Cu,
+        pGlobalTXT_LocalizationStrings[616],// "Load Game"
+        pIcons_LOD->GetTexture(uTextureID_Load1), 0);
+    pBtn_GameControls = wnd->CreateButton(241, 155, 214, 40, 1, 0, UIMSG_Game_OpenOptionsDialog, 0, 0x43u,
+        pGlobalTXT_LocalizationStrings[617],// ""Sound, Keyboard, Game Options:""
+        pIcons_LOD->GetTexture(uTextureID_Controls1), 0);
+    pBtn_QuitGame = wnd->CreateButton(241, 209, 214, 40, 1, 0, UIMSG_Quit, 0, 0x51u,
+        pGlobalTXT_LocalizationStrings[618],// "Quit"
+        pIcons_LOD->GetTexture(uTextureID_Quit1), 0);
+    pBtn_Resume = wnd->CreateButton(241, 263, 214, 40, 1, 0, UIMSG_GameMenu_ReturnToGame, 0, 0x52u,
+        pGlobalTXT_LocalizationStrings[619],// "Return to Game"
+        pIcons_LOD->GetTexture(uTextureID_Resume1), 0);
+    wnd->_41D08F_set_keyboard_control_group(6, 1, 0, 0);
+
+    return wnd;
+}
+
+
 std::array<bool, 28> GameMenuUI_InvaligKeyBindingsFlags; // 506E6C
 //----- (00414D24) --------------------------------------------------------
 static unsigned int GameMenuUI_GetKeyBindingColor(int key_index)
--- a/Game/Game.cpp	Sun May 10 01:29:11 2015 +0200
+++ b/Game/Game.cpp	Sun May 10 02:04:52 2015 +0200
@@ -683,7 +683,7 @@
                 continue;
             case UIMSG_OpenQuestBook:
                 DoThatMessageThing();
-                if (current_screen_type)
+                if (current_screen_type != SCREEN_GAME)
                     pGUIWindow_CurrentMenu->Release();
                 pEventTimer->Pause();
                 pAudioPlayer->StopChannels(-1, -1);
@@ -693,7 +693,7 @@
                 continue;
             case UIMSG_OpenAutonotes:
                 DoThatMessageThing();
-                if (current_screen_type)
+                if (current_screen_type != SCREEN_GAME)
                     pGUIWindow_CurrentMenu->Release();
                 pEventTimer->Pause();
                 pAudioPlayer->StopChannels(-1, -1);
@@ -703,7 +703,7 @@
                 continue;
             case UIMSG_OpenMapBook:
                 DoThatMessageThing();
-                if (current_screen_type)
+                if (current_screen_type != SCREEN_GAME)
                     pGUIWindow_CurrentMenu->Release();
                 pEventTimer->Pause();
                 viewparams->sViewCenterX = pParty->vPosition.x;
@@ -714,7 +714,7 @@
                 continue;
             case UIMSG_OpenCalendar:
                 DoThatMessageThing();
-                if (current_screen_type)
+                if (current_screen_type != SCREEN_GAME)
                     pGUIWindow_CurrentMenu->Release();
                 pEventTimer->Pause();
                 pAudioPlayer->StopChannels(-1, -1);
@@ -723,7 +723,7 @@
                 continue;
             case UIMSG_OpenHistoryBook:
                 DoThatMessageThing();
-                if (current_screen_type)
+                if (current_screen_type != SCREEN_GAME)
                     pGUIWindow_CurrentMenu->Release();
                 pEventTimer->Pause();
                 pAudioPlayer->StopChannels(-1, -1);
@@ -763,7 +763,7 @@
                     pRenderer->ClearZBuffer(0, 479);
                     viewparams->bRedrawGameUI = 1;
                     viewparams->field_48 = 1;
-                    if (current_screen_type)
+                    if (current_screen_type != SCREEN_GAME)
                     {
                         if (current_screen_type > SCREEN_67)
                         {
@@ -1265,33 +1265,8 @@
                         if (!pIcons_LOD->uNumPrevLoadedFiles)
                             pIcons_LOD->uNumPrevLoadedFiles = pIcons_LOD->uNumLoadedFiles;
 
-                        pGUIWindow_CurrentMenu = GUIWindow::Create(0, 0, window->GetWidth(), window->GetHeight(), WINDOW_OptionsButtons, 0, 0);
-                        uTextureID_Options = pIcons_LOD->LoadTexture("options", TEXTURE_16BIT_PALETTE);
-                        uTextureID_New1 = pIcons_LOD->LoadTexture("new1", TEXTURE_16BIT_PALETTE);
-                        uTextureID_Load1 = pIcons_LOD->LoadTexture("load1", TEXTURE_16BIT_PALETTE);
-                        uTextureID_Save1 = pIcons_LOD->LoadTexture("save1", TEXTURE_16BIT_PALETTE);
-                        uTextureID_Controls1 = pIcons_LOD->LoadTexture("controls1", TEXTURE_16BIT_PALETTE);
-                        uTextureID_Resume1 = pIcons_LOD->LoadTexture("resume1", TEXTURE_16BIT_PALETTE);
-                        uTextureID_Quit1 = pIcons_LOD->LoadTexture("quit1", TEXTURE_16BIT_PALETTE);
-                        pBtn_NewGame = pGUIWindow_CurrentMenu->CreateButton(0x13u, 0x9Bu, 0xD6u, 0x28u, 1, 0, UIMSG_StartNewGame, 0, 0x4Eu,
-                            pGlobalTXT_LocalizationStrings[614],// "New Game"
-                            pIcons_LOD->GetTexture(uTextureID_New1), 0);
-                        pBtn_SaveGame = pGUIWindow_CurrentMenu->CreateButton(0x13u, 0xD1u, 0xD6u, 0x28u, 1, 0, UIMSG_Game_OpenSaveGameDialog, 0, 0x53u,
-                            pGlobalTXT_LocalizationStrings[615],// "Save Game"
-                            pIcons_LOD->GetTexture(uTextureID_Save1), 0);
-                        pBtn_LoadGame = pGUIWindow_CurrentMenu->CreateButton(19, 263, 0xD6u, 0x28u, 1, 0, UIMSG_Game_OpenLoadGameDialog, 0, 0x4Cu,
-                            pGlobalTXT_LocalizationStrings[616],// "Load Game"
-                            pIcons_LOD->GetTexture(uTextureID_Load1), 0);
-                        pBtn_GameControls = pGUIWindow_CurrentMenu->CreateButton(241, 155, 214, 40, 1, 0, UIMSG_Game_OpenOptionsDialog, 0, 0x43u,
-                            pGlobalTXT_LocalizationStrings[617],// ""Sound, Keyboard, Game Options:""
-                            pIcons_LOD->GetTexture(uTextureID_Controls1), 0);
-                        pBtn_QuitGame = pGUIWindow_CurrentMenu->CreateButton(241, 209, 214, 40, 1, 0, UIMSG_Quit, 0, 0x51u,
-                            pGlobalTXT_LocalizationStrings[618],// "Quit"
-                            pIcons_LOD->GetTexture(uTextureID_Quit1), 0);
-                        pBtn_Resume = pGUIWindow_CurrentMenu->CreateButton(241, 263, 214, 40, 1, 0, UIMSG_GameMenu_ReturnToGame, 0, 0x52u,
-                            pGlobalTXT_LocalizationStrings[619],// "Return to Game"
-                            pIcons_LOD->GetTexture(uTextureID_Resume1), 0);
-                        pGUIWindow_CurrentMenu->_41D08F_set_keyboard_control_group(6, 1, 0, 0);
+                        pGUIWindow_CurrentMenu = GameMenuUI_Load();
+
                         viewparams->field_48 = 1;
 
                         stru_506E40.Release();
@@ -1310,6 +1285,7 @@
                 }
                 ModalWindow_Release();
                 continue;
+
             case UIMSG_ScrollNPCPanel://Right and Left button for NPCPanel
                 if (uMessageParam)
                 {
@@ -1334,6 +1310,7 @@
                 }
                 GameUI_DrawHiredNPCs();
                 continue;
+
             case UIMSG_TransitionUI_Confirm:
                 DoThatMessageThing();
                 dword_50CDC8 = 1;
@@ -1508,7 +1485,7 @@
                     pParty->vPosition.y = 22528;
                 DialogueEnding();
                 current_screen_type = SCREEN_GAME;
-                viewparams->bRedrawGameUI = 1;
+                viewparams->bRedrawGameUI = true;
                 continue;
             case UIMSG_CastSpell_Telekinesis:
                 //if ( pRenderer->pRenderD3D )
@@ -1642,6 +1619,7 @@
                     }
                 }
                 continue;
+
             case UIMSG_BF:
                 __debugbreak();
                 dword_50CDC8 = 1;