Reenabled the palette group menu.

This commit is contained in:
fendrin 2013-05-01 19:08:17 +02:00
parent 9995853471
commit f1527dd8a0
7 changed files with 59 additions and 23 deletions

View file

@ -15,7 +15,7 @@
[editor_group]
id=water
name= _ "water"
icon="group_water"
icon="group_water_deep"
core=yes
[/editor_group]
@ -29,7 +29,7 @@
[editor_group]
id=desert
name= _ "desert"
icon="group_desert"
icon="group_sand"
core=yes
[/editor_group]
@ -64,21 +64,21 @@
[editor_group]
id=rough
name= _ "rough"
icon="group_rough"
icon="group_mountains"
core=yes
[/editor_group]
[editor_group]
id=cave
name= _ "cave"
icon="group_cave"
icon="group_caves"
core=yes
[/editor_group]
[editor_group]
id=obstacle
name= _ "obstacle"
icon="group_obstacle"
icon="group_unwalkable"
core=yes
[/editor_group]
@ -99,7 +99,7 @@
[editor_group]
id=bridge
name= _ "bridge"
icon="group_bridge"
icon="group_bridges"
core=yes
[/editor_group]

View file

@ -881,7 +881,7 @@
xanchor=right
yanchor=top
[/palette]
[action]
[menu]
id=menu-editor-terrain
items=editor-palette-groups
type=turbo
@ -889,7 +889,7 @@
rect="=-1,=-43,+30,+30"
xanchor=right
yanchor=fixed
[/action]
[/menu]
[action]
id=menu-editor-flip-palette-selection
items=editor-terrain-palette-swap

View file

@ -689,10 +689,10 @@ void editor_controller::show_menu(const std::vector<std::string>& items_arg, int
context_manager_->expand_open_maps_menu(items);
}
//TODO
// if (!items.empty() && items.front() == "editor-palette-groups") {
// active_menu_ = editor::PALETTE;
// toolkit_->get_palette_manager()->active_palette().expand_palette_groups_menu(items);
// }
if (!items.empty() && items.front() == "editor-palette-groups") {
active_menu_ = editor::PALETTE;
toolkit_->get_palette_manager()->active_palette().expand_palette_groups_menu(items);
}
if (!items.empty() && items.front() == "editor-side-switch") {
active_menu_ = editor::SIDE;
context_manager_->expand_sides_menu(items);

View file

@ -74,6 +74,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
@ -81,6 +82,7 @@ public:
virtual size_t start_num() = 0;
virtual void set_start_item(size_t index) = 0;
virtual void swap() = 0;
};

View file

@ -41,21 +41,35 @@ 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::pair< std::string, std::string> >& items)
void editor_palette<Item>::expand_palette_groups_menu(std::vector<std::string>& items)
{
const std::vector<item_group>& item_groups = get_groups();
for (unsigned int i = 0; i < items.size(); ++i) {
if (items[i] == "editor-palette-groups") {
items.erase(items.begin() + i);
for (size_t mci = 0; mci < item_groups.size(); ++mci) {
std::string groupname = item_groups[mci].name;
if (groupname.empty()) {
groupname = _("(Unknown Group)");
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 + "_30.png";
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;
}
const std::string& img = item_groups[mci].icon;
items.push_back(std::pair<std::string, std::string>( img, groupname));
}
}
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 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<class Item>
bool editor_palette<Item>::scroll_up()
@ -74,6 +88,24 @@ bool editor_palette<Item>::scroll_up()
template bool editor_palette<t_translation::t_terrain>::scroll_up();
template bool editor_palette<unit_type>::scroll_up();
template<class Item>
void editor_palette<Item>::expand_palette_groups_menu(std::vector< std::pair< std::string, std::string> >& items)
{
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)");
}
const std::string& img = item_groups[mci].icon;
items.push_back(std::pair<std::string, std::string>( img, groupname));
}
}
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>::can_scroll_up()
{
@ -121,7 +153,7 @@ void editor_palette<Item>::set_group(const std::string& id)
BOOST_FOREACH(const item_group& group, groups_) {
if (group.id == id) {
found = true;
gui::button* palette_menu_button = gui_.find_action_button("menu-editor-terrain");
gui::button* palette_menu_button = gui_.find_menu_button("menu-editor-terrain");
if (palette_menu_button) {
//palette_menu_button->set_label(group.name);
palette_menu_button->set_tooltip_string(group.name);

View file

@ -63,6 +63,7 @@ public:
/** Menu expanding for palette group list */
void expand_palette_groups_menu(std::vector< std::pair<std::string, std::string> >& items);
void expand_palette_groups_menu(std::vector<std::string>& items);
void set_group(size_t index);
// int active_group();

View file

@ -68,6 +68,7 @@ public:
/** Menu expanding for palette group list */
virtual void expand_palette_groups_menu(std::vector< std::pair< std::string, std::string> >& /*items*/) {};
virtual void expand_palette_groups_menu(std::vector< std::string> & /*items*/) {};
//item
virtual size_t num_items() {return 0;};