home *** CD-ROM | disk | FTP | other *** search
- #include "LoadingMenu.h"
-
- #include "Gui.h"
- #include "TextureHandler.h"
- #include "Display.h"
- #include "Renderer.h"
- #include "ConsoleFrontEnd.h"
-
- LoadingMenu::LoadingMenu():Menu("LoadingMenu"){
- backgroundTexture=TextureHandler::getTexture("gui/menu/loading_menu_background.jpg");
- centerTexture=NULL;
- statusBarString=NULL;
- heading=NULL;
- subHeading=NULL;
- drawScoreboard = false;
-
- allowConsole = true;
- }
-
- LoadingMenu::~LoadingMenu(){
- if(backgroundTexture!=NULL)
- TextureHandler::releaseTexture(backgroundTexture);
-
- if( heading != NULL )
- delete heading;
-
- if( subHeading != NULL )
- delete subHeading;
-
- if( statusBarString != NULL )
- delete statusBarString;
-
- }
-
- bool LoadingMenu::open(){
- if( heading != NULL )
- delete heading;
-
- if( subHeading != NULL )
- delete subHeading;
-
- if( statusBarString != NULL )
- delete statusBarString;
-
- centerTexture=NULL;
- statusBarString=NULL;//"loading...";
- heading=NULL;
- subHeading=NULL;
- drawScoreboard = false;
- return Menu::open();
- }
-
- bool LoadingMenu::close(){
- if( heading != NULL )
- delete heading;
-
- if( subHeading != NULL )
- delete subHeading;
-
- if( statusBarString != NULL )
- delete statusBarString;
-
- centerTexture=NULL;
- statusBarString=NULL;//"loading...";
- heading=NULL;
- subHeading=NULL;
- drawScoreboard = false;
- return Menu::close();
- }
-
- void LoadingMenu::updateStatusBar(const char* string){
- if( statusBarString != NULL )
- delete statusBarString;
-
- statusBarString = newString(string);
-
- if(opened)
- draw();
-
- }
-
- void LoadingMenu::update(){
- if(opened)
- draw();
- }
-
- void LoadingMenu::updateCenterTexture(Texture* tex){
- centerTexture=tex;
- }
-
- void LoadingMenu::updateHeading(const char* string){
- if( heading != NULL )
- delete heading;
-
- heading = newString( string );
-
- if(opened)
- draw();
- }
-
- void LoadingMenu::updateSubHeading(const char* string){
- if( subHeading != NULL )
- delete subHeading;
-
- subHeading = newString( string );
-
- if(opened)
- draw();
- }
- /*
- void LoadingMenu::updateSubHeading(const char* formatString, ...){
- va_list ap;
- char toStringBuffer[128];
-
- va_start (ap, formatString);
- _vsnprintf(toStringBuffer, 128, formatString, ap);
- va_end(ap);
- toStringBuffer[127]='\0';
-
- this->subHeading=string;
- if(opened)
- draw();
- }
- */
- void LoadingMenu::draw(){
- glClear(GL_COLOR_BUFFER_BIT);
-
- Renderer::beginDrawing();
-
- drawBackground();
- if(centerTexture!=NULL)
- drawCenterTexture();
-
- if(statusBarString!=NULL)
- drawStatusBar();
-
- if(heading!=NULL)
- drawHeading();
-
- if(subHeading!=NULL)
- drawSubHeading();
-
-
- // console lines
-
- texFont_t* font=Gui::info.var.menu_tinyFont;
- // int height=70;
- int i;
- int n=7;
- #ifdef _DEBUG
- n=55;
- #endif
- int y=5;
-
- for(i=0; i<n; i++){
- if(console->lines[i]==NULL){
- y += (int)( font->height );
- continue;
- }
- glColor4fv(Gui::info.var.menu_normalColor);
- drawString(10, y, font, console->lines[i]);
- y += (int)( font->height );
- }
-
-
- // console lines end
-
- if( drawScoreboard )
- Gui::hud->scoreboard->draw();
-
- Renderer::endDrawing();
-
- if(allowConsole && consoleFrontEnd->isActive){
- consoleFrontEnd->draw();
- }
-
- SDL_GL_SwapBuffers();
- }
-
- void LoadingMenu::drawBackground(){
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- Renderer::drawTexturedQuad(0, 0, DISPLAY_VSCREEN_WIDTH, DISPLAY_VSCREEN_HEIGHT, backgroundTexture);
- }
-
- void LoadingMenu::drawCenterTexture(){
- int x1=(int)( (229) );
- int x2=(int)( (571) );
- int y1=(int)( (212) );
- int y2=(int)( (532) );
-
- glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- Renderer::drawTexturedQuad(x1, y1, x2, y2, centerTexture);
- }
-
- void LoadingMenu::drawStatusBar(){
- glColor4fv(Gui::info.var.menu_activeColor);
- drawScaledAndAlignedString(400, 110, 0.9f, 0.9f, Gui::info.var.menu_bigFont, TEXT_ALIGN_CENTER, statusBarString);
- }
-
- void LoadingMenu::drawHeading(){
- glColor4fv(Gui::info.var.menu_activeColor);
- drawShadowedFormatString(398, 553, 0.9f, 3, Gui::info.var.menu_bigFont, TEXT_ALIGN_CENTER, ">> %s <<", heading);
- }
-
- void LoadingMenu::drawSubHeading(){
- glColor4fv(Gui::info.var.menu_activeColor);
- drawShadowedFormatString(400, 538, 0.8f, 2, Gui::info.var.menu_smallFont, TEXT_ALIGN_CENTER, "(%s)", subHeading);
- }
-