mirror of https://github.com/mgba-emu/mgba.git
Qt: Add menu items for adjusting in-game solar levels
This commit is contained in:
parent
71e5aacd5b
commit
c7593d7073
|
@ -24,6 +24,8 @@ extern "C" {
|
||||||
using namespace QGBA;
|
using namespace QGBA;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
const int GameController::LUX_LEVELS[10] = { 5, 11, 18, 27, 42, 62, 84, 109, 139, 183 };
|
||||||
|
|
||||||
GameController::GameController(QObject* parent)
|
GameController::GameController(QObject* parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
, m_drawContext(new uint32_t[256 * 256])
|
, m_drawContext(new uint32_t[256 * 256])
|
||||||
|
@ -62,6 +64,7 @@ GameController::GameController(QObject* parent)
|
||||||
GameControllerLux* lux = static_cast<GameControllerLux*>(context);
|
GameControllerLux* lux = static_cast<GameControllerLux*>(context);
|
||||||
return lux->value;
|
return lux->value;
|
||||||
};
|
};
|
||||||
|
setLuminanceLevel(0);
|
||||||
|
|
||||||
m_rtc.p = this;
|
m_rtc.p = this;
|
||||||
m_rtc.override = GameControllerRTC::NO_OVERRIDE;
|
m_rtc.override = GameControllerRTC::NO_OVERRIDE;
|
||||||
|
@ -419,6 +422,27 @@ void GameController::clearAVStream() {
|
||||||
threadContinue();
|
threadContinue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameController::setLuminanceValue(uint8_t value) {
|
||||||
|
m_luxValue = value;
|
||||||
|
value = std::max<int>(value - 0x16, 0);
|
||||||
|
m_luxLevel = 10;
|
||||||
|
for (int i = 0; i < 10; ++i) {
|
||||||
|
if (value < LUX_LEVELS[i]) {
|
||||||
|
m_luxLevel = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GameController::setLuminanceLevel(int level) {
|
||||||
|
int value = 0x16;
|
||||||
|
level = std::max(0, std::min(10, level));
|
||||||
|
if (level > 0) {
|
||||||
|
value += LUX_LEVELS[level - 1];
|
||||||
|
}
|
||||||
|
setLuminanceValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
void GameController::setRealTime() {
|
void GameController::setRealTime() {
|
||||||
m_rtc.override = GameControllerRTC::NO_OVERRIDE;
|
m_rtc.override = GameControllerRTC::NO_OVERRIDE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,11 @@ public slots:
|
||||||
void setTurbo(bool, bool forced = true);
|
void setTurbo(bool, bool forced = true);
|
||||||
void setAVStream(GBAAVStream*);
|
void setAVStream(GBAAVStream*);
|
||||||
void clearAVStream();
|
void clearAVStream();
|
||||||
void setLuminanceValue(uint8_t value) { m_luxValue = value; }
|
|
||||||
|
void setLuminanceValue(uint8_t value);
|
||||||
|
void setLuminanceLevel(int level);
|
||||||
|
void increaseLuminanceLevel() { setLuminanceLevel(m_luxLevel + 1); }
|
||||||
|
void decreaseLuminanceLevel() { setLuminanceLevel(m_luxLevel - 1); }
|
||||||
|
|
||||||
void setRealTime();
|
void setRealTime();
|
||||||
void setFixedTime(const QDateTime& time);
|
void setFixedTime(const QDateTime& time);
|
||||||
|
@ -154,6 +158,9 @@ private:
|
||||||
uint8_t value;
|
uint8_t value;
|
||||||
} m_lux;
|
} m_lux;
|
||||||
uint8_t m_luxValue;
|
uint8_t m_luxValue;
|
||||||
|
int m_luxLevel;
|
||||||
|
|
||||||
|
static const int LUX_LEVELS[10];
|
||||||
|
|
||||||
struct GameControllerRTC : GBARTCSource {
|
struct GameControllerRTC : GBARTCSource {
|
||||||
GameController* p;
|
GameController* p;
|
||||||
|
|
|
@ -658,6 +658,23 @@ void Window::setupMenu(QMenuBar* menubar) {
|
||||||
addControlledAction(toolsMenu, gdbWindow, "gdbWindow");
|
addControlledAction(toolsMenu, gdbWindow, "gdbWindow");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
toolsMenu->addSeparator();
|
||||||
|
QAction* solarIncrease = new QAction(tr("Increase solar level"), toolsMenu);
|
||||||
|
connect(solarIncrease, SIGNAL(triggered()), m_controller, SLOT(increaseLuminanceLevel()));
|
||||||
|
addControlledAction(toolsMenu, solarIncrease, "increaseLuminanceLevel");
|
||||||
|
|
||||||
|
QAction* solarDecrease = new QAction(tr("Decrease solar level"), toolsMenu);
|
||||||
|
connect(solarDecrease, SIGNAL(triggered()), m_controller, SLOT(decreaseLuminanceLevel()));
|
||||||
|
addControlledAction(toolsMenu, solarDecrease, "decreaseLuminanceLevel");
|
||||||
|
|
||||||
|
QAction* maxSolar = new QAction(tr("Brightest solar level"), toolsMenu);
|
||||||
|
connect(maxSolar, &QAction::triggered, [this]() { m_controller->setLuminanceLevel(10); });
|
||||||
|
addControlledAction(toolsMenu, maxSolar, "maxLuminanceLevel");
|
||||||
|
|
||||||
|
QAction* minSolar = new QAction(tr("Darkest solar level"), toolsMenu);
|
||||||
|
connect(minSolar, &QAction::triggered, [this]() { m_controller->setLuminanceLevel(0); });
|
||||||
|
addControlledAction(toolsMenu, minSolar, "minLuminanceLevel");
|
||||||
|
|
||||||
toolsMenu->addSeparator();
|
toolsMenu->addSeparator();
|
||||||
addControlledAction(toolsMenu, toolsMenu->addAction(tr("Settings..."), this, SLOT(openSettingsWindow())), "settings");
|
addControlledAction(toolsMenu, toolsMenu->addAction(tr("Settings..."), this, SLOT(openSettingsWindow())), "settings");
|
||||||
addControlledAction(toolsMenu, toolsMenu->addAction(tr("Edit shortcuts..."), this, SLOT(openShortcutWindow())), "shortcuts");
|
addControlledAction(toolsMenu, toolsMenu->addAction(tr("Edit shortcuts..."), this, SLOT(openShortcutWindow())), "shortcuts");
|
||||||
|
|
Loading…
Reference in New Issue