2010-11-20 10:37:14 +00:00
|
|
|
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
|
|
|
|
/* If you are missing that file, acquire a complete release at teeworlds.com. */
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/graphics.h>
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <engine/shared/config.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/textrender.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/generated/client_data.h>
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <game/generated/protocol.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/layers.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/animstate.h>
|
2020-09-26 19:41:58 +00:00
|
|
|
#include <game/client/gameclient.h>
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/render.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
//#include "controls.h"
|
|
|
|
//#include "camera.h"
|
|
|
|
#include "debughud.h"
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CDebugHud::RenderNetCorrections()
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-09-12 10:55:37 +00:00
|
|
|
if(!g_Config.m_Debug || g_Config.m_DbgGraphs || !m_pClient->m_Snap.m_pLocalCharacter || !m_pClient->m_Snap.m_pLocalPrevCharacter)
|
2008-08-27 15:48:50 +00:00
|
|
|
return;
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
float Width = 300 * Graphics()->ScreenAspect();
|
2010-08-13 01:07:51 +00:00
|
|
|
Graphics()->MapScreen(0, 0, Width, 300);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
/*float speed = distance(vec2(netobjects.local_prev_character->x, netobjects.local_prev_character->y),
|
|
|
|
vec2(netobjects.local_character->x, netobjects.local_character->y));*/
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
float Velspeed = length(vec2(m_pClient->m_Snap.m_pLocalCharacter->m_VelX / 256.0f, m_pClient->m_Snap.m_pLocalCharacter->m_VelY / 256.0f)) * 50;
|
2014-04-29 01:34:23 +00:00
|
|
|
float Ramp = VelocityRamp(Velspeed, m_pClient->m_Tuning[g_Config.m_ClDummy].m_VelrampStart, m_pClient->m_Tuning[g_Config.m_ClDummy].m_VelrampRange, m_pClient->m_Tuning[g_Config.m_ClDummy].m_VelrampCurvature);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2020-08-15 23:51:35 +00:00
|
|
|
const char *paStrings[] = {"velspeed:", "velspeed*ramp:", "ramp:", "checkpoint:", "Pos", " x:", " y:", "angle:", "netobj corrections", " num:", " on:"};
|
2020-09-26 19:41:58 +00:00
|
|
|
const int Num = sizeof(paStrings) / sizeof(char *);
|
2010-08-13 01:07:51 +00:00
|
|
|
const float LineHeight = 6.0f;
|
|
|
|
const float Fontsize = 5.0f;
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
float x = Width - 100.0f, y = 50.0f;
|
2010-08-13 01:07:51 +00:00
|
|
|
for(int i = 0; i < Num; ++i)
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->Text(0, x, y + i * LineHeight, Fontsize, paStrings[i], -1.0f);
|
2010-08-13 01:07:51 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
x = Width - 10.0f;
|
2010-08-13 01:07:51 +00:00
|
|
|
char aBuf[128];
|
2020-09-26 19:41:58 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "%.0f", Velspeed / 32);
|
2020-07-15 19:10:13 +00:00
|
|
|
float w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
|
2010-08-13 01:07:51 +00:00
|
|
|
y += LineHeight;
|
2020-09-26 19:41:58 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "%.0f", Velspeed / 32 * Ramp);
|
2020-07-15 19:10:13 +00:00
|
|
|
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
|
2010-08-13 01:07:51 +00:00
|
|
|
y += LineHeight;
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%.2f", Ramp);
|
2020-07-15 19:10:13 +00:00
|
|
|
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
|
2020-08-15 23:51:35 +00:00
|
|
|
y += LineHeight;
|
2020-11-12 21:55:22 +00:00
|
|
|
const CCharacter *pCharacter = m_pClient->m_GameWorld.GetCharacterByID(m_pClient->m_Snap.m_LocalClientID);
|
|
|
|
if(pCharacter)
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%d", pCharacter->m_TeleCheckpoint);
|
|
|
|
else
|
|
|
|
str_copy(aBuf, "-1", sizeof(aBuf));
|
2020-08-15 23:51:35 +00:00
|
|
|
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
|
|
|
|
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
|
2020-09-26 19:41:58 +00:00
|
|
|
y += 2 * LineHeight;
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%.2f", static_cast<float>(m_pClient->m_Snap.m_pLocalCharacter->m_X) / 32.0f);
|
2020-07-15 19:10:13 +00:00
|
|
|
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
|
2010-08-13 01:07:51 +00:00
|
|
|
y += LineHeight;
|
2020-09-26 19:41:58 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "%.2f", static_cast<float>(m_pClient->m_Snap.m_pLocalCharacter->m_Y) / 32.0f);
|
2020-07-15 19:10:13 +00:00
|
|
|
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
|
2017-04-24 19:05:36 +00:00
|
|
|
y += LineHeight;
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%d", m_pClient->m_Snap.m_pLocalCharacter->m_Angle);
|
2020-07-15 19:10:13 +00:00
|
|
|
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
|
|
|
|
y += 2 * LineHeight;
|
2010-08-13 01:07:51 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "%d", m_pClient->NetobjNumCorrections());
|
2020-07-15 19:10:13 +00:00
|
|
|
w = TextRender()->TextWidth(0, Fontsize, aBuf, -1, -1.0f);
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->Text(0, x - w, y, Fontsize, aBuf, -1.0f);
|
2010-08-13 01:07:51 +00:00
|
|
|
y += LineHeight;
|
2020-07-15 19:10:13 +00:00
|
|
|
w = TextRender()->TextWidth(0, Fontsize, m_pClient->NetobjCorrectedOn(), -1, -1.0f);
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->Text(0, x - w, y, Fontsize, m_pClient->NetobjCorrectedOn(), -1.0f);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CDebugHud::RenderTuning()
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
|
|
|
// render tuning debugging
|
2010-05-29 07:25:38 +00:00
|
|
|
if(!g_Config.m_DbgTuning)
|
2008-08-27 15:48:50 +00:00
|
|
|
return;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CTuningParams StandardTuning;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
Graphics()->MapScreen(0, 0, 300 * Graphics()->ScreenAspect(), 300);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2014-04-18 12:37:40 +00:00
|
|
|
float y = 27.0f;
|
2010-05-29 07:25:38 +00:00
|
|
|
int Count = 0;
|
2014-04-29 01:34:23 +00:00
|
|
|
for(int i = 0; i < m_pClient->m_Tuning[g_Config.m_ClDummy].Num(); i++)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
char aBuf[128];
|
|
|
|
float Current, Standard;
|
2014-04-29 01:34:23 +00:00
|
|
|
m_pClient->m_Tuning[g_Config.m_ClDummy].Get(i, &Current);
|
2010-05-29 07:25:38 +00:00
|
|
|
StandardTuning.Get(i, &Standard);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
if(Standard == Current)
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->TextColor(1, 1, 1, 1.0f);
|
2008-08-27 15:48:50 +00:00
|
|
|
else
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->TextColor(1, 0.25f, 0.25f, 1.0f);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
float w;
|
|
|
|
float x = 5.0f;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "%.2f", Standard);
|
2008-08-27 15:48:50 +00:00
|
|
|
x += 20.0f;
|
2020-07-15 19:10:13 +00:00
|
|
|
w = TextRender()->TextWidth(0, 5, aBuf, -1, -1.0f);
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->Text(0x0, x - w, y + Count * 6, 5, aBuf, -1.0f);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), "%.2f", Current);
|
2008-08-27 15:48:50 +00:00
|
|
|
x += 20.0f;
|
2020-07-15 19:10:13 +00:00
|
|
|
w = TextRender()->TextWidth(0, 5, aBuf, -1, -1.0f);
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->Text(0x0, x - w, y + Count * 6, 5, aBuf, -1.0f);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
x += 5.0f;
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->Text(0x0, x, y + Count * 6, 5, m_pClient->m_Tuning[g_Config.m_ClDummy].ms_apNames[i], -1.0f);
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
Count++;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
y = y + Count * 6;
|
2011-04-13 18:37:12 +00:00
|
|
|
|
2012-08-12 10:41:50 +00:00
|
|
|
Graphics()->TextureClear();
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->BlendNormal();
|
|
|
|
Graphics()->LinesBegin();
|
2010-05-29 07:25:38 +00:00
|
|
|
float Height = 50.0f;
|
2008-08-27 15:48:50 +00:00
|
|
|
float pv = 1;
|
2010-05-29 07:25:38 +00:00
|
|
|
IGraphics::CLineItem Array[100];
|
2008-08-27 15:48:50 +00:00
|
|
|
for(int i = 0; i < 100; i++)
|
|
|
|
{
|
2020-09-26 19:41:58 +00:00
|
|
|
float Speed = i / 100.0f * 3000;
|
2014-04-29 01:34:23 +00:00
|
|
|
float Ramp = VelocityRamp(Speed, m_pClient->m_Tuning[g_Config.m_ClDummy].m_VelrampStart, m_pClient->m_Tuning[g_Config.m_ClDummy].m_VelrampRange, m_pClient->m_Tuning[g_Config.m_ClDummy].m_VelrampCurvature);
|
2020-09-26 19:41:58 +00:00
|
|
|
float RampedSpeed = (Speed * Ramp) / 1000.0f;
|
|
|
|
Array[i] = IGraphics::CLineItem((i - 1) * 2, y + Height - pv * Height, i * 2, y + Height - RampedSpeed * Height);
|
2009-10-27 14:38:53 +00:00
|
|
|
//Graphics()->LinesDraw((i-1)*2, 200, i*2, 200);
|
2010-05-29 07:25:38 +00:00
|
|
|
pv = RampedSpeed;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
Graphics()->LinesDraw(Array, 100);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->LinesEnd();
|
2020-09-26 19:41:58 +00:00
|
|
|
TextRender()->TextColor(1, 1, 1, 1);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2020-11-03 07:03:24 +00:00
|
|
|
void CDebugHud::RenderHint()
|
|
|
|
{
|
|
|
|
if(!g_Config.m_Debug)
|
|
|
|
return;
|
|
|
|
|
|
|
|
float Width = 300 * Graphics()->ScreenAspect();
|
|
|
|
Graphics()->MapScreen(0, 0, Width, 300);
|
|
|
|
TextRender()->TextColor(1, 1, 1, 1);
|
|
|
|
TextRender()->Text(0x0, 5, 290, 5, Localize("Debug mode enabled. Press Ctrl+Shift+D to disable debug mode."), -1.0f);
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CDebugHud::OnRender()
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderTuning();
|
|
|
|
RenderNetCorrections();
|
2020-11-03 07:03:24 +00:00
|
|
|
RenderHint();
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|