3 // NOTE: This file contains lots of debugging stuff
4 // it is not really used... can be seen as another sample...
6 string STR_PLAYER = "player";
7 #define FOR_EACH_PLAYER(v) for(v = world; (v = find(v, classname, STR_PLAYER)) != world; )
15 menu_show = menu_show_error;
16 menu_action = menu_sub_null;
19 strunzone(ctf_temp_1);*/
21 localcmd("\nin_bindmap 0 0;");
24 void() order_menu_render =
28 local string frags, color;
32 color = getplayerkey(player_localentnum-1, "topcolor");
34 if(getstati(STAT_CTF_STATE) == CTF_STATE_COMMANDER) {
35 drawstring(ps, _("----- Order Menu -----"), '8 8 0', '1 1 0', 1, 0); ps += po;
36 drawstring(ps, sprintf(_("Order: %s"), ctf_temp_1), '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 for((n = 2), (p = i = 0); i < maxclients && n > 0; ++i) {
40 frags = getplayerkey(i, "frags");
41 if(!frags || (i+1) == player_localentnum)
43 if(frags == "-666" || getplayerkey(i, "topcolor") != color) // FIXME use GetPlayerTeam
46 if(p > (8*order_page))
48 // only render current page
52 drawcolorcodedstring(ps, strcat(ftos(n), ") ", GetPlayerName(i), " : ", ftos(getstatf(STAT_CTF_STATE))), '8 8 0', 1, 0); ps += po;
55 drawstring(ps, _("ESC) Exit Menu"), '8 8 0', '1 1 0', 1, 0); ps += po;
61 float(float bInputType, float nPrimary, float nSecondary) order_menu_action =
64 local float p, i, n, chose;
65 local string frags, color;
66 if(bInputType != 0) // key down wanted
69 arg = chr2str(nSecondary);
70 chose = stof(chr2str(nPrimary));
73 color = getplayerkey(player_localentnum-1, "topcolor");
75 for(p = i = 0; i < maxclients; ++i) {
76 frags = getplayerkey(i, "frags");
77 if(!frags || (i+1) == player_localentnum)
79 if(frags == "-666" || getplayerkey(i, "topcolor") != color) // FIXME use GetPlayerTeam
83 if(p <= (8*order_page)) // no ppl on page
85 } else if(arg == "2") {
86 color = getplayerkey(player_localentnum-1, "topcolor");
89 for(p = i = 0; i < maxclients; ++i) {
90 frags = getplayerkey(i, "frags");
91 if(!frags || (i+1) == player_localentnum)
93 if(frags == "-666" || getplayerkey(i, "topcolor") != color) // FIXME use GetPlayerTeam
97 order_page = floor(p/8);
99 } else if(chose >= 3 && chose <= 9 || arg == "0") { // the 10 needs extra checking, assuming that stof(astring) returns 0
103 color = getplayerkey(player_localentnum-1, "topcolor");
104 for(p = i = 0; i < maxclients && n > 0; ++i) {
105 frags = getplayerkey(i, "frags");
106 if(!frags || (i+1) == player_localentnum)
108 if(frags == "-666" || getplayerkey(i, "topcolor") != color) // FIXME use GetPlayerTeam
111 if(p > (8*order_page))
113 // only render current page
122 //print(sprintf(_("Issuing order to: %d\n"), i+1));
123 //print(strcat("cmd order #", ftos(i+1), " ", ctf_temp_1, ";\n"));
124 localcmd(strcat("\ncmd order #", ftos(i+1), " ", ctf_temp_1, ";"));
126 print(sprintf(_("Couldn't find player %d\n"), chose));
129 } else if(nSecondary == K_ESCAPE) {
130 strunzone(ctf_temp_1);
133 //print(sprintf(_("Menu action %s does not exist.\n"), arg));
139 void() order_menu_show =
142 menu_show = order_menu_render;
143 menu_action = order_menu_action;
147 void() ctf_menu_render =
153 if(getstati(STAT_CTF_STATE) == CTF_STATE_COMMANDER) {
154 drawstring(ps, _("----- Command Menu -----"), '8 8 0', '1 1 0', 1, 0); ps += po;
155 drawstring(ps, _("Issue orders:"), '8 8 0', '1 1 0', 1, 0); ps += po;
156 drawstring(ps, _(" 1) Attack"), '8 8 0', '1 1 0', 1, 0);
157 drawstring(ps + '80 0 0', " \x0F", '8 8 0', '1 1 1', 1, 0); ps += po;
158 drawstring(ps, strcat(_(" 2) Defend"), " \x0E"), '8 8 0', '1 1 0', 1, 0); ps += po;
160 drawstring(ps, _("3) Resign from command."), '8 8 0', '1 1 0', 1, 0); ps += po;
161 drawstring(ps, _("ESC) Exit Menu"), '8 8 0', '1 1 0', 1, 0); ps += po;
167 float(float bInputType, float nPrimary, float nSecondary) ctf_menu_action =
170 if(bInputType != 0) // key down wanted
173 arg = chr2str(nSecondary);
176 ctf_temp_1 = strzone("attack");
178 } else if(arg == "2") {
179 ctf_temp_1 = strzone("defend");
181 } else if(arg == "3") {
182 localcmd("\ncmd order resign;");
184 } else if(nSecondary == K_ESCAPE) {
187 //print(strcat("Menu action ", arg, " does not exist.\n"));
193 void() ctf_menu_show =
195 if(getstati(STAT_CTF_STATE) < 0)
197 menu_show = ctf_menu_render;
198 menu_action = ctf_menu_action;
200 //menu_default_binds();
206 stat = getstati(STAT_CTF_STATE);
207 if(stat == CTF_STATE_ATTACK) {
208 drawpic('0 0 0', "gfx/ctf_ic_atk.tga", '64 64 0', '1 1 1', 1, 0);
209 } else if(stat == CTF_STATE_DEFEND) {
210 drawpic('0 0 0', "gfx/ctf_ic_def.tga", '64 64 0', '1 1 1', 1, 0);
211 } else if(stat == CTF_STATE_COMMANDER) {
212 drawstring('0 0 0', _("You're commander!"), '8 8 0', '1 1 1', 1, 0);
213 } else if(stat < 0) {
215 drawstring('0 0 0', _("Awaiting orders..."), '8 8 0', '1 1 1', 0.5, 0);