forked from gb2dev/HLA-NoVR-Launcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgamemenu.h
104 lines (93 loc) · 2.94 KB
/
gamemenu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef GAMEMENU_H
#define GAMEMENU_H
#include <QDesktopServices>
#include <QtConcurrent>
#include <QObject>
#include <QQuickWindow>
#include <QSettings>
#include <QDebug>
#ifdef Q_OS_UNIX
#include <X11/keysym.h>
#include <X11/Xatom.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#undef Bool
#endif
struct Addon {
QString fileName;
bool mounted;
bool enabled;
QStringList maps;
};
class GameMenu : public QObject
{
Q_OBJECT
public:
explicit GameMenu(QObject *parent = nullptr);
enum VisibilityState { Hidden, HUD, PauseMenu, MainMenu };
public slots:
void gameStarted(QQuickWindow *window);
void update();
void buttonPlayClicked();
void buttonLoadGameClicked();
void buttonSaveGameClicked();
void buttonNewGameClicked();
void buttonOptionsClicked();
void buttonMainMenuClicked();
void buttonAddonsClicked();
void buttonQuitClicked();
void loadSave(const QString &fileName);
void newGame(const QString &mapName, bool addonMap);
void toggleAddon(const QString &fileName);
void recordInput(const QString &input);
void changeOptions(const QStringList &options);
void hackFailed();
void hackSuccess();
signals:
void pauseMenuModeChanged(bool pauseMenuMode);
void hudHealthChanged(int hudHealth);
void visibilityStateChanged(GameMenu::VisibilityState v);
void saveAdded(const QString &name, const QString &dateTime, const QString &fileName);
void newGameSelected();
void noSaveFilesDetected();
void addonAdded(const QString &name, const QString &fileName);
void addonMapsAdded(const QStringList &maps, bool addonEnabled);
void addonToggled();
void bindingChanged(const QString &name, const QString &bind);
void convarLoaded(const QString &convar, const QString &value);
void hackingPuzzleStarted(const QString &type);
private:
bool eventFilter(QObject *object, QEvent *event) override;
void runGameScript(const QString &script, bool focusLauncher = true);
void runGameCommand(const QString &command, bool focusLauncher = true);
void writeToBindingsFile(const QString &key, const QVariant &value);
void readBindingsFile();
void readConvarsFile();
void writeToSaveCfg(const QString &key, const QString &value);
QFile mainMenuExecFile;
QSettings settings;
QQuickWindow *window;
#ifdef Q_OS_WIN
HWND thisWindow;
HWND targetWindow;
#else
Display *display;
Window window_from_name_search(Window current, char const *needle);
Window window_from_name(char const *name);
Window thisWindow;
Window targetWindow;
#endif
bool escPrevious = false;
QFuture<void> future;
bool stopRead = false;
bool stopSearchingTargetWindow = false;
int hudHealth = 100;
bool pauseMenuMode = false;
bool loadingMode = false;
bool gamePaused = false;
QList<Addon> addons;
QString recordInputName = "";
bool recordingInput = false;
int saveSlot = -1;
};
#endif // GAMEMENU_H