Qt: Game Pak override dialog, half implemented

This commit is contained in:
Jeffrey Pfau 2014-12-30 22:56:55 -08:00
parent a55a3cb4d4
commit d759305e23
6 changed files with 362 additions and 5 deletions

View File

@ -43,6 +43,7 @@ set(SOURCE_FILES
GBAKeyEditor.cpp
GIFView.cpp
GameController.cpp
GamePakView.cpp
InputController.cpp
KeyEditor.cpp
LoadSaveState.cpp
@ -55,6 +56,7 @@ set(SOURCE_FILES
qt5_wrap_ui(UI_FILES
GIFView.ui
GamePakView.ui
LoadSaveState.ui
LogView.ui
SettingsView.ui

View File

@ -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);
}

View File

@ -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

View File

@ -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>

View File

@ -18,6 +18,7 @@
#include "GDBController.h"
#include "GDBWindow.h"
#include "GIFView.h"
#include "GamePakView.h"
#include "LoadSaveState.h"
#include "LogView.h"
#include "SettingsView.h"
@ -206,6 +207,13 @@ void Window::openSettingsWindow() {
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
void Window::openGamepadWindow() {
GBAKeyEditor* keyEditor = new GBAKeyEditor(&m_inputController, SDL_BINDING_BUTTON);
@ -609,14 +617,19 @@ void Window::setupMenu(QMenuBar* menubar) {
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");

View File

@ -63,6 +63,8 @@ public slots:
void openKeymapWindow();
void openSettingsWindow();
void openGamePakWindow();
#ifdef BUILD_SDL
void openGamepadWindow();
#endif