X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=ball%2Fst_done.c;h=186ddbdd586a203bff9af473bff2ca3e18b6d33f;hb=afcca7618054cd6c5e900cb32f71466c45edb0cd;hp=842e115fb63316a91ee982f88c6300c3d03daf8a;hpb=4c3716fd7ea24223a6b12bc297cf207cb17edeb1;p=neverball diff --git a/ball/st_done.c b/ball/st_done.c index 842e115..186ddbd 100644 --- a/ball/st_done.c +++ b/ball/st_done.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2003 Robert Kooima * * NEVERBALL is free software; you can redistribute it and/or modify @@ -19,77 +19,45 @@ #include "game.h" #include "util.h" #include "demo.h" -#include "level.h" +#include "levels.h" #include "audio.h" #include "config.h" +#include "st_shared.h" #include "st_done.h" #include "st_start.h" +#include "st_name.h" /*---------------------------------------------------------------------------*/ -#define DONE_OK 2 +#define DONE_OK 1 +#define DONE_NAME 2 -static int high; -static int time_i; -static int coin_i; +extern struct state st_done_bis; static int done_action(int i) { - char player[MAXNAM]; - size_t l; - audio_play(AUD_MENU, 1.0f); - config_get_s(CONFIG_PLAYER, player, MAXNAM); - l = strlen(player); - switch (i) { case DONE_OK: return goto_state(&st_start); - case GUI_CL: - gui_keyboard_lock(); - break; - - case GUI_BS: - if (l > 0) - { - player[l - 1] = 0; - - config_set_s(CONFIG_PLAYER, player); - level_name(0, player, time_i, coin_i); - set_most_coins(0, coin_i); - set_best_times(0, time_i); - } - break; - - default: - if (l < MAXNAM - 1) - { - player[l + 0] = gui_keyboard_char((char) i); - player[l + 1] = 0; - - config_set_s(CONFIG_PLAYER, player); - level_name(0, player, time_i, coin_i); - set_most_coins(0, coin_i); - set_best_times(0, time_i); - } + case DONE_NAME: + return goto_name(&st_done_bis, &st_done_bis); } return 1; } -static int done_enter(void) +static int done_init(int *gidp) { const char *s1 = _("New Challenge Record"); const char *s2 = _("Challenge Complete"); int id, jd; - time_i = 3; - coin_i = 3; - high = level_done(&time_i, &coin_i); + int high = (curr_lg()->times_rank < 3) || (curr_lg()->score_rank < 3); if ((id = gui_vstack(0))) { @@ -100,64 +68,48 @@ static int done_enter(void) else gid = gui_label(id, s2, GUI_MED, GUI_ALL, gui_blu, gui_grn); + if (gidp) + *gidp = gid; + gui_space(id); if ((jd = gui_harray(id))) { - gui_most_coins(jd, 3, 1); - gui_best_times(jd, 3, 1); + gui_most_coins(jd, 1); + gui_best_times(jd, 1); } gui_space(id); - gui_start(id, _("OK"), GUI_SML, DONE_OK, 0); - if (high) gui_keyboard(id); + if ((jd = gui_harray(id))) + { + if (high) + gui_state(jd, _("Change Player Name"), GUI_SML, DONE_NAME, 0); + gui_start(jd, _("OK"), GUI_SML, DONE_OK, 0); + } gui_layout(id, 0, 0); - gui_pulse(gid, 1.2f); } - set_most_coins(0, coin_i); - set_best_times(0, time_i); + set_best_times(&curr_set()->time_score, curr_lg()->times_rank, 0); + set_most_coins(&curr_set()->coin_score, curr_lg()->score_rank); return id; } -static void done_leave(int id) -{ - gui_delete(id); -} - -static void done_paint(int id, float st) -{ - game_draw(0, st); - gui_paint(id); -} - -static void done_timer(int id, float dt) -{ - gui_timer(id, dt); - audio_timer(dt); -} - -static void done_point(int id, int x, int y, int dx, int dy) +static int done_enter(void) { - gui_pulse(gui_point(id, x, y), 1.2f); -} + int gid, r; -static void done_stick(int id, int a, int v) -{ - if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a)) - gui_pulse(gui_stick(id, v, 0), 1.2f); - if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a)) - gui_pulse(gui_stick(id, 0, v), 1.2f); + r = done_init(&gid); + gui_pulse(gid, 1.2f); + return r; } -static int done_click(int b, int d) +static int done_bis_enter(void) { - if (b <= 0 && d == 1) - return done_action(gui_token(gui_click())); - return 1; + level_update_player_name(); + return done_init(NULL); } static int done_buttn(int b, int d) @@ -165,7 +117,7 @@ static int done_buttn(int b, int d) if (d) { if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b)) - return done_click(0, 1); + return done_action(gui_token(gui_click())); if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b)) return done_action(DONE_OK); } @@ -176,12 +128,25 @@ static int done_buttn(int b, int d) struct state st_done = { done_enter, - done_leave, - done_paint, - done_timer, - done_point, - done_stick, - done_click, + shared_leave, + shared_paint, + shared_timer, + shared_point, + shared_stick, + shared_click, + NULL, + done_buttn, + 1, 0 +}; + +struct state st_done_bis = { + done_bis_enter, + shared_leave, + shared_paint, + shared_timer, + shared_point, + shared_stick, + shared_click, NULL, done_buttn, 1, 0