1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
#include <precomp.h>
#include "xuistats.h"
#include <tataki/canvas/ifc_canvas.h>
#include <tataki/color/skinclr.h>
#include <api.h>
#include <api/imgldr/imgldr.h>
#include <api/skin/skinparse.h>
#include <api/skin/gammamgr.h>
#include <api/skin/skinelem.h>
#include <api/skin/regioncache.h>
#include <api/wnd/wndtrack.h>
#include <api/font/font.h>
#include <api/wnd/wndapi.h>
#include <api/skin/guitree.h>
#include <api/xml/xmlreader.h>
#include <api/skin/groupwndcreate.h>
#include <api/skin/groupmgr.h>
#include <api/script/script.h>
#include "bfc/ptrlist.h"
#include "bfc/memblock.h"
// -----------------------------------------------------------------------
const wchar_t XuiStatsXuiObjectStr[] = L"Wasabi:Stats"; // This is the xml tag
char XuiStatsXuiSvcName[] = "Wasabi:Stats xui object";
// -----------------------------------------------------------------------
XuiStats::XuiStats() {
hastimer = 0;
line = 0;
col = 0;
curcanvas = NULL;
}
// -----------------------------------------------------------------------
XuiStats::~XuiStats() {
if (hastimer)
killTimer(0x10);
}
// -----------------------------------------------------------------------
int XuiStats::onInit() {
XUISTATS_PARENT::onInit();
return 1;
}
// -----------------------------------------------------------------------
#define MARGIN 10
#define FONTSIZE 15
#define LINEMUL 15
#define COLMUL 200
void XuiStats::doTextOut(Canvas *canvas, const wchar_t *text, int line, int col, const Wasabi::FontInfo *fontInfo)
{
RECT r;
getClientRect(&r);
if (!canvas || !text || !*text) return;
canvas->textOutEllipsed(r.left+MARGIN+col*COLMUL, r.top+MARGIN+line*LINEMUL, COLMUL-MARGIN/2, LINEMUL, text, fontInfo);
}
// -----------------------------------------------------------------------
void XuiStats::addLine(const wchar_t *txt, const Wasabi::FontInfo *fontInfo)
{
if (!curcanvas) return;
RECT r;
getClientRect(&r);
if (line * LINEMUL + MARGIN + FONTSIZE + r.top > r.bottom)
{ col++; line = 0; if (*txt == 0) return; }
doTextOut(curcanvas, txt, line++, col, fontInfo);
}
// -----------------------------------------------------------------------
int XuiStats::onPaint(Canvas *canvas)
{
XUISTATS_PARENT::onPaint(canvas);
curcanvas = canvas;
line = 0;
col = 0;
Wasabi::FontInfo fontInfo;
fontInfo.face = wasabi_default_fontnameW;
fontInfo.pointSize = FONTSIZE;
fontInfo.color = SkinColor(L"wasabi.list.text");
addLine(L"---------------------------- System ------", &fontInfo);
//addLine( StringPrintfW(L"entries in ptrlists : %d", ptrlist_totalnitems) );
#ifdef _DEBUG
addLine( StringPrintfW(L"total memblocks size : %d", memblocks_totalsize) , &fontInfo);
#endif
// TODO: add to api_timer - addLine( StringPrintfW(L"timers : %d/%d", mainmultiplex->getNumTimers(), mainmultiplex->getNumTimersLP()) , &fontInfo);
addLine(L"", &fontInfo);
addLine(L"----------------------------- Wnds -------", &fontInfo);
addLine( StringPrintfW(L"rootwnds : %d", windowTracker->getNumAllWindows()) , &fontInfo);
addLine( StringPrintfW(L"desktop rootwnds : %d", windowTracker->getNumWindows()) , &fontInfo);
addLine(L"", &fontInfo);
addLine(L"--------------------------- ImgLdr -------", &fontInfo);
addLine( StringPrintfW(L"bytes in imgldr : %d", imageLoader::getMemUsage()) , &fontInfo);
addLine( StringPrintfW(L"cached imgldr entries : %d", imageLoader::getNumCached()) , &fontInfo);
addLine( StringPrintfW(L"region caches : %d", RegionCache::getNumCaches()) , &fontInfo);
addLine(L"", &fontInfo);
addLine(L"----------------------------- Skin -------", &fontInfo);
addLine( StringPrintfW(L"skin bitmap elements : %d", WASABI_API_PALETTE->getNumBitmapElement()) , &fontInfo);
addLine( StringPrintfW(L"skin color elements : %d", WASABI_API_PALETTE->getNumColorElements()) , &fontInfo);
addLine( StringPrintfW(L"containers loaded : %d", SkinParser::getNumContainers()) , &fontInfo);
addLine( StringPrintfW(L"gamma sets : %d", WASABI_API_COLORTHEMES->getNumGammaSets()) , &fontInfo);
addLine( StringPrintfW(L"fonts : %d", Font::getNumFonts()) , &fontInfo);
addLine( StringPrintfW(L"base textures : %d", WndApi::getNumBaseTextures()) , &fontInfo);
addLine( StringPrintfW(L"guitree entries : %d", guiTree->getNumObject()) , &fontInfo);
addLine( StringPrintfW(L"wndtype groups : %d", GroupWndCreateSvc::num_group_list) , &fontInfo);
addLine( StringPrintfW(L"hosted groups : %d", GroupMgr::getNumGroups()) , &fontInfo);
addLine( StringPrintfW(L"scripts : %d", Script::getNumScripts()) , &fontInfo);
addLine(L"", &fontInfo);
addLine(L"----------------------------- Misc -------", &fontInfo);
addLine( StringPrintfW(L"registered cfgitems : %d", WASABI_API_CONFIG->config_getNumCfgItems()) , &fontInfo);
if (WASABI_API_THREADPOOL)
{
addLine(L"", &fontInfo);
addLine(L"----------------------------- ThreadPool -------", &fontInfo);
addLine( StringPrintfW(L"active threads : %d", WASABI_API_THREADPOOL->GetNumberOfActiveThreads()) , &fontInfo);
addLine( StringPrintfW(L"threads in pool : %d", WASABI_API_THREADPOOL->GetNumberOfThreads()) , &fontInfo);
}
curcanvas = NULL;
return 1;
}
// -----------------------------------------------------------------------
void XuiStats::onSetVisible(int show) {
XUISTATS_PARENT::onSetVisible(show);
if (show) {
setTimer(0x10, 250);
} else {
killTimer(0x10);
}
hastimer = show;
}
// -----------------------------------------------------------------------
void XuiStats::timerCallback(int p1) {
if (p1 == 0x10) invalidate();
else XUISTATS_PARENT::timerCallback(p1);
}
|