[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src dialogs.cpp display.cpp font.cpp ga...
From: |
Yann Dirson |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src dialogs.cpp display.cpp font.cpp ga... |
Date: |
Mon, 16 May 2005 18:44:22 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Yann Dirson <address@hidden> 05/05/16 22:44:21
Modified files:
src : dialogs.cpp display.cpp font.cpp game.cpp
game_config.cpp game_config.hpp help.cpp
intro.cpp language.cpp multiplayer_lobby.cpp
multiplayer_lobby.hpp playcampaign.cpp
playturn.cpp preferences.cpp random.cpp
show_dialog.cpp show_dialog.hpp tstring.cpp
tstring.hpp util.hpp variable.cpp
wml_separators.hpp
src/serialization: binary_or_text.cpp
src/widgets : button.cpp button.hpp menu.cpp menu.hpp
progressbar.cpp progressbar.hpp slider.hpp
widget.cpp widget.hpp
Log message:
dos2unix
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/dialogs.cpp.diff?tr1=1.101&tr2=1.102&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/display.cpp.diff?tr1=1.320&tr2=1.321&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/font.cpp.diff?tr1=1.141&tr2=1.142&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game.cpp.diff?tr1=1.245&tr2=1.246&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game_config.cpp.diff?tr1=1.97&tr2=1.98&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/game_config.hpp.diff?tr1=1.28&tr2=1.29&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/help.cpp.diff?tr1=1.98&tr2=1.99&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/intro.cpp.diff?tr1=1.77&tr2=1.78&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/language.cpp.diff?tr1=1.88&tr2=1.89&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_lobby.cpp.diff?tr1=1.72&tr2=1.73&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/multiplayer_lobby.hpp.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playcampaign.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.cpp.diff?tr1=1.369&tr2=1.370&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/preferences.cpp.diff?tr1=1.157&tr2=1.158&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/random.cpp.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/show_dialog.cpp.diff?tr1=1.128&tr2=1.129&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/show_dialog.hpp.diff?tr1=1.48&tr2=1.49&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/tstring.cpp.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/tstring.hpp.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/util.hpp.diff?tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/variable.cpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/wml_separators.hpp.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/serialization/binary_or_text.cpp.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/button.cpp.diff?tr1=1.64&tr2=1.65&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/button.hpp.diff?tr1=1.31&tr2=1.32&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/menu.cpp.diff?tr1=1.91&tr2=1.92&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/menu.hpp.diff?tr1=1.37&tr2=1.38&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/progressbar.cpp.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/progressbar.hpp.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/slider.hpp.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/widget.cpp.diff?tr1=1.32&tr2=1.33&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/widget.hpp.diff?tr1=1.27&tr2=1.28&r1=text&r2=text
Patches:
Index: wesnoth/src/dialogs.cpp
diff -u wesnoth/src/dialogs.cpp:1.101 wesnoth/src/dialogs.cpp:1.102
--- wesnoth/src/dialogs.cpp:1.101 Tue May 10 22:15:57 2005
+++ wesnoth/src/dialogs.cpp Mon May 16 22:44:19 2005
@@ -1,4 +1,4 @@
-/* $Id: dialogs.cpp,v 1.101 2005/05/10 22:15:57 Sirp Exp $ */
+/* $Id: dialogs.cpp,v 1.102 2005/05/16 22:44:19 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -391,51 +391,51 @@
font::draw_text(&video(), area, font::SIZE_SMALL, font::NORMAL_COLOUR,
str.str(), area.x, ypos, true);
}
-
-std::string format_time_summary(time_t t)
-{
- time_t curtime = time(NULL);
- const struct tm* timeptr = localtime(&curtime);
- if(timeptr == NULL) {
- return "";
- }
-
- const struct tm current_time = *timeptr;
-
- timeptr = localtime(&t);
- if(timeptr == NULL) {
- return "";
- }
-
- const struct tm save_time = *timeptr;
-
- const char* format_string = _("%b %d %y");
-
- if(current_time.tm_year == save_time.tm_year) {
- const int days_apart = current_time.tm_yday - save_time.tm_yday;
- if(days_apart == 0) {
- //save is from today
- format_string = _("%H:%M");
- } else if(days_apart > 0 && days_apart <= current_time.tm_wday)
{
- //save is from this week
- format_string = _("%A, %H:%M");
- } else {
- //save is from current year
- format_string = _("%b %d");
- }
- } else {
- //save is from a different year
- format_string = _("%b %d %y");
- }
-
- char buf[40];
- const size_t res = strftime(buf,sizeof(buf),format_string,&save_time);
- if(res == 0) {
- buf[0] = 0;
- }
-
- return buf;
-}
+
+std::string format_time_summary(time_t t)
+{
+ time_t curtime = time(NULL);
+ const struct tm* timeptr = localtime(&curtime);
+ if(timeptr == NULL) {
+ return "";
+ }
+
+ const struct tm current_time = *timeptr;
+
+ timeptr = localtime(&t);
+ if(timeptr == NULL) {
+ return "";
+ }
+
+ const struct tm save_time = *timeptr;
+
+ const char* format_string = _("%b %d %y");
+
+ if(current_time.tm_year == save_time.tm_year) {
+ const int days_apart = current_time.tm_yday - save_time.tm_yday;
+ if(days_apart == 0) {
+ //save is from today
+ format_string = _("%H:%M");
+ } else if(days_apart > 0 && days_apart <= current_time.tm_wday)
{
+ //save is from this week
+ format_string = _("%A, %H:%M");
+ } else {
+ //save is from current year
+ format_string = _("%b %d");
+ }
+ } else {
+ //save is from a different year
+ format_string = _("%b %d %y");
+ }
+
+ char buf[40];
+ const size_t res = strftime(buf,sizeof(buf),format_string,&save_time);
+ if(res == 0) {
+ buf[0] = 0;
+ }
+
+ return buf;
+}
} //end anon namespace
@@ -539,22 +539,22 @@
write_save_index();
}
- std::vector<std::string> items;
- std::ostringstream heading;
- heading << HEADING_PREFIX << _("Name") << COLUMN_SEPARATOR << _("Date");
- items.push_back(heading.str());
+ std::vector<std::string> items;
+ std::ostringstream heading;
+ heading << HEADING_PREFIX << _("Name") << COLUMN_SEPARATOR << _("Date");
+ items.push_back(heading.str());
for(i = games.begin(); i != games.end(); ++i) {
std::string name = i->name;
- name.resize(minimum<size_t>(name.size(),40));
-
- std::ostringstream str;
+ name.resize(minimum<size_t>(name.size(),40));
+
+ std::ostringstream str;
str << name << COLUMN_SEPARATOR <<
format_time_summary(i->time_modified);
items.push_back(str.str());
- }
-
- gui::menu::basic_sorter sorter;
+ }
+
+ gui::menu::basic_sorter sorter;
sorter.set_alpha_sort(0).set_id_sort(1);
gamemap map_obj(game_config,"");
Index: wesnoth/src/display.cpp
diff -u wesnoth/src/display.cpp:1.320 wesnoth/src/display.cpp:1.321
--- wesnoth/src/display.cpp:1.320 Sat May 14 20:56:21 2005
+++ wesnoth/src/display.cpp Mon May 16 22:44:19 2005
@@ -1,4 +1,4 @@
-/* $Id: display.cpp,v 1.320 2005/05/14 20:56:21 darthfool Exp $ */
+/* $Id: display.cpp,v 1.321 2005/05/16 22:44:19 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1647,7 +1647,7 @@
}
}
}
-
+
const std::vector<std::string>* image_category = NULL;
@@ -1665,22 +1665,22 @@
} else {
image_category = &game_config::foot_right_nw;
}
- }
-
- if(image_category == NULL || image_category->empty()) {
- return;
- }
-
- const std::string* image_str = &image_category->front();
- const unit_map::const_iterator un = units_.find(route_.steps.front());
- if(un != units_.end()) {
- const int move_cost =
un->second.movement_cost(map_,map_.get_terrain(loc)) - 1;
- if(move_cost >= int(image_category->size())) {
- image_str = &image_category->back();
- } else if(move_cost > 0) {
- image_str = &(*image_category)[move_cost];
- }
- }
+ }
+
+ if(image_category == NULL || image_category->empty()) {
+ return;
+ }
+
+ const std::string* image_str = &image_category->front();
+ const unit_map::const_iterator un = units_.find(route_.steps.front());
+ if(un != units_.end()) {
+ const int move_cost =
un->second.movement_cost(map_,map_.get_terrain(loc)) - 1;
+ if(move_cost >= int(image_category->size())) {
+ image_str = &image_category->back();
+ } else if(move_cost > 0) {
+ image_str = &(*image_category)[move_cost];
+ }
+ }
surface image(image::get_image(*image_str));
if(image == NULL) {
@@ -1697,29 +1697,29 @@
image.assign(image::reverse_image(image));
}
- draw_unit(xloc,yloc,image,vflip,ftofxp(0.5));
-
- if(show_time == false) {
- return;
- }
-
- std::stringstream text;
-
-#ifndef USE_TINY_GUI
- if(un != units_.end() && zoom_ >= DefaultZoom) {
- text <<
(100-un->second.defense_modifier(map_,map_.get_terrain(loc))) << "%";
- }
+ draw_unit(xloc,yloc,image,vflip,ftofxp(0.5));
+
+ if(show_time == false) {
+ return;
+ }
+
+ std::stringstream text;
+
+#ifndef USE_TINY_GUI
+ if(un != units_.end() && zoom_ >= DefaultZoom) {
+ text <<
(100-un->second.defense_modifier(map_,map_.get_terrain(loc))) << "%";
+ }
#endif
- if(route_.move_left > 0 && route_.move_left < 10) {
+ if(route_.move_left > 0 && route_.move_left < 10) {
+
+ text << " (" << char('1' + route_.move_left) << ")";
+ }
- text << " (" << char('1' + route_.move_left) << ")";
- }
-
- const std::string& str = text.str();
-
- if(str.empty() == false) {
- const SDL_Rect& rect = map_area();
+ const std::string& str = text.str();
+
+ if(str.empty() == false) {
+ const SDL_Rect& rect = map_area();
const SDL_Rect& text_area =
font::text_area(str,font::SIZE_PLUS);
const int x = xloc + zoom_/2 - text_area.w/2;
Index: wesnoth/src/font.cpp
diff -u wesnoth/src/font.cpp:1.141 wesnoth/src/font.cpp:1.142
--- wesnoth/src/font.cpp:1.141 Sat May 14 19:18:31 2005
+++ wesnoth/src/font.cpp Mon May 16 22:44:19 2005
@@ -1,4 +1,4 @@
-/* $Id: font.cpp,v 1.141 2005/05/14 19:18:31 Sirp Exp $ */
+/* $Id: font.cpp,v 1.142 2005/05/16 22:44:19 ydirson Exp $ */
/* vim:set encoding=utf-8: */
/*
Copyright (C) 2003 by David White <address@hidden>
@@ -93,13 +93,13 @@
ucs2_string ucs2_text;
};
-std::vector<subset_id> font_map;
-
-//cache sizes of small text
-typedef std::map<std::string,SDL_Rect> line_size_cache_map;
-
-//map of styles -> sizes -> cache
-std::map<int,std::map<int,line_size_cache_map> > line_size_cache;
+std::vector<subset_id> font_map;
+
+//cache sizes of small text
+typedef std::map<std::string,SDL_Rect> line_size_cache_map;
+
+//map of styles -> sizes -> cache
+std::map<int,std::map<int,line_size_cache_map> > line_size_cache;
//Splits the UTF-8 text into text_chunks using the same font.
std::vector<text_chunk> split_text(std::string const & utf8_text) {
@@ -219,7 +219,7 @@
font_table.clear();
font_names.clear();
- font_map.clear();
+ font_map.clear();
line_size_cache.clear();
}
@@ -497,8 +497,8 @@
hit_ = 0;
}
return cache_.front();
-}
-
+}
+
}
surface render_text(const std::string& text, int fontsize, const SDL_Color&
colour, int style)
@@ -555,8 +555,8 @@
return res;
}
}
-
-namespace {
+
+namespace {
//function which will parse the markup tags at the front of a string
std::string::const_iterator parse_markup(std::string::const_iterator i1,
std::string::const_iterator i2,
@@ -823,23 +823,23 @@
if(font == NULL)
return 0;
return TTF_FontHeight(font);
-}
+}
bool is_format_char(char c)
-{
- //side coloring
- if(c > 0 && c <= 10) {
- return true;
- }
+{
+ //side coloring
+ if(c > 0 && c <= 10) {
+ return true;
+ }
- switch(c) {
- case LARGE_TEXT:
+ switch(c) {
+ case LARGE_TEXT:
case SMALL_TEXT:
case GOOD_TEXT:
- case BAD_TEXT:
- case NORMAL_TEXT:
- case BLACK_TEXT:
- case BOLD_TEXT:
+ case BAD_TEXT:
+ case NORMAL_TEXT:
+ case BLACK_TEXT:
+ case BOLD_TEXT:
case NULL_MARKUP:
return true;
default:
@@ -858,21 +858,21 @@
}
int line_width(const std::string& line, int font_size, int style)
-{
+{
return line_size(line,font_size,style).w;
}
SDL_Rect line_size(const std::string& line, int font_size, int style)
-{
- const size_t max_cache_size = 12;
- line_size_cache_map& cache = line_size_cache[style][font_size];
-
- if(line.size() < max_cache_size) {
- const line_size_cache_map::const_iterator i = cache.find(line);
- if(i != cache.end()) {
- return i->second;
- }
- }
+{
+ const size_t max_cache_size = 12;
+ line_size_cache_map& cache = line_size_cache[style][font_size];
+
+ if(line.size() < max_cache_size) {
+ const line_size_cache_map::const_iterator i = cache.find(line);
+ if(i != cache.end()) {
+ return i->second;
+ }
+ }
SDL_Rect res;
@@ -880,10 +880,10 @@
text_surface s(line, font_size, col, style);
res.w = s.width();
- res.h = s.height();
-
- if(line.size() < max_cache_size) {
- cache.insert(std::pair<std::string,SDL_Rect>(line,res));
+ res.h = s.height();
+
+ if(line.size() < max_cache_size) {
+ cache.insert(std::pair<std::string,SDL_Rect>(line,res));
}
return res;
@@ -975,12 +975,12 @@
}
std::string word_wrap_text(const std::string& unwrapped_text, int font_size,
int max_width, int max_height, int max_lines)
-{
- assert(max_width > 0);
-
+{
+ assert(max_width > 0);
+
utils::utf8_iterator ch(unwrapped_text);
std::string current_word;
- std::string current_line;
+ std::string current_line;
size_t line_width = 0;
size_t current_height = 0;
bool line_break = false;
@@ -991,7 +991,7 @@
utils::utf8_iterator end = utils::utf8_iterator::end(unwrapped_text);
while(1) {
- if(start_of_line) {
+ if(start_of_line) {
line_width = 0;
format_string = "";
while(ch != end && *ch < 0x100U && is_format_char(*ch))
{
@@ -1029,17 +1029,17 @@
previous = *ch;
}
}
- }
+ }
if(current_word == "\n") {
line_break = true;
current_word = "";
start_of_line = true;
- } else {
-
- const std::string word = format_string + current_word;
-
- const size_t word_width = line_size(word,font_size).w;
+ } else {
+
+ const std::string word = format_string + current_word;
+
+ const size_t word_width = line_size(word,font_size).w;
line_width += word_width;
@@ -1059,22 +1059,22 @@
if(line_break || current_word.empty() && ch == end) {
SDL_Rect size = line_size(current_line, font_size);
if(max_height > 0 && current_height + size.h >=
size_t(max_height)) {
- return wrapped_text;
+ return wrapped_text;
}
if(!first) {
- wrapped_text += '\n';
- }
+ wrapped_text += '\n';
+ }
wrapped_text += current_line;
- current_line = format_string;
+ current_line = format_string;
line_width = 0;
current_height += size.h;
line_break = false;
- first = false;
-
- if(--max_lines == 0) {
- return wrapped_text;
+ first = false;
+
+ if(--max_lines == 0) {
+ return wrapped_text;
}
}
}
Index: wesnoth/src/game.cpp
diff -u wesnoth/src/game.cpp:1.245 wesnoth/src/game.cpp:1.246
--- wesnoth/src/game.cpp:1.245 Wed May 11 12:27:59 2005
+++ wesnoth/src/game.cpp Mon May 16 22:44:19 2005
@@ -1,4 +1,4 @@
-/* $Id: game.cpp,v 1.245 2005/05/11 12:27:59 Sirp Exp $ */
+/* $Id: game.cpp,v 1.246 2005/05/16 22:44:19 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -100,8 +100,8 @@
bool new_campaign();
bool play_multiplayer();
- bool change_language();
-
+ bool change_language();
+
void show_preferences();
enum RELOAD_GAME_DATA { RELOAD_DATA, NO_RELOAD_DATA };
@@ -874,19 +874,19 @@
return;
}
- std::vector<std::string> campaigns, options;
-
- std::string sep(1, COLUMN_SEPARATOR);
-
- std::stringstream heading;
- heading << HEADING_PREFIX << sep << _("Name") << sep <<
_("Version") << sep
- << _("Author") << sep << _("Downloads") << sep
<< _("Size");
-
+ std::vector<std::string> campaigns, options;
+
+ std::string sep(1, COLUMN_SEPARATOR);
+
+ std::stringstream heading;
+ heading << HEADING_PREFIX << sep << _("Name") << sep <<
_("Version") << sep
+ << _("Author") << sep << _("Downloads") << sep
<< _("Size");
+
const config::child_list& cmps =
campaigns_cfg->get_children("campaign");
const std::vector<std::string>& publish_options =
available_campaigns();
- std::vector<std::string> delete_options;
-
+ std::vector<std::string> delete_options;
+
std::vector<int> sizes;
for(config::child_list::const_iterator i = cmps.begin(); i !=
cmps.end(); ++i) {
@@ -916,9 +916,9 @@
if(author.size() > 16) {
author.resize(16);
- }
-
- //add negative sizes to reverse the sort order
+ }
+
+ //add negative sizes to reverse the sort order
sizes.push_back(-atoi((**i)["size"].c_str()));
options.push_back(IMAGE_PREFIX + (**i)["icon"].str() +
COLUMN_SEPARATOR +
@@ -928,8 +928,8 @@
(**i)["downloads"].str() +
COLUMN_SEPARATOR +
format_file_size((**i)["size"]));
}
-
- options.push_back(heading.str());
+
+ options.push_back(heading.str());
for(std::vector<std::string>::const_iterator j =
publish_options.begin(); j != publish_options.end(); ++j) {
options.push_back(sep + _("Publish campaign: ") + *j);
@@ -942,12 +942,12 @@
if(campaigns.empty() && publish_options.empty()) {
gui::show_error_message(disp(), _("There are no
campaigns available for download from this server."));
return;
- }
-
- gui::menu::basic_sorter sorter;
-
sorter.set_alpha_sort(1).set_alpha_sort(2).set_alpha_sort(3).set_numeric_sort(4).set_position_sort(5,sizes);
+ }
- const int index = gui::show_dialog(disp(),NULL,_("Get
Campaign"),_("Choose the campaign to download."),gui::OK_CANCEL,&options,
+ gui::menu::basic_sorter sorter;
+
sorter.set_alpha_sort(1).set_alpha_sort(2).set_alpha_sort(3).set_numeric_sort(4).set_position_sort(5,sizes);
+
+ const int index = gui::show_dialog(disp(),NULL,_("Get
Campaign"),_("Choose the campaign to download."),gui::OK_CANCEL,&options,
NULL,"",NULL,0,NULL,NULL,-1,-1,NULL,NULL,"",&sorter);
if(index < 0) {
return;
@@ -1199,14 +1199,14 @@
hotkey::load_descriptions();
return false;
-}
-
-void game_controller::show_preferences()
-{
- const preferences::display_manager disp_manager(&disp());
- preferences::show_preferences_dialog(disp(),game_config_);
-
- disp().redraw_everything();
+}
+
+void game_controller::show_preferences()
+{
+ const preferences::display_manager disp_manager(&disp());
+ preferences::show_preferences_dialog(disp(),game_config_);
+
+ disp().redraw_everything();
}
//this function reads the game configuration, searching for valid cached
copies first
@@ -1600,7 +1600,7 @@
if(game.change_language() == false) {
continue;
}
- } else if(res == gui::EDIT_PREFERENCES) {
+ } else if(res == gui::EDIT_PREFERENCES) {
game.show_preferences();
continue;
} else if(res == gui::SHOW_ABOUT) {
Index: wesnoth/src/game_config.cpp
diff -u wesnoth/src/game_config.cpp:1.97 wesnoth/src/game_config.cpp:1.98
--- wesnoth/src/game_config.cpp:1.97 Tue May 10 22:37:36 2005
+++ wesnoth/src/game_config.cpp Mon May 16 22:44:19 2005
@@ -1,4 +1,4 @@
-/* $Id: game_config.cpp,v 1.97 2005/05/10 22:37:36 Sirp Exp $ */
+/* $Id: game_config.cpp,v 1.98 2005/05/16 22:44:19 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -10,12 +10,12 @@
See the COPYING file for more details.
*/
-
-#include "global.hpp"
+
+#include "global.hpp"
#include "config.hpp"
#include "game_config.hpp"
-#include "wesconfig.h"
+#include "wesconfig.h"
#include "serialization/string_utils.hpp"
#include <cstdlib>
Index: wesnoth/src/game_config.hpp
diff -u wesnoth/src/game_config.hpp:1.28 wesnoth/src/game_config.hpp:1.29
--- wesnoth/src/game_config.hpp:1.28 Fri May 6 01:07:59 2005
+++ wesnoth/src/game_config.hpp Mon May 16 22:44:19 2005
@@ -1,4 +1,4 @@
-/* $Id: game_config.hpp,v 1.28 2005/05/06 01:07:59 Sirp Exp $ */
+/* $Id: game_config.hpp,v 1.29 2005/05/16 22:44:19 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -15,7 +15,7 @@
class config;
-#include <string>
+#include <string>
#include <vector>
//basic game configuration information is here.
@@ -42,8 +42,8 @@
enemy_energy_image,ally_energy_image,flag_image,
dot_image,cross_image,
missile_n_image,missile_ne_image,terrain_mask_image,observer_image,download_campaign_image,
-
checked_menu_image,unchecked_menu_image;
-
+
checked_menu_image,unchecked_menu_image;
+
extern std::vector<std::string>
foot_left_nw,foot_left_n,foot_right_nw,foot_right_n;
extern int title_logo_x, title_logo_y, title_buttons_x,
title_buttons_y, title_buttons_padding, title_tip_x, title_tip_y,
title_tip_width, title_tip_padding;
Index: wesnoth/src/help.cpp
diff -u wesnoth/src/help.cpp:1.98 wesnoth/src/help.cpp:1.99
--- wesnoth/src/help.cpp:1.98 Sat May 14 20:13:21 2005
+++ wesnoth/src/help.cpp Mon May 16 22:44:19 2005
@@ -1907,10 +1907,10 @@
surface surf(font::get_rendered_text(first_part, font_size,
color, state));
if (!surf.null())
add_item(item(surf, curr_loc_.first, curr_loc_.second,
first_part, ref_dst));
- if (parts.size() > 1) {
-
+ if (parts.size() > 1) {
+
std::string& s = parts.back();
-
+
const std::string first_word_before = get_first_word(s);
const std::string first_word_after =
get_first_word(remove_first_space(s));
if (get_remaining_width() >=
font::line_width(first_word_after, font_size, state)
@@ -2334,7 +2334,7 @@
}
void help_browser::show_topic(const topic &t, bool save_in_history)
-{
+{
log_scope("show_topic");
if (save_in_history) {
forward_topics_.clear();
@@ -2504,12 +2504,12 @@
std::vector<std::string> split_in_width(const std::string &s, const int
font_size,
const unsigned width)
-{
+{
std::vector<std::string> res;
- const std::string& first_line = font::word_wrap_text(s, font_size,
width, -1, 1);
- res.push_back(first_line);
- if(s.size() > first_line.size()) {
- res.push_back(s.substr(first_line.size()));
+ const std::string& first_line = font::word_wrap_text(s, font_size,
width, -1, 1);
+ res.push_back(first_line);
+ if(s.size() > first_line.size()) {
+ res.push_back(s.substr(first_line.size()));
}
return res;
Index: wesnoth/src/intro.cpp
diff -u wesnoth/src/intro.cpp:1.77 wesnoth/src/intro.cpp:1.78
--- wesnoth/src/intro.cpp:1.77 Tue May 10 22:15:57 2005
+++ wesnoth/src/intro.cpp Mon May 16 22:44:19 2005
@@ -1,4 +1,4 @@
-/* $Id: intro.cpp,v 1.77 2005/05/10 22:15:57 Sirp Exp $ */
+/* $Id: intro.cpp,v 1.78 2005/05/16 22:44:19 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -234,13 +234,13 @@
//to find out if the next word will fit, or if
it has to be wrapped
utils::utf8_iterator start_word = itor;
++start_word;
- utils::utf8_iterator end_word = start_word;
- const utils::utf8_iterator end_story =
utils::utf8_iterator::end(story);
- for(; end_word != end_story; ++end_word) {
- if(*end_word == ' ') {
- break;
- }
- }
+ utils::utf8_iterator end_word = start_word;
+ const utils::utf8_iterator end_story =
utils::utf8_iterator::end(story);
+ for(; end_word != end_story; ++end_word) {
+ if(*end_word == ' ') {
+ break;
+ }
+ }
std::string word;
for(; start_word != end_word; ++start_word) {
Index: wesnoth/src/language.cpp
diff -u wesnoth/src/language.cpp:1.88 wesnoth/src/language.cpp:1.89
--- wesnoth/src/language.cpp:1.88 Sat May 14 14:26:12 2005
+++ wesnoth/src/language.cpp Mon May 16 22:44:19 2005
@@ -1,4 +1,4 @@
-/* $Id: language.cpp,v 1.88 2005/05/14 14:26:12 ettin Exp $ */
+/* $Id: language.cpp,v 1.89 2005/05/16 22:44:19 ydirson Exp $ */
/* vim:set encoding=utf-8: */
/*
Copyright (C) 2003 by David White <address@hidden>
@@ -245,12 +245,12 @@
if(path.empty()) {
t_string::add_textdomain(name, get_intl_dir());
} else {
- const std::string& location =
get_binary_file_location(path, ".");
-
- //if location is empty, this causes a crash on Windows,
so we
- //disallow adding empty domains
+ const std::string& location =
get_binary_file_location(path, ".");
+
+ //if location is empty, this causes a crash on Windows,
so we
+ //disallow adding empty domains
if(location.empty() == false) {
- t_string::add_textdomain(name, location);
+ t_string::add_textdomain(name, location);
}
}
}
Index: wesnoth/src/multiplayer_lobby.cpp
diff -u wesnoth/src/multiplayer_lobby.cpp:1.72
wesnoth/src/multiplayer_lobby.cpp:1.73
--- wesnoth/src/multiplayer_lobby.cpp:1.72 Tue May 10 22:15:57 2005
+++ wesnoth/src/multiplayer_lobby.cpp Mon May 16 22:44:19 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_lobby.cpp,v 1.72 2005/05/10 22:15:57 Sirp Exp $ */
+/* $Id: multiplayer_lobby.cpp,v 1.73 2005/05/16 22:44:19 ydirson Exp $ */
/*
Copyright (C)
Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -19,86 +19,86 @@
#include "wml_separators.hpp"
#include "game_config.hpp"
#include "gettext.hpp"
-
-namespace {
-
-std::string games_menu_heading()
-{
- std::ostringstream str;
- str << HEADING_PREFIX << _("Map") << COLUMN_SEPARATOR << _("Name")
- << COLUMN_SEPARATOR << _("Status");
- return str.str();
-}
-
-}
+
+namespace {
+
+std::string games_menu_heading()
+{
+ std::ostringstream str;
+ str << HEADING_PREFIX << _("Map") << COLUMN_SEPARATOR << _("Name")
+ << COLUMN_SEPARATOR << _("Status");
+ return str.str();
+}
+
+}
namespace mp {
-
-lobby::lobby_sorter::lobby_sorter(const config& cfg) : cfg_(cfg)
-{
- set_alpha_sort(1);
-}
-
-bool lobby::lobby_sorter::column_sortable(int column) const
-{
- switch(column)
- {
- case MAP_COLUMN:
- case STATUS_COLUMN:
- return true;
- default:
- return basic_sorter::column_sortable(column);
- }
-}
-
-bool lobby::lobby_sorter::less(int column, const gui::menu::item& row1, const
gui::menu::item& row2) const
-{
- const config* const list = cfg_.child("gamelist");
- if(list == NULL) {
- return false;
- }
-
- const config::child_list& games = list->get_children("game");
- if(row1.id >= games.size() || row2.id >= games.size()) {
- return false;
- }
-
- const config& game1 = *games[row1.id];
- const config& game2 = *games[row2.id];
-
- if(column == MAP_COLUMN) {
- size_t mapsize1 = game1["map_data"].size();
- if(mapsize1 == 0) {
- mapsize1 = game1["map"].size();
- }
-
- size_t mapsize2 = game2["map_data"].size();
- if(mapsize2 == 0) {
- mapsize2 = game2["map"].size();
- }
-
- return mapsize1 < mapsize2;
-
- } else if(column == STATUS_COLUMN) {
- const int nslots1 = atoi(game1["slots"].c_str());
- const int nslots2 = atoi(game2["slots"].c_str());
-
- const int turn1 = atoi(game1["turn"].c_str());
- const int turn2 = atoi(game2["turn"].c_str());
-
- if(nslots1 > nslots2) {
- return true;
- } else if(nslots1 < nslots2) {
- return false;
- } else {
- return turn1 < turn2;
- }
- } else {
- return basic_sorter::less(column,row1,row2);
- }
-
- return false;
-}
+
+lobby::lobby_sorter::lobby_sorter(const config& cfg) : cfg_(cfg)
+{
+ set_alpha_sort(1);
+}
+
+bool lobby::lobby_sorter::column_sortable(int column) const
+{
+ switch(column)
+ {
+ case MAP_COLUMN:
+ case STATUS_COLUMN:
+ return true;
+ default:
+ return basic_sorter::column_sortable(column);
+ }
+}
+
+bool lobby::lobby_sorter::less(int column, const gui::menu::item& row1, const
gui::menu::item& row2) const
+{
+ const config* const list = cfg_.child("gamelist");
+ if(list == NULL) {
+ return false;
+ }
+
+ const config::child_list& games = list->get_children("game");
+ if(row1.id >= games.size() || row2.id >= games.size()) {
+ return false;
+ }
+
+ const config& game1 = *games[row1.id];
+ const config& game2 = *games[row2.id];
+
+ if(column == MAP_COLUMN) {
+ size_t mapsize1 = game1["map_data"].size();
+ if(mapsize1 == 0) {
+ mapsize1 = game1["map"].size();
+ }
+
+ size_t mapsize2 = game2["map_data"].size();
+ if(mapsize2 == 0) {
+ mapsize2 = game2["map"].size();
+ }
+
+ return mapsize1 < mapsize2;
+
+ } else if(column == STATUS_COLUMN) {
+ const int nslots1 = atoi(game1["slots"].c_str());
+ const int nslots2 = atoi(game2["slots"].c_str());
+
+ const int turn1 = atoi(game1["turn"].c_str());
+ const int turn2 = atoi(game2["turn"].c_str());
+
+ if(nslots1 > nslots2) {
+ return true;
+ } else if(nslots1 < nslots2) {
+ return false;
+ } else {
+ return turn1 < turn2;
+ }
+ } else {
+ return basic_sorter::less(column,row1,row2);
+ }
+
+ return false;
+}
lobby::lobby(display& disp, const config& cfg, chat& c, config& gamelist) :
mp::ui(disp, cfg, c, gamelist),
@@ -106,7 +106,7 @@
observe_game_(disp.video(), _("Observe Game")),
join_game_(disp.video(), _("Join Game")),
create_game_(disp.video(), _("Create Game")),
- quit_game_(disp.video(), _("Quit")),
+ quit_game_(disp.video(), _("Quit")),
sorter_(gamelist),
games_menu_(disp.video(),
std::vector<std::string>(1,games_menu_heading()),false,-1,-1,&sorter_),
current_game_(0)
@@ -206,7 +206,7 @@
if(game_strings.empty()) {
game_strings.push_back(_("<no games open>"));
}
-
+
//set the items, retaining the menu positioning if possible
games_menu_.set_items(game_strings,true,true);
Index: wesnoth/src/multiplayer_lobby.hpp
diff -u wesnoth/src/multiplayer_lobby.hpp:1.11
wesnoth/src/multiplayer_lobby.hpp:1.12
--- wesnoth/src/multiplayer_lobby.hpp:1.11 Tue May 10 22:15:57 2005
+++ wesnoth/src/multiplayer_lobby.hpp Mon May 16 22:44:19 2005
@@ -1,4 +1,4 @@
-/* $Id: multiplayer_lobby.hpp,v 1.11 2005/05/10 22:15:57 Sirp Exp $ */
+/* $Id: multiplayer_lobby.hpp,v 1.12 2005/05/16 22:44:19 ydirson Exp $ */
/*
Copyright (C)
Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -38,18 +38,18 @@
virtual void gamelist_updated(bool silent=true);
private:
-
- class lobby_sorter : public gui::menu::basic_sorter
- {
- const config& cfg_;
-
- bool column_sortable(int column) const;
- bool less(int column, const gui::menu::item& row1, const
gui::menu::item& row2) const;
-
- enum { MAP_COLUMN = 0, STATUS_COLUMN = 2};
- public:
- lobby_sorter(const config& cfg);
- };
+
+ class lobby_sorter : public gui::menu::basic_sorter
+ {
+ const config& cfg_;
+
+ bool column_sortable(int column) const;
+ bool less(int column, const gui::menu::item& row1, const
gui::menu::item& row2) const;
+
+ enum { MAP_COLUMN = 0, STATUS_COLUMN = 2};
+ public:
+ lobby_sorter(const config& cfg);
+ };
std::vector<bool> game_vacant_slots_;
std::vector<bool> game_observers_;
@@ -58,7 +58,7 @@
gui::button join_game_;
gui::button create_game_;
gui::button quit_game_;
-
+
lobby_sorter sorter_;
gui::menu games_menu_;
int current_game_;
Index: wesnoth/src/playcampaign.cpp
diff -u wesnoth/src/playcampaign.cpp:1.2 wesnoth/src/playcampaign.cpp:1.3
--- wesnoth/src/playcampaign.cpp:1.2 Tue May 10 22:15:57 2005
+++ wesnoth/src/playcampaign.cpp Mon May 16 22:44:19 2005
@@ -1,4 +1,4 @@
-/* $Id: playcampaign.cpp,v 1.2 2005/05/10 22:15:57 Sirp Exp $ */
+/* $Id: playcampaign.cpp,v 1.3 2005/05/16 22:44:19 ydirson Exp $ */
/*
Copyright (C) 2003-2005 by David White <address@hidden>
Copyright (C) 2005 by Philippe Plantier <address@hidden>
@@ -10,8 +10,8 @@
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
-*/
-
+*/
+
#include "global.hpp"
#include <map>
Index: wesnoth/src/playturn.cpp
diff -u wesnoth/src/playturn.cpp:1.369 wesnoth/src/playturn.cpp:1.370
--- wesnoth/src/playturn.cpp:1.369 Fri May 13 07:41:07 2005
+++ wesnoth/src/playturn.cpp Mon May 16 22:44:19 2005
@@ -1,4 +1,4 @@
-/* $Id: playturn.cpp,v 1.369 2005/05/13 07:41:07 silene Exp $ */
+/* $Id: playturn.cpp,v 1.370 2005/05/16 22:44:19 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1704,10 +1704,10 @@
<< _("Villages") << COLUMN_SEPARATOR
<< _("Units") << COLUMN_SEPARATOR
<< _("Upkeep") << COLUMN_SEPARATOR
- << _("Income");
-
- gui::menu::basic_sorter sorter;
-
sorter.set_redirect_sort(0,1).set_alpha_sort(1).set_numeric_sort(2).set_numeric_sort(3)
+ << _("Income");
+
+ gui::menu::basic_sorter sorter;
+
sorter.set_redirect_sort(0,1).set_alpha_sort(1).set_numeric_sort(2).set_numeric_sort(3)
.set_numeric_sort(4).set_numeric_sort(5).set_numeric_sort(6).set_numeric_sort(7);
if(game_config::debug)
@@ -1767,7 +1767,7 @@
items.push_back(IMAGE_PREFIX + std::string("random-enemy.png")
+ COLUMN_SEPARATOR +
IMAGE_PREFIX + "random-enemy.png");
- gui::show_dialog(gui_,NULL,"","",gui::CLOSE_ONLY,&items,
+ gui::show_dialog(gui_,NULL,"","",gui::CLOSE_ONLY,&items,
NULL,"",NULL,0,NULL,NULL,-1,-1,NULL,NULL,"",&sorter);
}
@@ -1973,18 +1973,18 @@
msg << vgettext("You must have at least $cost gold pieces to
recall a unit", i18n_symbols);
gui::show_dialog(gui_,NULL,"",msg.str());
} else {
- std::vector<std::string> options;
-
- std::ostringstream heading;
- heading << HEADING_PREFIX << COLUMN_SEPARATOR << _("Type")
- << COLUMN_SEPARATOR << _("Name")
- << COLUMN_SEPARATOR << _("Level")
- << COLUMN_SEPARATOR << _("XP");
-
- gui::menu::basic_sorter sorter;
-
sorter.set_alpha_sort(1).set_alpha_sort(2).set_id_sort(3).set_numeric_sort(4);
-
- options.push_back(heading.str());
+ std::vector<std::string> options;
+
+ std::ostringstream heading;
+ heading << HEADING_PREFIX << COLUMN_SEPARATOR << _("Type")
+ << COLUMN_SEPARATOR << _("Name")
+ << COLUMN_SEPARATOR << _("Level")
+ << COLUMN_SEPARATOR << _("XP");
+
+ gui::menu::basic_sorter sorter;
+
sorter.set_alpha_sort(1).set_alpha_sort(2).set_id_sort(3).set_numeric_sort(4);
+
+ options.push_back(heading.str());
for(std::vector<unit>::const_iterator u = recall_list.begin();
u != recall_list.end(); ++u) {
std::stringstream option;
@@ -2152,17 +2152,17 @@
void turn_info::unit_list()
{
- const std::string heading = std::string(1,HEADING_PREFIX) +
+ const std::string heading = std::string(1,HEADING_PREFIX) +
_("Type") + COLUMN_SEPARATOR +
_("Name") + COLUMN_SEPARATOR +
_("HP") + COLUMN_SEPARATOR +
_("XP") + COLUMN_SEPARATOR +
_("Traits") + COLUMN_SEPARATOR +
_("Moves") + COLUMN_SEPARATOR +
- _("Location");
-
- gui::menu::basic_sorter sorter;
-
sorter.set_alpha_sort(0).set_alpha_sort(1).set_numeric_sort(2).set_numeric_sort(3)
+ _("Location");
+
+ gui::menu::basic_sorter sorter;
+
sorter.set_alpha_sort(0).set_alpha_sort(1).set_numeric_sort(2).set_numeric_sort(3)
.set_alpha_sort(4).set_numeric_sort(5).set_numeric_sort(6);
std::vector<std::string> items;
@@ -2212,7 +2212,7 @@
preview_panes.push_back(&unit_preview);
selected = gui::show_dialog(gui_,NULL,_("Unit List"),"",
- gui::OK_ONLY,&items,&preview_panes,
+ gui::OK_ONLY,&items,&preview_panes,
"",NULL,0,NULL,NULL,-1,-1,NULL,NULL,"",&sorter);
}
Index: wesnoth/src/preferences.cpp
diff -u wesnoth/src/preferences.cpp:1.157 wesnoth/src/preferences.cpp:1.158
--- wesnoth/src/preferences.cpp:1.157 Sun May 15 20:59:43 2005
+++ wesnoth/src/preferences.cpp Mon May 16 22:44:19 2005
@@ -1,4 +1,4 @@
-/* $Id: preferences.cpp,v 1.157 2005/05/15 20:59:43 Sirp Exp $ */
+/* $Id: preferences.cpp,v 1.158 2005/05/16 22:44:19 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -817,8 +817,8 @@
void process_event();
bool left_side() const { return false; }
void set_selection(int index);
- void update_location(SDL_Rect const &rect);
- const config* get_advanced_pref() const;
+ void update_location(SDL_Rect const &rect);
+ const config* get_advanced_pref() const;
void set_advanced_menu();
gui::slider music_slider_, sound_slider_, scroll_slider_, gamma_slider_;
@@ -829,13 +829,13 @@
flip_time_button_, advanced_button_;
gui::label music_label_, sound_label_, scroll_label_, gamma_label_;
unsigned slider_label_width_;
-
- gui::menu advanced_;
- int advanced_selection_;
+
+ gui::menu advanced_;
+ int advanced_selection_;
enum TAB { GENERAL_TAB, DISPLAY_TAB, SOUND_TAB, ADVANCED_TAB };
TAB tab_;
- display &disp_;
+ display &disp_;
const config& game_cfg_;
};
@@ -856,11 +856,11 @@
video_mode_button_(disp.video(), _("Video Mode")),
hotkeys_button_(disp.video(), _("Hotkeys")),
gamma_button_(disp.video(), _("Adjust Gamma"),
gui::button::TYPE_CHECK),
- flip_time_button_(disp.video(), _("Reverse Time Graphics"),
gui::button::TYPE_CHECK),
+ flip_time_button_(disp.video(), _("Reverse Time Graphics"),
gui::button::TYPE_CHECK),
advanced_button_(disp.video(), "", gui::button::TYPE_CHECK),
music_label_(disp.video(), _("Music Volume:")),
sound_label_(disp.video(), _("SFX Volume:")),
scroll_label_(disp.video(), _("Scroll Speed:")),
gamma_label_(disp.video(), _("Gamma:")),
- slider_label_width_(0),
advanced_(disp.video(),std::vector<std::string>()), advanced_selection_(-1),
+ slider_label_width_(0),
advanced_(disp.video(),std::vector<std::string>()), advanced_selection_(-1),
tab_(GENERAL_TAB), disp_(disp), game_cfg_(game_cfg)
{
// FIXME: this box should be vertically centered on the screen, but is
not
@@ -933,9 +933,9 @@
show_haloing_button_.set_check(show_haloes());
show_haloing_button_.set_help_string(_("Use graphical special effects
(may be slower)"));
- hotkeys_button_.set_help_string(_("View and configure keyboard
shortcuts"));
-
- set_advanced_menu();
+ hotkeys_button_.set_help_string(_("View and configure keyboard
shortcuts"));
+
+ set_advanced_menu();
}
void preferences_dialog::update_location(SDL_Rect const &rect)
@@ -988,15 +988,15 @@
sound_label_.set_location(rect.x, ypos);
SDL_Rect sound_rect = { rect.x + slider_label_width_, ypos,
rect.w - slider_label_width_ - border, 0 };
- sound_slider_.set_location(sound_rect);
-
- //Advanced tab
- ypos = rect.y;
- advanced_.set_location(rect.x,ypos);
- advanced_.set_max_height(height()-100);
-
- ypos += advanced_.height() + border;
-
+ sound_slider_.set_location(sound_rect);
+
+ //Advanced tab
+ ypos = rect.y;
+ advanced_.set_location(rect.x,ypos);
+ advanced_.set_max_height(height()-100);
+
+ ypos += advanced_.height() + border;
+
advanced_button_.set_location(rect.x,ypos);
set_selection(tab_);
@@ -1041,66 +1041,66 @@
set_sound_volume(sound_slider_.value());
set_music_volume(music_slider_.value());
set_scroll_speed(scroll_slider_.value());
- set_gamma(gamma_slider_.value());
-
- if(advanced_.selection() != advanced_selection_) {
- advanced_selection_ = advanced_.selection();
- const config* const adv = get_advanced_pref();
- if(adv != NULL) {
- const config& pref = *adv;
- advanced_button_.set_label(pref["name"]);
- std::string value = prefs[pref["field"]];
- if(value.empty()) {
- value = pref["default"];
- }
-
- advanced_button_.set_check(value == "yes");
- }
- }
-
- if(advanced_button_.pressed()) {
- const config* const adv = get_advanced_pref();
- if(adv != NULL) {
- const config& pref = *adv;
- prefs[pref["field"]] = advanced_button_.checked() ?
"yes" : "no";
- set_advanced_menu();
- }
- }
-}
-
-const config* preferences_dialog::get_advanced_pref() const
-{
- const config::child_list& adv =
game_cfg_.get_children("advanced_preference");
- if(advanced_selection_ >= 0 && advanced_selection_ < int(adv.size())) {
- return adv[advanced_selection_];
- } else {
- return NULL;
- }
-}
-
-void preferences_dialog::set_advanced_menu()
-{
- std::vector<std::string> advanced_items;
- const config::child_list& adv =
game_cfg_.get_children("advanced_preference");
- for(config::child_list::const_iterator i = adv.begin(); i != adv.end();
++i) {
- std::ostringstream str;
- std::string field = prefs[(**i)["field"]];
- if(field.empty()) {
- field = (**i)["default"];
- }
-
- if(field == "yes") {
- field = _("yes");
- } else if(field == "no") {
- field = _("no");
- }
-
- str << (**i)["name"] << COLUMN_SEPARATOR << field;
- advanced_items.push_back(str.str());
- }
-
- advanced_.set_items(advanced_items,true,true);
-}
+ set_gamma(gamma_slider_.value());
+
+ if(advanced_.selection() != advanced_selection_) {
+ advanced_selection_ = advanced_.selection();
+ const config* const adv = get_advanced_pref();
+ if(adv != NULL) {
+ const config& pref = *adv;
+ advanced_button_.set_label(pref["name"]);
+ std::string value = prefs[pref["field"]];
+ if(value.empty()) {
+ value = pref["default"];
+ }
+
+ advanced_button_.set_check(value == "yes");
+ }
+ }
+
+ if(advanced_button_.pressed()) {
+ const config* const adv = get_advanced_pref();
+ if(adv != NULL) {
+ const config& pref = *adv;
+ prefs[pref["field"]] = advanced_button_.checked() ?
"yes" : "no";
+ set_advanced_menu();
+ }
+ }
+}
+
+const config* preferences_dialog::get_advanced_pref() const
+{
+ const config::child_list& adv =
game_cfg_.get_children("advanced_preference");
+ if(advanced_selection_ >= 0 && advanced_selection_ < int(adv.size())) {
+ return adv[advanced_selection_];
+ } else {
+ return NULL;
+ }
+}
+
+void preferences_dialog::set_advanced_menu()
+{
+ std::vector<std::string> advanced_items;
+ const config::child_list& adv =
game_cfg_.get_children("advanced_preference");
+ for(config::child_list::const_iterator i = adv.begin(); i != adv.end();
++i) {
+ std::ostringstream str;
+ std::string field = prefs[(**i)["field"]];
+ if(field.empty()) {
+ field = (**i)["default"];
+ }
+
+ if(field == "yes") {
+ field = _("yes");
+ } else if(field == "no") {
+ field = _("no");
+ }
+
+ str << (**i)["name"] << COLUMN_SEPARATOR << field;
+ advanced_items.push_back(str.str());
+ }
+
+ advanced_.set_items(advanced_items,true,true);
+}
void preferences_dialog::set_selection(int index)
{
@@ -1134,10 +1134,10 @@
music_label_.hide(hide_sound);
music_slider_.hide(hide_sound);
sound_label_.hide(hide_sound);
- sound_slider_.hide(hide_sound);
-
- const bool hide_advanced = tab_ != ADVANCED_TAB;
- advanced_.hide(hide_advanced);
+ sound_slider_.hide(hide_sound);
+
+ const bool hide_advanced = tab_ != ADVANCED_TAB;
+ advanced_.hide(hide_advanced);
advanced_button_.hide(hide_advanced);
}
@@ -1151,7 +1151,7 @@
char const sep = COLUMN_SEPARATOR;
items.push_back(pre + "general.png" + sep +
dsgettext(GETTEXT_DOMAIN,"Prefs section^General"));
items.push_back(pre + "display.png" + sep +
dsgettext(GETTEXT_DOMAIN,"Prefs section^Display"));
- items.push_back(pre + "music.png" + sep +
dsgettext(GETTEXT_DOMAIN,"Prefs section^Sound"));
+ items.push_back(pre + "music.png" + sep +
dsgettext(GETTEXT_DOMAIN,"Prefs section^Sound"));
items.push_back(pre + "advanced.png" + sep +
dsgettext(GETTEXT_DOMAIN,"Advanced section^Advanced"));
for(;;) {
@@ -1290,16 +1290,16 @@
str << i->get_name();
menu_items.push_back(str.str());
}
-
- std::ostringstream heading;
- heading << HEADING_PREFIX << _("Action") << COLUMN_SEPARATOR <<
_("Binding");
- menu_items.push_back(heading.str());
-
- gui::menu::basic_sorter sorter;
- sorter.set_alpha_sort(0).set_alpha_sort(1);
- gui::menu menu_(disp.video(), menu_items, false, height, -1, &sorter);
- menu_.sort_by(0);
+ std::ostringstream heading;
+ heading << HEADING_PREFIX << _("Action") << COLUMN_SEPARATOR <<
_("Binding");
+ menu_items.push_back(heading.str());
+
+ gui::menu::basic_sorter sorter;
+ sorter.set_alpha_sort(0).set_alpha_sort(1);
+
+ gui::menu menu_(disp.video(), menu_items, false, height, -1, &sorter);
+ menu_.sort_by(0);
menu_.reset_selection();
menu_.set_width(font::relative_size(400));
menu_.set_location(xpos + font::relative_size(20), ypos);
Index: wesnoth/src/random.cpp
diff -u wesnoth/src/random.cpp:1.5 wesnoth/src/random.cpp:1.6
--- wesnoth/src/random.cpp:1.5 Tue May 10 22:15:57 2005
+++ wesnoth/src/random.cpp Mon May 16 22:44:20 2005
@@ -1,4 +1,4 @@
-/* $Id: random.cpp,v 1.5 2005/05/10 22:15:57 Sirp Exp $ */
+/* $Id: random.cpp,v 1.6 2005/05/16 22:44:20 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Copyright (C) 2005 by Yann Dirson <address@hidden>
@@ -10,11 +10,11 @@
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
-*/
-
-#include "global.hpp"
-
-#include <cstdio>
+*/
+
+#include "global.hpp"
+
+#include <cstdio>
#include "config.hpp"
#include "random.hpp"
Index: wesnoth/src/serialization/binary_or_text.cpp
diff -u wesnoth/src/serialization/binary_or_text.cpp:1.12
wesnoth/src/serialization/binary_or_text.cpp:1.13
--- wesnoth/src/serialization/binary_or_text.cpp:1.12 Tue May 10 22:15:57 2005
+++ wesnoth/src/serialization/binary_or_text.cpp Mon May 16 22:44:20 2005
@@ -1,4 +1,4 @@
-/* $Id: binary_or_text.cpp,v 1.12 2005/05/10 22:15:57 Sirp Exp $ */
+/* $Id: binary_or_text.cpp,v 1.13 2005/05/16 22:44:20 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -11,8 +11,8 @@
See the COPYING file for more details.
*/
-
-#include "global.hpp"
+
+#include "global.hpp"
#include "config.hpp"
#include "filesystem.hpp"
Index: wesnoth/src/show_dialog.cpp
diff -u wesnoth/src/show_dialog.cpp:1.128 wesnoth/src/show_dialog.cpp:1.129
--- wesnoth/src/show_dialog.cpp:1.128 Fri May 13 00:47:56 2005
+++ wesnoth/src/show_dialog.cpp Mon May 16 22:44:20 2005
@@ -1,4 +1,4 @@
-/* $Id: show_dialog.cpp,v 1.128 2005/05/13 00:47:56 Sirp Exp $ */
+/* $Id: show_dialog.cpp,v 1.129 2005/05/16 22:44:20 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -34,7 +34,7 @@
#include "util.hpp"
#include "video.hpp"
#include "widgets/button.hpp"
-#include "widgets/menu.hpp"
+#include "widgets/menu.hpp"
#include "widgets/progressbar.hpp"
#include "widgets/textbox.hpp"
#include "wassert.hpp"
@@ -834,54 +834,54 @@
namespace gui {
network::connection network_data_dialog(display& disp, const std::string& msg,
config& cfg, network::connection connection_num)
-{
- const std::string title = _("Downloading...");
-
- const size_t width = 300;
- const size_t height = 80;
- const size_t border = 20;
- const int left = disp.x()/2 - width/2;
- const int top = disp.y()/2 - height/2;
-
- gui::button cancel_button(disp.video(),_("Cancel"));
- std::vector<gui::button*> buttons_ptr(1,&cancel_button);
-
- surface_restorer restorer;
-
gui::draw_dialog(left,top,width,height,disp.video(),title,NULL,&buttons_ptr,&restorer);
-
- const SDL_Rect progress_rect =
{left+border,top+border,width-border*2,height-border*2};
- gui::progress_bar progress(disp.video());
- progress.set_location(progress_rect);
-
- events::raise_draw_event();
- disp.flip();
-
- std::pair<int,int> old_stats = network::current_transfer_stats();
+{
+ const std::string title = _("Downloading...");
+
+ const size_t width = 300;
+ const size_t height = 80;
+ const size_t border = 20;
+ const int left = disp.x()/2 - width/2;
+ const int top = disp.y()/2 - height/2;
+
+ gui::button cancel_button(disp.video(),_("Cancel"));
+ std::vector<gui::button*> buttons_ptr(1,&cancel_button);
+
+ surface_restorer restorer;
+
gui::draw_dialog(left,top,width,height,disp.video(),title,NULL,&buttons_ptr,&restorer);
+
+ const SDL_Rect progress_rect =
{left+border,top+border,width-border*2,height-border*2};
+ gui::progress_bar progress(disp.video());
+ progress.set_location(progress_rect);
+
+ events::raise_draw_event();
+ disp.flip();
+
+ std::pair<int,int> old_stats = network::current_transfer_stats();
cfg.clear();
- for(;;) {
- const network::connection res =
network::receive_data(cfg,connection_num,100);
-
- const std::pair<int,int> stats =
network::current_transfer_stats();
- if(stats.first != -1 && stats.second != 0 && stats !=
old_stats) {
- old_stats = stats;
-
progress.set_progress_percent((stats.first*100)/stats.second);
- std::ostringstream stream;
- stream << stats.first/1024 << "/" << stats.second/1024
<< _("KB");
- progress.set_text(stream.str());
- }
-
- events::raise_draw_event();
- disp.flip();
-
- if(res != 0) {
- return res;
- }
-
- events::pump();
- if(cancel_button.pressed()) {
- return res;
- }
+ for(;;) {
+ const network::connection res =
network::receive_data(cfg,connection_num,100);
+
+ const std::pair<int,int> stats =
network::current_transfer_stats();
+ if(stats.first != -1 && stats.second != 0 && stats !=
old_stats) {
+ old_stats = stats;
+
progress.set_progress_percent((stats.first*100)/stats.second);
+ std::ostringstream stream;
+ stream << stats.first/1024 << "/" << stats.second/1024
<< _("KB");
+ progress.set_text(stream.str());
+ }
+
+ events::raise_draw_event();
+ disp.flip();
+
+ if(res != 0) {
+ return res;
+ }
+
+ events::pump();
+ if(cancel_button.pressed()) {
+ return res;
+ }
}
}
Index: wesnoth/src/show_dialog.hpp
diff -u wesnoth/src/show_dialog.hpp:1.48 wesnoth/src/show_dialog.hpp:1.49
--- wesnoth/src/show_dialog.hpp:1.48 Tue May 10 22:15:57 2005
+++ wesnoth/src/show_dialog.hpp Mon May 16 22:44:20 2005
@@ -1,4 +1,4 @@
-/* $Id: show_dialog.hpp,v 1.48 2005/05/10 22:15:57 Sirp Exp $ */
+/* $Id: show_dialog.hpp,v 1.49 2005/05/16 22:44:20 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -23,7 +23,7 @@
#include "network.hpp"
#include "tooltips.hpp"
-#include "widgets/button.hpp"
+#include "widgets/button.hpp"
#include "widgets/menu.hpp"
#include "SDL.h"
@@ -134,7 +134,7 @@
std::vector<check_item>* options=NULL, int
xloc=-1, int yloc=-1,
const std::string* dialog_style=NULL,
std::vector<dialog_button>* buttons=NULL,
- const std::string& help_topic="",
+ const std::string& help_topic="",
const menu::sorter* sorter=NULL
);
Index: wesnoth/src/tstring.cpp
diff -u wesnoth/src/tstring.cpp:1.12 wesnoth/src/tstring.cpp:1.13
--- wesnoth/src/tstring.cpp:1.12 Sat May 14 19:33:37 2005
+++ wesnoth/src/tstring.cpp Mon May 16 22:44:20 2005
@@ -1,4 +1,4 @@
-/* $Id: tstring.cpp,v 1.12 2005/05/14 19:33:37 silene Exp $ */
+/* $Id: tstring.cpp,v 1.13 2005/05/16 22:44:20 ydirson Exp $ */
/*
Copyright (C) 2004 by Philippe Plantier <address@hidden>
Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -11,9 +11,9 @@
See the COPYING file for more details.
*/
-
-#include "global.hpp"
-
+
+#include "global.hpp"
+
#include <sstream>
#include <vector>
#include <map>
Index: wesnoth/src/tstring.hpp
diff -u wesnoth/src/tstring.hpp:1.8 wesnoth/src/tstring.hpp:1.9
--- wesnoth/src/tstring.hpp:1.8 Sat May 14 08:56:13 2005
+++ wesnoth/src/tstring.hpp Mon May 16 22:44:20 2005
@@ -1,4 +1,4 @@
-/* $Id: tstring.hpp,v 1.8 2005/05/14 08:56:13 silene Exp $ */
+/* $Id: tstring.hpp,v 1.9 2005/05/16 22:44:20 ydirson Exp $ */
/*
Copyright (C) 2004 by Philippe Plantier <address@hidden>
Part of the Battle for Wesnoth Project http://www.wesnoth.org
@@ -40,8 +40,8 @@
std::string::size_type end_;
std::string textdomain_;
bool translatable_;
- };
-
+ };
+
friend class walker;
t_string();
Index: wesnoth/src/util.hpp
diff -u wesnoth/src/util.hpp:1.23 wesnoth/src/util.hpp:1.24
--- wesnoth/src/util.hpp:1.23 Tue May 10 22:15:57 2005
+++ wesnoth/src/util.hpp Mon May 16 22:44:20 2005
@@ -1,4 +1,4 @@
-/* $Id: util.hpp,v 1.23 2005/05/10 22:15:57 Sirp Exp $ */
+/* $Id: util.hpp,v 1.24 2005/05/16 22:44:20 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -79,7 +79,7 @@
return lexical_cast<std::string,From>(a);
}
-inline bool chars_equal_insensitive(char a, char b) { return tolower(a) ==
tolower(b); }
+inline bool chars_equal_insensitive(char a, char b) { return tolower(a) ==
tolower(b); }
inline bool chars_less_insensitive(char a, char b) { return tolower(a) <
tolower(b); }
//a definition of 'push_back' for strings, since some implementations
Index: wesnoth/src/variable.cpp
diff -u wesnoth/src/variable.cpp:1.2 wesnoth/src/variable.cpp:1.3
--- wesnoth/src/variable.cpp:1.2 Tue May 10 22:15:57 2005
+++ wesnoth/src/variable.cpp Mon May 16 22:44:20 2005
@@ -1,4 +1,4 @@
-/* $Id: variable.cpp,v 1.2 2005/05/10 22:15:57 Sirp Exp $ */
+/* $Id: variable.cpp,v 1.3 2005/05/16 22:44:20 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Copyright (C) 2005 by Philippe Plantier <address@hidden>
@@ -11,8 +11,8 @@
but WITHOUT ANY WARRANTY.
See the COPYING file for more details.
-*/
-
+*/
+
#include "global.hpp"
#include "variable.hpp"
@@ -80,7 +80,7 @@
vconfig::child_list vconfig::get_children(const std::string& key) const
{
const config::child_list& list = cfg_->get_children(key);
- vconfig::child_list res(list.size());
+ vconfig::child_list res(list.size());
std::copy(list.begin(), list.end(),res.begin());
return res;
}
Index: wesnoth/src/widgets/button.cpp
diff -u wesnoth/src/widgets/button.cpp:1.64 wesnoth/src/widgets/button.cpp:1.65
--- wesnoth/src/widgets/button.cpp:1.64 Sat May 7 21:53:43 2005
+++ wesnoth/src/widgets/button.cpp Mon May 16 22:44:20 2005
@@ -1,4 +1,4 @@
-/* $Id: button.cpp,v 1.64 2005/05/07 21:53:43 ettin Exp $ */
+/* $Id: button.cpp,v 1.65 2005/05/16 22:44:20 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -33,7 +33,7 @@
std::string button_image_name, SPACE_CONSUMPTION spacing)
: widget(video), label_(label),
image_(NULL), pressedImage_(NULL), activeImage_(NULL),
pressedActiveImage_(NULL),
- button_(true), state_(NORMAL), type_(type), enabled_(true),
pressed_(false),
+ button_(true), state_(NORMAL), type_(type), enabled_(true),
pressed_(false),
spacing_(spacing), base_height_(0), base_width_(0)
{
set_label(label);
@@ -64,11 +64,11 @@
}
if (button_image.null())
- throw error();
-
- base_height_ = button_image->h;
+ throw error();
+
+ base_height_ = button_image->h;
base_width_ = button_image->w;
-
+
calculate_size();
if(type == TYPE_PRESS) {
@@ -82,33 +82,33 @@
if (type == TYPE_CHECK)
pressedActiveImage_.assign(scale_surface(pressed_active_image, button_image->w,
button_image->h));
}
-}
-
-void button::calculate_size()
-{
- textRect_ = screen_area();
-
- textRect_ = font::draw_text(NULL,textRect_,font_size,
- font::BUTTON_COLOUR,label_,0,0);
-
-#ifdef USE_TINY_GUI
- set_height(textRect_.h+vertical_padding);
-#else
- set_height(maximum(textRect_.h+vertical_padding,base_height_));
-#endif
- if(type_ == TYPE_PRESS) {
-#ifdef USE_TINY_GUI
- set_width(textRect_.w + horizontal_padding);
-#else
- if(spacing_ == MINIMUM_SPACE) {
- set_width(textRect_.w + horizontal_padding);
- } else {
-
set_width(maximum(textRect_.w+horizontal_padding,base_width_));
- }
-#endif
- } else {
- set_width(checkbox_horizontal_padding + textRect_.w +
base_width_);
- }
+}
+
+void button::calculate_size()
+{
+ textRect_ = screen_area();
+
+ textRect_ = font::draw_text(NULL,textRect_,font_size,
+ font::BUTTON_COLOUR,label_,0,0);
+
+#ifdef USE_TINY_GUI
+ set_height(textRect_.h+vertical_padding);
+#else
+ set_height(maximum(textRect_.h+vertical_padding,base_height_));
+#endif
+ if(type_ == TYPE_PRESS) {
+#ifdef USE_TINY_GUI
+ set_width(textRect_.w + horizontal_padding);
+#else
+ if(spacing_ == MINIMUM_SPACE) {
+ set_width(textRect_.w + horizontal_padding);
+ } else {
+
set_width(maximum(textRect_.w+horizontal_padding,base_width_));
+ }
+#endif
+ } else {
+ set_width(checkbox_horizontal_padding + textRect_.w +
base_width_);
+ }
}
void button::set_check(bool check)
@@ -198,7 +198,7 @@
}
void button::set_label(const std::string& val)
-{
+{
bg_restore();
label_ = val;
@@ -210,8 +210,8 @@
label_ = *i;
}
}
-
- calculate_size();
+
+ calculate_size();
set_dirty(true);
}
Index: wesnoth/src/widgets/button.hpp
diff -u wesnoth/src/widgets/button.hpp:1.31 wesnoth/src/widgets/button.hpp:1.32
--- wesnoth/src/widgets/button.hpp:1.31 Wed May 4 03:16:39 2005
+++ wesnoth/src/widgets/button.hpp Mon May 16 22:44:20 2005
@@ -1,4 +1,4 @@
-/* $Id: button.hpp,v 1.31 2005/05/04 03:16:39 Sirp Exp $ */
+/* $Id: button.hpp,v 1.32 2005/05/16 22:44:20 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -55,8 +55,8 @@
virtual void mouse_up(const SDL_MouseButtonEvent& event);
virtual void draw_contents();
-private:
-
+private:
+
void calculate_size();
std::string label_;
@@ -72,10 +72,10 @@
bool enabled_;
- bool pressed_;
-
- SPACE_CONSUMPTION spacing_;
-
+ bool pressed_;
+
+ SPACE_CONSUMPTION spacing_;
+
int base_height_, base_width_;
bool hit(int x, int y) const;
Index: wesnoth/src/widgets/menu.cpp
diff -u wesnoth/src/widgets/menu.cpp:1.91 wesnoth/src/widgets/menu.cpp:1.92
--- wesnoth/src/widgets/menu.cpp:1.91 Mon May 16 01:16:41 2005
+++ wesnoth/src/widgets/menu.cpp Mon May 16 22:44:21 2005
@@ -9,8 +9,8 @@
#include "../video.hpp"
#include "../wml_separators.hpp"
#include "serialization/string_utils.hpp"
-
-#include <algorithm>
+
+#include <algorithm>
#include <cassert>
#include <numeric>
@@ -20,126 +20,126 @@
}
namespace gui {
-
-menu::basic_sorter::basic_sorter()
-{
- set_id_sort(-1);
-}
-
-menu::basic_sorter& menu::basic_sorter::set_alpha_sort(int column)
-{
- alpha_sort_.insert(column);
- return *this;
-}
-
-menu::basic_sorter& menu::basic_sorter::set_numeric_sort(int column)
-{
- numeric_sort_.insert(column);
- return *this;
-}
-
-menu::basic_sorter& menu::basic_sorter::set_id_sort(int column)
-{
- id_sort_.insert(column);
- return *this;
-}
-
-menu::basic_sorter& menu::basic_sorter::set_redirect_sort(int column, int to)
-{
- if(column != to) {
- redirect_sort_.insert(std::pair<int,int>(column,to));
- }
-
- return *this;
-}
-
-menu::basic_sorter& menu::basic_sorter::set_position_sort(int column, const
std::vector<int>& pos)
-{
- pos_sort_[column] = pos;
- return *this;
-}
-
-bool menu::basic_sorter::column_sortable(int column) const
-{
- const std::map<int,int>::const_iterator redirect =
redirect_sort_.find(column);
- if(redirect != redirect_sort_.end()) {
- return column_sortable(redirect->second);
- }
-
- return alpha_sort_.count(column) == 1 || numeric_sort_.count(column) ==
1 ||
- pos_sort_.count(column) == 1 || id_sort_.count(column) == 1;
-}
-
-bool menu::basic_sorter::less(int column, const item& row1, const item& row2)
const
-{
- const std::map<int,int>::const_iterator redirect =
redirect_sort_.find(column);
- if(redirect != redirect_sort_.end()) {
- return less(redirect->second,row1,row2);
- }
-
- if(id_sort_.count(column) == 1) {
- return row1.id < row2.id;
- }
-
- if(column < 0 || column >= int(row2.fields.size())) {
- return false;
- }
-
- if(column >= int(row1.fields.size())) {
- return true;
- }
-
- const std::string& item1 = row1.fields[column];
- const std::string& item2 = row2.fields[column];
- if(alpha_sort_.count(column) == 1) {
- std::string::const_iterator begin1 = item1.begin(), end1 =
item1.end(),
- begin2 = item2.begin(), end2 =
item2.end();
- while(begin1 != end1 && (font::is_format_char(*begin1) ||
is_wml_separator(*begin1))) {
- ++begin1;
- }
-
- while(begin2 != end2 && (font::is_format_char(*begin2) ||
is_wml_separator(*begin2))) {
- ++begin2;
- }
-
- return
std::lexicographical_compare(begin1,end1,begin2,end2,chars_less_insensitive);
- } else if(numeric_sort_.count(column) == 1) {
- const char* a = item1.c_str();
- const char* b = item2.c_str();
-
- while(*a != 0 && !isdigit(*a)) {
- ++a;
- }
-
- while(*b != 0 && !isdigit(*b)) {
- ++b;
- }
-
- return atoi(a) > atoi(b);
- }
-
- const std::map<int,std::vector<int> >::const_iterator itor =
pos_sort_.find(column);
- if(itor != pos_sort_.end()) {
- const std::vector<int>& pos = itor->second;
- if(row1.id >= pos.size()) {
- return false;
- }
-
- if(row2.id >= pos.size()) {
- return true;
- }
-
- return pos[row1.id] < pos[row2.id];
- }
-
- return false;
-}
+
+menu::basic_sorter::basic_sorter()
+{
+ set_id_sort(-1);
+}
+
+menu::basic_sorter& menu::basic_sorter::set_alpha_sort(int column)
+{
+ alpha_sort_.insert(column);
+ return *this;
+}
+
+menu::basic_sorter& menu::basic_sorter::set_numeric_sort(int column)
+{
+ numeric_sort_.insert(column);
+ return *this;
+}
+
+menu::basic_sorter& menu::basic_sorter::set_id_sort(int column)
+{
+ id_sort_.insert(column);
+ return *this;
+}
+
+menu::basic_sorter& menu::basic_sorter::set_redirect_sort(int column, int to)
+{
+ if(column != to) {
+ redirect_sort_.insert(std::pair<int,int>(column,to));
+ }
+
+ return *this;
+}
+
+menu::basic_sorter& menu::basic_sorter::set_position_sort(int column, const
std::vector<int>& pos)
+{
+ pos_sort_[column] = pos;
+ return *this;
+}
+
+bool menu::basic_sorter::column_sortable(int column) const
+{
+ const std::map<int,int>::const_iterator redirect =
redirect_sort_.find(column);
+ if(redirect != redirect_sort_.end()) {
+ return column_sortable(redirect->second);
+ }
+
+ return alpha_sort_.count(column) == 1 || numeric_sort_.count(column) ==
1 ||
+ pos_sort_.count(column) == 1 || id_sort_.count(column) == 1;
+}
+
+bool menu::basic_sorter::less(int column, const item& row1, const item& row2)
const
+{
+ const std::map<int,int>::const_iterator redirect =
redirect_sort_.find(column);
+ if(redirect != redirect_sort_.end()) {
+ return less(redirect->second,row1,row2);
+ }
+
+ if(id_sort_.count(column) == 1) {
+ return row1.id < row2.id;
+ }
+
+ if(column < 0 || column >= int(row2.fields.size())) {
+ return false;
+ }
+
+ if(column >= int(row1.fields.size())) {
+ return true;
+ }
+
+ const std::string& item1 = row1.fields[column];
+ const std::string& item2 = row2.fields[column];
+ if(alpha_sort_.count(column) == 1) {
+ std::string::const_iterator begin1 = item1.begin(), end1 =
item1.end(),
+ begin2 = item2.begin(), end2 =
item2.end();
+ while(begin1 != end1 && (font::is_format_char(*begin1) ||
is_wml_separator(*begin1))) {
+ ++begin1;
+ }
+
+ while(begin2 != end2 && (font::is_format_char(*begin2) ||
is_wml_separator(*begin2))) {
+ ++begin2;
+ }
+
+ return
std::lexicographical_compare(begin1,end1,begin2,end2,chars_less_insensitive);
+ } else if(numeric_sort_.count(column) == 1) {
+ const char* a = item1.c_str();
+ const char* b = item2.c_str();
+
+ while(*a != 0 && !isdigit(*a)) {
+ ++a;
+ }
+
+ while(*b != 0 && !isdigit(*b)) {
+ ++b;
+ }
+
+ return atoi(a) > atoi(b);
+ }
+
+ const std::map<int,std::vector<int> >::const_iterator itor =
pos_sort_.find(column);
+ if(itor != pos_sort_.end()) {
+ const std::vector<int>& pos = itor->second;
+ if(row1.id >= pos.size()) {
+ return false;
+ }
+
+ if(row2.id >= pos.size()) {
+ return true;
+ }
+
+ return pos[row1.id] < pos[row2.id];
+ }
+
+ return false;
+}
menu::menu(CVideo& video, const std::vector<std::string>& items,
- bool click_selects, int max_height, int max_width,
+ bool click_selects, int max_height, int max_width,
const sorter* sorter_obj)
: scrollarea(video),
- max_height_(max_height), max_width_(max_width), max_items_(-1),
item_height_(-1),
+ max_height_(max_height), max_width_(max_width), max_items_(-1),
item_height_(-1),
heading_height_(-1),
cur_help_(-1,-1), help_string_(-1),
selected_(0), click_selects_(click_selects),
@@ -147,7 +147,7 @@
double_clicked_(false),
num_selects_(true),
ignore_next_doubleclick_(false),
- last_was_doubleclick_(false),
+ last_was_doubleclick_(false),
sorter_(sorter_obj), sortby_(-1), sortreversed_(false),
highlight_heading_(-1)
{
fill_items(items, true);
@@ -156,21 +156,21 @@
void menu::fill_items(const std::vector<std::string>& items, bool strip_spaces)
{
for(std::vector<std::string>::const_iterator itor = items.begin();
- itor != items.end(); ++itor) {
-
- if(itor->empty() == false && (*itor)[0] == HEADING_PREFIX) {
- heading_ =
utils::quoted_split(itor->substr(1),COLUMN_SEPARATOR, !strip_spaces);
- continue;
- }
-
- const size_t id = items_.size();
- item_pos_.push_back(id);
+ itor != items.end(); ++itor) {
+
+ if(itor->empty() == false && (*itor)[0] == HEADING_PREFIX) {
+ heading_ =
utils::quoted_split(itor->substr(1),COLUMN_SEPARATOR, !strip_spaces);
+ continue;
+ }
+
+ const size_t id = items_.size();
+ item_pos_.push_back(id);
const item new_item(utils::quoted_split(*itor,
COLUMN_SEPARATOR, !strip_spaces),id);
items_.push_back(new_item);
//make sure there is always at least one item
if(items_.back().fields.empty()) {
- items_.back().fields.push_back(" ");
+ items_.back().fields.push_back(" ");
}
//if the first character in an item is an asterisk,
@@ -182,78 +182,78 @@
}
}
- create_help_strings();
-
- if(sortby_ >= 0) {
- do_sort();
+ create_help_strings();
+
+ if(sortby_ >= 0) {
+ do_sort();
}
update_size();
-}
-
-namespace {
-
-class sort_func
-{
-public:
- sort_func(const menu::sorter& pred, int column) : pred_(&pred),
column_(column)
- {}
-
- bool operator()(const menu::item& a, const menu::item& b) const
- {
- return pred_->less(column_,a,b);
- }
-
-private:
- const menu::sorter* pred_;
- int column_;
-};
-
-}
-
-void menu::do_sort()
-{
- if(sorter_ == NULL || sorter_->column_sortable(sortby_) == false) {
- return;
- }
-
- const int selectid = selection();
-
- if(sortreversed_ == false) {
-
std::stable_sort(items_.begin(),items_.end(),sort_func(*sorter_,sortby_));
- } else {
- std::reverse(items_.begin(),items_.end());
- }
-
- recalculate_pos();
-
- if(selectid >= 0 && selectid < int(item_pos_.size())) {
- move_selection(selectid,NO_MOVE_VIEWPORT);
- }
-
- set_dirty();
-}
-
-void menu::recalculate_pos()
-{
- item_pos_.resize(items_.size());
- for(std::vector<item>::const_iterator i = items_.begin(); i !=
items_.end(); ++i) {
- item_pos_[i->id] = i - items_.begin();
- }
-
- assert_pos();
-}
-
-void menu::assert_pos()
-{
- assert(item_pos_.size() == items_.size());
- for(size_t n = 0; n != item_pos_.size(); ++n) {
- assert(n == items_[item_pos_[n]].id);
- }
+}
+
+namespace {
+
+class sort_func
+{
+public:
+ sort_func(const menu::sorter& pred, int column) : pred_(&pred),
column_(column)
+ {}
+
+ bool operator()(const menu::item& a, const menu::item& b) const
+ {
+ return pred_->less(column_,a,b);
+ }
+
+private:
+ const menu::sorter* pred_;
+ int column_;
+};
+
+}
+
+void menu::do_sort()
+{
+ if(sorter_ == NULL || sorter_->column_sortable(sortby_) == false) {
+ return;
+ }
+
+ const int selectid = selection();
+
+ if(sortreversed_ == false) {
+
std::stable_sort(items_.begin(),items_.end(),sort_func(*sorter_,sortby_));
+ } else {
+ std::reverse(items_.begin(),items_.end());
+ }
+
+ recalculate_pos();
+
+ if(selectid >= 0 && selectid < int(item_pos_.size())) {
+ move_selection(selectid,NO_MOVE_VIEWPORT);
+ }
+
+ set_dirty();
+}
+
+void menu::recalculate_pos()
+{
+ item_pos_.resize(items_.size());
+ for(std::vector<item>::const_iterator i = items_.begin(); i !=
items_.end(); ++i) {
+ item_pos_[i->id] = i - items_.begin();
+ }
+
+ assert_pos();
+}
+
+void menu::assert_pos()
+{
+ assert(item_pos_.size() == items_.size());
+ for(size_t n = 0; n != item_pos_.size(); ++n) {
+ assert(n == items_[item_pos_[n]].id);
+ }
}
void menu::create_help_strings()
{
- for(std::vector<item>::iterator i = items_.begin(); i != items_.end();
++i) {
+ for(std::vector<item>::iterator i = items_.begin(); i != items_.end();
++i) {
i->help.clear();
for(std::vector<std::string>::iterator j = i->fields.begin(); j
!= i->fields.end(); ++j) {
if(std::find(j->begin(),j->end(),static_cast<char>(HELP_STRING_SEPARATOR)) ==
j->end()) {
@@ -277,7 +277,7 @@
set_shown_size(max_items_onscreen());
}
-void menu::update_size()
+void menu::update_size()
{
unsigned int h = heading_height();
for(size_t i = get_position(),
@@ -300,13 +300,13 @@
set_measurements(w, h);
}
-int menu::selection() const
-{
- if (selected_ >= items_.size()) {
- return -1;
- }
-
- return items_[selected_].id;
+int menu::selection() const
+{
+ if (selected_ >= items_.size()) {
+ return -1;
+ }
+
+ return items_[selected_].id;
}
void menu::set_inner_location(SDL_Rect const &rect)
@@ -317,11 +317,11 @@
}
void menu::change_item(int pos1, int pos2,const std::string& str)
-{
- if(pos1 < 0 || pos1 >= int(item_pos_.size()) ||
- pos2 < 0 || pos2 >= int(items_[item_pos_[pos1]].fields.size()))
{
- return;
- }
+{
+ if(pos1 < 0 || pos1 >= int(item_pos_.size()) ||
+ pos2 < 0 || pos2 >= int(items_[item_pos_[pos1]].fields.size()))
{
+ return;
+ }
items_[item_pos_[pos1]].fields[pos2] = str;
set_dirty();
@@ -331,18 +331,18 @@
{
size_t nb_items = items_.size();
if (index >= nb_items)
- return;
-
- clear_item(nb_items - 1);
-
- const size_t pos = item_pos_[index];
-
- item_pos_.erase(item_pos_.begin() + index);
- for(std::vector<size_t>::iterator i = item_pos_.begin(); i !=
item_pos_.end(); ++i) {
- if(*i > pos) {
- *i = *i-1;
- }
- }
+ return;
+
+ clear_item(nb_items - 1);
+
+ const size_t pos = item_pos_[index];
+
+ item_pos_.erase(item_pos_.begin() + index);
+ for(std::vector<size_t>::iterator i = item_pos_.begin(); i !=
item_pos_.end(); ++i) {
+ if(*i > pos) {
+ *i = *i-1;
+ }
+ }
items_.erase(items_.begin() + pos);
if (selected_ >= nb_items - 1)
@@ -352,42 +352,42 @@
adjust_viewport_to_selection();
itemRects_.clear();
set_dirty();
-}
-
-void menu::set_heading(const std::vector<std::string>& heading)
-{
- itemRects_.clear();
- column_widths_.clear();
-
- heading_ = heading;
- max_items_ = -1;
-
- set_dirty();
+}
+
+void menu::set_heading(const std::vector<std::string>& heading)
+{
+ itemRects_.clear();
+ column_widths_.clear();
+
+ heading_ = heading;
+ max_items_ = -1;
+
+ set_dirty();
}
void menu::set_items(const std::vector<std::string>& items, bool strip_spaces,
bool keep_viewport)
{
- items_.clear();
+ items_.clear();
item_pos_.clear();
itemRects_.clear();
column_widths_.clear();
//undrawn_items_.clear();
max_items_ = -1; // Force recalculation of the max items.
item_height_ = -1; // Force recalculation of the item height.
-
- if (!keep_viewport || selected_ >= items.size()) {
- selected_ = 0;
- }
+
+ if (!keep_viewport || selected_ >= items.size()) {
+ selected_ = 0;
+ }
fill_items(items, strip_spaces);
if(!keep_viewport) {
- set_position(0);
- }
+ set_position(0);
+ }
+
+ update_scrollbar_grip_height();
- update_scrollbar_grip_height();
-
if(!keep_viewport) {
- adjust_viewport_to_selection();
+ adjust_viewport_to_selection();
}
set_dirty();
}
@@ -423,7 +423,7 @@
--n;
return max_items_ = n;
-}
+}
void menu::adjust_viewport_to_selection()
{
@@ -435,11 +435,11 @@
void menu::move_selection_up(size_t dep)
{
set_selection_pos(selected_ > dep ? selected_ - dep : 0);
-}
-
-void menu::reset_selection()
-{
- set_selection_pos(0);
+}
+
+void menu::reset_selection()
+{
+ set_selection_pos(0);
}
void menu::move_selection_down(size_t dep)
@@ -452,21 +452,21 @@
{
if (new_selected == selected_ || new_selected >= items_.size())
return;
-
- invalidate_row_pos(selected_);
+
+ invalidate_row_pos(selected_);
invalidate_row_pos(new_selected);
- selected_ = new_selected;
-
+ selected_ = new_selected;
+
if(move_viewport == MOVE_VIEWPORT) {
- adjust_viewport_to_selection();
+ adjust_viewport_to_selection();
+ }
+}
+
+void menu::move_selection(size_t id, SELECTION_MOVE_VIEWPORT move_viewport)
+{
+ if(id < item_pos_.size()) {
+ set_selection_pos(item_pos_[id],move_viewport);
}
-}
-
-void menu::move_selection(size_t id, SELECTION_MOVE_VIEWPORT move_viewport)
-{
- if(id < item_pos_.size()) {
- set_selection_pos(item_pos_[id],move_viewport);
- }
}
void menu::key_press(SDLKey key)
@@ -548,26 +548,26 @@
}
last_was_doubleclick_ = false;
}
- }
-
-
- if(sorter_ != NULL) {
- const int heading = hit_heading(x,y);
- if(heading >= 0 && sorter_->column_sortable(heading)) {
- sort_by(heading);
- }
}
- } else if(event.type == SDL_MOUSEMOTION) {
+
+
+ if(sorter_ != NULL) {
+ const int heading = hit_heading(x,y);
+ if(heading >= 0 && sorter_->column_sortable(heading)) {
+ sort_by(heading);
+ }
+ }
+ } else if(event.type == SDL_MOUSEMOTION) {
if(click_selects_) {
const int item = hit(event.motion.x,event.motion.y);
if (item != -1)
- move_selection(item);
- }
-
- const int heading_item =
hit_heading(event.motion.x,event.motion.y);
- if(heading_item != highlight_heading_) {
- highlight_heading_ = heading_item;
- invalidate_heading();
+ move_selection(item);
+ }
+
+ const int heading_item =
hit_heading(event.motion.x,event.motion.y);
+ if(heading_item != highlight_heading_) {
+ highlight_heading_ = heading_item;
+ invalidate_heading();
}
}
}
@@ -588,42 +588,42 @@
double_clicked_ = false;
return old;
}
-
-void menu::set_click_selects(bool value)
-{
- click_selects_ = value;
-}
+
+void menu::set_click_selects(bool value)
+{
+ click_selects_ = value;
+}
void menu::set_numeric_keypress_selection(bool value)
{
num_selects_ = value;
-}
+}
void menu::scroll(int)
{
itemRects_.clear();
set_dirty();
-}
-
-void menu::sort_by(int column)
-{
- const bool already_sorted = (column == sortby_);
-
- if(already_sorted) {
- if(sortreversed_ == false) {
- sortreversed_ = true;
- } else {
- sortreversed_ = false;
- sortby_ = -1;
- }
- } else {
- sortby_ = column;
- sortreversed_ = false;
- }
-
- do_sort();
- itemRects_.clear();
- set_dirty();
+}
+
+void menu::sort_by(int column)
+{
+ const bool already_sorted = (column == sortby_);
+
+ if(already_sorted) {
+ if(sortreversed_ == false) {
+ sortreversed_ = true;
+ } else {
+ sortreversed_ = false;
+ sortby_ = -1;
+ }
+ } else {
+ sortby_ = column;
+ sortreversed_ = false;
+ }
+
+ do_sort();
+ itemRects_.clear();
+ set_dirty();
}
namespace {
@@ -655,25 +655,25 @@
return res;
}
}
-
-void menu::column_widths_item(const std::vector<std::string>& row,
std::vector<int>& widths) const
-{
- for(size_t col = 0; col != row.size(); ++col) {
- const SDL_Rect res = item_size(row[col]);
-
- if(col == widths.size()) {
- widths.push_back(res.w + menu_cell_padding);
- } else if(res.w > widths[col] - menu_cell_padding) {
- widths[col] = res.w + menu_cell_padding;
- }
- }
-}
+
+void menu::column_widths_item(const std::vector<std::string>& row,
std::vector<int>& widths) const
+{
+ for(size_t col = 0; col != row.size(); ++col) {
+ const SDL_Rect res = item_size(row[col]);
+
+ if(col == widths.size()) {
+ widths.push_back(res.w + menu_cell_padding);
+ } else if(res.w > widths[col] - menu_cell_padding) {
+ widths[col] = res.w + menu_cell_padding;
+ }
+ }
+}
const std::vector<int>& menu::column_widths() const
{
- if(column_widths_.empty()) {
+ if(column_widths_.empty()) {
column_widths_item(heading_,column_widths_);
- for(size_t row = 0; row != items_.size(); ++row) {
+ for(size_t row = 0; row != items_.size(); ++row) {
column_widths_item(items_[row].fields,column_widths_);
}
}
@@ -689,31 +689,31 @@
bg_restore(rect);
}
-void menu::draw_row(const std::vector<std::string>& row, const SDL_Rect& rect,
ROW_TYPE type)
+void menu::draw_row(const std::vector<std::string>& row, const SDL_Rect& rect,
ROW_TYPE type)
{
if(rect.w == 0 || rect.h == 0) {
return;
- }
-
- bg_restore(rect);
-
- int rgb = 0;
- double alpha = 0.0;
-
- switch(type) {
- case NORMAL_ROW:
- rgb = 0x000000;
- alpha = 0.2;
- break;
- case SELECTED_ROW:
- rgb = 0x990000;
- alpha = 0.6;
- break;
- case HEADING_ROW:
- rgb = 0x333333;
- alpha = 0.3;
- break;
- }
+ }
+
+ bg_restore(rect);
+
+ int rgb = 0;
+ double alpha = 0.0;
+
+ switch(type) {
+ case NORMAL_ROW:
+ rgb = 0x000000;
+ alpha = 0.2;
+ break;
+ case SELECTED_ROW:
+ rgb = 0x990000;
+ alpha = 0.6;
+ break;
+ case HEADING_ROW:
+ rgb = 0x333333;
+ alpha = 0.3;
+ break;
+ }
draw_solid_tinted_rectangle(rect.x, rect.y, rect.w, rect.h,
(rgb&0xff0000) >> 16,(rgb&0xff00) >>
8,rgb&0xff,alpha,
@@ -722,14 +722,14 @@
SDL_Rect const &area = screen_area();
SDL_Rect const &loc = inner_location();
- const std::vector<int>& widths = column_widths();
+ const std::vector<int>& widths = column_widths();
int xpos = rect.x;
- for(size_t i = 0; i != row.size(); ++i) {
-
- if(type == HEADING_ROW && highlight_heading_ == int(i)) {
-
draw_solid_tinted_rectangle(xpos,rect.y,widths[i],rect.h,255,255,255,0.3,video().getSurface());
- }
+ for(size_t i = 0; i != row.size(); ++i) {
+
+ if(type == HEADING_ROW && highlight_heading_ == int(i)) {
+
draw_solid_tinted_rectangle(xpos,rect.y,widths[i],rect.h,255,255,255,0.3,video().getSurface());
+ }
const int last_x = xpos;
std::string str = row[i];
@@ -753,17 +753,17 @@
font::make_text_ellipsis(str,
menu_font_size, loc.w - (xpos - rect.x)) : str;
const SDL_Rect& text_size =
font::text_area(str,menu_font_size);
const size_t y = rect.y + (rect.h -
text_size.h)/2;
-
font::draw_text(&video(),area,menu_font_size,font::NORMAL_COLOUR,to_show,xpos,y);
-
- if(type == HEADING_ROW && sortby_ == int(i)) {
- const surface sort_img =
image::get_image(sortreversed_ ? "misc/sort-arrow.png" :
-
"misc/sort-arrow-reverse.png", image::UNSCALED);
- if(sort_img != NULL && sort_img->w <=
widths[i] && sort_img->h <= rect.h) {
- const size_t sort_x = xpos +
widths[i] - sort_img->w;
- const size_t sort_y = rect.y +
rect.h/2 - sort_img->h/2;
-
video().blit_surface(sort_x,sort_y,sort_img);
- }
- }
+
font::draw_text(&video(),area,menu_font_size,font::NORMAL_COLOUR,to_show,xpos,y);
+
+ if(type == HEADING_ROW && sortby_ == int(i)) {
+ const surface sort_img =
image::get_image(sortreversed_ ? "misc/sort-arrow.png" :
+
"misc/sort-arrow-reverse.png", image::UNSCALED);
+ if(sort_img != NULL && sort_img->w <=
widths[i] && sort_img->h <= rect.h) {
+ const size_t sort_x = xpos +
widths[i] - sort_img->w;
+ const size_t sort_y = rect.y +
rect.h/2 - sort_img->h/2;
+
video().blit_surface(sort_x,sort_y,sort_img);
+ }
+ }
xpos += text_size.w + 5;
}
@@ -773,56 +773,56 @@
}
void menu::draw_contents()
-{
- SDL_Rect heading_rect = inner_location();
- heading_rect.h = heading_height();
- draw_row(heading_,heading_rect,HEADING_ROW);
+{
+ SDL_Rect heading_rect = inner_location();
+ heading_rect.h = heading_height();
+ draw_row(heading_,heading_rect,HEADING_ROW);
- for(size_t i = 0; i != item_pos_.size(); ++i) {
+ for(size_t i = 0; i != item_pos_.size(); ++i) {
draw_row(items_[item_pos_[i]].fields,get_item_rect(i),item_pos_[i] == selected_
? SELECTED_ROW : NORMAL_ROW);
}
-}
-
-void menu::draw()
-{
- if(hidden()) {
- return;
- }
-
- if(!dirty()) {
-
- for(std::set<int>::const_iterator i = invalid_.begin(); i !=
invalid_.end(); ++i) {
- if(*i == -1) {
- SDL_Rect heading_rect = inner_location();
- heading_rect.h = heading_height();
- bg_restore(heading_rect);
- draw_row(heading_,heading_rect,HEADING_ROW);
- update_rect(heading_rect);
- } else if(*i >= 0 && *i < int(item_pos_.size())) {
- const int pos = item_pos_[*i];
- const SDL_Rect& rect = get_item_rect(*i);
- bg_restore(rect);
- draw_row(items_[pos].fields,rect,pos ==
selected_ ? SELECTED_ROW : NORMAL_ROW);
- update_rect(rect);
- }
- }
-
- invalid_.clear();
- return;
- }
-
- invalid_.clear();
-
- bg_restore();
-
- util::scoped_ptr<clip_rect_setter> clipper(NULL);
- if(clip_rect())
- clipper.assign(new clip_rect_setter(video().getSurface(),
*clip_rect()));
-
- draw_contents();
-
- update_rect(location());
- set_dirty(false);
+}
+
+void menu::draw()
+{
+ if(hidden()) {
+ return;
+ }
+
+ if(!dirty()) {
+
+ for(std::set<int>::const_iterator i = invalid_.begin(); i !=
invalid_.end(); ++i) {
+ if(*i == -1) {
+ SDL_Rect heading_rect = inner_location();
+ heading_rect.h = heading_height();
+ bg_restore(heading_rect);
+ draw_row(heading_,heading_rect,HEADING_ROW);
+ update_rect(heading_rect);
+ } else if(*i >= 0 && *i < int(item_pos_.size())) {
+ const int pos = item_pos_[*i];
+ const SDL_Rect& rect = get_item_rect(*i);
+ bg_restore(rect);
+ draw_row(items_[pos].fields,rect,pos ==
selected_ ? SELECTED_ROW : NORMAL_ROW);
+ update_rect(rect);
+ }
+ }
+
+ invalid_.clear();
+ return;
+ }
+
+ invalid_.clear();
+
+ bg_restore();
+
+ util::scoped_ptr<clip_rect_setter> clipper(NULL);
+ if(clip_rect())
+ clipper.assign(new clip_rect_setter(video().getSurface(),
*clip_rect()));
+
+ draw_contents();
+
+ update_rect(location());
+ set_dirty(false);
}
int menu::hit(int x, int y) const
@@ -837,52 +837,52 @@
}
return -1;
-}
-
-int menu::hit_column(int x, int y) const
-{
- std::vector<int> const &widths = column_widths();
- x -= location().x;
- for(int j = 0, j_end = widths.size(); j != j_end; ++j) {
- x -= widths[j];
- if (x < 0) {
- return j;
- }
- }
-
- return -1;
+}
+
+int menu::hit_column(int x, int y) const
+{
+ std::vector<int> const &widths = column_widths();
+ x -= location().x;
+ for(int j = 0, j_end = widths.size(); j != j_end; ++j) {
+ x -= widths[j];
+ if (x < 0) {
+ return j;
+ }
+ }
+
+ return -1;
}
std::pair<int,int> menu::hit_cell(int x, int y) const
{
const int row = hit(x, y);
if(row < 0) {
- return std::pair<int,int>(-1, -1);
- }
-
+ return std::pair<int,int>(-1, -1);
+ }
+
const int col = hit_column(x,y);
if(col < 0) {
- return std::pair<int,int>(-1, -1);
- }
-
+ return std::pair<int,int>(-1, -1);
+ }
+
return std::pair<int,int>(x,y);
-}
-
-int menu::hit_heading(int x, int y) const
-{
- const size_t height = heading_height();
- const SDL_Rect& loc = inner_location();
- if(y >= loc.y && y < loc.y + height) {
- return hit_column(x,y);
- } else {
- return -1;
- }
-}
-
-SDL_Rect menu::get_item_rect(int item) const
-{
- return get_item_rect_internal(item_pos_[item]);
-}
+}
+
+int menu::hit_heading(int x, int y) const
+{
+ const size_t height = heading_height();
+ const SDL_Rect& loc = inner_location();
+ if(y >= loc.y && y < loc.y + height) {
+ return hit_column(x,y);
+ } else {
+ return -1;
+ }
+}
+
+SDL_Rect menu::get_item_rect(int item) const
+{
+ return get_item_rect_internal(item_pos_[item]);
+}
SDL_Rect menu::get_item_rect_internal(size_t item) const
{
@@ -938,15 +938,15 @@
}
return res;
-}
-
-size_t menu::heading_height() const
-{
- if(heading_height_ == -1) {
- heading_height_ = int(get_item_height_internal(heading_));
- }
-
- return minimum<unsigned int>(heading_height_,max_height_);
+}
+
+size_t menu::heading_height() const
+{
+ if(heading_height_ == -1) {
+ heading_height_ = int(get_item_height_internal(heading_));
+ }
+
+ return minimum<unsigned int>(heading_height_,max_height_);
}
size_t menu::get_item_height(int) const
@@ -989,29 +989,29 @@
}
cur_help_ = loc;
-}
-
-void menu::invalidate_row(size_t id)
-{
- if(id >= items_.size()) {
- return;
- }
-
- invalid_.insert(int(id));
-}
-
-void menu::invalidate_row_pos(size_t pos)
-{
- if(pos >= items_.size()) {
- return;
- }
-
- invalidate_row(items_[pos].id);
-}
-
-void menu::invalidate_heading()
-{
- invalid_.insert(-1);
+}
+
+void menu::invalidate_row(size_t id)
+{
+ if(id >= items_.size()) {
+ return;
+ }
+
+ invalid_.insert(int(id));
+}
+
+void menu::invalidate_row_pos(size_t pos)
+{
+ if(pos >= items_.size()) {
+ return;
+ }
+
+ invalidate_row(items_[pos].id);
+}
+
+void menu::invalidate_heading()
+{
+ invalid_.insert(-1);
}
}
Index: wesnoth/src/widgets/menu.hpp
diff -u wesnoth/src/widgets/menu.hpp:1.37 wesnoth/src/widgets/menu.hpp:1.38
--- wesnoth/src/widgets/menu.hpp:1.37 Mon May 16 01:16:42 2005
+++ wesnoth/src/widgets/menu.hpp Mon May 16 22:44:21 2005
@@ -1,7 +1,7 @@
#ifndef WIDGET_MENU_HPP_INCLUDED
#define WIDGET_MENU_HPP_INCLUDED
-
-#include <map>
+
+#include <map>
#include <set>
#include <string>
#include <vector>
@@ -18,66 +18,66 @@
class menu : public scrollarea
{
-public:
-
- struct item
- {
- item() : id(0)
- {}
-
- item(const std::vector<std::string>& fields, size_t id)
- : fields(fields), id(id)
- {}
-
- std::vector<std::string> fields;
- std::vector<std::string> help;
- size_t id;
- };
-
- class sorter
- {
- public:
- virtual ~sorter() {}
- virtual bool column_sortable(int column) const = 0;
- virtual bool less(int column, const item& row1, const item&
row2) const = 0;
- };
-
- class basic_sorter : public sorter
- {
- public:
- basic_sorter();
- virtual ~basic_sorter() {}
-
- basic_sorter& set_alpha_sort(int column);
- basic_sorter& set_numeric_sort(int column);
- basic_sorter& set_id_sort(int column);
- basic_sorter& set_redirect_sort(int column, int to);
- basic_sorter& set_position_sort(int column, const
std::vector<int>& pos);
- protected:
- virtual bool column_sortable(int column) const;
- virtual bool less(int column, const item& row1, const item&
row2) const;
-
- private:
- std::set<int> alpha_sort_, numeric_sort_, id_sort_;
- std::map<int,int> redirect_sort_;
- std::map<int,std::vector<int> > pos_sort_;
- };
+public:
+
+ struct item
+ {
+ item() : id(0)
+ {}
+
+ item(const std::vector<std::string>& fields, size_t id)
+ : fields(fields), id(id)
+ {}
+
+ std::vector<std::string> fields;
+ std::vector<std::string> help;
+ size_t id;
+ };
+
+ class sorter
+ {
+ public:
+ virtual ~sorter() {}
+ virtual bool column_sortable(int column) const = 0;
+ virtual bool less(int column, const item& row1, const item&
row2) const = 0;
+ };
+
+ class basic_sorter : public sorter
+ {
+ public:
+ basic_sorter();
+ virtual ~basic_sorter() {}
+
+ basic_sorter& set_alpha_sort(int column);
+ basic_sorter& set_numeric_sort(int column);
+ basic_sorter& set_id_sort(int column);
+ basic_sorter& set_redirect_sort(int column, int to);
+ basic_sorter& set_position_sort(int column, const
std::vector<int>& pos);
+ protected:
+ virtual bool column_sortable(int column) const;
+ virtual bool less(int column, const item& row1, const item&
row2) const;
+
+ private:
+ std::set<int> alpha_sort_, numeric_sort_, id_sort_;
+ std::map<int,int> redirect_sort_;
+ std::map<int,std::vector<int> > pos_sort_;
+ };
menu(CVideo& video, const std::vector<std::string>& items,
- bool click_selects=false, int max_height=-1, int max_width=-1,
- const sorter* sorter_obj=NULL);
+ bool click_selects=false, int max_height=-1, int max_width=-1,
+ const sorter* sorter_obj=NULL);
+
+ int selection() const;
- int selection() const;
-
enum SELECTION_MOVE_VIEWPORT { MOVE_VIEWPORT, NO_MOVE_VIEWPORT };
- void move_selection(size_t id, SELECTION_MOVE_VIEWPORT
move_viewport=MOVE_VIEWPORT);
+ void move_selection(size_t id, SELECTION_MOVE_VIEWPORT
move_viewport=MOVE_VIEWPORT);
void reset_selection();
// allows user to change_item while running (dangerous)
void change_item(int pos1,int pos2,const std::string& str);
- void erase_item(size_t index);
-
+ void erase_item(size_t index);
+
void set_heading(const std::vector<std::string>& heading);
/// Set new items to show and redraw/recalculate everything. If
@@ -98,12 +98,12 @@
int process();
bool double_clicked();
-
+
void set_click_selects(bool value);
void set_numeric_keypress_selection(bool value);
- void scroll(int pos);
-
+ void scroll(int pos);
+
void sort_by(int column);
protected:
@@ -111,8 +111,8 @@
void set_inner_location(const SDL_Rect& rect);
private:
- size_t max_items_onscreen() const;
-
+ size_t max_items_onscreen() const;
+
size_t heading_height() const;
int max_height_, max_width_;
@@ -121,10 +121,10 @@
void adjust_viewport_to_selection();
void key_press(SDLKey key);
- std::vector<item> items_;
- std::vector<size_t> item_pos_;
-
- std::vector<std::string> heading_;
+ std::vector<item> items_;
+ std::vector<size_t> item_pos_;
+
+ std::vector<std::string> heading_;
mutable int heading_height_;
void create_help_strings();
@@ -144,24 +144,24 @@
bool double_clicked_;
- const std::vector<int>& column_widths() const;
- void column_widths_item(const std::vector<std::string>& row,
std::vector<int>& widths) const;
-
+ const std::vector<int>& column_widths() const;
+ void column_widths_item(const std::vector<std::string>& row,
std::vector<int>& widths) const;
+
enum ROW_TYPE { NORMAL_ROW, SELECTED_ROW, HEADING_ROW };
void draw_row(const std::vector<std::string>& row, const SDL_Rect&
rect, ROW_TYPE type);
void clear_item(int item);
- void draw_contents();
+ void draw_contents();
void draw();
int hit(int x, int y) const;
- std::pair<int,int> hit_cell(int x, int y) const;
- int hit_column(int x, int y) const;
-
+ std::pair<int,int> hit_cell(int x, int y) const;
+ int hit_column(int x, int y) const;
+
int hit_heading(int x, int y) const;
mutable std::map<int,SDL_Rect> itemRects_;
- SDL_Rect get_item_rect(int item) const;
+ SDL_Rect get_item_rect(int item) const;
SDL_Rect get_item_rect_internal(size_t pos) const;
size_t get_item_height_internal(const std::vector<std::string>& item)
const;
size_t get_item_height(int item) const;
@@ -179,30 +179,30 @@
// behavior so that a click that causes one double click wont be
// counted as a first click in the "next" double click.
bool ignore_next_doubleclick_;
- bool last_was_doubleclick_;
-
- const sorter* sorter_;
- int sortby_;
- bool sortreversed_;
+ bool last_was_doubleclick_;
+
+ const sorter* sorter_;
+ int sortby_;
+ bool sortreversed_;
int highlight_heading_;
/// Set new items to show. If strip_spaces is false, spaces will
/// remain at the item edges.
- void fill_items(const std::vector<std::string>& items, bool
strip_spaces);
-
- void do_sort();
- void recalculate_pos();
+ void fill_items(const std::vector<std::string>& items, bool
strip_spaces);
+
+ void do_sort();
+ void recalculate_pos();
void assert_pos();
- void update_size();
+ void update_size();
void set_selection_pos(size_t pos, SELECTION_MOVE_VIEWPORT
move_viewport=MOVE_VIEWPORT);
void move_selection_up(size_t dep);
- void move_selection_down(size_t dep);
-
- void invalidate_row(size_t id);
- void invalidate_row_pos(size_t pos);
- void invalidate_heading();
-
+ void move_selection_down(size_t dep);
+
+ void invalidate_row(size_t id);
+ void invalidate_row_pos(size_t pos);
+ void invalidate_heading();
+
std::set<int> invalid_;
};
Index: wesnoth/src/widgets/progressbar.cpp
diff -u wesnoth/src/widgets/progressbar.cpp:1.10
wesnoth/src/widgets/progressbar.cpp:1.11
--- wesnoth/src/widgets/progressbar.cpp:1.10 Fri May 13 00:47:55 2005
+++ wesnoth/src/widgets/progressbar.cpp Mon May 16 22:44:21 2005
@@ -16,12 +16,12 @@
progress_ = progress;
set_dirty();
}
-
-void progress_bar::set_text(const std::string& text)
-{
- text_ = text;
- set_dirty();
-}
+
+void progress_bar::set_text(const std::string& text)
+{
+ text_ = text;
+ set_dirty();
+}
void progress_bar::draw_contents()
{
@@ -36,7 +36,7 @@
inner_area.w = (inner_area.w*progress_)/100;
SDL_FillRect(surf,&inner_area,SDL_MapRGB(surf->format,150,0,0));
- const std::string text = text_.empty() ? str_cast(progress_) +
"%" :
+ const std::string text = text_.empty() ? str_cast(progress_) +
"%" :
text_ + " (" + str_cast(progress_) +
"%)";
SDL_Rect text_area = font::text_area(text,font::SIZE_NORMAL);
Index: wesnoth/src/widgets/progressbar.hpp
diff -u wesnoth/src/widgets/progressbar.hpp:1.5
wesnoth/src/widgets/progressbar.hpp:1.6
--- wesnoth/src/widgets/progressbar.hpp:1.5 Fri May 13 00:47:56 2005
+++ wesnoth/src/widgets/progressbar.hpp Mon May 16 22:44:21 2005
@@ -10,13 +10,13 @@
public:
progress_bar(CVideo& video);
- void set_progress_percent(int progress);
+ void set_progress_percent(int progress);
void set_text(const std::string& text);
void draw_contents();
private:
- int progress_;
+ int progress_;
std::string text_;
};
Index: wesnoth/src/widgets/slider.hpp
diff -u wesnoth/src/widgets/slider.hpp:1.24 wesnoth/src/widgets/slider.hpp:1.25
--- wesnoth/src/widgets/slider.hpp:1.24 Tue May 10 22:15:57 2005
+++ wesnoth/src/widgets/slider.hpp Mon May 16 22:44:21 2005
@@ -1,4 +1,4 @@
-/* $Id: slider.hpp,v 1.24 2005/05/10 22:15:57 Sirp Exp $ */
+/* $Id: slider.hpp,v 1.25 2005/05/16 22:44:21 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -38,10 +38,10 @@
int min_value() const;
virtual void set_location(SDL_Rect const &rect);
-
- //VC++ doesn't like a 'using scrollarea::set_location' directive here,
so we declare
- //an inline forwarding function instead
- void set_location(int x, int y) { widget::set_location(x,y); }
+
+ //VC++ doesn't like a 'using scrollarea::set_location' directive here,
so we declare
+ //an inline forwarding function instead
+ void set_location(int x, int y) { widget::set_location(x,y); }
protected:
virtual void handle_event(const SDL_Event& event);
Index: wesnoth/src/widgets/widget.cpp
diff -u wesnoth/src/widgets/widget.cpp:1.32 wesnoth/src/widgets/widget.cpp:1.33
--- wesnoth/src/widgets/widget.cpp:1.32 Tue May 10 22:15:57 2005
+++ wesnoth/src/widgets/widget.cpp Mon May 16 22:44:21 2005
@@ -52,11 +52,11 @@
void widget::update_location(SDL_Rect const &rect)
{
bg_register(rect);
-}
-
-const SDL_Rect* widget::clip_rect() const
-{
- return clip_ ? &clip_rect_ : NULL;
+}
+
+const SDL_Rect* widget::clip_rect() const
+{
+ return clip_ ? &clip_rect_ : NULL;
}
void widget::bg_register(SDL_Rect const &rect)
Index: wesnoth/src/widgets/widget.hpp
diff -u wesnoth/src/widgets/widget.hpp:1.27 wesnoth/src/widgets/widget.hpp:1.28
--- wesnoth/src/widgets/widget.hpp:1.27 Tue May 10 22:15:57 2005
+++ wesnoth/src/widgets/widget.hpp Mon May 16 22:44:21 2005
@@ -70,8 +70,8 @@
virtual void draw();
virtual void draw_contents() {};
- virtual void update_location(SDL_Rect const &rect);
-
+ virtual void update_location(SDL_Rect const &rect);
+
const SDL_Rect* clip_rect() const;
private:
Index: wesnoth/src/wml_separators.hpp
diff -u wesnoth/src/wml_separators.hpp:1.2 wesnoth/src/wml_separators.hpp:1.3
--- wesnoth/src/wml_separators.hpp:1.2 Tue May 10 22:15:57 2005
+++ wesnoth/src/wml_separators.hpp Mon May 16 22:44:20 2005
@@ -2,22 +2,22 @@
#define WIDGET_DEFINES_HPP_INCLUDED
char const HELP_STRING_SEPARATOR = '|', DEFAULT_ITEM = '*', COLUMN_SEPARATOR =
'=',
- IMAGE_PREFIX = '&', IMG_TEXT_SEPARATOR = 1, HEADING_PREFIX = 2;
-
-inline bool is_wml_separator(char c)
-{
- switch(c)
- {
- case HELP_STRING_SEPARATOR:
- case DEFAULT_ITEM:
- case COLUMN_SEPARATOR:
- case IMAGE_PREFIX:
- case IMG_TEXT_SEPARATOR:
- case HEADING_PREFIX:
- return true;
- default:
- return false;
- }
+ IMAGE_PREFIX = '&', IMG_TEXT_SEPARATOR = 1, HEADING_PREFIX = 2;
+
+inline bool is_wml_separator(char c)
+{
+ switch(c)
+ {
+ case HELP_STRING_SEPARATOR:
+ case DEFAULT_ITEM:
+ case COLUMN_SEPARATOR:
+ case IMAGE_PREFIX:
+ case IMG_TEXT_SEPARATOR:
+ case HEADING_PREFIX:
+ return true;
+ default:
+ return false;
+ }
}
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src dialogs.cpp display.cpp font.cpp ga...,
Yann Dirson <=