1.1 --- a/plugins/basecommands/execcfg.sp Tue Oct 16 17:29:06 2007 +0000
1.2 +++ b/plugins/basecommands/execcfg.sp Tue Oct 16 18:37:24 2007 +0000
1.3 @@ -1,3 +1,5 @@
1.4 +new Handle:g_ConfigMenu = INVALID_HANDLE;
1.5 +
1.6 PerformExec(client, String:path[])
1.7 {
1.8 if (!FileExists(path))
1.9 @@ -26,7 +28,7 @@
1.10 }
1.11 else if (action == TopMenuAction_SelectOption)
1.12 {
1.13 - DisplayMenu(g_ConfigList, param, MENU_TIME_FOREVER);
1.14 + DisplayMenu(g_ConfigMenu, param, MENU_TIME_FOREVER);
1.15 }
1.16 }
1.17
1.18 @@ -65,18 +67,27 @@
1.19 return Plugin_Handled;
1.20 }
1.21
1.22 +new Handle:config_parser = INVALID_HANDLE;
1.23 ParseConfigs()
1.24 {
1.25 - new Handle:list = SMC_CreateParser();
1.26 - SMC_SetReaders(list, NewSection, KeyValue, EndSection);
1.27 - SMC_SetParseEnd(list, ParseEnd);
1.28 + if (config_parser == INVALID_HANDLE)
1.29 + {
1.30 + config_parser = SMC_CreateParser();
1.31 + }
1.32 +
1.33 + SMC_SetReaders(config_parser, NewSection, KeyValue, EndSection);
1.34
1.35 - new Handle:menu = CreateMenu(MenuHandler_ExecCFG);
1.36 - SetMenuTitle(menu, "Choose Config");
1.37 - SetMenuExitBackButton(menu, true);
1.38 + if (g_ConfigMenu != INVALID_HANDLE)
1.39 + {
1.40 + CloseHandle(g_ConfigMenu);
1.41 + }
1.42 +
1.43 + g_ConfigMenu = CreateMenu(MenuHandler_ExecCFG);
1.44 + SetMenuTitle(g_ConfigMenu, "Choose Config");
1.45 + SetMenuExitBackButton(g_ConfigMenu, true);
1.46
1.47 decl String:configPath[256];
1.48 - BuildPath(Path_SM, configPath, sizeof(configPath), "configs/menu_configs.cfg");
1.49 + BuildPath(Path_SM, configPath, sizeof(configPath), "configs/adminmenu_cfgs.txt");
1.50
1.51 if (!FileExists(configPath))
1.52 {
1.53 @@ -85,9 +96,15 @@
1.54 return;
1.55 }
1.56
1.57 - g_ConfigList = menu;
1.58 -
1.59 - SMC_ParseFile(list, configPath);
1.60 + new line;
1.61 + new SMCError:err = SMC_ParseFile(config_parser, configPath, line);
1.62 + if (err != SMCError_Okay)
1.63 + {
1.64 + decl String:error[256];
1.65 + SMC_GetErrorString(err, error, sizeof(error));
1.66 + LogError("Could not parse file (line %d, file \"%s\"):", line, configPath);
1.67 + LogError("Parser encountered error: %s", error);
1.68 + }
1.69
1.70 return;
1.71 }
1.72 @@ -99,18 +116,10 @@
1.73
1.74 public SMCResult:KeyValue(Handle:smc, const String:key[], const String:value[], bool:key_quotes, bool:value_quotes)
1.75 {
1.76 - AddMenuItem(g_ConfigList, key, value);
1.77 + AddMenuItem(g_ConfigMenu, key, value);
1.78 }
1.79
1.80 public SMCResult:EndSection(Handle:smc)
1.81 {
1.82
1.83 }
1.84 -
1.85 -public ParseEnd(Handle:smc, bool:halted, bool:failed)
1.86 -{
1.87 - if (halted || failed)
1.88 - LogError("Reading of configs file failed");
1.89 -
1.90 - CloseHandle(smc);
1.91 -}
1.92 \ No newline at end of file