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

#ifndef GAMEVIEW_H
#define GAMEVIEW_H

#include <QPointer>
#include <QQuickFramebufferObject>
#include <QScopedPointer>

#include "engine_instance.h"

class GameView : public QQuickFramebufferObject {
  Q_OBJECT

  Q_PROPERTY(EngineInstance* engineInstance READ engineInstance WRITE
                 setEngineInstance NOTIFY engineInstanceChanged)

 public:
  explicit GameView(QQuickItem* parent = nullptr);

  Q_INVOKABLE void tick(quint32 delta);

  EngineInstance* engineInstance() const;
  Renderer* createRenderer() const override;
  void executeActions();

 Q_SIGNALS:
  void engineInstanceChanged(EngineInstance* engineInstance);

 public Q_SLOTS:
  void setEngineInstance(EngineInstance* engineInstance);

 private:
  QPointer<EngineInstance> m_engineInstance;
  QSize m_viewportSize;
  QPoint m_centerPoint;
  QList<std::function<void(EngineInstance*)>> m_actions;

  void addAction(std::function<void(EngineInstance*)>&& action);
};

#endif  // GAMEVIEW_H