aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp
diff options
context:
space:
mode:
authorqwasdrizzel <145519042+qwasdrizzel@users.noreply.github.com>2026-03-16 21:44:26 -0500
committerGitHub <noreply@github.com>2026-03-16 21:44:26 -0500
commitce739f6045ec72127491286ea3f3f21e537c1b55 (patch)
treef33bd42a47c1b4a7b2153a7fb77127ee3b407db9 /Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp
parent255a18fe8e9b57377975f82e2b227afe2a12eda0 (diff)
parent5a59f5d146b43811dde6a5a0245ee9875d7b5cd1 (diff)
Merge branch 'smartcmd:main' into main
Diffstat (limited to 'Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp')
-rw-r--r--Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp57
1 files changed, 32 insertions, 25 deletions
diff --git a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp
index af86d4b8..c997fb31 100644
--- a/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp
+++ b/Minecraft.Client/Common/UI/UIScene_DebugOverlay.cpp
@@ -21,14 +21,16 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void *initData, UILayer *pa
// Setup all the Iggy references we need for this scene
initialiseMovie();
- Minecraft *pMinecraft = Minecraft::GetInstance();
- WCHAR TempString[256];
- swprintf( (WCHAR *)TempString, 256, L"Set fov (%d)", (int)pMinecraft->gameRenderer->GetFovVal());
- m_sliderFov.init(TempString,eControl_FOV,0,100,(int)pMinecraft->gameRenderer->GetFovVal());
+ 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);
- float currentTime = pMinecraft->level->getLevelData()->getGameTime() % 24000;
- swprintf( (WCHAR *)TempString, 256, L"Set time (unsafe) (%d)", (int)currentTime);
- m_sliderTime.init(TempString,eControl_Time,0,240,currentTime/100);
+ 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);
m_buttonRain.init(L"Toggle Rain",eControl_Rain);
m_buttonThunder.init(L"Toggle Thunder",eControl_Thunder);
@@ -44,7 +46,7 @@ UIScene_DebugOverlay::UIScene_DebugOverlay(int iPad, void *initData, UILayer *pa
std::vector<std::pair<std::wstring, unsigned int>> sortedItems;
for (size_t i = 0; i < Item::items.length; ++i)
{
- if (Item::items[i] != NULL)
+ if (Item::items[i] != nullptr)
{
sortedItems.emplace_back(std::wstring(app.GetString(Item::items[i]->getDescriptionId())), i);
}
@@ -136,19 +138,19 @@ wstring UIScene_DebugOverlay::getMoviePath()
void UIScene_DebugOverlay::customDraw(IggyCustomDrawCallbackRegion *region)
{
- Minecraft *pMinecraft = Minecraft::GetInstance();
- if(pMinecraft->localplayers[m_iPad] == NULL || pMinecraft->localgameModes[m_iPad] == NULL) return;
+ const Minecraft *pMinecraft = Minecraft::GetInstance();
+ if(pMinecraft->localplayers[m_iPad] == nullptr || pMinecraft->localgameModes[m_iPad] == nullptr) return;
int itemId = -1;
- swscanf((wchar_t*)region->name,L"item_%d",&itemId);
- if (itemId == -1 || itemId > Item::ITEM_NUM_COUNT || Item::items[itemId] == NULL)
+ swscanf(static_cast<wchar_t *>(region->name),L"item_%d",&itemId);
+ if (itemId == -1 || itemId > Item::ITEM_NUM_COUNT || Item::items[itemId] == nullptr)
{
app.DebugPrintf("This is not the control we are looking for\n");
}
else
{
- shared_ptr<ItemInstance> item = shared_ptr<ItemInstance>( new ItemInstance(itemId,1,0) );
- if(item != NULL) customDrawSlotControl(region,m_iPad,item,1.0f,false,false);
+ const auto item = std::make_shared<ItemInstance>(itemId, 1, 0);
+ if(item != nullptr) customDrawSlotControl(region,m_iPad,item,1.0f,false,false);
}
}
@@ -181,7 +183,7 @@ void UIScene_DebugOverlay::handleInput(int iPad, int key, bool repeat, bool pres
void UIScene_DebugOverlay::handlePress(F64 controlId, F64 childId)
{
- switch((int)controlId)
+ switch(static_cast<int>(controlId))
{
case eControl_Items:
{
@@ -211,14 +213,14 @@ void UIScene_DebugOverlay::handlePress(F64 controlId, F64 childId)
case eControl_Schematic:
{
#ifndef _CONTENT_PACKAGE
- ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugCreateSchematic,NULL,eUILayer_Debug);
+ ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugCreateSchematic,nullptr,eUILayer_Debug);
#endif
}
break;
case eControl_SetCamera:
{
#ifndef _CONTENT_PACKAGE
- ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugSetCamera,NULL,eUILayer_Debug);
+ ui.NavigateToScene(ProfileManager.GetPrimaryPad(),eUIScene_DebugSetCamera,nullptr,eUILayer_Debug);
#endif
}
break;
@@ -252,7 +254,7 @@ void UIScene_DebugOverlay::handlePress(F64 controlId, F64 childId)
void UIScene_DebugOverlay::handleSliderMove(F64 sliderId, F64 currentValue)
{
- switch((int)sliderId)
+ switch(static_cast<int>(sliderId))
{
case eControl_Time:
{
@@ -264,20 +266,25 @@ void UIScene_DebugOverlay::handleSliderMove(F64 sliderId, F64 currentValue)
MinecraftServer::SetTime(currentValue * 100);
pMinecraft->level->getLevelData()->setGameTime(currentValue * 100);
- WCHAR TempString[256];
+ WCHAR tempString[256];
float currentTime = currentValue * 100;
- swprintf( (WCHAR *)TempString, 256, L"Set time (unsafe) (%d)", (int)currentTime);
- m_sliderTime.setLabel(TempString);
+ swprintf( tempString, 256, L"Set time (unsafe) (%d)", static_cast<int>(currentTime));
+ m_sliderTime.setLabel(tempString);
}
break;
case eControl_FOV:
{
Minecraft *pMinecraft = Minecraft::GetInstance();
- pMinecraft->gameRenderer->SetFovVal((float)currentValue);
+ 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);
- WCHAR TempString[256];
- swprintf( (WCHAR *)TempString, 256, L"Set fov (%d)", (int)currentValue);
- m_sliderFov.setLabel(TempString);
+ WCHAR tempString[256];
+ swprintf( tempString, 256, L"Set fov (%d)", fovDeg);
+ m_sliderFov.setLabel(tempString);
}
break;
};