Move common widgets from Game to Mods.Common.
This commit is contained in:
66
OpenRA.Mods.Common/Widgets/PerfGraphWidget.cs
Normal file
66
OpenRA.Mods.Common/Widgets/PerfGraphWidget.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Support;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets
|
||||
{
|
||||
public class PerfGraphWidget : Widget
|
||||
{
|
||||
public override void Draw()
|
||||
{
|
||||
var rect = RenderBounds;
|
||||
var origin = new float2(rect.Right, rect.Bottom);
|
||||
var basis = new float2(-rect.Width / 100, -rect.Height / 100);
|
||||
|
||||
Game.Renderer.LineRenderer.DrawLine(origin, origin + new float2(100, 0) * basis, Color.White, Color.White);
|
||||
Game.Renderer.LineRenderer.DrawLine(origin + new float2(100, 0) * basis, origin + new float2(100, 100) * basis, Color.White, Color.White);
|
||||
|
||||
var k = 0;
|
||||
foreach (var item in PerfHistory.Items.Values)
|
||||
{
|
||||
var n = 0;
|
||||
item.Samples().Aggregate((a, b) =>
|
||||
{
|
||||
Game.Renderer.LineRenderer.DrawLine(
|
||||
origin + new float2(n, (float)a) * basis,
|
||||
origin + new float2(n + 1, (float)b) * basis,
|
||||
item.C, item.C);
|
||||
++n;
|
||||
return b;
|
||||
});
|
||||
|
||||
var u = new float2(rect.Left, rect.Top);
|
||||
|
||||
Game.Renderer.LineRenderer.DrawLine(
|
||||
u + new float2(10, 10 * k + 5),
|
||||
u + new float2(12, 10 * k + 5),
|
||||
item.C, item.C);
|
||||
|
||||
Game.Renderer.LineRenderer.DrawLine(
|
||||
u + new float2(10, 10 * k + 4),
|
||||
u + new float2(12, 10 * k + 4),
|
||||
item.C, item.C);
|
||||
|
||||
++k;
|
||||
}
|
||||
|
||||
k = 0;
|
||||
foreach (var item in PerfHistory.Items.Values)
|
||||
{
|
||||
Game.Renderer.Fonts["Tiny"].DrawText(item.Name, new float2(rect.Left, rect.Top) + new float2(18, 10 * k - 3), Color.White);
|
||||
++k;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user