mail[Wesnoth-commits] r28560 - in /trunk/src/gui/dialogs: editor_new_map.cpp editor_resize_map.cpp field.hpp mp_connect.cpp mp_create_game.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by koraq on August 13, 2008 - 19:32:
Author: mordante
Date: Wed Aug 13 19:12:16 2008
New Revision: 28560

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28560&view=rev
Log:
After discussing with ilor the overloaded get_value() in field.hpp was 
unclear.
Renamed both versions and fixed the callers. 
Also added more comment to the functions.

Modified:
    trunk/src/gui/dialogs/editor_new_map.cpp
    trunk/src/gui/dialogs/editor_resize_map.cpp
    trunk/src/gui/dialogs/field.hpp
    trunk/src/gui/dialogs/mp_connect.cpp
    trunk/src/gui/dialogs/mp_create_game.cpp

Modified: trunk/src/gui/dialogs/editor_new_map.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/editor_new_map.cpp?rev=28560&r1=28559&r2=28560&view=diff
==============================================================================
--- trunk/src/gui/dialogs/editor_new_map.cpp (original)
+++ trunk/src/gui/dialogs/editor_new_map.cpp Wed Aug 13 19:12:16 2008
@@ -44,22 +44,22 @@
 
 void teditor_new_map::set_map_width(int value) 
 { 
-       map_width_->set_value(value);
+       map_width_->set_cache_value(value);
 }
 
 int teditor_new_map::map_width() const
 {
-       return map_width_->get_value();
+       return map_width_->get_cache_value();
 }
 
 void teditor_new_map::set_map_height(int value)
 { 
-       map_height_->set_value(value);
+       map_height_->set_cache_value(value);
 }
 
 int teditor_new_map::map_height() const
 {
-       return map_height_->get_value();
+       return map_height_->get_cache_value();
 }
 
 twindow teditor_new_map::build_window(CVideo& video)

Modified: trunk/src/gui/dialogs/editor_resize_map.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/editor_resize_map.cpp?rev=28560&r1=28559&r2=28560&view=diff
==============================================================================
--- trunk/src/gui/dialogs/editor_resize_map.cpp (original)
+++ trunk/src/gui/dialogs/editor_resize_map.cpp Wed Aug 13 19:12:16 2008
@@ -60,22 +60,22 @@
 
 void teditor_resize_map::set_map_width(int value) 
 { 
-       map_width_->set_value(value);
+       map_width_->set_cache_value(value);
 }
 
 int teditor_resize_map::map_width() const
 {
-       return map_width_->get_value();
+       return map_width_->get_cache_value();
 }
 
 void teditor_resize_map::set_map_height(int value)
 {
-       map_height_->set_value(value);
+       map_height_->set_cache_value(value);
 }
 
 int teditor_resize_map::map_height() const
 {
-       return map_height_->get_value();
+       return map_height_->get_cache_value();
 }
 
 void teditor_resize_map::set_old_map_width(int value) 
@@ -90,7 +90,7 @@
 
 bool teditor_resize_map::copy_edge_terrain() const
 {
-       return copy_edge_terrain_->get_value();
+       return copy_edge_terrain_->get_cache_value();
 }
 
 twindow teditor_resize_map::build_window(CVideo& video)
@@ -159,8 +159,8 @@
                set_direction_icon(i, "none");
        }
        
-       int xdiff = map_width_->get_value(window) - old_width_ ;
-       int ydiff = map_height_->get_value(window) - old_height_ ;
+       int xdiff = map_width_->get_widget_value(window) - old_width_ ;
+       int ydiff = map_height_->get_widget_value(window) - old_height_ ;
        int x = static_cast<int>(expand_direction_) % 3;
        int y = static_cast<int>(expand_direction_) / 3;
        set_direction_icon(expand_direction_, "center");

Modified: trunk/src/gui/dialogs/field.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/field.hpp?rev=28560&r1=28559&r2=28560&view=diff
==============================================================================
--- trunk/src/gui/dialogs/field.hpp (original)
+++ trunk/src/gui/dialogs/field.hpp Wed Aug 13 19:12:16 2008
@@ -225,23 +225,29 @@
        }
 
        /** 
-        * Sets the value of the widget.
+        * Sets the value of the field.
+        *
+        * This sets the value in both the internal cache value and in the 
widget
+        * itself.
         *
         * @param window              The window containing the widget.
         * @param value               The new value.
         */
-       void set_value(twindow& window, CT value) 
+       void set_widget_value(twindow& window, CT value) 
        {
                value_ = value;
                restore(window);
        }
 
        /** 
-        * Sets the value of the widget.
+        * Sets the value of the field.
+        *
+        * This sets the internal cache value but not the widget value, this 
can
+        * be used to initialize the field.
         *
         * @param value               The new value.
         */
-       void set_value(CT value) 
+       void set_cache_value(CT value) 
        {
                value_ = value;
        }
