Fix chat colors when RTLer is on.

This commit is contained in:
shavitush 2017-10-13 09:36:10 +03:00
parent 86442a4059
commit 55604dfe77
3 changed files with 79 additions and 5 deletions

View File

@ -0,0 +1,35 @@
// code by alongub https://github.com/alongubkin/
#if defined _rtler_included
#endinput
#endif
#define _rtler_included
#pragma semicolon 1
/**
* Converts a string that contains words in RTL languages to be displayed correctly in-game.
*
* @param dest Destination string buffer to copy the RTL-ed string to.
* @param destLen Destination buffer length (includes null terminator).
* @param original Original non-rtled string.
*
* @return The amount of words that needed RTLifying.
*/
native int RTLify(char[] dest, int destLen, const char[] original);
public SharedPlugin __pl_rtler =
{
name = "rtler",
file = "rtler.smx",
#if defined REQUIRE_PLUGIN
required = 1,
#else
required = 0,
#endif
};
public void __pl_rtler_SetNTVOptional()
{
MarkNativeAsOptional("RTLify");
}

View File

@ -26,11 +26,18 @@
#undef REQUIRE_PLUGIN
#define USES_CHAT_COLORS
#include <shavit>
#include <rtler>
#pragma newdecls required
#pragma semicolon 1
// database
Database gH_SQL = null;
char gS_MySQLPrefix[32];
// modules
bool gB_RTLer = false;
// cache
EngineVersion gEV_Type = Engine_Unknown;
@ -51,6 +58,11 @@ public Plugin myinfo =
url = "https://github.com/shavitush/bhoptimer"
}
public void OnAllPluginsLoaded()
{
gB_RTLer = LibraryExists("rtler");
}
public void OnPluginStart()
{
gEV_Type = GetEngineVersion();
@ -131,6 +143,22 @@ void SQL_SetPrefix()
delete fFile;
}
public void OnLibraryAdded(const char[] name)
{
if(StrEqual(name, "rtler"))
{
gB_RTLer = true;
}
}
public void OnLibraryRemoved(const char[] name)
{
if(StrEqual(name, "rtler"))
{
gB_RTLer = false;
}
}
public void OnClientDisconnect(int client)
{
gB_AllowCustom[client] = false;
@ -294,7 +322,7 @@ public Action Command_CCList(int client, int args)
{
if(gB_AllowCustom[i])
{
PrintToConsole(client, "%N (%d/%d) (name: \"%s\"; message: \"%s\")", i, i, GetClientUserId(i), gS_CustomName[i], gS_CustomMessage[i])
PrintToConsole(client, "%N (%d/%d) (name: \"%s\"; message: \"%s\")", i, i, GetClientUserId(i), gS_CustomName[i], gS_CustomMessage[i]);
}
}
@ -325,7 +353,19 @@ public Action CP_OnChatMessage(int &author, ArrayList recipients, char[] flagstr
if(gB_MessageEnabled[author] && strlen(gS_CustomMessage[author]) > 0)
{
Format(message, MAXLENGTH_MESSAGE, "%s%s", gS_CustomMessage[author], message);
char[] sTemp = new char[MAXLENGTH_MESSAGE];
// proper colors with rtler
if(gB_RTLer && RTLify(sTemp, MAXLENGTH_MESSAGE, message))
{
Format(message, MAXLENGTH_MESSAGE, "%s%s", message, gS_CustomMessage[author]);
}
else
{
Format(message, MAXLENGTH_MESSAGE, "%s%s", gS_CustomMessage[author], message);
}
FormatRandom(message, MAXLENGTH_MESSAGE);
}

View File

@ -1346,7 +1346,6 @@ public void OnClientPutInServer(int client)
gB_Auto[client] = true;
gB_DoubleSteps[client] = false;
gF_StrafeWarning[client] = 0.0;
gBS_Style[client] = 0;
gB_PracticeMode[client] = false;
gI_SHSW_FirstCombination[client] = -1;
gI_Track[client] = 0;
@ -1358,13 +1357,13 @@ public void OnClientPutInServer(int client)
else
{
gBS_Style[client] = 0;
UpdateAutoBhop(client);
UpdateAiraccelerate(client);
UpdateBunnyhopping(client);
}
gBS_Style[client] = 0;
if(gH_SQL == null)
{
return;