Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

StepDecor.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  */
00009 #include "StepDecor.h"
00010 
00011 #include "StepCounter.h"
00012 
00013 #include "Path.h"
00014 #include "StringTool.h"
00015 #include "OptionAgent.h"
00016 
00017 //-----------------------------------------------------------------
00018 StepDecor::StepDecor(const StepCounter *counter)
00019     : m_font(Path::dataReadPath("font/font_console.ttf"), 20)
00020 {
00021     m_counter = counter;
00022 }
00023 //-----------------------------------------------------------------
00024 /**
00025  * Draw number of steps in right-top corner.
00026  */
00027 void
00028 StepDecor::drawOnScreen(const View * /*view*/, SDL_Surface *screen)
00029 {
00030     static const SDL_Color COLOR_ORANGE = {255, 197, 102, 255};
00031     static const SDL_Color COLOR_BLUE = {162, 244, 255, 255};
00032 
00033     if (OptionAgent::agent()->getAsBool("show_steps")) {
00034         SDL_Color color;
00035         if (m_counter->isPowerful()) {
00036             color = COLOR_BLUE;
00037         }
00038         else {
00039             color = COLOR_ORANGE;
00040         }
00041 
00042         std::string steps = StringTool::toString(m_counter->getStepCount());
00043         SDL_Surface *text_surface = m_font.renderTextOutlined(steps, color);
00044 
00045         SDL_Rect rect;
00046         rect.x = screen->w - text_surface->w;
00047         rect.y = 10;
00048         SDL_BlitSurface(text_surface, NULL, screen, &rect);
00049         SDL_FreeSurface(text_surface);
00050     }
00051 }
00052 

Generated on Wed Jun 1 09:54:31 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2