| 1 |
/* |
| 2 |
* Copyright (C) 2004 Ivo Danihelka ([email protected]) |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
*/ |
| 9 |
#include "StepDecor.h" |
| 10 |
|
| 11 |
#include "StepCounter.h" |
| 12 |
|
| 13 |
#include "Path.h" |
| 14 |
#include "StringTool.h" |
| 15 |
#include "OptionAgent.h" |
| 16 |
|
| 17 |
//----------------------------------------------------------------- |
| 18 |
StepDecor::StepDecor(const StepCounter *counter) |
| 19 |
: m_font(Path::dataReadPath("font/font_console.ttf"), 20) |
| 20 |
{ |
| 21 |
m_counter = counter; |
| 22 |
} |
| 23 |
//----------------------------------------------------------------- |
| 24 |
/** |
| 25 |
* Draw number of steps in right-top corner. |
| 26 |
*/ |
| 27 |
void |
| 28 |
StepDecor::drawOnScreen(const View * /*view*/, SDL_Surface *screen) |
| 29 |
{ |
| 30 |
static const SDL_Color COLOR_ORANGE = {255, 197, 102, 255}; |
| 31 |
static const SDL_Color COLOR_BLUE = {162, 244, 255, 255}; |
| 32 |
|
| 33 |
if (OptionAgent::agent()->getAsBool("show_steps")) { |
| 34 |
SDL_Color color; |
| 35 |
if (m_counter->isPowerful()) { |
| 36 |
color = COLOR_BLUE; |
| 37 |
} |
| 38 |
else { |
| 39 |
color = COLOR_ORANGE; |
| 40 |
} |
| 41 |
|
| 42 |
std::string steps = StringTool::toString(m_counter->getStepCount()); |
| 43 |
SDL_Surface *text_surface = m_font.renderTextOutlined(steps, color); |
| 44 |
|
| 45 |
SDL_Rect rect; |
| 46 |
rect.x = screen->w - text_surface->w; |
| 47 |
rect.y = 10; |
| 48 |
SDL_BlitSurface(text_surface, NULL, screen, &rect); |
| 49 |
SDL_FreeSurface(text_surface); |
| 50 |
} |
| 51 |
} |
| 52 |
|