Author: fendrin
Date: Tue Nov 24 02:49:20 2009
New Revision: 39907

URL: http://svn.gna.org/viewcvs/wesnoth?rev=39907&view=rev
Log:
Code cleanups.

Modified:
    branches/fendrin_gui_stuff/src/gui/dialogs/wml_message.cpp
    branches/fendrin_gui_stuff/src/gui/dialogs/wml_message.hpp

Modified: branches/fendrin_gui_stuff/src/gui/dialogs/wml_message.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_gui_stuff/src/gui/dialogs/wml_message.cpp?rev=39907&r1=39906&r2=39907&view=diff
==============================================================================
--- branches/fendrin_gui_stuff/src/gui/dialogs/wml_message.cpp (original)
+++ branches/fendrin_gui_stuff/src/gui/dialogs/wml_message.cpp Tue Nov 24 
02:49:20 2009
@@ -10,6 +10,13 @@
  but WITHOUT ANY WARRANTY.
 
  See the COPYING file for more details.
+ */
+
+/**
+ * @todo This function enables the wml markup for all items, but the interface
+ * is a bit hacky. Especially the fiddling in the internals of the listbox is
+ * ugly. There needs to be a clean interface to set whether a widget has a
+ * markup and what kind of markup. These fixes will be post 1.6.
  */
 
 #define GETTEXT_DOMAIN "wesnoth-lib"
