bugs and perfomance cleanup.
This commit is contained in:
+10
-4
@@ -39,9 +39,7 @@ struct Element {
|
||||
struct EImage : Element {
|
||||
uint64_t animation_id = UINT64_MAX;
|
||||
|
||||
EImage(uint64_t animation_id) : Element(Type::IMAGE), animation_id(animation_id) {
|
||||
animation_pool.use(animation_id);
|
||||
}
|
||||
EImage(uint64_t animation_id) : Element(Type::IMAGE), animation_id(animation_id) {}
|
||||
|
||||
~EImage() {
|
||||
if (animation_id != UINT64_MAX)
|
||||
@@ -86,6 +84,13 @@ struct EText : Element {
|
||||
return window.get_text_size(text_id);
|
||||
}
|
||||
|
||||
void reload_text() {
|
||||
if (text_id != UINT64_MAX) {
|
||||
text_pool.release(text_id);
|
||||
text_id = UINT64_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
void render(Window &window, uint64_t) override {
|
||||
if (
|
||||
last_language != Localization::current_language
|
||||
@@ -93,13 +98,14 @@ struct EText : Element {
|
||||
|| last_color != color
|
||||
|| params_changed
|
||||
) {
|
||||
std::string localized_str = Localization::get(Ruby::mrb, key, params);
|
||||
std::string localized_str = Localization::get(key, params);
|
||||
if (text_id != UINT64_MAX)
|
||||
text_pool.release(text_id);
|
||||
text_id = window.create_text(font_id, localized_str.c_str(), localized_str.size(), color);
|
||||
last_language = Localization::current_language;
|
||||
last_key = key;
|
||||
last_color = color;
|
||||
params_changed = false;
|
||||
}
|
||||
window.write(text_id, position, z, rotation, pivot, scale, alpha);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user