qmlfrontend/hwengine.h
author Simon McVittie <smcv@debian.org>
Mon, 12 Sep 2022 10:40:53 -0400
branch1.0.0
changeset 15859 7b1d6dfa3173
parent 14372 b6824a53d4b1
child 15891 d52f5d8e75e6
permissions -rw-r--r--
Remove FindSDL2 find-module, use sdl2-config.cmake instead This requires SDL >= 2.0.4. Since <https://bugzilla.libsdl.org/show_bug.cgi?id=2464> was fixed in SDL 2.0.4, SDL behaves as a CMake "config-file package", even if it was not itself built using CMake: it installs a sdl2-config.cmake file to ${libdir}/cmake/SDL2, which tells CMake where to find SDL's headers and library, analogous to a pkg-config .pc file. As a result, we no longer need to copy/paste a "find-module package" to be able to find a system copy of SDL >= 2.0.4 with find_package(SDL2). Find-module packages are now discouraged by the CMake developers, in favour of having upstream projects behave as config-file packages. This results in a small API change: FindSDL2 used to set SDL2_INCLUDE_DIR and SDL2_LIBRARY, but the standard behaviour for config-file packages is to set <name>_INCLUDE_DIRS and <name>_LIBRARIES. Use the CONFIG keyword to make sure we search in config-file package mode, and will not find a FindSDL2.cmake in some other directory that implements the old interface. In addition to deleting redundant code, this avoids some assumptions in FindSDL2 about the layout of a SDL installation. The current libsdl2-dev package in Debian breaks those assumptions; this is considered a bug and will hopefully be fixed soon, but it illustrates how fragile these assumptions can be. We can be more robust against different installation layouts by relying on SDL's own CMake integration. When linking to a copy of CMake in a non-standard location, users can now set the SDL2_DIR or CMAKE_PREFIX_PATH environment variable to point to it; previously, these users would have used the SDL2DIR environment variable. This continues to be unnecessary if using matching system-wide installations of CMake and SDL2, for example both from Debian.
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 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
14154
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents: 14143
diff changeset
     7
#include "engine_interface.h"
8354b390f1a2 Some refactoring of qmlfrontend. It now shows land preview generated by hedgewars-engine
unC0Rr
parents: 14143
diff changeset
     8
#include "game_config.h"
14143
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;
14298
00b56ec8b7df Pass opengl context to engine
unC0Rr
parents: 14273
diff changeset
    11
class EngineInstance;
14371
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14298
diff changeset
    12
class PreviewAcceptor;
14143
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    13
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    14
class HWEngine : public QObject {
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    15
  Q_OBJECT
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    16
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    17
  Q_PROPERTY(int previewHedgehogsCount READ previewHedgehogsCount NOTIFY
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    18
                 previewHedgehogsCountChanged)
14371
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14298
diff changeset
    19
  Q_PROPERTY(PreviewAcceptor* previewAcceptor READ previewAcceptor WRITE
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14298
diff changeset
    20
                 setPreviewAcceptor NOTIFY previewAcceptorChanged)
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14371
diff changeset
    21
  Q_PROPERTY(QString engineLibrary READ engineLibrary WRITE setEngineLibrary
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14371
diff changeset
    22
                 NOTIFY engineLibraryChanged)
14143
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:
14371
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14298
diff changeset
    25
  explicit HWEngine(QObject* parent = nullptr);
14143
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    26
  ~HWEngine();
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();
14298
00b56ec8b7df Pass opengl context to engine
unC0Rr
parents: 14273
diff changeset
    29
  Q_INVOKABLE EngineInstance* runQuickGame();
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
  int previewHedgehogsCount() const;
14371
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14298
diff changeset
    32
  PreviewAcceptor* previewAcceptor() const;
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14371
diff changeset
    33
  QString engineLibrary() const;
14371
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14298
diff changeset
    34
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14298
diff changeset
    35
 public slots:
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14298
diff changeset
    36
  void setPreviewAcceptor(PreviewAcceptor* previewAcceptor);
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14371
diff changeset
    37
  void setEngineLibrary(const QString& engineLibrary);
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
 signals:
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    40
  void previewIsRendering();
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    41
  void previewImageChanged();
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    42
  void previewHogCountChanged(int count);
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    43
  void gameFinished();
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    44
  void previewHedgehogsCountChanged(int previewHedgehogsCount);
14371
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14298
diff changeset
    45
  void previewAcceptorChanged(PreviewAcceptor* previewAcceptor);
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14371
diff changeset
    46
  void engineLibraryChanged(const QString& engineLibrary);
14143
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    47
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    48
 private:
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    49
  QQmlEngine* m_engine;
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    50
  GameConfig m_gameConfig;
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    51
  int m_previewHedgehogsCount;
14371
90bd2c331703 Add possibility to instantiate HWEngine objects from QML, reorganize work with preview
unC0Rr
parents: 14298
diff changeset
    52
  PreviewAcceptor* m_previewAcceptor;
14372
b6824a53d4b1 Allow to instantiate HWEngine with different library binaries
unC0Rr
parents: 14371
diff changeset
    53
  QString m_engineLibrary;
14143
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    54
};
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    55
745c73e0e644 Start working on frontend to rust engine rewrite
unC0Rr
parents:
diff changeset
    56
#endif  // HWENGINE_H