Skip to content

feat: Add CustomHudLayout api - #1410

Open
qstage wants to merge 4 commits into
roflmuffin:mainfrom
qstage:main
Open

feat: Add CustomHudLayout api#1410
qstage wants to merge 4 commits into
roflmuffin:mainfrom
qstage:main

Conversation

@qstage

@qstage qstage commented Sep 2, 2026

Copy link
Copy Markdown
Contributor
public static class CCSCustomHudLayoutExtensions
{
    extension(CCSCustomHudLayout customHud)
    {
        public void SetHasClass(string panelid, string classname, bool hasclass) => NativeAPI.SetHasClass(customHud.Handle, panelid, classname, hasclass);

        public void SetHasClassForPlayer(CCSPlayerController player, string panelid, string classname, bool hasclass)
        {
            if (player == null || player.Handle == IntPtr.Zero)
            {
                throw new ArgumentNullException(nameof(player));
            }

            NativeAPI.SetHasClassForPlayer(customHud.Handle, player.Handle, panelid, classname, hasclass);
        }

        public void SetDialogVariableString(string panelid, string variablename, string value) => NativeAPI.SetDialogVariableString(customHud.Handle, panelid, variablename, value);

        public void SetDialogVariableStringForPlayer(CCSPlayerController player, string panelid, string variablename, string value)
        {
            if (player == null || player.Handle == IntPtr.Zero)
            {
                throw new ArgumentNullException(nameof(player));
            }

            NativeAPI.SetDialogVariableStringForPlayer(customHud.Handle, player.Handle, panelid, variablename, value);
        }

        public void SetInputCaptureEnabled(CCSPlayerController player, bool enable)
        {
            if (player == null || player.Handle == IntPtr.Zero)
            {
                throw new ArgumentNullException(nameof(player));
            }

            NativeAPI.SetInputCaptureEnabled(customHud.Handle, player.Handle, enable);
        }

        public bool IsInputCaptureEnabled(CCSPlayerController player)
        {
            if (player == null || player.Handle == IntPtr.Zero)
            {
                throw new ArgumentNullException(nameof(player));
            }

            return NativeAPI.IsInputCaptureEnabled(customHud.Handle, player.Handle);
        }
    }
}
image

The implementation is taken from the CS2Fixes repository
Source2ZE/CS2Fixes@0d10786

@qstage
qstage requested a review from roflmuffin as a code owner September 2, 2026 13:39
@roflmuffin

Copy link
Copy Markdown
Owner

If I merge changes to fix the networked vector schema utility, we might not need most of these changes (except hooks maybe?)

@qstage

qstage commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Apparently, if it works as expected

@qstage

qstage commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

I checked SetInputCaptureEnabled and it worked

image

@qstage

qstage commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Although we cannot add elements to the vector. This is needed for SetHasClass, SetDialogVariableString.

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.

2 participants