FPS/Ping & More FOV Codes
#11


3 minutes ago, deudas said:




Hello, I have used the code, I have copied and pasted but it only works when I place myself on top of those texts, how can I make it always show up? sorry for my ignorance but i'm new and i'm learning



 









 




You put the fps code inside the if (m_bRemote) bracket.

#12

you have added it in the wrong place, search for this line: 

pDrawPort->PutTextExCX( strServerInfo, m_nPosX +this->GetWidth()/2 + 50, m_nLocalTimeY + 17, 0xFFA600FF );

which already exists in uiradar.cpp

then add this below:

// timer variables
#define FRAMES_AVERAGING_MAX 20L
static CTimerValue _tvLasts[FRAMES_AVERAGING_MAX];
static CTimerValue _tvDelta[FRAMES_AVERAGING_MAX];
static INDEX _iCheckNow = 0;
static INDEX _iCheckMax = 0;
#define FPS_LAST_CACHED 120
static INDEX _aiFPS[FPS_LAST_CACHED];
static INDEX _iStartingFPSIndex = 0;
static INDEX _iLastFPSOut = 0;
static INDEX hud_bShowClock = FALSE;
static INDEX hud_bShowNetGraph = FALSE;
static INDEX hud_bShowResolution = FALSE;
static INDEX hud_bShowPauseText = TRUE;
static INDEX dem_bOSD = FALSE;
static INDEX dem_bPlay = FALSE;
static INDEX dem_bPlayByName = FALSE;
static INDEX dem_bProfile = FALSE;
static INDEX dem_iProfileRate = 5;
static FLOAT dem_fMotionBlurStrength = 0.5f; // 0.1=min, 1=max
static CTString dem_strPostExec = "";
INDEX hud_iStats = 3;
static INDEX hud_iFPSGraphSpeed = 4;
static INDEX hud_iFPSGraphMax = 400;
static INDEX hud_bShowTime = FALSE;
// if required, print real time
if (hud_bShowClock) {
// set font, spacing and scale
// determine time
struct tm *newtime;
time_t long_time;
time(&long_time);
newtime = localtime(&long_time);
// printout
CTString strTime;
}
// clamp stat values
extern ENGINE_API INDEX _iStatsMode;
hud_iStats = Clamp(hud_iStats, 0L, 4L);
_iStatsMode = hud_iStats; // send it to engine
hud_iFPSGraphSpeed = Clamp(hud_iFPSGraphSpeed, 0L, 50L);
hud_iFPSGraphMax = Clamp(hud_iFPSGraphMax, 50L, 500L);
// calculate FPS
FLOAT fFPS = 0.0f;
_iCheckMax++;
if (_iCheckMax >= FRAMES_AVERAGING_MAX) {
for (INDEX i = 0; i<FRAMES_AVERAGING_MAX; i++) fFPS += _tvDelta[i].GetSeconds();
fFPS = FRAMES_AVERAGING_MAX*FRAMES_AVERAGING_MAX / fFPS;
_iCheckMax = FRAMES_AVERAGING_MAX;
}

// determine newest time
CTimerValue tvNow = _pTimer->GetHighPrecisionTimer();
_tvDelta[_iCheckNow] = tvNow - _tvLasts[_iCheckNow];
_tvLasts[_iCheckNow] = tvNow;
_iCheckNow = (_iCheckNow + 1) % FRAMES_AVERAGING_MAX;

// fill FPS graph
INDEX iTimeNow = tvNow.GetSeconds() * 2 * hud_iFPSGraphSpeed;
if (iTimeNow != _iLastFPSOut && iTimeNow % 2) {
_iStartingFPSIndex = (_iStartingFPSIndex + 1) % FPS_LAST_CACHED;
_aiFPS[_iStartingFPSIndex] = fFPS;
_iLastFPSOut = iTimeNow;
}

