Skip to content

Commit

Permalink
Merge pull request #4 from Bearborg/photo-mode
Browse files Browse the repository at this point in the history
Add Photo Mode
  • Loading branch information
Pwootage authored Aug 16, 2023
2 parents cb5e261 + e2680c3 commit ad195e4
Show file tree
Hide file tree
Showing 12 changed files with 313 additions and 20 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ cmake-build-*/

# specific files
compile_commands.json
scripts/binary_to_compressed_c
scripts/binary_to_compressed_c
/.vs
/CMakeSettings.json
9 changes: 9 additions & 0 deletions src/prime/CActorMP1.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include "prime/Math.hpp"

class CActorMP1 {
public:
CTransform4f& GetTransform() const;
CTransform4f SetTransform(const CTransform4f& transform);
};
35 changes: 35 additions & 0 deletions src/prime/CFirstPersonCamera.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include "program/GetField.hpp"
#include "prime/CActorMP1.hpp"

class CStateManager;

class CGameCamera : public CActorMP1 {};

class CGameCameraMP1: public CGameCamera {
public:
inline float* GetCurrentFOV() {
return GetField<float>(this, 0x25c);
};
void UpdateFOV(float dt);
};

class CFirstPersonCameraMP1 : public CGameCameraMP1 {
public:
void Think(float, CStateManager&);
};

class CCameraManagerMP1 {
public:
static float GetDefaultFirstPersonVerticalFOV();
};

class STonemapParams {
public:
inline float* inverseExposure() { return GetField<float>(this, 0x0); };
};

namespace NTonemap {
void build_tonemap_eval_params(STonemapParams const&);
}
22 changes: 19 additions & 3 deletions src/prime/CGameState.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "CObjectId.hpp"
#include "program/GetField.hpp"
#include "types.h"

namespace rstl {
Expand Down Expand Up @@ -80,18 +81,33 @@ class CGameState {
}
};

class CStateManagerGameLogicMP1;
class CStateManager {
public:
CGameState* GameState();

inline CStateManagerGameLogicMP1* GameLogic() {
return GetField<CStateManagerGameLogicMP1>(this, 0x4e0150);
}
};

class CStateManagerUpdateAccess;

class CPlayerStateMP1;
class CGameStateMP1 {
public:
// CPlayerStateMP1* GetPlayerState() const;
CPlayerStateMP1* PlayerState();
inline CPlayerStateMP1* GetPlayerState_2() { return reinterpret_cast<CPlayerStateMP1*>(reinterpret_cast<size_t>(this) + 0x20); }
inline CPlayerStateMP1* GetPlayerState_2() { return GetField<CPlayerStateMP1>(this, 0x20); }
};
extern CGameStateMP1* gpGameState;

class CPlayerMP1;
class CStateManagerGameLogicMP1 {
public:
static CPlayerStateMP1 *PlayerState();
CPlayerMP1 *PlayerActor();
enum class EGameState : uint32_t { Running, SoftPaused, Paused };
void GameMainLoop(CStateManager& mgr, CStateManagerUpdateAccess& mgrUpdAcc, float dt);
static CPlayerStateMP1* PlayerState();
CPlayerMP1* PlayerActor();
void SetGameState(EGameState state);
};
18 changes: 12 additions & 6 deletions src/prime/CPlayerMP1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

#include "prime/Math.hpp"
#include "program/GetField.hpp"

class CActorMP1 {
public:
CTransform4f &GetTransform() const;
CTransform4f SetTransform(const CTransform4f &transform);
};
#include "prime/CActorMP1.hpp"

