Support for a new select terrain group dialog.
This commit is contained in:
parent
63e4db2140
commit
adbda2dd37
6 changed files with 44 additions and 33 deletions
|
@ -425,6 +425,10 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde
|
|||
context_manager_->get_map_context().get_labels().recalculate_labels();
|
||||
return true;
|
||||
case HOTKEY_EDITOR_PALETTE_GROUPS:
|
||||
//TODO mordante
|
||||
//std::vector< std::pair< std::string, std::string > > items;
|
||||
//toolkit_->get_palette_manager()->active_palette().expand_palette_groups_menu(items);
|
||||
//new_dialog(items);
|
||||
return true;
|
||||
case HOTKEY_EDITOR_PALETTE_UPSCROLL:
|
||||
toolkit_->get_palette_manager()->scroll_up();
|
||||
|
@ -635,11 +639,11 @@ void editor_controller::show_menu(const std::vector<std::string>& items_arg, int
|
|||
context_manager_->expand_open_maps_menu(items);
|
||||
context_menu = true; //FIXME hack to display a one-item menu
|
||||
}
|
||||
if (!items.empty() && items.front() == "editor-palette-groups") {
|
||||
active_menu_ = editor::PALETTE;
|
||||
toolkit_->get_palette_manager()->active_palette().expand_palette_groups_menu(items);
|
||||
context_menu = true; //FIXME hack to display a one-item menu
|
||||
}
|
||||
// if (!items.empty() && items.front() == "editor-palette-groups") {
|
||||
// active_menu_ = editor::PALETTE;
|
||||
// toolkit_->get_palette_manager()->active_palette().expand_palette_groups_menu(items);
|
||||
// context_menu = true; //FIXME hack to display a one-item menu
|
||||
// }
|
||||
if (!items.empty() && items.front() == "editor-side-switch") {
|
||||
active_menu_ = editor::SIDE;
|
||||
context_manager_->expand_sides_menu(items);
|
||||
|
|
|
@ -71,7 +71,7 @@ public:
|
|||
virtual const std::vector<item_group>& get_groups() const = 0;
|
||||
|
||||
/** Menu expanding for palette group list */
|
||||
virtual void expand_palette_groups_menu(std::vector<std::string>& items) = 0;
|
||||
virtual void expand_palette_groups_menu(std::vector< std::pair< std::string, std::string> >& items) = 0;
|
||||
|
||||
//item
|
||||
virtual size_t num_items() = 0;
|
||||
|
|
|
@ -41,35 +41,33 @@ template handler_vector editor_palette<t_translation::t_terrain>::handler_member
|
|||
template handler_vector editor_palette<unit_type>::handler_members();
|
||||
|
||||
template<class Item>
|
||||
void editor_palette<Item>::expand_palette_groups_menu(std::vector<std::string>& items)
|
||||
void editor_palette<Item>::expand_palette_groups_menu(std::vector< std::pair< std::string, std::string> >& items)
|
||||
{
|
||||
for (unsigned int i = 0; i < items.size(); ++i) {
|
||||
if (items[i] == "editor-palette-groups") {
|
||||
items.erase(items.begin() + i);
|
||||
//for (unsigned int i = 0; i < items.size(); ++i) {
|
||||
// if (items[i] == "editor-palette-groups") {
|
||||
// items.erase(items.begin() + i);
|
||||
|
||||
std::vector<std::string> groups;
|
||||
const std::vector<item_group>& item_groups = get_groups();
|
||||
//std::vector<std::string> groups;
|
||||
const std::vector<item_group>& item_groups = get_groups();
|
||||
|
||||
for (size_t mci = 0; mci < item_groups.size(); ++mci) {
|
||||
std::string groupname = item_groups[mci].name;
|
||||
if (groupname.empty()) {
|
||||
groupname = _("(Unknown Group)");
|
||||
}
|
||||
std::string img = item_groups[mci].icon;
|
||||
std::stringstream str;
|
||||
//TODO
|
||||
//std::string postfix = ".png"; //(toolkit_->active_group_index() == mci) ? "-pressed.png" : ".png";
|
||||
//str << IMAGE_PREFIX << "buttons/" << img << postfix << COLUMN_SEPARATOR << groupname;
|
||||
str << IMAGE_PREFIX << img << COLUMN_SEPARATOR << groupname;
|
||||
groups.push_back(str.str());
|
||||
}
|
||||
items.insert(items.begin() + i, groups.begin(), groups.end());
|
||||
break;
|
||||
for (size_t mci = 0; mci < item_groups.size(); ++mci) {
|
||||
std::string groupname = item_groups[mci].name;
|
||||
if (groupname.empty()) {
|
||||
groupname = _("(Unknown Group)");
|
||||
}
|
||||
std::string img = item_groups[mci].icon;
|
||||
std::stringstream str;
|
||||
//TODO
|
||||
//std::string postfix = ".png"; //(toolkit_->active_group_index() == mci) ? "-pressed.png" : ".png";
|
||||
//str << IMAGE_PREFIX << "buttons/" << img << postfix << COLUMN_SEPARATOR << groupname;
|
||||
str << IMAGE_PREFIX << img << COLUMN_SEPARATOR << groupname;
|
||||
items.push_back(std::pair<std::string, std::string>( str.str(), str.str()));
|
||||
}
|
||||
//items.insert(items.begin() + i, groups.begin(), groups.end());
|
||||
//break;
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::expand_palette_groups_menu(std::vector<std::string>& items);
|
||||
template void editor_palette<unit_type>::expand_palette_groups_menu(std::vector<std::string>& items);
|
||||
template void editor_palette<t_translation::t_terrain>::expand_palette_groups_menu(std::vector< std::pair< std::string, std::string> >& items);
|
||||
template void editor_palette<unit_type>::expand_palette_groups_menu(std::vector< std::pair< std::string, std::string> >& items);
|
||||
|
||||
template<class Item>
|
||||
bool editor_palette<Item>::scroll_up()
|
||||
|
@ -131,8 +129,15 @@ void editor_palette<Item>::set_group(const std::string& id)
|
|||
|
||||
bool found = false;
|
||||
BOOST_FOREACH(const item_group& group, groups_) {
|
||||
if (group.id == id)
|
||||
if (group.id == id) {
|
||||
found = true;
|
||||
gui::button* palette_menu_button = gui_.find_button("menu-editor-terrain");
|
||||
if (palette_menu_button) {
|
||||
palette_menu_button->set_label(group.name);
|
||||
ERR_ED << group.icon << " sowas \n";
|
||||
palette_menu_button->set_image(group.icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(found);
|
||||
|
||||
|
@ -141,6 +146,8 @@ void editor_palette<Item>::set_group(const std::string& id)
|
|||
if(active_group().empty()) {
|
||||
ERR_ED << "No items found in group with the id: '" << id << "'.\n";
|
||||
}
|
||||
|
||||
//if (groups_.size() >= 3)
|
||||
gui_.set_palette_report(active_group_report());
|
||||
}
|
||||
template void editor_palette<t_translation::t_terrain>::set_group(const std::string& id);
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
size_t start_num(void) { return items_start_; };
|
||||
|
||||
/** Menu expanding for palette group list */
|
||||
void expand_palette_groups_menu(std::vector<std::string>& items);
|
||||
void expand_palette_groups_menu(std::vector< std::pair<std::string, std::string> >& items);
|
||||
|
||||
void set_group(size_t index);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
virtual const std::vector<item_group>& get_groups() const { return empty_; };
|
||||
|
||||
/** Menu expanding for palette group list */
|
||||
virtual void expand_palette_groups_menu(std::vector<std::string>& /*items*/) {};
|
||||
virtual void expand_palette_groups_menu(std::vector< std::pair< std::string, std::string> >& /*items*/) {};
|
||||
|
||||
//item
|
||||
virtual size_t num_items() {return 0;};
|
||||
|
|
|
@ -96,7 +96,7 @@ void terrain_palette::setup(const config& cfg)
|
|||
cfg["id"] = g["id"];
|
||||
cfg["name"] = g["name"];
|
||||
|
||||
cfg["icon"] = "buttons/editor/group/" + g["icon"].t_str() + ".png";
|
||||
cfg["icon"] = "buttons/editor/group/" + g["icon"].t_str();
|
||||
cfg["core"] = "yes";
|
||||
groups_.push_back(item_group(cfg));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue