2025-07-06 20:43:53 +03:00
|
|
|
#pragma once
|
|
|
|
|
#include "../SharedTypes.hpp"
|
|
|
|
|
#include "DrawComponent.hpp"
|
|
|
|
|
#include "../CoordSpaceHelper.hpp"
|
2025-11-10 14:45:51 +03:00
|
|
|
#include "../RichText/TextBox.hpp"
|
2025-07-06 20:43:53 +03:00
|
|
|
|
|
|
|
|
#ifndef IS_SERVER
|
|
|
|
|
#include <include/core/SkPath.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
class DrawTextBox : public DrawComponent {
|
|
|
|
|
public:
|
2025-11-12 10:44:17 +03:00
|
|
|
constexpr static float TEXTBOX_PADDING = 5.0f;
|
|
|
|
|
|
2025-10-20 17:30:36 +03:00
|
|
|
DrawTextBox();
|
2025-07-06 20:43:53 +03:00
|
|
|
virtual DrawComponentType get_type() const override;
|
|
|
|
|
virtual void save(cereal::PortableBinaryOutputArchive& a) const override;
|
|
|
|
|
virtual void load(cereal::PortableBinaryInputArchive& a) override;
|
|
|
|
|
|
|
|
|
|
// User input data
|
|
|
|
|
struct Data {
|
|
|
|
|
Vector2f p1;
|
|
|
|
|
Vector2f p2;
|
2025-10-25 17:31:55 +03:00
|
|
|
bool editing = false; // Should probably move this out of the Data struct
|
2025-07-06 20:43:53 +03:00
|
|
|
bool operator==(const Data& o) const = default;
|
2025-07-31 15:30:22 +03:00
|
|
|
bool operator!=(const Data& o) const = default;
|
2025-07-06 20:43:53 +03:00
|
|
|
} d;
|
|
|
|
|
|
|
|
|
|
#ifndef IS_SERVER
|
|
|
|
|
virtual std::shared_ptr<DrawComponent> copy() const override;
|
2025-07-29 14:11:36 +03:00
|
|
|
virtual std::shared_ptr<DrawComponent> deep_copy() const override;
|
|
|
|
|
|
2025-07-06 20:43:53 +03:00
|
|
|
virtual void draw(SkCanvas* canvas, const DrawData& drawData) override;
|
|
|
|
|
virtual void initialize_draw_data(DrawingProgram& drawP) override;
|
2025-07-28 14:25:28 +03:00
|
|
|
virtual bool collides_within_coords(const SCollision::ColliderCollection<float>& checkAgainst) override;
|
2025-07-06 20:43:53 +03:00
|
|
|
virtual void update(DrawingProgram& drawP) override;
|
2025-07-31 09:34:17 +03:00
|
|
|
void create_collider();
|
|
|
|
|
virtual void update_from_delayed_ptr(const std::shared_ptr<DrawComponent>& delayedUpdatePtr) override;
|
2025-07-06 20:43:53 +03:00
|
|
|
void init_text_box(DrawingProgram& drawP);
|
|
|
|
|
Vector2f get_mouse_pos(DrawingProgram& drawP);
|
|
|
|
|
|
|
|
|
|
virtual SCollision::AABB<float> get_obj_coord_bounds() const override;
|
|
|
|
|
|
2025-11-10 14:45:51 +03:00
|
|
|
std::shared_ptr<RichText::TextBox> textBox;
|
|
|
|
|
std::shared_ptr<RichText::TextBox::Cursor> cursor;
|
2025-07-06 20:43:53 +03:00
|
|
|
SCollision::BVHContainer<float> collisionTree;
|
|
|
|
|
#endif
|
|
|
|
|
};
|