2 * Copyright (C) 2003 Robert Kooima
4 * NEVERPUTT 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.
31 /*---------------------------------------------------------------------------*/
33 static SDL_Joystick *joystick = NULL;
35 void set_joystick(SDL_Joystick *j)
40 /*---------------------------------------------------------------------------*/
42 static char *number(int i)
44 static char str[MAXSTR];
46 sprintf(str, "%02d", i);
51 static int score_card(const char *title,
57 int p1 = (curr_party() >= 1) ? 1 : 0, l1 = (curr_party() == 1) ? 1 : 0;
58 int p2 = (curr_party() >= 2) ? 1 : 0, l2 = (curr_party() == 2) ? 1 : 0;
59 int p3 = (curr_party() >= 3) ? 1 : 0, l3 = (curr_party() == 3) ? 1 : 0;
60 int p4 = (curr_party() >= 4) ? 1 : 0, l4 = (curr_party() == 4) ? 1 : 0;
63 int n = curr_count() - 1;
64 int m = curr_count() / 2;
66 if ((id = gui_vstack(0)))
68 gui_label(id, title, GUI_MED, GUI_ALL, c0, c1);
71 if ((jd = gui_hstack(id)))
73 if ((kd = gui_varray(jd)))
75 if (p1) gui_label(kd, _("O"), 0, GUI_NE, 0, 0);
76 if (p1) gui_label(kd, hole_out(0), 0, 0, gui_wht, gui_wht);
77 if (p1) gui_label(kd, hole_out(1), 0, GUI_SE * l1, gui_red, gui_wht);
78 if (p2) gui_label(kd, hole_out(2), 0, GUI_SE * l2, gui_grn, gui_wht);
79 if (p3) gui_label(kd, hole_out(3), 0, GUI_SE * l3, gui_blu, gui_wht);
80 if (p4) gui_label(kd, hole_out(4), 0, GUI_SE * l4, gui_yel, gui_wht);
83 if ((kd = gui_harray(jd)))
84 for (i = m; i > 0; i--)
85 if ((ld = gui_varray(kd)))
87 if (p1) gui_label(ld, number(i), 0, (i == 1) ? GUI_NW : 0, 0, 0);
88 if (p1) gui_label(ld, hole_score(i, 0), 0, 0, gui_wht, gui_wht);
89 if (p1) gui_label(ld, hole_score(i, 1), 0, 0, gui_red, gui_wht);
90 if (p2) gui_label(ld, hole_score(i, 2), 0, 0, gui_grn, gui_wht);
91 if (p3) gui_label(ld, hole_score(i, 3), 0, 0, gui_blu, gui_wht);
92 if (p4) gui_label(ld, hole_score(i, 4), 0, 0, gui_yel, gui_wht);
94 if ((kd = gui_varray(jd)))
97 if (p1) gui_label(kd, _("Par"), 0, GUI_NW, gui_wht, gui_wht);
98 if (p1) gui_label(kd, _("P1"), 0, GUI_SW * l1, gui_red, gui_wht);
99 if (p2) gui_label(kd, _("P2"), 0, GUI_SW * l2, gui_grn, gui_wht);
100 if (p3) gui_label(kd, _("P3"), 0, GUI_SW * l3, gui_blu, gui_wht);
101 if (p4) gui_label(kd, _("P4"), 0, GUI_SW * l4, gui_yel, gui_wht);
107 if ((jd = gui_hstack(id)))
109 if ((kd = gui_varray(jd)))
111 if (p1) gui_label(kd, _("Tot"), 0, GUI_TOP, 0, 0);
112 if (p1) gui_label(kd, hole_tot(0), 0, 0, gui_wht, gui_wht);
113 if (p1) gui_label(kd, hole_tot(1), 0, GUI_BOT * l1, gui_red, gui_wht);
114 if (p2) gui_label(kd, hole_tot(2), 0, GUI_BOT * l2, gui_grn, gui_wht);
115 if (p3) gui_label(kd, hole_tot(3), 0, GUI_BOT * l3, gui_blu, gui_wht);
116 if (p4) gui_label(kd, hole_tot(4), 0, GUI_BOT * l4, gui_yel, gui_wht);
118 if ((kd = gui_varray(jd)))
120 if (p1) gui_label(kd, _("I"), 0, GUI_NE, 0, 0);
121 if (p1) gui_label(kd, hole_in(0), 0, 0, gui_wht, gui_wht);
122 if (p1) gui_label(kd, hole_in(1), 0, GUI_SE * l1, gui_red, gui_wht);
123 if (p2) gui_label(kd, hole_in(2), 0, GUI_SE * l2, gui_grn, gui_wht);
124 if (p3) gui_label(kd, hole_in(3), 0, GUI_SE * l3, gui_blu, gui_wht);
125 if (p4) gui_label(kd, hole_in(4), 0, GUI_SE * l4, gui_yel, gui_wht);
127 if ((kd = gui_harray(jd)))
128 for (i = n; i > m; i--)
129 if ((ld = gui_varray(kd)))
131 if (p1) gui_label(ld, number(i), 0, (i == m+1) ? GUI_NW : 0, 0, 0);
132 if (p1) gui_label(ld, hole_score(i, 0), 0, 0, gui_wht, gui_wht);
133 if (p1) gui_label(ld, hole_score(i, 1), 0, 0, gui_red, gui_wht);
134 if (p2) gui_label(ld, hole_score(i, 2), 0, 0, gui_grn, gui_wht);
135 if (p3) gui_label(ld, hole_score(i, 3), 0, 0, gui_blu, gui_wht);
136 if (p4) gui_label(ld, hole_score(i, 4), 0, 0, gui_yel, gui_wht);
138 if ((kd = gui_varray(jd)))
141 if (p1) gui_label(kd, _("Par"), 0, GUI_NW, gui_wht, gui_wht);
142 if (p1) gui_label(kd, _("P1"), 0, GUI_SW * l1, gui_red, gui_wht);
143 if (p2) gui_label(kd, _("P2"), 0, GUI_SW * l2, gui_grn, gui_wht);
144 if (p3) gui_label(kd, _("P3"), 0, GUI_SW * l3, gui_blu, gui_wht);
145 if (p4) gui_label(kd, _("P4"), 0, GUI_SW * l4, gui_yel, gui_wht);
149 gui_layout(id, 0, 0);
155 /*---------------------------------------------------------------------------*/
157 static int shared_stick_basic(int id, int a, float v, int bump)
161 if ((jd = gui_stick(id, a, v, bump)))
167 static void shared_stick(int id, int a, float v, int bump)
169 shared_stick_basic(id, a, v, bump);
172 /*---------------------------------------------------------------------------*/
178 static int title_action(int i)
180 audio_play(AUD_MENU, 1.0f);
184 case TITLE_PLAY: return goto_state(&st_course);
185 case TITLE_CONF: return goto_state(&st_conf);
186 case TITLE_EXIT: return 0;
191 static int title_enter(struct state *st, struct state *prev)
195 /* Build the title GUI. */
197 if ((id = gui_vstack(0)))
199 gui_label(id, "Neverputt", GUI_LRG, GUI_ALL, 0, 0);
202 if ((jd = gui_harray(id)))
206 if ((kd = gui_varray(jd)))
208 gui_start(kd, sgettext("menu^Play"), GUI_MED, TITLE_PLAY, 1);
209 gui_state(kd, sgettext("menu^Options"), GUI_MED, TITLE_CONF, 0);
210 gui_state(kd, sgettext("menu^Exit"), GUI_MED, TITLE_EXIT, 0);
215 gui_layout(id, 0, 0);
224 static void title_leave(struct state *st, struct state *next, int id)
229 static void title_paint(int id, float t)
235 static void title_timer(int id, float dt)
237 float g[3] = { 0.f, 0.f, 0.f };
240 game_set_fly(fcosf(time_state() / 10.f));
245 static void title_point(int id, int x, int y, int dx, int dy)
247 gui_pulse(gui_point(id, x, y), 1.2f);
250 static int title_click(int b, int d)
252 return d && b == SDL_BUTTON_LEFT ? title_action(gui_token(gui_click())) : 1;
255 static int title_buttn(int b, int d)
259 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
260 return title_action(gui_token(gui_click()));
261 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
262 return title_action(TITLE_EXIT);
267 /*---------------------------------------------------------------------------*/
272 #define COURSE_BACK -1
274 static int course_action(int i)
276 if (course_exists(i))
279 goto_state(&st_party);
281 if (i == COURSE_BACK)
282 goto_state(&st_title);
287 static int comp_size(int n, int s)
289 return n <= s * s ? s : comp_size(n, s + 1);
292 static int comp_cols(int n)
294 return comp_size(n, 1);
297 static int comp_rows(int n)
299 int s = comp_size(n, 1);
301 return n <= s * (s - 1) ? s - 1 : s;
304 static int course_enter(struct state *st, struct state *prev)
306 int w = config_get_d(CONFIG_WIDTH);
307 int h = config_get_d(CONFIG_HEIGHT);
309 int id, jd, kd, ld, md;
318 if ((id = gui_vstack(0)))
320 gui_label(id, _("Select Course"), GUI_MED, GUI_ALL, 0, 0);
323 if ((jd = gui_hstack(id)))
325 shot_id = gui_image(jd, course_shot(0), w / 3, h / 3);
329 if ((kd = gui_varray(jd)))
331 for(i = 0; i < r; i++)
333 if ((ld = gui_harray(kd)))
335 for (j = c - 1; j >= 0; j--)
341 md = gui_image(ld, course_shot(k),
342 w / 3 / c, h / 3 / r);
343 gui_active(md, k, 0);
357 desc_id = gui_multi(id, _(course_desc(0)), GUI_SML, GUI_ALL, gui_yel, gui_wht);
360 if ((jd = gui_hstack(id)))
363 gui_state(jd, _("Back"), GUI_SML, COURSE_BACK, 0);
366 gui_layout(id, 0, 0);
369 audio_music_fade_to(0.5f, "bgm/inter.ogg");
374 static void course_leave(struct state *st, struct state *next, int id)
379 static void course_paint(int id, float t)
385 static void course_timer(int id, float dt)
390 static void course_point(int id, int x, int y, int dx, int dy)
394 if ((jd = gui_point(id, x, y)))
396 int i = gui_token(jd);
398 if (course_exists(i))
400 gui_set_image(shot_id, course_shot(i));
401 gui_set_multi(desc_id, _(course_desc(i)));
407 static void course_stick(int id, int a, float v, int bump)
411 if ((jd = shared_stick_basic(id, a, v, bump)))
413 int i = gui_token(jd);
415 if (course_exists(i))
417 gui_set_image(shot_id, course_shot(i));
418 gui_set_multi(desc_id, _(course_desc(i)));
424 static int course_click(int b, int d)
426 return d && b == SDL_BUTTON_LEFT ? course_action(gui_token(gui_click())) : 1;
429 static int course_buttn(int b, int d)
433 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
434 return course_action(gui_token(gui_click()));
435 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
436 return course_action(COURSE_BACK);
441 /*---------------------------------------------------------------------------*/
450 static int party_action(int i)
455 audio_play(AUD_MENU, 1.f);
457 goto_state(&st_next);
460 audio_play(AUD_MENU, 1.f);
462 goto_state(&st_next);
465 audio_play(AUD_MENU, 1.f);
467 goto_state(&st_next);
470 audio_play(AUD_MENU, 1.f);
472 goto_state(&st_next);
475 audio_play(AUD_MENU, 1.f);
476 goto_state(&st_course);
482 static int party_enter(struct state *st, struct state *prev)
486 if ((id = gui_vstack(0)))
488 gui_label(id, _("Players?"), GUI_MED, GUI_ALL, 0, 0);
491 if ((jd = gui_harray(id)))
493 int p4 = gui_state(jd, "4", GUI_LRG, PARTY_4, 0);
494 int p3 = gui_state(jd, "3", GUI_LRG, PARTY_3, 0);
495 int p2 = gui_state(jd, "2", GUI_LRG, PARTY_2, 0);
496 int p1 = gui_state(jd, "1", GUI_LRG, PARTY_1, 0);
498 gui_set_color(p1, gui_red, gui_wht);
499 gui_set_color(p2, gui_grn, gui_wht);
500 gui_set_color(p3, gui_blu, gui_wht);
501 gui_set_color(p4, gui_yel, gui_wht);
508 if ((jd = gui_hstack(id)))
511 gui_state(jd, _("Back"), GUI_SML, PARTY_B, 0);
514 gui_layout(id, 0, 0);
520 static void party_leave(struct state *st, struct state *next, int id)
525 static void party_paint(int id, float t)
531 static void party_timer(int id, float dt)
536 static void party_point(int id, int x, int y, int dx, int dy)
538 gui_pulse(gui_point(id, x, y), 1.2f);
541 static int party_click(int b, int d)
543 return d && b == SDL_BUTTON_LEFT ? party_action(gui_token(gui_click())) : 1;
546 static int party_buttn(int b, int d)
550 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
551 return party_action(gui_token(gui_click()));
552 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
553 return party_action(PARTY_B);
558 /*---------------------------------------------------------------------------*/
560 static int paused = 0;
562 static struct state *st_continue;
563 static struct state *st_quit;
565 #define PAUSE_CONTINUE 1
568 int goto_pause(struct state *s, int e)
570 if (curr_state() == &st_pause)
573 if (e && !config_tst_d(CONFIG_KEY_PAUSE, SDLK_ESCAPE))
574 return goto_state(s);
576 st_continue = curr_state();
580 return goto_state(&st_pause);
583 static int pause_action(int i)
585 audio_play(AUD_MENU, 1.0f);
590 return goto_state(st_continue ? st_continue : &st_title);
593 return goto_state(st_quit);
598 static int pause_enter(struct state *st, struct state *prev)
602 audio_music_fade_out(0.2f);
604 if ((id = gui_vstack(0)))
606 td = gui_label(id, _("Paused"), GUI_LRG, GUI_ALL, 0, 0);
609 if ((jd = gui_harray(id)))
611 gui_state(jd, _("Quit"), GUI_SML, PAUSE_QUIT, 0);
612 gui_start(jd, _("Continue"), GUI_SML, PAUSE_CONTINUE, 1);
616 gui_layout(id, 0, 0);
623 static void pause_leave(struct state *st, struct state *next, int id)
627 audio_music_fade_in(0.5f);
630 static void pause_paint(int id, float t)
637 static void pause_timer(int id, float dt)
642 static void pause_point(int id, int x, int y, int dx, int dy)
644 gui_pulse(gui_point(id, x, y), 1.2f);
647 static int pause_click(int b, int d)
649 return d && b == SDL_BUTTON_LEFT ? pause_action(gui_token(gui_click())) : 1;
652 static int pause_keybd(int c, int d)
654 if (d && config_tst_d(CONFIG_KEY_PAUSE, c))
655 return pause_action(PAUSE_CONTINUE);
659 static int pause_buttn(int b, int d)
663 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
664 return pause_action(gui_token(gui_click()));
665 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
666 return pause_action(PAUSE_CONTINUE);
671 /*---------------------------------------------------------------------------*/
673 static int shared_keybd(int c, int d)
677 if (config_tst_d(CONFIG_KEY_PAUSE, c))
678 return goto_pause(&st_over, 0);
683 /*---------------------------------------------------------------------------*/
687 static int next_enter(struct state *st, struct state *prev)
692 sprintf(str, _("Hole %02d"), curr_hole());
694 if ((id = gui_vstack(0)))
696 gui_label(id, str, GUI_MED, GUI_ALL, 0, 0);
699 gui_label(id, _("Player"), GUI_SML, GUI_TOP, 0, 0);
701 switch (curr_player())
704 gui_label(id, "1", GUI_LRG, GUI_BOT, gui_red, gui_wht);
705 if (curr_party() > 1) audio_play(AUD_PLAYER1, 1.f);
708 gui_label(id, "2", GUI_LRG, GUI_BOT, gui_grn, gui_wht);
709 if (curr_party() > 1) audio_play(AUD_PLAYER2, 1.f);
712 gui_label(id, "3", GUI_LRG, GUI_BOT, gui_blu, gui_wht);
713 if (curr_party() > 1) audio_play(AUD_PLAYER3, 1.f);
716 gui_label(id, "4", GUI_LRG, GUI_BOT, gui_yel, gui_wht);
717 if (curr_party() > 1) audio_play(AUD_PLAYER4, 1.f);
720 gui_layout(id, 0, 0);
732 static void next_leave(struct state *st, struct state *next, int id)
738 static void next_paint(int id, float t)
745 static void next_timer(int id, float dt)
750 static void next_point(int id, int x, int y, int dx, int dy)
752 gui_pulse(gui_point(id, x, y), 1.2f);
755 static int next_click(int b, int d)
757 return (d && b == SDL_BUTTON_LEFT) ? goto_state(&st_flyby) : 1;
760 static int next_keybd(int c, int d)
765 return goto_state(&st_poser);
766 if (config_tst_d(CONFIG_KEY_PAUSE, c))
767 return goto_pause(&st_over, 0);
768 if ('0' <= c && c <= '9')
769 num = num * 10 + c - '0';
774 static int next_buttn(int b, int d)
778 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
780 if (num > 0 && hole_goto(num, -1))
783 return goto_state(&st_next);
785 return goto_state(&st_flyby);
787 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
788 return goto_pause(&st_over, 1);
793 /*---------------------------------------------------------------------------*/
795 static int poser_enter(struct state *st, struct state *prev)
801 static void poser_paint(int id, float t)
806 static int poser_buttn(int b, int d)
810 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
811 return goto_state(&st_next);
812 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
813 return goto_state(&st_next);
818 /*---------------------------------------------------------------------------*/
820 static int flyby_enter(struct state *st, struct state *prev)
830 static void flyby_leave(struct state *st, struct state *next, int id)
835 static void flyby_paint(int id, float t)
841 static void flyby_timer(int id, float dt)
843 float t = time_state();
845 if (dt > 0.f && t > 1.f)
846 goto_state(&st_stroke);
848 game_set_fly(1.f - t);
853 static int flyby_click(int b, int d)
855 if (d && b == SDL_BUTTON_LEFT)
858 return goto_state(&st_stroke);
863 static int flyby_buttn(int b, int d)
867 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
870 return goto_state(&st_stroke);
872 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
873 return goto_pause(&st_over, 1);
878 /*---------------------------------------------------------------------------*/
880 static int stroke_rotate = 0;
881 static int stroke_mag = 0;
883 static int stroke_enter(struct state *st, struct state *prev)
887 config_set_d(CONFIG_CAMERA, 2);
888 video_set_grab(!paused);
896 static void stroke_leave(struct state *st, struct state *next, int id)
900 config_set_d(CONFIG_CAMERA, 0);
903 static void stroke_paint(int id, float t)
909 static void stroke_timer(int id, float dt)
911 float g[3] = { 0.f, 0.f, 0.f };
915 if (SDL_GetModState() & KMOD_SHIFT ||
916 (joystick && SDL_JoystickGetButton(joystick,
917 config_get_d(CONFIG_JOYSTICK_BUTTON_B))))
922 game_set_rot(stroke_rotate * k);
923 game_set_mag(stroke_mag * k);
925 game_update_view(dt);
929 static void stroke_point(int id, int x, int y, int dx, int dy)
935 static void stroke_stick(int id, int a, float v, int bump)
937 if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
938 stroke_rotate = 6 * v;
939 else if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
943 static int stroke_click(int b, int d)
945 return (d && b == SDL_BUTTON_LEFT) ? goto_state(&st_roll) : 1;
948 static int stroke_buttn(int b, int d)
952 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
953 return goto_state(&st_roll);
954 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
955 return goto_pause(&st_over, 1);
960 /*---------------------------------------------------------------------------*/
962 static int roll_enter(struct state *st, struct state *prev)
974 static void roll_leave(struct state *st, struct state *next, int id)
979 static void roll_paint(int id, float t)
985 static void roll_timer(int id, float dt)
987 float g[3] = { 0.0f, -9.8f, 0.0f };
989 switch (game_step(g, dt))
991 case GAME_STOP: goto_state(&st_stop); break;
992 case GAME_GOAL: goto_state(&st_goal); break;
993 case GAME_FALL: goto_state(&st_fall); break;
997 static int roll_buttn(int b, int d)
1001 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
1002 return goto_pause(&st_over, 1);
1007 /*---------------------------------------------------------------------------*/
1009 static int goal_enter(struct state *st, struct state *prev)
1013 if ((id = gui_label(0, _("It's In!"), GUI_MED, GUI_ALL, gui_grn, gui_grn)))
1014 gui_layout(id, 0, 0);
1026 static void goal_leave(struct state *st, struct state *next, int id)
1032 static void goal_paint(int id, float t)
1039 static void goal_timer(int id, float dt)
1041 if (time_state() > 3)
1044 goto_state(&st_next);
1046 goto_state(&st_score);
1050 static int goal_click(int b, int d)
1052 if (b == SDL_BUTTON_LEFT && d == 1)
1055 goto_state(&st_next);
1057 goto_state(&st_score);
1062 static int goal_buttn(int b, int d)
1066 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
1069 goto_state(&st_next);
1071 goto_state(&st_score);
1073 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
1074 return goto_pause(&st_over, 1);
1079 /*---------------------------------------------------------------------------*/
1081 static int stop_enter(struct state *st, struct state *prev)
1093 static void stop_leave(struct state *st, struct state *next, int id)
1098 static void stop_paint(int id, float t)
1104 static void stop_timer(int id, float dt)
1106 float g[3] = { 0.f, 0.f, 0.f };
1108 game_update_view(dt);
1111 if (time_state() > 1)
1114 goto_state(&st_next);
1116 goto_state(&st_score);
1120 static int stop_click(int b, int d)
1122 if (b == SDL_BUTTON_LEFT && d == 1)
1125 goto_state(&st_next);
1127 goto_state(&st_score);
1132 static int stop_buttn(int b, int d)
1136 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
1139 goto_state(&st_next);
1141 goto_state(&st_score);
1143 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
1144 return goto_pause(&st_over, 1);
1149 /*---------------------------------------------------------------------------*/
1151 static int fall_enter(struct state *st, struct state *prev)
1155 if ((id = gui_label(0, _("1 Stroke Penalty"), GUI_MED, GUI_ALL, gui_blk, gui_red)))
1156 gui_layout(id, 0, 0);
1163 /* game_draw(0);*/ /*TODO: is this call ok? */ /* No, it's not. */
1171 static void fall_leave(struct state *st, struct state *next, int id)
1177 static void fall_paint(int id, float t)
1184 static void fall_timer(int id, float dt)
1186 if (time_state() > 3)
1189 goto_state(&st_next);
1191 goto_state(&st_score);
1195 static int fall_click(int b, int d)
1197 if (b == SDL_BUTTON_LEFT && d == 1)
1200 goto_state(&st_next);
1202 goto_state(&st_score);
1207 static int fall_buttn(int b, int d)
1211 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
1214 goto_state(&st_next);
1216 goto_state(&st_score);
1218 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
1219 return goto_pause(&st_over, 1);
1224 /*---------------------------------------------------------------------------*/
1226 static int score_enter(struct state *st, struct state *prev)
1228 audio_music_fade_out(2.f);
1233 return score_card(_("Scores"), gui_yel, gui_red);
1236 static void score_leave(struct state *st, struct state *next, int id)
1241 static void score_paint(int id, float t)
1247 static void score_timer(int id, float dt)
1252 static int score_click(int b, int d)
1254 if (b == SDL_BUTTON_LEFT && d == 1)
1257 return goto_state(&st_next);
1259 return goto_state(&st_title);
1264 static int score_buttn(int b, int d)
1268 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
1271 goto_state(&st_next);
1273 goto_state(&st_score);
1275 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
1276 return goto_pause(&st_over, 1);
1281 /*---------------------------------------------------------------------------*/
1283 static int over_enter(struct state *st, struct state *prev)
1285 audio_music_fade_out(2.f);
1286 return score_card(_("Final Scores"), gui_yel, gui_red);
1289 static void over_leave(struct state *st, struct state *next, int id)
1294 static void over_paint(int id, float t)
1300 static void over_timer(int id, float dt)
1305 static int over_click(int b, int d)
1307 return (d && b == SDL_BUTTON_LEFT) ? goto_state(&st_title) : 1;
1310 static int over_buttn(int b, int d)
1314 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
1315 return goto_state(&st_title);
1316 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
1317 return goto_state(&st_title);
1322 /*---------------------------------------------------------------------------*/
1324 struct state st_title = {
1337 struct state st_course = {
1350 struct state st_party = {
1363 struct state st_next = {
1376 struct state st_poser = {
1389 struct state st_flyby = {
1402 struct state st_stroke = {
1415 struct state st_roll = {
1428 struct state st_goal = {
1441 struct state st_stop = {
1454 struct state st_fall = {
1467 struct state st_score = {
1480 struct state st_over = {
1493 struct state st_pause = {