Skip to content

Commit

Permalink
[STCoP] * hud_adjust: Activating hud_adjust_mode OpenXRay#2.
Browse files Browse the repository at this point in the history
— I couldn't get it to work from STCoP - so I moved it from my project - SWM 3.0(including helper) + own changes..[Romann]
— The hud customizer is activated in the config, in the [debug] section - the 'custom_weapon' parameter - the 'true' flag, after that, in game, either enter the console command 'hud_adjust_mode 1', or press 'LALT+NUM 0'.
—  After that, press the 'H' key - a description of the control will appear on the screen.
— Output to the log - does not work (((. But saving all changes to a separate file-section works.
*   Authors: [Shoker](https://github.com/ShokerStlk) | [Debrovski](https://github.com/Debrovski) | [Romann](https://github.com/Roman-n) |
  • Loading branch information
Roman-n committed Sep 19, 2022
1 parent 19bd272 commit 0f620b2
Show file tree
Hide file tree
Showing 4 changed files with 541 additions and 87 deletions.
20 changes: 15 additions & 5 deletions src/xrGame/ActorInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,22 @@ bool g_bAutoClearCrouch = true;

void CActor::IR_OnKeyboardPress(int cmd)
{
if (hud_adj_mode && pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT))
if (hud_adj_mode)
{
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 (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT))
{
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;
}
else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_END))
{
extern void logInfoAboutTunedItems(); //defined in player_hud_tune.cpp
logInfoAboutTunedItems();
return;
}
}

if (Remote())
Expand Down
10 changes: 4 additions & 6 deletions src/xrGame/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2122,14 +2122,12 @@ BOOL CWeapon::ParentIsActor()
return EA->cast_actor() != nullptr;
}

extern u32 hud_adj_mode;

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

return m_zoom_params.m_bHideCrosshairInZoom || ZoomTexture();
CActor* pA = smart_cast<CActor*>(H_Parent());
if (pA && pA->active_cam() == eacLookAt || hud_adj_mode != 0)
return false;
return m_zoom_params.m_bHideCrosshairInZoom || ZoomTexture();
}

void CWeapon::debug_draw_firedeps()
Expand Down
47 changes: 44 additions & 3 deletions src/xrGame/console_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ extern float psSqueezeVelocity;
extern int psLUA_GCSTEP;
extern int g_auto_ammo_unload;

extern u32 hud_adj_mode;
extern int x_m_x;
extern int x_m_z;
extern BOOL net_cl_inputguaranteed;
Expand Down Expand Up @@ -107,6 +108,7 @@ int g_keypress_on_start = 1;
ENGINE_API extern float g_console_sensitive;

bool bCheatEnable = READ_IF_EXISTS(pSettingsOpenXRay, r_bool, "debug", "cheats_mode", false);
bool isCustomWeapon = READ_IF_EXISTS(pSettingsOpenXRay, r_bool, "debug", "custom_weapon", false);

//Alundaio
extern BOOL g_ai_die_in_anomaly;
Expand Down Expand Up @@ -284,6 +286,40 @@ class CCC_ALifePath : public IConsole_Command
};
#endif // DEBUG

class CCC_U32 : public IConsole_Command
{
protected:
unsigned* value;
unsigned min, max;

public:
const unsigned GetValue() const { return *value; };
void GetBounds(u32& imin, u32& imax) const
{
imin = min;
imax = max;
}
CCC_U32(const char* N, unsigned* V, unsigned _min = 0, unsigned _max = 999)
: IConsole_Command(N), value(V), min(_min), max(_max) {};
virtual void Execute(const char* args)
{
int v = atoi(args);
if (v < min || v > max)
InvalidSyntax();
else
*value = v;
}
virtual void Status(TStatus& S) { itoa(*value, S, 10); }
virtual void Info(TInfo& I) { xr_sprintf(I, sizeof(I), "integer value in range [%d,%d]", min, max); }
virtual void fill_tips(vecTips& tips, u32 mode)
{
TStatus str;
xr_sprintf(str, sizeof(str), "%d (current) [%d,%d]", *value, min, max);
tips.push_back(str);
IConsole_Command::fill_tips(tips, mode);
}
};

class CCC_ALifeTimeFactor : public IConsole_Command
{
public:
Expand Down Expand Up @@ -2098,13 +2134,18 @@ void CCC_RegisterCommands()
CMD4(CCC_FloatBlock, "ph_tri_query_ex_aabb_rate", &ph_console::ph_tri_query_ex_aabb_rate, 1.01f, 3.f);
#endif // DEBUG

if (bCheatEnable)
{
if (bCheatEnable)
{
CMD3(CCC_Mask, "g_god", &psActorFlags, AF_GODMODE);
CMD3(CCC_Mask, "g_unlimitedammo", &psActorFlags, AF_UNLIMITEDAMMO);
CMD1(CCC_SetWeather, "set_weather");
}
if (isCustomWeapon)
{
CMD1(CCC_TuneAttachableItem, "dbg_adjust_attachable_item");
}
CMD4(CCC_U32, "hud_adjust_mode", &hud_adj_mode, 0, 5); /// adjust mode support

}

#ifndef MASTER_GOLD
CMD1(CCC_JumpToLevel, "jump_to_level");
Expand Down
Loading

0 comments on commit 0f620b2

Please sign in to comment.