patch #542 by kvasir, and modded by myself to be centered
This commit is contained in:
parent
13f3cfb817
commit
f3b6fb5e89
2 changed files with 50 additions and 9 deletions
|
@ -15,7 +15,7 @@
|
|||
#include "font.hpp"
|
||||
#include "marked-up_text.hpp"
|
||||
|
||||
//#include <iostream>
|
||||
#include <iostream>
|
||||
|
||||
#define MIN_PERCENTAGE 0
|
||||
#define MAX_PERCENTAGE 100
|
||||
|
@ -35,10 +35,27 @@ void loadscreen::set_progress(const int percentage, const std::string &text, con
|
|||
int scry = screen_.gety() - 2*(bw+bispw); /* Available height. */
|
||||
int pbw = scrx/2; /* Used width. */
|
||||
int pbh = scry/16; /* Used heigth. */
|
||||
int pbx = (scrx - pbw)/2; /* Horizontal location. */
|
||||
int pby = (scry - pbh)/2; /* Vertical location. */
|
||||
surface const gdis = screen_.getSurface();
|
||||
SDL_Rect area;
|
||||
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;
|
||||
/* 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);
|
||||
}
|
||||
else {
|
||||
std::cerr << "loadscreen: Logo image is too big." << std::endl;
|
||||
}
|
||||
logo_drawn_ = true;
|
||||
}
|
||||
int pbx = (scrx - pbw)/2; /* Horizontal location. */
|
||||
int pby = (scry - pbh)/2 + pby_offset_; /* Vertical location. */
|
||||
|
||||
/* Draw top border. */
|
||||
area.x = pbx; area.y = pby;
|
||||
area.w = pbw + 2*(bw+bispw); area.h = bw;
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
See the COPYING file for more details.
|
||||
*/
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL.h"
|
||||
#include "SDL_image.h"
|
||||
|
||||
#include "font.hpp"
|
||||
#include "video.hpp"
|
||||
|
@ -28,10 +29,27 @@ class loadscreen {
|
|||
filesystem_counter(0),
|
||||
binarywml_counter(0),
|
||||
setconfig_counter(0),
|
||||
parser_counter(0),
|
||||
screen_(screen), prcnt_(percent)
|
||||
parser_counter(0),
|
||||
screen_(screen),
|
||||
logo_drawn_(false),
|
||||
pby_offset_(0),
|
||||
prcnt_(percent)
|
||||
{
|
||||
/* Nothing. */
|
||||
#ifdef WESNOTH_PATH
|
||||
const char *path = WESNOTH_PATH;
|
||||
#else
|
||||
const char *path = ".";
|
||||
#endif
|
||||
size_t sl = strlen (path);
|
||||
char *sp = new char [sl + 21u + 1u];
|
||||
sp [0] = '\0';
|
||||
strncat (sp, path, sl);
|
||||
strncat (sp, "/images/misc/logo.png", 21u);
|
||||
logo_surface_ = IMG_Load (sp);
|
||||
if (!logo_surface_) {
|
||||
std::cerr << "loadscreen: Failed to load the logo: " << sp << std::endl;
|
||||
}
|
||||
delete sp;
|
||||
}
|
||||
// Keep default copy constructor
|
||||
// Keep default copy assignment
|
||||
|
@ -42,6 +60,9 @@ class loadscreen {
|
|||
std::cerr << "loadscreen: binarywml counter = " << binarywml_counter << std::endl;
|
||||
std::cerr << "loadscreen: setconfig counter = " << setconfig_counter << std::endl;
|
||||
std::cerr << "loadscreen: parser counter = " << parser_counter << std::endl;
|
||||
if (logo_surface_) {
|
||||
SDL_FreeSurface (logo_surface_);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to display a load progress bar.
|
||||
|
@ -66,7 +87,10 @@ class loadscreen {
|
|||
|
||||
// Data members
|
||||
CVideo &screen_;
|
||||
SDL_Rect textarea_;
|
||||
SDL_Rect textarea_;
|
||||
SDL_Surface *logo_surface_;
|
||||
bool logo_drawn_;
|
||||
int pby_offset_;
|
||||
int prcnt_;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue