diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index c3a623d5f..c2fd04cc4 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -837,7 +837,9 @@ int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,con SetGameSettings(iPad,eGameSetting_SoundFXVolume,DEFAULT_VOLUME_LEVEL); SetGameSettings(iPad,eGameSetting_RenderDistance,16); SetGameSettings(iPad,eGameSetting_Gamma,50); - SetGameSettings(iPad,eGameSetting_FOV,0); + + // jvnpr -- FOV setting is stored as 101-201 but mapped to 0-80 (offset from 30-110). + SetGameSettings(iPad,eGameSetting_FOV,151); // 4J-PB - Don't reset the difficult level if we're in-game if(Minecraft::GetInstance()->level==nullptr) @@ -1406,9 +1408,8 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal) case eGameSetting_FOV: if(iPad==ProfileManager.GetPrimaryPad()) { - float fovDeg = 70.0f + (float)GameSettingsA[iPad]->ucFov * 40.0f / 100.0f; - pMinecraft->gameRenderer->SetFovVal(fovDeg); - pMinecraft->options->set(Options::Option::FOV, (float)GameSettingsA[iPad]->ucFov / 100.0f); + float v = (static_cast(GameSettingsA[iPad]->ucFov) - 101) * 80.0f / 100.0f; // jvnpr -- convert 0-80 to 30-110 + pMinecraft->options->fov = ( v / 40.0f ) - 1; } break; case eGameSetting_Difficulty: diff --git a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp index c997fb311..c58a0c905 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp @@ -6,6 +6,7 @@ #include "..\..\Minecraft.h" #include "..\..\MinecraftServer.h" #include "..\..\GameRenderer.h" +#include "..\..\Options.h" #include "..\..\MultiPlayerLevel.h" #include "ClientConnection.h" #include "MultiPlayerLocalPlayer.h" @@ -21,16 +22,16 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void *initData, UILayer *pa // Setup all the Iggy references we need for this scene initialiseMovie(); - const Minecraft *pMinecraft = Minecraft::GetInstance(); - WCHAR tempString[256]; - const int fovSliderVal = app.GetGameSettings(m_iPad, eGameSetting_FOV); - const int fovDeg = 70 + fovSliderVal * 40 / 100; - swprintf( tempString, 256, L"Set fov (%d)", fovDeg); - m_sliderFov.init(tempString,eControl_FOV,0,100,fovSliderVal); + Minecraft *pMinecraft = Minecraft::GetInstance(); + WCHAR TempString[256]; + int fovSliderVal = (app.GetGameSettings(m_iPad, eGameSetting_FOV) - 101) * 80.0f / 100.0f; + int fovDeg = 30 + fovSliderVal * 80 / 100; + swprintf( (WCHAR *)TempString, 256, L"Set fov (%d)", fovDeg); + m_sliderFov.init(TempString,eControl_FOV,0,80,fovSliderVal); const float currentTime = pMinecraft->level->getLevelData()->getGameTime() % 24000; - swprintf( tempString, 256, L"Set time (unsafe) (%d)", static_cast(currentTime)); - m_sliderTime.init(tempString,eControl_Time,0,240,currentTime/100); + swprintf(TempString, 256, L"Set time (unsafe) (%d)", static_cast(currentTime)); + m_sliderTime.init(TempString,eControl_Time,0,240,currentTime/100); m_buttonRain.init(L"Toggle Rain",eControl_Rain); m_buttonThunder.init(L"Toggle Thunder",eControl_Thunder); @@ -274,17 +275,18 @@ void UIScene_DebugOverlay::handleSliderMove(F64 sliderId, F64 currentValue) break; case eControl_FOV: { - Minecraft *pMinecraft = Minecraft::GetInstance(); + // jvnpr -- code here is copied from UIScene_SettingsGraphicsMenu.cpp for consistency int v = static_cast(currentValue); + Minecraft *pMinecraft = Minecraft::GetInstance(); if (v < 0) v = 0; - if (v > 100) v = 100; - int fovDeg = 70 + v * 40 / 100; - pMinecraft->gameRenderer->SetFovVal(static_cast(fovDeg)); - app.SetGameSettings(m_iPad, eGameSetting_FOV, v); + if (v > 80) v = 80; + int displayFOV = v + 30; // jvnpr -- convert 0-80 to 30-110 + + pMinecraft->options->fov = ( v / 40.0f ) - 1; + WCHAR TempString[256]; + swprintf( (WCHAR *)TempString, 256, L"FOV: %d", displayFOV); + m_sliderFov.setLabel(TempString); - WCHAR tempString[256]; - swprintf( tempString, 256, L"Set fov (%d)", fovDeg); - m_sliderFov.setLabel(tempString); } break; }; diff --git a/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp b/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp index a1cbc1449..b520bbf70 100644 --- a/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_MainMenu.cpp @@ -3,6 +3,7 @@ #include "..\..\..\Minecraft.World\StringHelpers.h" #include "..\..\..\Minecraft.World\Random.h" #include "..\..\User.h" +#include "..\..\Options.h" #include "..\..\MinecraftServer.h" #include "UI.h" #include "UIScene_MainMenu.h" @@ -32,6 +33,17 @@ UIScene_MainMenu::UIScene_MainMenu(int iPad, void *initData, UILayer *parentLaye m_eAction=eAction_None; m_bIgnorePress=false; + Minecraft* pMinecraft = Minecraft::GetInstance(); + + // jvnpr -- convert old FOV setting to new + if (app.GetGameSettings(m_iPad, eGameSetting_FOV) < 101) { + float newFov = app.GetGameSettings(m_iPad, eGameSetting_FOV) * 40.0f / 100.0f; // old system stores 70-110 as 0-100. divide by 4 to get 0-40 for 70-110 + if (newFov > 15) newFov = 15; // FOV of 85 in the old system is the same as 110 in new system, so if set higher than that we need to cap it. + newFov *= (40.0f / 15.0f); // we need to map the old range from 70-85 to 70-110 so we can convert to a new equivalent FOV + newFov += 40; // apply offset so now our FOV is between 40-80 (which is 70-110 in new system) + app.SetGameSettings(m_iPad, eGameSetting_FOV, (newFov / (80.0f / 100.0f)) + 101); // store new value in range from 101-201 + pMinecraft->options->fov = (newFov / 40.0f) - 1; + } m_buttons[static_cast(eControl_PlayGame)].init(IDS_PLAY_GAME,eControl_PlayGame); diff --git a/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp index b258d8c31..3212e4b50 100644 --- a/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SettingsGraphicsMenu.cpp @@ -5,34 +5,6 @@ #include "..\..\Options.h" #include "..\..\GameRenderer.h" -namespace -{ - constexpr int FOV_MIN = 70; - constexpr int FOV_MAX = 110; - constexpr int FOV_SLIDER_MAX = 100; - - int ClampFov(int value) - { - if (value < FOV_MIN) return FOV_MIN; - if (value > FOV_MAX) return FOV_MAX; - return value; - } - - [[maybe_unused]] - int FovToSliderValue(float fov) - { - const int clampedFov = ClampFov(static_cast(fov + 0.5f)); - return ((clampedFov - FOV_MIN) * FOV_SLIDER_MAX) / (FOV_MAX - FOV_MIN); - } - - int sliderValueToFov(int sliderValue) - { - if (sliderValue < 0) sliderValue = 0; - if (sliderValue > FOV_SLIDER_MAX) sliderValue = FOV_SLIDER_MAX; - return FOV_MIN + ((sliderValue * (FOV_MAX - FOV_MIN)) / FOV_SLIDER_MAX); - } -} - int UIScene_SettingsGraphicsMenu::LevelToDistance(int level) { static const int table[6] = {2,4,8,16,32,64}; @@ -63,7 +35,7 @@ UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initD m_checkboxBedrockFog.init(app.GetString(IDS_CHECKBOX_RENDER_BEDROCKFOG),eControl_BedrockFog,(app.GetGameSettings(m_iPad,eGameSetting_BedrockFog)!=0)); m_checkboxCustomSkinAnim.init(app.GetString(IDS_CHECKBOX_CUSTOM_SKIN_ANIM),eControl_CustomSkinAnim,(app.GetGameSettings(m_iPad,eGameSetting_CustomSkinAnim)!=0)); - + WCHAR TempString[256]; swprintf(TempString, 256, L"Render Distance: %d",app.GetGameSettings(m_iPad,eGameSetting_RenderDistance)); @@ -72,10 +44,15 @@ UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initD swprintf( TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_GAMMA ),app.GetGameSettings(m_iPad,eGameSetting_Gamma)); m_sliderGamma.init(TempString,eControl_Gamma,0,100,app.GetGameSettings(m_iPad,eGameSetting_Gamma)); - const int initialFovSlider = app.GetGameSettings(m_iPad, eGameSetting_FOV); - const int initialFovDeg = sliderValueToFov(initialFovSlider); - swprintf(TempString, 256, L"FOV: %d", initialFovDeg); - m_sliderFOV.init(TempString, eControl_FOV, 0, FOV_SLIDER_MAX, initialFovSlider); + if (static_cast(30.0f + (app.GetGameSettings(m_iPad, eGameSetting_FOV) - 101) * 80.0f / 100.0f) == 70) + { + swprintf((WCHAR*)TempString, 256, L"FOV: Default"); + } + else + { + swprintf((WCHAR*)TempString, 256, L"FOV: %d", static_cast(30.0f + (app.GetGameSettings(m_iPad, eGameSetting_FOV) - 101) * 80.0f / 100.0f)); + } + m_sliderFOV.init(TempString, eControl_FOV, 0, 80, ((app.GetGameSettings(m_iPad, eGameSetting_FOV)) - 101) * 80.0f / 100.0f); swprintf( TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_INTERFACEOPACITY ),app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity)); m_sliderInterfaceOpacity.init(TempString,eControl_InterfaceOpacity,0,100,app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity)); @@ -216,15 +193,29 @@ void UIScene_SettingsGraphicsMenu::handleSliderMove(F64 sliderId, F64 currentVal break; case eControl_FOV: - { - m_sliderFOV.handleSliderMove(value); - const Minecraft* pMinecraft = Minecraft::GetInstance(); - const int fovValue = sliderValueToFov(value); - pMinecraft->gameRenderer->SetFovVal(static_cast(fovValue)); - app.SetGameSettings(m_iPad, eGameSetting_FOV, value); - WCHAR tempString[256]; - swprintf(tempString, 256, L"FOV: %d", fovValue); - m_sliderFOV.setLabel(tempString); + { + + // jvnpr -- code in Consoles_App.cpp should always reflect the same calculations as here so that controller and mouse inputs work the same. + int v = static_cast(currentValue); + m_sliderFOV.handleSliderMove(v); + Minecraft *pMinecraft = Minecraft::GetInstance(); + if (v < 0) v = 0; + if (v > 80) v = 80; + int displayFOV = v + 30; // jvnpr -- convert 0-80 to 30-110 + + pMinecraft->options->fov = (v / 40.0f) - 1; // jvnpr -- use FOV option instead of hooking into gamerenderer (range from -1 to 1 for 30-110) + WCHAR TempString[256]; + + if (v + 30 == 70) { + swprintf((WCHAR*)TempString, 256, L"FOV: Default", displayFOV); // when fov is 70 display "FOV: Default (90)" + } + else { + swprintf((WCHAR*)TempString, 256, L"FOV: %d", displayFOV); + } + + m_sliderFOV.setLabel(TempString); + + app.SetGameSettings(m_iPad, eGameSetting_FOV, (v / ( 80.0f / 100.0f )) + 101); // offset from storing as 0-100 to 101-201 to detect whether we use old system and convert } break; diff --git a/Minecraft.Client/GameRenderer.cpp b/Minecraft.Client/GameRenderer.cpp index 73b39529c..ffc805749 100644 --- a/Minecraft.Client/GameRenderer.cpp +++ b/Minecraft.Client/GameRenderer.cpp @@ -132,6 +132,8 @@ GameRenderer::GameRenderer(Minecraft *mc) m_fov=70.0f; + h_fov=70.0f; // jvnpr -- Hardcoded hand FOV to prevent scaling with main renderer fov + // 4J Stu - Init these so they are setup before the tick for( int i = 0; i < 4; i++ ) { @@ -716,14 +718,14 @@ void GameRenderer::renderItemInHand(float a, int eye) // 4J - have split out fov & aspect calculation so we can take into account viewports float fov, aspect; - getFovAndAspect(fov, aspect, a, false); + getFovAndAspect(fov, aspect, a, false); // jvnpr -- don't need to run fov calc since it's hardcoded now but it's probably better to just leave this if (zoom != 1) { glTranslatef(static_cast(zoom_x), static_cast(-zoom_y), 0); glScaled(zoom, zoom, 1); } - gluPerspective(fov, aspect, 0.05f, renderDistance * 2); + gluPerspective(h_fov, aspect, 0.05f, renderDistance * 2); // jvnpr -- hardcoded h_fov to fix hand fov scaling if (mc->gameMode->isCutScene()) { diff --git a/Minecraft.Client/GameRenderer.h b/Minecraft.Client/GameRenderer.h index c379106e0..3a8aa5826 100644 --- a/Minecraft.Client/GameRenderer.h +++ b/Minecraft.Client/GameRenderer.h @@ -90,6 +90,8 @@ class GameRenderer bool isInClouds; float m_fov; + + float h_fov; // jvnpr -- Hardcoded hand FOV to prevent scaling with main renderer fov public: GameRenderer(Minecraft *mc); ~GameRenderer();