00001
00002
00003
00004
00005
00006
00007
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
00026
00027 void
00028 StepDecor::drawOnScreen(const 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