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-07-08 04:15:44 +00:00
|
|
|
#include <optional>
|
|
|
|
|
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
|
|
|
|
2020-06-28 21:57:20 +00:00
|
|
|
// There are machine-specific controls for the following:
|
|
|
|
#include "../../Machines/ZX8081/ZX8081.hpp"
|
|
|
|
#include "../../Machines/Atari/2600/Atari2600.hpp"
|
|
|
|
|
2020-05-30 04:37:06 +00:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
namespace Ui { class MainWindow; }
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
2020-07-04 04:29:37 +00:00
|
|
|
class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegate, public ScanTargetWidget::MouseDelegate {
|
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-21 16:30:18 +00:00
|
|
|
explicit MainWindow(const QString &fileName);
|
2020-06-01 03:39:08 +00:00
|
|
|
|
2020-06-06 02:11:17 +00:00
|
|
|
protected:
|
2020-07-03 02:03:12 +00:00
|
|
|
void keyPressEvent(QKeyEvent *event) override;
|
|
|
|
void keyReleaseEvent(QKeyEvent *event) override;
|
2020-06-06 02:11:17 +00:00
|
|
|
|
2020-07-04 04:29:37 +00:00
|
|
|
void setMouseIsCaptured(bool) override;
|
|
|
|
void moveMouse(QPoint) override;
|
|
|
|
void setButtonPressed(int index, bool isPressed) 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 {
|
2020-06-29 02:50:24 +00:00
|
|
|
SelectingMachine, RequestingROMs, RunningMachine
|
|
|
|
} uiPhase = UIPhase::SelectingMachine;
|
2020-06-29 03:08:40 +00:00
|
|
|
QString openFileName;
|
2020-06-29 02:50:24 +00:00
|
|
|
void setUIPhase(UIPhase);
|
|
|
|
|
2020-06-03 03:35:01 +00:00
|
|
|
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-07-09 01:31:29 +00:00
|
|
|
void changeEvent(QEvent *) override;
|
|
|
|
|
2020-06-01 03:39:08 +00:00
|
|
|
private slots:
|
2020-06-19 03:34:37 +00: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();
|
|
|
|
|
2020-07-10 03:47:38 +00:00
|
|
|
enum class KeyboardInputMode {
|
|
|
|
Keyboard, Joystick
|
|
|
|
} keyboardInputMode;
|
|
|
|
|
2020-06-26 22:25:56 +00:00
|
|
|
QAction *insertAction = nullptr;
|
|
|
|
void insertFile(const QString &fileName);
|
|
|
|
|
2020-06-21 16:30:18 +00:00
|
|
|
void launchFile(const QString &fileName);
|
2020-06-19 03:34:37 +00:00
|
|
|
void launchTarget(std::unique_ptr<Analyser::Static::Target> &&);
|
2020-06-21 16:30:18 +00:00
|
|
|
|
|
|
|
void restoreSelections();
|
|
|
|
void storeSelections();
|
|
|
|
|
|
|
|
void init();
|
|
|
|
void tile(const QMainWindow *previous);
|
2020-06-22 03:50:18 +00:00
|
|
|
QString getFilename(const char *title);
|
|
|
|
|
|
|
|
void closeEvent(QCloseEvent *event) override;
|
|
|
|
static inline int mainWindowCount = 0;
|
2020-06-23 02:36:36 +00:00
|
|
|
|
|
|
|
void deleteMachine();
|
2020-06-27 03:04:45 +00:00
|
|
|
|
2020-06-27 03:27:14 +00:00
|
|
|
QMenu *displayMenu = nullptr;
|
2020-06-27 20:26:39 +00:00
|
|
|
void addDisplayMenu(const std::string &machinePrefix, const std::string &compositeColour, const std::string &compositeMono, const std::string &svideo, const std::string &rgb);
|
2020-06-27 21:08:29 +00:00
|
|
|
|
|
|
|
QMenu *enhancementsMenu = nullptr;
|
2020-06-28 20:23:35 +00:00
|
|
|
QAction *automaticTapeControlAction = nullptr;
|
2020-06-27 21:08:29 +00:00
|
|
|
void addEnhancementsMenu(const std::string &machinePrefix, bool offerQuickLoad, bool offerQuickBoot);
|
2020-06-28 05:04:32 +00:00
|
|
|
void addEnhancementsItems(const std::string &machinePrefix, QMenu *menu, bool offerQuickLoad, bool offerQuickBoot, bool automatic_tape_motor_control);
|
2020-06-27 21:08:29 +00:00
|
|
|
|
|
|
|
QMenu *controlsMenu = nullptr;
|
2020-06-28 20:23:35 +00:00
|
|
|
QAction *stopTapeAction = nullptr;
|
|
|
|
QAction *startTapeAction = nullptr;
|
2020-06-28 05:04:32 +00:00
|
|
|
void addZX8081Menu(const std::string &machinePrefix);
|
2020-06-28 20:23:35 +00:00
|
|
|
void updateTapeControls();
|
2020-06-28 21:57:20 +00:00
|
|
|
|
|
|
|
void addAtari2600Menu();
|
|
|
|
void toggleAtari2600Switch(Atari2600Switch toggleSwitch);
|
2020-07-04 04:29:37 +00:00
|
|
|
|
|
|
|
void setWindowTitle();
|
|
|
|
bool mouseIsCaptured = false;
|
2020-07-04 23:19:41 +00:00
|
|
|
|
|
|
|
QMenu *helpMenu = nullptr;
|
|
|
|
void addHelpMenu();
|
2020-07-08 04:15:44 +00:00
|
|
|
|
2020-07-10 03:47:38 +00:00
|
|
|
QMenu *inputMenu = nullptr;
|
|
|
|
|
2020-07-08 04:15:44 +00:00
|
|
|
std::optional<Inputs::Keyboard::Key> keyForEvent(QKeyEvent *);
|
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
|