Mario: formatting
This commit is contained in:
+35
-28
@@ -33,8 +33,9 @@ public:
|
||||
std::shared_ptr<SDLPP::Renderer> &r, const std::string &text,
|
||||
const ButtonConfig &config,
|
||||
std::function<void(void *, Button *)> click_fun, void *input)
|
||||
: TextRenderer(x, y, w, h, r, g_text_config->getFont(), text, config.font_color,
|
||||
config.font_outline_color, config.outline),
|
||||
: TextRenderer(x, y, w, h, r, g_text_config->getFont(), text,
|
||||
config.font_color, config.font_outline_color,
|
||||
config.outline),
|
||||
click_fun(std::move(click_fun)), func_input(input),
|
||||
config(config), button_text(text) {
|
||||
setColor(config.bg_color);
|
||||
@@ -48,60 +49,60 @@ public:
|
||||
}
|
||||
void setFontColor(const std::string &color) {
|
||||
config.font_color = color;
|
||||
if(!highlighted && !disabled) {
|
||||
if (!highlighted && !disabled) {
|
||||
should_update_color = true;
|
||||
}
|
||||
}
|
||||
void setFontColorHighlight(const std::string &color) {
|
||||
config.font_color_highlight = color;
|
||||
if(highlighted && !disabled) {
|
||||
if (highlighted && !disabled) {
|
||||
should_update_color = true;
|
||||
}
|
||||
}
|
||||
void setFontColorDisabled(const std::string &color) {
|
||||
config.font_color_disabled = color;
|
||||
if(disabled) {
|
||||
if (disabled) {
|
||||
should_update_color = true;
|
||||
}
|
||||
}
|
||||
void setFontOutlineColor(const std::string &color) {
|
||||
config.font_outline_color = color;
|
||||
if(!highlighted && !disabled) {
|
||||
if (!highlighted && !disabled) {
|
||||
should_update_color = true;
|
||||
}
|
||||
}
|
||||
void setFontOutlineColorHighlight(const std::string &color) {
|
||||
config.font_outline_color_highlight = color;
|
||||
if(highlighted && !disabled) {
|
||||
if (highlighted && !disabled) {
|
||||
should_update_color = true;
|
||||
}
|
||||
}
|
||||
void setFontOutlineColorDisabled(const std::string &color) {
|
||||
config.font_outline_color_disabled = color;
|
||||
if(disabled) {
|
||||
if (disabled) {
|
||||
should_update_color = true;
|
||||
}
|
||||
}
|
||||
void setBackgroundColor(const std::string &color) {
|
||||
config.bg_color = color;
|
||||
if(!highlighted && !disabled) {
|
||||
if (!highlighted && !disabled) {
|
||||
setColor(color);
|
||||
}
|
||||
}
|
||||
void setBackgroundColorHighlight(const std::string &color) {
|
||||
config.bg_color_highlight = color;
|
||||
if(highlighted && !disabled) {
|
||||
if (highlighted && !disabled) {
|
||||
setColor(color);
|
||||
}
|
||||
}
|
||||
void setBackgroundColorDisabled(const std::string &color) {
|
||||
config.bg_color_disabled = color;
|
||||
if(disabled) {
|
||||
if (disabled) {
|
||||
setColor(color);
|
||||
}
|
||||
}
|
||||
void performFunction() {
|
||||
if(!disabled) {
|
||||
if (!disabled) {
|
||||
click_fun(func_input, this);
|
||||
}
|
||||
}
|
||||
@@ -112,7 +113,7 @@ public:
|
||||
_id = id;
|
||||
}
|
||||
void setHighlight() {
|
||||
if(!disabled) {
|
||||
if (!disabled) {
|
||||
setColor(config.bg_color_highlight);
|
||||
should_update_color = true;
|
||||
state = HIGHLIGHTED;
|
||||
@@ -120,7 +121,7 @@ public:
|
||||
highlighted = true;
|
||||
}
|
||||
void unsetHighlight() {
|
||||
if(!disabled) {
|
||||
if (!disabled) {
|
||||
setColor(config.bg_color);
|
||||
should_update_color = true;
|
||||
state = NORMAL;
|
||||
@@ -134,7 +135,7 @@ public:
|
||||
disabled = true;
|
||||
}
|
||||
void enable() {
|
||||
if(!highlighted) {
|
||||
if (!highlighted) {
|
||||
setColor(config.bg_color);
|
||||
should_update_color = true;
|
||||
state = NORMAL;
|
||||
@@ -147,24 +148,30 @@ public:
|
||||
}
|
||||
|
||||
void update() {
|
||||
if(should_update_color) {
|
||||
switch(state) {
|
||||
case NORMAL:
|
||||
setTextColor(g_text_config->getFont(), config.font_color, config.font_outline_color, config.outline);
|
||||
break;
|
||||
case HIGHLIGHTED:
|
||||
setTextColor(g_text_config->getFont(), config.font_color_highlight, config.font_outline_color_highlight, config.outline);
|
||||
break;
|
||||
case DISABLED:
|
||||
setTextColor(g_text_config->getFont(), config.font_color_disabled, config.font_outline_color_disabled, config.outline);
|
||||
default:
|
||||
break;
|
||||
if (should_update_color) {
|
||||
switch (state) {
|
||||
case NORMAL:
|
||||
setTextColor(g_text_config->getFont(), config.font_color,
|
||||
config.font_outline_color, config.outline);
|
||||
break;
|
||||
case HIGHLIGHTED:
|
||||
setTextColor(
|
||||
g_text_config->getFont(), config.font_color_highlight,
|
||||
config.font_outline_color_highlight, config.outline);
|
||||
break;
|
||||
case DISABLED:
|
||||
setTextColor(
|
||||
g_text_config->getFont(), config.font_color_disabled,
|
||||
config.font_outline_color_disabled, config.outline);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(should_update_text) {
|
||||
if (should_update_text) {
|
||||
changeText(button_text);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::function<void(void *, Button *)> click_fun;
|
||||
void *func_input;
|
||||
|
||||
Reference in New Issue
Block a user