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

Add onClientChatboxLayoutChange event #3448

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

XJMLN
Copy link
Contributor

@XJMLN XJMLN commented Jun 9, 2024

Event: onClientChatboxLayoutChange
Description:
Triggered when the client changes any settings related to the chatbox layout.

Parameters:
chatboxLayout: A table containing all CVars values related to the chatbox settings.

Usage Example:

addEventHandler("onClientChatboxLayoutChange", root,
    function(chatboxLayout)
          iprint(chatboxLayout)
    end
)

Resolves #696

@Dutchman101 Dutchman101 requested a review from Lpsd June 30, 2024 03:20
Copy link
Member

@Lpsd Lpsd left a comment

Choose a reason for hiding this comment

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

Seems good to me, just left one comment.

Comment on lines +3636 to +3637
std::stringstream ss;
ss << std::stof(m_pChatScaleX->GetText()) << " " << std::stof(m_pChatScaleY->GetText());
Copy link
Member

Choose a reason for hiding this comment

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

SString constructor can do printf formatting.

Comment on lines +431 to +432
void SetChatLayoutChanged(bool changed) { m_bChatLayoutChanged = changed; };
bool GetChatLayoutChanged() const { return m_bChatLayoutChanged; };
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
void SetChatLayoutChanged(bool changed) { m_bChatLayoutChanged = changed; };
bool GetChatLayoutChanged() const { return m_bChatLayoutChanged; };
void SetChatLayoutChanged(bool changed) { m_bChatLayoutChanged = changed; }
bool GetChatLayoutChanged() const { return m_bChatLayoutChanged; }

@@ -13,6 +13,7 @@
#define ALLOC_STATS_MODULE_NAME "client"
#include "SharedUtil.hpp"
#include <core/CClientCommands.h>
#include <../Client/core/CClientChatboxVariables.h>
Copy link
Member

Choose a reason for hiding this comment

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

The header belongs in Client/sdk/core if you want to interface between core and deathmatch.

int iR, iG, iB, iA;
CLuaArguments chatboxItemList;

for (unsigned int i = 0; i < MAX_CHATBOX_LAYOUT_CVARS; i++)
Copy link
Member

Choose a reason for hiding this comment

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

You could use an array of struct for g_chatboxLayoutCVars, and store the type of value next to the cvar name. For example:

enum class DummyType {
    STRING,
    BOOLEAN,
    FLOAT1,
    FLOAT2,
    FLOAT4,
};

struct Dummy {
    const char* name;
    DummyType   type;
};

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.

onChatboxLayoutChange event
6 participants