1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3
4#ifndef ENGINE_CLIENT_GRAPH_H
5#define ENGINE_CLIENT_GRAPH_H
6
7#include <base/color.h>
8
9#include <engine/shared/ringbuffer.h>
10
11#include <cstddef>
12
13class IGraphics;
14class ITextRender;
15
16class CGraph
17{
18private:
19 struct SEntry
20 {
21 int64_t m_Time;
22 float m_Value;
23 ColorRGBA m_Color;
24 bool m_ApplyColor;
25 };
26 SEntry *m_pFirstScaled = nullptr;
27 int64_t m_RenderedTotalTime = 0;
28 float m_Min, m_Max;
29 float m_MinRange, m_MaxRange;
30 CDynamicRingBuffer<SEntry> m_Entries;
31
32public:
33 CGraph(int MaxEntries);
34
35 void Init(float Min, float Max);
36 void SetMin(float Min);
37 void SetMax(float Max);
38
39 void Scale(int64_t WantedTotalTime);
40 void Add(float Value, ColorRGBA Color = ColorRGBA(1.0f, 1.0f, 1.0f, 0.75f));
41 void InsertAt(int64_t Time, float Value, ColorRGBA Color = ColorRGBA(1.0f, 1.0f, 1.0f, 0.75f));
42 void Render(IGraphics *pGraphics, ITextRender *pTextRender, float x, float y, float w, float h, const char *pDescription);
43};
44
45#endif
46