1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-24 10:38:02 +02:00
Beef/BeefTools/BeefPerf/src/StatusBar.bf

81 lines
1.9 KiB
Beef
Raw Normal View History

2019-08-23 11:56:54 -07:00
using Beefy.widgets;
using Beefy.theme.dark;
using System;
namespace BeefPerf
{
class StatusBar : Widget
{
public double mShowTime;
public double mSelTime;
public int64 mSelTick;
public override void Draw(Beefy.gfx.Graphics g)
{
base.Draw(g);
uint32 bkgColor = 0xFF404040;
using (g.PushColor(bkgColor))
g.FillRect(0, 0, mWidth, mHeight);
g.SetFont(DarkTheme.sDarkTheme.mSmallFont);
2020-05-11 10:16:24 -07:00
g.DrawString(scope String()..AppendF("FPS: {0}", gApp.mLastFPS), 4, 0);
2019-08-23 11:56:54 -07:00
//
2020-05-11 10:16:24 -07:00
g.DrawString(scope String()..AppendF("{0}", gApp.mUpdateCnt), 0, 0, .Right, mWidth - 8);
2019-08-23 11:56:54 -07:00
float curY = 64;
if (!gApp.mListenSocket.IsConnected)
{
using (g.PushColor(0xFFFF4040))
2020-05-11 10:16:24 -07:00
g.DrawString(scope String()..AppendF("Failed to listen on port {0}", gApp.mListenPort), 0, 0, .Right, mWidth - 8);
2019-08-23 11:56:54 -07:00
}
else
{
2020-05-11 10:16:24 -07:00
g.DrawString(scope String()..AppendF("Clients: {0}", gApp.mClients.Count), curY, 0);
2019-08-23 11:56:54 -07:00
curY += 64;
float kPerSec = gApp.mStatBytesPerSec / 1024.0f;
if ((kPerSec > 0) && (kPerSec < 0.1f))
kPerSec = 0.1f;
2020-05-11 10:16:24 -07:00
g.DrawString(scope String()..AppendF("BPS: {0:0.0}k", kPerSec), curY, 0);
2019-08-23 11:56:54 -07:00
curY += 80;
}
if (gApp.mBoard.mPerfView != null)
{
var client = gApp.mBoard.mPerfView.mSession;
2020-05-11 10:16:24 -07:00
g.DrawString(scope String()..AppendF("Zones: {0}", (int32)client.mNumZones), curY, 0);
2019-08-23 11:56:54 -07:00
curY += 118;
var str = scope String();
BpClient.TimeToStr(client.TicksToUS(client.mCurTick - client.mFirstTick), str);
g.DrawString(str, curY, 0);
curY += 108;
}
if (mShowTime != 0)
{
var str = scope String();
BpClient.TimeToStr(mShowTime, str);
g.DrawString(str, curY, 0);
curY += 108;
}
if (mSelTime != 0)
{
var str = scope String();
BpClient.ElapsedTimeToStr(mSelTime, str);
g.DrawString(str, curY, 0);
curY += 108;
}
/*{
var str = scope String();
str.FormatInto("{0}", mSelTick);
g.DrawString(str, 550, 0);
}*/
}
}
}