Author: silene
Date: Tue Apr 14 22:32:22 2009
New Revision: 34923
URL: http://svn.gna.org/viewcvs/wesnoth?rev=34923&view=rev
Log:
Converted loadscreen to use the generic image loading system. (Patch #1154 from
Chusslove.)
Modified:
trunk/src/loadscreen.cpp
trunk/src/loadscreen.hpp
Modified: trunk/src/loadscreen.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/loadscreen.cpp?rev=34923&r1=34922&r2=34923&view=diff
==============================================================================
--- trunk/src/loadscreen.cpp (original)
+++ trunk/src/loadscreen.cpp Tue Apr 14 22:32:22 2009
@@ -25,6 +25,7 @@
#include "gettext.hpp"
#include "filesystem.hpp"
#include "video.hpp"
+#include "image.hpp"
#include <SDL_image.h>
@@ -71,16 +72,14 @@
parser_counter(0),
screen_(screen),
textarea_(),
- logo_surface_(NULL),
logo_drawn_(false),
pby_offset_(0),
prcnt_(percent)
{
- std::string path = get_binary_file_location("images","misc/logo.png");
- logo_surface_ = IMG_Load(path.c_str());
- if (!logo_surface_) {
- ERR_DISP << "loadscreen: Failed to load the logo: " <<
path << std::endl;
- }
+ logo_surface_ = image::get_image("misc/logo.png");
+ if (logo_surface_.null()) {
+ ERR_DISP << "loadscreen: Failed to load the logo" << std::endl;
+ }
textarea_.x = textarea_.y = textarea_.w = textarea_.h = 0;
}
void loadscreen::set_progress(const int percentage, const std::string &text,
const bool commit)
@@ -115,15 +114,16 @@
surface const gdis = screen_.getSurface();
SDL_Rect area;
// Draw logo if it was succesfully loaded.
- if (logo_surface_ && !logo_drawn_) {
- area.x = (screen_.getx () - logo_surface_->w) / 2;
- area.y = ((scry - logo_surface_->h) / 2) - pbh;
- area.w = logo_surface_->w;
- area.h = logo_surface_->h;
+ if (!logo_surface_.null() && !logo_drawn_) {
+ SDL_Surface *logo = logo_surface_.get();
+ area.x = (screen_.getx () - logo->w) / 2;
+ area.y = ((scry - logo->h) / 2) - pbh;
+ area.w = logo->w;
+ area.h = logo->h;
// Check if we have enough pixels to display it.
if (area.x > 0 && area.y > 0) {
pby_offset_ = (pbh + area.h)/2;
- SDL_BlitSurface (logo_surface_, 0, gdis, &area);
+ SDL_BlitSurface (logo, 0, gdis, &area);
} else {
ERR_DISP << "loadscreen: Logo image is too big." <<
std::endl;
}
Modified: trunk/src/loadscreen.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/loadscreen.hpp?rev=34923&r1=34922&r2=34923&view=diff
==============================================================================
--- trunk/src/loadscreen.hpp (original)
+++ trunk/src/loadscreen.hpp Tue Apr 14 22:32:22 2009
@@ -22,6 +22,7 @@
#include "SDL.h"
#include "global.hpp"
+#include "sdl_utils.hpp"
#include <string>
@@ -35,9 +36,6 @@
~loadscreen()
{
dump_counters();
- if (logo_surface_) {
- SDL_FreeSurface (logo_surface_);
- }
}
/** Function to display a load progress bar. */
@@ -75,7 +73,7 @@
// Data members
CVideo &screen_;
SDL_Rect textarea_;
- SDL_Surface *logo_surface_;
+ surface logo_surface_;
bool logo_drawn_;
int pby_offset_;
int prcnt_;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits