mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Scale C++ menus down to fit the window (#14690)
This commit is contained in:
parent
d5fc040d2d
commit
728f643ea7
6 changed files with 32 additions and 29 deletions
|
@ -398,3 +398,17 @@ porting::AndroidDialogState GUIModalMenu::getAndroidUIInputState()
|
|||
return porting::getInputDialogState();
|
||||
}
|
||||
#endif
|
||||
|
||||
GUIModalMenu::ScalingInfo GUIModalMenu::getScalingInfo(v2u32 screensize, v2u32 base_size)
|
||||
{
|
||||
f32 scale = m_gui_scale;
|
||||
scale = std::min(scale, (f32)screensize.X / (f32)base_size.X);
|
||||
scale = std::min(scale, (f32)screensize.Y / (f32)base_size.Y);
|
||||
s32 w = base_size.X * scale, h = base_size.Y * scale;
|
||||
return {scale, core::rect<s32>(
|
||||
screensize.X / 2 - w / 2,
|
||||
screensize.Y / 2 - h / 2,
|
||||
screensize.X / 2 + w / 2,
|
||||
screensize.Y / 2 + h / 2
|
||||
)};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue