|
From: Lasse Kärkkäi. <tr...@us...> - 2011-10-22 19:36:37
|
Author: Tapio Vierros <tap...@gm...>
Date: Tue Aug 23 19:05:43 2011 +0300
Fixed loading screen rendering.
---
game/screen.hh | 3 +++
game/screenmanager.cc | 14 +++++++++-----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/game/screen.hh b/game/screen.hh
index 1ea4fbd..64d3e29 100644
--- a/game/screen.hh
+++ b/game/screen.hh
@@ -62,6 +62,8 @@ class ScreenManager: public Singleton <ScreenManager> {
/// Draw a loading progress indication
void loading(std::string const& message, float progress);
+ /// Internal rendering function for loading indicator
+ void drawLoading();
/// Draw an error notification and quit
void fatalError(std::string const& message);
/// Set a message to flash in current screen
@@ -97,6 +99,7 @@ class ScreenManager: public Singleton <ScreenManager> {
std::string m_message;
AnimValue m_messagePopup;
SvgTxtTheme m_textMessage;
+ float m_loadingProgress;
Surface m_logo;
AnimValue m_logoAnim;
// Dialog members
diff --git a/game/screenmanager.cc b/game/screenmanager.cc
index 6087d2c..5b289b8 100644
--- a/game/screenmanager.cc
+++ b/game/screenmanager.cc
@@ -16,7 +16,7 @@ ScreenManager::ScreenManager(Window& _window):
m_window(_window), m_finished(false), newScreen(), currentScreen(),
m_timeToFadeIn(), m_timeToFadeOut(), m_timeToShow(), m_message(),
m_messagePopup(0.0, 1.0), m_textMessage(getThemePath("message_text.svg"), config["graphic/text_lod"].f()),
- m_logo(getThemePath("logo.svg")), m_logoAnim(0.0, 0.5)
+ m_loadingProgress(0.0f), m_logo(getThemePath("logo.svg")), m_logoAnim(0.0, 0.5)
{
m_textMessage.dimensions.middle().center(-0.05);
}
@@ -49,23 +49,27 @@ void ScreenManager::drawScreen() {
drawNotifications();
}
-
void ScreenManager::loading(std::string const& message, float progress) {
// TODO: Create a better one, this is quite ugly
flashMessage(message + " " + boost::lexical_cast<std::string>(int(round(progress*100))) + "%", 0.0f, 1.0f, 1.0f);
+ m_loadingProgress = progress;
m_window.blank();
+ m_window.render(boost::bind(&ScreenManager::drawLoading, this));
+ m_window.swap();
+}
+
+void ScreenManager::drawLoading() {
drawLogo();
drawNotifications();
const int maxi = 20;
const float x = 0.3;
const float spacing = 0.01;
const float sq_size = (2*x - (maxi-1)*spacing) / maxi;
- for (int i = 0; i <= progress * maxi; ++i) {
- ColorTrans c(Color(0.2f, 0.7f, 0.7f, (progress + 1)*0.5f));
+ for (int i = 0; i <= m_loadingProgress * maxi; ++i) {
+ ColorTrans c(Color(0.2f, 0.7f, 0.7f, (m_loadingProgress + 1)*0.5f));
UseShader shader(getShader("color"));
glutil::Square(-x + i * (sq_size + spacing), 0, sq_size/2, true);
}
- m_window.swap();
}
void ScreenManager::fatalError(std::string const& message) {
|