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.
28 /*---------------------------------------------------------------------------*/
34 /*---------------------------------------------------------------------------*/
36 /* Create a level selector button based upon its existence and status. */
38 static void gui_level(int id
, char *text
, int i
)
40 int o
= level_opened(i
);
41 int e
= level_exists(i
);
43 if (o
) gui_state(id
, text
, GUI_SML
, i
, 0);
44 else if (e
) gui_label(id
, text
, GUI_SML
, GUI_ALL
, gui_yel
, gui_red
);
45 else gui_label(id
, text
, GUI_SML
, GUI_ALL
, gui_blk
, gui_blk
);
48 /*---------------------------------------------------------------------------*/
50 static int start_action(int i
)
52 audio_play(AUD_MENU
, 1.0f
);
55 return goto_state(&st_set
);
59 if (level_play(USER_REPLAY_FILE
, i
))
60 return goto_state(&st_level
);
64 return goto_state(&st_title
);
70 static int start_enter(void)
72 int w
= config_get_d(CONFIG_WIDTH
);
73 int h
= config_get_d(CONFIG_HEIGHT
);
77 if ((id
= gui_vstack(0)))
79 if ((jd
= gui_harray(id
)))
81 gui_label(jd
, "Level", GUI_SML
, GUI_ALL
, gui_yel
, gui_red
);
84 gui_start(jd
, "Back", GUI_SML
, START_BACK
, 0);
87 if ((jd
= gui_harray(id
)))
89 shot_id
= gui_image(jd
, "shot-rlk/easy.jpg", 7 * w
/ 16, 7 * h
/ 16);
91 if ((kd
= gui_varray(jd
)))
93 if ((ld
= gui_harray(kd
)))
95 gui_level(ld
, "05", 5);
96 gui_level(ld
, "04", 4);
97 gui_level(ld
, "03", 3);
98 gui_level(ld
, "02", 2);
99 gui_level(ld
, "01", 1);
101 if ((ld
= gui_harray(kd
)))
103 gui_level(ld
, "10", 10);
104 gui_level(ld
, "09", 9);
105 gui_level(ld
, "08", 8);
106 gui_level(ld
, "07", 7);
107 gui_level(ld
, "06", 6);
109 if ((ld
= gui_harray(kd
)))
111 gui_level(ld
, "15", 15);
112 gui_level(ld
, "14", 14);
113 gui_level(ld
, "13", 13);
114 gui_level(ld
, "12", 12);
115 gui_level(ld
, "11", 11);
117 if ((ld
= gui_harray(kd
)))
119 gui_level(ld
, "20", 20);
120 gui_level(ld
, "19", 19);
121 gui_level(ld
, "18", 18);
122 gui_level(ld
, "17", 17);
123 gui_level(ld
, "16", 16);
125 if ((ld
= gui_harray(kd
)))
127 gui_level(ld
, "25", 25);
128 gui_level(ld
, "24", 24);
129 gui_level(ld
, "23", 23);
130 gui_level(ld
, "22", 22);
131 gui_level(ld
, "21", 21);
137 if ((jd
= gui_harray(id
)))
139 gui_most_coins(jd
, 3, 4);
140 gui_best_times(jd
, 3, 4);
143 gui_layout(id
, 0, 0);
144 set_most_coins(0, 3);
145 set_best_times(0, 3);
151 static void start_leave(int id
)
156 static void start_paint(int id
, float st
)
163 static void start_timer(int id
, float dt
)
169 static void start_point(int id
, int x
, int y
, int dx
, int dy
)
173 if ((jd
= gui_point(id
, x
, y
)))
175 int i
= gui_token(jd
);
177 gui_set_image(shot_id
, level_shot(i
));
179 set_most_coins(i
, 3);
180 set_best_times(i
, 3);
186 static void start_stick(int id
, int a
, int v
)
190 int x
= (config_tst_d(CONFIG_JOYSTICK_AXIS_X
, a
)) ? v
: 0;
191 int y
= (config_tst_d(CONFIG_JOYSTICK_AXIS_Y
, a
)) ? v
: 0;
193 if ((jd
= gui_stick(id
, x
, y
)))
195 int i
= gui_token(jd
);
197 gui_set_image(shot_id
, level_shot(i
));
199 set_most_coins(i
, 3);
200 set_best_times(i
, 3);
206 static int start_click(int b
, int d
)
209 return start_action(gui_token(gui_click()));
213 static int start_keybd(int c
, int d
)
215 if (d
&& c
== SDLK_ESCAPE
)
216 return goto_state(&st_title
);
218 if (d
&& c
== SDLK_F12
)
220 int n
= curr_count();
223 /* Iterate over all levels, taking a screenshot of each. */
225 for (i
= 1; i
< n
; i
++)
233 static int start_buttn(int b
, int d
)
237 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A
, b
))
238 return start_action(gui_token(gui_click()));
239 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_B
, b
))
240 return goto_state(&st_title
);
241 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT
, b
))
242 return goto_state(&st_title
);
247 /*---------------------------------------------------------------------------*/
249 struct state st_start
= {