// set display interface (proportional) font
CTString strDebug;
strDebug = "";
// display colored FPS
COLOR colFPS = C_RED;
if (fFPS >= 20) colFPS = C_GREEN;
if (fFPS >= 60) colFPS = C_WHITE;
//if (fFPS < 10) pdpDrawPort->SetTextScaling(fTextScale*1.5); // enlarge output if FPS is extremely low
// prepare FPS string for printing
CTString strFPS = "?";
CTString strRomain = "?";
if (fFPS >= 30) strFPS.PrintF("%s%3.0f", (const char*)strDebug, fFPS);
else if (fFPS >= 0.1f) strFPS.PrintF("%s%3.1f", (const char*)strDebug, fFPS);
// printout FPS number (if allowed)
//pdpDrawPort->PutTextC(strFPS, slDPWidth*0.75f, slDPHeight*0.005f, colFPS | 192);
strRomain.PrintF("Arcania - FPS");
pDrawPort->PutTextExCX(strRomain, m_nPosX + this->GetWidth() / 2 + 50, m_nLocalTimeY + 34, 0xFFFFFFFF);
pDrawPort->PutTextExCX(strFPS, m_nPosX + this->GetWidth() / 2 + 50, m_nLocalTimeY + 54, 0x4BE100FF);

extern ENGINE_API INDEX cli_iCurrentFPS;
cli_iCurrentFPS = fFPS;
// display extensive statistics
CTString strReport;
// printout statistics
strFPS.PrintF( " frame =%3.0f ms\n---------------\n", 1000.0f/fFPS);
//pDrawPort->PutTextExCX(strFPS, 0, 30, C_WHITE | CT_OPAQUE, m_nPosX + this->GetWidth() / 2, m_nLocalTimeY + 48, 0x72D02EFF);
//pDrawPort->PutTextExCX(strReport, 4, 55, C_WHITE | CT_OPAQUE, m_nPosX + this->GetWidth() / 2, m_nLocalTimeY + 55, 0x72D02EFF);
if (!hud_bShowNetGraph)
{ // draw canvas
const INDEX iWidth = FPS_LAST_CACHED;
const INDEX iHeight = 60;
// calculate FPS
FLOAT fFPS = 0.0f;
_iCheckMax++;
if (_iCheckMax >= FRAMES_AVERAGING_MAX)
{
for (INDEX i = 0; i<FRAMES_AVERAGING_MAX; i++) fFPS += _tvDelta[i].GetSeconds();
fFPS = FRAMES_AVERAGING_MAX*FRAMES_AVERAGING_MAX / fFPS;
_iCheckMax = FRAMES_AVERAGING_MAX;
}

// draw graph lines
for (INDEX i = 0; i<FPS_LAST_CACHED; i++)
{
const INDEX iValue = ClampUp(_aiFPS[(i + _iStartingFPSIndex + 1) % FPS_LAST_CACHED], hud_iFPSGraphMax);
COLOR iCol = C_RED;
if (iValue>100) iCol = C_lBLUE;
if (iValue> 60) iCol = C_WHITE;
if (iValue> 20) iCol = C_GREEN;
const INDEX iNormalizedValue = ((FLOAT)iValue) / hud_iFPSGraphMax * iHeight;
}
// print max normalization value
CTString strMaxFPS;
strMaxFPS.PrintF("%d", hud_iFPSGraphMax);
//Show Max FPS
//pDrawPort->PutTextExCX(strMaxFPS, m_nPosX + this->GetWidth() / 2, m_nLocalTimeY + 40, 0x72D02EFF);
}

 

#13


15 minutes ago, Desarija said:




you have added it in the wrong place, search for this line: 


pDrawPort->PutTextExCX( strServerInfo, m_nPosX +this->GetWidth()/2 + 50, m_nLocalTimeY + 17, 0xFFA600FF );


which already exists in uiradar.cpp

then add this below:


