3DS: Prevent magnify effect from updating while the GUI is active

This commit is contained in:
Michael Ball 2019-11-28 12:17:42 -08:00 committed by Bastien Bouclet
parent 2048c9cc78
commit 6f678e6e84
4 changed files with 24 additions and 17 deletions

View File

@ -144,7 +144,6 @@ static void eventThreadFunc(void *arg) {
// Button events
if (keysPressed & KEY_L) {
if (g_gui.isActive()) {
// TODO: Prevent the magnify effect from updating while the GUI is active
osys->displayMessageOnOSD(_("Magnify Mode cannot be activated in menus."));
} else if (config.screen != kScreenBoth && osys->getMagnifyMode() == MODE_MAGOFF) {
// TODO: Automatically enable both screens while magnify mode is on

View File

@ -25,6 +25,7 @@
#include "backends/platform/3ds/shader_shbin.h"
#include "common/rect.h"
#include "graphics/fontman.h"
#include "gui/gui-manager.h"
#include "options-dialog.h"
#include "config.h"
@ -156,8 +157,8 @@ void OSystem_3DS::initSize(uint width, uint height,
_gameHeight = height;
_gameTopTexture.create(width, height, _pfGameTexture);
_overlay.create(400, 320, _pfGameTexture);
_topHalfWidth = _topWidth / 2;
_topHalfHeight = _topHeight / 2;
_magCenterX = _magWidth / 2;
_magCenterY = _magHeight / 2;
if (format) {
debug("pixelformat: %d %d %d %d %d", format->bytesPerPixel, format->rBits(), format->gBits(), format->bBits(), format->aBits());
@ -461,16 +462,21 @@ void OSystem_3DS::updateMagnify() {
_magnifyMode = MODE_MAGOFF;
}
// TODO: When exiting GUI, prevent cursor's position within GUI from changing
// position of magnification viewport. Possible solution: save in-game cursor
// coordinates separately from GUI cursor coordinates?
if (_magnifyMode == MODE_MAGON) {
_topX = (_cursorX < _topHalfWidth) ?
0 : ((_cursorX < (_gameWidth - _topHalfWidth)) ?
_cursorX - _topHalfWidth : _gameWidth - _topWidth);
_topY = (_cursorY < _topHalfHeight) ?
0 : ((_cursorY < _gameHeight - _topHalfHeight) ?
_cursorY - _topHalfHeight : _gameHeight - _topHeight);
if (!g_gui.isActive()) {
_magX = (_cursorX < _magCenterX) ?
0 : ((_cursorX < (_gameWidth - _magCenterX)) ?
_cursorX - _magCenterX : _gameWidth - _magWidth);
_magY = (_cursorY < _magCenterY) ?
0 : ((_cursorY < _gameHeight - _magCenterY) ?
_cursorY - _magCenterY : _gameHeight - _magHeight);
}
_gameTopTexture.setScale(1.f,1.f);
_gameTopTexture.setPosition(0,0);
_gameTopTexture.setOffset(_topX, _topY);
_gameTopTexture.setOffset(_magX, _magY);
}
}

View File

@ -72,10 +72,10 @@ OSystem_3DS::OSystem_3DS():
_gameBottomY(0),
_gameWidth(320),
_gameHeight(240),
_topX(0),
_topY(0),
_topWidth(400),
_topHeight(240),
_magX(0),
_magY(0),
_magWidth(400),
_magHeight(240),
_overlayVisible(false),
_screenChangeId(0),
_magnifyMode(MODE_MAGOFF),

View File

@ -174,9 +174,6 @@ private:
u16 _gameWidth, _gameHeight;
u16 _gameTopX, _gameTopY;
u16 _gameBottomX, _gameBottomY;
u16 _topWidth, _topHeight;
u16 _topHalfWidth, _topHalfHeight;
u16 _topX, _topY;
// Audio
Thread audioThread;
@ -241,7 +238,12 @@ private:
float _cursorDeltaX, _cursorDeltaY;
int _cursorHotspotX, _cursorHotspotY;
uint32 _cursorKeyColor;
// Magnify
MagnifyMode _magnifyMode;
u16 _magX, _magY;
u16 _magWidth, _magHeight;
u16 _magCenterX, _magCenterY;
};
} // namespace _3DS