Skip to content
Permalink
Browse files

3DS: Use the full resolution for the overlay on the top screen

(cherry picked from commit 6901ee0)
  • Loading branch information...
bgK committed Nov 7, 2019
1 parent c67615a commit 01876ad3d91fb5291dd13f75f898921132c212a5

This file was deleted.

This file was deleted.

@@ -4,7 +4,6 @@ MODULE_OBJS := \
main.o \
shader.shbin.o \
sprite.o \
gui.o \
config.o \
options-dialog.o \
osystem.o \
@@ -61,7 +61,7 @@ OptionsDialog::OptionsDialog() : GUI::Dialog(20, 20, 280, 200) {
_screenRadioGroup->setValue(config.screen);

new GUI::StaticTextWidget(this, 0, 100, 110, 15, _("C-Pad Sensitivity:"), Graphics::kTextAlignRight);
_sensitivity = new GUI::SliderWidget(this, 115, 100, 160, 15, "TODO: Add tooltip", 1);
_sensitivity = new GUI::SliderWidget(this, 115, 100, 160, 15);
_sensitivity->setMinValue(-15);
_sensitivity->setMaxValue(30);
_sensitivity->setValue(config.sensitivity);
@@ -72,20 +72,41 @@ OptionsDialog::~OptionsDialog() {
optionMenuOpened = false;
}

void OptionsDialog::updateConfigManager() {
config.showCursor = _showCursorCheckbox->getState();
config.snapToBorder = _snapToBorderCheckbox->getState();
config.stretchToFit = _stretchToFitCheckbox->getState();
config.sensitivity = _sensitivity->getValue();
config.screen = _screenRadioGroup->getValue();
saveConfig();
loadConfig();
bool OptionsDialog::getShowCursor() const {
return _showCursorCheckbox->getState();
}

bool OptionsDialog::getSnapToBorder() const {
return _snapToBorderCheckbox->getState();
}

bool OptionsDialog::getStretchToFit() const {
return _stretchToFitCheckbox->getState();
}

int OptionsDialog::getSensitivity() const {
return _sensitivity->getValue();
}

int OptionsDialog::getScreen() const {
return _screenRadioGroup->getValue();
}

void OptionsDialog::reflowLayout() {
const int screenW = g_system->getOverlayWidth();
const int screenH = g_system->getOverlayHeight();

// Center the dialog
_x = (screenW - getWidth()) / 2;
_y = (screenH - getHeight()) / 2;

GUI::Dialog::reflowLayout();
}

void OptionsDialog::handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) {
switch(cmd) {
case GUI::kOKCmd:
updateConfigManager();
setResult(1);
// Fall through
case GUI::kCloseCmd:
close();
@@ -50,9 +50,16 @@ class OptionsDialog : public GUI::Dialog {
OptionsDialog();
~OptionsDialog();

// GuiObject API
void reflowLayout() override;

bool getShowCursor() const;
bool getSnapToBorder() const;
bool getStretchToFit() const;
int getSensitivity() const;
int getScreen() const;
protected:
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
void updateConfigManager();
void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data) override;

GUI::SliderWidget *_sensitivity;
GUI::CheckboxWidget *_showCursorCheckbox;
@@ -22,13 +22,14 @@

#define FORBIDDEN_SYMBOL_EXCEPTION_time_h

#include "osystem.h"
#include "backends/platform/3ds/osystem.h"

#include "backends/platform/3ds/config.h"
#include "backends/platform/3ds/options-dialog.h"
#include "backends/timer/default/default-timer.h"
#include "gui/gui-manager.h"
#include "common/translation.h"
#include "engines/engine.h"
#include "gui.h"
#include "options-dialog.h"
#include "config.h"
#include "gui/gui-manager.h"

namespace _3DS {

@@ -149,43 +150,43 @@ static void eventThreadFunc(void *arg) {
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.");
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
osys->displayMessageOnOSD("Magnify Mode can only be activated\n when both screens are enabled.");
osys->displayMessageOnOSD(_("Magnify Mode can only be activated\n when both screens are enabled."));
} else if (osys->getWidth() <= 400 && osys->getHeight() <= 240) {
osys->displayMessageOnOSD("In-game resolution too small to magnify.");
osys->displayMessageOnOSD(_("In-game resolution too small to magnify."));
} else {
if (osys->getMagnifyMode() == MODE_MAGOFF) {
osys->setMagnifyMode(MODE_MAGON);
if (inputMode == MODE_DRAG) {
inputMode = MODE_HOVER;
osys->displayMessageOnOSD("Magnify Mode On. Switching to Hover Mode...");
osys->displayMessageOnOSD(_("Magnify Mode On. Switching to Hover Mode..."));
} else {
osys->displayMessageOnOSD("Magnify Mode On");
osys->displayMessageOnOSD(_("Magnify Mode On"));
}
} else {
osys->setMagnifyMode(MODE_MAGOFF);
osys->updateSize();
if (savedInputMode == MODE_DRAG) {
inputMode = savedInputMode;
osys->displayMessageOnOSD("Magnify Mode Off. Reactivating Drag Mode...");
osys->displayMessageOnOSD(_("Magnify Mode Off. Reactivating Drag Mode..."));
} else {
osys->displayMessageOnOSD("Magnify Mode Off");
osys->displayMessageOnOSD(_("Magnify Mode Off"));
}
}
}
}
if (keysPressed & KEY_R) {
if (inputMode == MODE_DRAG) {
inputMode = savedInputMode = MODE_HOVER;
osys->displayMessageOnOSD("Hover Mode");
osys->displayMessageOnOSD(_("Hover Mode"));
} else {
if (osys->getMagnifyMode() == MODE_MAGOFF) {
inputMode = savedInputMode = MODE_DRAG;
osys->displayMessageOnOSD("Drag Mode");
osys->displayMessageOnOSD(_("Drag Mode"));
} else
osys->displayMessageOnOSD("Cannot Switch to Drag Mode while Magnify Mode is On");
osys->displayMessageOnOSD(_("Cannot Switch to Drag Mode while Magnify Mode is On"));
}
}
if (keysPressed & KEY_A || keysPressed & KEY_DLEFT || keysReleased & KEY_A || keysReleased & KEY_DLEFT) {
@@ -238,9 +239,9 @@ static void eventThreadFunc(void *arg) {
osys->updateSize();
if (savedInputMode == MODE_DRAG) {
inputMode = savedInputMode;
osys->displayMessageOnOSD("Magnify Mode Off. Reactivating Drag Mode.\nReturning to Launcher...");
osys->displayMessageOnOSD(_("Magnify Mode Off. Reactivating Drag Mode.\nReturning to Launcher..."));
} else
osys->displayMessageOnOSD("Magnify Mode Off. Returning to Launcher...");
osys->displayMessageOnOSD(_("Magnify Mode Off. Returning to Launcher..."));
}
}

@@ -309,8 +310,12 @@ void OSystem_3DS::destroyEvents() {

void OSystem_3DS::transformPoint(touchPosition &point) {
if (!_overlayVisible) {
point.px = static_cast<float>(point.px) / _gameBottomTexture.getScaleX() - _gameBottomX;
point.py = static_cast<float>(point.py) / _gameBottomTexture.getScaleY() - _gameBottomY;
point.px = static_cast<float>(point.px) / _gameBottomTexture.getScaleX() - _gameBottomTexture.getPosX();
point.py = static_cast<float>(point.py) / _gameBottomTexture.getScaleY() - _gameBottomTexture.getPosY();
} else {
if (config.screen == kScreenTop) {
point.px = (uint32) point.px * 400 / 320; // TODO: Fix horizontal speed
}
}
}

@@ -323,12 +328,7 @@ bool OSystem_3DS::pollEvent(Common::Event &event) {

if (optionMenuOpening) {
optionMenuOpening = false;
OptionsDialog dialog;
if (g_engine)
g_engine->pauseEngine(true);
dialog.runModal();
if (g_engine)
g_engine->pauseEngine(false);
runOptionsDialog();
}

Common::StackLock lock(*eventMutex);
@@ -340,4 +340,31 @@ bool OSystem_3DS::pollEvent(Common::Event &event) {
return true;
}

void OSystem_3DS::runOptionsDialog() {
OptionsDialog dialog;
if (g_engine)
g_engine->pauseEngine(true);
int result = dialog.runModal();
if (g_engine)
g_engine->pauseEngine(false);

if (result > 0) {
int oldScreen = config.screen;

config.showCursor = dialog.getShowCursor();
config.snapToBorder = dialog.getSnapToBorder();
config.stretchToFit = dialog.getStretchToFit();
config.sensitivity = dialog.getSensitivity();
config.screen = dialog.getScreen();

saveConfig();
loadConfig();

if (config.screen != oldScreen) {
_screenChangeId++;
g_gui.checkScreenChange();
}
}
}

} // namespace _3DS
@@ -146,10 +146,16 @@ int OSystem_3DS::getGraphicsMode() const {
void OSystem_3DS::initSize(uint width, uint height,
const Graphics::PixelFormat *format) {
debug("3ds initsize w:%d h:%d", width, height);
int oldScreen = config.screen;
loadConfig();
if (config.screen != oldScreen) {
_screenChangeId++;
}

_gameWidth = width;
_gameHeight = height;
_gameTopTexture.create(width, height, _pfGameTexture);
_overlay.create(getOverlayWidth(), getOverlayHeight(), _pfGameTexture);
_overlay.create(400, 320, _pfGameTexture);
_topHalfWidth = _topWidth / 2;
_topHalfHeight = _topHeight / 2;

@@ -558,7 +564,7 @@ int16 OSystem_3DS::getOverlayHeight() {
}

int16 OSystem_3DS::getOverlayWidth() {
return 320;
return config.screen == kScreenTop ? 400 : 320;
}

bool OSystem_3DS::showMouse(bool visible) {
@@ -77,6 +77,7 @@ OSystem_3DS::OSystem_3DS():
_topWidth(400),
_topHeight(240),
_overlayVisible(false),
_screenChangeId(0),
_magnifyMode(MODE_MAGOFF),
exiting(false),
sleeping(false)
@@ -105,7 +105,7 @@ class OSystem_3DS : public EventsBaseBackend, public PaletteManager {
virtual Common::List<Graphics::PixelFormat> getSupportedFormats() const;
void initSize(uint width, uint height,
const Graphics::PixelFormat *format = NULL);
virtual int getScreenChangeID() const { return 0; };
virtual int getScreenChangeID() const { return _screenChangeId; };

void beginGFXTransaction();
OSystem::TransactionError endGFXTransaction();
@@ -152,14 +152,14 @@ class OSystem_3DS : public EventsBaseBackend, public PaletteManager {
void setMagnifyMode(MagnifyMode mode);
MagnifyMode getMagnifyMode(){ return _magnifyMode; }


private:
void initGraphics();
void destroyGraphics();
void initAudio();
void destroyAudio();
void initEvents();
void destroyEvents();
void runOptionsDialog();

void flushGameScreen();
void flushCursor();
@@ -199,6 +199,7 @@ class OSystem_3DS : public EventsBaseBackend, public PaletteManager {

int _screenShakeOffset;
bool _overlayVisible;
int _screenChangeId;

DVLB_s *_dvlb;
shaderProgram_s _program;
@@ -75,6 +75,8 @@ backends/networking/sdl_net/handlers/uploadfilehandler.cpp
backends/networking/sdl_net/handlerutils.cpp
backends/networking/sdl_net/localwebserver.cpp
backends/networking/sdl_net/uploadfileclienthandler.cpp
backends/platform/3ds/options-dialog.cpp
backends/platform/3ds/osystem-events.cpp
backends/platform/ds/arm9/source/dsoptions.cpp
backends/platform/ios7/ios7_osys_events.cpp
backends/platform/iphone/osys_events.cpp

0 comments on commit 01876ad

Please sign in to comment.
You can’t perform that action at this time.