Skip to content

Commit

Permalink
Fix height
Browse files Browse the repository at this point in the history
  • Loading branch information
nonperforming committed Sep 2, 2023
1 parent e7d9221 commit 095f6f7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .sbproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"Schema": 1,
"HasAssets": true,
"AssetsPath": "",
"Resources": "/fonts/*\n/ui/*",
"Resources": "/fonts/*\n/ui/*\n!/logo.*",
"MenuResources": null,
"HasCode": true,
"CodePath": ".",
Expand Down
46 changes: 35 additions & 11 deletions ui/Perfmon.razor
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,30 @@

@if (draw)
{
@if (drawPing)
{
<text><style>
.perfmon {
height: 6vh
}
</style></text>
}
else
{
<text><style>
.perfmon {
height: 3vh
}
</style></text>
}
<root class="perfmon">
<div class="fps @FPSStatus">
<p>@fps fps / @ms ms</p>
</div>
@if (ping != -1)
@if (drawFPS)
{
<div class="fps @FPSStatus">
<p>@fps fps / @ms ms</p>
</div>
}
@if (ping != -1 && drawPing)
{
<div class="ping @PingStatus">
<p>@ping ms</p>
Expand All @@ -27,22 +46,25 @@
public readonly IClient? client;
public bool draw = true;

public bool drawFPS = true;
public bool drawPing = false;

private string FPSStatus
{
get
{
if (fps >= 60) return "green";
if (fps >= 30) return "orange";
else return "red";
if (fps >= 60) return "green"; // FPS 60+
if (fps >= 30) return "orange"; // FPS 30-59
else return "red"; // FPS < 29
}
}
private string PingStatus
{
get
{
if (ping <= 50) return "green";
if (ping <= 300) return "orange";
else return "red";
if (ping <= 50) return "green"; // Ping 0-50
if (ping <= 300) return "orange"; // Ping 51-300
else return "red"; // Ping 300+
}
}

Expand All @@ -54,9 +76,11 @@
private float deltaBetweenUpdates;
private int framesBetweenUpdates;

public Perfmon(bool draw = true, IClient client = null, float updateRate = 1f)
public Perfmon(bool draw = true, bool drawFPS = true, bool drawPing = false, IClient client = null, float updateRate = 1f)
{
this.draw = draw;
this.drawFPS = drawFPS;
this.drawPing = drawPing;
this.client = client;
this.updateRate = updateRate;
// RenderedManually = true; // Only for RootPanel
Expand Down
2 changes: 1 addition & 1 deletion ui/Perfmon.razor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
aspect-ratio: auto;
//width: fit-content;
// min-height: 10px;
height: 3vh; // FIXME: looks great on 21:9 and 16:9, shit on 4:3
height: 2vh;

background-color: rgba(0, 0, 0, 0.5);
border: 3px solid rgba(255, 255, 255, 0.1);
Expand Down
4 changes: 2 additions & 2 deletions ui/PerfmonRoot.razor
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

@code
{
public PerfmonRoot(bool draw = true, IClient client = null, float updateRate = 1f)
public PerfmonRoot(bool draw = true, bool drawFPS = true, bool drawPing = false, IClient client = null, float updateRate = 1f)
{
RenderedManually = true; // Only for RootPanel
Scale = 1; // Only for RootPanel
AddChild(new Perfmon(draw, client, updateRate));
AddChild(new Perfmon(draw, drawFPS, drawPing, client, updateRate));
}
}

0 comments on commit 095f6f7

Please sign in to comment.