// timer variables
#define FRAMES_AVERAGING_MAX 20L
static CTimerValue _tvLasts[FRAMES_AVERAGING_MAX];
static CTimerValue _tvDelta[FRAMES_AVERAGING_MAX];
static INDEX _iCheckNow = 0;
static INDEX _iCheckMax = 0;
#define FPS_LAST_CACHED 120
static INDEX _aiFPS[FPS_LAST_CACHED];
static INDEX _iStartingFPSIndex = 0;
static INDEX _iLastFPSOut = 0;
static INDEX hud_bShowClock = FALSE;
static INDEX hud_bShowNetGraph = FALSE;
static INDEX hud_bShowResolution = FALSE;
static INDEX hud_bShowPauseText = TRUE;
static INDEX dem_bOSD = FALSE;
static INDEX dem_bPlay = FALSE;
static INDEX dem_bPlayByName = FALSE;
static INDEX dem_bProfile = FALSE;
static INDEX dem_iProfileRate = 5;
static FLOAT dem_fMotionBlurStrength = 0.5f; // 0.1=min, 1=max
static CTString dem_strPostExec = "";
INDEX hud_iStats = 3;
static INDEX hud_iFPSGraphSpeed = 4;
static INDEX hud_iFPSGraphMax = 400;
static INDEX hud_bShowTime = FALSE;
// if required, print real time
if (hud_bShowClock) {
// set font, spacing and scale
// determine time
struct tm *newtime;
time_t long_time;
time(&long_time);
newtime = localtime(&long_time);
// printout
CTString strTime;
}
// clamp stat values
extern ENGINE_API INDEX _iStatsMode;
hud_iStats = Clamp(hud_iStats, 0L, 4L);
_iStatsMode = hud_iStats; // send it to engine
hud_iFPSGraphSpeed = Clamp(hud_iFPSGraphSpeed, 0L, 50L);
hud_iFPSGraphMax = Clamp(hud_iFPSGraphMax, 50L, 500L);
// calculate FPS
FLOAT fFPS = 0.0f;
_iCheckMax++;
if (_iCheckMax >= FRAMES_AVERAGING_MAX) {
for (INDEX i = 0; i<FRAMES_AVERAGING_MAX; i++) fFPS += _tvDelta[i].GetSeconds();
fFPS = FRAMES_AVERAGING_MAX*FRAMES_AVERAGING_MAX / fFPS;
_iCheckMax = FRAMES_AVERAGING_MAX;
}

// determine newest time
CTimerValue tvNow = _pTimer->GetHighPrecisionTimer();
_tvDelta[_iCheckNow] = tvNow - _tvLasts[_iCheckNow];
_tvLasts[_iCheckNow] = tvNow;
_iCheckNow = (_iCheckNow + 1) % FRAMES_AVERAGING_MAX;

// fill FPS graph
INDEX iTimeNow = tvNow.GetSeconds() * 2 * hud_iFPSGraphSpeed;
if (iTimeNow != _iLastFPSOut && iTimeNow % 2) {
_iStartingFPSIndex = (_iStartingFPSIndex + 1) % FPS_LAST_CACHED;
_aiFPS[_iStartingFPSIndex] = fFPS;
_iLastFPSOut = iTimeNow;
}

// set display interface (proportional) font
CTString strDebug;
strDebug = "";
// display colored FPS
COLOR colFPS = C_RED;
if (fFPS >= 20) colFPS = C_GREEN;
if (fFPS >= 60) colFPS = C_WHITE;
//if (fFPS < 10) pdpDrawPort->SetTextScaling(fTextScale*1.5); // enlarge output if FPS is extremely low
// prepare FPS string for printing
CTString strFPS = "?";
CTString strRomain = "?";
if (fFPS >= 30) strFPS.PrintF("%s%3.0f", (const char*)strDebug, fFPS);
else if (fFPS >= 0.1f) strFPS.PrintF("%s%3.1f", (const char*)strDebug, fFPS);
// printout FPS number (if allowed)
//pdpDrawPort->PutTextC(strFPS, slDPWidth*0.75f, slDPHeight*0.005f, colFPS | 192);
strRomain.PrintF("Arcania - FPS");
pDrawPort->PutTextExCX(strRomain, m_nPosX + this->GetWidth() / 2 + 50, m_nLocalTimeY + 34, 0xFFFFFFFF);
pDrawPort->PutTextExCX(strFPS, m_nPosX + this->GetWidth() / 2 + 50, m_nLocalTimeY + 54, 0x4BE100FF);

