Add Render Distance option. (#675)
* FOV option without debug menu Now located in Graphics section. Based on the FOV thing from discord idk * language * render distance option for graphics menu * oop * swf files on media * revert changes on language selector * nvm it was actually easy to fix * forgot this * Final probably Fixed visual bug and made the chunk updates depend to your view distance.
This commit is contained in:
@@ -133,6 +133,7 @@ enum eGameSetting
|
||||
{
|
||||
eGameSetting_MusicVolume=0,
|
||||
eGameSetting_SoundFXVolume,
|
||||
eGameSetting_RenderDistance,
|
||||
eGameSetting_Gamma,
|
||||
eGameSetting_FOV,
|
||||
eGameSetting_Difficulty,
|
||||
|
||||
@@ -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);
|
||||
SetGameSettings(iPad,eGameSetting_FOV,0);
|
||||
|
||||
@@ -1330,6 +1331,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_FOV );
|
||||
ActionGameSettings(iPad,eGameSetting_Difficulty );
|
||||
@@ -1379,6 +1381,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())
|
||||
{
|
||||
@@ -1848,6 +1859,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)
|
||||
{
|
||||
@@ -2307,6 +2329,13 @@ unsigned char CMinecraftApp::GetGameSettings(int iPad,eGameSetting eVal)
|
||||
case eGameSetting_SoundFXVolume:
|
||||
return GameSettingsA[iPad]->ucSoundFXVolume;
|
||||
break;
|
||||
case eGameSetting_RenderDistance:
|
||||
{
|
||||
int val = (GameSettingsA[iPad]->uiBitmaskValues >> 16) & 0xFF;
|
||||
if(val == 0) return val = 16; //brain
|
||||
return val;
|
||||
break;
|
||||
}
|
||||
case eGameSetting_Gamma:
|
||||
return GameSettingsA[iPad]->ucGamma;
|
||||
break;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -126,4 +126,4 @@ void UIScene_LanguageSelector::handlePress(F64 controlId, F64 childId)
|
||||
|
||||
app.CheckGameSettingsChanged(true, m_iPad);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "UI.h"
|
||||
#include "UIScene_SettingsGraphicsMenu.h"
|
||||
#include "..\..\Minecraft.h"
|
||||
#include "..\..\Options.h"
|
||||
#include "..\..\GameRenderer.h"
|
||||
|
||||
namespace
|
||||
@@ -31,6 +32,24 @@ namespace
|
||||
}
|
||||
}
|
||||
|
||||
int UIScene_SettingsGraphicsMenu::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 3;
|
||||
}
|
||||
|
||||
UIScene_SettingsGraphicsMenu::UIScene_SettingsGraphicsMenu(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer)
|
||||
{
|
||||
// Setup all the Iggy references we need for this scene
|
||||
@@ -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));
|
||||
@@ -168,6 +190,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);
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include "UIScene.h"
|
||||
#include "Common/UI/UIControl_CheckBox.h"
|
||||
#include "Common/UI/UIControl_Slider.h"
|
||||
|
||||
class UIScene_SettingsGraphicsMenu : public UIScene
|
||||
{
|
||||
@@ -10,17 +12,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 +49,8 @@ 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 LevelToDistance(int dist);
|
||||
|
||||
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 = (float)(16 * 16 >> 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();
|
||||
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
#include "..\Minecraft.World\SoundTypes.h"
|
||||
#include "FrustumCuller.h"
|
||||
#include "..\Minecraft.World\BasicTypeContainers.h"
|
||||
#include "Common/UI/UIScene_SettingsGraphicsMenu.h"
|
||||
|
||||
//#define DISABLE_SPU_CODE
|
||||
|
||||
@@ -426,8 +427,11 @@ void LevelRenderer::allChanged(int playerIndex)
|
||||
Tile::leaves->setFancy(mc->options->fancyGraphics);
|
||||
lastViewDistance = mc->options->viewDistance;
|
||||
|
||||
int realviewDistance = UIScene_SettingsGraphicsMenu::LevelToDistance(3 - mc->options->viewDistance) + 2;
|
||||
int realrenderArea = (realviewDistance * realviewDistance * 4);
|
||||
|
||||
// Calculate size of area we can render based on number of players we need to render for
|
||||
int dist = (int)sqrtf( (float)PLAYER_RENDER_AREA / (float)activePlayers() );
|
||||
int dist = (int)sqrtf( (float)realrenderArea / (float)activePlayers() );
|
||||
|
||||
// AP - poor little Vita just can't cope with such a big area
|
||||
#ifdef __PSVITA__
|
||||
|
||||
@@ -238,6 +238,10 @@ void Options::set(const Options::Option *item, float fVal)
|
||||
{
|
||||
gamma = fVal;
|
||||
}
|
||||
if (item == Option::RENDER_DISTANCE)
|
||||
{
|
||||
viewDistance = fVal;
|
||||
}
|
||||
}
|
||||
|
||||
void Options::toggle(const Options::Option *option, int dir)
|
||||
@@ -292,6 +296,7 @@ float Options::getProgressValue(const Options::Option *item)
|
||||
if (item == Option::MUSIC) return music;
|
||||
if (item == Option::SOUND) return sound;
|
||||
if (item == Option::SENSITIVITY) return sensitivity;
|
||||
if (item == Option::RENDER_DISTANCE) return viewDistance;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user