view UIOptions.cpp @ 1003:9318dd3f3711

return dword_50C9EC
author Ritor1
date Tue, 14 May 2013 23:16:10 +0600
parents a079c489118d
children e865f349aa41 c45d51b3f4f4
line wrap: on
line source

#include <assert.h>

#include "MM7.h"

#include "MapInfo.h"
#include "Game.h"
#include "GUIWindow.h"
#include "GUIFont.h"
#include "GUIProgressBar.h"
#include "Party.h"
#include "AudioPlayer.h"
#include "Outdoor.h"
#include "IndoorCamera.h"
#include "Overlays.h"
#include "Monsters.h"
#include "Arcomage.h"
#include "LOD.h"
#include "Actor.h"
#include "Allocator.h"
#include "Events.h"
#include "Viewport.h"
#include "FrameTableInc.h"
#include "Math.h"
#include "SpriteObject.h"
#include "ObjectList.h"
#include "Chest.h"
#include "PaletteManager.h"
#include "DecorationList.h"
#include "SaveLoad.h"
#include "stru123.h"
#include "Time.h"
#include "IconFrameTable.h"
#include "Awards.h"
#include "Autonotes.h"
#include "stru160.h"
#include "TurnEngine.h"
#include "CastSpellInfo.h"
#include "Weather.h"
#include "stru298.h"
#include "StorylineTextTable.h"
#include "Events2D.h"
#include "texts.h"

#include "mm7_data.h"




OptionsMenuSkin options_menu_skin; // 507C60




//----- (004142D3) --------------------------------------------------------
char __cdecl GameMenuUI_DrawKeyBindings()
    {
    unsigned int v0; // ebp@1
    int v1; // ecx@2
    unsigned int v2; // eax@6
    GUIWindow *v3; // edx@6
    signed int v4; // ecx@7
    signed int v5; // eax@8
    const char *v6; // ST0C_4@16
    unsigned int v7; // eax@16
    const char *v8; // ST0C_4@16
    unsigned int v9; // eax@16
    const char *v10; // ST0C_4@16
    unsigned int v11; // eax@16
    const char *v12; // ST0C_4@16
    unsigned int v13; // eax@16
    const char *v14; // ST0C_4@16
    unsigned int v15; // eax@16
    const char *v16; // ST0C_4@16
    unsigned int v17; // eax@16
    const char *v18; // ST0C_4@16
    unsigned int v19; // eax@16
    const char *v20; // ST0C_4@16
    unsigned int v21; // eax@16
    signed int v22; // ebp@16
    const char *v23; // ST0C_4@16
    unsigned int v24; // eax@16
    const char *v25; // ST0C_4@16
    unsigned int v26; // eax@16
    const char *v27; // ST0C_4@16
    unsigned int v28; // eax@16
    const char *v29; // ST0C_4@16
    unsigned int v30; // eax@16
    const char *v31; // ST0C_4@16
    unsigned int v32; // eax@16
    const char *v33; // ST0C_4@17
    unsigned int v34; // eax@17
    const char *v35; // ST0C_4@17
    unsigned int v36; // eax@17
    const char *v37; // ST0C_4@17
    unsigned int v38; // eax@17
    const char *v39; // ST0C_4@17
    unsigned int v40; // eax@17
    const char *v41; // ST0C_4@17
    unsigned int v42; // eax@17
    const char *v43; // ST0C_4@17
    unsigned int v44; // eax@17
    const char *v45; // ST0C_4@17
    unsigned int v46; // eax@17
    const char *v47; // ST0C_4@17
    unsigned int v48; // eax@17
    const char *v49; // ST0C_4@17
    unsigned int v50; // eax@17
    const char *v51; // ST0C_4@17
    unsigned int v52; // eax@17
    const char *v53; // ST0C_4@17
    unsigned int v54; // eax@17
    const char *v55; // ST0C_4@17
    unsigned int v56; // eax@17
    const char *v57; // ST0C_4@17
    unsigned int v58; // eax@17
    unsigned int v59; // eax@18
    //int v61; // [sp-14h] [bp-28h]@16
    const char *v62; // [sp-10h] [bp-24h]@16
    unsigned int a5; // [sp+10h] [bp-4h]@1

    v0 = TargetColor(0xFFu, 0xFFu, 0xFFu);
    a5 = v0;
    if ( byte_4E28FC )
        {
        v1 = dword_507C0C + 15;
        dword_507C0C = v1;
        if ( v1 == 255 )
            byte_4E28FC = 0;
        }
    else
        {
        v1 = dword_507C0C - 15;
        dword_507C0C = v1;
        if ( v1 == 15 )
            byte_4E28FC = 1;
        }
    v2 = TargetColor(v1, 0, 0);
    v3 = pGUIWindow_CurrentMenu;
    dword_507C08 = v2;
    if ( pGUIWindow_CurrentMenu->field_40 == 2 )
        {
        pPrevVirtualCidesMapping[dword_506E68] = pKeyActionMap->pPressedKeysBuffer[0];
        memset(&KeyButtonFlagChangesArray, 0, sizeof(KeyButtonFlagChangesArray));
        v4 = 0;
        do
            {
            v5 = 0;
            do
                {
                if ( v4 != v5 && pPrevVirtualCidesMapping[v4] == pPrevVirtualCidesMapping[v5] )
                    {
                    KeyButtonFlagChangesArray[v4] = 1;
                    KeyButtonFlagChangesArray[v5] = 1;
                    }
                ++v5;
                }
                while ( v5 < 28 );
                ++v4;
            }
            while ( v4 < 28 );
            dword_506E68 = -1;
            v3->field_40 = 0;
        }
    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_Optkb[0]));
    if ( KeyboardPageNum == 1 )
    {
        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, "ÍÀÇÀÄ", 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, "ÂËÅÂÎ", 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, "ÂÏÐÀÂÎ", 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, "ÊÐÈÊ", 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, "ÏÐÛÆÎÊ", 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, "Ï.ÐÅÆÈÌ", 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, "ÏÐÈÌ. ÇÀÊË.", 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, "ÀÒÀÊÀ", 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, "ÄÅÉÑÒÂ.", 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, "ÇÀÊËÈÍ.", 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, "ÈÃÐÎÊ", 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, "ÑËÅÄ. ÈÃÐÎÊ", 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, "ÇÀÄÀÍÈß", 0, 0, 0);

        v62 = pKeyActionMap->GetVKeyDisplayName(pPrevVirtualCidesMapping[13]);
        v59 = sub_414D24(13);
        }
    else
        {
        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, "ÎÒÄÛÕ", 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, "ÒÅÊ. ÂÐÅÌß", 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, "ÀÂÒÎÇÀÌÅÒÊÈ", 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, "ÊÀÐÒÀ", 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, "ÁÅÆÀÒÜ", 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, "ÑÌ. ÂÂÅÐÕ", 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, "ÑÌ. ÂÍÈÇ", 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, "ÑÌ. ÂÏÅШÄ", 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, "ÏÐÈÁËÈÇ", 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, "ÎÒÄÀËÈÒÜ", 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, "Ï. ÂÂÅÐÕ", 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, "Ï. ÂÍÈÇ", 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, "ÏÐÈÇÅÌË", 0, 0, 0);

        v62 = pKeyActionMap->GetVKeyDisplayName(pWindowList_at_506F50_minus1_indexing[0]);
        v59 = sub_414D24(27);
        }
    return pGUIWindow_CurrentMenu->DrawText(pFontLucida, v22, 268, v59, v62, 0, 0, 0);
    }


//----- (00414D24) --------------------------------------------------------
unsigned int __thiscall sub_414D24(int _this)
    {
    int v1; // esi@1
    unsigned int v2; // edi@1
    unsigned int v3; // ebx@1
    unsigned int result; // eax@1

    v1 = _this;
    v2 = TargetColor(0xE1u, 0xCDu, 0x23u);
    v3 = TargetColor(0xFu, 0, 0);
    result = TargetColor(0xFFu, 0xFFu, 0xFFu);
    if ( dword_506E68 == v1 )
        {
        if ( GetTickCount() % 0x3E8 <= 0x1F4 )
            result = v3;
        else
            result = v2;
        }
    else
        {
        if ( KeyButtonFlagChangesArray[v1] )
            result = dword_507C08;
        }
    return result;
    }

//----- (00414D9A) --------------------------------------------------------
void GameMenuUI_DrawVideoOptions()
{
    const char *v0; // ST0C_4@3
    unsigned __int16 v1; // ax@3
    //int v2; // eax@10
    GUIWindow v3; // [sp+8h] [bp-54h]@3

    pRenderer->DrawTextureIndexed(8, 8, pIcons_LOD->GetTexture(uTextureID_507C10));
    if ( !pRenderer->bWindowMode && GammaController::IsGammaSupported() )
        {
        pRenderer->DrawTextureIndexed(
            17 * uGammaPos + 42,
            162,
            pIcons_LOD->GetTexture(pTextureIDs_GammaPositions[uGammaPos]));
        pRenderer->DrawTextureRGB(0x112u, 0xA9u, &stru_506E40);
        v3.uFrameX = 22;
        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 = TargetColor(0xFFu, 0xFFu, 0x9Bu);
        v3.DrawTitleText(pFontSmallnum, 0, 0, v1, v0, 3u);
        }

    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 DrawGameOptions()
{
  pRenderer->DrawTextureIndexed(8,   8, pIcons_LOD->GetTexture(uTextureID_Options));
  pRenderer->DrawTextureIndexed(8, 132, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_Background));

  switch (uTurnSpeed)
  {
    case 64:   pRenderer->DrawTextureIndexed(BtnTurnCoord[1], 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[1])); break;
    case 128:  pRenderer->DrawTextureIndexed(BtnTurnCoord[2], 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[2])); break;
    default:   pRenderer->DrawTextureIndexed(BtnTurnCoord[0], 270, pIcons_LOD->GetTexture(options_menu_skin.uTextureID_TurnSpeed[0])); break;
  }

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










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
}