fix CPU spike during intro splash screens
This commit is contained in:
@@ -42,7 +42,6 @@
|
||||
#include "tools/prefs.hpp"
|
||||
#include "dialogxml/widgets/button.hpp"
|
||||
#include "tools/enum_map.hpp"
|
||||
#include "tools/framerate_limiter.hpp"
|
||||
#include "tools/event_listener.hpp"
|
||||
#include "tools/drawable_manager.hpp"
|
||||
bool All_Done = false;
|
||||
@@ -358,12 +357,13 @@ void init_boe(int argc, char* argv[]) {
|
||||
init_screen_locs();
|
||||
init_startup();
|
||||
flushingInput = true;
|
||||
cFramerateLimiter fps_limiter;
|
||||
// Hidden preference to hide the startup logo - should be kept hidden
|
||||
if(get_bool_pref("ShowStartupLogo", true))
|
||||
show_logo();
|
||||
show_logo(fps_limiter);
|
||||
// The preference to hide the startup splash is exposed however.
|
||||
if(get_bool_pref("ShowStartupSplash", true))
|
||||
plop_fancy_startup();
|
||||
plop_fancy_startup(fps_limiter);
|
||||
|
||||
cUniverse::print_result = iLiving::print_result = add_string_to_buf;
|
||||
cPlayer::give_help = give_help;
|
||||
|
@@ -1,5 +1,6 @@
|
||||
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include "tools/framerate_limiter.hpp"
|
||||
|
||||
#ifdef __APPLE__
|
||||
extern eMenuChoice menuChoice;
|
||||
@@ -18,8 +19,8 @@ void incidental_noises(bool on_surface);
|
||||
void pause(short length);
|
||||
bool handle_startup_press(location the_point);
|
||||
void handle_splash_events();
|
||||
void show_logo();
|
||||
void plop_fancy_startup();
|
||||
void show_logo(cFramerateLimiter& framerate_limiter);
|
||||
void plop_fancy_startup(cFramerateLimiter& framerate_limiter);
|
||||
void update_terrain_animation();
|
||||
void update_startup_animation();
|
||||
void handle_events();
|
||||
|
@@ -128,12 +128,13 @@ bool handle_startup_press(location the_point) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void handle_splash_events() {
|
||||
void handle_splash_events(cFramerateLimiter& framerate_limiter) {
|
||||
sf::Event event;
|
||||
while(mainPtr.pollEvent(event)) {
|
||||
if(event.type == sf::Event::GainedFocus || event.type == sf::Event::MouseMoved)
|
||||
set_cursor(sword_curs);
|
||||
}
|
||||
framerate_limiter.frame_finished();
|
||||
}
|
||||
|
||||
static rectangle view_rect() {
|
||||
@@ -141,7 +142,7 @@ static rectangle view_rect() {
|
||||
return rectangle(0, 0, size.y, size.x);
|
||||
}
|
||||
|
||||
void show_logo() {
|
||||
void show_logo(cFramerateLimiter& framerate_limiter) {
|
||||
rectangle whole_window = view_rect();
|
||||
|
||||
if(get_int_pref("DisplayMode") != 5)
|
||||
@@ -156,17 +157,17 @@ void show_logo() {
|
||||
play_sound(-95);
|
||||
while(sound_going(95)) {
|
||||
draw_splash(pict_to_draw, mainPtr, logo_from);
|
||||
handle_splash_events();
|
||||
handle_splash_events(framerate_limiter);
|
||||
}
|
||||
if(!get_int_pref("ShowStartupSplash", true)) {
|
||||
sf::Time delay = time_in_ticks(60);
|
||||
sf::Clock timer;
|
||||
while(timer.getElapsedTime() < delay)
|
||||
handle_splash_events();
|
||||
handle_splash_events(framerate_limiter);
|
||||
}
|
||||
}
|
||||
|
||||
void plop_fancy_startup() {
|
||||
void plop_fancy_startup(cFramerateLimiter& framerate_limiter) {
|
||||
rectangle whole_window = view_rect();
|
||||
|
||||
float ui_scale = get_float_pref("UIScale", 1.0);
|
||||
@@ -182,7 +183,7 @@ void plop_fancy_startup() {
|
||||
|
||||
while(timer.getElapsedTime() < delay) {
|
||||
draw_splash(pict_to_draw, mainPtr, intro_from);
|
||||
handle_splash_events();
|
||||
handle_splash_events(framerate_limiter);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user