@@ -253,20 +259,31 @@
        }
 
        /** 
-        * Gets the value of the widget.
-        *
-        * @param window              The window containing the widget.
-        */
-       T get_value(twindow& window) 
+        * Gets the value of the field.
+        *
+        * This function gets the value of the widget and stores that in the
+        * internal cache, then that value is returned.
+        *
+        * @param window              The window containing the widget.
+        *
+        * @returns                   The current value of the widget.
+        */ 
+       T get_widget_value(twindow& window) 
        {
                save(window, false);
                return value_;
        }
 
        /** 
-        * Gets the value of the widget.
-        */
-       T get_value() 
+        * Gets the value of the field.
+        *
+        * This function returns the value internal cache, this function can 
be
+        * used after the widget no longer exists. The cache is normally 
updated
+        * when the window is closed with succes.
+        *
+        * @returns                   The currently value of the internal 
cache.
+        */ 
+       T get_cache_value() 
        {
                return value_;
        }

Modified: trunk/src/gui/dialogs/mp_connect.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/mp_connect.cpp?rev=28560&r1=28559&r2=28560&view=diff
==============================================================================
--- trunk/src/gui/dialogs/mp_connect.cpp (original)
+++ trunk/src/gui/dialogs/mp_connect.cpp Wed Aug 13 19:12:16 2008
@@ -194,7 +194,7 @@
        dlg.show(*video_);
 
        if(dlg.get_retval() == twindow::OK) {
-               host_name_->set_value(window, dlg.host_name());
+               host_name_->set_widget_value(window, dlg.host_name());
        }
 }
 

Modified: trunk/src/gui/dialogs/mp_create_game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/mp_create_game.cpp?rev=28560&r1=28559&r2=28560&view=diff
==============================================================================
--- trunk/src/gui/dialogs/mp_create_game.cpp (original)
+++ trunk/src/gui/dialogs/mp_create_game.cpp Wed Aug 13 19:12:16 2008
@@ -158,7 +158,7 @@
 
 void tmp_create_game::update_map_settings(twindow& window)
 {
-       const bool use_map_settings = use_map_settings_->get_value(window);
+       const bool use_map_settings = 
use_map_settings_->get_widget_value(window);
 
        fog_->widget_set_enabled(window, !use_map_settings, false);
        shroud_->widget_set_enabled(window, !use_map_settings, false);
@@ -171,26 +171,26 @@
        if(use_map_settings) {
                if(scenario_) {
 
-                       fog_->set_value(window, 
::settings::use_fog((*(*scenario_).get_children("side").front())["fog"]));
-                       shroud_->set_value(window, 
::settings::use_shroud((*(*scenario_).get_children("side").front())["shroud"]));
-                       start_time_->set_value(window, 
::settings::use_random_start_time((*scenario_)["random_start_time"]));
+                       fog_->set_widget_value(window, 
::settings::use_fog((*(*scenario_).get_children("side").front())["fog"]));
+                       shroud_->set_widget_value(window, 
::settings::use_shroud((*(*scenario_).get_children("side").front())["shroud"]));
+                       start_time_->set_widget_value(window, 
::settings::use_random_start_time((*scenario_)["random_start_time"]));
 
-                       turns_->set_value(window, 
::settings::get_turns((*scenario_)["turns"]));
-                       gold_->set_value(window, 
::settings::get_village_gold((*(*scenario_).get_children("side").front())["village_gold"]));
-                       experience_->set_value(window, 
::settings::get_xp_modifier((*scenario_)["experience_modifier"]));
+                       turns_->set_widget_value(window, 
::settings::get_turns((*scenario_)["turns"]));
+                       gold_->set_widget_value(window, 
::settings::get_village_gold((*(*scenario_).get_children("side").front())["village_gold"]));
+                       experience_->set_widget_value(window, 
::settings::get_xp_modifier((*scenario_)["experience_modifier"]));
                }
                // No scenario selected just leave the state unchanged for 
now.
 
        } else {
 
                // Fixme we should store the value and reuse it later...
-               fog_->set_value(window, preferences::fog());
-               shroud_->set_value(window, preferences::shroud());
-               start_time_->set_value(window, 
preferences::random_start_time());
+               fog_->set_widget_value(window, preferences::fog());
+               shroud_->set_widget_value(window, preferences::shroud());
+               start_time_->set_widget_value(window, 
preferences::random_start_time());
 
-               turns_->set_value(window, preferences::turns());
-               gold_->set_value(window, preferences::village_gold());
-               experience_->set_value(window, preferences::xp_modifier());
+               turns_->set_widget_value(window, preferences::turns());
+               gold_->set_widget_value(window, preferences::village_gold());
+               experience_->set_widget_value(window, 
preferences::xp_modifier());
        }
 }
 




Related Messages


Powered by MHonArc, Updated Wed Aug 13 19:42:17 2008