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 extern struct state st_conf;
29 extern struct state st_null;
33 /*---------------------------------------------------------------------------*/
37 static int lang_action(int i)
50 config_set_s(CONFIG_LANG, language_get_code(i-1));
60 static int lang_enter(void)
65 char * ln, * ln1, * ln2;
67 back_init("back/gui.png", config_get_d(CONFIG_GEOMETRY));
69 /* Initialize the language selection GUI. */
70 l = language_from_code(config_simple_get_s(CONFIG_LANG));
72 if ((id = gui_harray(0)))
74 if ((jd = gui_varray(id)))
76 if ((kd = gui_harray(jd)))
78 gui_label(kd, _("Language"), GUI_SML, GUI_ALL, 0, 0);
80 gui_start(kd, _("Back"), GUI_SML, LANG_BACK, 0);
83 lang_names = calloc(language_count(), sizeof(char*));
85 gui_state(jd, _(language_get_name(0)), GUI_SML, 1, (l==0));
86 for(i=1; i<=language_count(); i++)
89 ln1 = _(language_get_name(i));
91 ln2 = _(language_get_name(i));
92 if (strcmp(ln1, ln2) == 0)
96 ln = malloc(sizeof(char)*(strlen(ln1)+strlen(ln2)+4));
104 gui_state(jd, ln, GUI_SML, i+1, (l==i));
107 gui_layout(id, 0, 0);
110 audio_music_fade_to(0.5f, "bgm/inter.ogg");
115 static void lang_leave(int id)
118 for(i=0;i<language_count();i++)
119 if (lang_names[i] != NULL)
126 static void lang_paint(int id, float st)
128 config_push_persp((float) config_get_d(CONFIG_VIEW_FOV), 0.1f, FAR_DIST);
136 static void lang_timer(int id, float dt)
142 static void lang_point(int id, int x, int y, int dx, int dy)
144 gui_pulse(gui_point(id, x, y), 1.2f);
147 static void lang_stick(int id, int a, int v)
149 if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
150 gui_pulse(gui_stick(id, v, 0), 1.2f);
151 if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
152 gui_pulse(gui_stick(id, 0, v), 1.2f);
155 static int lang_click(int b, int d)
158 return lang_action(gui_token(gui_click()));
162 static int lang_keybd(int c, int d)
164 return (d && c == SDLK_ESCAPE) ? goto_state(&st_conf) : 1;
167 static int lang_buttn(int b, int d)
171 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
172 return lang_action(gui_token(gui_click()));
173 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_B, b))
174 return goto_state(&st_conf);
175 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
176 return goto_state(&st_conf);
181 /*---------------------------------------------------------------------------*/
184 struct state st_lang = {