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.
22 #include "st_shared.h"
28 /*---------------------------------------------------------------------------*/
35 #define SET_GROUP 5 /* number of sets in one screen */
40 static int set_action(int i)
42 audio_play(AUD_MENU, 1.0f);
47 return goto_state(&st_title);
50 config_set_d(CONFIG_LAST_SET,
51 ((config_get_d(CONFIG_LAST_SET) / SET_GROUP) - 1) * SET_GROUP);
52 return goto_state(&st_set);
55 config_set_d(CONFIG_LAST_SET,
56 ((config_get_d(CONFIG_LAST_SET) / SET_GROUP) + 1) * SET_GROUP);
57 return goto_state(&st_set);
65 config_set_d(CONFIG_LAST_SET, i);
67 return goto_state(&st_start);
73 static void gui_set(int id, int i)
75 const struct set *s = get_set(i);
79 jd = gui_label(id, _(s->name), GUI_SML, GUI_ALL, gui_yel, gui_wht);
80 else if (set_unlocked(s))
81 jd = gui_label(id, _(s->name), GUI_SML, GUI_ALL, gui_grn, gui_wht);
83 jd = gui_label(id, _(s->name), GUI_SML, GUI_ALL, gui_wht, gui_wht);
88 static int set_enter(void)
90 int w = config_get_d(CONFIG_WIDTH);
91 int h = config_get_d(CONFIG_HEIGHT);
92 int last_set = config_get_d(CONFIG_LAST_SET);
93 int b = last_set / SET_GROUP;
101 /* Reset last set if it do not exists */
102 if (!set_exists(last_set))
106 config_set_d(CONFIG_LAST_SET, 0);
109 audio_music_fade_to(0.5f, "bgm/inter.ogg");
110 audio_play(AUD_START, 1.f);
112 if ((id = gui_vstack(0)))
114 if ((jd = gui_hstack(id)))
116 gui_label(jd, _("Level Set"), GUI_SML, GUI_ALL, gui_yel, gui_red);
118 gui_back_prev_next(jd, b > 0, set_exists((b + 1) * SET_GROUP));
121 if ((jd = gui_harray(id)))
123 shot_id = gui_image(jd, get_set(last_set)->shot, 7 * w / 16,
126 if ((kd = gui_varray(jd)))
129 for (i = b * SET_GROUP; i < (b + 1) * SET_GROUP && set_exists(i); i++)
132 /* Display empty slots */
133 for(; i < (b + 1) * SET_GROUP; i++)
139 desc_id = gui_multi(id, " \\ \\ \\ \\ \\", GUI_SML, GUI_ALL, gui_yel, gui_wht);
141 gui_layout(id, 0, 0);
146 static void set_over(int i)
148 gui_set_image(shot_id, get_set(i)->shot);
149 gui_set_multi(desc_id, _(get_set(i)->desc));
152 static void set_point(int id, int x, int y, int dx, int dy)
154 int jd = shared_point_basic(id, x, y);
155 int i = gui_token(jd);
156 if (jd && set_exists(i))
160 static void set_stick(int id, int a, int v)
162 int jd = shared_stick_basic(id, a, v);
163 int i = gui_token(jd);
164 if (jd && set_exists(i))
168 static int set_buttn(int b, int d)
172 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
173 return set_action(gui_token(gui_click()));
174 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
175 return set_action(GUI_BACK);
180 /*---------------------------------------------------------------------------*/
182 struct state st_set = {