Cavoke  1.1.0
A Platform for creating and hosting multiplayer turn-based board games
Loading...
Searching...
No Matches
cavokeclientcontroller.h
1#ifndef CAVOKECLIENTCONTROLLER_H
2#define CAVOKECLIENTCONTROLLER_H
3
4#include <QObject>
5#include <QtQuick>
6#include "cache_manager.h"
7#include "cavokeclientmodel.h"
8#include "network_manager.h"
9#include "views/creategameview.h"
10#include "views/gameslistview.h"
11#include "views/joingameview.h"
12#include "views/roomview.h"
13#include "views/sessionview.h"
14#include "views/settingsview.h"
15#include "views/startview.h"
16#include "views/statisticsview.h"
17#include "views/testwindowview.h"
18
19class CavokeClientController : public QObject {
20 enum class UserDisplacement { NOWHERE, ROOM, SESSION, GAME };
21 enum class QMLDownloadStatus { NOT_STARTED, DOWNLOADING, DOWNLOADED };
22 enum class HostGuestStatus { NOT_IN, HOST, GUEST };
23 Q_OBJECT
24public:
25 explicit CavokeClientController(QObject *parent = nullptr);
26
27public slots:
28 void showTestWindowView();
29 void showStartView();
30 void showJoinGameView();
31 void showGamesListView();
32 void showCreateGameView();
33 void showStatisticsView();
34 void showSettingsView();
35 void showRoomView();
36 void showSessionView();
37 void updateSettings(const QString &displayName, const QString &host);
38
39signals:
40 void loadGamesList();
41 void setGameName(const QString &gameName);
42 void initSettingsValues(const QString &nickname, const QString &host);
43 void clearScreens();
44 void createdAvailableRolesList(const std::vector<Role> &availableRoles);
45
46private slots:
47 void startQmlApplication(CavokeQmlGameModel *);
48 void exitApplication();
49 void startQmlByGameId(const QString &gameId);
50 void startLoadedQml();
51 void stopQml();
52 void unpackDownloadedQml(QFile *file, const QString &gameId);
53 void createGameStart(const QString &roomName);
54 void joinGameStart(const QString &inviteCode);
55 void createSessionStart(const QString &gameId);
56 void joinSessionStart(const QString &sessionId);
57 void gotCurrentGameInfo(const GameInfo &gameInfo);
58 void gotRoomInfo(const RoomInfo &roomInfo);
59 void gotSessionInfo(const SessionInfo &sessionInfo);
60 void collectListOfAvailableRoles();
61 void becomeHost();
62 void becomeGuest();
63 void becomeRoomHost();
64 void becomeRoomGuest();
65 void leftSession(bool real_leave = true);
66 void leftRoom();
67
68private:
69 void defaultSettingsInitialization();
70 const static inline QString PLAYER_NICKNAME{"player/nickname"};
71 const static inline QString NETWORK_HOST{"network/host"};
72 const static inline QString DEFAULT_NICKNAME{"Guest"};
73 NetworkManager networkManager;
75 TestWindowView testWindowView;
76 StartView startView;
77 JoinGameView joinGameView;
78 CreateGameView createGameView;
79 GamesListView gamesListView;
80 StatisticsView statisticsView;
81 SettingsView settingsView;
82 RoomView roomView;
83 SessionView sessionView;
84 CavokeQmlGameModel *currentQmlGameModel = nullptr;
85 RoomInfo currentRoomInfo;
86 SessionInfo currentSessionInfo;
87 GameInfo currentGameInfo;
88 UserDisplacement displacement = UserDisplacement::NOWHERE;
89 QMLDownloadStatus qmlDownloadStatus = QMLDownloadStatus::NOT_STARTED;
90 HostGuestStatus hostGuestStatus = HostGuestStatus::NOT_IN;
91 HostGuestStatus roomHostGuestStatus = HostGuestStatus::NOT_IN;
92 QSettings settings;
93};
94
95#endif // CAVOKECLIENTCONTROLLER_H