extern ENGINE_API INDEX cli_iCurrentFPS;
cli_iCurrentFPS = fFPS;
// display extensive statistics
CTString strReport;
// printout statistics
strFPS.PrintF( " frame =%3.0f ms\n---------------\n", 1000.0f/fFPS);
//pDrawPort->PutTextExCX(strFPS, 0, 30, C_WHITE | CT_OPAQUE, m_nPosX + this->GetWidth() / 2, m_nLocalTimeY + 48, 0x72D02EFF);
//pDrawPort->PutTextExCX(strReport, 4, 55, C_WHITE | CT_OPAQUE, m_nPosX + this->GetWidth() / 2, m_nLocalTimeY + 55, 0x72D02EFF);
if (!hud_bShowNetGraph)
{ // draw canvas
const INDEX iWidth = FPS_LAST_CACHED;
const INDEX iHeight = 60;
// calculate FPS
FLOAT fFPS = 0.0f;
_iCheckMax++;
if (_iCheckMax >= FRAMES_AVERAGING_MAX)
{
for (INDEX i = 0; i<FRAMES_AVERAGING_MAX; i++) fFPS += _tvDelta[i].GetSeconds();
fFPS = FRAMES_AVERAGING_MAX*FRAMES_AVERAGING_MAX / fFPS;
_iCheckMax = FRAMES_AVERAGING_MAX;
}

// draw graph lines
for (INDEX i = 0; i<FPS_LAST_CACHED; i++)
{
const INDEX iValue = ClampUp(_aiFPS[(i + _iStartingFPSIndex + 1) % FPS_LAST_CACHED], hud_iFPSGraphMax);
COLOR iCol = C_RED;
if (iValue>100) iCol = C_lBLUE;
if (iValue> 60) iCol = C_WHITE;
if (iValue> 20) iCol = C_GREEN;
const INDEX iNormalizedValue = ((FLOAT)iValue) / hud_iFPSGraphMax * iHeight;
}
// print max normalization value
CTString strMaxFPS;
strMaxFPS.PrintF("%d", hud_iFPSGraphMax);
//Show Max FPS
//pDrawPort->PutTextExCX(strMaxFPS, m_nPosX + this->GetWidth() / 2, m_nLocalTimeY + 40, 0x72D02EFF);
}


 




 

tyy worked Smile)

#14

please dont use all that code thats a mess

from that code above the only lines you need is

FLOAT fFPS = 0.0f;
extern ENGINE_API INDEX cli_iCurrentFPS;
fFPS = cli_iCurrentFPS;

CTString strFPS = "?";
CTString strRomain = "?";
if (fFPS >= 30)
strFPS.PrintF("%3.0f", fFPS);
else if (fFPS >= 0.1f)
strFPS.PrintF("%3.1f", fFPS);

strRomain.PrintF("LastChaos - FPS");
pDrawPort->PutTextExCX(strRomain, m_nPosX + this->GetWidth() / 2 , m_nLocalTimeY + 224, 0xFFFFFFFF);
pDrawPort->PutTextExCX(strFPS, m_nPosX + this->GetWidth() / 2 , m_nLocalTimeY + 244, 0x4BE100FF);
#15


1 hour ago, WhosUrDaddi said:




please dont use all that code thats a mess



from that code above the only lines you need is


FLOAT fFPS = 0.0f;
extern ENGINE_API INDEX cli_iCurrentFPS;
fFPS = cli_iCurrentFPS;

CTString strFPS = "?";
CTString strRomain = "?";
if (fFPS >= 30)
strFPS.PrintF("%3.0f", fFPS);
else if (fFPS >= 0.1f)
strFPS.PrintF("%3.1f", fFPS);

strRomain.PrintF("LastChaos - FPS");
pDrawPort->PutTextExCX(strRomain, m_nPosX + this->GetWidth() / 2 , m_nLocalTimeY + 224, 0xFFFFFFFF);
pDrawPort->PutTextExCX(strFPS, m_nPosX + this->GetWidth() / 2 , m_nLocalTimeY + 244, 0x4BE100FF);


Oop sorry thats only if you have the hud_iStats enabled but without that it would also be less code

// timer variables
#define FRAMES_AVERAGING_MAX 20L
static CTimerValue _tvLasts[FRAMES_AVERAGING_MAX];
static CTimerValue _tvDelta[FRAMES_AVERAGING_MAX];
static INDEX _iCheckNow = 0;
static INDEX _iCheckMax = 0;

