From c55945a1e81f5e49ef706cb3d0d37f17dbb84709 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 12 Jan 2009 18:38:48 +0000 Subject: Improved loader message --- src/client/client.cc | 8 +++-- src/client/video.cc | 96 +++++++++++++++++++++++++++++++--------------------- src/client/video.h | 9 +++-- 3 files changed, 69 insertions(+), 44 deletions(-) (limited to 'src') diff --git a/src/client/client.cc b/src/client/client.cc index 6611bb2..66feecf 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -254,7 +254,8 @@ void Client::shutdown() void Client::notify_connect() { - video::frame_loading("Connecting..."); + video::set_loader_message("Loading..."); + video::frame_loader(); view()->notify()->clear(); view()->chat()->clear(); @@ -277,6 +278,9 @@ void Client::notify_disconnect() void Client::notify_zonechange() { + video::set_loader_message("Loading..."); + video::frame_loader(); + // unload entity sounds for (core::Entity::Registry::iterator it = core::Entity::registry().begin(); it != core::Entity::registry().end(); it++) { core::Entity *entity = (*it).second; @@ -339,7 +343,7 @@ void Client::notify_message(const core::Message::Channel channel, const std::str } void Client::notify_loader(const std::string &message) { - video::loader_message(message.c_str()); + video::set_loader_message(message.c_str()); } //--- engine functions -------------------------------------------- diff --git a/src/client/video.cc b/src/client/video.cc index 892f1a6..b4ee70e 100644 --- a/src/client/video.cc +++ b/src/client/video.cc @@ -10,11 +10,13 @@ #include "client/client.h" #include "client/targets.h" #include "render/render.h" +#include "render/gl.h" #include "core/core.h" #include "core/gameserver.h" #include "filesystem/filesystem.h" #include "sys/sys.h" #include "ui/ui.h" +#include "ui/paint.h" #include @@ -33,7 +35,6 @@ core::Cvar *draw_stats = 0; core::Cvar *draw_devinfo = 0; core::Cvar *draw_keypress = 0; - namespace video { float fullscreen = 0; @@ -50,7 +51,8 @@ int height_prev = 0; const int width_default = 1024; const int height_default = 768; -bool is_loader_frame = false; +std::string loader_message; +bool is_loading = false; bool init() { @@ -274,76 +276,92 @@ void set_cursor() } } -void loader_message(const char *message) +void set_loader_message(const std::string message) { - if (!is_loader_frame) - return; - - frame_loading(message); + loader_message.assign(message); + + if (is_loading) + frame_loader(); } -void frame_loading(const char *message) +void set_loader_message(const char *message) { - using namespace render; - - is_loader_frame = true; + if (message) + loader_message.assign(message); + else + loader_message.clear(); + + if (is_loading) + frame_loader(); +} - // Clear the color and depth buffers. - gl::clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); +void draw_loader() +{ render::Camera::ortho(); - - gl::enable(GL_TEXTURE_2D); + gl::enable(GL_BLEND); gl::color(1.0f, 1.0f, 1.0f, 1.0f); - render::Textures::load("bitmaps/banner"); - gl::begin(gl::Quads); - - gl::vertex(0, 0); - gl::vertex(0, render::State::height()); - gl::vertex(render::State::width(), render::State::height()); - gl::vertex(render::State::width(), 0); - gl::end(); + math::Vector2f pos; + math::Vector2f size(render::State::width(), render::State::height()); + ui::paint::bitmap(pos, size, "banner"); - - if (message) { + if (loader_message.size()) { + using render::Text; + gl::enable(GL_TEXTURE_2D); Text::setfont("gui", 12, 18); Text::setcolor('N'); //set normal color - Text::draw(Text::fontwidth(), Text::fontheight(), message); + Text::draw(Text::fontwidth(), Text::fontheight(), loader_message); + gl::disable(GL_TEXTURE_2D); } - gl::disable(GL_TEXTURE_2D); gl::disable(GL_BLEND); + +} + +void frame_loader() +{ + // Clear the color and depth buffers. + gl::clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + draw_loader(); + + is_loading = true; SDL_GL_SwapBuffers(); } void frame(float elapsed) { - is_loader_frame = false; - // detect fullscreen/windowed mode switch if (fullscreen != r_fullscreen->value()) restart(); using namespace render; + is_loading = false; + // Clear the color and depth buffers. gl::clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); render::Stats::clear(); + if (core::application()->connected()) { + + if (core::game()->time() && core::localplayer()->zone()) { + render::Camera::frame(elapsed); + render::Camera::frustum(); - if (core::application()->connected() && core::game()->time() && core::localplayer()->zone()) { - render::Camera::frame(elapsed); - render::Camera::frustum(); - - render::draw(elapsed); // draw the world - targets::frame(); // validate current target, render sound - - if (!core::localplayer()->view() && targets::current()) // draw target docks etc - render::draw_target(targets::current()); + render::draw(elapsed); // draw the world + targets::frame(); // validate current target, render sound - render::Camera::ortho(); + if (!core::localplayer()->view() && targets::current()) // draw target docks etc + render::draw_target(targets::current()); + render::Camera::ortho(); + + } else { + draw_loader(); + } + } else { render::Camera::ortho(); } diff --git a/src/client/video.h b/src/client/video.h index 80762ae..3ba3ad2 100644 --- a/src/client/video.h +++ b/src/client/video.h @@ -33,10 +33,13 @@ namespace video void frame(float elapsed); /// draw the loader screen - void frame_loading(const char *message); + void frame_loader(); - /// update the loader screen - void loader_message(const char *message); + /// update the loader screen message + void set_loader_message(const std::string message); + + /// update the loader screen message + void set_loader_message(const char *message); /// set the window caption void set_caption(); -- cgit v1.2.3