X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=ball%2Fhud.c;h=c339d4a1b653043adc5f9ad6cdad3ac01081891c;hb=76d05f44396a09df4f90e3d22bffe75c9665619c;hp=ecb28dd813a88bc7119b51e3834814cac5b1dc01;hpb=0a4a471cbdc821a74009987c67c274ea4b48e84f;p=neverball diff --git a/ball/hud.c b/ball/hud.c index ecb28dd..c339d4a 100644 --- a/ball/hud.c +++ b/ball/hud.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2003 Robert Kooima * * NEVERBALL is free software; you can redistribute it and/or modify @@ -20,7 +20,7 @@ #include "hud.h" #include "gui.h" #include "game.h" -#include "levels.h" +#include "progress.h" #include "config.h" #include "audio.h" @@ -28,11 +28,9 @@ static int Lhud_id; static int Rhud_id; -static int Rhud2_id; static int time_id; static int coin_id; -static int coin2_id; static int ball_id; static int scor_id; static int goal_id; @@ -43,21 +41,7 @@ static float view_timer; static void hud_fps(void) { - static int fps = 0; - static int then = 0; - static int count = 0; - - int now = SDL_GetTicks(); - - if (now - then > 250) - { - fps = count * 1000 / (now - then); - then = now; - count = 0; - - gui_set_count(fps_id, fps); - } - else count++; + gui_set_count(fps_id, config_perf()); } void hud_init(void) @@ -79,13 +63,6 @@ void hud_init(void) } gui_layout(Rhud_id, +1, -1); } - - if ((Rhud2_id = gui_hstack(0))) - { - gui_label(Rhud2_id, _("Coins"), GUI_SML, 0, gui_wht, gui_wht); - coin2_id = gui_count(Rhud2_id, 100, GUI_SML, GUI_NW); - gui_layout(Rhud2_id, +1, -1); - } if ((Lhud_id = gui_hstack(0))) { @@ -126,13 +103,10 @@ void hud_free(void) void hud_paint(void) { - int mode = curr_lg()->mode; - if (mode == MODE_CHALLENGE) + if (curr_mode() == MODE_CHALLENGE) gui_paint(Lhud_id); - if (mode == MODE_PRACTICE || mode == MODE_SINGLE) - gui_paint(Rhud2_id); - else - gui_paint(Rhud_id); + + gui_paint(Rhud_id); gui_paint(time_id); if (config_get_d(CONFIG_FPS)) @@ -144,31 +118,31 @@ void hud_paint(void) void hud_update(int pulse) { - const struct level_game *lg = curr_lg(); int clock = curr_clock(); int coins = curr_coins(); int goal = curr_goal(); - int balls = lg->balls; - int score = lg->score; - int mode = lg->mode; + int balls = curr_balls(); + int score = curr_score(); + int c_id; int last; if (!pulse) { - /* reset the hud */ + /* reset the hud */ + gui_pulse(ball_id, 0.f); gui_pulse(time_id, 0.f); gui_pulse(coin_id, 0.f); } /* time and tick-tock */ - last = gui_value(time_id); - if (last != clock) + + if (clock != (last = gui_value(time_id))) { gui_set_clock(time_id, clock); - if (last > clock && pulse && mode != MODE_PRACTICE - && mode != MODE_SINGLE) + + if (last > clock && pulse) { if (clock <= 1000 && (last / 100) > (clock / 100)) { @@ -179,28 +153,35 @@ void hud_update(int pulse) { audio_play(AUD_TOCK, 1.f); gui_pulse(time_id, 1.25); - } + } } } - + /* balls and score + select coin widget */ - if (mode == MODE_CHALLENGE) + + switch (curr_mode()) { + case MODE_CHALLENGE: if (gui_value(ball_id) != balls) gui_set_count(ball_id, balls); if (gui_value(scor_id) != score) gui_set_count(scor_id, score); + c_id = coin_id; - } - else if (mode == MODE_NORMAL) + break; + + default: c_id = coin_id; - else - c_id = coin2_id; - + break; + } + + /* coins and pulse */ - last = gui_value(c_id); - if (last != coins) + + if (coins != (last = gui_value(c_id))) { last = coins - last; + gui_set_count(c_id, coins); + if (pulse && last > 0) { if (last >= 10) gui_pulse(coin_id, 2.00f); @@ -217,23 +198,23 @@ void hud_update(int pulse) } /* goal and pulse */ - last = gui_value(goal_id); - if (last != goal) + + if (goal != (last = gui_value(goal_id))) { gui_set_count(goal_id, goal); + if (pulse && goal == 0 && last > 0) gui_pulse(goal_id, 2.00f); } - /* fps */ if (config_get_d(CONFIG_FPS)) hud_fps(); } void hud_timer(float dt) { - - hud_update(1); + + hud_update(1); view_timer -= dt; @@ -246,7 +227,7 @@ void hud_timer(float dt) void hud_view_pulse(int c) { switch (c) - { + { case 0: gui_set_label(view_id, STR_VIEW0); break; case 1: gui_set_label(view_id, STR_VIEW1); break; case 2: gui_set_label(view_id, STR_VIEW2); break;