mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-08-20 09:57:09 +00:00
render distance option for graphics menu
This commit is contained in:
parent
05fdb3a548
commit
5b74e9d5e4
|
|
@ -133,6 +133,7 @@ enum eGameSetting
|
|||
{
|
||||
eGameSetting_MusicVolume=0,
|
||||
eGameSetting_SoundFXVolume,
|
||||
eGameSetting_RenderDistance,
|
||||
eGameSetting_Gamma,
|
||||
eGameSetting_Difficulty,
|
||||
eGameSetting_Sensitivity_InGame,
|
||||
|
|
|
|||
|
|
@ -835,6 +835,7 @@ int CMinecraftApp::SetDefaultOptions(C_4JProfile::PROFILESETTINGS *pSettings,con
|
|||
{
|
||||
SetGameSettings(iPad,eGameSetting_MusicVolume,DEFAULT_VOLUME_LEVEL);
|
||||
SetGameSettings(iPad,eGameSetting_SoundFXVolume,DEFAULT_VOLUME_LEVEL);
|
||||
SetGameSettings(iPad,eGameSetting_RenderDistance,16);
|
||||
SetGameSettings(iPad,eGameSetting_Gamma,50);
|
||||
|
||||
// 4J-PB - Don't reset the difficult level if we're in-game
|
||||
|
|
@ -1329,6 +1330,7 @@ void CMinecraftApp::ApplyGameSettingsChanged(int iPad)
|
|||
{
|
||||
ActionGameSettings(iPad,eGameSetting_MusicVolume );
|
||||
ActionGameSettings(iPad,eGameSetting_SoundFXVolume );
|
||||
ActionGameSettings(iPad,eGameSetting_RenderDistance );
|
||||
ActionGameSettings(iPad,eGameSetting_Gamma );
|
||||
ActionGameSettings(iPad,eGameSetting_Difficulty );
|
||||
ActionGameSettings(iPad,eGameSetting_Sensitivity_InGame );
|
||||
|
|
@ -1377,6 +1379,15 @@ void CMinecraftApp::ActionGameSettings(int iPad,eGameSetting eVal)
|
|||
pMinecraft->options->set(Options::Option::SOUND,((float)GameSettingsA[iPad]->ucSoundFXVolume)/100.0f);
|
||||
}
|
||||
break;
|
||||
case eGameSetting_RenderDistance:
|
||||
if(iPad == ProfileManager.GetPrimaryPad())
|
||||
{
|
||||
int dist = (GameSettingsA[iPad]->uiBitmaskValues >> 16) & 0xFF;
|
||||
|
||||
int level = UIScene_SettingsGraphicsMenu::DistanceToLevel(dist);
|
||||
pMinecraft->options->set(Options::Option::RENDER_DISTANCE, 3 - level);
|
||||
}
|
||||
break;
|
||||
case eGameSetting_Gamma:
|
||||
if(iPad==ProfileManager.GetPrimaryPad())
|
||||
{
|
||||
|
|
@ -1838,6 +1849,17 @@ void CMinecraftApp::SetGameSettings(int iPad,eGameSetting eVal,unsigned char ucV
|
|||
GameSettingsA[iPad]->bSettingsChanged=true;
|
||||
}
|
||||
break;
|
||||
case eGameSetting_RenderDistance:
|
||||
{
|
||||
unsigned int val = ucVal & 0xFF;
|
||||
|
||||
GameSettingsA[iPad]->uiBitmaskValues &= ~(0xFF << 16);
|
||||
GameSettingsA[iPad]->uiBitmaskValues |= val << 16;
|
||||
if(iPad == ProfileManager.GetPrimaryPad())
|
||||
ActionGameSettings(iPad,eVal);
|
||||
GameSettingsA[iPad]->bSettingsChanged = true;
|
||||
}
|
||||
break;
|
||||
case eGameSetting_Gamma:
|
||||
if(GameSettingsA[iPad]->ucGamma!=ucVal)
|
||||
{
|
||||
|
|
@ -2286,6 +2308,9 @@ unsigned char CMinecraftApp::GetGameSettings(int iPad,eGameSetting eVal)
|
|||
case eGameSetting_SoundFXVolume:
|
||||
return GameSettingsA[iPad]->ucSoundFXVolume;
|
||||
break;
|
||||
case eGameSetting_RenderDistance:
|
||||
return (GameSettingsA[iPad]->uiBitmaskValues >> 16) & 0xFF;
|
||||
break;
|
||||
case eGameSetting_Gamma:
|
||||
return GameSettingsA[iPad]->ucGamma;
|
||||
break;
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -2,6 +2,7 @@
|
|||
#include "UI.h"
|
||||
#include "UIScene_SettingsGraphicsMenu.h"
|
||||
#include "..\..\Minecraft.h"
|
||||
#include "..\..\Options.h"
|
||||
#include "..\..\GameRenderer.h"
|
||||
|
||||
namespace
|
||||
|
|
@ -29,6 +30,24 @@ namespace
|
|||
if (sliderValue > FOV_SLIDER_MAX) sliderValue = FOV_SLIDER_MAX;
|
||||
return FOV_MIN + ((sliderValue * (FOV_MAX - FOV_MIN)) / FOV_SLIDER_MAX);
|
||||
}
|
||||
|
||||
int LevelToDistance(int level)
|
||||
{
|
||||
static const int table[6] = {2,4,8,16,32,64};
|
||||
if(level < 0) level = 0;
|
||||
if(level > 5) level = 5;
|
||||
return table[level];
|
||||
}
|
||||
}
|
||||
|
||||
int UIScene_SettingsGraphicsMenu::DistanceToLevel(int dist)
|
||||
{
|
||||
static const int table[6] = {2,4,8,16,32,64};
|
||||
for(int i = 0; i < 6; i++){
|
||||
if(table[i] == dist)
|
||||
return i;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
|
||||
|
|
@ -45,6 +64,9 @@ UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initD
|
|||
|
||||
|
||||
WCHAR TempString[256];
|
||||
|
||||
swprintf((WCHAR*)TempString, 256, L"Render Distance: %d",app.GetGameSettings(m_iPad,eGameSetting_RenderDistance));
|
||||
m_sliderRenderDistance.init(TempString,eControl_RenderDistance,0,5,DistanceToLevel(app.GetGameSettings(m_iPad,eGameSetting_RenderDistance)));
|
||||
|
||||
swprintf( (WCHAR *)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));
|
||||
|
|
@ -167,6 +189,21 @@ void UIScene_SettingsGraphicsMenu::handleSliderMove(F64 sliderId, F64 currentVal
|
|||
int value = (int)currentValue;
|
||||
switch((int)sliderId)
|
||||
{
|
||||
case eControl_RenderDistance:
|
||||
{
|
||||
m_sliderRenderDistance.handleSliderMove(value);
|
||||
|
||||
int dist = LevelToDistance(value);
|
||||
|
||||
app.SetGameSettings(m_iPad,eGameSetting_RenderDistance,dist);
|
||||
|
||||
Minecraft* mc = Minecraft::GetInstance();
|
||||
mc->options->viewDistance = 3 - value;
|
||||
swprintf((WCHAR*)TempString,256,L"Render Distance: %d",dist);
|
||||
m_sliderRenderDistance.setLabel(TempString);
|
||||
}
|
||||
break;
|
||||
|
||||
case eControl_Gamma:
|
||||
m_sliderGamma.handleSliderMove(value);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,17 +10,19 @@ private:
|
|||
eControl_Clouds,
|
||||
eControl_BedrockFog,
|
||||
eControl_CustomSkinAnim,
|
||||
eControl_RenderDistance,
|
||||
eControl_Gamma,
|
||||
eControl_FOV,
|
||||
eControl_InterfaceOpacity
|
||||
};
|
||||
|
||||
UIControl_CheckBox m_checkboxClouds, m_checkboxBedrockFog, m_checkboxCustomSkinAnim; // Checkboxes
|
||||
UIControl_Slider m_sliderGamma, m_sliderFOV, m_sliderInterfaceOpacity; // Sliders
|
||||
UIControl_Slider m_sliderRenderDistance, m_sliderGamma, m_sliderFOV, m_sliderInterfaceOpacity; // Sliders
|
||||
UI_BEGIN_MAP_ELEMENTS_AND_NAMES(UIScene)
|
||||
UI_MAP_ELEMENT( m_checkboxClouds, "Clouds")
|
||||
UI_MAP_ELEMENT( m_checkboxBedrockFog, "BedrockFog")
|
||||
UI_MAP_ELEMENT( m_checkboxCustomSkinAnim, "CustomSkinAnim")
|
||||
UI_MAP_ELEMENT( m_sliderRenderDistance, "RenderDistance")
|
||||
UI_MAP_ELEMENT( m_sliderGamma, "Gamma")
|
||||
UI_MAP_ELEMENT(m_sliderFOV, "FOV")
|
||||
UI_MAP_ELEMENT( m_sliderInterfaceOpacity, "InterfaceOpacity")
|
||||
|
|
@ -45,4 +47,6 @@ public:
|
|||
virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled);
|
||||
|
||||
virtual void handleSliderMove(F64 sliderId, F64 currentValue);
|
||||
|
||||
static int DistanceToLevel(int dist);
|
||||
};
|
||||
|
|
@ -74,7 +74,7 @@ ResourceLocation GameRenderer::SNOW_LOCATION = ResourceLocation(TN_ENVIRONMENT_S
|
|||
GameRenderer::GameRenderer(Minecraft *mc)
|
||||
{
|
||||
// 4J - added this block of initialisers
|
||||
renderDistance = 0;
|
||||
renderDistance = mc->options->viewDistance;
|
||||
_tick = 0;
|
||||
hovered = nullptr;
|
||||
thirdDistance = 4;
|
||||
|
|
@ -614,7 +614,15 @@ void GameRenderer::getFovAndAspect(float& fov, float& aspect, float a, bool appl
|
|||
|
||||
void GameRenderer::setupCamera(float a, int eye)
|
||||
{
|
||||
renderDistance = (float)(16 * 16 >> (mc->options->viewDistance));
|
||||
if (mc->options->viewDistance >= 0)
|
||||
{
|
||||
renderDistance = (float)(16 * 16 >> mc->options->viewDistance);
|
||||
}
|
||||
else
|
||||
{
|
||||
renderDistance = (float)((16 * 16) << (-mc->options->viewDistance));
|
||||
}
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue