Author: esr
Date: Mon Jul 16 14:58:42 2007
New Revision: 18828

URL: http://svn.gna.org/viewcvs/wesnoth?rev=18828&view=rev
Log:
Move the rectangle painter for reports from game_display.cpp to
display.cpp.  This needs to happen in order to restore terrain and
position reports in the refactored editor.

In order to accomplish this, I removed the "Reverse Time" display
option.  I could have saved it, but once I realized what it was doing
I judged it a clear violation of OAB and too stupid to live.

Modified:
    trunk/src/display.cpp
    trunk/src/display.hpp
    trunk/src/game_display.cpp
    trunk/src/game_preferences.cpp
    trunk/src/game_preferences.hpp
    trunk/src/game_preferences_display.cpp

Modified: trunk/src/display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.cpp?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/src/display.cpp (original)
+++ trunk/src/display.cpp Mon Jul 16 14:58:42 2007
@@ -76,6 +76,8 @@
        if(non_interactive()) {
                screen_.lock_updates(true);
        }
+
+       std::fill(reportRects_,reportRects_+reports::NUM_REPORTS,empty_rect);
 
        image::set_zoom(zoom_);
 }
@@ -1469,3 +1471,155 @@
        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));
+       if(item != NULL) {
+               SDL_Rect& rect = reportRects_[report_num];
+               const SDL_Rect& new_rect = item->location(screen_area());
+
+               //report and its location is unchanged since last time. Do 
nothing.
+               if(rect == new_rect && reports_[report_num] == report) {
+                       return;
+               }
+
+               reports_[report_num] = report;
+
+               surface& surf = reportSurfaces_[report_num];
+
+               if(surf != NULL) {
+                       SDL_BlitSurface(surf,NULL,screen_.getSurface(),&rect);
+                       update_rect(rect);
+               }
+               //if the rectangle has just changed, assign the surface to it
+               if(new_rect != rect || surf == NULL) {
+                       surf.assign(NULL);
+                       rect = new_rect;
+
+                       //if the rectangle is present, and we are
+                       //blitting text, then we need to backup the
+                       //surface. (Images generally won't need
+                       //backing up unless they are transperant, but
+                       //that is done later)
+                       if(rect.w > 0 && rect.h > 0) {
+                               
surf.assign(get_surface_portion(screen_.getSurface(),rect));
+                               if(reportSurfaces_[report_num] == NULL) {
+                                       ERR_DP << "Could not backup background 
for report!\n";
+                               }
+                       }
+
+                       update_rect(rect);
+               }
+
+               tooltips::clear_tooltips(rect);
+
+               SDL_Rect area = rect;
+
+               int x = rect.x, y = rect.y;
+
+               if(!report.empty()) {
+                       // Add prefix, postfix elements. Make sure
+                       // that they get the same tooltip as the guys
+                       // around them.
+                       std::stringstream temp;
+                       Uint32 RGB = item->font_rgb();
+                       int red = (RGB & 0x00FF0000)>>16;
+                       int green = (RGB & 0x0000FF00)>>8;
+                       int blue = (RGB & 0x000000FF);
+
+                       std::string c_start="<";
+                       std::string c_sep=",";
+                       std::string c_end=">";
+                       std::stringstream color;
+                       color<< c_start << red << c_sep << green << c_sep << 
blue << c_end;
+                       std::string str;
+
+                       str = item->prefix();
+                       if(str.empty() == false) {
+                         report.insert(report.begin(), 
reports::element(str,"",report.begin()->tooltip));
+                       }
+                       str = item->postfix();
+                       if(str.empty() == false) {
+                         
report.push_back(reports::element(str,"",report.end()->tooltip));
+                       }
+                       // Loop through and display each report element
+                       size_t tallest = 0;
+                       int image_count = 0;
+                       bool used_ellipsis=false;
+                       std::stringstream ellipsis_tooltip;
+                       SDL_Rect ellipsis_area =rect;
+                       for(reports::report::iterator i = report.begin(); i != 
report.end(); ++i) {
+                         temp.str("");
+                               if(i->text.empty() == false) {
+                                 if(used_ellipsis == false) {
+                                       // Draw a text element
+                                       if(item->font_rgb_set()) {
+                                               temp <<color.str();
+                                       }
+                                       temp << i->text;
+                                       str = temp.str();
+                                       area = 
font::draw_text(&screen_,rect,item->font_size(),font::NORMAL_COLOUR,str,x,y);
+                                       if(area.h > tallest) {
+                                               tallest = area.h;
+                                       }
+                                       if(i->text[i->text.size() - 1] == '\n') 
{
+                                               x = rect.x;
+                                               y += tallest;
+                                               tallest = 0;
+                                       } else {
+                                               x += area.w;
+                                       }
+                                 }
+                               } else if(i->image.get_filename().empty() == 
false) {
+                                 if(used_ellipsis == false) {
+                                       // Draw an image element
+                                       surface 
img(image::get_image(i->image,image::UNSCALED));
+
+                                       if(img == NULL) {
+                                               ERR_DP << "could not find image 
for report: '" << i->image.get_filename() << "'\n";
+                                               continue;
+                                       }
+
+                                       if(rect.w + rect.x - x < img->w && 
image_count) {
+                                         //we have more than one image, and 
this one doesn't fit.
+                                         
img=surface(image::get_image(game_config::ellipsis_image,image::UNSCALED));
+                                         used_ellipsis=true;
+                                       }
+
+                                       area.x = x;
+                                       area.y = y;
+                                       area.w = minimum<int>(rect.w + rect.x - 
x, img->w);
+                                       area.h = minimum<int>(rect.h + rect.y - 
y, img->h);
+                                       draw_image_for_report(img, area);
+
+                                       image_count++;
+                                       if(area.h > tallest) {
+                                               tallest = area.h;
+                                       }
+
+                                       if(! used_ellipsis) {
+                                               x += area.w;
+                                       } else {
+                                               ellipsis_area = area;
+                                       }
+                                 }
+                               } else {
+                                       // No text or image, skip this element
+                                       continue;
+                               }
+                               if(i->tooltip.empty() == false) {
+                                       if(! used_ellipsis) {
+                                               
tooltips::add_tooltip(area,i->tooltip);
+                                       } else { //collect all tooltips for the 
ellipsis
+                                               
ellipsis_tooltip<<i->tooltip<<"\n";
+                                       }
+                               }
+                       }
+                       if(used_ellipsis) {
+                               
tooltips::add_tooltip(ellipsis_area,ellipsis_tooltip.str());
+                       }
+               }
+       } else {
+               reportSurfaces_[report_num].assign(NULL);
+       }
+}

Modified: trunk/src/display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/display.hpp?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/src/display.hpp (original)
+++ trunk/src/display.hpp Mon Jul 16 14:58:42 2007
@@ -168,6 +168,8 @@
        gui::button::TYPE string_to_button_type(std::string type);
        void create_buttons();
        void invalidate_theme() { panelsDrawn_ = false; }
+
+       void refresh_report(reports::TYPE report_num, reports::report report);
 
        // Will be overridden in the display subclass
        virtual void invalidate(const gamemap::location& loc) 
{invalidated_.insert(loc);};

Modified: trunk/src/game_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.cpp?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/src/game_display.cpp (original)
+++ trunk/src/game_display.cpp Mon Jul 16 14:58:42 2007
@@ -176,7 +176,6 @@
        tod_hex_mask1(NULL), tod_hex_mask2(NULL), reach_map_changed_(true)
 {
        singleton_ = this;
-       std::fill(reportRects_,reportRects_+reports::NUM_REPORTS,empty_rect);
 
        //inits the flag list
        flags_.reserve(teams_.size());
@@ -618,163 +617,6 @@
        //SDL_Delay(2*simulate_delay + rand() % 20);
 
        display::draw_wrap(update, force, changed);
-}
-
-void game_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));
-       if(item != NULL) {
-               SDL_Rect& rect = reportRects_[report_num];
-               const SDL_Rect& new_rect = item->location(screen_area());
-
-               //report and its location is unchanged since last time. Do 
nothing.
-               if(rect == new_rect && reports_[report_num] == report) {
-                       return;
-               }
-
-               reports_[report_num] = report;
-
-               surface& surf = reportSurfaces_[report_num];
-
-               if(surf != NULL) {
-                       SDL_BlitSurface(surf,NULL,screen_.getSurface(),&rect);
-                       update_rect(rect);
-               }
-               //if the rectangle has just changed, assign the surface to it
-               if(new_rect != rect || surf == NULL) {
-                       surf.assign(NULL);
-                       rect = new_rect;
-
-                       //if the rectangle is present, and we are
-                       //blitting text, then we need to backup the
-                       //surface. (Images generally won't need
-                       //backing up unless they are transperant, but
-                       //that is done later)
-                       if(rect.w > 0 && rect.h > 0) {
-                               
surf.assign(get_surface_portion(screen_.getSurface(),rect));
-                               if(reportSurfaces_[report_num] == NULL) {
-                                       ERR_DP << "Could not backup background 
for report!\n";
-                               }
-                       }
-
-                       update_rect(rect);
-               }
-
-               tooltips::clear_tooltips(rect);
-
-               SDL_Rect area = rect;
-
-               int x = rect.x, y = rect.y;
-
-               if(!report.empty()) {
-                       // Add prefix, postfix elements. Make sure
-                       // that they get the same tooltip as the guys
-                       // around them.
-                       std::stringstream temp;
-                       Uint32 RGB = item->font_rgb();
-                       int red = (RGB & 0x00FF0000)>>16;
-                       int green = (RGB & 0x0000FF00)>>8;
-                       int blue = (RGB & 0x000000FF);
-
-                       std::string c_start="<";
-                       std::string c_sep=",";
-                       std::string c_end=">";
-                       std::stringstream color;
-                       color<< c_start << red << c_sep << green << c_sep << 
blue << c_end;
-                       std::string str;
-
-                       str = item->prefix();
-                       if(str.empty() == false) {
-                         report.insert(report.begin(), 
reports::element(str,"",report.begin()->tooltip));
-                       }
-                       str = item->postfix();
-                       if(str.empty() == false) {
-                         
report.push_back(reports::element(str,"",report.end()->tooltip));
-                       }
-                       // Loop through and display each report element
-                       size_t tallest = 0;
-                       int image_count = 0;
-                       bool used_ellipsis=false;
-                       std::stringstream ellipsis_tooltip;
-                       SDL_Rect ellipsis_area =rect;
-                       for(reports::report::iterator i = report.begin(); i != 
report.end(); ++i) {
-                         temp.str("");
-                               if(i->text.empty() == false) {
-                                 if(used_ellipsis == false) {
-                                       // Draw a text element
-                                       if(item->font_rgb_set()) {
-                                               temp <<color.str();
-                                       }
-                                       temp << i->text;
-                                       str = temp.str();
-                                       area = 
font::draw_text(&screen_,rect,item->font_size(),font::NORMAL_COLOUR,str,x,y);
-                                       if(area.h > tallest) {
-                                               tallest = area.h;
-                                       }
-                                       if(i->text[i->text.size() - 1] == '\n') 
{
-                                               x = rect.x;
-                                               y += tallest;
-                                               tallest = 0;
-                                       } else {
-                                               x += area.w;
-                                       }
-                                 }
-                               } else if(i->image.get_filename().empty() == 
false) {
-                                 if(used_ellipsis == false) {
-                                       // Draw an image element
-                                       surface 
img(image::get_image(i->image,image::UNSCALED));
-
-                                       if(report_num == reports::TIME_OF_DAY 
&& img != NULL && preferences::flip_time()) {
-                                               img = flip_surface(img);
-                                       }
-
-                                       if(img == NULL) {
-                                               ERR_DP << "could not find image 
for report: '" << i->image.get_filename() << "'\n";
-                                               continue;
-                                       }
-
-                                       if(rect.w + rect.x - x < img->w && 
image_count) {
-                                         //we have more than one image, and 
this one doesn't fit.
-                                         
img=surface(image::get_image(game_config::ellipsis_image,image::UNSCALED));
-                                         used_ellipsis=true;
-                                       }
-
-                                       area.x = x;
-                                       area.y = y;
-                                       area.w = minimum<int>(rect.w + rect.x - 
x, img->w);
-                                       area.h = minimum<int>(rect.h + rect.y - 
y, img->h);
-                                       draw_image_for_report(img, area);
-
-                                       image_count++;
-                                       if(area.h > tallest) {
-                                               tallest = area.h;
-                                       }
-
-                                       if(! used_ellipsis) {
-                                               x += area.w;
-                                       } else {
-                                               ellipsis_area = area;
-                                       }
-                                 }
-                               } else {
-                                       // No text or image, skip this element
-                                       continue;
-                               }
-                               if(i->tooltip.empty() == false) {
-                                       if(! used_ellipsis) {
-                                               
tooltips::add_tooltip(area,i->tooltip);
-                                       } else { //collect all tooltips for the 
ellipsis
-                                               
ellipsis_tooltip<<i->tooltip<<"\n";
-                                       }
-                               }
-                       }
-                       if(used_ellipsis) {
-                               
tooltips::add_tooltip(ellipsis_area,ellipsis_tooltip.str());
-                       }
-               }
-       } else {
-               reportSurfaces_[report_num].assign(NULL);
-       }
 }
 
 void game_display::draw_report(reports::TYPE report_num)

Modified: trunk/src/game_preferences.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_preferences.cpp?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/src/game_preferences.cpp (original)
+++ trunk/src/game_preferences.cpp Mon Jul 16 14:58:42 2007
@@ -610,16 +610,6 @@
        preferences::set("show_haloes", value ? "yes" : "no");
 }
 
-bool flip_time()
-{
-       return preferences::get("flip_time") == "yes";
-}
-
-void set_flip_time(bool value)
-{
-       preferences::set("flip_time", value ? "yes" : "no");
-}
-
 bool upload_log()
 {
        return preferences::get("upload_log") == "yes";

Modified: trunk/src/game_preferences.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_preferences.hpp?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/src/game_preferences.hpp (original)
+++ trunk/src/game_preferences.hpp Mon Jul 16 14:58:42 2007
@@ -144,9 +144,6 @@
        bool show_haloes();
        void set_show_haloes(bool value);
 
-       bool flip_time();
-       void set_flip_time(bool value);
-
        bool upload_log();
        void set_upload_log(bool value);
        const std::string upload_id();

Modified: trunk/src/game_preferences_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_preferences_display.cpp?rev=18828&r1=18827&r2=18828&view=diff
==============================================================================
--- trunk/src/game_preferences_display.cpp (original)
+++ trunk/src/game_preferences_display.cpp Mon Jul 16 14:58:42 2007
@@ -99,7 +99,7 @@
                        show_team_colours_button_, show_colour_cursors_button_,
                        show_haloing_button_, video_mode_button_, 
                        theme_button_, hotkeys_button_, gamma_button_,
-                       flip_time_button_, advanced_button_, sound_button_, 
+                       advanced_button_, sound_button_, 
                        music_button_, chat_timestamp_button_,
                        advanced_sound_button_, normal_sound_button_, 
                        UI_sound_button_, sample_rate_button1_, 
@@ -157,7 +157,6 @@
          theme_button_(disp.video(), _("Theme")),
          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),
          advanced_button_(disp.video(), "", gui::button::TYPE_CHECK),
          sound_button_(disp.video(), _("Sound effects"), 
gui::button::TYPE_CHECK),
          music_button_(disp.video(), _("Music"), gui::button::TYPE_CHECK),
@@ -339,9 +338,6 @@
 
        show_team_colours_button_.set_check(show_side_colours());
        show_team_colours_button_.set_help_string(_("Show a colored circle 
around the base of each unit to show which side it is on"));
-
-       flip_time_button_.set_check(flip_time());
-       flip_time_button_.set_help_string(_("Choose whether the sun moves 
left-to-right or right-to-left"));
 
        show_colour_cursors_button_.set_check(use_colour_cursors());
        show_colour_cursors_button_.set_help_string(_("Use colored mouse 
cursors (may be slower)"));
@@ -395,7 +391,6 @@
        h.push_back(&theme_button_);
        h.push_back(&hotkeys_button_);
        h.push_back(&gamma_button_);
-       h.push_back(&flip_time_button_);
        h.push_back(&advanced_button_);
        h.push_back(&sound_button_);
        h.push_back(&music_button_);
@@ -470,7 +465,6 @@
        SDL_Rect gamma_rect = { rect.x + gamma_label_.width(), ypos,
                                                        rect.w - 
gamma_label_.width() - right_border, 0 };
        gamma_slider_.set_location(gamma_rect);
-       ypos += item_interline; flip_time_button_.set_location(rect.x,ypos);
        ypos += item_interline; 
show_floating_labels_button_.set_location(rect.x, ypos);
        ypos += item_interline; 
show_colour_cursors_button_.set_location(rect.x, ypos);
        ypos += item_interline; show_haloing_button_.set_location(rect.x, ypos);
@@ -646,8 +640,6 @@
                        gamma_slider_.enable(enable_gamma);
                        gamma_label_.enable(enable_gamma);
                }
-               if (flip_time_button_.pressed())
-                       set_flip_time(flip_time_button_.checked());
 
                set_gamma(gamma_slider_.value());
 
@@ -954,7 +946,6 @@
        fullscreen_button_.hide(hide_display);
        video_mode_button_.hide(hide_display);
        theme_button_.hide(hide_display);
-       flip_time_button_.hide(hide_display);
 
        const bool hide_sound = tab_ != SOUND_TAB;
        music_button_.hide(hide_sound);


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

Reply via email to