[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src dialogs.cpp map_label.cpp map_label...
From: |
Philippe Plantier |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src dialogs.cpp map_label.cpp map_label... |
Date: |
Wed, 27 Oct 2004 15:33:53 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Philippe Plantier <address@hidden> 04/10/27 19:28:07
Modified files:
src : dialogs.cpp map_label.cpp map_label.hpp
playturn.cpp show_dialog.cpp show_dialog.hpp
src/widgets : combo.cpp textbox.cpp
Log message:
Fixed bug 10664. Made it possible in show_dialog to specify the maximum
length
of the text widget.
show_dialog invocation really is cluttered. Maybe we should replace it,
using
the "named parameter idiom" ?
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/dialogs.cpp.diff?tr1=1.61&tr2=1.62&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/map_label.cpp.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/map_label.hpp.diff?tr1=1.6&tr2=1.7&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/playturn.cpp.diff?tr1=1.278&tr2=1.279&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/show_dialog.cpp.diff?tr1=1.98&tr2=1.99&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/show_dialog.hpp.diff?tr1=1.40&tr2=1.41&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/combo.cpp.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/textbox.cpp.diff?tr1=1.57&tr2=1.58&r1=text&r2=text
Patches:
Index: wesnoth/src/dialogs.cpp
diff -u wesnoth/src/dialogs.cpp:1.61 wesnoth/src/dialogs.cpp:1.62
--- wesnoth/src/dialogs.cpp:1.61 Sat Oct 23 16:45:26 2004
+++ wesnoth/src/dialogs.cpp Wed Oct 27 19:28:07 2004
@@ -1,4 +1,4 @@
-/* $Id: dialogs.cpp,v 1.61 2004/10/23 16:45:26 silene Exp $ */
+/* $Id: dialogs.cpp,v 1.62 2004/10/27 19:28:07 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -209,7 +209,7 @@
options.push_back(gui::check_item(_("Don't ask me
again!"),false));
const int res = gui::show_dialog(disp_,NULL,"",_("Do
you really want to delete this game?"),gui::YES_NO,
-
NULL,NULL,"",NULL,NULL,&options);
+
NULL,NULL,"",NULL,-1,NULL,&options);
//see if the user doesn't want to be asked this again
assert(options.empty() == false);
@@ -448,7 +448,7 @@
std::vector<gui::check_item> options;
options.push_back(gui::check_item(_("Don't ask me
again!"),false));
const int res =
gui::show_dialog(disp,NULL,_(caption),_(message),
-
gui::YES_NO,NULL,NULL,"",NULL,NULL,&options);
+
gui::YES_NO,NULL,NULL,"",NULL,-1,NULL,&options);
generate_summaries = res == 0;
if(options.front().checked) {
@@ -517,7 +517,7 @@
const int res = gui::show_dialog(disp,NULL,
_("Load Game"),
_("Choose the game to load"),
-
gui::OK_CANCEL,&items,&preview_panes,"",NULL,NULL,&options,-1,-1,NULL,&buttons);
+
gui::OK_CANCEL,&items,&preview_panes,"",NULL,-1,NULL,&options,-1,-1,NULL,&buttons);
if(res == -1)
return "";
Index: wesnoth/src/map_label.cpp
diff -u wesnoth/src/map_label.cpp:1.12 wesnoth/src/map_label.cpp:1.13
--- wesnoth/src/map_label.cpp:1.12 Mon Sep 27 00:24:41 2004
+++ wesnoth/src/map_label.cpp Wed Oct 27 19:28:07 2004
@@ -3,6 +3,10 @@
#include "language.hpp"
#include "map_label.hpp"
+namespace {
+ const size_t max_label_size = 32;
+}
+
map_labels::map_labels(const display& disp, const gamemap& map) : disp_(disp),
map_(map)
{}
@@ -42,6 +46,10 @@
return font::get_floating_label_text(index);
}
+int map_labels::get_max_chars() {
+ return max_label_size;
+}
+
const std::string& map_labels::get_label(const gamemap::location& loc) const
{
const label_map::const_iterator itor = labels_.find(loc);
@@ -55,7 +63,6 @@
void map_labels::set_label(const gamemap::location& loc, const std::string&
str)
{
- const size_t max_label_size = 32;
std::string text = str;
if(text.size() > max_label_size) {
text.resize(max_label_size);
Index: wesnoth/src/map_label.hpp
diff -u wesnoth/src/map_label.hpp:1.6 wesnoth/src/map_label.hpp:1.7
--- wesnoth/src/map_label.hpp:1.6 Tue Jul 20 11:56:58 2004
+++ wesnoth/src/map_label.hpp Wed Oct 27 19:28:07 2004
@@ -20,6 +20,8 @@
void write(config& res) const;
void read(const config& cfg);
+ static int get_max_chars();
+
const std::string& get_label(const gamemap::location& loc) const;
void set_label(const gamemap::location& loc, const std::string& text);
void clear();
Index: wesnoth/src/playturn.cpp
diff -u wesnoth/src/playturn.cpp:1.278 wesnoth/src/playturn.cpp:1.279
--- wesnoth/src/playturn.cpp:1.278 Thu Oct 21 18:16:08 2004
+++ wesnoth/src/playturn.cpp Wed Oct 27 19:28:07 2004
@@ -1,4 +1,4 @@
-/* $Id: playturn.cpp,v 1.278 2004/10/21 18:16:08 silene Exp $ */
+/* $Id: playturn.cpp,v 1.279 2004/10/27 19:28:07 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -642,9 +642,9 @@
preview_panes.push_back(&defender_preview);
res = gui::show_dialog(gui_,NULL,_("Attack Enemy"),
- _("Choose
weapon")+std::string(":\n"),
-
gui::OK_CANCEL,&items,&preview_panes,"",NULL,NULL,NULL,-1,-1,
-
NULL,&buttons);
+ _("Choose weapon")+std::string(":\n"),
+
gui::OK_CANCEL,&items,&preview_panes,"",NULL,-1,NULL,NULL,-1,-1,
+ NULL,&buttons);
}
cursor::set(cursor::NORMAL);
@@ -1040,7 +1040,7 @@
static const std::string style = "menu2";
const int res = gui::show_dialog(gui_,NULL,"","",
-
gui::MESSAGE,&menu,NULL,"",NULL,NULL,NULL,xloc,yloc,&style);
+
gui::MESSAGE,&menu,NULL,"",NULL,-1,NULL,NULL,xloc,yloc,&style);
if(res < 0 || res >= items.size())
return;
@@ -1640,9 +1640,9 @@
preview_panes.push_back(&unit_preview);
recruit_res = gui::show_dialog(gui_,NULL,_("Recruit"),
- _("Select unit") +
std::string(":\n"),
-
gui::OK_CANCEL,&items,&preview_panes,"",NULL,NULL,NULL,-1,-1,
-
NULL,NULL,"recruit_and_recall");
+ _("Select unit") + std::string(":\n"),
+
gui::OK_CANCEL,&items,&preview_panes,"",NULL,-1,NULL,NULL,-1,-1,
+ NULL,NULL,"recruit_and_recall");
}
if(recruit_res != -1) {
@@ -1819,10 +1819,10 @@
preview_panes.push_back(&unit_preview);
res = gui::show_dialog(gui_,NULL,_("Recall"),
- _("Select unit") +
std::string(":\n"),
- gui::OK_CANCEL,&options,
- &preview_panes,"",NULL,
- NULL,NULL,-1,-1,NULL,&buttons);
+ _("Select unit") + std::string(":\n"),
+ gui::OK_CANCEL,&options,
+ &preview_panes,"",NULL,-1,
+ NULL,NULL,-1,-1,NULL,&buttons);
}
if(res >= 0) {
@@ -2295,7 +2295,8 @@
std::string label = gui_.labels().get_label(last_hex_);
const int res = gui::show_dialog(gui_,NULL,_("Place
Label"),"",gui::OK_CANCEL,
- NULL,NULL,_("Label") +
std::string(":"),&label);
+ NULL,NULL,_("Label") +
std::string(":"),&label,
+ map_labels::get_max_chars());
if(res == 0) {
gui_.labels().set_label(last_hex_,label);
recorder.add_label(label,last_hex_);
Index: wesnoth/src/show_dialog.cpp
diff -u wesnoth/src/show_dialog.cpp:1.98 wesnoth/src/show_dialog.cpp:1.99
--- wesnoth/src/show_dialog.cpp:1.98 Thu Oct 21 18:16:08 2004
+++ wesnoth/src/show_dialog.cpp Wed Oct 27 19:28:07 2004
@@ -1,4 +1,4 @@
-/* $Id: show_dialog.cpp,v 1.98 2004/10/21 18:16:08 silene Exp $ */
+/* $Id: show_dialog.cpp,v 1.99 2004/10/27 19:28:07 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -384,6 +384,7 @@
const std::vector<preview_pane*>* preview_panes,
const std::string& text_widget_label,
std::string* text_widget_text,
+ int text_widget_max_chars,
dialog_action* action, std::vector<check_item>*
options, int xloc, int yloc,
const std::string* dialog_style,
std::vector<dialog_button>* action_buttons,
const std::string& help_topic)
@@ -420,7 +421,7 @@
static const std::string default_text_string = "";
const unsigned int text_box_width = 350;
textbox text_widget(disp,text_box_width,
- use_textbox ? *text_widget_text :
default_text_string, editable_textbox);
+ use_textbox ? *text_widget_text :
default_text_string, editable_textbox, text_widget_max_chars);
int text_widget_width = 0;
int text_widget_height = 0;
@@ -954,7 +955,7 @@
}
dialog_action_receive_network
receiver(connection_num,cfg,stats);
- const int res =
show_dialog(disp,NULL,"",str.str(),CANCEL_ONLY,NULL,NULL,"",NULL,&receiver);
+ const int res =
show_dialog(disp,NULL,"",str.str(),CANCEL_ONLY,NULL,NULL,"",NULL,-1,&receiver);
if(res !=
int(dialog_action_receive_network::CONNECTION_CONTINUING)) {
return receiver.result();
}
Index: wesnoth/src/show_dialog.hpp
diff -u wesnoth/src/show_dialog.hpp:1.40 wesnoth/src/show_dialog.hpp:1.41
--- wesnoth/src/show_dialog.hpp:1.40 Sat Sep 18 18:52:20 2004
+++ wesnoth/src/show_dialog.hpp Wed Oct 27 19:28:07 2004
@@ -1,4 +1,4 @@
-/* $Id: show_dialog.hpp,v 1.40 2004/09/18 18:52:20 gruikya Exp $ */
+/* $Id: show_dialog.hpp,v 1.41 2004/10/27 19:28:07 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -138,6 +138,7 @@
const std::vector<preview_pane*>*
preview_panes=NULL,
const std::string& text_widget_label="",
std::string* text_widget_text=NULL,
+ const int text_widget_max_chars = 256,
dialog_action* action=NULL,
std::vector<check_item>* options=NULL, int
xloc=-1, int yloc=-1,
const std::string* dialog_style=NULL,
Index: wesnoth/src/widgets/combo.cpp
diff -u wesnoth/src/widgets/combo.cpp:1.20 wesnoth/src/widgets/combo.cpp:1.21
--- wesnoth/src/widgets/combo.cpp:1.20 Mon Sep 27 00:24:41 2004
+++ wesnoth/src/widgets/combo.cpp Wed Oct 27 19:28:07 2004
@@ -1,4 +1,4 @@
-/* $Id: combo.cpp,v 1.20 2004/09/27 00:24:41 ydirson Exp $ */
+/* $Id: combo.cpp,v 1.21 2004/10/27 19:28:07 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -78,7 +78,7 @@
if(button_.process(x,y,button)) {
const SDL_Rect rect = button_.location();
set_selected(gui::show_dialog(*display_,NULL,"","",
-
gui::MESSAGE,&items_,NULL,"",NULL,NULL,NULL,
+
gui::MESSAGE,&items_,NULL,"",NULL,-1,NULL,NULL,
rect.x,rect.y+rect.h));
button_.draw();
Index: wesnoth/src/widgets/textbox.cpp
diff -u wesnoth/src/widgets/textbox.cpp:1.57
wesnoth/src/widgets/textbox.cpp:1.58
--- wesnoth/src/widgets/textbox.cpp:1.57 Tue Oct 12 03:35:57 2004
+++ wesnoth/src/widgets/textbox.cpp Wed Oct 27 19:28:07 2004
@@ -1,4 +1,4 @@
-/* $Id: textbox.cpp,v 1.57 2004/10/12 03:35:57 Sirp Exp $ */
+/* $Id: textbox.cpp,v 1.58 2004/10/27 19:28:07 gruikya Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -39,7 +39,8 @@
scroll_bottom_(false), wrap_(false), line_height_(0), yscroll_(0)
{
static const SDL_Rect area = d.screen_area();
- const int height =
font::draw_text(NULL,area,font_size,font::NORMAL_COLOUR,"ABCD",0,0).h;
+ // const int height =
font::draw_text(NULL,area,font_size,font::NORMAL_COLOUR,"ABCD",0,0).h;
+ const int height = font::get_max_height(font_size);
const SDL_Rect starting_rect = {0,0,width,height};
set_location(starting_rect);
update_text_cache(true);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src dialogs.cpp map_label.cpp map_label...,
Philippe Plantier <=