2020-05-30 00:37:06 -04:00
|
|
|
#ifndef MAINWINDOW_H
|
|
|
|
#define MAINWINDOW_H
|
|
|
|
|
2020-06-06 19:19:01 -04:00
|
|
|
#include <QAudioOutput>
|
2020-05-30 00:37:06 -04:00
|
|
|
#include <QMainWindow>
|
2020-06-06 19:19:01 -04:00
|
|
|
|
2020-05-31 23:39:08 -04:00
|
|
|
#include <memory>
|
2020-06-09 00:01:22 -04:00
|
|
|
#include "audiobuffer.h"
|
2020-05-31 23:58:19 -04:00
|
|
|
#include "timer.h"
|
2020-06-02 23:35:01 -04:00
|
|
|
#include "ui_mainwindow.h"
|
2020-06-10 22:14:54 -04:00
|
|
|
#include "functionthread.h"
|
2020-06-02 23:35:01 -04:00
|
|
|
|
|
|
|
#include "../../Analyser/Static/StaticAnalyser.hpp"
|
|
|
|
#include "../../Machines/Utility/MachineForTarget.hpp"
|
2020-05-30 00:37:06 -04:00
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
namespace Ui { class MainWindow; }
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2020-06-06 19:19:01 -04:00
|
|
|
class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegate {
|
2020-05-31 23:39:08 -04:00
|
|
|
Q_OBJECT
|
2020-05-30 00:37:06 -04:00
|
|
|
|
2020-05-31 23:39:08 -04:00
|
|
|
void createActions();
|
2020-05-30 00:37:06 -04:00
|
|
|
|
2020-05-31 23:39:08 -04:00
|
|
|
public:
|
|
|
|
MainWindow(QWidget *parent = nullptr);
|
|
|
|
~MainWindow();
|
|
|
|
|
2020-06-05 22:11:17 -04:00
|
|
|
protected:
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
|
|
|
|
2020-05-31 23:39:08 -04:00
|
|
|
private:
|
|
|
|
std::unique_ptr<Ui::MainWindow> ui;
|
2020-05-31 23:58:19 -04:00
|
|
|
std::unique_ptr<Timer> timer;
|
|
|
|
|
2020-06-02 23:35:01 -04: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-05-31 23:39:08 -04:00
|
|
|
|
2020-06-03 23:39:16 -04:00
|
|
|
// Ongoing state.
|
|
|
|
std::unique_ptr<Machine::DynamicMachine> machine;
|
2020-06-05 23:06:28 -04:00
|
|
|
std::mutex machineMutex;
|
|
|
|
|
2020-06-06 19:19:01 -04: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 00:01:22 -04:00
|
|
|
AudioBuffer audioBuffer;
|
2020-06-10 22:14:54 -04:00
|
|
|
FunctionThread audioThread;
|
2020-06-06 19:19:01 -04:00
|
|
|
|
2020-06-05 23:06:28 -04:00
|
|
|
bool processEvent(QKeyEvent *);
|
2020-06-03 00:21:37 -04:00
|
|
|
|
2020-06-18 20:05:46 -04:00
|
|
|
enum class WidgetSet {
|
|
|
|
MachinePicker,
|
|
|
|
ROMRequester,
|
|
|
|
RunningMachine,
|
|
|
|
};
|
|
|
|
void setVisibleWidgetSet(WidgetSet);
|
|
|
|
|
2020-05-31 23:39:08 -04:00
|
|
|
private slots:
|
|
|
|
void open();
|
2020-06-16 23:15:47 -04:00
|
|
|
void newFile();
|
|
|
|
void about();
|
2020-06-18 23:34:37 -04:00
|
|
|
void startMachine();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void start_appleII();
|
|
|
|
void start_amstradCPC();
|
|
|
|
void start_atariST();
|
|
|
|
void start_electron();
|
|
|
|
void start_macintosh();
|
|
|
|
void start_msx();
|
|
|
|
void start_oric();
|
|
|
|
void start_vic20();
|
|
|
|
void start_zx80();
|
|
|
|
void start_zx81();
|
|
|
|
|
|
|
|
void launchTarget(std::unique_ptr<Analyser::Static::Target> &&);
|
2020-05-30 00:37:06 -04:00
|
|
|
};
|
2020-05-31 23:39:08 -04:00
|
|
|
|
2020-05-30 00:37:06 -04:00
|
|
|
#endif // MAINWINDOW_H
|