X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=ball%2Fst_level.c;h=80507521a4ddf525d22466ebe95497770baee33f;hb=76d05f44396a09df4f90e3d22bffe75c9665619c;hp=b9ec268b61662af6fe8de03055c1b0918d3ba772;hpb=7dcaea282184f5c7997f78453bec2633d89742fb;p=neverball diff --git a/ball/st_level.c b/ball/st_level.c index b9ec268..8050752 100644 --- a/ball/st_level.c +++ b/ball/st_level.c @@ -12,10 +12,12 @@ * General Public License for more details. */ +#include + #include "gui.h" #include "game.h" #include "set.h" -#include "levels.h" +#include "progress.h" #include "audio.h" #include "config.h" #include "st_shared.h" @@ -23,62 +25,50 @@ #include "st_level.h" #include "st_play.h" #include "st_start.h" +#include "st_over.h" /*---------------------------------------------------------------------------*/ -static int level_ok; - static int level_enter(void) { - int id, jd, kd, ld; - const char *ln; - const struct level_game *lg = curr_lg(); - int b; - const float *textcol1, *textcol2; - - /* Load the level */ - level_ok = level_play_go(); + int id, jd, kd; if ((id = gui_vstack(0))) { - if (lg->mode == MODE_SINGLE) - { - gui_label(id, _("Single Level"), GUI_LRG, GUI_TOP, 0, 0); - } - else if ((jd = gui_hstack(id))) + if ((jd = gui_hstack(id))) { - ln = lg->level->repr; - b = lg->level->is_bonus; - textcol1 = b ? gui_wht : 0; - textcol2 = b ? gui_grn : 0; - gui_filler(jd); + if ((kd = gui_vstack(jd))) { - gui_label(kd, mode_to_str(lg->mode), GUI_SML, GUI_TOP, - gui_wht, gui_wht); + const char *ln = level_name (curr_level()); + int b = level_bonus(curr_level()); + + char setattr[MAXSTR], lvlattr[MAXSTR]; + if (b) - gui_label(kd, _("*** BONUS ***"), GUI_MED, 0, gui_wht, - gui_grn); - if ((ld = gui_hstack(kd))) - { - gui_label(ld, ln, GUI_LRG, 0, textcol1, textcol2); - gui_label(ld, _("Level "), GUI_LRG, 0, textcol1, textcol2); - } - - gui_label(kd, _(curr_set()->name), GUI_SML, GUI_BOT, gui_wht, - gui_wht); + sprintf(lvlattr, _("Bonus Level %s"), ln); + else + sprintf(lvlattr, _("Level %s"), ln); + + if (curr_mode() == MODE_CHALLENGE) + sprintf(setattr, "%s: %s", set_name(curr_set()), + mode_to_str(MODE_CHALLENGE, 1)); + else + sprintf(setattr, "%s", set_name(curr_set())); + + gui_label(kd, lvlattr, b ? GUI_MED : GUI_LRG, GUI_TOP, + b ? gui_wht : 0, b ? gui_grn : 0); + gui_label(kd, setattr, GUI_SML, GUI_BOT, + gui_wht, gui_wht); } gui_filler(jd); } gui_space(id); - if (!level_ok) - gui_label(id, _("Cannot load the level file."), GUI_SML, GUI_ALL, - gui_red, gui_red); - else if (lg->level->message[0] != '\0') - gui_multi(id, _(lg->level->message), GUI_SML, GUI_ALL, gui_wht, - gui_wht); + gui_multi(id, level_msg(curr_level()), + GUI_SML, GUI_ALL, + gui_wht, gui_wht); gui_layout(id, 0, 0); } @@ -91,14 +81,11 @@ static int level_enter(void) static void level_timer(int id, float dt) { game_step_fade(dt); - audio_timer(dt); } static int level_click(int b, int d) { - if (b < 0 && d == 1) - return level_ok ? goto_state(&st_play_ready) : goto_end_level(); - return 1; + return (b < 0 && d == 1) ? goto_state(&st_play_ready) : 1; } static int level_keybd(int c, int d) @@ -114,27 +101,30 @@ static int level_buttn(int b, int d) { if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b)) { - if (level_ok) - return goto_state(&st_play_ready); - else - return goto_end_level(); + return goto_state(&st_play_ready); } if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b)) - return goto_end_level(); + { + progress_stop(); + return goto_state(&st_over); + } } return 1; } /*---------------------------------------------------------------------------*/ -static void poser_paint(int id, float st) +static void poser_paint(int id, float t) { - game_draw(1, st); + game_draw(1, t); } static int poser_buttn(int c, int d) { - return (d && config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, c)) ? goto_state(&st_level) : 1; + if (d && config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, c)) + return goto_state(&st_level); + + return 1; } /*---------------------------------------------------------------------------*/ @@ -146,6 +136,7 @@ struct state st_level = { level_timer, NULL, NULL, + NULL, level_click, level_keybd, level_buttn, @@ -161,6 +152,7 @@ struct state st_poser = { NULL, NULL, NULL, + NULL, poser_buttn, 1, 0 };