Qt: Game Pak override dialog, half implemented
Jeffrey Pfau jeffrey@endrift.com
Tue, 30 Dec 2014 22:56:55 -0800
6 files changed,
362 insertions(+),
5 deletions(-)
M
src/platform/qt/CMakeLists.txt
→
src/platform/qt/CMakeLists.txt
@@ -43,6 +43,7 @@ GBAApp.cpp
GBAKeyEditor.cpp GIFView.cpp GameController.cpp + GamePakView.cpp InputController.cpp KeyEditor.cpp LoadSaveState.cpp@@ -55,6 +56,7 @@ VideoView.cpp)
qt5_wrap_ui(UI_FILES GIFView.ui + GamePakView.ui LoadSaveState.ui LogView.ui SettingsView.ui
A
src/platform/qt/GamePakView.cpp
@@ -0,0 +1,63 @@
+/* Copyright (c) 2013-2014 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "GamePakView.h" + +#include "GameController.h" + +extern "C" { +#include "gba-thread.h" +} + +using namespace QGBA; + +GamePakView::GamePakView(GameController* controller, QWidget* parent) + : QWidget(parent) + , m_controller(controller) +{ + m_ui.setupUi(this); + + connect(controller, SIGNAL(gameStarted(GBAThread*)), this, SLOT(gameStarted(GBAThread*))); + connect(controller, SIGNAL(gameStopped(GBAThread*)), this, SLOT(gameStopped())); + + if (controller->isLoaded()) { + gameStarted(controller->thread()); + } +} + +void GamePakView::gameStarted(GBAThread* thread) { + if (!thread->gba) { + gameStopped(); + return; + } + SavedataType savetype = thread->gba->memory.savedata.type; + if (m_ui.savetype->currentIndex() > 0) { + if (savetype > SAVEDATA_NONE) { + VFile* vf = thread->gba->memory.savedata.vf; + GBASavedataDeinit(&thread->gba->memory.savedata); + GBASavedataInit(&thread->gba->memory.savedata, vf); + } + savetype = static_cast<SavedataType>(m_ui.savetype->currentIndex() - 1); + GBASavedataForceType(&thread->gba->memory.savedata, savetype); + } + + if (savetype > SAVEDATA_NONE) { + m_ui.savetype->setCurrentIndex(savetype + 1); + } + m_ui.savetype->setEnabled(false); + + m_ui.sensorRTC->setChecked(thread->gba->memory.gpio.gpioDevices & GPIO_RTC); + m_ui.sensorGyro->setChecked(thread->gba->memory.gpio.gpioDevices & GPIO_GYRO); + m_ui.sensorLight->setChecked(thread->gba->memory.gpio.gpioDevices & GPIO_LIGHT_SENSOR); +} + +void GamePakView::gameStopped() { + m_ui.savetype->setCurrentIndex(0); + m_ui.savetype->setEnabled(true); + + m_ui.sensorRTC->setChecked(false); + m_ui.sensorGyro->setChecked(false); + m_ui.sensorLight->setChecked(false); +}
A
src/platform/qt/GamePakView.h
@@ -0,0 +1,37 @@
+/* Copyright (c) 2013-2014 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef QGBA_GAMEPAK_VIEW +#define QGBA_GAMEPAK_VIEW + +#include <QWidget> + +#include "ui_GamePakView.h" + +struct GBAThread; + +namespace QGBA { + +class GameController; + +class GamePakView : public QWidget { +Q_OBJECT + +public: + GamePakView(GameController* controller, QWidget* parent = nullptr); + +private slots: + void gameStarted(GBAThread*); + void gameStopped(); + +private: + Ui::GamePakView m_ui; + + GameController* m_controller; +}; + +} + +#endif
A
src/platform/qt/GamePakView.ui
@@ -0,0 +1,240 @@
+<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>GamePakView</class> + <widget class="QWidget" name="GamePakView"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>247</width> + <height>345</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="windowTitle"> + <string>Game Pak Overrides</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="title"> + <string/> + </property> + <layout class="QFormLayout" name="formLayout"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::FieldsStayAtSizeHint</enum> + </property> + <item row="1" column="0" colspan="2"> + <widget class="Line" name="line"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Sensors</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="sensorAutodetect"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Autodetect</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="3" column="1"> + <widget class="QCheckBox" name="sensorRTC"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Realtime Clock</string> + </property> + </widget> + </item> + <item row="4" column="1"> + <widget class="QCheckBox" name="sensorGyro"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Gyroscope</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QCheckBox" name="sensorAccel"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Accelerometer</string> + </property> + </widget> + </item> + <item row="6" column="1"> + <widget class="QCheckBox" name="sensorLight"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Light sensor</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QComboBox" name="savetype"> + <item> + <property name="text"> + <string>Autodetect</string> + </property> + </item> + <item> + <property name="text"> + <string>None</string> + </property> + </item> + <item> + <property name="text"> + <string>SRAM</string> + </property> + </item> + <item> + <property name="text"> + <string>Flash 512kb</string> + </property> + </item> + <item> + <property name="text"> + <string>Flash 1Mb</string> + </property> + </item> + <item> + <property name="text"> + <string>EEPROM</string> + </property> + </item> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Save type</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QTabWidget" name="tabWidget"> + <property name="currentIndex"> + <number>0</number> + </property> + <widget class="QWidget" name="tab_3"> + <attribute name="title"> + <string>RTC</string> + </attribute> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QRadioButton" name="radioButton"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>System time</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="radioButton_2"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Manual time</string> + </property> + </widget> + </item> + <item> + <widget class="QDateTimeEdit" name="dateTimeEdit"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="displayFormat"> + <string>M/d/yyyy h:mm AP</string> + </property> + <property name="calendarPopup"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="tab_6"> + <attribute name="title"> + <string>Light</string> + </attribute> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="1"> + <widget class="QSpinBox" name="lightSpin"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maximum"> + <number>255</number> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Brightness</string> + </property> + </widget> + </item> + <item row="1" column="0" colspan="2"> + <widget class="QSlider" name="lightSlide"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="maximum"> + <number>255</number> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="tickPosition"> + <enum>QSlider::TicksBelow</enum> + </property> + <property name="tickInterval"> + <number>16</number> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + </layout> + </widget> + <resources/> + <connections/> +</ui>
M
src/platform/qt/Window.cpp
→
src/platform/qt/Window.cpp
@@ -18,6 +18,7 @@ #include "GBAKeyEditor.h"
#include "GDBController.h" #include "GDBWindow.h" #include "GIFView.h" +#include "GamePakView.h" #include "LoadSaveState.h" #include "LogView.h" #include "SettingsView.h"@@ -204,6 +205,13 @@ connect(this, SIGNAL(shutdown()), settingsWindow, SLOT(close()));
connect(settingsWindow, SIGNAL(biosLoaded(const QString&)), m_controller, SLOT(loadBIOS(const QString&))); settingsWindow->setAttribute(Qt::WA_DeleteOnClose); settingsWindow->show(); +} + +void Window::openGamePakWindow() { + GamePakView* gamePakWindow = new GamePakView(m_controller); + connect(this, SIGNAL(shutdown()), gamePakWindow, SLOT(close())); + gamePakWindow->setAttribute(Qt::WA_DeleteOnClose); + gamePakWindow->show(); } #ifdef BUILD_SDL@@ -609,14 +617,19 @@ addAction(recordGIF);
avMenu->addAction(recordGIF); #endif - QMenu* debuggingMenu = menubar->addMenu(tr("&Debugging")); - QAction* viewLogs = new QAction(tr("View &logs..."), debuggingMenu); + QMenu* toolsMenu = menubar->addMenu(tr("&Tools")); + QAction* viewLogs = new QAction(tr("View &logs..."), toolsMenu); connect(viewLogs, SIGNAL(triggered()), m_logView, SLOT(show())); - debuggingMenu->addAction(viewLogs); + toolsMenu->addAction(viewLogs); + + QAction* gamePak = new QAction(tr("Game &Pak overrides..."), toolsMenu); + connect(gamePak, SIGNAL(triggered()), this, SLOT(openGamePakWindow())); + toolsMenu->addAction(gamePak); + #ifdef USE_GDB_STUB - QAction* gdbWindow = new QAction(tr("Start &GDB server..."), debuggingMenu); + QAction* gdbWindow = new QAction(tr("Start &GDB server..."), toolsMenu); connect(gdbWindow, SIGNAL(triggered()), this, SLOT(gdbOpen())); - debuggingMenu->addAction(gdbWindow); + toolsMenu->addAction(gdbWindow); #endif ConfigOption* skipBios = m_config->addOption("skipBios");
M
src/platform/qt/Window.h
→
src/platform/qt/Window.h
@@ -63,6 +63,8 @@
void openKeymapWindow(); void openSettingsWindow(); + void openGamePakWindow(); + #ifdef BUILD_SDL void openGamepadWindow(); #endif