qmlfrontend/hwengine.h
author unC0Rr
Wed, 28 Aug 2024 17:16:23 +0200
branchtransitional_engine
changeset 16052 0fd23fc57947
parent 16039 a73b9770467a
permissions -rw-r--r--
Make pascal engine link to hwengine-future and use WFC generator
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14164
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
     1
#ifndef HWENGINE_H
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
     2
#define HWENGINE_H
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
     3
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
     4
#include <QList>
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
     5
#include <QObject>
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
     6
14175
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents: 14164
diff changeset
     7
#include "game_config.h"
16039
a73b9770467a Port QML frontend to Qt6, use rendering to framebuffer object
unC0Rr
parents: 15919
diff changeset
     8
#include "preview_acceptor.h"
14164
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
     9
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    10
class QQmlEngine;
14319
00b56ec8b7df Pass opengl context to engine
unC0Rr
parents: 14294
diff changeset
    11
class EngineInstance;
14164
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    12
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    13
class HWEngine : public QObject {
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    14
  Q_OBJECT
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    15
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    16
  Q_PROPERTY(int previewHedgehogsCount READ previewHedgehogsCount NOTIFY
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    17
                 previewHedgehogsCountChanged)
14392
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    18
  Q_PROPERTY(PreviewAcceptor* previewAcceptor READ previewAcceptor WRITE
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    19
                 setPreviewAcceptor NOTIFY previewAcceptorChanged)
14393
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14392
diff changeset
    20
  Q_PROPERTY(QString engineLibrary READ engineLibrary WRITE setEngineLibrary
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14392
diff changeset
    21
                 NOTIFY engineLibraryChanged)
15919
d52f5d8e75e6 Allow passing data_path from QML
unc0rr
parents: 14393
diff changeset
    22
  Q_PROPERTY(QString dataPath READ dataPath WRITE setDataPath NOTIFY dataPathChanged)
14164
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    23
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    24
 public:
14392
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    25
  explicit HWEngine(QObject* parent = nullptr);
16039
a73b9770467a Port QML frontend to Qt6, use rendering to framebuffer object
unC0Rr
parents: 15919
diff changeset
    26
  ~HWEngine() override;
14164
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    27
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    28
  Q_INVOKABLE void getPreview();
14319
00b56ec8b7df Pass opengl context to engine
unC0Rr
parents: 14294
diff changeset
    29
  Q_INVOKABLE EngineInstance* runQuickGame();
14164
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    30
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    31
  int previewHedgehogsCount() const;
14392
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    32
  PreviewAcceptor* previewAcceptor() const;
14393
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14392
diff changeset
    33
  QString engineLibrary() const;
14392
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    34
15919
d52f5d8e75e6 Allow passing data_path from QML
unc0rr
parents: 14393
diff changeset
    35
  const QString &dataPath() const;
d52f5d8e75e6 Allow passing data_path from QML
unc0rr
parents: 14393
diff changeset
    36
  void setDataPath(const QString &newDataPath);
d52f5d8e75e6 Allow passing data_path from QML
unc0rr
parents: 14393
diff changeset
    37
d52f5d8e75e6 Allow passing data_path from QML
unc0rr
parents: 14393
diff changeset
    38
public slots:
14392
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    39
  void setPreviewAcceptor(PreviewAcceptor* previewAcceptor);
14393
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14392
diff changeset
    40
  void setEngineLibrary(const QString& engineLibrary);
14164
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    41
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    42
 signals:
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    43
  void previewIsRendering();
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    44
  void previewImageChanged();
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    45
  void previewHogCountChanged(int count);
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    46
  void gameFinished();
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    47
  void previewHedgehogsCountChanged(int previewHedgehogsCount);
14392
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    48
  void previewAcceptorChanged(PreviewAcceptor* previewAcceptor);
14393
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14392
diff changeset
    49
  void engineLibraryChanged(const QString& engineLibrary);
14164
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    50
15919
d52f5d8e75e6 Allow passing data_path from QML
unc0rr
parents: 14393
diff changeset
    51
  void dataPathChanged();
d52f5d8e75e6 Allow passing data_path from QML
unc0rr
parents: 14393
diff changeset
    52
d52f5d8e75e6 Allow passing data_path from QML
unc0rr
parents: 14393
diff changeset
    53
private:
14164
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    54
  QQmlEngine* m_engine;
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    55
  GameConfig m_gameConfig;
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    56
  int m_previewHedgehogsCount;
14392
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14319
diff changeset
    57
  PreviewAcceptor* m_previewAcceptor;
14393
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14392
diff changeset
    58
  QString m_engineLibrary;
15919
d52f5d8e75e6 Allow passing data_path from QML
unc0rr
parents: 14393
diff changeset
    59
  QString m_dataPath;
14164
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    60
};
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    61
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    62
#endif  // HWENGINE_H