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.
25 /*---------------------------------------------------------------------------*/
31 #define SET_GROUP 5 /* number of sets in one screen */
36 static int set_action(int i)
38 audio_play(AUD_MENU, 1.0f);
43 return goto_state(&st_title);
46 config_set_d(CONFIG_LAST_SET, ((config_get_d(CONFIG_LAST_SET)/SET_GROUP)-1)*SET_GROUP);
47 return goto_state(&st_set);
50 config_set_d(CONFIG_LAST_SET, ((config_get_d(CONFIG_LAST_SET)/SET_GROUP)+1)*SET_GROUP);
51 return goto_state(&st_set);
56 config_set_d(CONFIG_LAST_SET, i);
58 return goto_state(&st_start);
64 static int set_enter(void)
66 int w = config_get_d(CONFIG_WIDTH);
67 int h = config_get_d(CONFIG_HEIGHT);
68 int last_set = config_get_d(CONFIG_LAST_SET);
69 int b = last_set / SET_GROUP;
76 audio_music_fade_to(0.5f, "bgm/inter.ogg");
77 audio_play(AUD_START, 1.f);
79 if ((id = gui_vstack(0)))
81 if ((jd = gui_hstack(id)))
83 gui_label(jd, _("Level Set"), GUI_SML, GUI_ALL, gui_yel, gui_red);
85 if (set_exists((b+1)*SET_GROUP))
86 gui_state(jd, _("Next"), GUI_SML, SET_NEXT, 0);
88 gui_state(jd, _("Prev"), GUI_SML, SET_PREV, 0);
89 gui_state(jd, _("Back"), GUI_SML, SET_BACK, 0);
92 if ((jd = gui_harray(id)))
94 shot_id = gui_image(jd, set_shot(last_set), 7 * w / 16, 7 * h / 16);
96 if ((kd = gui_varray(jd)))
99 for(i=b*SET_GROUP; i<(b+1)*SET_GROUP && set_exists(i); i++)
102 gui_start(kd, _(set_name(i)), GUI_SML, i, 0);
104 gui_state(kd, _(set_name(i)), GUI_SML, i, 0);
107 /* Display empty slots */
108 for(; i<(b+1)*SET_GROUP; i++)
114 desc_id = gui_multi(id, " \\ \\ \\ \\ \\", GUI_SML, GUI_ALL, gui_yel, gui_wht);
116 gui_layout(id, 0, 0);
121 static void set_leave(int id)
126 static void set_paint(int id, float st)
133 static void set_timer(int id, float dt)
139 static void set_point(int id, int x, int y, int dx, int dy)
143 if ((jd = gui_point(id, x, y)))
145 int i = gui_token(jd);
149 gui_set_image(shot_id, set_shot(i));
150 gui_set_multi(desc_id, _(set_desc(i)));
156 static void set_stick(int id, int a, int v)
160 int x = (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a)) ? v : 0;
161 int y = (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a)) ? v : 0;
163 if ((jd = gui_stick(id, x, y)))
165 int i = gui_token(jd);
169 gui_set_image(shot_id, set_shot(i));
170 gui_set_multi(desc_id, _(set_desc(i)));
176 static int set_click(int b, int d)
178 return (b < 0 && d == 1) ? set_action(gui_token(gui_click())) : 1;
181 static int set_buttn(int b, int d)
185 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
186 return set_action(gui_token(gui_click()));
187 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
188 return goto_state(&st_title);
193 /*---------------------------------------------------------------------------*/
195 struct state st_set = {