mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-05-22 10:44:49 +00:00
328 lines
11 KiB
C++
328 lines
11 KiB
C++
#include "stdafx.h"
|
|
#include "UI.h"
|
|
#include "UIScene_SettingsGraphicsMenu.h"
|
|
#include "..\..\Minecraft.h"
|
|
#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::m_iGraphicsModeTitleSettingA[4]=
|
|
{
|
|
IDS_GRAPHICSMODE_POTATO,
|
|
IDS_GRAPHICSMODE_FAST,
|
|
IDS_GRAPHICSMODE_FANCY,
|
|
IDS_GRAPHICSMODE_EXTRA
|
|
};
|
|
|
|
int UIScene_SettingsGraphicsMenu::LevelToDistance(int level)
|
|
{
|
|
static const int table[5] = {2,4,8,16,32};
|
|
if(level < 0) level = 0;
|
|
if(level > 4) level = 4;
|
|
return table[level];
|
|
}
|
|
|
|
int UIScene_SettingsGraphicsMenu::DistanceToLevel(int dist)
|
|
{
|
|
static const int table[5] = {2,4,8,16,32};
|
|
for(int i = 0; i < 5; 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
|
|
initialiseMovie();
|
|
|
|
m_labelGeneralOptions.init( L"General" ); //IDS_GENERAL
|
|
m_labelQualityOptions.init( L"Quality" ); //IDS_QUALITY
|
|
|
|
IggyDataValue result;
|
|
|
|
IggyDataValue value[1];
|
|
value[0].type = IGGY_DATATYPE_number;
|
|
value[0].number = 0;
|
|
|
|
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcSetMenuType , 1 , value );
|
|
|
|
m_tabIndex = TAB_GENERAL_OPTIONS;
|
|
|
|
m_generalOptionsList.AddNewCheckbox(app.GetString(IDS_CHECKBOX_CUSTOM_SKIN_ANIM),eControl_CustomSkinAnim,(app.GetGameSettings(m_iPad,eGameSetting_CustomSkinAnim)!=0));
|
|
|
|
WCHAR TempString[256];
|
|
|
|
swprintf(TempString, 256, L"%ls: %d", app.GetString( IDS_SLIDER_RENDERDISTANCE ),app.GetGameSettings(m_iPad,eGameSetting_RenderDistance));
|
|
m_generalOptionsList.AddNewSlider(TempString,eControl_RenderDistance,0,3,DistanceToLevel(app.GetGameSettings(m_iPad,eGameSetting_RenderDistance)));
|
|
|
|
swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_GAMMA ),app.GetGameSettings(m_iPad,eGameSetting_Gamma));
|
|
m_generalOptionsList.AddNewSlider(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"%ls: %d", app.GetString( IDS_SLIDER_FOV ),initialFovDeg);
|
|
m_generalOptionsList.AddNewSlider(TempString, eControl_FOV, 0, FOV_SLIDER_MAX, initialFovSlider);
|
|
|
|
swprintf(TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_INTERFACEOPACITY ),app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity));
|
|
m_generalOptionsList.AddNewSlider(TempString,eControl_InterfaceOpacity,0,100,app.GetGameSettings(m_iPad,eGameSetting_InterfaceOpacity));
|
|
|
|
m_qualityOptionsList.AddNewCheckbox(app.GetString(IDS_CHECKBOX_RENDER_CLOUDS),eControl_Clouds,(app.GetGameSettings(m_iPad,eGameSetting_Clouds)!=0));
|
|
m_qualityOptionsList.AddNewCheckbox(app.GetString(IDS_CHECKBOX_RENDER_BEDROCKFOG),eControl_BedrockFog,(app.GetGameSettings(m_iPad,eGameSetting_BedrockFog)!=0));
|
|
|
|
int currentGraphics = app.GetGameSettings(m_iPad, eGameSetting_GraphicsMode);
|
|
swprintf(TempString, 256, L"%ls %ls", app.GetString( IDS_GRAPHICS ),app.GetString(m_iGraphicsModeTitleSettingA[app.GetGameSettings(m_iPad,eGameSetting_GraphicsMode)]));
|
|
m_qualityOptionsList.AddNewSlider(TempString, eControl_GraphicsMode, 0, 3, currentGraphics);
|
|
|
|
/*
|
|
Minecraft* pMinecraft = Minecraft::GetInstance();
|
|
|
|
m_bNotInGame=(Minecraft::GetInstance()->level==nullptr);
|
|
|
|
m_checkboxClouds.init(app.GetString(IDS_CHECKBOX_RENDER_CLOUDS),eControl_Clouds,(app.GetGameSettings(m_iPad,eGameSetting_Clouds)!=0));
|
|
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"%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"%ls: %d", app.GetString( IDS_SLIDER_FOV ),initialFovDeg);
|
|
m_sliderFOV.init(TempString, eControl_FOV, 0, FOV_SLIDER_MAX, initialFovSlider);
|
|
|
|
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));
|
|
|
|
swprintf(TempString, 256, L"%ls: %d", app.GetString( IDS_SLIDER_RENDERDISTANCE ),app.GetGameSettings(m_iPad,eGameSetting_RenderDistance));
|
|
m_sliderRenderDistance.init(TempString,eControl_RenderDistance,0,3,DistanceToLevel(app.GetGameSettings(m_iPad,eGameSetting_RenderDistance)));
|
|
|
|
int currentGraphics = app.GetGameSettings(m_iPad, eGameSetting_GraphicsMode);
|
|
|
|
swprintf(TempString, 256, L"%ls %ls", app.GetString( IDS_GRAPHICS ),app.GetString(m_iGraphicsModeTitleSettingA[app.GetGameSettings(m_iPad,eGameSetting_GraphicsMode)]));
|
|
m_sliderGraphicsMode.init(TempString, eControl_GraphicsMode, 0, 3, currentGraphics);
|
|
|
|
doHorizontalResizeCheck();
|
|
|
|
const bool bInGame=(Minecraft::GetInstance()->level!=nullptr);
|
|
const bool bIsPrimaryPad=(ProfileManager.GetPrimaryPad()==m_iPad);
|
|
// if we're not in the game, we need to use basescene 0
|
|
if(bInGame)
|
|
{
|
|
// If the game has started, then you need to be the host to change the in-game gamertags
|
|
if(bIsPrimaryPad)
|
|
{
|
|
// we are the primary player on this machine, but not the game host
|
|
// are we the game host? If not, we need to remove the bedrockfog setting
|
|
if(!g_NetworkManager.IsHost())
|
|
{
|
|
// hide the in-game bedrock fog setting
|
|
removeControl(&m_checkboxBedrockFog, true);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// We shouldn't have the bedrock fog option, or the m_CustomSkinAnim option
|
|
removeControl(&m_checkboxBedrockFog, true);
|
|
removeControl(&m_checkboxCustomSkinAnim, true);
|
|
}
|
|
}
|
|
|
|
if(app.GetLocalPlayerCount()>1)
|
|
{
|
|
#if TO_BE_IMPLEMENTED
|
|
app.AdjustSplitscreenScene(m_hObj,&m_OriginalPosition,m_iPad);
|
|
#endif
|
|
}
|
|
*/
|
|
}
|
|
|
|
void UIScene_SettingsGraphicsMenu::updateTooltips()
|
|
{
|
|
int changeTabTooltip = -1;
|
|
|
|
// Set tooltip for change tab (only two tabs)
|
|
if (m_tabIndex == TAB_QUALITY_OPTIONS)
|
|
changeTabTooltip = IDS_GENERAL_OPTIONS;
|
|
else
|
|
changeTabTooltip = IDS_QUALITY_OPTIONS;
|
|
|
|
// If there's a change tab tooltip, left bumper symbol should show but not the text (-2)
|
|
int lb = changeTabTooltip == -1 ? -1 : -2;
|
|
|
|
ui.SetTooltips( DEFAULT_XUI_MENU_USER, IDS_TOOLTIPS_SELECT, IDS_TOOLTIPS_BACK, -1, -1, -1, -1, lb, changeTabTooltip);
|
|
}
|
|
|
|
void UIScene_SettingsGraphicsMenu::updateComponents()
|
|
{
|
|
const bool bNotInGame=(Minecraft::GetInstance()->level==nullptr);
|
|
if(bNotInGame)
|
|
{
|
|
m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,true);
|
|
m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,true);
|
|
}
|
|
else
|
|
{
|
|
m_parentLayer->showComponent(m_iPad,eUIComponent_Panorama,false);
|
|
|
|
if( app.GetLocalPlayerCount() == 1 ) m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,true);
|
|
else m_parentLayer->showComponent(m_iPad,eUIComponent_Logo,false);
|
|
|
|
}
|
|
}
|
|
|
|
wstring UIScene_SettingsGraphicsMenu::getMoviePath()
|
|
{
|
|
return L"SettingsGraphicsMenu";
|
|
}
|
|
|
|
void UIScene_SettingsGraphicsMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
|
|
{
|
|
if (isDirectEditBlocking()) return;
|
|
|
|
ui.AnimateKeyPress(iPad, key, repeat, pressed, released);
|
|
switch(key)
|
|
{
|
|
case ACTION_MENU_CANCEL:
|
|
if(pressed)
|
|
{
|
|
/*
|
|
// check the checkboxes
|
|
app.SetGameSettings(m_iPad,eGameSetting_Clouds,m_checkboxClouds.IsChecked()?1:0);
|
|
app.SetGameSettings(m_iPad,eGameSetting_BedrockFog,m_checkboxBedrockFog.IsChecked()?1:0);
|
|
app.SetGameSettings(m_iPad,eGameSetting_CustomSkinAnim,m_checkboxCustomSkinAnim.IsChecked()?1:0);
|
|
*/
|
|
navigateBack();
|
|
handled = true;
|
|
}
|
|
break;
|
|
case ACTION_MENU_UP:
|
|
case ACTION_MENU_DOWN:
|
|
case ACTION_MENU_LEFT:
|
|
case ACTION_MENU_RIGHT:
|
|
case ACTION_MENU_PAGEUP:
|
|
case ACTION_MENU_PAGEDOWN:
|
|
case ACTION_MENU_OTHER_STICK_UP:
|
|
case ACTION_MENU_OTHER_STICK_DOWN:
|
|
sendInputToMovie(key, repeat, pressed, released);
|
|
handled = true; //test
|
|
break;
|
|
case ACTION_MENU_LEFT_SCROLL:
|
|
case ACTION_MENU_RIGHT_SCROLL:
|
|
if(pressed)
|
|
{
|
|
// Toggle tab index
|
|
m_tabIndex = m_tabIndex == 0 ? 1 : 0;
|
|
updateTooltips();
|
|
IggyDataValue result;
|
|
IggyResult out = IggyPlayerCallMethodRS ( getMovie() , &result, IggyPlayerRootPath( getMovie() ), m_funcChangeTab , 0 , nullptr );
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
UIControl* UIScene_SettingsGraphicsMenu::GetMainPanel()
|
|
{
|
|
if(m_tabIndex == 0 )
|
|
return &m_generalOptions;
|
|
else
|
|
return &m_qualityOptions;
|
|
}
|
|
|
|
void UIScene_SettingsGraphicsMenu::handleSliderMove(F64 sliderId, F64 currentValue)
|
|
{
|
|
/*
|
|
WCHAR TempString[256];
|
|
const int value = static_cast<int>(currentValue);
|
|
switch(static_cast<int>(sliderId))
|
|
{
|
|
case eControl_Gamma:
|
|
m_sliderGamma.handleSliderMove(value);
|
|
|
|
app.SetGameSettings(m_iPad,eGameSetting_Gamma,value);
|
|
swprintf( TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_GAMMA ),value);
|
|
m_sliderGamma.setLabel(TempString);
|
|
|
|
break;
|
|
|
|
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);
|
|
swprintf(TempString, 256, L"%ls: %d", app.GetString( IDS_SLIDER_FOV ),fovValue);
|
|
m_sliderFOV.setLabel(TempString);
|
|
}
|
|
break;
|
|
|
|
case eControl_InterfaceOpacity:
|
|
m_sliderInterfaceOpacity.handleSliderMove(value);
|
|
|
|
app.SetGameSettings(m_iPad,eGameSetting_InterfaceOpacity,value);
|
|
swprintf( TempString, 256, L"%ls: %d%%", app.GetString( IDS_SLIDER_INTERFACEOPACITY ),value);
|
|
m_sliderInterfaceOpacity.setLabel(TempString);
|
|
|
|
break;
|
|
|
|
case eControl_RenderDistance:
|
|
{
|
|
m_sliderRenderDistance.handleSliderMove(value);
|
|
|
|
const int dist = LevelToDistance(value);
|
|
|
|
app.SetGameSettings(m_iPad,eGameSetting_RenderDistance,dist);
|
|
|
|
const Minecraft* mc = Minecraft::GetInstance();
|
|
mc->options->viewDistance = 3 - value;
|
|
swprintf(TempString,256,L"%ls: %d", app.GetString( IDS_SLIDER_RENDERDISTANCE ),dist);
|
|
m_sliderRenderDistance.setLabel(TempString);
|
|
}
|
|
break;
|
|
|
|
case eControl_GraphicsMode:
|
|
{
|
|
m_sliderGraphicsMode.handleSliderMove(value);
|
|
|
|
app.SetGameSettings(m_iPad, eGameSetting_GraphicsMode, value);
|
|
|
|
swprintf(TempString, 256, L"%ls %ls", app.GetString( IDS_GRAPHICS ),app.GetString(m_iGraphicsModeTitleSettingA[value]));
|
|
|
|
m_sliderGraphicsMode.setLabel(TempString);
|
|
}
|
|
break;
|
|
}
|
|
*/
|
|
} |