Skip to content
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

HUD Customization #3836

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

FileEX
Copy link
Contributor

@FileEX FileEX commented Nov 1, 2024

Closes #3682

This PR adds customization for the default HUD in GTA. Eventually, all components are intended to be modifiable. Currently, the PR is in progress, and the following properties are available:

  • Position
  • Size
  • Bar fill colors
  • Black border
  • Percentage value
  • The HP value at which the health bar flashes

Syntax

bool setPlayerHudComponentProperty(string component, string property, mixed value)
mixed getPlayerHudComponentProperty(string component, string property)
bool resetPlayerHudComponentProperty(string component, string property)

I also plan to create a HUD visualization in the settings where changes will be possible. However, I think that will be part of a separate PR.

With this PR, it will also be possible to easily fix issues like #3807 without the need to patch values in memory.

image

setPlayerHudComponentProperty('health', 'fillColor', tocolor(50, 168, 82, 255));
setPlayerHudComponentProperty('breath', 'fillColor', tocolor(167, 189, 58, 255));
setPlayerHudComponentProperty('armour', 'fillColor', tocolor(53, 130, 171, 255));

setPlayerHudComponentProperty('armour', 'drawPercentage', true);

setPlayerHudComponentProperty('health', 'position', 300, 200);
setPlayerHudComponentProperty('health', 'size', 100, 20);

setPlayerHudComponentProperty('breath', 'position', 300, 240);
setPlayerHudComponentProperty('armour', 'position', 300, 280);

setPlayerHudComponentProperty('armour', 'size', 300, 20);

@FileEX FileEX marked this pull request as draft November 1, 2024 22:58
@Fernando-A-Rocha
Copy link
Contributor

Nice, what about #3444 ?

@Proxy-99
Copy link
Contributor

Proxy-99 commented Nov 2, 2024

Nice, what about #3444 ?

this is a patch for wide screens has nothing to do with customization

@Fernando-A-Rocha
Copy link
Contributor

Nice, what about #3444 ?

this is a patch for wide screens has nothing to do with customization

This PR alters HUD component sizes, won't it conflict with wide screen HUD sizing PR?

@Proxy-99
Copy link
Contributor

Proxy-99 commented Nov 2, 2024

Nice, what about #3444 ?

this is a patch for wide screens has nothing to do with customization

This PR alters HUD component sizes, won't it conflict with wide screen HUD sizing PR?

this is normal but we compare conflicts according to multitheftauto:master rely on which pr will be merged first other pr has to adjuct to the new changes

@@ -190,6 +190,7 @@ class CGameSA : public CGame
int32_t GetCountOfAllFileIDs() { return (*(char**)(0x5B8AFA + 2) - *(char**)(0x5B8B08 + 6)) / sizeof(CStreamingInfo); }

DWORD GetSystemTime() { return *(DWORD*)0xB7CB84; } // CTimer::m_snTimeInMilliseconds
int GetSystemFrameCounter() { return *(int*)0xB7CB4C; } // CTimer::m_FrameCounter
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const?

float totalWidth = ((useCustomSize ? componentProperties.hpBar.bar.placement.customWidth : componentProperties.hpBar.bar.placement.width) * maxHealth) / statModifier;

// call CSprite2d::DrawBarChart
((void(__cdecl*)(float, float, std::uint16_t, std::uint32_t, float, bool, bool, bool, RwColor, RwColor))FUNC_CSprite2d_DrawBarChart)(useCustomPosition ? componentProperties.hpBar.bar.placement.customX : (useCustomSize ? componentProperties.hpBar.bar.placement.customWidth : componentProperties.hpBar.bar.placement.width) - totalWidth + x, useCustomPosition ? componentProperties.hpBar.bar.placement.customY : y, static_cast<std::uint16_t>(totalWidth), static_cast<std::uint32_t>(useCustomSize ? componentProperties.hpBar.bar.placement.customHeight : componentProperties.hpBar.bar.placement.height), playerPed->GetHealth() * 100.0f / maxHealth, false, componentProperties.hpBar.bar.drawPercentage, componentProperties.hpBar.bar.drawBlackBorder, componentProperties.hpBar.bar.fillColor, COLOR_BLACK);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe separate these conditional arguments?

bool useCustomSize = componentProperties.breathBar.bar.placement.useCustomSize;

// call CSprite2d::DrawBarChart
((void(__cdecl*)(float, float, std::uint16_t, std::uint32_t, float, bool, bool, bool, RwColor, RwColor))FUNC_CSprite2d_DrawBarChart)(useCustomPosition ? componentProperties.breathBar.bar.placement.customX : x, useCustomPosition ? componentProperties.breathBar.bar.placement.customY : y, static_cast<std::uint16_t>(useCustomSize ? componentProperties.breathBar.bar.placement.customWidth : componentProperties.breathBar.bar.placement.width), static_cast<std::uint32_t>(useCustomSize ? componentProperties.breathBar.bar.placement.customHeight : componentProperties.breathBar.bar.placement.height), playerPed->GetOxygenLevel() / statModifier * 100.0f, false, componentProperties.breathBar.bar.drawPercentage, componentProperties.breathBar.bar.drawBlackBorder, componentProperties.breathBar.bar.fillColor, COLOR_BLACK);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

above

((void(__cdecl*)(float, float, std::uint16_t, std::uint32_t, float, bool, bool, bool, RwColor, RwColor))FUNC_CSprite2d_DrawBarChart)(useCustomPosition ? componentProperties.armorBar.bar.placement.customX : x, useCustomPosition ? componentProperties.armorBar.bar.placement.customY : y, static_cast<std::uint16_t>(useCustomSize ? componentProperties.armorBar.bar.placement.customWidth : componentProperties.armorBar.bar.placement.width), static_cast<std::uint32_t>(useCustomSize ? componentProperties.armorBar.bar.placement.customHeight : componentProperties.armorBar.bar.placement.height), playerPed->GetArmor() / static_cast<float>(pGame->GetPlayerInfo()->GetMaxArmor()) * 100.0f, false, componentProperties.armorBar.bar.drawPercentage, componentProperties.armorBar.bar.drawBlackBorder, componentProperties.armorBar.bar.fillColor, COLOR_BLACK);
}

static void _declspec(naked) HOOK_RenderHudBar()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make that function non naked?

Comment on lines +41 to +42
virtual std::uint8_t GetMaxHealth() = 0;
virtual std::uint8_t GetMaxArmor() = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const and/or noexcept?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support HUD Components Customizations
4 participants