mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-07-09 00:28:42 +12:00
Merge branch 'master' into metal2
This commit is contained in:
commit
779e30e3e5
48 changed files with 1691 additions and 242 deletions
|
@ -1,10 +1,13 @@
|
|||
#include "panda_qt/about_window.hpp"
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QtGlobal>
|
||||
|
||||
#include "version.hpp"
|
||||
|
||||
// Based on https://github.com/dolphin-emu/dolphin/blob/master/Source/Core/DolphinQt/AboutDialog.cpp
|
||||
|
||||
AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) {
|
||||
|
@ -17,6 +20,8 @@ AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) {
|
|||
QStringLiteral(R"(
|
||||
<p style='font-size:38pt; font-weight:400;'>Panda3DS</p>
|
||||
|
||||
<p style='font-size:18pt;'>v%VERSION_STRING%</p>
|
||||
|
||||
<p>
|
||||
%ABOUT_PANDA3DS%<br>
|
||||
<a href='https://panda3ds.com/'>%SUPPORT%</a><br>
|
||||
|
@ -26,6 +31,7 @@ AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) {
|
|||
<a>%AUTHORS%</a>
|
||||
</p>
|
||||
)")
|
||||
.replace(QStringLiteral("%VERSION_STRING%"), PANDA3DS_VERSION)
|
||||
.replace(QStringLiteral("%ABOUT_PANDA3DS%"), tr("Panda3DS is a free and open source Nintendo 3DS emulator, for Windows, MacOS and Linux"))
|
||||
.replace(QStringLiteral("%SUPPORT%"), tr("Visit panda3ds.com for help with Panda3DS and links to our official support sites."))
|
||||
.replace(
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
#include "panda_qt/cheats_window.hpp"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
#include <QTextEdit>
|
||||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QTimer>
|
||||
#include <QVBoxLayout>
|
||||
#include <functional>
|
||||
|
||||
#include "cheats.hpp"
|
||||
|
@ -18,71 +12,17 @@
|
|||
|
||||
MainWindow* mainWindow = nullptr;
|
||||
|
||||
struct CheatMetadata {
|
||||
u32 handle = Cheats::badCheatHandle;
|
||||
std::string name = "New cheat";
|
||||
std::string code;
|
||||
bool enabled = true;
|
||||
};
|
||||
|
||||
void dispatchToMainThread(std::function<void()> callback) {
|
||||
QTimer* timer = new QTimer();
|
||||
timer->moveToThread(qApp->thread());
|
||||
timer->setSingleShot(true);
|
||||
QObject::connect(timer, &QTimer::timeout, [=]()
|
||||
{
|
||||
callback();
|
||||
timer->deleteLater();
|
||||
});
|
||||
QMetaObject::invokeMethod(timer, "start", Qt::QueuedConnection, Q_ARG(int, 0));
|
||||
QTimer* timer = new QTimer();
|
||||
timer->moveToThread(qApp->thread());
|
||||
timer->setSingleShot(true);
|
||||
QObject::connect(timer, &QTimer::timeout, [=]() {
|
||||
callback();
|
||||
timer->deleteLater();
|
||||
});
|
||||
QMetaObject::invokeMethod(timer, "start", Qt::QueuedConnection, Q_ARG(int, 0));
|
||||
}
|
||||
|
||||
class CheatEntryWidget : public QWidget {
|
||||
public:
|
||||
CheatEntryWidget(Emulator* emu, CheatMetadata metadata, QListWidget* parent);
|
||||
|
||||
void Update() {
|
||||
name->setText(metadata.name.c_str());
|
||||
enabled->setChecked(metadata.enabled);
|
||||
update();
|
||||
}
|
||||
|
||||
void Remove() {
|
||||
emu->getCheats().removeCheat(metadata.handle);
|
||||
cheatList->takeItem(cheatList->row(listItem));
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
const CheatMetadata& getMetadata() { return metadata; }
|
||||
void setMetadata(const CheatMetadata& metadata) { this->metadata = metadata; }
|
||||
|
||||
private:
|
||||
void checkboxChanged(int state);
|
||||
void editClicked();
|
||||
|
||||
Emulator* emu;
|
||||
CheatMetadata metadata;
|
||||
u32 handle;
|
||||
QLabel* name;
|
||||
QCheckBox* enabled;
|
||||
QListWidget* cheatList;
|
||||
QListWidgetItem* listItem;
|
||||
};
|
||||
|
||||
class CheatEditDialog : public QDialog {
|
||||
public:
|
||||
CheatEditDialog(Emulator* emu, CheatEntryWidget& cheatEntry);
|
||||
|
||||
void accepted();
|
||||
void rejected();
|
||||
|
||||
private:
|
||||
Emulator* emu;
|
||||
CheatEntryWidget& cheatEntry;
|
||||
QTextEdit* codeEdit;
|
||||
QLineEdit* nameEdit;
|
||||
};
|
||||
|
||||
CheatEntryWidget::CheatEntryWidget(Emulator* emu, CheatMetadata metadata, QListWidget* parent)
|
||||
: QWidget(), emu(emu), metadata(metadata), cheatList(parent) {
|
||||
QHBoxLayout* layout = new QHBoxLayout;
|
||||
|
@ -219,7 +159,7 @@ void CheatEditDialog::rejected() {
|
|||
|
||||
CheatsWindow::CheatsWindow(Emulator* emu, const std::filesystem::path& cheatPath, QWidget* parent)
|
||||
: QWidget(parent, Qt::Window), emu(emu), cheatPath(cheatPath) {
|
||||
mainWindow = static_cast<MainWindow*>(parent);
|
||||
mainWindow = static_cast<MainWindow*>(parent);
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout;
|
||||
layout->setContentsMargins(6, 6, 6, 6);
|
||||
|
@ -265,4 +205,4 @@ void CheatsWindow::removeClicked() {
|
|||
|
||||
CheatEntryWidget* entry = static_cast<CheatEntryWidget*>(cheatList->itemWidget(item));
|
||||
entry->Remove();
|
||||
}
|
||||
}
|
|
@ -7,9 +7,10 @@
|
|||
#include <cstdio>
|
||||
#include <fstream>
|
||||
|
||||
#include "version.hpp"
|
||||
#include "cheats.hpp"
|
||||
#include "input_mappings.hpp"
|
||||
#include "sdl_gyro.hpp"
|
||||
#include "sdl_sensors.hpp"
|
||||
#include "services/dsp.hpp"
|
||||
|
||||
MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent), keyboardMappings(InputMappings::defaultKeyboardMappings()) {
|
||||
|
@ -98,6 +99,14 @@ MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent)
|
|||
}
|
||||
}
|
||||
|
||||
if (emu->getConfig().appVersionOnWindow) {
|
||||
setWindowTitle("Alber v" PANDA3DS_VERSION);
|
||||
}
|
||||
|
||||
if (emu->getConfig().printAppVersion) {
|
||||
printf("Welcome to Panda3DS v%s!\n", PANDA3DS_VERSION);
|
||||
}
|
||||
|
||||
// The emulator graphics context for the thread should be initialized in the emulator thread due to how GL contexts work
|
||||
emuThread = std::thread([this]() {
|
||||
const RendererType rendererType = emu->getConfig().rendererType;
|
||||
|
@ -609,7 +618,7 @@ void MainWindow::pollControllers() {
|
|||
|
||||
case SDL_CONTROLLERSENSORUPDATE: {
|
||||
if (event.csensor.sensor == SDL_SENSOR_GYRO) {
|
||||
auto rotation = Gyro::SDL::convertRotation({
|
||||
auto rotation = Sensors::SDL::convertRotation({
|
||||
event.csensor.data[0],
|
||||
event.csensor.data[1],
|
||||
event.csensor.data[2],
|
||||
|
@ -618,6 +627,9 @@ void MainWindow::pollControllers() {
|
|||
hid.setPitch(s16(rotation.x));
|
||||
hid.setRoll(s16(rotation.y));
|
||||
hid.setYaw(s16(rotation.z));
|
||||
} else if (event.csensor.sensor == SDL_SENSOR_ACCEL) {
|
||||
auto accel = Sensors::SDL::convertAcceleration(event.csensor.data);
|
||||
hid.setAccel(accel.x, accel.y, accel.z);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -627,8 +639,13 @@ void MainWindow::pollControllers() {
|
|||
|
||||
void MainWindow::setupControllerSensors(SDL_GameController* controller) {
|
||||
bool haveGyro = SDL_GameControllerHasSensor(controller, SDL_SENSOR_GYRO) == SDL_TRUE;
|
||||
bool haveAccelerometer = SDL_GameControllerHasSensor(controller, SDL_SENSOR_ACCEL) == SDL_TRUE;
|
||||
|
||||
if (haveGyro) {
|
||||
SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_GYRO, SDL_TRUE);
|
||||
}
|
||||
|
||||
if (haveAccelerometer) {
|
||||
SDL_GameControllerSetSensorEnabled(controller, SDL_SENSOR_ACCEL, SDL_TRUE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "input_mappings.hpp"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include "input_mappings.hpp"
|
||||
|
||||
InputMappings InputMappings::defaultKeyboardMappings() {
|
||||
InputMappings mappings;
|
||||
mappings.setMapping(Qt::Key_L, HID::Keys::A);
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
#include "panda_qt/shader_editor.hpp"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
#include "panda_qt/main_window.hpp"
|
||||
#include "panda_qt/shader_editor.hpp"
|
||||
|
||||
using namespace Zep;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue