26 #include <boost/make_shared.hpp>
27 #include <boost/shared_ptr.hpp>
35 static const char *
next_id =
"__wml_items_next_page";
36 static const char *
prev_id =
"__wml_items_prev_page";
39 std::vector<std::string> & descriptions)
43 temp[
"description"] = desc;
44 items.push_back(boost::make_shared<const game_events::wml_menu_item>(
next_id, temp));
45 descriptions.push_back(desc);
49 std::vector<std::string> & descriptions)
53 temp[
"description"] = desc;
54 items.push_back(boost::make_shared<const game_events::wml_menu_item>(
prev_id, temp));
55 descriptions.push_back(desc);
71 typedef std::pair<wmi_ptr, std::string>
wmi_pair;
86 std::vector<wmi_ptr > &
items,
87 std::vector<std::string> & descriptions)
95 assert(page_size_int >= 0 &&
"max wml menu items cannot be negative, this indicates preferences corruption");
97 const size_t page_size = page_size_int;
99 assert(page_size > 2u &&
"if we dont have at least 3 items, we can't display anything on a middle page...");
103 if (new_items.size() <= page_size) {
117 wmi_it end_first_page = new_items.begin();
118 std::advance(end_first_page, page_size - 1);
133 size_t first_displayed_index = (page_size - 2) *
page_num_ + 1;
136 while (first_displayed_index >= new_items.size())
139 first_displayed_index = (page_size - 2) *
page_num_ + 1;
143 if (first_displayed_index + page_size-1 >= new_items.size())
146 wmi_it end_range = new_items.end();
147 wmi_it start_range = end_range;
148 std::advance(start_range, -static_cast<signed int>(page_size-1));
154 wmi_it start_range = new_items.begin();
155 std::advance(start_range, first_displayed_index);
157 wmi_it end_range = start_range;
158 std::advance(end_range, page_size-2);
const std::vector< std::string > items
Definitions for the interface to Wesnoth Markup Language (WML).
GLuint GLenum GLenum transform
static UNUSEDNOWARN std::string _(const char *str)
Encapsulates the map of the game.
Declarations for a container for wml_menu_item.
std::vector< std::pair< boost::shared_ptr< const wml_menu_item >, std::string > > get_items(const map_location &hex, game_data &gamedata, filter_context &fc, unit_map &units, const_iterator start, const_iterator finish) const
Returns the menu items that can be shown for the given location.
Container associating units to locations.
A config object defines a single node in a WML file, with access to child nodes.
GLsizei const GLcharARB ** string