From fe1aae79f001dcfa3551af1092a8c8263a71e821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boldizs=C3=A1r=20Lipka?= Date: Tue, 1 Jul 2014 21:06:04 +0200 Subject: [PATCH] Remove SDL2-specific parts from loadscreen. --- src/loadscreen.cpp | 102 --------------------------------------------- src/loadscreen.hpp | 8 ---- 2 files changed, 110 deletions(-) diff --git a/src/loadscreen.cpp b/src/loadscreen.cpp index d4b3fefd984a..e5da517b51d4 100644 --- a/src/loadscreen.cpp +++ b/src/loadscreen.cpp @@ -71,24 +71,15 @@ void loadscreen::global_loadscreen_manager::reset() loadscreen::loadscreen(CVideo &screen, const int percent): screen_(screen), textarea_(), -#if SDL_VERSION_ATLEAST(2,0,0) - logo_texture_(image::get_texture("misc/logo.png")), -#else #ifdef SDL_GPU logo_image_(NULL), #else logo_surface_(image::get_image("misc/logo.png")), -#endif #endif logo_drawn_(false), pby_offset_(0), prcnt_(percent) { -#if SDL_VERSION_ATLEAST(2,0,0) - if (logo_texture_.null()) { - ERR_DP << "loadscreen: Failed to load the logo" << std::endl; - } -#else #ifdef SDL_GPU surface surf = image::get_image("misc/logo.png"); logo_image_ = GPU_CopyImageFromSurface(surf); @@ -99,7 +90,6 @@ loadscreen::loadscreen(CVideo &screen, const int percent): if (logo_surface_.null()) { ERR_DP << "loadscreen: Failed to load the logo" << std::endl; } -#endif #endif textarea_.x = textarea_.y = textarea_.w = textarea_.h = 0; } @@ -131,93 +121,6 @@ void loadscreen::draw_screen(const std::string &text) // Height of the lighting line. int lightning_thickness = 2; -#if SDL_VERSION_ATLEAST(2,0,0) - sdl::twindow *wnd = CVideo::get_window(); - SDL_Renderer *rnd = SDL_GetRenderer(*wnd); - - SDL_Rect area; - - // Pump events and make sure to redraw the logo if there's a chance that it's been obscured - SDL_Event ev; - while(SDL_PollEvent(&ev)) { - if(ev.type == SDL_WINDOWEVENT - && (ev.window.event == SDL_WINDOWEVENT_RESIZED - || ev.window.event == SDL_WINDOWEVENT_EXPOSED)) - { - logo_drawn_ = false; - } - } - - // Draw logo if it was successfully loaded. - if (!logo_texture_.null() && !logo_drawn_) { - int x = (screen_.getx () - logo_texture_.width()) / 2; - int y = ((scry - logo_texture_.height()) / 2) - pbh; - - // Check if we have enough pixels to display it. - if (x > 0 && y > 0) { - pby_offset_ = (pbh + logo_texture_.height())/2; - wnd->draw(logo_texture_, x, y); - } else { - if (!screen_.faked()) { // Avoid error if --nogui is used. - ERR_DP << "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; - sdl::fill_rect(rnd,&area,bcr,bcg,bcb,255); - // Draw bottom border. - area.x = pbx; area.y = pby + pbh + bw + 2*bispw; - area.w = pbw + 2*(bw+bispw); area.h = bw; - sdl::fill_rect(rnd,&area,bcr,bcg,bcb,255); - // Draw left border. - area.x = pbx; area.y = pby + bw; - area.w = bw; area.h = pbh + 2*bispw; - sdl::fill_rect(rnd,&area,bcr,bcg,bcb,255); - // Draw right border. - area.x = pbx + pbw + bw + 2*bispw; area.y = pby + bw; - area.w = bw; area.h = pbh + 2*bispw; - sdl::fill_rect(rnd,&area,bcr,bcg,bcb,255); - // Draw the finished bar area. - area.x = pbx + bw + bispw; area.y = pby + bw + bispw; - area.w = (prcnt_ * pbw) / 100; area.h = pbh; - sdl::fill_rect(rnd,&area,fcr,fcg,fcb,255); - - SDL_Rect lightning = area; - lightning.h = lightning_thickness; - //we add 25% of white to the color of the bar to simulate a light effect - sdl::fill_rect(rnd,&lightning,(fcr*3+255)/4,(fcg*3+255)/4,(fcb*3+255)/4,255); - lightning.y = area.y+area.h-lightning.h; - //remove 50% of color to simulate a shadow effect - sdl::fill_rect(rnd,&lightning,fcr/2,fcg/2,fcb/2,255); - - // Draw the leftover bar area. - area.x = pbx + bw + bispw + (prcnt_ * pbw) / 100; area.y = pby + bw + bispw; - area.w = ((100 - prcnt_) * pbw) / 100; area.h = pbh; - sdl::fill_rect(rnd, &area, lcr, lcg, lcb, 255); - - // Clear the last text and draw new if text is provided. - if (!text.empty()) - { - sdl::fill_rect(rnd, &textarea_, 0, 0, 0, 255); - - font::ttext txt; - txt.set_text(text, false); - // A text-ure... haha, get it? - sdl::ttexture texture = txt.render_as_texture(); - textarea_.h = texture.height(); - textarea_.w = texture.width(); - textarea_.x = scrx/2 + bw + bispw - textarea_.w / 2; - textarea_.y = pby + pbh + 4*(bw + bispw); - wnd->draw(texture, textarea_.x, textarea_.y); - } - CVideo::get_window()->render(); -#else #ifdef SDL_GPU int x1, y1, x2, y2; @@ -412,14 +315,10 @@ void loadscreen::draw_screen(const std::string &text) update_rect(pbx, pby, pbw + 2*(bw + bispw), pbh + 2*(bw + bispw)); screen_.flip(); #endif -#endif } void loadscreen::clear_screen() { -#if SDL_VERSION_ATLEAST(2,0,0) - CVideo::get_window()->fill(0,0,0); -#else #ifdef SDL_GPU GPU_Clear(get_render_target()); #else @@ -432,7 +331,6 @@ void loadscreen::clear_screen() update_whole_screen(); screen_.flip(); #endif -#endif } loadscreen *loadscreen::global_loadscreen = 0; diff --git a/src/loadscreen.hpp b/src/loadscreen.hpp index bde8a342574d..0fc342c3a9d2 100644 --- a/src/loadscreen.hpp +++ b/src/loadscreen.hpp @@ -22,10 +22,6 @@ class CVideo; #include "sdl/utils.hpp" #include "sdl/gpu.hpp" -#if SDL_VERSION_ATLEAST(2,0,0) -#include "sdl/texture.hpp" -#endif - class loadscreen { public: // Preferred constructor @@ -79,14 +75,10 @@ class loadscreen { // Data members CVideo &screen_; SDL_Rect textarea_; -#if SDL_VERSION_ATLEAST(2,0,0) - sdl::ttexture logo_texture_; -#else #ifdef SDL_GPU GPU_Image *logo_image_; #else surface logo_surface_; -#endif #endif bool logo_drawn_; int pby_offset_;