mirror of
https://github.com/vcmi/vcmi.git
synced 2025-10-08 23:22:25 +02:00
Merge pull request #6128 from Laserlicht/portrait
fix android portrait mode
This commit is contained in:
@@ -255,7 +255,11 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
|
|||||||
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
case SDL_WINDOWEVENT_SIZE_CHANGED:
|
||||||
{
|
{
|
||||||
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
|
||||||
|
#ifdef VCMI_MOBILE
|
||||||
|
ENGINE->onScreenResize(true, false);
|
||||||
|
#else
|
||||||
ENGINE->onScreenResize(true, true);
|
ENGINE->onScreenResize(true, true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||||
|
@@ -48,6 +48,8 @@ std::tuple<int, int> ScreenHandler::getSupportedScalingRange() const
|
|||||||
Point renderResolution = getRenderResolution();
|
Point renderResolution = getRenderResolution();
|
||||||
double reservedAreaWidth = settings["video"]["reservedWidth"].Float();
|
double reservedAreaWidth = settings["video"]["reservedWidth"].Float();
|
||||||
Point availableResolution = Point(renderResolution.x * (1 - reservedAreaWidth), renderResolution.y);
|
Point availableResolution = Point(renderResolution.x * (1 - reservedAreaWidth), renderResolution.y);
|
||||||
|
if(renderResolution.x < renderResolution.y) // reserved in portrait mode
|
||||||
|
availableResolution = Point(renderResolution.x, renderResolution.y * (1 - reservedAreaWidth));
|
||||||
|
|
||||||
double maximalScalingWidth = 100.0 * availableResolution.x / minResolution.x;
|
double maximalScalingWidth = 100.0 * availableResolution.x / minResolution.x;
|
||||||
double maximalScalingHeight = 100.0 * availableResolution.y / minResolution.y;
|
double maximalScalingHeight = 100.0 * availableResolution.y / minResolution.y;
|
||||||
@@ -114,6 +116,8 @@ Point ScreenHandler::getPreferredLogicalResolution() const
|
|||||||
|
|
||||||
int scaling = getInterfaceScalingPercentage();
|
int scaling = getInterfaceScalingPercentage();
|
||||||
Point availableResolution = Point(renderResolution.x * (1 - reservedAreaWidth), renderResolution.y);
|
Point availableResolution = Point(renderResolution.x * (1 - reservedAreaWidth), renderResolution.y);
|
||||||
|
if(renderResolution.x < renderResolution.y) // reserved in portrait mode
|
||||||
|
availableResolution = Point(renderResolution.x, renderResolution.y * (1 - reservedAreaWidth));
|
||||||
Point logicalResolution = availableResolution * 100.0 / scaling;
|
Point logicalResolution = availableResolution * 100.0 / scaling;
|
||||||
return logicalResolution;
|
return logicalResolution;
|
||||||
}
|
}
|
||||||
|
@@ -338,10 +338,17 @@ void CSettingsView::fillValidResolutionsForScreen(int screenIndex)
|
|||||||
bool fullscreen = settings["video"]["fullscreen"].Bool();
|
bool fullscreen = settings["video"]["fullscreen"].Bool();
|
||||||
bool realFullscreen = settings["video"]["realFullscreen"].Bool();
|
bool realFullscreen = settings["video"]["realFullscreen"].Bool();
|
||||||
|
|
||||||
|
int resX = settings["video"]["resolution"]["width"].Integer();
|
||||||
|
int resY = settings["video"]["resolution"]["height"].Integer();
|
||||||
|
QSize currentRes(resX, resY);
|
||||||
|
|
||||||
if (!fullscreen || realFullscreen)
|
if (!fullscreen || realFullscreen)
|
||||||
{
|
{
|
||||||
QVector<QSize> resolutions = findAvailableResolutions(screenIndex);
|
QVector<QSize> resolutions = findAvailableResolutions(screenIndex);
|
||||||
|
|
||||||
|
if(!resolutions.contains(currentRes))
|
||||||
|
resolutions.append(currentRes);
|
||||||
|
|
||||||
for(const auto & entry : resolutions)
|
for(const auto & entry : resolutions)
|
||||||
ui->comboBoxResolution->addItem(resolutionToString(entry));
|
ui->comboBoxResolution->addItem(resolutionToString(entry));
|
||||||
}
|
}
|
||||||
@@ -351,8 +358,6 @@ void CSettingsView::fillValidResolutionsForScreen(int screenIndex)
|
|||||||
}
|
}
|
||||||
ui->comboBoxResolution->setEnabled(ui->comboBoxResolution->count() > 1);
|
ui->comboBoxResolution->setEnabled(ui->comboBoxResolution->count() > 1);
|
||||||
|
|
||||||
int resX = settings["video"]["resolution"]["width"].Integer();
|
|
||||||
int resY = settings["video"]["resolution"]["height"].Integer();
|
|
||||||
int resIndex = ui->comboBoxResolution->findText(resolutionToString({resX, resY}));
|
int resIndex = ui->comboBoxResolution->findText(resolutionToString({resX, resY}));
|
||||||
ui->comboBoxResolution->setCurrentIndex(resIndex);
|
ui->comboBoxResolution->setCurrentIndex(resIndex);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user