diff --git a/src/Layers/xrRender/ParticleEffect.cpp b/src/Layers/xrRender/ParticleEffect.cpp index 6a5995042ae..5add4574b31 100644 --- a/src/Layers/xrRender/ParticleEffect.cpp +++ b/src/Layers/xrRender/ParticleEffect.cpp @@ -673,7 +673,7 @@ void CParticleEffect::Render(CBackend& cmd_list, float, bool use_fast_geo) Fmatrix FTold = Device.mFullTransform; if (GetHudMode()) { - Device.mProject.build_projection(deg2rad(psHUD_FOV * Device.fFOV), Device.fASPECT, VIEWPORT_NEAR, + Device.mProject.build_projection(deg2rad(psHUD_FOV * Device.fFOV), Device.fASPECT, HUD_VIEWPORT_NEAR, g_pGamePersistent->Environment().CurrentEnv.far_plane); Device.mFullTransform.mul(Device.mProject, Device.mView); @@ -841,7 +841,7 @@ void CParticleEffect::Render(float, bool) Fmatrix FTold = Device.mFullTransform; if (GetHudMode()) { - Device.mProject.build_projection(deg2rad(psHUD_FOV * Device.fFOV), Device.fASPECT, VIEWPORT_NEAR, + Device.mProject.build_projection(deg2rad(psHUD_FOV * Device.fFOV), Device.fASPECT, HUD_VIEWPORT_NEAR, g_pGamePersistent->Environment().CurrentEnv.far_plane); Device.mFullTransform.mul(Device.mProject, Device.mView); diff --git a/src/Layers/xrRender/r__dsgraph_render.cpp b/src/Layers/xrRender/r__dsgraph_render.cpp index 5a5b21718a9..86b1eba36ce 100644 --- a/src/Layers/xrRender/r__dsgraph_render.cpp +++ b/src/Layers/xrRender/r__dsgraph_render.cpp @@ -167,7 +167,7 @@ class hud_transform_helper Fmatrix prj_new; prj_new.build_projection(deg2rad(psHUD_FOV * Device.fFOV /* *Device.fASPECT*/), Device.fASPECT, - VIEWPORT_NEAR, g_pGamePersistent->Environment().CurrentEnv.far_plane); + HUD_VIEWPORT_NEAR, g_pGamePersistent->Environment().CurrentEnv.far_plane); cmd_list.set_xform_project(prj_new); RImplementation.rmNear(cmd_list); diff --git a/src/xrEngine/device.h b/src/xrEngine/device.h index 424386ab24c..26afdd47581 100644 --- a/src/xrEngine/device.h +++ b/src/xrEngine/device.h @@ -16,6 +16,7 @@ #include "xrCore/ModuleLookup.hpp" #define VIEWPORT_NEAR 0.2f +#define HUD_VIEWPORT_NEAR 0.05f #define DEVICE_RESET_PRECACHE_FRAME_COUNT 10 diff --git a/src/xrEngine/editor_base.h b/src/xrEngine/editor_base.h index fbc728bea9c..b8e440b29a3 100644 --- a/src/xrEngine/editor_base.h +++ b/src/xrEngine/editor_base.h @@ -20,6 +20,9 @@ class XR_NOVTABLE ENGINE_API ide_tool : public pureFrame virtual pcstr tool_name() = 0; bool& get_open_state() { return is_opened; } + bool is_open() const { return is_opened; } + virtual bool is_active() const { return is_opened; } + ImGuiWindowFlags get_default_window_flags() const; }; @@ -57,6 +60,7 @@ class ENGINE_API ide final : auto GetState() const { return m_state; } void SetState(visible_state state); void SwitchToNextState(); + bool IsActiveState() const { return m_state == visible_state::full; } public: // Interface implementations diff --git a/src/xrGame/ActorInput.cpp b/src/xrGame/ActorInput.cpp index 3c71e5521a2..a303d52ad87 100644 --- a/src/xrGame/ActorInput.cpp +++ b/src/xrGame/ActorInput.cpp @@ -30,14 +30,13 @@ #include "clsid_game.h" #include "HUDManager.h" #include "Weapon.h" - -extern u32 hud_adj_mode; +#include "GamePersistent.h" bool g_bAutoClearCrouch = true; void CActor::IR_OnKeyboardPress(int cmd) { - if (hud_adj_mode && pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) + if (GamePersistent().GetHudTuner().is_active()) return; if (Remote()) @@ -213,11 +212,8 @@ void CActor::IR_OnKeyboardPress(int cmd) void CActor::IR_OnMouseWheel(float x, float y) { - if (hud_adj_mode) - { - g_player_hud->tune({ 0, 0, static_cast(std::round(y)) }); + if (GamePersistent().GetHudTuner().is_active()) return; - } if (inventory().Action((y > 0) ? (u16)kWPN_ZOOM_INC : (u16)kWPN_ZOOM_DEC, CMD_START)) return; @@ -230,7 +226,7 @@ void CActor::IR_OnMouseWheel(float x, float y) void CActor::IR_OnKeyboardRelease(int cmd) { - if (hud_adj_mode && pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) + if (GamePersistent().GetHudTuner().is_active()) return; if (Remote()) @@ -272,7 +268,7 @@ void CActor::IR_OnKeyboardRelease(int cmd) void CActor::IR_OnKeyboardHold(int cmd) { - if (hud_adj_mode && pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) + if (GamePersistent().GetHudTuner().is_active()) return; if (Remote() || !g_Alive()) @@ -352,11 +348,8 @@ void CActor::OnAxisMove(float x, float y, float scale, bool invert) void CActor::IR_OnMouseMove(int dx, int dy) { - if (hud_adj_mode) - { - g_player_hud->tune(Ivector().set(dx, dy, 0)); + if (GamePersistent().GetHudTuner().is_active()) return; - } PIItem iitem = inventory().ActiveItem(); if (iitem && iitem->cast_hud_item()) diff --git a/src/xrGame/CMakeLists.txt b/src/xrGame/CMakeLists.txt index 02b4ec50002..a0850bdbc35 100644 --- a/src/xrGame/CMakeLists.txt +++ b/src/xrGame/CMakeLists.txt @@ -1005,6 +1005,7 @@ target_sources(xrGame PRIVATE player_hud.cpp player_hud.h player_hud_tune.cpp + player_hud_tune.h player_name_modifyer.cpp player_name_modifyer.h player_spot_params.cpp diff --git a/src/xrGame/GamePersistent.h b/src/xrGame/GamePersistent.h index 8ed8431e976..1b5c7df47f6 100644 --- a/src/xrGame/GamePersistent.h +++ b/src/xrGame/GamePersistent.h @@ -3,6 +3,7 @@ #pragma once #include "xrEngine/IGame_Persistent.h" +#include "player_hud_tune.h" class Task; class CMainMenu; @@ -40,6 +41,9 @@ class CGamePersistent : public IGame_Persistent fastdelegate::FastDelegate0<> m_intro_event; + // hud tuner + CHudTuner m_hudTuner; + void start_logo_intro(); void update_logo_intro(); @@ -101,6 +105,8 @@ class CGamePersistent : public IGame_Persistent virtual void SetBaseDof(const Fvector3& dof); virtual void OnSectorChanged(IRender_Sector::sector_id_t sector); virtual void OnAssetsChanged(); + + CHudTuner GetHudTuner() { return m_hudTuner; } }; IC CGamePersistent& GamePersistent() { return *((CGamePersistent*)g_pGamePersistent); } diff --git a/src/xrGame/HudItem.cpp b/src/xrGame/HudItem.cpp index 6e8bae3a1d0..0cecb3cf54e 100644 --- a/src/xrGame/HudItem.cpp +++ b/src/xrGame/HudItem.cpp @@ -75,7 +75,6 @@ void CHudItem::renderable_Render(u32 context_id, IRenderable* root) if (!object().H_Parent() || (!_hud_render && !IsHidden())) { on_renderable_Render(context_id, root); - debug_draw_firedeps(); } else if (object().H_Parent()) { @@ -431,6 +430,55 @@ void CHudItem::OnMovementChanged(ACTOR_DEFS::EMoveCommand cmd) } } +extern ENGINE_API float psHUD_FOV; +void CHudItem::TransformPosFromWorldToHud(Fvector& worldPos) +{ + CActor* actor = smart_cast(object().H_Parent()); + + Fmatrix mView; + mView.set(Device.mView); + if (GetHUDmode() && actor) + { + Fmatrix trans; + actor->Cameras().hud_camera_Matrix(trans); + mView.build_camera_dir(trans.c, trans.k, trans.j); + } + + Fmatrix hud_project; + hud_project.build_projection(deg2rad(psHUD_FOV * Device.fFOV), Device.fASPECT, HUD_VIEWPORT_NEAR, + g_pGamePersistent->Environment().CurrentEnv.far_plane); + + mView.transform_tiny(worldPos); + hud_project.transform_tiny(worldPos); + + Fmatrix().set(Device.mProject).invert().transform_tiny(worldPos); + Fmatrix().set(mView).invert().transform_tiny(worldPos); +} + +void CHudItem::TransformDirFromWorldToHud(Fvector& worldDir) +{ + CActor* actor = smart_cast(object().H_Parent()); + + Fmatrix mView; + mView.set(Device.mView); + if (GetHUDmode() && actor) + { + Fmatrix trans; + actor->Cameras().hud_camera_Matrix(trans); + mView.build_camera_dir(trans.c, trans.k, trans.j); + } + + Fmatrix hud_project; + hud_project.build_projection(deg2rad(psHUD_FOV * Device.fFOV), Device.fASPECT, HUD_VIEWPORT_NEAR, + g_pGamePersistent->Environment().CurrentEnv.far_plane); + + mView.transform_dir(worldDir); + hud_project.transform_dir(worldDir); + + Fmatrix().set(Device.mProject).invert().transform_dir(worldDir); + Fmatrix().set(mView).invert().transform_dir(worldDir); +} + attachable_hud_item* CHudItem::HudItemData() const { attachable_hud_item* hi = NULL; diff --git a/src/xrGame/HudItem.h b/src/xrGame/HudItem.h index f11c3820bd0..0ce80570238 100644 --- a/src/xrGame/HudItem.h +++ b/src/xrGame/HudItem.h @@ -93,6 +93,9 @@ class CHudItem : public CHUDState virtual bool Action(u16 cmd, u32 flags) { return false; } void OnMovementChanged(ACTOR_DEFS::EMoveCommand cmd); + virtual void TransformPosFromWorldToHud(Fvector& worldPos); + virtual void TransformDirFromWorldToHud(Fvector& worldDir); + virtual u8 GetCurrentHudOffsetIdx() { return 0; } BOOL GetHUDmode(); IC BOOL IsPending() const { return !!m_huditem_flags.test(fl_pending); } @@ -178,7 +181,6 @@ class CHudItem : public CHUDState } IC u32 animation_slot() { return m_animation_slot; } virtual void on_renderable_Render(u32 context_id, IRenderable* root) = 0; - virtual void debug_draw_firedeps(){}; virtual CHudItem* cast_hud_item() { return this; } void PlayAnimIdleMovingCrouch(); //AVO: new crouch idle animation diff --git a/src/xrGame/Missile.cpp b/src/xrGame/Missile.cpp index 06d3bc33feb..a86f382bd1c 100644 --- a/src/xrGame/Missile.cpp +++ b/src/xrGame/Missile.cpp @@ -24,6 +24,7 @@ #include "xrUICore/ProgressBar/UIProgressShape.h" #include "ui/UIXmlInit.h" #include "PhysicsShellHolder.h" +#include "GamePersistent.h" CUIProgressShape* g_MissileForceShape = NULL; @@ -188,8 +189,6 @@ void CMissile::OnH_B_Independent(bool just_before_destroy) } } -extern u32 hud_adj_mode; - void CMissile::UpdateCL() { m_dwStateTime += Device.dwTimeDelta; @@ -199,7 +198,7 @@ void CMissile::UpdateCL() CActor* pActor = smart_cast(H_Parent()); if (pActor && !pActor->AnyMove() && this == pActor->inventory().ActiveItem()) { - if (hud_adj_mode == 0 && GetState() == eIdle && (Device.dwTimeGlobal - m_dw_curr_substate_time > 20000)) + if (!GamePersistent().GetHudTuner().is_active() && GetState() == eIdle && (Device.dwTimeGlobal - m_dw_curr_substate_time > 20000)) { SwitchState(eBore); ResetSubStateTime(); diff --git a/src/xrGame/UIGameSP.cpp b/src/xrGame/UIGameSP.cpp index 6da0f630772..7399921e8b2 100644 --- a/src/xrGame/UIGameSP.cpp +++ b/src/xrGame/UIGameSP.cpp @@ -60,12 +60,6 @@ void CUIGameSP::SetClGame(game_cl_GameState* g) m_game = smart_cast(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() { @@ -109,11 +103,6 @@ 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(Level().CurrentEntity()); if (!pInvOwner) return false; @@ -182,8 +171,6 @@ bool CUIGameSP::IR_UIOnKeyboardPress(int dik) void CUIGameSP::Render() { inherited::Render(); - hud_draw_adjust_mode(); - attach_draw_adjust_mode(); } #endif diff --git a/src/xrGame/Weapon.cpp b/src/xrGame/Weapon.cpp index c8c48fdbe0c..c556cb13eba 100644 --- a/src/xrGame/Weapon.cpp +++ b/src/xrGame/Weapon.cpp @@ -27,6 +27,7 @@ #include "Torch.h" #include "xrNetServer/NET_Messages.h" #include "xrCore/xr_token.h" +#include "GamePersistent.h" #define WEAPON_REMOVE_TIME 60000 #define ROTATION_TIME 0.25f @@ -857,7 +858,6 @@ void CWeapon::OnH_B_Chield() m_set_next_ammoType_on_reload = undefined_ammo_type; } -extern u32 hud_adj_mode; bool CWeapon::AllowBore() { return true; } void CWeapon::UpdateCL() { @@ -878,7 +878,7 @@ void CWeapon::UpdateCL() CActor* pActor = smart_cast(H_Parent()); if (pActor && !pActor->AnyMove() && this == pActor->inventory().ActiveItem()) { - if (hud_adj_mode == 0 && GetState() == eIdle && (Device.dwTimeGlobal - m_dw_curr_substate_time > 20000) && + if (!GamePersistent().GetHudTuner().is_active() && GetState() == eIdle && (Device.dwTimeGlobal - m_dw_curr_substate_time > 20000) && !IsZoomed() && g_player_hud->attached_item(1) == nullptr) { if (AllowBore()) @@ -1297,6 +1297,8 @@ bool CWeapon::SilencerAttachable() { return (ALife::eAddonAttachable == m_eSilen void CWeapon::UpdateHUDAddonsVisibility() { + if (GamePersistent().GetHudTuner().is_active()) + return; static shared_str wpn_scope = WPN_SCOPE; static shared_str wpn_silencer = WPN_SILENCER; static shared_str wpn_grenade_launcher = WPN_GRENADE_LAUNCHER; @@ -1344,6 +1346,9 @@ void CWeapon::UpdateHUDAddonsVisibility() void CWeapon::UpdateAddonsVisibility() { + if (GamePersistent().GetHudTuner().is_active()) + return; + static shared_str wpn_scope = WPN_SCOPE; static shared_str wpn_silencer = WPN_SILENCER; static shared_str wpn_grenade_launcher = WPN_GRENADE_LAUNCHER; @@ -1894,27 +1899,6 @@ BOOL CWeapon::ParentIsActor() return EA->cast_actor() != nullptr; } -extern u32 hud_adj_mode; - -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(); - - if (hud_adj_mode == 5) - render.draw_aabb(get_LastFP(), 0.005f, 0.005f, 0.005f, color_xrgb(255, 0, 0)); - - if (hud_adj_mode == 6) - render.draw_aabb(get_LastFP2(), 0.005f, 0.005f, 0.005f, color_xrgb(0, 0, 255)); - - 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 { VERIFY((g_SingleGameDifficulty >= egdNovice) && (g_SingleGameDifficulty <= egdMaster)); diff --git a/src/xrGame/Weapon.h b/src/xrGame/Weapon.h index 922d7d219ed..c7d28d2b3eb 100644 --- a/src/xrGame/Weapon.h +++ b/src/xrGame/Weapon.h @@ -311,7 +311,6 @@ class CWeapon : public CHudItemObject, public CShootingObject return m_current_firedeps.m_FireParticlesXForm; } virtual void ForceUpdateFireParticles(); - virtual void debug_draw_firedeps(); protected: virtual void SetDefaults(); diff --git a/src/xrGame/attachable_item.cpp b/src/xrGame/attachable_item.cpp index fdf8d7d56ca..9d7f6da8ee0 100644 --- a/src/xrGame/attachable_item.cpp +++ b/src/xrGame/attachable_item.cpp @@ -132,98 +132,3 @@ bool CAttachableItem::use_parent_ai_locations() const { return !enabled(); } - -#ifdef DEBUG -float ATT_ITEM_MOVE_CURR = 0.01f; -float ATT_ITEM_ROT_CURR = 0.1f; - -float ATT_ITEM_MOVE_STEP = 0.001f; -float ATT_ITEM_ROT_STEP = 0.01f; - -void attach_adjust_mode_keyb(int dik) -{ - if (!CAttachableItem::m_dbgItem) - return; - - bool b_move = !!(pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)); - bool b_rot = !!(pInput->iGetAsyncKeyState(SDL_SCANCODE_LALT)); - - int axis = -1; - if (pInput->iGetAsyncKeyState(SDL_SCANCODE_Z)) - axis = 0; - else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_X)) - axis = 1; - if (pInput->iGetAsyncKeyState(SDL_SCANCODE_C)) - axis = 2; - - if (!b_move && !b_rot) - return; - - switch (dik) - { - case SDL_SCANCODE_LEFT: - { - if (b_move) - CAttachableItem::mov(axis, ATT_ITEM_MOVE_CURR); - else - CAttachableItem::rot(axis, ATT_ITEM_ROT_CURR); - } - break; - case SDL_SCANCODE_RIGHT: - { - if (b_move) - CAttachableItem::mov(axis, -ATT_ITEM_MOVE_CURR); - else - CAttachableItem::rot(axis, -ATT_ITEM_ROT_CURR); - } - break; - case SDL_SCANCODE_PAGEUP: - { - if (b_move) - ATT_ITEM_MOVE_CURR += ATT_ITEM_MOVE_STEP; - else - ATT_ITEM_ROT_CURR += ATT_ITEM_ROT_STEP; - } - break; - case SDL_SCANCODE_PAGEDOWN: - { - if (b_move) - ATT_ITEM_MOVE_CURR -= ATT_ITEM_MOVE_STEP; - else - ATT_ITEM_ROT_CURR -= ATT_ITEM_ROT_STEP; - } - break; - }; -} - -void attach_draw_adjust_mode() -{ - if (!CAttachableItem::m_dbgItem) - return; - - string1024 _text; - - CGameFont* F = UI().Font().pFontDI; - F->SetAligment(CGameFont::alCenter); - F->OutSetI(0.f, -0.8f); - F->SetColor(0xffffffff); - xr_sprintf(_text, "Adjusting attachable item [%s]", CAttachableItem::m_dbgItem->object().cNameSect().c_str()); - F->OutNext(_text); - xr_sprintf(_text, "move step [%3.3f] rotate step [%3.3f]", ATT_ITEM_MOVE_CURR, ATT_ITEM_ROT_CURR); - F->OutNext(_text); - - F->OutNext("HOLD LShift to move. ALT to rotate"); - F->OutNext("HOLD [Z]-x axis [X]-y axis [C]-z axis"); - - F->OutNext("RIGHT-LEFT - move. PgUP-PgDOWN - step"); - F->OutSkip(); - - Fvector _pos = CAttachableItem::get_pos_offset(); - xr_sprintf(_text, "attach_position_offset IS [%3.3f][%3.3f][%3.3f]", _pos.x, _pos.y, _pos.z); - F->OutNext(_text); - - Fvector _ang = CAttachableItem::get_angle_offset(); - xr_sprintf(_text, "attach_angle_offset IS [%3.3f][%3.3f][%3.3f]", _ang.x, _ang.y, _ang.z); - F->OutNext(_text); -} -#endif // #ifdef DEBUG diff --git a/src/xrGame/player_hud.cpp b/src/xrGame/player_hud.cpp index ae82710b3a8..9489b2cdec1 100644 --- a/src/xrGame/player_hud.cpp +++ b/src/xrGame/player_hud.cpp @@ -7,8 +7,8 @@ #include "static_cast_checked.hpp" #include "ActorEffector.h" #include "WeaponMagazinedWGrenade.h" // XXX: move somewhere +#include "GamePersistent.h" -extern u32 hud_adj_mode; player_hud* g_player_hud = nullptr; extern ENGINE_API shared_str current_player_hud_sect; // clang-format off @@ -131,7 +131,7 @@ void attachable_hud_item::update(bool bForce) reload_measures(); } - if (hud_adj_mode > 0) + if (GamePersistent().GetHudTuner().is_active()) m_measures.update(m_attach_offset); m_parent->calc_transform(m_attach_place_idx, m_attach_offset, m_item_transform); @@ -199,7 +199,6 @@ bool attachable_hud_item::need_renderable() const { return m_parent_hud_item->ne void attachable_hud_item::render(u32 context_id, IRenderable* root) { GEnv.Render->add_Visual(context_id, root, m_model->dcast_RenderVisual(), m_item_transform); - debug_draw_firedeps(); m_parent_hud_item->render_hud_mode(); } diff --git a/src/xrGame/player_hud.h b/src/xrGame/player_hud.h index cbba3c8e909..28acd5eaf5b 100644 --- a/src/xrGame/player_hud.h +++ b/src/xrGame/player_hud.h @@ -108,7 +108,6 @@ struct attachable_hud_item bool render_item_ui_query() const; bool need_renderable() const; void set_bone_visible(const shared_str& bone_name, BOOL bVisibility, BOOL bSilent = FALSE); - void debug_draw_firedeps(); // hands bind position Fvector& hands_attach_pos(); diff --git a/src/xrGame/player_hud_tune.cpp b/src/xrGame/player_hud_tune.cpp index 087b4108cb7..528b568df9c 100644 --- a/src/xrGame/player_hud_tune.cpp +++ b/src/xrGame/player_hud_tune.cpp @@ -11,372 +11,280 @@ #include "xrUICore/ui_base.h" #include "debug_renderer.h" #include "xrEngine/GameFont.h" +#include "player_hud_tune.h" -u32 hud_adj_mode = 0; -u32 hud_adj_item_idx = 0; -// "press SHIFT+NUM 0-return 1-hud_pos 2-hud_rot 3-itm_pos 4-itm_rot 5-fire_point 6-fire_2_point 7-shell_point"; +extern ENGINE_API float psHUD_FOV; -float _delta_pos = 0.0005f; -float _delta_rot = 0.05f; +CHudTuner::CHudTuner() +{ + ImGui::SetCurrentContext(Device.GetImGuiContext()); + paused = fsimilar(Device.time_factor(), EPS); +} -bool is_attachable_item_tuning_mode() +bool CHudTuner::is_active() const { - return pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT) || pInput->iGetAsyncKeyState(SDL_SCANCODE_Z) || - pInput->iGetAsyncKeyState(SDL_SCANCODE_X) || pInput->iGetAsyncKeyState(SDL_SCANCODE_C); + return is_open() && Device.editor().IsActiveState(); } -void tune_remap(const Ivector& in_values, Ivector& out_values) +void CHudTuner::ResetToDefaultValues() { - if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) + if (current_hud_item) { - out_values = in_values; - } - else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_Z)) - { // strict by X - out_values.x = in_values.y; - out_values.y = 0; - out_values.z = 0; - } - else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_X)) - { // strict by Y - out_values.x = 0; - out_values.y = in_values.y; - out_values.z = 0; - } - else if (pInput->iGetAsyncKeyState(SDL_SCANCODE_C)) - { // strict by Z - out_values.x = 0; - out_values.y = 0; - out_values.z = in_values.y; + current_hud_item->reload_measures(); + curr_measures = current_hud_item->m_measures; } else { - out_values.set(0, 0, 0); + Fvector zero = { 0, 0, 0 }; + curr_measures.m_hands_attach[0] = zero; + curr_measures.m_hands_attach[1] = zero; + curr_measures.m_hands_offset[0][0] = zero; + curr_measures.m_hands_offset[1][0] = zero; + curr_measures.m_hands_offset[0][1] = zero; + curr_measures.m_hands_offset[1][1] = zero; + curr_measures.m_hands_offset[0][2] = zero; + curr_measures.m_hands_offset[1][2] = zero; + curr_measures.m_item_attach[0] = zero; + curr_measures.m_item_attach[1] = zero; + curr_measures.m_fire_point_offset = zero; + curr_measures.m_fire_point2_offset = zero; + curr_measures.m_shell_point_offset = zero; } -} -void calc_cam_diff_pos(Fmatrix item_transform, Fvector diff, Fvector& res) -{ - Fmatrix cam_m; - cam_m.i.set(Device.vCameraRight); - cam_m.j.set(Device.vCameraTop); - cam_m.k.set(Device.vCameraDirection); - cam_m.c.set(Device.vCameraPosition); - - Fvector res1; - cam_m.transform_dir(res1, diff); - - Fmatrix item_transform_i; - item_transform_i.invert(item_transform); - item_transform_i.transform_dir(res, res1); + new_measures = curr_measures; } -void calc_cam_diff_rot(Fmatrix item_transform, Fvector diff, Fvector& res) +void CHudTuner::UpdateValues() { - Fmatrix cam_m; - cam_m.i.set(Device.vCameraRight); - cam_m.j.set(Device.vCameraTop); - cam_m.k.set(Device.vCameraDirection); - cam_m.c.set(Device.vCameraPosition); - - Fmatrix R; - R.identity(); - if (!fis_zero(diff.x)) - { - R.rotation(cam_m.i, diff.x); - } - else if (!fis_zero(diff.y)) - { - R.rotation(cam_m.j, diff.y); - } - else if (!fis_zero(diff.z)) + if (current_hud_item) { - R.rotation(cam_m.k, diff.z); - }; + new_measures.m_hands_attach[0].set(curr_measures.m_hands_attach[0]); + new_measures.m_hands_attach[1].set(curr_measures.m_hands_attach[1]); + new_measures.m_hands_attach[0].add(new_measures.m_hands_offset[0][0]); + new_measures.m_hands_attach[1].add(new_measures.m_hands_offset[1][0]); - Fmatrix item_transform_i; - item_transform_i.invert(item_transform); - R.mulB_43(item_transform); - R.mulA_43(item_transform_i); - - R.getHPB(res); - - res.mul(180.0f / PI); + current_hud_item->m_measures = new_measures; + } } -void attachable_hud_item::tune(Ivector values) +void CHudTuner::OnFrame() { #ifndef MASTER_GOLD - if (!is_attachable_item_tuning_mode()) + if (!get_open_state()) return; - Fvector diff; - diff.set(0, 0, 0); + if (!g_player_hud) + return; - if (hud_adj_mode == 3 || hud_adj_mode == 4) + auto hud_item = g_player_hud->attached_item(current_hud_idx); + if (current_hud_item != hud_item) { - if (hud_adj_mode == 3) - { - if (values.x) - diff.x = (values.x > 0) ? _delta_pos : -_delta_pos; - if (values.y) - diff.y = (values.y > 0) ? _delta_pos : -_delta_pos; - if (values.z) - diff.z = (values.z > 0) ? _delta_pos : -_delta_pos; - - Fvector d; - Fmatrix ancor_m; - m_parent->calc_transform(m_attach_place_idx, Fidentity, ancor_m); - calc_cam_diff_pos(ancor_m, diff, d); - m_measures.m_item_attach[0].add(d); - } - else if (hud_adj_mode == 4) - { - if (values.x) - diff.x = (values.x > 0) ? _delta_rot : -_delta_rot; - if (values.y) - diff.y = (values.y > 0) ? _delta_rot : -_delta_rot; - if (values.z) - diff.z = (values.z > 0) ? _delta_rot : -_delta_rot; - - Fvector d; - Fmatrix ancor_m; - m_parent->calc_transform(m_attach_place_idx, Fidentity, ancor_m); - - calc_cam_diff_pos(m_item_transform, diff, d); - m_measures.m_item_attach[1].add(d); - } - - if ((values.x) || (values.y) || (values.z)) - { - Msg("[%s]", m_sect_name.c_str()); - Msg("item_position = %f,%f,%f", m_measures.m_item_attach[0].x, m_measures.m_item_attach[0].y, - m_measures.m_item_attach[0].z); - Msg("item_orientation = %f,%f,%f", m_measures.m_item_attach[1].x, m_measures.m_item_attach[1].y, - m_measures.m_item_attach[1].z); - Log("-----------"); - } + current_hud_item = hud_item; + ResetToDefaultValues(); } - if (hud_adj_mode == 5 || hud_adj_mode == 6 || hud_adj_mode == 7) + if (ImGui::Begin(tool_name(), &get_open_state(), get_default_window_flags())) { - if (values.x) - diff.x = (values.x > 0) ? _delta_pos : -_delta_pos; - if (values.y) - diff.y = (values.y > 0) ? _delta_pos : -_delta_pos; - if (values.z) - diff.z = (values.z > 0) ? _delta_pos : -_delta_pos; - - if (hud_adj_mode == 5) + if (ImGui::BeginMenuBar()) { - m_measures.m_fire_point_offset.add(diff); - } - if (hud_adj_mode == 6) - { - m_measures.m_fire_point2_offset.add(diff); - } - if (hud_adj_mode == 7) - { - m_measures.m_shell_point_offset.add(diff); - } - if ((values.x) || (values.y) || (values.z)) - { - Msg("[%s]", m_sect_name.c_str()); - Msg("fire_point = %f,%f,%f", m_measures.m_fire_point_offset.x, m_measures.m_fire_point_offset.y, - m_measures.m_fire_point_offset.z); - Msg("fire_point2 = %f,%f,%f", m_measures.m_fire_point2_offset.x, - m_measures.m_fire_point2_offset.y, m_measures.m_fire_point2_offset.z); - Msg("shell_point = %f,%f,%f", m_measures.m_shell_point_offset.x, - m_measures.m_shell_point_offset.y, m_measures.m_shell_point_offset.z); - Log("-----------"); - } - } -#endif // #ifndef MASTER_GOLD -} - -void attachable_hud_item::debug_draw_firedeps() -{ -#ifdef DEBUG - bool bForce = (hud_adj_mode == 3 || hud_adj_mode == 4); - - if (hud_adj_mode == 5 || hud_adj_mode == 6 || hud_adj_mode == 7 || bForce) - { - CDebugRenderer& render = Level().debug_renderer(); - - firedeps fd; - setup_firedeps(fd); - - if (hud_adj_mode == 5 || bForce) - render.draw_aabb(fd.vLastFP, 0.005f, 0.005f, 0.005f, color_xrgb(255, 0, 0)); - - if (hud_adj_mode == 6) - render.draw_aabb(fd.vLastFP2, 0.005f, 0.005f, 0.005f, color_xrgb(0, 0, 255)); + if (ImGui::RadioButton("Pause", paused)) + { + paused = !paused; + float time_factor = 1.f; + if (paused) + { + time_factor = EPS; + } + Device.time_factor(time_factor); + } - if (hud_adj_mode == 7) - render.draw_aabb(fd.vLastSP, 0.005f, 0.005f, 0.005f, color_xrgb(0, 255, 0)); - } -#endif // DEBUG -} + ImGui::EndMenuBar(); + } -void player_hud::tune(Ivector _values) -{ -#ifndef MASTER_GOLD - Ivector values; - tune_remap(_values, values); + if (ImGui::CollapsingHeader("Main Settings", ImGuiTreeNodeFlags_DefaultOpen)) + { + if (ImGui::BeginCombo("Hud Item Mode", hud_item_mode[current_hud_idx])) + { + for (const auto& [idx, value] : hud_item_mode) + { + if (ImGui::Selectable(value, current_hud_idx == idx)) + { + current_hud_idx = idx; + } + } + ImGui::EndCombo(); + } - bool is_16x9 = UI().is_widescreen(); + ImGui::LabelText("Current item", "%s", hud_item ? hud_item->m_sect_name.c_str() : "none"); - if (hud_adj_mode == 1 || hud_adj_mode == 2) - { - Fvector diff; - diff.set(0, 0, 0); + ImGui::SliderFloat("HUD FOV", &psHUD_FOV, 0.1f, 1.0f); - float _curr_dr = _delta_rot; + ImGui::NewLine(); - attachable_hud_item* hi = m_attached_items[hud_adj_item_idx]; - if (!hi) - return; + ImGui::SliderFloat("Position step", &_delta_pos, 0.0000001f, 0.001f, "%.7f"); + ImGui::SliderFloat("Rotation step", &_delta_rot, 0.000001f, 0.1f, "%.6f"); - u8 idx = hi->m_parent_hud_item->GetCurrentHudOffsetIdx(); - if (idx) - _curr_dr /= 20.0f; + ImGui::DragFloat3(hud_adj_modes[HUD_POS], (float*)&new_measures.m_hands_offset[0][0], _delta_pos, 0.f, 0.f, "%.7f"); + ImGui::DragFloat3(hud_adj_modes[HUD_ROT], (float*)&new_measures.m_hands_offset[1][0], _delta_rot, 0.f, 0.f, "%.7f"); + ImGui::DragFloat3(hud_adj_modes[HUD_POS_AIM], (float*)&new_measures.m_hands_offset[0][1], _delta_pos, 0.f, 0.f, "%.7f"); + ImGui::DragFloat3(hud_adj_modes[HUD_ROT_AIM], (float*)&new_measures.m_hands_offset[1][1], _delta_rot, 0.f, 0.f, "%.7f"); + ImGui::DragFloat3(hud_adj_modes[HUD_POS_GL], (float*)&new_measures.m_hands_offset[0][2], _delta_pos, 0.f, 0.f, "%.7f"); + ImGui::DragFloat3(hud_adj_modes[HUD_ROT_GL], (float*)&new_measures.m_hands_offset[1][2], _delta_rot, 0.f, 0.f, "%.7f"); + ImGui::DragFloat3(hud_adj_modes[ITEM_POS], (float*)&new_measures.m_item_attach[0], _delta_pos, 0.f, 0.f, "%.7f"); + ImGui::DragFloat3(hud_adj_modes[ITEM_ROT], (float*)&new_measures.m_item_attach[1], _delta_rot, 0.f, 0.f, "%.7f"); + ImGui::DragFloat3(hud_adj_modes[FIRE_POINT], (float*)&new_measures.m_fire_point_offset, _delta_pos, 0.f, 0.f, "%.7f"); + ImGui::DragFloat3(hud_adj_modes[FIRE_POINT_2], (float*)&new_measures.m_fire_point2_offset, _delta_pos, 0.f, 0.f, "%.7f"); + ImGui::DragFloat3(hud_adj_modes[SHELL_POINT], (float*)&new_measures.m_shell_point_offset, _delta_pos, 0.f, 0.f, "%.7f"); - Fvector& pos_ = (idx != 0) ? hi->hands_offset_pos() : hi->hands_attach_pos(); - Fvector& rot_ = (idx != 0) ? hi->hands_offset_rot() : hi->hands_attach_rot(); + UpdateValues(); - if (hud_adj_mode == 1) - { - if (values.x) - diff.x = (values.x < 0) ? _delta_pos : -_delta_pos; - if (values.y) - diff.y = (values.y > 0) ? _delta_pos : -_delta_pos; - if (values.z) - diff.z = (values.z > 0) ? _delta_pos : -_delta_pos; - - pos_.add(diff); - } + string128 selectable; - if (hud_adj_mode == 2) - { - if (values.x) - diff.x = (values.x > 0) ? _curr_dr : -_curr_dr; - if (values.y) - diff.y = (values.y > 0) ? _curr_dr : -_curr_dr; - if (values.z) - diff.z = (values.z > 0) ? _curr_dr : -_curr_dr; - - rot_.add(diff); - } - if ((values.x) || (values.y) || (values.z)) - { - if (idx == 0) + if (current_hud_item) { - Msg("[%s]", hi->m_sect_name.c_str()); - Msg("hands_position%s = %f,%f,%f", (is_16x9) ? "_16x9" : "", pos_.x, pos_.y, pos_.z); - Msg("hands_orientation%s = %f,%f,%f", (is_16x9) ? "_16x9" : "", rot_.x, rot_.y, rot_.z); - Log("-----------"); - } - else if (idx == 1) - { - Msg("[%s]", hi->m_sect_name.c_str()); - Msg("aim_hud_offset_pos%s = %f,%f,%f", (is_16x9) ? "_16x9" : "", pos_.x, pos_.y, pos_.z); - Msg("aim_hud_offset_rot%s = %f,%f,%f", (is_16x9) ? "_16x9" : "", rot_.x, rot_.y, rot_.z); - Log("-----------"); + bool is_16x9 = UI().is_widescreen(); + shared_str m_sect_name = current_hud_item->m_sect_name; + + ImGuiIO& io = ImGui::GetIO(); + + if (ImGui::Button("Copy formatted values to clipboard")) + { + ImGui::LogToClipboard(); + xr_sprintf(selectable, "[%s]\n", m_sect_name.c_str()); + ImGui::LogText(selectable); + xr_sprintf(selectable, "hands_position%s = %f,%f,%f\n", (is_16x9) ? "_16x9" : "", new_measures.m_hands_offset[0][0].x, new_measures.m_hands_offset[0][0].y, new_measures.m_hands_offset[0][0].z); + ImGui::LogText(selectable); + xr_sprintf(selectable, "hands_orientation%s = %f,%f,%f\n", (is_16x9) ? "_16x9" : "", new_measures.m_hands_offset[1][0].x, new_measures.m_hands_offset[1][0].y, new_measures.m_hands_offset[1][0].z); + ImGui::LogText(selectable); + xr_sprintf(selectable, "aim_hud_offset_pos%s = %f,%f,%f\n", (is_16x9) ? "_16x9" : "", new_measures.m_hands_offset[0][1].x, new_measures.m_hands_offset[0][1].y, new_measures.m_hands_offset[0][1].z); + ImGui::LogText(selectable); + xr_sprintf(selectable, "aim_hud_offset_rot%s = %f,%f,%f\n", (is_16x9) ? "_16x9" : "", new_measures.m_hands_offset[1][1].x, new_measures.m_hands_offset[1][1].y, new_measures.m_hands_offset[1][1].z); + ImGui::LogText(selectable); + xr_sprintf(selectable, "gl_hud_offset_pos%s = %f,%f,%f\n", (is_16x9) ? "_16x9" : "", new_measures.m_hands_offset[0][2].x, new_measures.m_hands_offset[0][2].y, new_measures.m_hands_offset[0][2].z); + ImGui::LogText(selectable); + xr_sprintf(selectable, "gl_hud_offset_rot%s = %f,%f,%f\n", (is_16x9) ? "_16x9" : "", new_measures.m_hands_offset[1][2].x, new_measures.m_hands_offset[1][2].y, new_measures.m_hands_offset[1][2].z); + ImGui::LogText(selectable); + xr_sprintf(selectable, "item_position = %f,%f,%f\n", new_measures.m_item_attach[0].x, new_measures.m_item_attach[0].y, new_measures.m_item_attach[0].z); + ImGui::LogText(selectable); + xr_sprintf(selectable, "item_orientation = %f,%f,%f\n", new_measures.m_item_attach[1].x, new_measures.m_item_attach[1].y, new_measures.m_item_attach[1].z); + ImGui::LogText(selectable); + xr_sprintf(selectable, "fire_point = %f,%f,%f\n", new_measures.m_fire_point_offset.x, new_measures.m_fire_point_offset.y, new_measures.m_fire_point_offset.z); + ImGui::LogText(selectable); + xr_sprintf(selectable, "fire_point = %f,%f,%f\n", new_measures.m_fire_point2_offset.x, new_measures.m_fire_point2_offset.y, new_measures.m_fire_point2_offset.z); + ImGui::LogText(selectable); + xr_sprintf(selectable, "shell_point = %f,%f,%f\n", new_measures.m_shell_point_offset.x, new_measures.m_shell_point_offset.y, new_measures.m_shell_point_offset.z); + ImGui::LogText(selectable); + ImGui::LogFinish(); + } + + ImGui::NewLine(); + +#ifdef DEBUG + firedeps fd; + current_hud_item->setup_firedeps(fd); + collide::rq_result& RQ = HUD().GetCurrentRayQuery(); + + CDebugRenderer& render = Level().debug_renderer(); + + ImGui::SliderFloat("Debug Point Size", &debug_point_size, 0.00005f, 1.f, "%.5f"); + if (ImGui::RadioButton("Draw Fire Point", draw_fp)) { draw_fp = !draw_fp; }; ImGui::SameLine(); + if (ImGui::RadioButton("Draw Fire Point (GL)", draw_fp2)) { draw_fp2 = !draw_fp2; } ImGui::SameLine(); + if (ImGui::RadioButton("Draw Fire Direction", draw_fd)) { draw_fd = !draw_fd; } ImGui::SameLine(); + if (ImGui::RadioButton("Draw Fire Direction (GL)", draw_fd2)) { draw_fd2 = !draw_fd2; } ImGui::SameLine(); + if (ImGui::RadioButton("Draw Shell Point", draw_sp)) { draw_sp = !draw_sp; } + + if (draw_fp) + { + Fvector point; + point.set(fd.vLastFP); + current_hud_item->m_parent_hud_item->TransformPosFromWorldToHud(point); + render.draw_aabb(point, debug_point_size, debug_point_size, debug_point_size, color_xrgb(255, 0, 0)); + } + + if (draw_fp2) + { + Fvector point; + point.set(fd.vLastFP2); + current_hud_item->m_parent_hud_item->TransformPosFromWorldToHud(point); + render.draw_aabb(point, debug_point_size, debug_point_size, debug_point_size, color_xrgb(255, 0, 0)); + } + + if (draw_fd) + { + Fvector point; + Fvector dir; + point.set(fd.vLastFP); + dir.set(fd.vLastFD); + current_hud_item->m_parent_hud_item->TransformPosFromWorldToHud(point); + current_hud_item->m_parent_hud_item->TransformDirFromWorldToHud(dir); + + Fvector parallelPoint; + parallelPoint.set(point); + parallelPoint.mad(dir, RQ.range); + render.draw_aabb(parallelPoint, debug_point_size, debug_point_size, debug_point_size, color_xrgb(255, 0, 0)); + render.draw_line(Fidentity, point, parallelPoint, color_xrgb(255, 0, 0)); + } + + if (draw_fd2) + { + Fvector point; + Fvector dir; + point.set(fd.vLastFP2); + dir.set(fd.vLastFD); + current_hud_item->m_parent_hud_item->TransformPosFromWorldToHud(point); + current_hud_item->m_parent_hud_item->TransformDirFromWorldToHud(dir); + + Fvector parallelPoint; + parallelPoint.set(point); + parallelPoint.mad(dir, RQ.range); + render.draw_aabb(parallelPoint, debug_point_size, debug_point_size, debug_point_size, color_xrgb(255, 0, 0)); + render.draw_line(Fidentity, point, parallelPoint, color_xrgb(255, 0, 0)); + } + + if (draw_sp) + { + Fvector point; + point.set(fd.vLastSP); + current_hud_item->m_parent_hud_item->TransformPosFromWorldToHud(point); + render.draw_aabb(point, debug_point_size, debug_point_size, debug_point_size, color_xrgb(255, 0, 0)); + } +#endif // DEBUG } - else if (idx == 2) + + if (ImGui::Button("Reset to default values")) { - Msg("[%s]", hi->m_sect_name.c_str()); - Msg("gl_hud_offset_pos%s = %f,%f,%f", (is_16x9) ? "_16x9" : "", pos_.x, pos_.y, pos_.z); - Msg("gl_hud_offset_rot%s = %f,%f,%f", (is_16x9) ? "_16x9" : "", rot_.x, rot_.y, rot_.z); - Log("-----------"); + ResetToDefaultValues(); } } - } - else if (hud_adj_mode == 8 || hud_adj_mode == 9) - { - if (hud_adj_mode == 8 && (values.z)) - _delta_pos += (values.z > 0) ? _delta_pos * 0.1f : _delta_pos * -0.1f; - if (hud_adj_mode == 9 && (values.z)) - _delta_rot += (values.z > 0) ? _delta_rot * .1f : _delta_rot * -0.1f; - } - else - { - attachable_hud_item* hi = m_attached_items[hud_adj_item_idx]; - if (!hi) - return; - hi->tune(values); - } -#endif // #ifndef MASTER_GOLD -} + if (current_hud_item && ImGui::CollapsingHeader("Bone and Animation Debugging", ImGuiTreeNodeFlags_DefaultOpen)) + { + IKinematics* ik = current_hud_item->m_model; + ImGui::Text("Bone Count = %i", ik->LL_BoneCount()); + ImGui::Text("Root Bone = %s", ik->LL_BoneName_dbg(ik->LL_GetBoneRoot())); -void hud_draw_adjust_mode() -{ - if (!hud_adj_mode) - return; + for (const auto& [bone_name, bone_id] : *ik->LL_Bones()) + { + if (bone_id == ik->LL_GetBoneRoot()) + continue; - LPCSTR _text = NULL; - if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT) && hud_adj_mode) - _text = - "press SHIFT+NUM 0-return 1-hud_pos 2-hud_rot 3-itm_pos 4-itm_rot 5-fire_point 6-fire_2_point " - "7-shell_point " - "8-pos_step 9-rot_step"; + bool visible = ik->LL_GetBoneVisible(bone_id); + if (ImGui::RadioButton(bone_name.c_str(), visible)) { visible = !visible; }; ImGui::SameLine(); + ik->LL_SetBoneVisible(bone_id, visible, FALSE); + } - switch (hud_adj_mode) - { - case 1: _text = "adjusting HUD POSITION"; break; - case 2: _text = "adjusting HUD ROTATION"; break; - case 3: _text = "adjusting ITEM POSITION"; break; - case 4: _text = "adjusting ITEM ROTATION"; break; - case 5: _text = "adjusting FIRE POINT"; break; - case 6: _text = "adjusting FIRE 2 POINT"; break; - case 7: _text = "adjusting SHELL POINT"; break; - case 8: _text = "adjusting pos STEP"; break; - case 9: _text = "adjusting rot STEP"; break; - }; - if (_text) - { - CGameFont* F = UI().Font().pFontDI; - F->SetAligment(CGameFont::alCenter); - F->OutSetI(0.f, -0.8f); - F->SetColor(0xffffffff); - F->OutNext(_text); - F->OutNext("for item [%d]", hud_adj_item_idx); - F->OutNext("delta values dP=%f dR=%f", _delta_pos, _delta_rot); - F->OutNext("[Z]-x axis [X]-y axis [C]-z axis"); - } -} + ImGui::NewLine(); -void hud_adjust_mode_keyb(int dik) -{ - if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LSHIFT)) - { - if (dik == SDL_SCANCODE_KP_0 || dik == SDL_SCANCODE_0) - hud_adj_mode = 0; - if (dik == SDL_SCANCODE_KP_1 || dik == SDL_SCANCODE_1) - hud_adj_mode = 1; - if (dik == SDL_SCANCODE_KP_2 || dik == SDL_SCANCODE_2) - hud_adj_mode = 2; - if (dik == SDL_SCANCODE_KP_3 || dik == SDL_SCANCODE_3) - hud_adj_mode = 3; - if (dik == SDL_SCANCODE_KP_4 || dik == SDL_SCANCODE_4) - hud_adj_mode = 4; - if (dik == SDL_SCANCODE_KP_5 || dik == SDL_SCANCODE_5) - hud_adj_mode = 5; - if (dik == SDL_SCANCODE_KP_6 || dik == SDL_SCANCODE_6) - hud_adj_mode = 6; - if (dik == SDL_SCANCODE_KP_7 || dik == SDL_SCANCODE_7) - hud_adj_mode = 7; - if (dik == SDL_SCANCODE_KP_8 || dik == SDL_SCANCODE_8) - hud_adj_mode = 8; - if (dik == SDL_SCANCODE_KP_9 || dik == SDL_SCANCODE_9) - hud_adj_mode = 9; - } - if (pInput->iGetAsyncKeyState(SDL_SCANCODE_LCTRL)) - { - if (dik == SDL_SCANCODE_KP_0 || dik == SDL_SCANCODE_0) - hud_adj_item_idx = 0; - if (dik == SDL_SCANCODE_KP_1 || dik == SDL_SCANCODE_1) - hud_adj_item_idx = 1; + for (const auto& [anim_name, motion] : current_hud_item->m_hand_motions.m_anims) + { + if (ImGui::Button(anim_name.c_str())) + { + current_hud_item->m_parent_hud_item->PlayHUDMotion_noCB(anim_name, false); + }; + ImGui::SameLine(); + } + } } + ImGui::End(); +#endif } diff --git a/src/xrGame/player_hud_tune.h b/src/xrGame/player_hud_tune.h new file mode 100644 index 00000000000..a2c470ffae5 --- /dev/null +++ b/src/xrGame/player_hud_tune.h @@ -0,0 +1,73 @@ +#pragma once + +#include "player_hud.h" + +class CHudTuner final : public xray::editor::ide_tool +{ +public: + CHudTuner(); + void OnFrame() override; + bool is_active() const override; + +private: + pcstr tool_name() override { return "Hud Tuner"; } + + void ResetToDefaultValues(); + void UpdateValues(); + + enum hud_adj_mode_keys + { + HUD_POS = 0, + HUD_ROT, + HUD_POS_AIM, + HUD_ROT_AIM, + HUD_POS_GL, + HUD_ROT_GL, + ITEM_POS, + ITEM_ROT, + FIRE_POINT, + FIRE_POINT_2, + SHELL_POINT, + }; + enum hud_item_idx + { + MAIN_ITEM = 0, + OFFHAND_ITEM, + }; + xr_map hud_item_mode + { + { MAIN_ITEM, "Main hand item" }, + { OFFHAND_ITEM, "Off hand item" }, + }; + xr_map hud_adj_modes = + { + { HUD_POS, "Hud Position (Default)" }, + { HUD_ROT, "Hud Rotation (Default)" }, + { HUD_POS_AIM, "Hud Position (Aiming)" }, + { HUD_ROT_AIM, "Hud Rotation (Aiming)" }, + { HUD_POS_GL, "Hud Position (GL)" }, + { HUD_ROT_GL, "Hud Rotation (GL)" }, + { ITEM_POS, "Item Position" }, + { ITEM_ROT, "Item Rotation" }, + { FIRE_POINT, "Fire Point" }, + { FIRE_POINT_2, "Fire Point 2" }, + { SHELL_POINT, "Shell Point" }, + }; + + bool paused{}; + bool draw_fp{}; + bool draw_fp2{}; + bool draw_fd{}; + bool draw_fd2{}; + bool draw_sp{}; + + float debug_point_size{ 0.005f }; + float _delta_pos{ 0.0005f }; + float _delta_rot{ 0.05f }; + + attachable_hud_item* current_hud_item{}; + hud_item_idx current_hud_idx{ MAIN_ITEM }; + + hud_item_measures curr_measures{}; + hud_item_measures new_measures{}; +}; diff --git a/src/xrGame/xrGame.vcxproj b/src/xrGame/xrGame.vcxproj index 54ee5a81250..762c7b46e36 100644 --- a/src/xrGame/xrGame.vcxproj +++ b/src/xrGame/xrGame.vcxproj @@ -967,6 +967,7 @@ + diff --git a/src/xrGame/xrGame.vcxproj.filters b/src/xrGame/xrGame.vcxproj.filters index 541aba9c67d..ba820c81759 100644 --- a/src/xrGame/xrGame.vcxproj.filters +++ b/src/xrGame/xrGame.vcxproj.filters @@ -6492,6 +6492,9 @@ Core\Server + + Core\Client\Objects\items & weapons\HudItem +