mail[Wesnoth-commits] r44381 - in /trunk/src: ./ editor/


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

Header


Content

Posted by guillaume . melquiond on July 19, 2010 - 18:14:
Author: silene
Date: Mon Jul 19 18:14:13 2010
New Revision: 44381

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44381&view=rev
Log:
Simplified code.
Fixed internationalization of selected terrain report.

Modified:
    trunk/src/display.cpp
    trunk/src/display.hpp
    trunk/src/editor/editor_controller.cpp
    trunk/src/editor/editor_palettes.cpp
    trunk/src/game_display.cpp
    trunk/src/generate_report.cpp
    trunk/src/reports.hpp

Modified: trunk/src/display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=44381&r1=44380&r2=44381&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Mon Jul 19 18:14:13 2010
@@ -102,7 +102,6 @@
        map_labels_(new map_labels(*this, 0)),
        scroll_event_("scrolled"),
        nextDraw_(0),
-       report_(),
        buttons_(),
        invalidated_(),
        previous_invalidated_(),
@@ -2128,10 +2127,6 @@
        }
 }
 
-void display:: set_report_content(const reports::TYPE which_report, const 
std::string &content) {
-       report_[which_report] = content;
-}
-
 void display::refresh_report(reports::TYPE report_num, reports::report 
report)
 {
        const theme::status_item* const item = 
theme_.get_status_item(reports::report_name(report_num));

Modified: trunk/src/display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=44381&r1=44380&r2=44381&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Mon Jul 19 18:14:13 2010
@@ -467,16 +467,6 @@
         * Useful if units have moved about on the map.
         */
        void redraw_minimap() { redrawMinimap_ = true; }
-
-       /**
-        * Set what will be shown for the report with type which_report.
-        * Note that this only works for some reports,
-        * i.e. reports that can not be deducted
-        * from the supplied arguments to generate_report,
-        * currently: SELECTED_TERRAIN, EDIT_LEFT_BUTTON_FUNCTION
-        */
-       void set_report_content(const reports::TYPE which_report, const 
std::string &content);
-       std::map<reports::TYPE, std::string> get_report_contents() const 
{return report_;};
 
        virtual const time_of_day get_time_of_day(const map_location& 
/*loc*/) const {return time_of_day();}
 
@@ -594,7 +584,6 @@
        SDL_Rect reportRects_[reports::NUM_REPORTS];
        surface reportSurfaces_[reports::NUM_REPORTS];
        reports::report reports_[reports::NUM_REPORTS];
-       std::map<reports::TYPE, std::string> report_;
        std::vector<gui::button> buttons_;
        std::set<map_location> invalidated_;
        std::set<map_location> previous_invalidated_;

Modified: trunk/src/editor/editor_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/editor_controller.cpp?rev=44381&r1=44380&r2=44381&view=diff
==============================================================================
--- trunk/src/editor/editor_controller.cpp (original)
+++ trunk/src/editor/editor_controller.cpp Mon Jul 19 18:14:13 2010
@@ -1184,6 +1184,8 @@
        perform_refresh(editor_action_paint_area(get_map().selection(), 
foreground_terrain_));
 }
 
+std::string left_button_function;
+
 void editor_controller::hotkey_set_mouse_action(hotkey::HOTKEY_COMMAND 
command)
 {
        std::map<hotkey::HOTKEY_COMMAND, mouse_action*>::iterator i = 
mouse_actions_.find(command);
@@ -1191,8 +1193,7 @@
                mouse_action_ = i->second;
                set_mouseover_overlay();
                redraw_toolbar();
-               gui().set_report_content(reports::EDIT_LEFT_BUTTON_FUNCTION,
-                               
hotkey::get_hotkey(command).get_description());
+               left_button_function = 
hotkey::get_hotkey(command).get_description();
                gui().invalidate_game_status();
        } else {
                ERR_ED << "Invalid hotkey command ("

Modified: trunk/src/editor/editor_palettes.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/editor_palettes.cpp?rev=44381&r1=44380&r2=44381&view=diff
==============================================================================
--- trunk/src/editor/editor_palettes.cpp (original)
+++ trunk/src/editor/editor_palettes.cpp Mon Jul 19 18:14:13 2010
@@ -532,12 +532,14 @@
        return -1;
 }
 
-void terrain_palette::update_report() {
-       const std::string msg = std::string(_("FG")) + ": "
-               + get_terrain_string(selected_fg_terrain()) + "\n"
-               + std::string(_("BG")) +
-               ": " + get_terrain_string(selected_bg_terrain());
-       gui_.set_report_content(reports::SELECTED_TERRAIN, msg);
+std::string selected_terrain;
+
+void terrain_palette::update_report()
+{
+       std::ostringstream msg;
+       msg << _("FG: ") << get_terrain_string(selected_fg_terrain())
+               << '\n' << _("BG: ") << 
get_terrain_string(selected_bg_terrain());
+       selected_terrain = msg.str();
 }
 
 void terrain_palette::load_tooltips()

Modified: trunk/src/game_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.cpp?rev=44381&r1=44380&r2=44381&view=diff
==============================================================================
--- trunk/src/game_display.cpp (original)
+++ trunk/src/game_display.cpp Mon Jul 19 18:14:13 2010
@@ -420,10 +420,9 @@
                return;
        }
 
-       reports::report report = reports::generate_report(report_num, report_,
-                                                         
teams_[viewing_team()],
-                                                         
size_t(currentTeam_+1),size_t(activeTeam_+1),
-                                                         selectedHex_, 
mouseoverHex_, displayedUnitHex_,
+       reports::report report = reports::generate_report(report_num,
+               teams_[viewing_team()], currentTeam_ + 1, activeTeam_ + 1,
+               selectedHex_, mouseoverHex_, displayedUnitHex_,
                observers_, level_, !viewpoint_);
 
        refresh_report(report_num, report);

Modified: trunk/src/generate_report.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/generate_report.cpp?rev=44381&r1=44380&r2=44381&view=diff
==============================================================================
--- trunk/src/generate_report.cpp (original)
+++ trunk/src/generate_report.cpp Mon Jul 19 18:14:13 2010
@@ -36,6 +36,10 @@
 #include <iostream>
 #include <ctime>
 
+namespace editor {
+extern std::string selected_terrain, left_button_function;
+}
+
 namespace reports {
 
 static void add_status(report &r,
@@ -56,7 +60,6 @@
 static char const *naps = "</span>";
 
 report generate_report(TYPE type,
-       const std::map<reports::TYPE, std::string> &report_contents,
                        const team &current_team, int current_side, int 
playing_side,
                        const map_location& loc, const map_location& 
mouseover, const map_location& displayed_unit_hex,
                        const std::set<std::string> &observers,
@@ -688,25 +691,17 @@
 
                return report("",game_config::observer_image,str.str());
        }
-       case SELECTED_TERRAIN: {
-               std::map<TYPE, std::string>::const_iterator it =
-                       report_contents.find(SELECTED_TERRAIN);
-               if (it != report_contents.end()) {
-                       return report(it->second);
-               }
-               else {
+       case EDITOR_SELECTED_TERRAIN: {
+               if (editor::selected_terrain.empty())
                        return report();
-               }
-       }
-       case EDIT_LEFT_BUTTON_FUNCTION: {
-               std::map<TYPE, std::string>::const_iterator it =
-                       report_contents.find(EDIT_LEFT_BUTTON_FUNCTION);
-               if (it != report_contents.end()) {
-                       return report(it->second);
-               }
-               else {
+               else
+                       return report(editor::selected_terrain);
+       }
+       case EDITOR_LEFT_BUTTON_FUNCTION: {
+               if (editor::left_button_function.empty())
                        return report();
-               }
+               else
+                       return report(editor::left_button_function);
        }
        case REPORT_COUNTDOWN: {
                int min;

Modified: trunk/src/reports.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/reports.hpp?rev=44381&r1=44380&r2=44381&view=diff
==============================================================================
--- trunk/src/reports.hpp (original)
+++ trunk/src/reports.hpp Mon Jul 19 18:14:13 2010
@@ -33,8 +33,9 @@
                    UNIT_IMAGE, UNIT_PROFILE, TIME_OF_DAY,
                    TURN, GOLD, VILLAGES, NUM_UNITS, UPKEEP, EXPENSES,
                    INCOME, TERRAIN, POSITION, SIDE_PLAYING, OBSERVERS,
-                   REPORT_COUNTDOWN, REPORT_CLOCK, SELECTED_TERRAIN,
-                   EDIT_LEFT_BUTTON_FUNCTION, EDITOR_TOOL_HINT, NUM_REPORTS};
+               REPORT_COUNTDOWN, REPORT_CLOCK, EDITOR_SELECTED_TERRAIN,
+               EDITOR_LEFT_BUTTON_FUNCTION, EDITOR_TOOL_HINT, NUM_REPORTS
+       };
 
        enum { UNIT_REPORTS_BEGIN=UNIT_NAME, UNIT_REPORTS_END=UNIT_PROFILE+1 
};
        enum { STATUS_REPORTS_BEGIN=TIME_OF_DAY, 
STATUS_REPORTS_END=EDITOR_TOOL_HINT };
@@ -94,7 +95,6 @@
        };
 
        report generate_report(TYPE type,
-               const std::map<reports::TYPE, std::string> &report_contents,
                const team &current_team,
                               int current_side, int active_side,
                               const map_location& loc, const map_location& 
mouseover, const map_location& displayed_unit_hex,




Related Messages


Powered by MHonArc, Updated Mon Jul 19 19:00:13 2010