Port KeyValues to the transitional syntax.

This commit is contained in:
David Anderson
2014-11-08 15:54:40 -08:00
parent 78687080b1
commit f020b5682e
8 changed files with 423 additions and 134 deletions
+27 -30
View File
@@ -74,16 +74,15 @@ new Handle:g_DataArray;
BuildDynamicMenu()
{
new itemInput[Item];
int itemInput[Item];
g_DataArray = CreateArray(sizeof(itemInput));
new String:executeBuffer[32];
char executeBuffer[32];
new Handle:kvMenu;
kvMenu = CreateKeyValues("Commands");
KvSetEscapeSequences(kvMenu, true);
KeyValues kvMenu = KeyValues("Commands");
kvMenu.SetEscapeSequences(true);
new String:file[256];
char file[256];
/* As a compatibility shim, we use the old file if it exists. */
BuildPath(Path_SM, file, 255, "configs/dynamicmenu/menu.ini");
@@ -102,10 +101,8 @@ BuildDynamicMenu()
new String:name[NAME_LENGTH];
new String:buffer[NAME_LENGTH];
if (!KvGotoFirstSubKey(kvMenu))
{
if (!kvMenu.GotoFirstSubKey())
return;
}
decl String:admin[30];
@@ -113,9 +110,9 @@ BuildDynamicMenu()
do
{
KvGetSectionName(kvMenu, buffer, sizeof(buffer));
kvMenu.GetSectionName(buffer, sizeof(buffer));
KvGetString(kvMenu, "admin", admin, sizeof(admin),"sm_admin");
kvMenu.GetString("admin", admin, sizeof(admin),"sm_admin");
if ((categoryId = hAdminMenu.FindCategory(buffer)) == INVALID_TOPMENUOBJECT)
{
@@ -130,16 +127,16 @@ BuildDynamicMenu()
decl String:category_name[NAME_LENGTH];
strcopy(category_name, sizeof(category_name), buffer);
if (!KvGotoFirstSubKey(kvMenu))
if (!kvMenu.GotoFirstSubKey())
{
return;
}
do
{
KvGetSectionName(kvMenu, buffer, sizeof(buffer));
kvMenu.GetSectionName(buffer, sizeof(buffer));
KvGetString(kvMenu, "admin", admin, sizeof(admin),"");
kvMenu.GetString("admin", admin, sizeof(admin),"");
if (admin[0] == '\0')
{
@@ -147,14 +144,14 @@ BuildDynamicMenu()
//Use the first argument of the 'cmd' string instead
decl String:temp[64];
KvGetString(kvMenu, "cmd", temp, sizeof(temp),"");
kvMenu.GetString("cmd", temp, sizeof(temp),"");
BreakString(temp, admin, sizeof(admin));
}
KvGetString(kvMenu, "cmd", itemInput[Item_cmd], sizeof(itemInput[Item_cmd]));
KvGetString(kvMenu, "execute", executeBuffer, sizeof(executeBuffer));
kvMenu.GetString("cmd", itemInput[Item_cmd], sizeof(itemInput[Item_cmd]));
kvMenu.GetString("execute", executeBuffer, sizeof(executeBuffer));
if (StrEqual(executeBuffer, "server"))
{
@@ -172,7 +169,7 @@ BuildDynamicMenu()
decl String:inputBuffer[48];
while (KvJumpToKey(kvMenu, countBuffer))
while (kvMenu.JumpToKey(countBuffer))
{
new submenuInput[Submenu];
@@ -181,7 +178,7 @@ BuildDynamicMenu()
itemInput[Item_submenus] = CreateArray(sizeof(submenuInput));
}
KvGetString(kvMenu, "type", inputBuffer, sizeof(inputBuffer));
kvMenu.GetString("type", inputBuffer, sizeof(inputBuffer));
if (strncmp(inputBuffer,"group",5)==0)
{
@@ -198,7 +195,7 @@ BuildDynamicMenu()
{
submenuInput[Submenu_type] = SubMenu_MapCycle;
KvGetString(kvMenu, "path", inputBuffer, sizeof(inputBuffer),"mapcycle.txt");
kvMenu.GetString("path", inputBuffer, sizeof(inputBuffer),"mapcycle.txt");
submenuInput[Submenu_listdata] = CreateDataPack();
WritePackString(submenuInput[Submenu_listdata], inputBuffer);
@@ -230,13 +227,13 @@ BuildDynamicMenu()
do
{
Format(temp,3,"%i",i);
KvGetString(kvMenu, temp, value, sizeof(value), "");
kvMenu.GetString(temp, value, sizeof(value), "");
Format(temp,5,"%i.",i);
KvGetString(kvMenu, temp, text, sizeof(text), value);
kvMenu.GetString(temp, text, sizeof(text), value);
Format(temp,5,"%i*",i);
KvGetString(kvMenu, temp, subadm, sizeof(subadm),"");
kvMenu.GetString(temp, subadm, sizeof(subadm),"");
if (value[0]=='\0')
{
@@ -260,7 +257,7 @@ BuildDynamicMenu()
if ((submenuInput[Submenu_type] == SubMenu_Player) || (submenuInput[Submenu_type] == SubMenu_GroupPlayer))
{
KvGetString(kvMenu, "method", inputBuffer, sizeof(inputBuffer));
kvMenu.GetString("method", inputBuffer, sizeof(inputBuffer));
if (StrEqual(inputBuffer, "clientid"))
{
@@ -288,7 +285,7 @@ BuildDynamicMenu()
}
}
KvGetString(kvMenu, "title", inputBuffer, sizeof(inputBuffer));
kvMenu.GetString("title", inputBuffer, sizeof(inputBuffer));
strcopy(submenuInput[Submenu_title], sizeof(submenuInput[Submenu_title]), inputBuffer);
count++;
@@ -296,7 +293,7 @@ BuildDynamicMenu()
PushArrayArray(itemInput[Item_submenus], submenuInput[0]);
KvGoBack(kvMenu);
kvMenu.GoBack();
}
/* Save this entire item into the global items array and add it to the menu */
@@ -316,13 +313,13 @@ BuildDynamicMenu()
LogError("Duplicate command name \"%s\" in adminmenu_custom.txt category \"%s\"", buffer, category_name);
}
} while (KvGotoNextKey(kvMenu));
} while (kvMenu.GotoNextKey());
KvGoBack(kvMenu);
kvMenu.GoBack();
} while (KvGotoNextKey(kvMenu));
} while (kvMenu.GotoNextKey());
CloseHandle(kvMenu);
delete kvMenu;
}
ParseConfigs()