| 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 "SolverDrawer.h" |
| 10 |
|
| 11 |
#include "Log.h" |
| 12 |
#include "Path.h" |
| 13 |
#include "Font.h" |
| 14 |
#include "Labels.h" |
| 15 |
#include "LevelStatus.h" |
| 16 |
#include "WiPara.h" |
| 17 |
#include "BaseException.h" |
| 18 |
|
| 19 |
//----------------------------------------------------------------- |
| 20 |
/** |
| 21 |
* Prepares to draw info about best solver. |
| 22 |
* @param status shared level status |
| 23 |
*/ |
| 24 |
SolverDrawer::SolverDrawer(LevelStatus *status) |
| 25 |
{ |
| 26 |
try { |
| 27 |
Font usedFont(Path::dataReadPath("font/font_menu.ttf"), 14); |
| 28 |
SDL_Color usedColor = {255, 255, 255, 255}; |
| 29 |
|
| 30 |
Labels labels(Path::dataReadPath("script/labels.lua")); |
| 31 |
const char *labelName; |
| 32 |
switch (status->compareToBest()) { |
| 33 |
case 1: |
| 34 |
labelName = "solver_better"; |
| 35 |
break; |
| 36 |
case 0: |
| 37 |
labelName = "solver_equals"; |
| 38 |
break; |
| 39 |
default: |
| 40 |
labelName = "solver_worse"; |
| 41 |
} |
| 42 |
StringTool::t_args args; |
| 43 |
args.push_back(""); |
| 44 |
args.push_back(StringTool::toString(status->getBestMoves())); |
| 45 |
args.push_back(status->getBestAuthor()); |
| 46 |
|
| 47 |
WiPara *para = new WiPara( |
| 48 |
labels.getFormatedLabel(labelName, args), |
| 49 |
usedFont, usedColor); |
| 50 |
para->enableCentered(); |
| 51 |
para->recenter(); |
| 52 |
addWidget(para); |
| 53 |
} |
| 54 |
catch (BaseException &e) { |
| 55 |
LOG_WARNING(e.info()); |
| 56 |
} |
| 57 |
} |
| 58 |
|