macros and ui element
This commit is contained in:
29
include/object/ui/uibutton.hpp
Normal file
29
include/object/ui/uibutton.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <object/entity.hpp>
|
||||
#include <renderer/font.hpp>
|
||||
#include <renderer/texture.hpp>
|
||||
#include <utility>
|
||||
#include <game/input.hpp>
|
||||
|
||||
namespace Game::Object {
|
||||
class UIButton : public Entity {
|
||||
public:
|
||||
UIButton(const std::string& name, std::shared_ptr<Renderer::Texture> texture, const Transform& transform, void* clickFunction = nullptr, float x = 0.f, float y = 0.f);
|
||||
~UIButton() override = default;
|
||||
|
||||
void start() override;
|
||||
void update(float deltaTime) override;
|
||||
|
||||
void setText(const std::string& text);
|
||||
std::string getText() const;
|
||||
|
||||
void setPosition(float x, float y) { mX = x; mY = y; }
|
||||
std::pair<float, float> getPosition() const { return {mX, mY}; }
|
||||
|
||||
private:
|
||||
void* mClickFunction = nullptr;
|
||||
float mX, mY;
|
||||
std::string mText;
|
||||
};
|
||||
}
|
||||
29
include/object/ui/uitext.hpp
Normal file
29
include/object/ui/uitext.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#include <object/entity.hpp>
|
||||
#include <renderer/font.hpp>
|
||||
#include <renderer/texture.hpp>
|
||||
#include <utility>
|
||||
#include <game/input.hpp>
|
||||
|
||||
namespace Game::Object {
|
||||
class UIText : public Entity {
|
||||
public:
|
||||
UIText(const std::string& name, std::shared_ptr<Renderer::Font> font, const Transform& transform, float x = 0.f, float y = 0.f);
|
||||
~UIText() override = default;
|
||||
|
||||
void start() override;
|
||||
void update(float deltaTime) override;
|
||||
|
||||
void setText(const std::string& text);
|
||||
std::string getText() const;
|
||||
|
||||
void setPosition(float x, float y) { mX = x; mY = y; }
|
||||
std::pair<float, float> getPosition() const { return {mX, mY}; }
|
||||
|
||||
private:
|
||||
//void* mClickFunction = nullptr;
|
||||
float mX, mY;
|
||||
std::string mText;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user