Encapsulate CGraph member variables

Make the member variables private and add `SetMin` to replace a usage of the member variables in `CDebugHud`. For completeness/symmetry, `SetMax` is also added.
This commit is contained in:
Robert Müller 2022-08-12 14:23:50 +02:00
parent 8c88005a42
commit 967c92f5d6
3 changed files with 17 additions and 3 deletions

View file

@ -84,11 +84,21 @@ static const ColorRGBA gs_ClientNetworkErrPrintColor{1.0f, 0.25f, 0.25f, 1.0f};
void CGraph::Init(float Min, float Max)
{
m_MinRange = m_Min = Min;
m_MaxRange = m_Max = Max;
SetMin(Min);
SetMax(Max);
m_Index = 0;
}
void CGraph::SetMin(float Min)
{
m_MinRange = m_Min = Min;
}
void CGraph::SetMax(float Max)
{
m_MaxRange = m_Max = Max;
}
void CGraph::Scale()
{
m_Min = m_MinRange;

View file

@ -47,13 +47,17 @@ public:
MAX_VALUES = 128,
};
private:
float m_Min, m_Max;
float m_MinRange, m_MaxRange;
float m_aValues[MAX_VALUES];
float m_aColors[MAX_VALUES][3];
size_t m_Index;
public:
void Init(float Min, float Max);
void SetMin(float Min);
void SetMax(float Max);
void Scale();
void Add(float v, float r, float g, float b);

View file

@ -183,7 +183,7 @@ void CDebugHud::RenderTuning()
}
if(i == 0)
{
m_ZoomedInGraph.m_Min = m_ZoomedInGraph.m_MinRange = RampedSpeed;
m_ZoomedInGraph.SetMin(RampedSpeed);
}
pv = RampedSpeed;
}