Remove element script and allow images to be pixel updated for similar behaviour
This commit is contained in:
+1
-30
@@ -8,8 +8,7 @@
|
||||
|
||||
enum Type { IMAGE,
|
||||
TEXT,
|
||||
RECT,
|
||||
SCRIPT };
|
||||
RECT };
|
||||
|
||||
enum ClickMode { PASS,
|
||||
BLOCK,
|
||||
@@ -83,34 +82,6 @@ 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
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ inline struct RubyBindings {
|
||||
Binding ElementText;
|
||||
Binding ElementRect;
|
||||
Binding ElementImage;
|
||||
Binding ElementScript;
|
||||
Binding Scene;
|
||||
} bindings;
|
||||
|
||||
@@ -44,7 +43,6 @@ void register_animation();
|
||||
void register_element_text();
|
||||
void register_element_rect();
|
||||
void register_element_image();
|
||||
void register_element_script();
|
||||
void register_scene();
|
||||
void register_app();
|
||||
|
||||
@@ -57,7 +55,6 @@ inline void setup() {
|
||||
register_element_text();
|
||||
register_element_rect();
|
||||
register_element_image();
|
||||
register_element_script();
|
||||
register_scene();
|
||||
register_app();
|
||||
}
|
||||
|
||||
+3
-19
@@ -32,15 +32,6 @@ struct Text {
|
||||
}
|
||||
};
|
||||
|
||||
struct Scripted {
|
||||
SDL_Texture *texture;
|
||||
Vec2<float> size;
|
||||
|
||||
~Scripted() {
|
||||
SDL_DestroyTexture(texture);
|
||||
}
|
||||
};
|
||||
|
||||
// Image pool
|
||||
inline Pool<Image> image_pool;
|
||||
|
||||
@@ -50,9 +41,6 @@ inline Pool<Font> font_pool;
|
||||
// Text pool
|
||||
inline Pool<Text> text_pool;
|
||||
|
||||
// Scripted pool
|
||||
inline Pool<Scripted> scripted_pool;
|
||||
|
||||
struct Event {
|
||||
enum Type {
|
||||
NONE,
|
||||
@@ -111,7 +99,9 @@ public:
|
||||
|
||||
// Rendering functions
|
||||
uint64_t load_image(const char *path, bool pixel_art);
|
||||
uint64_t create_image(Vec2<float> size, bool pixel_art);
|
||||
Vec2<float> get_image_size(uint64_t image_id);
|
||||
bool update_image(uint64_t image_id, Rect content_rect, const char *new_content, uint32_t length);
|
||||
|
||||
uint64_t load_font(const char *path, int font_size, bool bold, bool italic, bool underline, bool pixel_art);
|
||||
|
||||
@@ -119,11 +109,6 @@ public:
|
||||
uint64_t create_text(uint64_t font_id, const char *text, uint32_t length, Color color);
|
||||
Vec2<float> get_text_size(uint64_t text_id);
|
||||
|
||||
uint64_t create_scripted(Vec2<float> size, bool pixel_art);
|
||||
Vec2<float> get_scripted_size(uint64_t scripted_id);
|
||||
|
||||
bool update_scripted(uint64_t scripted_id, Rect content_rect, const char *new_content, uint32_t length);
|
||||
|
||||
bool write(uint64_t text_id, Vec2<float> position, float z, float angle, Vec2<float> pivot, Vec2<float> scale, float alpha);
|
||||
|
||||
bool draw(uint64_t image_id, Vec2<float> position, float z, float angle, Vec2<float> pivot, Vec2<float> scale, float alpha);
|
||||
@@ -166,8 +151,7 @@ private:
|
||||
enum Type {
|
||||
DRAW_IMAGE,
|
||||
DRAW_TEXT,
|
||||
DRAW_RECT,
|
||||
DRAW_SCRIPTED
|
||||
DRAW_RECT
|
||||
} type;
|
||||
|
||||
float z;
|
||||
|
||||
Reference in New Issue
Block a user