Skip to content

Commit

Permalink
[STCoP] * hud_adjust: Activating hud_adjust.
Browse files Browse the repository at this point in the history
  • Loading branch information
mortany authored and Roman-n committed Sep 19, 2022
1 parent d8276fa commit 19bd272
Show file tree
Hide file tree
Showing 27 changed files with 104 additions and 159 deletions.
5 changes: 0 additions & 5 deletions src/Include/xrRender/DebugRender.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#pragma once

#ifdef DEBUG

#include "xrCore/xr_types.h"
#include "DebugShader.h"

Expand Down Expand Up @@ -46,9 +44,6 @@ class IDebugRender
virtual void SetDebugShader(dbgShaderHandle shdHandle) = 0;
virtual void DestroyDebugShader(dbgShaderHandle shdHandle) = 0;

#ifdef DEBUG
virtual void dbg_DrawTRI(Fmatrix& T, Fvector& p1, Fvector& p2, Fvector& p3, u32 C) = 0;
#endif // DEBUG
};

#endif // DEBUG
4 changes: 0 additions & 4 deletions src/Layers/xrRender/R_Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ class ECORE_API CBackend
# error No graphics API selected or enabled!
#endif

#ifdef DEBUG
LPCSTR ps_name;
LPCSTR vs_name;
#ifndef USE_DX9
Expand All @@ -153,7 +152,6 @@ class ECORE_API CBackend
# ifdef USE_OGL
pcstr pp_name;
# endif
#endif // DEBUG

u32 stencil_enable;
u32 stencil_func;
Expand Down Expand Up @@ -536,7 +534,6 @@ class ECORE_API CBackend
void dbg_DIP(D3DPRIMITIVETYPE pt, ref_geom geom, u32 baseV, u32 startV, u32 countV, u32 startI, u32 PC);
void dbg_SetRS(D3DRENDERSTATETYPE p1, u32 p2);
void dbg_SetSS(u32 sampler, D3DSAMPLERSTATETYPE type, u32 value);
#ifdef DEBUG
void dbg_Draw(D3DPRIMITIVETYPE T, FVF::L* pVerts, int vcnt, u16* pIdx, int pcnt);
void dbg_Draw(D3DPRIMITIVETYPE T, FVF::L* pVerts, int pcnt);

Expand All @@ -554,7 +551,6 @@ class ECORE_API CBackend
void dbg_DrawTRI(Fmatrix& T, Fvector& p1, Fvector& p2, Fvector& p3, u32 C);
void dbg_DrawLINE(Fmatrix& T, Fvector& p1, Fvector& p2, u32 C);
void dbg_DrawEllipse(Fmatrix& T, u32 C);
#endif
void dbg_OverdrawBegin();
void dbg_OverdrawEnd();

Expand Down
2 changes: 0 additions & 2 deletions src/Layers/xrRender/R_Backend_DBG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ void CBackend::dbg_DIP(D3DPRIMITIVETYPE pt, ref_geom geom, u32 baseV, u32 startV
Render(pt, baseV, startV, countV, startI, PC);
}

#ifdef DEBUG

void CBackend::dbg_Draw(D3DPRIMITIVETYPE T, FVF::L* pVerts, int vcnt, u16* pIdx, int pcnt)
{
Expand Down Expand Up @@ -231,7 +230,6 @@ void CBackend::dbg_DrawEllipse(Fmatrix& T, u32 C)
dbg_Draw(D3DPT_TRIANGLELIST, verts, vcnt, gFaces, 224);
RCache.set_FillMode(D3DFILL_SOLID);
}
#endif

void CBackend::dbg_OverdrawBegin()
{
Expand Down
2 changes: 0 additions & 2 deletions src/Layers/xrRender/R_DStreams.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ class ECORE_API _VertexStream
u32 mSize{}; // size in bytes
u32 mPosition{}; // position in bytes
u32 mDiscardID{}; // ID of discard - usually for caching
#ifdef DEBUG
u32 dbg_lock{};
#endif

public:
VertexBufferHandle old_pVB{};
Expand Down
3 changes: 0 additions & 3 deletions src/Layers/xrRender/dxDebugRender.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "stdafx.h"

#ifdef DEBUG

#include "dxDebugRender.h"
#include "dxUIShader.h"

Expand Down Expand Up @@ -166,4 +164,3 @@ struct RDebugRender : public dxDebugRender, public pureRender
} rdebug_render_impl;
dxDebugRender* rdebug_render = &rdebug_render_impl;

#endif // DEBUG
6 changes: 0 additions & 6 deletions src/Layers/xrRender/dxDebugRender.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef dxDebugRender_included
#define dxDebugRender_included
#pragma once

#ifdef DEBUG

#include "Include/xrRender/DebugRender.h"

Expand All @@ -28,9 +26,7 @@ class dxDebugRender : public IDebugRender
virtual void SetDebugShader(dbgShaderHandle shdHandle);
virtual void DestroyDebugShader(dbgShaderHandle shdHandle);

#ifdef DEBUG
virtual void dbg_DrawTRI(Fmatrix& T, Fvector& p1, Fvector& p2, Fvector& p3, u32 C);
#endif // DEBUG

private:
void try_render(u32 const& vertex_count, u32 const& index_count);
Expand All @@ -56,6 +52,4 @@ class dxDebugRender : public IDebugRender

extern dxDebugRender DebugRenderImpl;
extern dxDebugRender* rdebug_render;
#endif // DEBUG

#endif // dxDebugRender_included
2 changes: 0 additions & 2 deletions src/Layers/xrRenderPC_GL/xrRender_GL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ class RGLRendererModule final : public RendererModule
GEnv.RenderFactory = &RenderFactoryImpl;
GEnv.DU = &DUImpl;
GEnv.UIRender = &UIRenderImpl;
#ifdef DEBUG
GEnv.DRender = &DebugRenderImpl;
#endif
xrRender_initconsole();
}
} static s_rgl_module;
Expand Down
2 changes: 0 additions & 2 deletions src/Layers/xrRenderPC_R1/xrRender_R1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ class R1RendererModule final : public RendererModule
GEnv.RenderFactory = &RenderFactoryImpl;
GEnv.DU = &DUImpl;
GEnv.UIRender = &UIRenderImpl;
#ifdef DEBUG
GEnv.DRender = &DebugRenderImpl;
#endif
xrRender_initconsole();
}
} static s_r1_module;
Expand Down
2 changes: 0 additions & 2 deletions src/Layers/xrRenderPC_R2/xrRender_R2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ class R2RendererModule final : public RendererModule
GEnv.RenderFactory = &RenderFactoryImpl;
GEnv.DU = &DUImpl;
GEnv.UIRender = &UIRenderImpl;
#ifdef DEBUG
GEnv.DRender = &DebugRenderImpl;
#endif
xrRender_initconsole();
}
} static s_r2_module;
Expand Down
2 changes: 0 additions & 2 deletions src/Layers/xrRenderPC_R4/xrRender_R4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ class R4RendererModule final : public RendererModule
GEnv.RenderFactory = &RenderFactoryImpl;
GEnv.DU = &DUImpl;
GEnv.UIRender = &UIRenderImpl;
#ifdef DEBUG
GEnv.DRender = &DebugRenderImpl;
#endif
xrRender_initconsole();
}
} static s_r4_module;
Expand Down
2 changes: 0 additions & 2 deletions src/xrEngine/CameraManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ class ENGINE_API CCameraManager
void OnEffectorReleased(SBaseEffector* e);

public:
#ifdef DEBUG
u32 dbg_upd_frame;
#endif

BENCH_SEC_SCRAMBLEMEMBER2

Expand Down
27 changes: 21 additions & 6 deletions src/xrGame/ActorInput.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "StdAfx.h"
#include <dinput.h>
// #include <dinput.h>
#include "Actor.h"
#include "Torch.h"
#include "trade.h"
Expand Down Expand Up @@ -39,7 +39,12 @@ bool g_bAutoClearCrouch = true;
void CActor::IR_OnKeyboardPress(int cmd)
{
if (hud_adj_mode && pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT))
return;
{
if (pInput->iGetAsyncKeyState(SDL_SCANCODE_RETURN) || pInput->iGetAsyncKeyState(SDL_SCANCODE_BACKSPACE) ||
pInput->iGetAsyncKeyState(SDL_SCANCODE_DELETE))
g_player_hud->tune(Ivector().set(0, 0, 0));
return;
}

if (Remote())
return;
Expand All @@ -52,11 +57,11 @@ void CActor::IR_OnKeyboardPress(int cmd)
if (load_screen_renderer.IsActive())
return;

