2020-05-30 04:37:06 +00:00
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
2020-06-06 23:19:01 +00:00
|
|
|
#include <QAudioOutput>
|
2020-05-30 04:37:06 +00:00
|
|
|
#include <QMainWindow>
|
2020-06-06 23:19:01 +00:00
|
|
|
|
2020-06-01 03:39:08 +00:00
|
|
|
#include <memory>
|
2020-06-09 04:01:22 +00:00
|
|
|
#include "audiobuffer.h"
|
2020-06-01 03:58:19 +00:00
|
|
|
#include "timer.h"
|
2020-06-03 03:35:01 +00:00
|
|
|
#include "ui_mainwindow.h"
|
2020-06-11 02:14:54 +00:00
|
|
|
#include "functionthread.h"
|
2020-06-03 03:35:01 +00:00
|
|
|
|
|
|
|
#include "../../Analyser/Static/StaticAnalyser.hpp"
|
|
|
|
#include "../../Machines/Utility/MachineForTarget.hpp"
|
2020-05-30 04:37:06 +00:00
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
namespace Ui { class MainWindow; }
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2020-06-06 23:19:01 +00:00
|
|
|
class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegate {
|
2020-06-01 03:39:08 +00:00
|
|
|
Q_OBJECT
|
2020-05-30 04:37:06 +00:00
|
|
|
|
2020-06-01 03:39:08 +00:00
|
|
|
void createActions();
|
2020-05-30 04:37:06 +00:00
|
|
|
|
2020-06-01 03:39:08 +00:00
|
|
|
public:
|
|
|
|
MainWindow(QWidget *parent = nullptr);
|
|
|
|
~MainWindow();
|
|
|
|
|
2020-06-06 02:11:17 +00:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
|
|
|
|
2020-06-01 03:39:08 +00:00
|
|
|
private:
|
|
|
|
std::unique_ptr<Ui::MainWindow> ui;
|
2020-06-01 03:58:19 +00:00
|
|
|
std::unique_ptr<Timer> timer;
|
|
|
|
|
2020-06-03 03:35:01 +00:00
|
|
|
// Initial setup stuff.
|
|
|
|
Analyser::Static::TargetList targets;
|
|
|
|
enum class UIPhase {
|
|
|
|
NoFileSelected, RequestingROMs, RunningMachine
|
|
|
|
} uiPhase = UIPhase::NoFileSelected;
|
|
|
|
void launchMachine();
|
|
|
|
|
|
|
|
QString romRequestBaseText;
|
|
|
|
std::vector<ROMMachine::ROM> missingRoms;
|
|
|
|
|
|
|
|
// File drag and drop is supported.
|
|
|
|
void dragEnterEvent(QDragEnterEvent* event) override;
|
|
|
|
void dropEvent(QDropEvent* event) override;
|
2020-06-01 03:39:08 +00:00
|
|
|
|
2020-06-04 03:39:16 +00:00
|
|
|
// Ongoing state.
|
|
|
|
std::unique_ptr<Machine::DynamicMachine> machine;
|
2020-06-06 03:06:28 +00:00
|
|
|
std::mutex machineMutex;
|
|
|
|
|
2020-06-06 23:19:01 +00:00
|
|
|
std::unique_ptr<QAudioOutput> audioOutput;
|
|
|
|
bool audioIs8bit = false, audioIsStereo = false;
|
|
|
|
void speaker_did_complete_samples(Outputs::Speaker::Speaker *speaker, const std::vector<int16_t> &buffer) override;
|
2020-06-09 04:01:22 +00:00
|
|
|
AudioBuffer audioBuffer;
|
2020-06-11 02:14:54 +00:00
|
|
|
FunctionThread audioThread;
|
2020-06-06 23:19:01 +00:00
|
|
|
|
2020-06-06 03:06:28 +00:00
|
|
|
bool processEvent(QKeyEvent *);
|
2020-06-03 04:21:37 +00:00
|
|
|
|
2020-06-01 03:39:08 +00:00
|
|
|
private slots:
|
|
|
|
void open();
|
2020-06-17 03:15:47 +00:00
|
|
|
void newFile();
|
|
|
|
void about();
|
2020-05-30 04:37:06 +00:00
|
|
|
};
|
2020-06-01 03:39:08 +00:00
|
|
|
|
2020-05-30 04:37:06 +00:00
|
|
|
#endif // MAINWINDOW_H
|