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.
26 /*---------------------------------------------------------------------------*/
39 static float view_timer;
41 static void hud_fps(void)
47 int now = SDL_GetTicks();
51 fps = count * 1000 / (now - then);
55 gui_set_count(fps_id, fps);
65 if ((Rhud_id = gui_hstack(0)))
67 if ((id = gui_vstack(Rhud_id)))
69 gui_label(id, _("Coins"), GUI_SML, 0, gui_wht, gui_wht);
70 gui_label(id, _("Goal"), GUI_SML, 0, gui_wht, gui_wht);
72 if ((id = gui_vstack(Rhud_id)))
74 coin_id = gui_count(id, 100, GUI_SML, GUI_NW);
75 goal_id = gui_count(id, 10, GUI_SML, 0);
77 gui_layout(Rhud_id, +1, -1);
80 if ((Lhud_id = gui_hstack(0)))
82 if ((id = gui_vstack(Lhud_id)))
84 ball_id = gui_count(id, 10, GUI_SML, GUI_NE);
85 scor_id = gui_count(id, 1000, GUI_SML, 0);
87 if ((id = gui_vstack(Lhud_id)))
89 gui_label(id, _("Balls"), GUI_SML, 0, gui_wht, gui_wht);
90 gui_label(id, _("Score"), GUI_SML, 0, gui_wht, gui_wht);
92 gui_layout(Lhud_id, -1, -1);
95 if ((time_id = gui_clock(0, 59999, GUI_MED, GUI_TOP)))
96 gui_layout(time_id, 0, -1);
98 str_view = strlen(STR_VIEW0) > strlen(STR_VIEW1) ? STR_VIEW0 : STR_VIEW1;
99 if (strlen(str_view) < strlen(STR_VIEW2))
100 str_view = STR_VIEW2;
101 if ((view_id = gui_label(0, str_view, GUI_SML, GUI_SW, gui_wht, gui_wht)))
102 gui_layout(view_id, 1, 1);
104 if ((fps_id = gui_count(0, 1000, GUI_SML, GUI_SE)))
105 gui_layout(fps_id, -1, 1);
119 if (level_mode() == MODE_CHALLENGE)
124 if (config_get_d(CONFIG_FPS))
127 if (view_timer > 0.0f)
131 void hud_timer(float dt)
133 const int clock = curr_clock();
134 const int balls = curr_balls();
135 const int coins = curr_coins();
136 const int score = curr_score();
137 const int goal = curr_goal();
139 if (gui_value(time_id) != clock) gui_set_clock(time_id, clock);
140 if (level_mode() == MODE_CHALLENGE)
142 if (gui_value(ball_id) != balls) gui_set_count(ball_id, balls);
143 if (gui_value(scor_id) != score) gui_set_count(scor_id, score);
145 if (gui_value(coin_id) != coins) gui_set_count(coin_id, coins);
146 if (gui_value(goal_id) != goal) gui_set_count(goal_id, goal);
148 if (config_get_d(CONFIG_FPS))
153 gui_timer(Rhud_id, dt);
154 gui_timer(Lhud_id, dt);
155 gui_timer(time_id, dt);
156 gui_timer(view_id, dt);
159 void hud_ball_pulse(float k) { gui_pulse(ball_id, k); }
160 void hud_time_pulse(float k) { gui_pulse(time_id, k); }
161 void hud_coin_pulse(float k) { gui_pulse(coin_id, k); }
162 void hud_goal_pulse(float k) { gui_pulse(goal_id, k); }
164 void hud_view_pulse(int c)
168 case 0: gui_set_label(view_id, STR_VIEW0); break;
169 case 1: gui_set_label(view_id, STR_VIEW1); break;
170 case 2: gui_set_label(view_id, STR_VIEW2); break;
173 gui_pulse(view_id, 1.2f);
177 /*---------------------------------------------------------------------------*/