qmlFrontend/hwengine.h
author unc0rr
Tue, 17 May 2016 23:18:08 +0300
branchqmlfrontend
changeset 11827 8c71c5a1172f
parent 11443 5182d44fb733
permissions -rw-r--r--
- Add state to engine callback for it to know what engine is sending - Display suggested hogs number in preview
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
     1
#ifndef HWENGINE_H
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
     2
#define HWENGINE_H
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
     3
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
     4
#include <QObject>
10416
1c301054694d - Remove --port command
unc0rr
parents: 10402
diff changeset
     5
#include <QByteArray>
1c301054694d - Remove --port command
unc0rr
parents: 10402
diff changeset
     6
#include <QVector>
10420
unc0rr
parents: 10418
diff changeset
     7
#include <QPixmap>
10416
1c301054694d - Remove --port command
unc0rr
parents: 10402
diff changeset
     8
1c301054694d - Remove --port command
unc0rr
parents: 10402
diff changeset
     9
#include "flib.h"
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    10
10420
unc0rr
parents: 10418
diff changeset
    11
class QQmlEngine;
unc0rr
parents: 10418
diff changeset
    12
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    13
class HWEngine : public QObject
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    14
{
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    15
    Q_OBJECT
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    16
public:
10420
unc0rr
parents: 10418
diff changeset
    17
    explicit HWEngine(QQmlEngine * engine, QObject *parent = 0);
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    18
    ~HWEngine();
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    19
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    20
    static void exposeToQML();
10428
7c25297720f1 More refactoring: move PoC preview getting code into flib
unc0rr
parents: 10426
diff changeset
    21
    Q_INVOKABLE void getPreview();
10432
b0abef0ee78c Quick Game PoC
unc0rr
parents: 10430
diff changeset
    22
    Q_INVOKABLE void runQuickGame();
10448
4cb727e029fa - Allow to delete teams from config
unc0rr
parents: 10444
diff changeset
    23
    Q_INVOKABLE void runLocalGame();
10424
4be6cd55f1cf - Get rid of engine's PathPrefix and UserPathPrefix
unc0rr
parents: 10420
diff changeset
    24
    Q_INVOKABLE QString currentSeed();
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10434
diff changeset
    25
    Q_INVOKABLE void getTeamsList();
10450
bf9e30b4ef9b - Store index of color instead of its value
unc0rr
parents: 10448
diff changeset
    26
    Q_INVOKABLE void resetGameConfig();
10612
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10456
diff changeset
    27
10456
6fd99bb73524 Theme can be changed
unc0rr
parents: 10452
diff changeset
    28
    Q_INVOKABLE void setTheme(const QString & theme);
10612
eb3c1a289a23 Script combobox.wiki
unc0rr
parents: 10456
diff changeset
    29
    Q_INVOKABLE void setScript(const QString & script);
10819
57e21f7621b0 Send selected scheme config on engine initialization (WIP)
unc0rr
parents: 10612
diff changeset
    30
    Q_INVOKABLE void setScheme(const QString & scheme);
10888
a04e04aaf599 Ammo schemes list, almost works
unc0rr
parents: 10819
diff changeset
    31
    Q_INVOKABLE void setAmmo(const QString & ammo);
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    32
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    33
    Q_INVOKABLE void tryAddTeam(const QString & teamName);
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    34
    Q_INVOKABLE void tryRemoveTeam(const QString & teamName);
10452
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
    35
    Q_INVOKABLE void changeTeamColor(const QString & teamName, int dir);
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    36
10896
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents: 10888
diff changeset
    37
    Q_INVOKABLE void connect(const QString & host, quint16 port);
5a74923120d5 Start network support: only setting up a connection for now
unc0rr
parents: 10888
diff changeset
    38
11416
78d6b99ddcb0 Can send chat messages now
unc0rr
parents: 11415
diff changeset
    39
    Q_INVOKABLE void sendChatMessage(const QString & msg);
78d6b99ddcb0 Can send chat messages now
unc0rr
parents: 11415
diff changeset
    40
11423
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11422
diff changeset
    41
    Q_INVOKABLE void joinRoom(const QString & roomName);
11424
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
    42
    Q_INVOKABLE void partRoom(const QString & message);
11423
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11422
diff changeset
    43
11430
f88b3948adf3 UI knowns local player nickname
unc0rr
parents: 11424
diff changeset
    44
    Q_INVOKABLE QString myNickname();
f88b3948adf3 UI knowns local player nickname
unc0rr
parents: 11424
diff changeset
    45
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
    46
signals:
11423
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11422
diff changeset
    47
    void errorMessage(const QString & message);
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11422
diff changeset
    48
    void warningMessage(const QString & message);
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11422
diff changeset
    49
11434
23912c93935a - Implement engine runs queue
unc0rr
parents: 11433
diff changeset
    50
    void previewIsRendering();
10420
unc0rr
parents: 10418
diff changeset
    51
    void previewImageChanged();
11827
8c71c5a1172f - Add state to engine callback for it to know what engine is sending
unc0rr
parents: 11443
diff changeset
    52
    void previewHogCountChanged(int count);
10442
c58db813240b Load and show local teams list
unc0rr
parents: 10434
diff changeset
    53
    void localTeamAdded(const QString & teamName, int aiLevel);
10444
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    54
    void localTeamRemoved(const QString & teamName);
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    55
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    56
    void playingTeamAdded(const QString & teamName, int aiLevel, bool isLocal);
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    57
    void playingTeamRemoved(const QString & teamName);
47a6231f1fc1 Teams widget now allows to add and remove teams (basic implementation, no checks performed, no colors, no hedgehogs)
unc0rr
parents: 10442
diff changeset
    58
10452
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
    59
    void teamColorChanged(const QString & teamName, const QString & colorValue);
11443
5182d44fb733 - Hedgehogs number display
unc0rr
parents: 11440
diff changeset
    60
    void hedgehogsNumberChanged(const QString & teamName, int hedgehogsNumber);
10452
03519fd9f98d Show team color in teams list widget, also allow to change it on mouse click
unc0rr
parents: 10450
diff changeset
    61
11415
05cf35103206 Lobby page with chat widget(readonly)
unc0rr
parents: 10896
diff changeset
    62
    void netConnected();
05cf35103206 Lobby page with chat widget(readonly)
unc0rr
parents: 10896
diff changeset
    63
    void netDisconnected(const QString & message);
05cf35103206 Lobby page with chat widget(readonly)
unc0rr
parents: 10896
diff changeset
    64
05cf35103206 Lobby page with chat widget(readonly)
unc0rr
parents: 10896
diff changeset
    65
    void lobbyClientAdded(const QString & clientName);
11423
e045dc60c37e - Warnings/errors message box
unc0rr
parents: 11422
diff changeset
    66
    void lobbyClientRemoved(const QString & clientName, const QString & reason);
11415
05cf35103206 Lobby page with chat widget(readonly)
unc0rr
parents: 10896
diff changeset
    67
    void lobbyChatLine(const QString & nickname, const QString & line);
05cf35103206 Lobby page with chat widget(readonly)
unc0rr
parents: 10896
diff changeset
    68
11424
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
    69
    void roomClientAdded(const QString & clientName);
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
    70
    void roomClientRemoved(const QString & clientName, const QString & reason);
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
    71
    void roomChatLine(const QString & nickname, const QString & line);
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
    72
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
    73
    void movedToLobby();
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
    74
    void movedToRoom();
86c13e5662f1 - Some refactoring
unc0rr
parents: 11423
diff changeset
    75
11431
80a9b14bb8d3 Some game config methods and signals
unc0rr
parents: 11430
diff changeset
    76
    void seedChanged(const QString & seed);
80a9b14bb8d3 Some game config methods and signals
unc0rr
parents: 11430
diff changeset
    77
    void themeChanged(const QString & theme);
80a9b14bb8d3 Some game config methods and signals
unc0rr
parents: 11430
diff changeset
    78
    void scriptChanged(const QString & script);
11433
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
    79
    void featureSizeChanged(int featureSize);
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
    80
    void mapGenChanged(int mapgen);
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
    81
    void mapChanged(const QString & map);
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
    82
    void mazeSizeChanged(int mazeSize);
bca9afcc3a72 Handle some CFG parameters
unc0rr
parents: 11431
diff changeset
    83
    void templateChanged(int templ);
11437
6e641b5453f9 Accept ammo scheme from network
unc0rr
parents: 11434
diff changeset
    84
    void ammoChanged(const QString & ammo);
11440
330c14f4ba69 Accept scheme from net
unc0rr
parents: 11437
diff changeset
    85
    void schemeChanged(const QString & scheme);
11431
80a9b14bb8d3 Some game config methods and signals
unc0rr
parents: 11430
diff changeset
    86
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
    87
    void roomAdded(quint32 flags
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
    88
                   , const QString & name
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
    89
                   , int players
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
    90
                   , int teams
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
    91
                   , const QString & host
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
    92
                   , const QString & map
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
    93
                   , const QString & script
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
    94
                   , const QString & scheme
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
    95
                   , const QString & weapons);
11422
c6c6a4b32cea Handle ROOM UPD
unc0rr
parents: 11419
diff changeset
    96
    void roomUpdated(const QString & name
c6c6a4b32cea Handle ROOM UPD
unc0rr
parents: 11419
diff changeset
    97
                   , quint32 flags
c6c6a4b32cea Handle ROOM UPD
unc0rr
parents: 11419
diff changeset
    98
                   , const QString & newName
c6c6a4b32cea Handle ROOM UPD
unc0rr
parents: 11419
diff changeset
    99
                   , int players
c6c6a4b32cea Handle ROOM UPD
unc0rr
parents: 11419
diff changeset
   100
                   , int teams
c6c6a4b32cea Handle ROOM UPD
unc0rr
parents: 11419
diff changeset
   101
                   , const QString & host
c6c6a4b32cea Handle ROOM UPD
unc0rr
parents: 11419
diff changeset
   102
                   , const QString & map
c6c6a4b32cea Handle ROOM UPD
unc0rr
parents: 11419
diff changeset
   103
                   , const QString & script
c6c6a4b32cea Handle ROOM UPD
unc0rr
parents: 11419
diff changeset
   104
                   , const QString & scheme
c6c6a4b32cea Handle ROOM UPD
unc0rr
parents: 11419
diff changeset
   105
                   , const QString & weapons);
11419
8a5cc31483c6 - Handle ROOM DEL
unc0rr
parents: 11418
diff changeset
   106
    void roomRemoved(const QString & name);
11418
091149424aa4 Handle ROOMS and ROOM ADD protocol commands
unc0rr
parents: 11416
diff changeset
   107
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
   108
public slots:
10416
1c301054694d - Remove --port command
unc0rr
parents: 10402
diff changeset
   109
1c301054694d - Remove --port command
unc0rr
parents: 10402
diff changeset
   110
private:
10420
unc0rr
parents: 10418
diff changeset
   111
    QQmlEngine * m_engine;
11430
f88b3948adf3 UI knowns local player nickname
unc0rr
parents: 11424
diff changeset
   112
    QString m_myNickname;
10416
1c301054694d - Remove --port command
unc0rr
parents: 10402
diff changeset
   113
10428
7c25297720f1 More refactoring: move PoC preview getting code into flib
unc0rr
parents: 10426
diff changeset
   114
    static void guiMessagesCallback(void * context, MessageType mt, const char * msg, uint32_t len);
10434
1614b13ad35e Themes model, also add some files I forgot to add previously
unc0rr
parents: 10432
diff changeset
   115
    void fillModels();
10420
unc0rr
parents: 10418
diff changeset
   116
unc0rr
parents: 10418
diff changeset
   117
private slots:
10430
899a30018ede Getter and setter for seed
unc0rr
parents: 10428
diff changeset
   118
    void engineMessageHandler(MessageType mt, const QByteArray &msg);
10402
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
   119
};
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
   120
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
   121
#endif // HWENGINE_H
3313336c1ee0 Let's get it started
unc0rr
parents:
diff changeset
   122