mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
use fov options implementation instead of modifying gamerenderer hardcoded value
This commit is contained in:
parent
a58cf0cc39
commit
f0e604d988
|
|
@ -852,7 +852,7 @@ 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);
|
||||
SetGameSettings(iPad,eGameSetting_FOV,40); //jvnpr -- 40 here is an FOV of 70 (FOV = eGameSetting_FOV - 30)
|
||||
|
||||
// 4J-PB - Don't reset the difficult level if we're in-game
|
||||
if(Minecraft::GetInstance()->level==nullptr)
|
||||
|
|
@ -1424,9 +1424,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<float>(GameSettingsA[iPad]->ucFov);
|
||||
pMinecraft->options->fov = (v / 40.0f) - 1; // map to range between -1 and 1.
|
||||
}
|
||||
break;
|
||||
case eGameSetting_Difficulty:
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -22,15 +23,14 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void *initData, UILayer *pa
|
|||
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);
|
||||
WCHAR TempString[256];
|
||||
const int displayFOV = 30 + app.GetGameSettings(m_iPad,eGameSetting_FOV);
|
||||
swprintf(TempString, 256, L"Set fov (%d)", fovDeg);
|
||||
m_sliderFov.init(TempString,eControl_FOV,0,80,app.GetGameSettings(m_iPad,eGameSetting_FOV);
|
||||
|
||||
const float currentTime = pMinecraft->level->getLevelData()->getGameTime() % 24000;
|
||||
swprintf( tempString, 256, L"Set time (unsafe) (%d)", static_cast<int>(currentTime));
|
||||
m_sliderTime.init(tempString,eControl_Time,0,240,currentTime/100);
|
||||
swprintf(TempString, 256, L"Set time (unsafe) (%d)", static_cast<int>(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 +274,17 @@ void UIScene_DebugOverlay::handleSliderMove(F64 sliderId, F64 currentValue)
|
|||
break;
|
||||
case eControl_FOV:
|
||||
{
|
||||
Minecraft *pMinecraft = Minecraft::GetInstance();
|
||||
int v = static_cast<int>(currentValue);
|
||||
if (v < 0) v = 0;
|
||||
if (v > 100) v = 100;
|
||||
int fovDeg = 70 + v * 40 / 100;
|
||||
pMinecraft->gameRenderer->SetFovVal(static_cast<float>(fovDeg));
|
||||
app.SetGameSettings(m_iPad, eGameSetting_FOV, v);
|
||||
if (v > 80) v = 80;
|
||||
int displayFOV = v + 30; // convert 0-80 to 30-110
|
||||
|
||||
WCHAR tempString[256];
|
||||
swprintf( tempString, 256, L"Set fov (%d)", fovDeg);
|
||||
m_sliderFov.setLabel(tempString);
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
pMinecraft->options->fov = (v / 40.0f) - 1;
|
||||
|
||||
WCHAR TempString[256];
|
||||
swprintf((WCHAR*)TempString, 256, L"FOV: %d", displayFOV);
|
||||
m_sliderFov.setLabel(TempString);
|
||||
}
|
||||
break;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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<int>(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};
|
||||
|
|
@ -72,11 +44,11 @@ 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 FOV = 70, display "Default" instead; otherwise display true value.
|
||||
if (static_cast<int>(30.0f + app.GetGameSettings(m_iPad, eGameSetting_FOV)) == 70) swprintf((WCHAR*)TempString, 256, L"FOV: Default");
|
||||
else swprintf((WCHAR*)TempString, 256, L"FOV: %d", static_cast<int>(30.0f + app.GetGameSettings(m_iPad, eGameSetting_FOV)));
|
||||
m_sliderFOV.init(TempString, eControl_FOV, 0, 80, app.GetGameSettings(m_iPad, eGameSetting_FOV));
|
||||
|
||||
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));
|
||||
|
||||
|
|
@ -217,14 +189,25 @@ void UIScene_SettingsGraphicsMenu::handleSliderMove(F64 sliderId, F64 currentVal
|
|||
|
||||
case eControl_FOV:
|
||||
{
|
||||
m_sliderFOV.handleSliderMove(value);
|
||||
const Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
const int fovValue = sliderValueToFov(value);
|
||||
pMinecraft->gameRenderer->SetFovVal(static_cast<float>(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 reflect the same calculations as here so that controller and mouse inputs work the same.
|
||||
int v = static_cast<int>(currentValue);
|
||||
m_sliderFOV.handleSliderMove(v);
|
||||
|
||||
if (v < 0) v = 0;
|
||||
if (v > 80) v = 80;
|
||||
int displayFOV = v + 30;
|
||||
|
||||
Minecraft* pMinecraft = Minecraft::GetInstance();
|
||||
pMinecraft->options->fov = (v / 40.0f) - 1; // use FOV option framework instead of modifying hardcoded gameRenderer value
|
||||
|
||||
WCHAR TempString[256];
|
||||
|
||||
if (displayFOV == 70) swprintf((WCHAR*)TempString, 256, L"FOV: Default");
|
||||
else swprintf((WCHAR*)TempString, 256, L"FOV: %d", static_cast<int>(30.0f + app.GetGameSettings(m_iPad, eGameSetting_FOV)));
|
||||
m_sliderFOV.setLabel(TempString);
|
||||
|
||||
app.SetGameSettings(m_iPad, eGameSetting_FOV, v);
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue