Added pixel texture element
This commit is contained in:
+32
-2
@@ -8,7 +8,8 @@
|
||||
|
||||
enum Type { IMAGE,
|
||||
TEXT,
|
||||
RECT };
|
||||
RECT,
|
||||
SCRIPT };
|
||||
|
||||
enum ClickMode { PASS,
|
||||
BLOCK,
|
||||
@@ -72,8 +73,9 @@ private:
|
||||
};
|
||||
|
||||
struct ERect : Element {
|
||||
Vec2<float> shape = {0, 0};
|
||||
Color color = {255, 255, 255};
|
||||
Vec2<float> shape = {0, 0};
|
||||
|
||||
Vec2<float> size() override;
|
||||
|
||||
ERect(Vec2<float> shape, Color color) : Element(Type::RECT), shape(shape), color(color) {}
|
||||
@@ -81,6 +83,34 @@ struct ERect : Element {
|
||||
void render(uint64_t) override;
|
||||
};
|
||||
|
||||
struct EScript : Element {
|
||||
Ruby::Block script;
|
||||
uint64_t scripted_id = UINT64_MAX;
|
||||
bool pixel_art = false;
|
||||
Vec2<float> shape;
|
||||
|
||||
EScript(Vec2<float> shape) : Element(Type::SCRIPT), shape(shape) {
|
||||
scripted_id = window.create_scripted(shape, pixel_art);
|
||||
}
|
||||
|
||||
~EScript() {
|
||||
if (scripted_id != UINT64_MAX)
|
||||
scripted_pool.release(scripted_id);
|
||||
};
|
||||
|
||||
Vec2<float> size() override {
|
||||
return shape;
|
||||
}
|
||||
|
||||
bool update_scripted(Rect content_rect, const char *new_content, uint32_t length) {
|
||||
return window.update_scripted(scripted_id, content_rect, new_content, length);
|
||||
}
|
||||
|
||||
void render(uint64_t) override {
|
||||
window.draw_scripted(scripted_id, position, z, rotation, pivot, scale, alpha);
|
||||
};
|
||||
};
|
||||
|
||||
inline Pool<Element> element_pool;
|
||||
} // namespace app
|
||||
|
||||
|
||||
Reference in New Issue
Block a user