2 // NOTE: This file contains lots of debugging stuff
3 // it is not really used... can be seen as another sample...
5 string STR_PLAYER = "player";
6 #define FOR_EACH_PLAYER(v) for(v = world; (v = find(v, classname, STR_PLAYER)) != world; )
14 menu_show = menu_show_error;
15 menu_action = menu_sub_null;
18 strunzone(ctf_temp_1);*/
20 localcmd("\nin_bindmap 0 0;");
23 void() order_menu_render =
27 local string frags, color;
31 color = getplayerkey(player_localentnum-1, "topcolor");
33 if(getstati(STAT_CTF_STATE) == CTF_STATE_COMMANDER) {
34 drawstring(ps, "\x1D\x1E\x1E\x1E\x1E Order Menu \x1E\x1E\x1E\x1E\x1F", '8 8 0', '1 1 0', 1, 0); ps += po;
35 drawstring(ps, strcat("Order: ", ctf_temp_1), '8 8 0', '1 1 0', 1, 0); ps += po;
36 //drawstring(ps, strcat("N1 = ", ftos(player_localnum), " - N2 = ", ftos(player_localentnum)), '8 8 0', '1 1 0', 1, 0); ps += po;
37 drawcolorcodedstring(ps, "1) ^3previous page", '8 8 0', 1, 0); ps += po;
38 drawcolorcodedstring(ps, "2) ^3next page", '8 8 0', 1, 0); ps += po;
39 //drawcolorcodedstring(ps, strcat("Clients to go: ", ftos(maxclients)), '8 8 0', 1, 0); ps += po;
40 for((n = 2), (p = i = 0); i < maxclients && n > 0; ++i) {
41 frags = getplayerkey(i, "frags");
42 /*print(strcat(ftos(i), "/", ftos(p), "/", ftos(n), "/", getplayerkey(i, "viewentity"), "\n"));
43 print(strcat(" - name: ", getplayerkey(i, "name"), " - frags: ", frags, "\n"));
44 print(strcat(" - color: ", getplayerkey(i, "topcolor"), " - ", color, "\n"));*/
45 if(!frags || (i+1) == player_localentnum)
47 if(frags == "-666" || getplayerkey(i, "topcolor") != color)
50 if(p > (8*order_page))
52 // only render current page
56 drawcolorcodedstring(ps, strcat(ftos(n), ") ", getplayerkey(i, "name"), " : ", ftos(getstatf(STAT_CTF_STATE))), '8 8 0', 1, 0); ps += po;
59 //drawstring(ps, strcat("LocalEntNum = ", ftos(player_localnum)), '8 8 0', '1 1 0', 1, 0); ps += po;
60 drawstring(ps, "ESC) Exit Menu", '8 8 0', '1 1 0', 1, 0); ps += po;
66 float(float bInputType, float nPrimary, float nSecondary) order_menu_action =
69 local float p, i, n, chose;
70 local string frags, color;
71 if(bInputType != 0) // key down wanted
74 arg = chr2str(nSecondary);
75 chose = stof(chr2str(nPrimary));
78 color = getplayerkey(player_localentnum-1, "topcolor");
80 for(p = i = 0; i < maxclients; ++i) {
81 frags = getplayerkey(i, "frags");
82 if(!frags || (i+1) == player_localentnum)
84 if(frags == "-666" || getplayerkey(i, "topcolor") != color)
88 if(p <= (8*order_page)) // no ppl on page
90 } else if(arg == "2") {
91 color = getplayerkey(player_localentnum-1, "topcolor");
94 for(p = i = 0; i < maxclients; ++i) {
95 frags = getplayerkey(i, "frags");
96 if(!frags || (i+1) == player_localentnum)
98 if(frags == "-666" || getplayerkey(i, "topcolor") != color)
102 order_page = floor(p/8);
104 } else if(chose >= 3 && chose <= 9 || arg == "0") { // the 10 needs extra checking, assuming that stof(astring) returns 0
108 color = getplayerkey(player_localentnum-1, "topcolor");
109 for(p = i = 0; i < maxclients && n > 0; ++i) {
110 frags = getplayerkey(i, "frags");
111 if(!frags || (i+1) == player_localentnum)
113 if(frags == "-666" || getplayerkey(i, "topcolor") != color)
116 if(p > (8*order_page))
118 // only render current page
127 //print(strcat("Issuing order to: ", ftos(i+1), "\n"));
128 //print(strcat("cmd order #", ftos(i+1), " ", ctf_temp_1, ";\n"));
129 localcmd(strcat("\ncmd order #", ftos(i+1), " ", ctf_temp_1, ";"));
131 print(strcat("Couldn't find player ", ftos(chose), "\n"));
134 } else if(nSecondary == K_ESCAPE) {
135 strunzone(ctf_temp_1);
138 //print(strcat("Menu action ", arg, " does not exist.\n"));
144 void() order_menu_show =
147 menu_show = order_menu_render;
148 menu_action = order_menu_action;
152 void() ctf_menu_render =
158 if(getstati(STAT_CTF_STATE) == CTF_STATE_COMMANDER) {
159 drawstring(ps, "\x1D\x1E\x1E\x1E\x1E Command Menu \x1E\x1E\x1E\x1E\x1F", '8 8 0', '1 1 0', 1, 0); ps += po;
160 drawstring(ps, "Issue orders:", '8 8 0', '1 1 0', 1, 0); ps += po;
161 drawstring(ps, " 1) Attack ", '8 8 0', '1 1 0', 1, 0);
162 drawstring(ps + '80 0', " \x0F", '8 8 0', '1 1 1', 1, 0); ps += po;
163 drawstring(ps, " 2) Defend \x0E", '8 8 0', '1 1 0', 1, 0); ps += po;
165 drawstring(ps, "3) Resign from command.", '8 8 0', '1 1 0', 1, 0); ps += po;
166 drawstring(ps, "ESC) Exit Menu", '8 8 0', '1 1 0', 1, 0); ps += po;
172 float(float bInputType, float nPrimary, float nSecondary) ctf_menu_action =
175 if(bInputType != 0) // key down wanted
178 arg = chr2str(nSecondary);
181 ctf_temp_1 = strzone("attack");
183 } else if(arg == "2") {
184 ctf_temp_1 = strzone("defend");
186 } else if(arg == "3") {
187 localcmd("\ncmd order resign;");
189 } else if(nSecondary == K_ESCAPE) {
192 //print(strcat("Menu action ", arg, " does not exist.\n"));
198 void() ctf_menu_show =
200 if(getstati(STAT_CTF_STATE) < 0)
202 menu_show = ctf_menu_render;
203 menu_action = ctf_menu_action;
205 //menu_default_binds();
211 stat = getstati(STAT_CTF_STATE);
212 if(stat == CTF_STATE_ATTACK) {
213 drawpic('0 0', "gfx/ctf_ic_atk.tga", '64 64 0', '1 1 1', 1, 0);
214 } else if(stat == CTF_STATE_DEFEND) {
215 drawpic('0 0', "gfx/ctf_ic_def.tga", '64 64 0', '1 1 1', 1, 0);
216 } else if(stat == CTF_STATE_COMMANDER) {
217 drawstring('0 0', "You're commander!", '8 8 0', '1 1 1', 1, 0);
218 } else if(stat < 0) {
220 drawstring('0 0', "Awaiting orders...", '8 8 0', '1 1 1', 0.5, 0);