Shkyera Engine
Easy to use, game engine for Python
ObjectsWidget.hpp
Go to the documentation of this file.
1 
7 #pragma once
8 
9 #include <memory>
10 #include <vector>
11 
12 #include "game/Game.hpp"
13 #include "ui/Widget.hpp"
14 
15 namespace shkyera {
16 
22 class ObjectsWidget : public Widget {
23  public:
24  using Widget::Widget;
25 
31  void setGame(std::shared_ptr<Game> game);
32 
38  std::shared_ptr<GameObject> getSelectedObject() const;
39 
43  virtual void draw() override;
44 
45  private:
49  void drawCreate();
50 
54  void drawList();
55 
56  std::shared_ptr<Game> _game;
57  std::vector<std::shared_ptr<GameObject>> _gameObjects;
59 };
60 
61 } // namespace shkyera
Contains the declaration of the Game class, representing the game environment.
Contains the declaration of the Widget class, an abstract base class for GUI widgets.
A user interface widget for managing game objects.
Definition: ObjectsWidget.hpp:22
std::vector< std::shared_ptr< GameObject > > _gameObjects
A list of game objects.
Definition: ObjectsWidget.hpp:57
std::shared_ptr< Game > _game
A shared pointer to the associated game.
Definition: ObjectsWidget.hpp:56
size_t _selectedGameObject
The index of the currently selected game object.
Definition: ObjectsWidget.hpp:58
virtual void draw() override
Implementation of the abstract draw method to render the game objects widget.
Definition: ObjectsWidget.cpp:15
void drawList()
Draw the list of game objects and allow selection.
Definition: ObjectsWidget.cpp:39
void setGame(std::shared_ptr< Game > game)
Set the game to associate with this widget.
Definition: ObjectsWidget.cpp:11
void drawCreate()
Draw the creation panel for new game objects.
Definition: ObjectsWidget.cpp:23
std::shared_ptr< GameObject > getSelectedObject() const
Get the currently selected game object.
Definition: ObjectsWidget.cpp:13
An abstract base class representing a GUI widget.
Definition: Widget.hpp:21
Widget(std::string name)
Constructor to create a widget with a specified name.
Definition: Widget.cpp:5
Definition: Entity.cpp:3