if (pInput->iGetAsyncKeyState(DIK_ADD))
if (pInput->iGetAsyncKeyState(SDL_SCANCODE_KP_MEMADD)) // old DIK_ADD
inventory().Action((u16)kWPN_ZOOM_INC, CMD_START);
else if (pInput->iGetAsyncKeyState(DIK_SUBTRACT))
else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_KP_MEMSUBTRACT)) // old DIK_SUBTRACT
inventory().Action((u16)kWPN_ZOOM_DEC, CMD_START);
else if (pInput->iGetAsyncKeyState(DIK_HOME))
else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_AC_HOME)) // old DIK_HOME
inventory().Action((u16)kWPN_NV_CHANGE, CMD_START);

bool quickSlot = false;
Expand Down Expand Up @@ -284,7 +289,17 @@ void CActor::IR_OnKeyboardRelease(int cmd)
void CActor::IR_OnKeyboardHold(int cmd)
{
if (hud_adj_mode && pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT))
return;
{
if (pInput->iGetAsyncKeyState(SDL_SCANCODE_UP)) // old DIK_UP
g_player_hud->tune(Ivector().set(0, -1, 0));
if (pInput->iGetAsyncKeyState(SDL_SCANCODE_DOWN)) // old DIK_DOWN
g_player_hud->tune(Ivector().set(0, 1, 0));
if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LEFT)) // old DIK_LEFT
g_player_hud->tune(Ivector().set(-1, 0, 0));
if (pInput->iGetAsyncKeyState(SDL_SCANCODE_RIGHT)) // old DIK_RIGHT
g_player_hud->tune(Ivector().set(1, 0, 0));
return;
}

if (Remote() || !g_Alive())
return;
Expand Down
10 changes: 5 additions & 5 deletions src/xrGame/Level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@
#include "xrNetServer/NET_Messages.h"
#include "xrEngine/GameFont.h"

#ifdef DEBUG
#include "level_debug.h"
#include "ai/stalker/ai_stalker.h"
#include "debug_renderer.h"
#include "PhysicObject.h"
#include "PHDebug.h"
#include "debug_text_tree.h"
#ifdef DEBUG
#include "LevelGraphDebugRender.hpp"
#endif

Expand Down Expand Up @@ -95,11 +95,11 @@ CLevel::CLevel()
m_space_restriction_manager = xr_new<CSpaceRestrictionManager>();
m_client_spawn_manager = xr_new<CClientSpawnManager>();
m_autosave_manager = xr_new<CAutosaveManager>();
#ifdef DEBUG
m_debug_renderer = xr_new<CDebugRenderer>();
#ifdef DEBUG
levelGraphDebugRender = xr_new<LevelGraphDebugRender>();
m_level_debug = xr_new<CLevelDebug>();
#endif
// m_level_debug = xr_new<CLevelDebug>();
}
m_ph_commander = xr_new<CPHCommander>();
m_ph_commander_scripts = xr_new<CPHCommander>();
Expand Down Expand Up @@ -145,9 +145,9 @@ CLevel::~CLevel()
xr_delete(m_seniority_hierarchy_holder);
xr_delete(m_client_spawn_manager);
xr_delete(m_autosave_manager);
xr_delete(m_debug_renderer);
#ifdef DEBUG
xr_delete(levelGraphDebugRender);
xr_delete(m_debug_renderer);
#endif
if (!GEnv.isDedicatedServer)
GEnv.ScriptEngine->remove_script_process(ScriptProcessor::Level);
Expand Down Expand Up @@ -614,7 +614,7 @@ void CLevel::OnRender()

if (!Device.IsAnselActive)
HUD().RenderUI();

debug_renderer().render();
#ifdef DEBUG
draw_wnds_rects();
physics_world()->OnRender();
Expand Down
8 changes: 1 addition & 7 deletions src/xrGame/Level.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ class demoplay_control;
class demo_info;
class CStreamReader;

#ifdef DEBUG
class CDebugRenderer;
#endif

extern ENGINE_API float g_fov;

