From d702a2c33b975a4763f6831a0ba5d8fce110c8f9 Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Sun, 26 Jun 2011 20:00:04 +0300 Subject: Made the initial loading screen slightly more alive --- src/game.cpp | 77 ++++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 52 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/game.cpp b/src/game.cpp index 3197985e6..55ae6686e 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -639,6 +639,34 @@ void update_skybox(video::IVideoDriver* driver, } } +/* + Draws a screen with a single text on it. + Text will be removed when the screen is drawn the next time. +*/ +/*gui::IGUIStaticText **/ +void draw_load_screen(const std::wstring &text, + video::IVideoDriver* driver, gui::IGUIFont* font) +{ + v2u32 screensize = driver->getScreenSize(); + const wchar_t *loadingtext = text.c_str(); + core::vector2d textsize_u = font->getDimension(loadingtext); + core::vector2d textsize(textsize_u.X,textsize_u.Y); + core::vector2d center(screensize.X/2, screensize.Y/2); + core::rect textrect(center - textsize/2, center + textsize/2); + + gui::IGUIStaticText *guitext = guienv->addStaticText( + loadingtext, textrect, false, false); + guitext->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); + + driver->beginScene(true, true, video::SColor(255,0,0,0)); + guienv->drawAll(); + driver->endScene(); + + guitext->remove(); + + //return guitext; +} + void the_game( bool &kill, bool random_input, @@ -655,6 +683,9 @@ void the_game( { video::IVideoDriver* driver = device->getVideoDriver(); scene::ISceneManager* smgr = device->getSceneManager(); + + // Calculate text height using the font + u32 text_height = font->getDimension(L"Random test string").Height; v2u32 screensize(0,0); v2u32 last_screensize(0,0); @@ -674,20 +705,10 @@ void the_game( /* Draw "Loading" screen */ - const wchar_t *loadingtext = L"Loading and connecting..."; - u32 text_height = font->getDimension(loadingtext).Height; - core::vector2d center(screensize.X/2, screensize.Y/2); - core::vector2d textsize(300, text_height); - core::rect textrect(center - textsize/2, center + textsize/2); - - gui::IGUIStaticText *gui_loadingtext = guienv->addStaticText( - loadingtext, textrect, false, false); - gui_loadingtext->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_UPPERLEFT); - - driver->beginScene(true, true, video::SColor(255,0,0,0)); - guienv->drawAll(); - driver->endScene(); + /*gui::IGUIStaticText *gui_loadingtext = */ + //draw_load_screen(L"Loading and connecting...", driver, font); + draw_load_screen(L"Loading...", driver, font); /* Create server. @@ -695,6 +716,7 @@ void the_game( */ SharedPtr server; if(address == ""){ + draw_load_screen(L"Creating server...", driver, font); std::cout<start(port); @@ -704,9 +726,11 @@ void the_game( Create client */ + draw_load_screen(L"Creating client...", driver, font); std::cout<remove(); + //gui_loadingtext->remove(); return; } @@ -753,11 +777,17 @@ void the_game( { break; } + + std::wostringstream ss; + ss<beginScene(true, true, video::SColor(255,0,0,0)); guienv->drawAll(); - driver->endScene(); + driver->endScene();*/ // Update client and server @@ -787,7 +817,7 @@ void the_game( error_message = L"Connection timed out."; std::cout<remove(); + //gui_loadingtext->remove(); return; } @@ -849,7 +879,7 @@ void the_game( Move into game */ - gui_loadingtext->remove(); + //gui_loadingtext->remove(); /* Add some gui stuff @@ -2254,15 +2284,12 @@ void the_game( generator and other stuff quits */ { - const wchar_t *shuttingdowntext = L"Shutting down stuff..."; - gui::IGUIStaticText *gui_shuttingdowntext = guienv->addStaticText( - shuttingdowntext, textrect, false, false); - gui_shuttingdowntext->setTextAlignment(gui::EGUIA_CENTER, - gui::EGUIA_UPPERLEFT); - driver->beginScene(true, true, video::SColor(255,0,0,0)); + /*gui::IGUIStaticText *gui_shuttingdowntext = */ + draw_load_screen(L"Shutting down stuff...", driver, font); + /*driver->beginScene(true, true, video::SColor(255,0,0,0)); guienv->drawAll(); driver->endScene(); - gui_shuttingdowntext->remove(); + gui_shuttingdowntext->remove();*/ } } -- cgit v1.2.3