2 * Copyright (C) 2003 Robert Kooima
4 * NEVERBALL is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
23 /*---------------------------------------------------------------------------*/
25 static int is_special_name(const char * n)
27 return (strcmp(n, N_("Hard"))==0 || strcmp(n, N_("Medium"))==0 || strcmp(n, N_("Easy"))==0);
30 /*---------------------------------------------------------------------------*/
36 static int coin_lastrow;
38 /* Build a Most Coins top three list with default values. */
40 void gui_most_coins(int id, int n, int n2)
42 const char *s = "1234567";
44 int j, jd, kd, ld, md;
49 if ((jd = gui_hstack(id)))
53 if ((kd = gui_vstack(jd)))
55 gui_label(kd, _("Most Coins"), GUI_SML, GUI_TOP, 0, 0);
57 if ((ld = gui_hstack(kd)))
59 if ((md = gui_vstack(ld)))
61 for (j = 0; j < n - 1; j++)
62 coin_c[j] = gui_count(md, 1000, GUI_SML, 0);
64 coin_c[j++] = gui_count(md, 1000, GUI_SML, GUI_SE);
69 coin_c[j++] = gui_count(md, 1000, GUI_SML, GUI_RGT);
73 if ((md = gui_vstack(ld)))
75 for (j = 0; j < n; j++)
76 coin_n[j] = gui_label(md, s, GUI_SML, 0, gui_yel, gui_wht);
81 coin_n[j++] = gui_label(md, s, GUI_SML, 0, gui_yel, gui_wht);
85 if ((md = gui_vstack(ld)))
87 for (j = 0; j < n - 1; j++)
88 coin_t[j] = gui_clock(md, 359999, GUI_SML, 0);
90 coin_t[j++] = gui_clock(md, 359999, GUI_SML, GUI_SW);
95 coin_t[j++] = gui_clock(md, 359999, GUI_SML, GUI_LFT);
104 /* Set the Most Coins top three list values for level i. */
106 void set_most_coins(int level, int hilight)
111 for (j = 0; j < coin_row + coin_lastrow; j++)
113 name = level_coin_n(level, j);
114 spe = is_special_name(name);
117 gui_set_color(coin_n[j], 0, 0);
118 else if (j != hilight)
119 gui_set_color(coin_n[j], gui_yel, gui_wht);
120 else if (j>= coin_row)
121 gui_set_color(coin_n[j], gui_red, gui_red);
123 gui_set_color(coin_n[j], gui_grn, gui_grn);
125 gui_set_count(coin_c[j], level_coin_c(level, j));
126 gui_set_label(coin_n[j], spe ? _(name) : name);
127 gui_set_clock(coin_t[j], level_coin_t(level, j));
131 /*---------------------------------------------------------------------------*/
133 static int time_c[4];
134 static int time_n[4];
135 static int time_t[4];
137 static int time_lastrow;
139 /* Build a Best Times top three list with default values. */
141 void gui_best_times(int id, int n, int n2)
143 const char *s = "1234567";
145 int j, jd, kd, ld, md;
150 if ((jd = gui_hstack(id)))
154 if ((kd = gui_vstack(jd)))
156 gui_label(kd, _("Best Times"), GUI_SML, GUI_TOP, 0, 0);
158 if ((ld = gui_hstack(kd)))
160 if ((md = gui_vstack(ld)))
162 for (j = 0; j < n - 1; j++)
163 time_t[j] = gui_clock(md, 359999, GUI_SML, 0);
165 time_t[j++] = gui_clock(md, 359999, GUI_SML, GUI_SE);
170 time_t[j++] = gui_clock(md, 359999, GUI_SML, GUI_RGT);
174 if ((md = gui_vstack(ld)))
176 for (j = 0; j < n; j++)
177 time_n[j] = gui_label(md, s, GUI_SML, 0, gui_yel, gui_wht);
182 time_n[j++] = gui_label(md, s, GUI_SML, 0, gui_yel, gui_wht);
186 if ((md = gui_vstack(ld)))
188 for (j = 0; j < n - 1; j++)
189 time_c[j] = gui_count(md, 1000, GUI_SML, 0);
191 time_c[j++] = gui_count(md, 1000, GUI_SML, GUI_SW);
196 time_c[j++] = gui_count(md, 1000, GUI_SML, GUI_LFT);
205 /* Set the Best Times top three list values for level i. */
207 void set_best_times(int level, int hilight)
212 for (j = 0; j < time_row + time_lastrow; j++)
214 name = level_time_n(level, j);
215 spe = is_special_name(name);
218 gui_set_color(time_n[j], 0, 0);
219 else if (j != hilight)
220 gui_set_color(time_n[j], gui_yel, gui_wht);
221 else if (j>= time_row)
222 gui_set_color(time_n[j], gui_red, gui_red);
224 gui_set_color(time_n[j], gui_grn, gui_grn);
226 gui_set_clock(time_t[j], level_time_t(level, j));
227 gui_set_label(time_n[j], spe ? _(name) : name);
228 gui_set_count(time_c[j], level_time_c(level, j));
232 /*---------------------------------------------------------------------------*/
235 static int keyd[127];
237 static void gui_fill(int id, char * line)
244 keyd[(int)*l] = gui_state(id, l, GUI_SML, *l, 0);
248 void gui_keyboard(int id)
254 if ((jd = gui_hstack(id)))
258 if ((kd = gui_vstack(jd)))
260 if ((ld = gui_harray(kd)))
263 gui_fill(ld, "9876543210");
266 if ((ld = gui_harray(kd)))
269 gui_fill(ld, "JIHGFEDCBA");
272 if ((ld = gui_harray(kd)))
275 gui_fill(ld, "TSRQPONMLK");
278 if ((ld = gui_harray(kd)))
281 gui_fill(ld, "!.-_ZYXWVU");
284 if ((ld = gui_harray(kd)))
287 gui_fill(ld, "jihgfedcba");
290 if ((ld = gui_harray(kd)))
293 gui_fill(ld, "tsrqponmlk");
296 if ((ld = gui_hstack(kd)))
299 gui_state(ld, _("del"), GUI_SML, GUI_BS, 0);
300 gui_fill(ld, "zyxwvu");
308 /*---------------------------------------------------------------------------*/