qmlfrontend/engine_instance.h
author Wuzzy <Wuzzy2@mail.ru>
Sat, 06 Jun 2020 15:40:51 +0200
changeset 15597 6e72bd61002e
parent 15217 b32c52c76977
child 15891 d52f5d8e75e6
permissions -rw-r--r--
Disable gfMoreWind for land objects on turn end only after a fixed-time delay 15s sounds much, but it's the average amount for gfMineStrike mines to settle naturally. And it would be very confusing to see falling mines suddenly not caring about gfMoreWind for no apparent reason. Note this whole thing is a giant hack anyway, to prevent a turn being blocked by infinitely bouncing mines. The better solution would be to help gfMoreWind-affected land objects settle naturally more reliably even under extreme wind. But this commit is "good enough" for now. If you don't like the delay, you can always tweak the constant.

#ifndef ENGINEINSTANCE_H
#define ENGINEINSTANCE_H

#include <QImage>
#include <QObject>
#include <QOpenGLContext>

#include "engine_interface.h"
#include "game_config.h"

class EngineInstance : public QObject {
  Q_OBJECT

 public:
  explicit EngineInstance(const QString& libraryPath,
                          QObject* parent = nullptr);
  ~EngineInstance();

  Q_PROPERTY(bool isValid READ isValid NOTIFY isValidChanged)

  void sendConfig(const GameConfig& config);
  void renderFrame();
  void setOpenGLContext(QOpenGLContext* context);
  QImage generatePreview();

  bool isValid() const;

 signals:
  void isValidChanged(bool isValid);

 public slots:
  void advance(quint32 ticks);
  void moveCamera(const QPoint& delta);
  void simpleEvent(Engine::SimpleEventType event_type);
  void longEvent(Engine::LongEventType event_type,
                 Engine::LongEventState state);
  void positionedEvent(Engine::PositionedEventType event_type, qint32 x,
                       qint32 y);

 private:
  Engine::EngineInstance* m_instance;

  Engine::hedgewars_engine_protocol_version_t*
      hedgewars_engine_protocol_version;
  Engine::start_engine_t* start_engine;
  Engine::generate_preview_t* generate_preview;
  Engine::dispose_preview_t* dispose_preview;
  Engine::cleanup_t* cleanup;
  Engine::send_ipc_t* send_ipc;
  Engine::read_ipc_t* read_ipc;
  Engine::setup_current_gl_context_t* setup_current_gl_context;
  Engine::render_frame_t* render_frame;
  Engine::advance_simulation_t* advance_simulation;
  Engine::move_camera_t* move_camera;
  Engine::simple_event_t* simple_event;
  Engine::long_event_t* long_event;
  Engine::positioned_event_t* positioned_event;
  bool m_isValid;
};

#endif  // ENGINEINSTANCE_H