mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-10 03:48:25 +00:00
Added Shavit_GetStyleSetting, deprecated Shavit_GetStyleSettings
This commit is contained in:
parent
a1e60b39fa
commit
db27bdce14
@ -1533,6 +1533,19 @@ native void Shavit_OpenStatsMenu(int client, int steamid);
|
|||||||
*/
|
*/
|
||||||
native int Shavit_GetWRCount(int client);
|
native int Shavit_GetWRCount(int client);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets a value from the style config for the given style
|
||||||
|
* e.g. Shavit_GetStyleSetting(Shavit_GetBhopStyle(client), "TAS", sBuffer, 2);
|
||||||
|
*
|
||||||
|
* @param style Style index.
|
||||||
|
* @param key Style key to retreive.
|
||||||
|
* @param value Value buffer to store the return value in.
|
||||||
|
* @param maxlength Max length of the value buffer, cannot exceed 256.
|
||||||
|
*
|
||||||
|
* @return True if key was found, false otherwise.
|
||||||
|
*/
|
||||||
|
native bool Shavit_GetStyleSetting(int style, const char[] key, char[] value, int maxlength);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves the style settings on `any` references.
|
* Saves the style settings on `any` references.
|
||||||
*
|
*
|
||||||
@ -1541,6 +1554,7 @@ native int Shavit_GetWRCount(int client);
|
|||||||
* @param size Size of the StyleSettings buffer, e.g sizeof(stylesettings_t)
|
* @param size Size of the StyleSettings buffer, e.g sizeof(stylesettings_t)
|
||||||
* @return SP_ERROR_NONE on success, anything else on failure.
|
* @return SP_ERROR_NONE on success, anything else on failure.
|
||||||
*/
|
*/
|
||||||
|
#pragma deprecated Use different natives or Shavit_GetStyleSetting instead.
|
||||||
native int Shavit_GetStyleSettings(int style, any[] StyleSettings, int size = sizeof(stylesettings_t));
|
native int Shavit_GetStyleSettings(int style, any[] StyleSettings, int size = sizeof(stylesettings_t));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2010,6 +2024,7 @@ public void __pl_shavit_SetNTVOptional()
|
|||||||
MarkNativeAsOptional("Shavit_GetStageZone");
|
MarkNativeAsOptional("Shavit_GetStageZone");
|
||||||
MarkNativeAsOptional("Shavit_GetStrafeCount");
|
MarkNativeAsOptional("Shavit_GetStrafeCount");
|
||||||
MarkNativeAsOptional("Shavit_GetStyleCount");
|
MarkNativeAsOptional("Shavit_GetStyleCount");
|
||||||
|
MarkNativeAsOptional("Shavit_GetStyleSetting");
|
||||||
MarkNativeAsOptional("Shavit_GetStyleSettings");
|
MarkNativeAsOptional("Shavit_GetStyleSettings");
|
||||||
MarkNativeAsOptional("Shavit_GetStyleStrings");
|
MarkNativeAsOptional("Shavit_GetStyleStrings");
|
||||||
MarkNativeAsOptional("Shavit_GetSync");
|
MarkNativeAsOptional("Shavit_GetSync");
|
||||||
|
|||||||
@ -159,6 +159,8 @@ int gI_Styles = 0;
|
|||||||
int gI_OrderedStyles[STYLE_LIMIT];
|
int gI_OrderedStyles[STYLE_LIMIT];
|
||||||
stylestrings_t gS_StyleStrings[STYLE_LIMIT];
|
stylestrings_t gS_StyleStrings[STYLE_LIMIT];
|
||||||
stylesettings_t gA_StyleSettings[STYLE_LIMIT];
|
stylesettings_t gA_StyleSettings[STYLE_LIMIT];
|
||||||
|
StringMap gSM_StyleKeys[STYLE_LIMIT];
|
||||||
|
int gI_CurrentParserIndex = 0;
|
||||||
|
|
||||||
// chat settings
|
// chat settings
|
||||||
chatstrings_t gS_ChatStrings;
|
chatstrings_t gS_ChatStrings;
|
||||||
@ -207,6 +209,7 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
|||||||
CreateNative("Shavit_GetPerfectJumps", Native_GetPerfectJumps);
|
CreateNative("Shavit_GetPerfectJumps", Native_GetPerfectJumps);
|
||||||
CreateNative("Shavit_GetStrafeCount", Native_GetStrafeCount);
|
CreateNative("Shavit_GetStrafeCount", Native_GetStrafeCount);
|
||||||
CreateNative("Shavit_GetStyleCount", Native_GetStyleCount);
|
CreateNative("Shavit_GetStyleCount", Native_GetStyleCount);
|
||||||
|
CreateNative("Shavit_GetStyleSetting", Native_GetStyleSetting);
|
||||||
CreateNative("Shavit_GetStyleSettings", Native_GetStyleSettings);
|
CreateNative("Shavit_GetStyleSettings", Native_GetStyleSettings);
|
||||||
CreateNative("Shavit_GetStyleStrings", Native_GetStyleStrings);
|
CreateNative("Shavit_GetStyleStrings", Native_GetStyleStrings);
|
||||||
CreateNative("Shavit_GetSync", Native_GetSync);
|
CreateNative("Shavit_GetSync", Native_GetSync);
|
||||||
@ -2028,6 +2031,22 @@ public int Native_SetClientTimescale(Handle handler, int numParams)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int Native_GetStyleSetting(Handle handler, int numParams)
|
||||||
|
{
|
||||||
|
int style = GetNativeCell(1);
|
||||||
|
|
||||||
|
char sKey[256];
|
||||||
|
GetNativeString(2, sKey, 256);
|
||||||
|
|
||||||
|
int maxlength = GetNativeCell(4);
|
||||||
|
|
||||||
|
char sValue[256];
|
||||||
|
bool ret = gSM_StyleKeys[style].GetString(sKey, sValue, maxlength);
|
||||||
|
|
||||||
|
SetNativeString(3, sValue, maxlength);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int GetTimerStatus(int client)
|
int GetTimerStatus(int client)
|
||||||
{
|
{
|
||||||
if(!gA_Timers[client].bEnabled)
|
if(!gA_Timers[client].bEnabled)
|
||||||
@ -2300,6 +2319,12 @@ bool LoadStyles()
|
|||||||
char sPath[PLATFORM_MAX_PATH];
|
char sPath[PLATFORM_MAX_PATH];
|
||||||
BuildPath(Path_SM, sPath, PLATFORM_MAX_PATH, "configs/shavit-styles.cfg");
|
BuildPath(Path_SM, sPath, PLATFORM_MAX_PATH, "configs/shavit-styles.cfg");
|
||||||
|
|
||||||
|
SMCParser parser = new SMCParser();
|
||||||
|
parser.OnEnterSection = OnStyleEnterSection;
|
||||||
|
parser.OnKeyValue = OnStyleKeyValue;
|
||||||
|
parser.ParseFile(sPath);
|
||||||
|
delete parser;
|
||||||
|
|
||||||
KeyValues kv = new KeyValues("shavit-styles");
|
KeyValues kv = new KeyValues("shavit-styles");
|
||||||
|
|
||||||
if(!kv.ImportFromFile(sPath) || !kv.GotoFirstSubKey())
|
if(!kv.ImportFromFile(sPath) || !kv.GotoFirstSubKey())
|
||||||
@ -2434,6 +2459,28 @@ bool LoadStyles()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SMCResult OnStyleEnterSection(SMCParser smc, const char[] name, bool opt_quotes)
|
||||||
|
{
|
||||||
|
// styles key
|
||||||
|
if(!IsCharNumeric(name[0]))
|
||||||
|
{
|
||||||
|
return SMCParse_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Technically can lead to a small memory leak if a style is removed mid game.
|
||||||
|
// TODO: replace hard coded values with SMCParser logic.
|
||||||
|
gI_CurrentParserIndex = StringToInt(name);
|
||||||
|
delete gSM_StyleKeys[gI_CurrentParserIndex];
|
||||||
|
gSM_StyleKeys[gI_CurrentParserIndex] = new StringMap();
|
||||||
|
|
||||||
|
return SMCParse_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SMCResult OnStyleKeyValue(SMCParser smc, const char[] key, const char[] value, bool key_quotes, bool value_quotes)
|
||||||
|
{
|
||||||
|
gSM_StyleKeys[gI_CurrentParserIndex].SetString(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
public int SortAscending_StyleOrder(int index1, int index2, const int[] array, any hndl)
|
public int SortAscending_StyleOrder(int index1, int index2, const int[] array, any hndl)
|
||||||
{
|
{
|
||||||
int iOrder1 = gA_StyleSettings[index1].iOrdering;
|
int iOrder1 = gA_StyleSettings[index1].iOrdering;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user