X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=ball%2Fst_level.c;h=80507521a4ddf525d22466ebe95497770baee33f;hb=76d05f44396a09df4f90e3d22bffe75c9665619c;hp=d2d56d5070db8caae3156c257af291c131b2314a;hpb=9fc76ac43e87022c39cd1e062f64123c780097f6;p=neverball diff --git a/ball/st_level.c b/ball/st_level.c index d2d56d5..8050752 100644 --- a/ball/st_level.c +++ b/ball/st_level.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2003 Robert Kooima * * NEVERBALL is free software; you can redistribute it and/or modify @@ -12,57 +12,63 @@ * General Public License for more details. */ +#include + #include "gui.h" #include "game.h" #include "set.h" -#include "level.h" +#include "progress.h" #include "audio.h" #include "config.h" +#include "st_shared.h" #include "st_level.h" #include "st_play.h" +#include "st_start.h" #include "st_over.h" /*---------------------------------------------------------------------------*/ static int level_enter(void) { - int id, jd, kd, ld; - const char * ln; - - /* Load the level */ - level_play_go(); - - ln = _(level_number_name(curr_level())); - + int id, jd, kd; + if ((id = gui_vstack(0))) { if ((jd = gui_hstack(id))) { gui_filler(jd); - if ((kd = gui_vstack(jd))) - { - if (level_extra_bonus(curr_level())) - gui_label(kd, _("*** BONUS ***"), GUI_MED, GUI_TOP, gui_wht, gui_grn); - if ((ld = gui_hstack(kd))) - { - if (level_extra_bonus(curr_level())) - { - gui_label(ld, ln, GUI_LRG, 0, gui_wht, gui_grn); - gui_label(ld, _("Level "), GUI_LRG, 0, gui_wht, gui_grn); - } - else - { - gui_label(ld, ln, GUI_LRG, GUI_NE, 0, 0); - gui_label(ld, _("Level "), GUI_LRG, GUI_NW, 0, 0); - } - } - gui_label(kd, _(set_name(set_curr())), GUI_SML, GUI_BOT, gui_wht, gui_wht); - } + + if ((kd = gui_vstack(jd))) + { + const char *ln = level_name (curr_level()); + int b = level_bonus(curr_level()); + + char setattr[MAXSTR], lvlattr[MAXSTR]; + + if (b) + 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); - gui_multi(id, _(curr_intro()), 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); } @@ -72,21 +78,9 @@ static int level_enter(void) return id; } -static void level_leave(int id) -{ - gui_delete(id); -} - static void level_timer(int id, float dt) { game_step_fade(dt); - audio_timer(dt); -} - -static void level_paint(int id, float st) -{ - game_draw(0, st); - gui_paint(id); } static int level_click(int b, int d) @@ -96,10 +90,8 @@ static int level_click(int b, int d) static int level_keybd(int c, int d) { - if (d && c == SDLK_ESCAPE) - goto_state(&st_over); if (d && c == SDLK_F12) - goto_state(&st_poser); + return goto_state(&st_poser); return 1; } @@ -108,34 +100,43 @@ static int level_buttn(int b, int d) if (d) { if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b)) + { return goto_state(&st_play_ready); + } if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b)) + { + 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_keybd(int c, int d) +static int poser_buttn(int c, int d) { - return (d && c == SDLK_ESCAPE) ? goto_state(&st_level) : 1; + if (d && config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, c)) + return goto_state(&st_level); + + return 1; } /*---------------------------------------------------------------------------*/ struct state st_level = { level_enter, - level_leave, - level_paint, + shared_leave, + shared_paint, level_timer, NULL, NULL, + NULL, level_click, level_keybd, level_buttn, @@ -150,7 +151,8 @@ struct state st_poser = { NULL, NULL, NULL, - poser_keybd, NULL, + NULL, + poser_buttn, 1, 0 };