Made use of the help string system to signal selected palette items.
This commit is contained in:
parent
6e399d8d53
commit
6d54cacb12
6 changed files with 30 additions and 27 deletions
|
@ -241,6 +241,8 @@ void editor_palette<Item>::select_fg_item(const std::string& item_id)
|
|||
selected_fg_item_ = item_id;
|
||||
set_dirty();
|
||||
}
|
||||
gui_.video().clear_help_string(help_handle_);
|
||||
help_handle_ = gui_.video().set_help_string(get_help_string());
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::select_fg_item(const std::string& terrain_id);
|
||||
template void editor_palette<unit_type>::select_fg_item(const std::string& unit_id);
|
||||
|
@ -252,6 +254,8 @@ void editor_palette<Item>::select_bg_item(const std::string& item_id)
|
|||
selected_bg_item_ = item_id;
|
||||
set_dirty();
|
||||
}
|
||||
gui_.video().clear_help_string(help_handle_);
|
||||
help_handle_ = gui_.video().set_help_string(get_help_string());
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::select_bg_item(const std::string& terrain_id);
|
||||
template void editor_palette<unit_type>::select_bg_item(const std::string& unit_id);
|
||||
|
|
|
@ -50,6 +50,7 @@ public:
|
|||
, selected_bg_item_()
|
||||
, active_mouse_action_(active_mouse_action)
|
||||
, buttons_()
|
||||
, help_handle_(-1)
|
||||
{
|
||||
};
|
||||
|
||||
|
@ -98,6 +99,8 @@ public:
|
|||
|
||||
void swap();
|
||||
|
||||
virtual std::string get_help_string() = 0;
|
||||
|
||||
/** Return the currently selected foreground/background item. */
|
||||
const Item& selected_fg_item() const { return item_map_.find(selected_fg_item_)->second; };
|
||||
const Item& selected_bg_item() const { return item_map_.find(selected_bg_item_)->second; };
|
||||
|
@ -126,6 +129,9 @@ private:
|
|||
|
||||
void hide(bool hidden) {
|
||||
widget::hide(hidden);
|
||||
if (!hidden)
|
||||
help_handle_ = gui_.video().set_help_string(get_help_string());
|
||||
else gui_.video().clear_help_string(help_handle_);
|
||||
BOOST_FOREACH(gui::widget& w, buttons_) {
|
||||
w.hide(hidden);
|
||||
}
|
||||
|
@ -177,6 +183,8 @@ private:
|
|||
|
||||
mouse_action** active_mouse_action_;
|
||||
std::vector<gui::tristate_button> buttons_;
|
||||
|
||||
int help_handle_;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <boost/foreach.hpp>
|
||||
|
||||
namespace {
|
||||
static std::string selected_terrain;
|
||||
static t_translation::t_terrain fg_terrain;
|
||||
static t_translation::t_terrain bg_terrain;
|
||||
}
|
||||
|
@ -48,36 +47,24 @@ static bool is_valid_terrain(const t_translation::t_terrain & c) {
|
|||
return !(c == t_translation::VOID_TERRAIN || c == t_translation::FOGGED);
|
||||
}
|
||||
|
||||
void terrain_palette::update_report()
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << _("FG: ") << map().get_terrain_editor_string(selected_fg_item()) << " | "
|
||||
<< _("BG: ") << map().get_terrain_editor_string(selected_bg_item());
|
||||
selected_terrain = msg.str();
|
||||
}
|
||||
|
||||
void terrain_palette::select_bg_item(const std::string& item_id) {
|
||||
bg_terrain = item_map_[item_id];
|
||||
editor_palette<t_translation::t_terrain>::select_bg_item(item_id);
|
||||
bg_terrain = editor_palette<t_translation::t_terrain>::selected_bg_item();
|
||||
update_report();
|
||||
}
|
||||
|
||||
void terrain_palette::select_fg_item(const std::string& item_id) {
|
||||
fg_terrain = item_map_[item_id];
|
||||
editor_palette<t_translation::t_terrain>::select_fg_item(item_id);
|
||||
fg_terrain = editor_palette<t_translation::t_terrain>::selected_fg_item();
|
||||
update_report();
|
||||
}
|
||||
|
||||
void terrain_palette::select_bg_item(const t_translation::t_terrain& terrain) {
|
||||
editor_palette<t_translation::t_terrain>::select_bg_item(get_id(terrain));
|
||||
bg_terrain = terrain;
|
||||
update_report();
|
||||
editor_palette<t_translation::t_terrain>::select_bg_item(get_id(terrain));
|
||||
}
|
||||
|
||||
void terrain_palette::select_fg_item(const t_translation::t_terrain& terrain) {
|
||||
editor_palette<t_translation::t_terrain>::select_fg_item(get_id(terrain));
|
||||
fg_terrain = terrain;
|
||||
update_report();
|
||||
editor_palette<t_translation::t_terrain>::select_fg_item(get_id(terrain));
|
||||
}
|
||||
|
||||
|
||||
|
@ -232,5 +219,13 @@ const std::string& terrain_palette::get_id(const t_translation::t_terrain& terra
|
|||
return t_info.id();
|
||||
}
|
||||
|
||||
std::string terrain_palette::get_help_string()
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << _("FG: ") << map().get_terrain_editor_string(selected_fg_item()) << " | "
|
||||
<< _("BG: ") << map().get_terrain_editor_string(selected_bg_item());
|
||||
return msg.str();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ public:
|
|||
const t_translation::t_terrain& selected_fg_item() const;
|
||||
const t_translation::t_terrain& selected_bg_item() const;
|
||||
|
||||
virtual std::string get_help_string();
|
||||
|
||||
private:
|
||||
|
||||
virtual void select_bg_item(const std::string& item_id);
|
||||
|
@ -54,7 +56,6 @@ private:
|
|||
|
||||
virtual void draw_item(const t_translation::t_terrain& terrain, surface& item_image, std::stringstream& tooltip_text);
|
||||
|
||||
virtual void update_report();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -28,16 +28,9 @@
|
|||
|
||||
namespace editor {
|
||||
|
||||
//TODO
|
||||
/*
|
||||
void unit_palette::update_report()
|
||||
{
|
||||
// std::ostringstream msg;
|
||||
// msg << _("FG: ") << map().get_terrain_editor_string(selected_fg_item())
|
||||
// << '\n' << _("BG: ") << map().get_terrain_editor_string(selected_fg_item());
|
||||
// selected_terrain = msg.str();
|
||||
std::string unit_palette::get_help_string() {
|
||||
return selected_fg_item().type_name();
|
||||
}
|
||||
*/
|
||||
|
||||
void unit_palette::setup(const config& /*cfg*/)
|
||||
{
|
||||
|
|
|
@ -35,6 +35,8 @@ public:
|
|||
|
||||
virtual void setup(const config& cfg);
|
||||
|
||||
virtual std::string get_help_string();
|
||||
|
||||
private:
|
||||
virtual const std::string& get_id(const unit_type& terrain);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue