Skip to content

Commit

Permalink
Show line labels for CGraphStats
Browse files Browse the repository at this point in the history
  • Loading branch information
Necktrox committed Dec 18, 2017
1 parent b76d05f commit fc8b1e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Client/core/CCore.h
Expand Up @@ -52,7 +52,7 @@ class CCore;
#include <dinput.h>

#define BLUE_VERSION_STRING "Multi Theft Auto v" MTA_DM_BUILDTAG_LONG
#define BLUE_COPYRIGHT_STRING _td("Copyright (C) 2003 - 2016 Multi Theft Auto")
#define BLUE_COPYRIGHT_STRING _td("Copyright (C) 2003 - 2017 Multi Theft Auto")

This comment has been minimized.

Copy link
@4O4

4O4 Dec 28, 2017

Contributor

It's almost 2018, maybe ++ one more time? 😄

This comment has been minimized.

Copy link
@Necktrox

Necktrox Dec 28, 2017

Author Contributor

Soon™


// Configuration file path (relative to MTA install directory)
#define MTA_CONFIG_PATH "mta/config/coreconfig.xml"
Expand Down
20 changes: 12 additions & 8 deletions Client/core/CGraphStats.cpp
Expand Up @@ -20,6 +20,7 @@ namespace
std::vector < TIMEUS > dataHistory;
int iDataPos;
SColor color;
const char* szName;
};
}

Expand Down Expand Up @@ -162,6 +163,7 @@ void CGraphStats::AddTimingPoint( const char* szName )
memset( &pLine->dataHistory[ 0 ], 0, pLine->dataHistory.size() );
pLine->iDataPos = 0;
pLine->prevData = 0;
pLine->szName = szName;

// Random color based on line name
MD5 md5;
Expand Down Expand Up @@ -212,19 +214,17 @@ void CGraphStats::Draw ( void )
uint uiSizeY = 150;
uint uiRangeY = 100; // 100ms
float fLineScale = 1/1000.f / uiRangeY * uiSizeY;
float fHalfLineHeight = pGraphics->GetDXFontHeight() / 2;

// Backgrounf box
// Backgroung box

This comment has been minimized.

Copy link
@Citizen01

Citizen01 Dec 28, 2017

Member

😏
(Sorry if that is not appropriate)

This comment has been minimized.

Copy link
@Necktrox

Necktrox Dec 28, 2017

Author Contributor

Ups

pGraphics->DrawRectQueued( uiOriginX, uiOriginY - uiSizeY, uiSizeX, uiSizeY, SColorRGBA( 0, 0, 0, 128 ), true );

// Draw data line.
for ( std::map < SString, SGraphStatLine >::iterator iter = m_LineList.begin() ; iter != m_LineList.end() ; ++iter )
for ( const auto& dataLine : m_LineList )
{
SGraphStatLine& line = iter->second;

int iDataPos = line.iDataPos;
int iDataPosPrev = iDataPos;
if ( iDataPos == -1 )
iDataPos = GRAPHSTAT_HISTORY_SIZE - 1;
const SGraphStatLine& line = dataLine.second;
int iDataPos = line.iDataPos;
int iDataPosPrev = iDataPos;

for ( int i = uiSizeX - 1 ; i > 0 ; i-- )
{
Expand All @@ -238,5 +238,9 @@ void CGraphStats::Draw ( void )

pGraphics->DrawLineQueued( uiOriginX + i - 1, uiOriginY - fY0, uiOriginX + i, uiOriginY - fY1, 1, line.color, true );
}

float fX = uiOriginX + uiSizeX + 2;
float fY = uiOriginY - line.dataHistory[ line.iDataPos ] * fLineScale - fHalfLineHeight;
pGraphics->DrawStringQueued( fX, fY, fX, fY, line.color, line.szName, 1.0f, 1.0f, DT_NOCLIP, nullptr, true );
}
}

3 comments on commit fc8b1e5

@qaisjp
Copy link
Contributor

@qaisjp qaisjp commented on fc8b1e5 Dec 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is spacing using tabs in this file?

@Necktrox
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file seems to abuse both, even before my edit

@qaisjp
Copy link
Contributor

@qaisjp qaisjp commented on fc8b1e5 Dec 28, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh ok

Please sign in to comment.