Add sliders to set colour of label in map editor

- Needs work, not very user-friendly in my opinion
This commit is contained in:
Celtic Minstrel 2015-08-06 23:43:16 -04:00
parent af6d3060e2
commit 1c578590e1
4 changed files with 160 additions and 38 deletions

View file

@ -131,58 +131,151 @@
[/column]
[/row]
[row]
grow_factor = 0
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[grid]
[row]
grow_factor = 0
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[toggle_button]
id = "immutable_toggle"
definition = "default"
label= _ "Immutable"
[/toggle_button]
[label]
definition = "default"
label = _ "Properties"
[/label]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[label]
definition = "default"
label = _ "Color"
[/label]
[/column]
[/row]
[/column]
[/row]
[row]
grow_factor = 0
[row]
grow_factor = 0
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[toggle_button]
id = "immutable_toggle"
definition = "default"
label= _ "Immutable"
[/toggle_button]
[toggle_button]
id = "visible_fog_toggle"
definition = "default"
label= _ "Visible in fog"
[/toggle_button]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[slider]
id = "slider_red"
definition = "default"
minimum_value = 0
maximum_value = 255
step_size = 1
value = 255
[/slider]
[/column]
[/row]
[/column]
[/row]
[row]
grow_factor = 0
[row]
grow_factor = 0
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[toggle_button]
id = "visible_fog_toggle"
definition = "default"
label= _ "Visible in fog"
[/toggle_button]
[toggle_button]
id = "visible_shroud_toggle"
definition = "default"
label= _ "Visible in shroud"
[/toggle_button]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[slider]
id = "slider_green"
definition = "default"
minimum_value = 0
maximum_value = 255
step_size = 1
value = 255
[/slider]
[/column]
[/row]
[row]
grow_factor = 0
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[toggle_button]
id = "visible_shroud_toggle"
definition = "default"
label= _ "Visible in shroud"
[/toggle_button]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
border = "all"
border_size = 5
[slider]
id = "slider_blue"
definition = "default"
minimum_value = 0
maximum_value = 255
step_size = 1
value = 255
[/slider]
[/column]
[/row]
[/grid]
[/column]
[/row]

View file

@ -76,12 +76,13 @@ editor_action* mouse_action_map_label::up_left(editor_display& disp, int x, int
bool visible_shroud = old_label ? old_label->visible_in_shroud() : false;
bool visible_fog = old_label ? old_label->visible_in_fog() : true;
bool immutable = old_label ? old_label->immutable() : true;
SDL_Color color = old_label ? old_label->color() : font::NORMAL_COLOR;
gui2::teditor_edit_label d(label, immutable, visible_fog, visible_shroud, category);
gui2::teditor_edit_label d(label, immutable, visible_fog, visible_shroud, color, category);
editor_action* a = NULL;
if(d.show(disp.video())) {
a = new editor_action_label(hex, label, team_name, font::NORMAL_COLOR
a = new editor_action_label(hex, label, team_name, color
, visible_fog, visible_shroud, immutable, category);
update_brush_highlights(disp, hex);
}

View file

@ -18,6 +18,9 @@
#include "gui/widgets/settings.hpp"
#include <SDL_video.h>
#include <boost/bind.hpp>
namespace gui2
{
@ -50,7 +53,9 @@ teditor_edit_label::teditor_edit_label(std::string& text,
bool& immutable,
bool& visible_fog,
bool& visible_shroud,
SDL_Color& color,
std::string& category)
: color_store(color)
{
// std::string text = label.text();
// bool immutable = label.immutable();
@ -70,5 +75,22 @@ teditor_edit_label::teditor_edit_label(std::string& text,
register_bool("immutable_toggle", true, immutable);
register_bool("visible_fog_toggle", true, visible_fog);
register_bool("visible_shroud_toggle", true, visible_shroud);
register_color_component("slider_red", &SDL_Color::r);
register_color_component("slider_green", &SDL_Color::g);
register_color_component("slider_blue", &SDL_Color::b);
}
void teditor_edit_label::register_color_component(std::string widget_id, Uint8 SDL_Color::* component) {
register_integer(widget_id, true,
boost::bind(&teditor_edit_label::load_color_component, this, component),
boost::bind(&teditor_edit_label::save_color_component, this, component, _1));
}
int teditor_edit_label::load_color_component(Uint8 SDL_Color::* component) {
return color_store.*component;
}
void teditor_edit_label::save_color_component(Uint8 SDL_Color::* component, const int value) {
color_store.*component = value;
}
}

View file

@ -37,6 +37,7 @@ public:
bool& immutable,
bool& visible_fog,
bool& visible_shroud,
SDL_Color& color,
std::string& category);
/** The execute function see @ref tdialog for more information. */
@ -44,14 +45,19 @@ public:
bool& immutable,
bool& visible_fog,
bool& visible_shroud,
SDL_Color& color,
std::string& category,
CVideo& video)
{
return teditor_edit_label(text, immutable, visible_fog, visible_shroud, /*color,*/ category)
return teditor_edit_label(text, immutable, visible_fog, visible_shroud, color, category)
.show(video);
}
private:
SDL_Color& color_store;
int load_color_component(Uint8 SDL_Color::* component);
void save_color_component(Uint8 SDL_Color::* component, const int value);
void register_color_component(std::string widget_id, Uint8 SDL_Color::* component);
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
};