Permalink
Browse files

Fix display scale not refreshing with display resolution

  • Loading branch information...
SupSuper committed Sep 16, 2018
1 parent da13800 commit d37a02102dff0095da3d3c574269840938a392c7
@@ -72,7 +72,7 @@ InventoryState::InventoryState(bool tu, BattlescapeState *parent) : _tu(tu), _pa
}
else if (!_battleGame->getTileEngine())
{
Screen::updateScale(Options::battlescapeScale, Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, true);
Screen::updateScale(Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, true);
_game->getScreen()->resetDisplay(false);
}
@@ -254,7 +254,7 @@ InventoryState::~InventoryState()
{
if (Options::maximizeInfoScreens)
{
Screen::updateScale(Options::battlescapeScale, Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, true);
Screen::updateScale(Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, true);
_game->getScreen()->resetDisplay(false);
}
Tile *inventoryTile = _battleGame->getSelectedUnit()->getTile();
@@ -264,7 +264,7 @@ InventoryState::~InventoryState()
}
else
{
Screen::updateScale(Options::geoscapeScale, Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, true);
Screen::updateScale(Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, true);
_game->getScreen()->resetDisplay(false);
}
}
@@ -203,7 +203,7 @@ void MedikitState::onEndClick(Action *)
{
if (Options::maximizeInfoScreens)
{
Screen::updateScale(Options::battlescapeScale, Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, true);
Screen::updateScale(Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, true);
_game->getScreen()->resetDisplay(false);
}
_game->popState();
@@ -124,7 +124,7 @@ void MiniMapState::btnOkClick(Action *)
{
if (Options::maximizeInfoScreens)
{
Screen::updateScale(Options::battlescapeScale, Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, true);
Screen::updateScale(Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, true);
_game->getScreen()->resetDisplay(false);
}
_game->popState();
@@ -126,7 +126,7 @@ void ScannerState::exitClick(Action *)
{
if (Options::maximizeInfoScreens)
{
Screen::updateScale(Options::battlescapeScale, Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, true);
Screen::updateScale(Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, true);
_game->getScreen()->resetDisplay(false);
}
_game->popState();
@@ -680,7 +680,7 @@ void UnitInfoState::exitClick(Action *)
{
if (!_fromInventory && Options::maximizeInfoScreens)
{
Screen::updateScale(Options::battlescapeScale, Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, true);
Screen::updateScale(Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, true);
_game->getScreen()->resetDisplay(false);
}
_game->popState();
@@ -204,8 +204,8 @@ void Game::run()
Options::newDisplayWidth = Options::displayWidth = std::max(Screen::ORIGINAL_WIDTH, _event.resize.w);
Options::newDisplayHeight = Options::displayHeight = std::max(Screen::ORIGINAL_HEIGHT, _event.resize.h);
int dX = 0, dY = 0;
Screen::updateScale(Options::battlescapeScale, Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, false);
Screen::updateScale(Options::geoscapeScale, Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, false);
Screen::updateScale(Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, false);
Screen::updateScale(Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, false);
for (std::list<State*>::iterator i = _states.begin(); i != _states.end(); ++i)
{
(*i)->resize(dX, dY);
@@ -602,13 +602,12 @@ int Screen::getDY() const
/**
* Changes a given scale, and if necessary, switch the current base resolution.
* @param type reference to which scale option we are using, battlescape or geoscape.
* @param selection the new scale level.
* @param type the new scale level.
* @param width reference to which x scale to adjust.
* @param height reference to which y scale to adjust.
* @param change should we change the current scale.
*/
void Screen::updateScale(int &type, int selection, int &width, int &height, bool change)
void Screen::updateScale(int type, int &width, int &height, bool change)
{
double pixelRatioY = 1.0;
@@ -617,7 +616,6 @@ void Screen::updateScale(int &type, int selection, int &width, int &height, bool
pixelRatioY = 1.2;
}
type = selection;
switch (type)
{
case SCALE_15X:
@@ -629,11 +627,11 @@ void Screen::updateScale(int &type, int selection, int &width, int &height, bool
height = Screen::ORIGINAL_HEIGHT * 2;
break;
case SCALE_SCREEN_DIV_3:
width = Options::displayWidth / 3;
height = Options::displayHeight / pixelRatioY / 3;
width = Options::displayWidth / 3.0;
height = Options::displayHeight / pixelRatioY / 3.0;
break;
case SCALE_SCREEN_DIV_2:
width = Options::displayWidth / 2;
width = Options::displayWidth / 2.0;
height = Options::displayHeight / pixelRatioY / 2.0;
break;
case SCALE_SCREEN:
@@ -97,7 +97,7 @@ class Screen
/// Checks whether OpenGL output is requested
static bool useOpenGL();
/// update the game scale as required.
static void updateScale(int &type, int selection, int &x, int &y, bool change);
static void updateScale(int type, int &width, int &height, bool change);
};
}
@@ -108,7 +108,7 @@ void AbandonGameState::btnYesClick(Action *)
_game->getMod()->getSoundByDepth(0, _game->getSavedGame()->getSavedBattle()->getAmbientSound())->stopLoop();
if (!_game->getSavedGame()->isIronman())
{
Screen::updateScale(Options::geoscapeScale, Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, true);
Screen::updateScale(Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, true);
_game->getScreen()->resetDisplay(false);
_game->setState(new MainMenuState);
@@ -113,7 +113,7 @@ bool CutsceneState::initDisplay()
void CutsceneState::resetDisplay(bool wasLetterboxed)
{
Options::keepAspectRatio = wasLetterboxed;
Screen::updateScale(Options::geoscapeScale, Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, true);
Screen::updateScale(Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, true);
_game->getScreen()->resetDisplay(false);
}
@@ -38,7 +38,7 @@ namespace OpenXcom
void GoToMainMenuState::init()
{
Screen::updateScale(Options::geoscapeScale, Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, true);
Screen::updateScale(Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, true);
_game->getScreen()->resetDisplay(false);
_game->setState(new MainMenuState);
}
@@ -160,7 +160,7 @@ void MainMenuState::resize(int &dX, int &dY)
{
dX = Options::baseXResolution;
dY = Options::baseYResolution;
Screen::updateScale(Options::geoscapeScale, Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, true);
Screen::updateScale(Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, true);
dX = Options::baseXResolution - dX;
dY = Options::baseYResolution - dY;
State::resize(dX, dY);
@@ -190,14 +190,14 @@ void OptionsBaseState::setCategory(TextButton *button)
*/
void OptionsBaseState::btnOkClick(Action *)
{
Options::switchDisplay();
int dX = Options::baseXResolution;
int dY = Options::baseYResolution;
Screen::updateScale(Options::battlescapeScale, Options::newBattlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, _origin == OPT_BATTLESCAPE);
Screen::updateScale(Options::geoscapeScale, Options::newGeoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, _origin != OPT_BATTLESCAPE);
Screen::updateScale(Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, _origin == OPT_BATTLESCAPE);
Screen::updateScale(Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, _origin != OPT_BATTLESCAPE);
dX = Options::baseXResolution - dX;
dY = Options::baseYResolution - dY;
recenter(dX, dY);
Options::switchDisplay();
Options::save();
if (Options::reload && _origin == OPT_MENU)
{
@@ -239,8 +239,8 @@ void OptionsBaseState::btnCancelClick(Action *)
Options::reload = false;
Options::load();
SDL_WM_GrabInput(Options::captureMouse);
Screen::updateScale(Options::newBattlescapeScale, Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, _origin == OPT_BATTLESCAPE);
Screen::updateScale(Options::newGeoscapeScale, Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, _origin != OPT_BATTLESCAPE);
Screen::updateScale(Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, _origin == OPT_BATTLESCAPE);
Screen::updateScale(Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, _origin != OPT_BATTLESCAPE);
_game->setVolume(Options::soundVolume, Options::musicVolume, Options::uiVolume);
_game->popState();
}
@@ -138,6 +138,8 @@ void OptionsConfirmState::btnYesClick(Action *)
void OptionsConfirmState::btnNoClick(Action *)
{
Options::switchDisplay();
Screen::updateScale(Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, _origin == OPT_BATTLESCAPE);
Screen::updateScale(Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, _origin != OPT_BATTLESCAPE);
Options::save();
_game->getScreen()->resetDisplay();
_game->popState();
@@ -168,7 +168,7 @@ void SaveGameState::think()
if (_type == SAVE_IRONMAN_END)
{
Screen::updateScale(Options::geoscapeScale, Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, true);
Screen::updateScale(Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, true);
_game->getScreen()->resetDisplay(false);
_game->setState(new MainMenuState);
@@ -53,8 +53,8 @@ StartState::StartState() : _anim(0)
//updateScale() uses newDisplayWidth/Height and needs to be set ahead of time
Options::newDisplayWidth = Options::displayWidth;
Options::newDisplayHeight = Options::displayHeight;
Screen::updateScale(Options::geoscapeScale, Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, false);
Screen::updateScale(Options::battlescapeScale, Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, false);
Screen::updateScale(Options::geoscapeScale, Options::baseXGeoscape, Options::baseYGeoscape, false);
Screen::updateScale(Options::battlescapeScale, Options::baseXBattlescape, Options::baseYBattlescape, false);
Options::baseXResolution = Options::displayWidth;
Options::baseYResolution = Options::displayHeight;
_game->getScreen()->resetDisplay(false);

0 comments on commit d37a021

Please sign in to comment.