class CStateManager;
class CPhysicsActorMP1 : public CActorMP1 {
Expand Down Expand Up @@ -48,11 +43,22 @@ class CHealthInfoMP1 {
// inline float &GetB() const { return *GetField<float>(this, 0x4); }
};

class CTweakPlayerMP1 {
public:
inline float GetMaxFreeLookPitchAngle() { return *GetField<float>(this, 0x138); }
};

extern CTweakPlayerMP1* gpTweakPlayer;

class CFinalInput;
class CPlayerMP1 : public CPhysicsActorMP1 {
public:
enum class EOrbitBrokenType : uint32_t;
void BreakOrbit(EOrbitBrokenType, CStateManager&);
inline float* GetFreeLookPitchAngle() { return GetField<float>(this, 0x5cc); };
inline CMorphBallMP1 *GetMorphBall() { return *GetField<CMorphBallMP1*>(this, 0x9d0); }
inline EPlayerMovementState GetMoveState() { return *GetField<EPlayerMovementState>(this, 0x3f0); }
CHealthInfoMP1 &HealthInfo(CStateManager &mgr);
void ProcessInput(const CFinalInput&, CStateManager&);
void RenderGun(const CStateManager& mgr, const CVector3f& pos) const;
};
17 changes: 17 additions & 0 deletions src/prime/CSamusHudMP1.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
#pragma once

namespace rstl {
template <class T, typename storage, T val>
struct enum_bit_field;
};

class CStateManager;

class CGuiCamera;

class CAutoMapperMP1 {
public:
void Update(float f1, const CStateManager &csm, const CGuiCamera& cgc, float f2, bool b1);
};


class CSamusHudMP1 {
public:
enum class EHudDrawFilter : uint32_t;

void Draw(const CStateManager &stateManager, float alpha, uint32_t param_3, const rstl::enum_bit_field<CSamusHudMP1::EHudDrawFilter, unsigned int, (CSamusHudMP1::EHudDrawFilter)3> &hudDrawFilterFlags) const;
void DrawHelmet(const CStateManager& stateManager, float camYOffset) const;
void DrawTargetingReticle(const CStateManager&) const;
};
8 changes: 0 additions & 8 deletions src/program/InventoryMenu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@
#include "prime/CPlayerStateMP1.hpp"
#include "prime/CGameState.hpp"

class CStateManager {
public:
CGameState *GameState();

inline CStateManagerGameLogicMP1* GameLogic() {
return reinterpret_cast<CStateManagerGameLogicMP1*>(reinterpret_cast<size_t>(this) + 0x4e0150);
}
};
namespace GUI {
void drawInventoryMenu();
}
73 changes: 73 additions & 0 deletions src/program/PhotoModeMenu.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include "PhotoModeMenu.hpp"
#include "patches.hpp"
#include "imgui.h"

#define REQ_CONFIG_IF(cond, ...) \
{ \
if (cond) { \
PATCH_CONFIG.RequestConfigSave(); \
__VA_ARGS__ \
} \
}

namespace GUI {
bool is_time_stopped = false;
const float defaultFirstPersonFov = CCameraManagerMP1::GetDefaultFirstPersonVerticalFOV();
float verticalFov = defaultFirstPersonFov;
bool shouldUpdateVerticalFov = false;
float viewRoll = 0.f;
CGameCameraMP1* fpCamera = nullptr;
float exposure;

const bool shouldHideAll() {
return PATCH_CONFIG.hide_hud_when_time_stopped && is_time_stopped;
}

void drawPhotoModeMenu() {
if (ImGui::TreeNode("Photo Mode")) {
REQ_CONFIG_IF(ImGui::Checkbox("Stop time (left stick + L)", &PATCH_CONFIG.enable_stop_time));
REQ_CONFIG_IF(ImGui::Checkbox("Hide arm cannon", &PATCH_CONFIG.hide_cannon));
REQ_CONFIG_IF(ImGui::Checkbox("Hide HUD", &PATCH_CONFIG.hide_hud));
REQ_CONFIG_IF(ImGui::Checkbox("Auto-hide HUD & cannon when time stopped", &PATCH_CONFIG.hide_hud_when_time_stopped));

// NOT SAVED
// Vertical FOV
ImGui::PushID("VerticalFOV");
if (ImGui::DragFloat("", &verticalFov, 1.0, 1.0, 170.f, "%.2f")) {
shouldUpdateVerticalFov = true;
}
ImGui::SameLine();
if (ImGui::Button("Reset")) {
verticalFov = defaultFirstPersonFov;
shouldUpdateVerticalFov = true;
}
ImGui::SameLine();
ImGui::Text("Vertical FOV");
ImGui::PopID();

// View Roll
ImGui::PushID("ViewRoll");
ImGui::DragFloat("", &viewRoll, 1.0, -90.f, 90.f, "%.2f");
ImGui::SameLine();
if (ImGui::Button("Reset")) {
viewRoll = 0.f;
}
ImGui::SameLine();
ImGui::Text("View Roll");
ImGui::PopID();

// Exposure
ImGui::PushID("Exposure");
ImGui::DragFloat("", &exposure, 0.1, -2.5, 2.5, "%.2f");
ImGui::SameLine();
if (ImGui::Button("Reset")) {
exposure = 0.f;
}
ImGui::SameLine();
ImGui::Text("Exposure");
ImGui::PopID();

ImGui::TreePop();
}
}
}
16 changes: 16 additions & 0 deletions src/program/PhotoModeMenu.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include "prime/Math.hpp"
#include "prime/CFirstPersonCamera.hpp"

namespace GUI {
extern bool is_time_stopped;
extern float verticalFov;
extern bool shouldUpdateVerticalFov;
extern float viewRoll;
extern CGameCameraMP1* fpCamera;
extern float exposure;

const bool shouldHideAll();
void drawPhotoModeMenu();
} // namespace GUI
2 changes: 2 additions & 0 deletions src/program/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "PlayerMenu.hpp"
#include "ProductionFlagMenu.hpp"
#include "InputWindow.hpp"
#include "PhotoModeMenu.hpp"

#define IMGUI_ENABLED true

Expand Down Expand Up @@ -86,6 +87,7 @@ void drawDebugWindow() {
ImGui::TreePop();
}

GUI::drawPhotoModeMenu();
GUI::drawInventoryMenu();
GUI::drawPlayerMenu();
// GUI::drawProductionFlagMenu();
Expand Down
Loading

0 comments on commit ad195e4

Please sign in to comment.