Skip to main content
Sign in
Snippets Groups Projects
Select Git revision
  • cb738475d01fa2a67b32804e906f74e468a46d00
  • main default protected
  • leveleditor
  • david-author
  • clang-tidy-cleanup
  • architecture-refactoring
  • cleanUpMenus
  • doxygen-cleanup
  • project-structure-refactoring
  • interpolation
  • buildingFeatures
  • win_end_screen
  • helpMenu
  • leveleditor-placement
  • text-rendering
  • updated_unit_contextmenu
  • level-from-commandline
  • unit_contextmenu
  • player
  • engine-scaling
  • clang-tidy
21 results

LevelScene.hpp

Blame
  • LevelScene.hpp 1.29 KiB
    #ifndef LEVELSCENE_HPP
    #define LEVELSCENE_HPP
    
    #include <QGraphicsScene>
    #include <QMouseEvent>
    #include <QWidget>
    #include <QGraphicsRectItem>
    #include <QGraphicsSceneMouseEvent>
    #include "EventBroker.hpp"
    #include "Tile.hpp"
    
    class LevelScene : public QGraphicsScene, public EventBroker {
    public:
        LevelScene(const std::string& name, int width, int height, std::vector<uint8_t> tile_ids, const std::string& file_path, QWidget *parent = nullptr);
        static LevelScene* empty(const std::string& name, int width, int height, QWidget *parent = nullptr);
        static LevelScene* fromFile(const std::string& file_path, QWidget *parent = nullptr);
        std::string getName();
        int getWidth();
        int getHeight();
    private:
        void onLevelNameUpdated(std::string new_name) override;
        void onLevelWriteRequested(QString file_path) override;
        void onTileEntered(int index) override;  
        void onTileExited(int index) override;
        void onTileClicked(int index) override;
        void onNewTileIdSelected(uint8_t tile_id) override;
        QGraphicsPixmapItem* occupy_tile(int index, uint8_t tile_id);
        uint8_t selected_tile_id;
        std::string name;
        int width;
        int height;
        std::vector<uint8_t> tile_ids;
        std::vector<QGraphicsPixmapItem*> tile_occupants;
        std::string file_path;
    };
    
    #endif // LEVELSCENE_HPP