-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Racing UI API #100
Merged
Racing UI API #100
Changes from 13 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c3d40a7
Racing: WIP branch for racing game research
Greavesy1899 9a9f12a
Merge branch 'master' into racing-ui
Greavesy1899 972581b
Merge branch 'master' into racing-ui
Greavesy1899 b1dfb3d
Merge branch 'master' into racing-ui
Greavesy1899 052bd4a
racing: C_HUDTable; ability to modify UI from cpp
Greavesy1899 7f7c028
racing: fix header, improve debug UI
Greavesy1899 b7cf2d3
Racing: Clean up RaceXBin, implement code in sdk
Greavesy1899 818b2d1
racing: cleanup introduced code
Greavesy1899 427b64d
racing: improved debug
Greavesy1899 86ec9e2
cleaning up code
Greavesy1899 459bbe5
C_RaceTimer: Using patterns, removed MP references
Greavesy1899 676380e
reorganise includes
Greavesy1899 65e82cd
latest changes
Greavesy1899 629d4d4
Merge branch 'master' into racing-ui
Greavesy1899 c4ad3bd
Merge branch 'master' into racing-ui
Greavesy1899 cd3b6b5
Fix bad merge
Greavesy1899 c23f977
move racing debug to new debug_world.cpp
Greavesy1899 b265c6c
Remove old world_debug from bad merge
Greavesy1899 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "c_ui_database.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include "../../ue/sys/sodb/c_database_interface.h" | ||
|
||
namespace SDK { | ||
namespace mafia::database { | ||
class C_UIDatabase: public ue::sys::sodb::C_DatabaseInterface { | ||
public: | ||
class C_HUDTable { | ||
public: | ||
uint8_t pad0[0x1E]; // 0000 - 001E | ||
bool m_bRacingVisible = false; // 001E - 001F | ||
uint8_t pad1[0x3]; // 001F - 0022 | ||
uint8_t pad2[0x346]; // 0022 - 0368 | ||
float m_fElapsedTime = 0.0f; // 0368 - 036C | ||
float m_fTargetTime = 0.0f; // 036C - 0370 | ||
uint16_t m_uCurCheckpoint = 0; // 0370 - 0372 | ||
uint16_t m_uTotalCheckpoints = 0; // 0372 - 0374 | ||
uint16_t m_uCurPosition = 0; // 0374 - 0376 | ||
uint16_t m_uTotalPositions = 0; // 0376 - 0378 | ||
uint16_t m_uUnknown1 = 0; // 0378 - 037C | ||
uint16_t m_uUnknown2 = 0; // 0378 - 037C | ||
uint16_t m_uCurLap = 0; // 037C - 037E | ||
uint16_t m_uTotalLaps = 0; // 037E - 0380 | ||
uint8_t m_uCountdown = 0; // 0380 - 0381 | ||
}; | ||
|
||
C_HUDTable *GetHUDTable() const { | ||
return m_pHUDTable; | ||
} | ||
|
||
private: | ||
// NB: Atleast 0x38 is part of C_DatabaseInterface | ||
// Since m_pHUDTable is at 0x20, that could actually be part of base class | ||
uint8_t pad0[0x20]; // 0000 - 0020 | ||
C_HUDTable *m_pHUDTable = nullptr; // 0020 - 0028 | ||
}; | ||
}; // namespace mafia::database | ||
}; // namespace SDK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,42 @@ | ||
#pragma once | ||
|
||
#include "../../../patterns.h" | ||
|
||
namespace SDK { | ||
namespace mafia::ui::hud { | ||
|
||
class C_RaceTimer { | ||
Greavesy1899 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public: | ||
|
||
// This starts C_RaceManager! | ||
// If you do not wish to use C_RaceManager, use mafia::ui::hud::RaceXBin instead! | ||
void SetVisible(const bool visible) { | ||
hook::this_call(gPatterns.C_RaceTimer_SetVisible, this, visible); | ||
} | ||
|
||
// This starts C_RaceManager! | ||
// If you do not wish to use C_RaceManager, Use mafia::ui::hud::RaceXBin instead! | ||
void StartRace(const uint32_t numCheckpoints, const float targetTime, const uint32_t numLaps) { | ||
hook::this_call(gPatterns.C_RaceTimer_StartRace, this, numCheckpoints, targetTime, numLaps); | ||
} | ||
|
||
private: | ||
void *m_pVtable = nullptr; // 0000 - 0008 | ||
void *m_pUnk0 = nullptr; // 0008 - 0010 | ||
float m_fTimer = 0.0f; // 0010 - 0014 | ||
uint32_t m_uCurrentCheckpoint = 0; // 0014 - 0018 | ||
uint32_t m_uCurrentLap = 0; // 0018 - 001C | ||
}; | ||
|
||
class C_HudController { | ||
public: | ||
C_RaceTimer *GetRacingTimer() { | ||
return m_pRaceTimer; | ||
} | ||
|
||
private: | ||
char pad0[0x5A8]; // 0000 - 05A8 | ||
C_RaceTimer *m_pRaceTimer = nullptr; // 05A8 - 05B0 | ||
}; | ||
} // namespace mafia::ui::hud | ||
} // namespace SDK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#include "race_xbin.h" | ||
|
||
#include "../../database/c_ui_database.h" | ||
#include "../c_game_gui_2_module.h" | ||
|
||
namespace RaceXBinUtils | ||
{ | ||
// Handy little utility function to fetch the HUDTable, for the Racing XBin. | ||
SDK::mafia::database::C_UIDatabase::C_HUDTable *GetHUDTable() { | ||
|
||
// Fetch database | ||
SDK::mafia::ui::C_GameGUI2Module *GameGuiModule = SDK::mafia::ui::GetGameGui2Module(); | ||
SDK::ue::C_WeakPtr<SDK::ue::sys::sodb::C_DatabaseInterface> result = GameGuiModule->GetDatabase(); | ||
|
||
// need to cast to C_UIDatabase | ||
// TODO: Feels like this should be dynamic_cast, rather than reinterpret_cast | ||
Comment on lines
+15
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we handle that comment now? not a big deal There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Causes a crash using dynamic_cast, unsure why. I'll debug though. |
||
if (SDK::mafia::database::C_UIDatabase *database = reinterpret_cast<SDK::mafia::database::C_UIDatabase *>(result.Get())) { | ||
return database->GetHUDTable(); | ||
} | ||
|
||
return nullptr; | ||
} | ||
} | ||
|
||
namespace SDK { | ||
namespace mafia::ui::hud { | ||
|
||
void RaceXBin::SetVisible(const bool visibility) { | ||
if (SDK::mafia::database::C_UIDatabase::C_HUDTable *hudTable = RaceXBinUtils::GetHUDTable()) { | ||
hudTable->m_bRacingVisible = visibility; | ||
} | ||
} | ||
|
||
void RaceXBin::SetTargetTime(const float targetTime) { | ||
if (SDK::mafia::database::C_UIDatabase::C_HUDTable *hudTable = RaceXBinUtils::GetHUDTable()) { | ||
hudTable->m_fTargetTime = targetTime; | ||
} | ||
} | ||
|
||
void RaceXBin::SetPosition(const uint16_t currentPosition) { | ||
if (SDK::mafia::database::C_UIDatabase::C_HUDTable *hudTable = RaceXBinUtils::GetHUDTable()) { | ||
hudTable->m_uCurPosition = currentPosition; | ||
} | ||
} | ||
|
||
void RaceXBin::SetPositionTotal(const uint16_t totalPositions) { | ||
if (SDK::mafia::database::C_UIDatabase::C_HUDTable *hudTable = RaceXBinUtils::GetHUDTable()) { | ||
hudTable->m_uTotalPositions = totalPositions; | ||
} | ||
} | ||
|
||
void RaceXBin::SetLaps(const uint16_t currentLap) { | ||
if (SDK::mafia::database::C_UIDatabase::C_HUDTable *hudTable = RaceXBinUtils::GetHUDTable()) { | ||
hudTable->m_uCurLap = currentLap; | ||
} | ||
} | ||
|
||
void RaceXBin::SetLapsTotal(const uint16_t totalLaps) { | ||
if (SDK::mafia::database::C_UIDatabase::C_HUDTable *hudTable = RaceXBinUtils::GetHUDTable()) { | ||
hudTable->m_uTotalLaps = totalLaps; | ||
} | ||
} | ||
|
||
void RaceXBin::SetCheckpoints(const uint16_t currentCheckpoint) { | ||
if (SDK::mafia::database::C_UIDatabase::C_HUDTable *hudTable = RaceXBinUtils::GetHUDTable()) { | ||
hudTable->m_uCurCheckpoint = currentCheckpoint; | ||
} | ||
} | ||
|
||
void RaceXBin::SetCheckpointsTotal(const uint16_t totalCheckpoint) { | ||
if (SDK::mafia::database::C_UIDatabase::C_HUDTable *hudTable = RaceXBinUtils::GetHUDTable()) { | ||
hudTable->m_uTotalCheckpoints = totalCheckpoint; | ||
} | ||
} | ||
|
||
void RaceXBin::SetCountdown(const uint8_t countdown) { | ||
if (SDK::mafia::database::C_UIDatabase::C_HUDTable *hudTable = RaceXBinUtils::GetHUDTable()) { | ||
hudTable->m_uCountdown = countdown; | ||
} | ||
} | ||
} // namespace mafia::ui::hud | ||
} // namespace SDK |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#pragma once | ||
|
||
#include <stdint.h> | ||
|
||
namespace SDK { | ||
namespace mafia::ui::hud { | ||
|
||
/** | ||
* Handy structure which provides an API to update the Racing HUD Element. | ||
* Note that there are some discrepancies with the executable code however | ||
* all functionality should be the same. | ||
*/ | ||
class RaceXBin { | ||
public: | ||
|
||
/** | ||
* Set the visibility of the Racing HUD Element. | ||
* @param bVisibility - Should the HUD Element be visible | ||
*/ | ||
static void SetVisible(const bool visiblity); | ||
|
||
/** | ||
* Set the Target Time on the Racing HUD Element. | ||
* Note that this may not have an effect (eg. appear on the HUD) | ||
* @param InTargetTime - Target Time to show on the HUD | ||
*/ | ||
static void SetTargetTime(const float targetTime); | ||
|
||
/** | ||
* Set the current Position on the Racing HUD Element. | ||
* Note that 'Total Positions' may need to be set before this to have an effect. | ||
* @param InPosition - The current position out of Total Positions | ||
*/ | ||
static void SetPosition(const uint16_t currentPosition); | ||
|
||
/** | ||
* Set the max amount of Positions on the Racing HUD Element | ||
* @param InTotalPosition - Max number of positions | ||
*/ | ||
static void SetPositionTotal(const uint16_t totalPositions); | ||
|
||
/** | ||
* Set the current Lap on the Racing HUD Element. | ||
* Note that 'Total Laps' may need to be set before this to have an effect. | ||
* @param InLaps - The current Lap out of Total Laps | ||
*/ | ||
static void SetLaps(const uint16_t currentLap); | ||
|
||
/** | ||
* Set the number of Laps on the Racing HUD Element | ||
* @param InTotalPosition - Number of Laps | ||
*/ | ||
static void SetLapsTotal(const uint16_t totalLaps); | ||
|
||
/** | ||
* Set the current Checkpoint on the Racing HUD Element. | ||
* Note that 'Total Checkpoints' may need to be set before this to have an effect. | ||
* @param InPosition - The current Checkpoint out of Total Checkpoints | ||
*/ | ||
static void SetCheckpoints(const uint16_t currentCheckpoint); | ||
|
||
/** | ||
* Set the max amount of Checkpoints on the Racing HUD Element | ||
* @param InTotalPosition - Max number of checkpoints | ||
*/ | ||
static void SetCheckpointsTotal(const uint16_t totalCheckpoints); | ||
|
||
/** | ||
* Set the countdown. Max is 3, Minimum is 0. | ||
* The HUD automatically plays the noise when the countdown is updated. | ||
* The caller will have to manage a timer for the countdown. | ||
* @param InCountdown - Current step in the Countdown | ||
*/ | ||
static void SetCountdown(const uint8_t countdown); | ||
}; | ||
} // namespace mafia::ui::hud | ||
} // namespace SDK |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all temporary so I can test because ImGui cursor is currently broken. I'll likely remove it out from this PR when it has been approved.