00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "MyGUI_Precompiled.h"
00025 #include "MyGUI_RenderOut.h"
00026 #include "MyGUI_Utility.h"
00027
00028 #include "MyGUI_Gui.h"
00029 #include "MyGUI_FontManager.h"
00030 #include "MyGUI_LayerManager.h"
00031 #include "MyGUI_SkinManager.h"
00032 #include "MyGUI_StaticText.h"
00033
00034 namespace MyGUI
00035 {
00036 namespace implement
00037 {
00038
00039
00040 struct info
00041 {
00042 info() : num(0), count(1) { }
00043 info(size_t _num, const std::string& _line) : num(_num), count(1), line(_line) { }
00044
00045 size_t num;
00046 size_t count;
00047 std::string line;
00048 };
00049
00050 void render_out(const std::string& _value)
00051 {
00052
00053 typedef std::deque<info> DequeInfo;
00054
00055
00056 static size_t num = 0;
00057
00058 static DequeInfo lines;
00059
00060 const int offset = 10;
00061 const size_t count_lines = 20;
00062 static const std::string font = "DejaVuSans.14";
00063 static const std::string layer = "Statistic";
00064 static const std::string skin = "StaticText";
00065
00066 static StaticText* widget = nullptr;
00067 static StaticText* widget_shadow = nullptr;
00068
00069 if (widget == nullptr)
00070 {
00071 Gui * gui = Gui::getInstancePtr();
00072 if (gui == nullptr) return;
00073
00074 const IntSize& size = gui->getViewSize();
00075
00076 if (!LayerManager::getInstance().isExist(layer)) return;
00077 if (!SkinManager::getInstance().isExist(skin)) return;
00078
00079
00080 widget_shadow = gui->createWidget<StaticText>(skin, IntCoord(offset + 1, offset + 1, size.width - offset - offset, size.height - offset - offset), Align::Stretch, layer);
00081 widget_shadow->setNeedMouseFocus(false);
00082 widget_shadow->setTextAlign(Align::Default);
00083 widget_shadow->setTextColour(Colour::Black);
00084
00085 widget = gui->createWidget<StaticText>(skin, IntCoord(offset, offset, size.width - offset - offset, size.height - offset - offset), Align::Stretch, layer);
00086 widget->setNeedMouseFocus(false);
00087 widget->setTextAlign(Align::Default);
00088 widget->setTextColour(Colour::White);
00089
00090 if (FontManager::getInstance().getByName(font) != nullptr)
00091 {
00092 widget_shadow->setFontName(font);
00093 widget->setFontName(font);
00094 }
00095 }
00096
00097
00098 if (lines.empty())
00099 {
00100 lines.push_back(info(num++, _value));
00101
00102 }
00103
00104 else
00105 {
00106
00107 if (lines.back().line == _value) lines.back().count ++;
00108 else
00109 {
00110 lines.push_back(info(num++, _value));
00111
00112 if (lines.size() > count_lines) lines.pop_front();
00113 }
00114
00115 }
00116
00117
00118 std::string str_out;
00119 str_out.reserve(2048);
00120
00121 for (DequeInfo::iterator iter=lines.begin(); iter != lines.end(); ++iter)
00122 {
00123 str_out += utility::toString("[ ", (unsigned int)iter->num, (iter->count > 1) ? (" , " + utility::toString((unsigned int)iter->count)) : "", " ] ", iter->line, "\n");
00124 }
00125
00126
00127 widget_shadow->setCaption(str_out);
00128 widget->setCaption(str_out);
00129 }
00130 }
00131
00132 }