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.
27 /*---------------------------------------------------------------------------*/
40 static float view_timer;
42 static void hud_fps(void)
44 gui_set_count(fps_id, config_perf());
52 if ((Rhud_id = gui_hstack(0)))
54 if ((id = gui_vstack(Rhud_id)))
56 gui_label(id, _("Coins"), GUI_SML, 0, gui_wht, gui_wht);
57 gui_label(id, _("Goal"), GUI_SML, 0, gui_wht, gui_wht);
59 if ((id = gui_vstack(Rhud_id)))
61 coin_id = gui_count(id, 100, GUI_SML, GUI_NW);
62 goal_id = gui_count(id, 10, GUI_SML, 0);
64 gui_layout(Rhud_id, +1, -1);
67 if ((Lhud_id = gui_hstack(0)))
69 if ((id = gui_vstack(Lhud_id)))
71 ball_id = gui_count(id, 10, GUI_SML, GUI_NE);
72 scor_id = gui_count(id, 1000, GUI_SML, 0);
74 if ((id = gui_vstack(Lhud_id)))
76 gui_label(id, _("Balls"), GUI_SML, 0, gui_wht, gui_wht);
77 gui_label(id, _("Score"), GUI_SML, 0, gui_wht, gui_wht);
79 gui_layout(Lhud_id, -1, -1);
82 if ((time_id = gui_clock(0, 59999, GUI_MED, GUI_TOP)))
83 gui_layout(time_id, 0, -1);
85 str_view = strlen(STR_VIEW0) > strlen(STR_VIEW1) ? STR_VIEW0 : STR_VIEW1;
86 if (strlen(str_view) < strlen(STR_VIEW2))
88 if ((view_id = gui_label(0, str_view, GUI_SML, GUI_SW, gui_wht, gui_wht)))
89 gui_layout(view_id, 1, 1);
91 if ((fps_id = gui_count(0, 1000, GUI_SML, GUI_SE)))
92 gui_layout(fps_id, -1, 1);
106 if (curr_mode() == MODE_CHALLENGE)
112 if (config_get_d(CONFIG_FPS))
115 if (view_timer > 0.0f)
119 void hud_update(int pulse)
121 int clock = curr_clock();
122 int coins = curr_coins();
123 int goal = curr_goal();
124 int balls = curr_balls();
125 int score = curr_score();
134 gui_pulse(ball_id, 0.f);
135 gui_pulse(time_id, 0.f);
136 gui_pulse(coin_id, 0.f);
139 /* time and tick-tock */
141 if (clock != (last = gui_value(time_id)))
143 gui_set_clock(time_id, clock);
145 if (last > clock && pulse)
147 if (clock <= 1000 && (last / 100) > (clock / 100))
149 audio_play(AUD_TICK, 1.f);
150 gui_pulse(time_id, 1.50);
152 else if (clock < 500 && (last / 50) > (clock / 50))
154 audio_play(AUD_TOCK, 1.f);
155 gui_pulse(time_id, 1.25);
160 /* balls and score + select coin widget */
165 if (gui_value(ball_id) != balls) gui_set_count(ball_id, balls);
166 if (gui_value(scor_id) != score) gui_set_count(scor_id, score);
177 /* coins and pulse */
179 if (coins != (last = gui_value(c_id)))
183 gui_set_count(c_id, coins);
185 if (pulse && last > 0)
187 if (last >= 10) gui_pulse(coin_id, 2.00f);
188 else if (last >= 5) gui_pulse(coin_id, 1.50f);
189 else gui_pulse(coin_id, 1.25f);
193 if (last >= 10) gui_pulse(goal_id, 2.00f);
194 else if (last >= 5) gui_pulse(goal_id, 1.50f);
195 else gui_pulse(goal_id, 1.25f);
202 if (goal != (last = gui_value(goal_id)))
204 gui_set_count(goal_id, goal);
206 if (pulse && goal == 0 && last > 0)
207 gui_pulse(goal_id, 2.00f);
210 if (config_get_d(CONFIG_FPS))
214 void hud_timer(float dt)
221 gui_timer(Rhud_id, dt);
222 gui_timer(Lhud_id, dt);
223 gui_timer(time_id, dt);
224 gui_timer(view_id, dt);
227 void hud_view_pulse(int c)
231 case 0: gui_set_label(view_id, STR_VIEW0); break;
232 case 1: gui_set_label(view_id, STR_VIEW1); break;
233 case 2: gui_set_label(view_id, STR_VIEW2); break;
236 gui_pulse(view_id, 1.2f);
240 /*---------------------------------------------------------------------------*/