* Allow dynamic screen size change on windows

This commit is contained in:
iProgramInCpp
2023-08-06 22:45:15 +03:00
parent 9ef72164bb
commit 88d68cf21e
7 changed files with 50 additions and 5 deletions

View File

@@ -773,6 +773,35 @@ void Minecraft::prepareLevel(const std::string& unused)
// " - prepr: ";
}
void Minecraft::sizeUpdate(int newWidth, int newHeight)
{
// re-calculate the GUI scale.
Gui::InvGuiScale = getBestScaleForThisScreenSize(newWidth, newHeight);
if (m_pScreen)
m_pScreen->setSize(int(newWidth * Gui::InvGuiScale), int(newHeight * Gui::InvGuiScale));
}
float Minecraft::getBestScaleForThisScreenSize(int width, int height)
{
// phones only
#if !defined(_WIN32) && !defined(USE_SDL2)
if (width > 1000)
return 1.0f / 4.0f;
if (width > 800)
return 1.0f / 3.0f;
#else
if (width > 1000)
return 1.0f / 3.0f;
#endif
if (width > 400)
return 1.0f / 2.0f;
return 1.0f;
}
void Minecraft::generateLevel(const std::string& unused, Level* pLevel)
{
float time = getTimeS(); //@UNUSED