Skip to content

Commit

Permalink
Tiny refactor, optimization and fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
TheIndra55 committed Aug 6, 2021
1 parent 6fc14b9 commit 5da1750
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,21 @@ jobs:
run: MSBuild /p:Configuration=Release /p:Platform=Win32 /p:GameConstant=TR7 /p:TargetName=TR7-Menu-Hook

# upload
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v2
with:
name: Anniversary
path: |
bin/Release/TRAE-Menu-Hook.asi
bin/Release/TRAE-Menu-Hook.pdb
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v2
with:
name: Underworld
path: |
bin/Release/TR8-Menu-Hook.asi
bin/Release/TR8-Menu-Hook.pdb
- uses: actions/upload-artifact@v1
- uses: actions/upload-artifact@v2
with:
name: Legend
path: |
Expand Down
2 changes: 1 addition & 1 deletion Camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void __cdecl GAMELOOP_Process(int a1)
{
origGAMELOOP_Process(a1);

if (Hooking::GetInstance().GetMenu()->m_drawSettings.flight)
if (Hooking::GetInstance().GetMenu()->IsFreecam())
{
auto speed = IsActionPressed(34);
auto camera = *reinterpret_cast<int*>(0xE80534);
Expand Down
13 changes: 7 additions & 6 deletions Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#include "Game.hpp"
#include "Hooking.hpp"

extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);

static bool shouldInstance = true;
static bool shouldReloc = true;

Expand Down Expand Up @@ -379,8 +377,8 @@ void Menu::Process(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
auto cameraMode = (int*)0x850984;
*cameraMode = *cameraMode == 7 ? 2 : 7;
#elif TR8
m_drawSettings.flight = !m_drawSettings.flight;
if (m_drawSettings.flight)
m_freecam = !m_freecam;
if (m_freecam)
{
CAMERA_SetMode(11);

Expand All @@ -389,8 +387,6 @@ void Menu::Process(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
}
else
{
//*(int*)0xE80534 = 0xE83860 /* AVLaraCameraRewrite */;

_setToGameplayCamera(0xE804F0 /* AVCameraManager */);
}
#endif
Expand Down Expand Up @@ -1043,6 +1039,11 @@ bool Menu::IsFocus() const noexcept
return m_focus;
}

bool Menu::IsFreecam() const noexcept
{
return m_freecam;
}

void Menu::SetFocus(bool value) noexcept
{
m_focus = value;
Expand Down
21 changes: 11 additions & 10 deletions Menu.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ struct DrawSettings
// "DrawSettings"
bool noRespawn = false;
bool noMovieBars = false;

#if TR8
bool flight = false;
#endif
};

class Menu
Expand All @@ -41,12 +37,10 @@ class Menu
void OnPresent();
void Process(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
void ToggleFlight(bool flight);
void ProcessFlight(UINT msg, WPARAM wparam);
void SetDevice(LPDIRECT3DDEVICE9 pd3dDevice);
void OnLayoutChange() noexcept;
void Log(const char* fmt, ...);
void DrawInstanceViewer();

bool IsFreecam() const noexcept;
bool IsFocus() const noexcept;
void SetFocus(bool value) noexcept;

Expand All @@ -58,14 +52,22 @@ class Menu
DrawSettings m_drawSettings;
private:
void Draw();
void ProcessFlight(UINT msg, WPARAM wparam);
void DrawInstanceViewer();
void OnLayoutChange() noexcept;

private:
bool m_focus = false;
bool m_flight = false;
float m_flightSpeed = 50.f;
float m_flightSpeed = 75.f;

bool m_visible = true;
bool m_isAzertyLayout = false;

#if TR8
bool m_freecam = false;
#endif

ImGuiTextBuffer logBuffer;

LPDIRECT3DDEVICE9 m_pd3dDevice;
Expand All @@ -74,5 +76,4 @@ class Menu
DWORD clickedInstance;
};

void DrawInstanceViewer();
int __cdecl IMAGE_LoadImage(char* name);
extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
1 change: 0 additions & 1 deletion dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ DWORD WINAPI Hook(LPVOID lpParam)
Hooking::GetInstance(); // Will call the ctor
#endif

while (true) Sleep(0);
return 0;
}

Expand Down

0 comments on commit 5da1750

Please sign in to comment.