Skip to content

Commit 4f07e87

Browse files
committed
nomination: add new cvar mapm_nom_show_lists
1 parent 75910be commit 4f07e87

File tree

2 files changed

+72
-5
lines changed

2 files changed

+72
-5
lines changed

addons/amxmodx/configs/map_manager.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ mapm_nom_random_sort "0"
150150
// 0 - disable, 1 - enable
151151
mapm_nom_remove_maps "1"
152152

153+
// В меню номинации выводить активные списки карт (из advanced lists)
154+
// 0 - disable, 1 - enable
155+
mapm_nom_show_lists "0"
153156

154157
// Online sorter
155158

addons/amxmodx/scripting/map_manager_nomination.sma

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#include <amxmodx>
22
#include <map_manager>
33
#include <map_manager_blocklist>
4+
#include <map_manager_adv_lists>
45

56
#if AMXX_VERSION_NUM < 183
67
#include <colorchat>
78
#endif
89

910
#define PLUGIN "Map Manager: Nomination"
10-
#define VERSION "0.0.5"
11+
#define VERSION "0.0.6"
1112
#define AUTHOR "Mistrick"
1213

1314
#pragma semicolon 1
@@ -36,7 +37,8 @@ enum Cvars {
3637
DONT_CLOSE_MENU,
3738
DENOMINATE_TIME,
3839
RANDOM_SORT,
39-
REMOVE_MAPS
40+
REMOVE_MAPS,
41+
SHOW_LISTS
4042
};
4143

4244
new g_pCvars[Cvars];
@@ -60,6 +62,7 @@ public plugin_init()
6062
g_pCvars[DENOMINATE_TIME] = register_cvar("mapm_nom_denominate_time", "5"); // seconds
6163
g_pCvars[RANDOM_SORT] = register_cvar("mapm_nom_random_sort", "0"); // 0 - disable, 1 - enable
6264
g_pCvars[REMOVE_MAPS] = register_cvar("mapm_nom_remove_maps", "1"); // 0 - disable, 1 - enable
65+
g_pCvars[SHOW_LISTS] = register_cvar("mapm_nom_show_lists", "0"); // 0 - disable, 1 - enable
6366

6467
register_clcmd("say", "clcmd_say");
6568
register_clcmd("say_team", "clcmd_say");
@@ -78,13 +81,25 @@ public module_filter_handler(const library[], LibType:type)
7881
if(equal(library, "map_manager_blocklist")) {
7982
return PLUGIN_HANDLED;
8083
}
84+
if(equal(library, "map_manager_adv_lists")) {
85+
return PLUGIN_HANDLED;
86+
}
8187
return PLUGIN_CONTINUE;
8288
}
8389
public native_filter_handler(const native_func[], index, trap)
8490
{
8591
if(equal(native_func, "mapm_get_blocked_count")) {
8692
return PLUGIN_HANDLED;
8793
}
94+
if(equal(native_func, "mapm_advl_get_active_lists")) {
95+
return PLUGIN_HANDLED;
96+
}
97+
if(equal(native_func, "mapm_advl_get_list_name")) {
98+
return PLUGIN_HANDLED;
99+
}
100+
if(equal(native_func, "mapm_advl_get_list_array")) {
101+
return PLUGIN_HANDLED;
102+
}
88103
return PLUGIN_CONTINUE;
89104
}
90105
public callback_disable_item()
@@ -266,10 +281,59 @@ public nomlist_handler(id, menu, item)
266281
}
267282
public clcmd_mapslist(id)
268283
{
269-
new text[64]; formatex(text, charsmax(text), "%L", LANG_PLAYER, "MAPM_MENU_MAP_LIST");
284+
if(get_num(SHOW_LISTS) && mapm_advl_get_active_lists() > 1) {
285+
show_lists_menu(id);
286+
} else {
287+
show_nomination_menu(id, g_aMapsList);
288+
}
289+
}
290+
show_lists_menu(id)
291+
{
292+
new text[64];
293+
new menu = menu_create("Maps lists:", "lists_handler");
294+
295+
new list[32], size = mapm_advl_get_active_lists();
296+
for(new i; i < size; i++) {
297+
mapm_advl_get_list_name(i, list, charsmax(list));
298+
menu_additem(menu, list);
299+
}
300+
301+
formatex(text, charsmax(text), "%L", id, "MAPM_MENU_BACK");
302+
menu_setprop(menu, MPROP_BACKNAME, text);
303+
formatex(text, charsmax(text), "%L", id, "MAPM_MENU_NEXT");
304+
menu_setprop(menu, MPROP_NEXTNAME, text);
305+
formatex(text, charsmax(text), "%L", id, "MAPM_MENU_EXIT");
306+
menu_setprop(menu, MPROP_EXITNAME, text);
307+
308+
menu_display(id, menu);
309+
}
310+
public lists_handler(id, menu, item)
311+
{
312+
if(item == MENU_EXIT) {
313+
menu_destroy(menu);
314+
return PLUGIN_HANDLED;
315+
}
316+
317+
new item_info[8], item_name[32], access, callback;
318+
menu_item_getinfo(menu, item, access, item_info, charsmax(item_info), item_name, charsmax(item_name), callback);
319+
320+
// TODO: make this safe, callback may call after changes in adv list
321+
new Array:maplist = mapm_advl_get_list_array(item);
322+
show_nomination_menu(id, maplist, item_name);
323+
324+
return PLUGIN_HANDLED;
325+
}
326+
show_nomination_menu(id, Array:maplist, custom_title[] = "")
327+
{
328+
new text[64];
329+
if(!custom_title[0]) {
330+
formatex(text, charsmax(text), "%L", LANG_PLAYER, "MAPM_MENU_MAP_LIST");
331+
} else {
332+
formatex(text, charsmax(text), "%s", custom_title);
333+
}
270334
new menu = menu_create(text, "mapslist_handler");
271335

272-
new map_info[MapStruct], item_info[48], block_count, size = ArraySize(g_aMapsList);
336+
new map_info[MapStruct], item_info[48], block_count, size = ArraySize(maplist);
273337
new random_sort = get_num(RANDOM_SORT), Array:array = ArrayCreate(1, 1);
274338

275339
for(new i = 0, index, nom_index; i < size; i++) {
@@ -282,7 +346,7 @@ public clcmd_mapslist(id)
282346
index = i;
283347
}
284348

285-
ArrayGetArray(g_aMapsList, index, map_info);
349+
ArrayGetArray(maplist, index, map_info);
286350
nom_index = map_nominated(map_info[MapName]);
287351
block_count = mapm_get_blocked_count(map_info[MapName]);
288352

0 commit comments

Comments
 (0)