-
-
Notifications
You must be signed in to change notification settings - Fork 452
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
base: master
Are you sure you want to change the base?
Changes from all commits
37b4db3
971e022
c95419b
6cd65a1
d4253d3
009d5b8
7e213bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: core/CClientChatboxVariables.h | ||
* PURPOSE: Header file for client chatbox variables | ||
* | ||
* Multi Theft Auto is available from http://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
|
||
#include <SharedUtil.Misc.h> | ||
|
||
#define MAX_CHATBOX_LAYOUT_CVARS 21 | ||
|
||
static const SFixedArray<const char*, MAX_CHATBOX_LAYOUT_CVARS>& g_chatboxLayoutCVars = {{"chat_font", | ||
"chat_lines", | ||
"chat_color", | ||
"chat_text_color", | ||
"chat_input_color", | ||
"chat_input_prefix_color", | ||
"chat_input_text_color", | ||
"chat_scale", | ||
"chat_position_offset_x", | ||
"chat_position_offset_y", | ||
"chat_position_horizontal", | ||
"chat_position_vertical", | ||
"chat_text_alignment", | ||
"chat_width", | ||
"chat_css_style_text", | ||
"chat_css_style_background", | ||
"chat_line_life", | ||
"chat_line_fade_out", | ||
"chat_use_cegui", | ||
"text_scale", | ||
"chat_text_outline"}}; |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -420,11 +420,17 @@ class CSettings | |||||||||
void LoadChatColorFromCVar(eChatColorType eType, const char* szCVar); | ||||||||||
void LoadChatColorFromString(eChatColorType eType, const std::string& strColor); | ||||||||||
void SaveChatColor(eChatColorType eType, const char* szCVar); | ||||||||||
void SaveChatSetting(const char* szCVar, int iVal); | ||||||||||
void SaveChatSetting(const char* szCVar, const std::string& strVal); | ||||||||||
void SaveChatSetting(const char* szCVar, bool bVal); | ||||||||||
CColor GetChatColorValues(eChatColorType eType); | ||||||||||
void SetChatColorValues(eChatColorType eType, CColor pColor); | ||||||||||
int GetMilliseconds(CGUIEdit* pEdit); | ||||||||||
void SetMilliseconds(CGUIEdit* pEdit, int milliseconds); | ||||||||||
|
||||||||||
void SetChatLayoutChanged(bool changed) { m_bChatLayoutChanged = changed; }; | ||||||||||
bool GetChatLayoutChanged() const { return m_bChatLayoutChanged; }; | ||||||||||
Comment on lines
+431
to
+432
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.
Suggested change
|
||||||||||
|
||||||||||
void ResetGTAVolume(); | ||||||||||
void SetRadioVolume(float fVolume); | ||||||||||
void SetSFXVolume(float fVolume); | ||||||||||
|
@@ -465,4 +471,6 @@ class CSettings | |||||||||
int m_iMaxAnisotropic; | ||||||||||
|
||||||||||
std::list<SKeyBindSection*> m_pKeyBindSections; | ||||||||||
|
||||||||||
bool m_bChatLayoutChanged = false; | ||||||||||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
#define ALLOC_STATS_MODULE_NAME "client" | ||
#include "SharedUtil.hpp" | ||
#include <core/CClientCommands.h> | ||
#include <../Client/core/CClientChatboxVariables.h> | ||
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. The header belongs in |
||
|
||
CCoreInterface* g_pCore = NULL; | ||
CLocalizationInterface* g_pLocalization = NULL; | ||
|
@@ -305,6 +306,75 @@ void CClient::OnWindowFocusChange(bool state) | |
g_pClientGame->OnWindowFocusChange(state); | ||
} | ||
|
||
void CClient::OnChatboxLayoutChange() | ||
{ | ||
if (g_pClientGame) | ||
{ | ||
CCVarsInterface* pCVars = g_pCore->GetCVars(); | ||
SString strCVarValue; | ||
std::stringstream ss; | ||
float fNumber, fX, fY; | ||
int iR, iG, iB, iA; | ||
CLuaArguments chatboxItemList; | ||
|
||
for (unsigned int i = 0; i < MAX_CHATBOX_LAYOUT_CVARS; i++) | ||
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. You could use an array of struct for enum class DummyType {
STRING,
BOOLEAN,
FLOAT1,
FLOAT2,
FLOAT4,
};
struct Dummy {
const char* name;
DummyType type;
}; |
||
{ | ||
chatboxItemList.PushString(g_chatboxLayoutCVars[i]); | ||
if (g_chatboxLayoutCVars[i] == "chat_color" || g_chatboxLayoutCVars[i] == "chat_text_color" || g_chatboxLayoutCVars[i] == "chat_input_color" || | ||
g_chatboxLayoutCVars[i] == "chat_input_prefix_color" || g_chatboxLayoutCVars[i] == "chat_input_text_color") | ||
{ | ||
pCVars->Get(g_chatboxLayoutCVars[i], strCVarValue); | ||
if (strCVarValue.empty()) | ||
continue; | ||
ss.clear(); | ||
ss.str(strCVarValue); | ||
ss >> iR >> iG >> iB >> iA; | ||
|
||
CLuaArguments chatboxColorItem; | ||
chatboxColorItem.PushNumber(1); | ||
chatboxColorItem.PushNumber(iR); | ||
chatboxColorItem.PushNumber(2); | ||
chatboxColorItem.PushNumber(iG); | ||
chatboxColorItem.PushNumber(3); | ||
chatboxColorItem.PushNumber(iB); | ||
chatboxColorItem.PushNumber(4); | ||
chatboxColorItem.PushNumber(iA); | ||
|
||
chatboxItemList.PushTable(&chatboxColorItem); | ||
} | ||
else if (g_chatboxLayoutCVars[i] == "chat_scale") | ||
{ | ||
pCVars->Get(g_chatboxLayoutCVars[i], strCVarValue); | ||
if (strCVarValue.empty()) | ||
continue; | ||
ss.clear(); | ||
ss.str(strCVarValue); | ||
ss >> fX >> fY; | ||
|
||
CLuaArguments numberTable; | ||
numberTable.PushNumber(1); | ||
numberTable.PushNumber(fX); | ||
numberTable.PushNumber(2); | ||
numberTable.PushNumber(fY); | ||
|
||
chatboxItemList.PushTable(&numberTable); | ||
} | ||
else | ||
{ | ||
pCVars->Get(g_chatboxLayoutCVars[i], fNumber); | ||
if (g_chatboxLayoutCVars[i] == "chat_use_cegui") | ||
chatboxItemList.PushBoolean(fNumber ? true : false); | ||
else | ||
chatboxItemList.PushNumber(fNumber); | ||
} | ||
} | ||
|
||
CLuaArguments Arguments; | ||
Arguments.PushTable(&chatboxItemList); | ||
g_pClientGame->GetRootEntity()->CallEvent("onClientChatboxLayoutChange", Arguments, false); | ||
} | ||
} | ||
|
||
CClient::InitializeArguments CClient::ExtractInitializeArguments(const char* arguments) | ||
{ | ||
// Format: "nickname [password]" | ||
|
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.
SString constructor can do
printf
formatting.