Expand Down Expand Up @@ -111,9 +109,9 @@ class CLevel : public IGame_Level, public IPureClient
CSeniorityHierarchyHolder* m_seniority_hierarchy_holder = nullptr;
CClientSpawnManager* m_client_spawn_manager = nullptr;
CAutosaveManager* m_autosave_manager = nullptr;
CDebugRenderer* m_debug_renderer = nullptr;
#ifdef DEBUG
LevelGraphDebugRender* levelGraphDebugRender = nullptr;
CDebugRenderer* m_debug_renderer = nullptr;
#endif
CPHCommander* m_ph_commander = nullptr;
CPHCommander* m_ph_commander_scripts = nullptr;
Expand Down Expand Up @@ -349,9 +347,7 @@ class CLevel : public IGame_Level, public IPureClient
IC CSeniorityHierarchyHolder& seniority_holder();
IC CClientSpawnManager& client_spawn_manager();
IC CAutosaveManager& autosave_manager();
#ifdef DEBUG
IC CDebugRenderer& debug_renderer();
#endif
void script_gc(); // GC-cycle
IC CPHCommander& ph_commander();
IC CPHCommander& ph_commander_scripts();
Expand Down Expand Up @@ -463,13 +459,11 @@ IC CAutosaveManager& CLevel::autosave_manager()
return *m_autosave_manager;
}

#ifdef DEBUG
IC CDebugRenderer& CLevel::debug_renderer()
{
VERIFY(m_debug_renderer);
return *m_debug_renderer;
}
#endif

IC CPHCommander& CLevel::ph_commander()
{
Expand Down
7 changes: 1 addition & 6 deletions src/xrGame/UIGameSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ void CUIGameSP::SetClGame(game_cl_GameState* g)
m_game = smart_cast<game_cl_Single*>(g);
R_ASSERT(m_game);
}
#ifdef DEBUG

void attach_adjust_mode_keyb(int dik);
void attach_draw_adjust_mode();
void hud_adjust_mode_keyb(int dik);
void hud_draw_adjust_mode();
#endif

void CUIGameSP::OnFrame()
{
Expand Down Expand Up @@ -105,10 +104,8 @@ bool CUIGameSP::IR_UIOnKeyboardPress(int dik)
if (Device.Paused())
return false;

#ifdef DEBUG
hud_adjust_mode_keyb(dik);
attach_adjust_mode_keyb(dik);
#endif

CInventoryOwner* pInvOwner = smart_cast<CInventoryOwner*>(Level().CurrentEntity());
if (!pInvOwner)
Expand Down Expand Up @@ -174,14 +171,12 @@ bool CUIGameSP::IR_UIOnKeyboardPress(int dik)

return false;
}
#ifdef DEBUG
void CUIGameSP::Render()
{
inherited::Render();
hud_draw_adjust_mode();
attach_draw_adjust_mode();
}
#endif

void CUIGameSP::StartTrade(CInventoryOwner* pActorInv, CInventoryOwner* pOtherOwner)
{
Expand Down
2 changes: 0 additions & 2 deletions src/xrGame/UIGameSP.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ class CUIGameSP : public CUIGameCustom
void HideShownDialogs() override;
void ReinitDialogs() override;

#ifdef DEBUG
virtual void Render();
#endif
CUITalkWnd* TalkMenu;
CChangeLevelWnd* UIChangeLevelWnd;

Expand Down
10 changes: 8 additions & 2 deletions src/xrGame/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2124,9 +2124,16 @@ BOOL CWeapon::ParentIsActor()

extern u32 hud_adj_mode;

bool CWeapon::ZoomHideCrosshair()
{
if (hud_adj_mode != 0)
return false;

return m_zoom_params.m_bHideCrosshairInZoom || ZoomTexture();
}

void CWeapon::debug_draw_firedeps()
{
#ifdef DEBUG
if (hud_adj_mode == 5 || hud_adj_mode == 6 || hud_adj_mode == 7)
{
CDebugRenderer& render = Level().debug_renderer();
Expand All @@ -2140,7 +2147,6 @@ void CWeapon::debug_draw_firedeps()
if (hud_adj_mode == 7)
render.draw_aabb(get_LastSP(), 0.005f, 0.005f, 0.005f, color_xrgb(0, 255, 0));
}
#endif // DEBUG
}

const float& CWeapon::hit_probability() const
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class CWeapon : public CHudItemObject, public CShootingObject
IC bool IsZoomed() const { return m_zoom_params.m_bIsZoomModeNow; };
CUIWindow* ZoomTexture();

bool ZoomHideCrosshair() { return m_zoom_params.m_bHideCrosshairInZoom || ZoomTexture(); }
bool ZoomHideCrosshair();
IC float GetZoomFactor() const { return m_zoom_params.m_fCurrentZoomFactor; }
IC void SetZoomFactor(float f) { m_zoom_params.m_fCurrentZoomFactor = f; }
virtual float CurrentZoomFactor();
Expand Down
Loading

0 comments on commit 19bd272

Please sign in to comment.