@@ -36,18 +43,12 @@
 
 namespace gui2 {
 
+/*
 void trecall_message_::recall_pressed(twindow& window) {
-       //      std::string icon   = (chosen_unit_->absolute_image() + "~GS()");
 
        tlistbox& input_list = find_widget<tlistbox> (&window, "unit_list", 
false);
 
        game_menu_handler_->do_recall(chosen_unit_);
-
-       //TODO grey the unit out.
-       //      set_variable("portrait_image", variant(portrait_));
-       //      input_list.add_row()
-       //      
(input_list.get_row_grid(input_list.get_selected_row()))->set_child()
-
        input_list.remove_row(input_list.get_selected_row());
 
        if (unit_list_.empty()) {
@@ -60,6 +61,7 @@
        input_list.set_dirty();
        window.set_dirty();
 }
+*/
 
 void tunit_message_::profile_pressed() {
        const unit_type& t = *chosen_unit_->type();
@@ -116,33 +118,13 @@
        window.set_dirty();
 }
 
-/*
-void trecruit_message_::update_type_list(twindow& window) {
-       tlistbox& type_listbox =
-                       find_widget<tlistbox> (&window, "type_list", false);
-
-       unit_type tmp = *type_list_[type_listbox.get_selected_row()];
-       chosen_type_ = tmp.id();
-
-       const int side_num = 1; //dummy krempel TODO
-
-       unit new_unit(resources::units, &tmp, side_num, false);
-
-       new_unit.draw_report();
-
-       window.canvas(1).set_variable("portrait_image", variant(
-                       new_unit.transparent()));
-       window.set_dirty();
-}
-*/
-
 void tunit_message_::update_unit_list(twindow& window) {
        tlistbox& unit_listbox = find_widget<tlistbox> (&window, "unit_list", 
false);
        *chosen_unit_ = unit_list_[unit_listbox.get_selected_row()];
 
        if (resources::game_map->on_board(chosen_unit_->get_location())) {
+               resources::screen->highlight_hex(chosen_unit_->get_location());
                //TODO is false better?
-               resources::screen->highlight_hex(chosen_unit_->get_location());
                resources::screen->scroll_to_tile(chosen_unit_->get_location(),
                                game_display::SCROLL, true);
        } else {
@@ -174,64 +156,63 @@
         * with special meanings for certain characters.
         */
 
+       assert(!option_list_.empty());
+
        // Avoid negetive and 0 since item 0 is already selected.
        if (*chosen_option_ > 0 && static_cast<size_t> (*chosen_option_)
                        < option_list_.size()) {
-
                options.select_row(*chosen_option_);
        }
 
-       if (!option_list_.empty()) {
-               std::map<std::string, string_map> data;
-               for (size_t i = 0; i < option_list_.size(); ++i) {
-                       std::string icon = "";
-                       std::string label = option_list_[i];
-                       std::string description = "";
-
-                       // Handle selection.
-                       if (!label.empty() && label[0] == '*') {
-                               // Number of items hasn't been increased yet so 
i is ok.
-                               *chosen_option_ = i;
+       std::map<std::string, string_map> data;
+       for (size_t i = 0; i < option_list_.size(); ++i) {
+               std::string icon = "";
+               std::string label = option_list_[i];
+               std::string description = "";
+
+               // Handle selection.
+               if (!label.empty() && label[0] == '*') {
+                       // Number of items hasn't been increased yet so i is ok.
+                       *chosen_option_ = i;
+                       label.erase(0, 1);
+               }
+
+               // Handle the special case with an image.
+               if (label.find('=') != std::string::npos) {
+                       // We always assume the first item is an image if not 
it's
+                       // still handled as an image. This is a hack but the 
code
+                       // should be rewritten anyway.
+                       if (label[0] == '&') {
                                label.erase(0, 1);
                        }
 
-                       // Handle the special case with an image.
-                       if (label.find('=') != std::string::npos) {
-                               // We always assume the first item is an image 
if not it's
-                               // still handled as an image. This is a hack 
but the code
-                               // should be rewritten anyway.
-                               if (label[0] == '&') {
-                                       label.erase(0, 1);
-                               }
-
-                               std::vector<std::string> row_data = 
utils::split(label, '=', 0);
-                               label = "";
-
-                               assert(!row_data.empty());
-                               icon = row_data[0];
-
-                               if (row_data.size() > 1) {
-                                       label = row_data[1];
-
-                                       for (size_t j = 2; j < row_data.size(); 
++j) {
-                                               description += row_data[j];
-                                               if (j + 1 < row_data.size()) {
-                                                       description += '=';
-                                               }
+                       std::vector<std::string> row_data = utils::split(label, 
'=', 0);
+                       label = "";
+
+                       assert(!row_data.empty());
+                       icon = row_data[0];
+
+                       if (row_data.size() > 1) {
+                               label = row_data[1];
+
+                               for (size_t j = 2; j < row_data.size(); ++j) {
+                                       description += row_data[j];
+                                       if (j + 1 < row_data.size()) {
+                                               description += '=';
                                        }
                                }
                        }
-
-                       // Add the data.
-                       data["icon"]["label"] = icon;
-                       data["label"]["label"] = label;
-                       data["label"]["use_markup"] = "true";
-                       data["description"]["label"] = description;
-                       data["description"]["use_markup"] = "true";
-                       options.add_row(data);
                }
-       }
-       //TODO put into the if?
+
+               // Add the data.
+               data["icon"]["label"] = icon;
+               data["label"]["label"] = label;
+               data["label"]["use_markup"] = "true";
+               data["description"]["label"] = description;
+               data["description"]["use_markup"] = "true";
+               options.add_row(data);
+       }
+
        window.set_click_dismiss(false);
        window.set_escape_disabled(true);
 }
@@ -239,7 +220,6 @@
 void trecall_message_::pre_show(CVideo& video, twindow& window) {
        tunit_message_::pre_show(video, window);
 
-       //TODO
        /*
        tbutton* recall_button = find_widget<tbutton> (&window, "recall", false,
                        false);
@@ -314,9 +294,7 @@
                // Add the data.
                data["cost"]["label"] = cost.str();
                data["cost"]["use_markup"] = "true";
-
                data["usage"]["label"] = unit.usage();
-
                data["icon"]["label"] = icon;
                data["icon"]["use_markup"] = "true";
                data["name"]["label"] = name;
@@ -356,13 +334,6 @@
        window.set_escape_disabled(true);
 }
 
-//TODO update this comment
-/**
- * @todo This function enables the wml markup for all items, but the interface
- * is a bit hacky. Especially the fiddling in the internals of the listbox is
- * ugly. There needs to be a clean interface to set whether a widget has a
- * markup and what kind of markup. These fixes will be post 1.6.
- */
 void ticon_message_::pre_show(CVideo& video, twindow& window) {
        window.canvas(1).set_variable("portrait_image", variant(portrait_));
        window.canvas(1).set_variable("portrait_mirror", variant(mirror_));

Modified: branches/fendrin_gui_stuff/src/gui/dialogs/wml_message.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/branches/fendrin_gui_stuff/src/gui/dialogs/wml_message.hpp?rev=39907&r1=39906&r2=39907&view=diff
==============================================================================
--- branches/fendrin_gui_stuff/src/gui/dialogs/wml_message.hpp (original)
+++ branches/fendrin_gui_stuff/src/gui/dialogs/wml_message.hpp Tue Nov 24 
02:49:20 2009
@@ -24,9 +24,8 @@
 
 namespace gui2 {
 
-//TODO update the comment.
 /**
- * Base class for the wml generated messages.
+ * Base class for messages that also display an image or portrait.
  *
  * We have a separate sub class for left and right images.
  */
@@ -309,9 +308,8 @@
        /** Inherited from tdialog. */
        void pre_show(CVideo& video, twindow& window);
 
-       //TODO clean up
-       /** Inherited from tdialog. */
-       void post_show(twindow& window);// { chosen_type_ = 
chosen_unit_->type_id(); }
+       /** Inherited from tdialog. */
+       void post_show(twindow& window);
 
 private:
 //     std::vector<const unit_type*> type_list_;
@@ -405,9 +403,6 @@
        /** Inherited from tdialog. */
        void pre_show(CVideo& video, twindow& window);
 
-       //TODO cleanup
-       /** Inherited from tdialog. */
-//     void post_show(twindow& window);
 };
 
 class trecall_message_left : public trecall_message_
@@ -442,7 +437,7 @@
 
 
 
-//TODO clean up the documentation
+//TODO find a way to reference to these docu in the other methods.
 /**
  *  Helper function to show a message with speaker portrait.
  *
@@ -453,19 +448,6 @@
  *  @param message                The message to show.
  *  @param portrait               Filename of the portrait.
  *  @param mirror                 Does the portrait need to be mirrored?
- *
- *  @param has_input              Do we need to show the input box.
- *  @param input_caption          The caption for the optional input text
- *                                box. If this value != "" there is an input
- *                                and the input text parameter is mandatory.
- *  @param input_text             Pointer to the initial text value will be
- *                                set to the result.
- *  @param maximum_length         The maximum length of the text.
- *
- *  @param option_list            A list of options to select in the dialog.
- *  @param chosen_option          Pointer to the initially chosen option.
- *                                Will be set to the chosen_option when the
- *                                dialog closes.
  */
 int show_icon_message(const bool left_side
                , CVideo& video
@@ -474,6 +456,16 @@
                , const std::string& portrait
                , const bool mirror);
 
+/**
+*
+*  @param input_caption          The caption for the optional input text
+*                                box. If this value != "" there is an input
+*                                and the input text parameter is mandatory.
+*  @param input_text             Pointer to the initial text value will be
+*                                set to the result.
+*  @param maximum_length         The maximum length of the text.
+*
+*/
 int show_input_message(const bool left_side
                , CVideo& video
                , const std::string& title
@@ -484,7 +476,12 @@
                , std::string* input_text
            , const unsigned maximum_length);
 
-//TODO comment
+/*
+*  @param option_list            A list of options to select in the dialog.
+*  @param chosen_option          Pointer to the initially chosen option.
+*                                Will be set to the chosen_option when the
+*                                dialog closes.
+*/
 int show_option_message(const bool left_side
                , CVideo& video
                , const std::string& title


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to