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 "SolverDrawer.h" 00010 00011 #include "Log.h" 00012 #include "Path.h" 00013 #include "Font.h" 00014 #include "Labels.h" 00015 #include "LevelStatus.h" 00016 #include "WiPara.h" 00017 #include "BaseException.h" 00018 00019 //----------------------------------------------------------------- 00020 /** 00021 * Prepares to draw info about best solver. 00022 * @param status shared level status 00023 */ 00024 SolverDrawer::SolverDrawer(LevelStatus *status) 00025 { 00026 try { 00027 Font usedFont(Path::dataReadPath("font/font_menu.ttf"), 14); 00028 SDL_Color usedColor = {255, 255, 255, 255}; 00029 00030 Labels labels(Path::dataReadPath("script/labels.lua")); 00031 const char *labelName; 00032 switch (status->compareToBest()) { 00033 case 1: 00034 labelName = "solver_better"; 00035 break; 00036 case 0: 00037 labelName = "solver_equals"; 00038 break; 00039 default: 00040 labelName = "solver_worse"; 00041 } 00042 StringTool::t_args args; 00043 args.push_back(""); 00044 args.push_back(StringTool::toString(status->getBestMoves())); 00045 args.push_back(status->getBestAuthor()); 00046 00047 WiPara *para = new WiPara( 00048 labels.getFormatedLabel(labelName, args), 00049 usedFont, usedColor); 00050 para->enableCentered(); 00051 para->recenter(); 00052 addWidget(para); 00053 } 00054 catch (BaseException &e) { 00055 LOG_WARNING(e.info()); 00056 } 00057 } 00058