qmlfrontend/game_view.h
author unC0Rr
Mon, 16 Sep 2024 16:57:11 +0200
branchtransitional_engine
changeset 16034 09beeec033ba
parent 16017 e8afb1bf2779
permissions -rw-r--r--
Sanitize maze mapgen code a bit
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14143
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
     1
#ifndef GAMEVIEW_H
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
     2
#define GAMEVIEW_H
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
     3
14290
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14154
diff changeset
     4
#include <QPointer>
16010
a73b9770467a Port QML frontend to Qt6, use rendering to framebuffer object
unC0Rr
parents: 14842
diff changeset
     5
#include <QQuickFramebufferObject>
14290
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14154
diff changeset
     6
#include <QScopedPointer>
14143
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
     7
14290
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14154
diff changeset
     8
#include "engine_instance.h"
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14154
diff changeset
     9
16010
a73b9770467a Port QML frontend to Qt6, use rendering to framebuffer object
unC0Rr
parents: 14842
diff changeset
    10
class GameView : public QQuickFramebufferObject {
14143
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    11
  Q_OBJECT
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    12
14290
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14154
diff changeset
    13
  Q_PROPERTY(EngineInstance* engineInstance READ engineInstance WRITE
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14154
diff changeset
    14
                 setEngineInstance NOTIFY engineInstanceChanged)
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14154
diff changeset
    15
14143
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    16
 public:
14842
ef9630519491 Fix some minor problems with new frontend code
unc0rr
parents: 14713
diff changeset
    17
  explicit GameView(QQuickItem* parent = nullptr);
14143
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    18
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    19
  Q_INVOKABLE void tick(quint32 delta);
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    20
14290
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14154
diff changeset
    21
  EngineInstance* engineInstance() const;
16010
a73b9770467a Port QML frontend to Qt6, use rendering to framebuffer object
unC0Rr
parents: 14842
diff changeset
    22
  Renderer* createRenderer() const override;
16017
e8afb1bf2779 Implement triggering advancement of simulation in qmlfrontend
unC0Rr
parents: 16010
diff changeset
    23
  void executeActions();
16010
a73b9770467a Port QML frontend to Qt6, use rendering to framebuffer object
unC0Rr
parents: 14842
diff changeset
    24
a73b9770467a Port QML frontend to Qt6, use rendering to framebuffer object
unC0Rr
parents: 14842
diff changeset
    25
 Q_SIGNALS:
14290
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14154
diff changeset
    26
  void engineInstanceChanged(EngineInstance* engineInstance);
14143
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    27
16010
a73b9770467a Port QML frontend to Qt6, use rendering to framebuffer object
unC0Rr
parents: 14842
diff changeset
    28
 public Q_SLOTS:
14290
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14154
diff changeset
    29
  void setEngineInstance(EngineInstance* engineInstance);
14143
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
 private:
14290
92e5682810d4 Prepare to have possibility to pass opengl context to engine
unc0rr
parents: 14154
diff changeset
    32
  QPointer<EngineInstance> m_engineInstance;
14712
57293f34ce59 Detect and handle resize
unc0rr
parents: 14290
diff changeset
    33
  QSize m_viewportSize;
14713
cc6ab1e3f7d5 Allow to move camera around
unc0rr
parents: 14712
diff changeset
    34
  QPoint m_centerPoint;
16017
e8afb1bf2779 Implement triggering advancement of simulation in qmlfrontend
unC0Rr
parents: 16010
diff changeset
    35
  QList<std::function<void(EngineInstance*)>> m_actions;
e8afb1bf2779 Implement triggering advancement of simulation in qmlfrontend
unC0Rr
parents: 16010
diff changeset
    36
e8afb1bf2779 Implement triggering advancement of simulation in qmlfrontend
unC0Rr
parents: 16010
diff changeset
    37
  void addAction(std::function<void(EngineInstance*)>&& action);
14143
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    38
};
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    39
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    40
#endif  // GAMEVIEW_H