// calculate FPS
FLOAT fFPS = 0.0f;
_iCheckMax++;
if (_iCheckMax >= FRAMES_AVERAGING_MAX) {
for (INDEX i = 0; i<FRAMES_AVERAGING_MAX; i++) fFPS += _tvDelta[i].GetSeconds();
fFPS = FRAMES_AVERAGING_MAX*FRAMES_AVERAGING_MAX / fFPS;
_iCheckMax = FRAMES_AVERAGING_MAX;
}

// determine newest time
CTimerValue tvNow = _pTimer->GetHighPrecisionTimer();
_tvDelta[_iCheckNow] = tvNow - _tvLasts[_iCheckNow];
_tvLasts[_iCheckNow] = tvNow;
_iCheckNow = (_iCheckNow + 1) % FRAMES_AVERAGING_MAX;

// display colored FPS
COLOR colFPS = C_RED;
if (fFPS >= 20)
colFPS = C_GREEN;

if (fFPS >= 60)
colFPS = C_WHITE;

CTString strFPS = "?";
CTString strRomain = "?";
if (fFPS >= 30)
strFPS.PrintF("%3.0f", fFPS);
else if (fFPS >= 0.1f)
strFPS.PrintF("%3.1f", fFPS);

strRomain.PrintF("LastChaos - FPS");
pDrawPort->PutTextExCX(strRomain, m_nPosX + this->GetWidth() / 2 , m_nLocalTimeY + 224, 0xFFFFFFFF);
pDrawPort->PutTextExCX(strFPS, m_nPosX + this->GetWidth() / 2 , m_nLocalTimeY + 244, 0x4BE100FF);

 

#16
pDrawPort->PutTextExCX( strServerInfo, m_nPosX +this->GetWidth()/2 + 50, m_nLocalTimeY + 17, 0xFFA600FF );

Don't exist on november source have you a solution?

#17


7 minutes ago, Stormax said:



pDrawPort->PutTextExCX( strServerInfo, m_nPosX +this->GetWidth()/2 + 50, m_nLocalTimeY + 17, 0xFFA600FF );


Don't exist on november source have you a solution?




in my case, I call a function inside

void CUIRadar::OnUpdate

to update the fps value.

I leave the function in case anyone is interested, they would have to add the CUIText to their xml and do the corresponding thing in the source

// NICOLASG MARK (SHOW FPS)
void CUIRadar::updateFPSCounter(){
if(m_pTxtFpsInfo == NULL)
return;

#define FRAMES_AVERAGING_MAX 20L
static CTimerValue _tvLasts[FRAMES_AVERAGING_MAX];
static CTimerValue _tvDelta[FRAMES_AVERAGING_MAX];
static INDEX _iCheckNow = 0;
static INDEX _iCheckMax = 0;

FLOAT fFPS = 0.0f;

_iCheckMax++;

if(_iCheckMax >= FRAMES_AVERAGING_MAX){
for(INDEX i = 0; i<FRAMES_AVERAGING_MAX; i++)
fFPS += _tvDelta[i].GetSeconds();
fFPS = FRAMES_AVERAGING_MAX*FRAMES_AVERAGING_MAX / fFPS;
_iCheckMax = FRAMES_AVERAGING_MAX;
}

CTimerValue tvNow = _pTimer->GetHighPrecisionTimer();
_tvDelta[_iCheckNow] = tvNow - _tvLasts[_iCheckNow];
_tvLasts[_iCheckNow] = tvNow;
_iCheckNow = (_iCheckNow + 1) % FRAMES_AVERAGING_MAX;

CTString strFPS = "";

if(fFPS >= 30) strFPS.PrintF("FPS: %3.0f", fFPS);
else if(fFPS >= 0.1f) strFPS.PrintF("FPS: %3.1f", fFPS);

m_pTxtFpsInfo->SetText(strFPS);
}
// NICOLASG MARK END

 

#18

Thanks @nicolasg

Where i can edit CUIRadar? as you say i need to add updateFPSCounter

Also i need declare m_pTxtFpsInfo ?



Forum Jump:


Users browsing this thread: 3 Guest(s)