Example #1
0
static int lang_gui(void)
{
    const int step = (first == 0 ? LANG_STEP - 1 : LANG_STEP);

    int id, jd;
    int i;

    if ((id = gui_vstack(0)))
    {
        if ((jd = gui_hstack(id)))
        {
            gui_label(jd, _("Language"), GUI_SML, 0, 0);
            gui_space(jd);
            gui_space(jd);
            gui_navig(jd, array_len(langs), first, LANG_STEP);
        }

        gui_space(id);

        if (step < LANG_STEP)
        {
            int default_id;
            default_id = gui_state(id, _("Default"), GUI_SML, LANG_DEFAULT, 0);
            gui_set_hilite(default_id, !*config_get_s(CONFIG_LANGUAGE));
        }

        for (i = first; i < first + step; i++)
        {
            if (i < array_len(langs))
            {
                struct lang_desc *desc = LANG_GET(langs, i);

                int lang_id;

                lang_id = gui_state(id, lang_name(desc),
                                    GUI_SML, LANG_SELECT, i);

                gui_set_hilite(lang_id, (strcmp(config_get_s(CONFIG_LANGUAGE),
                                                desc->code) == 0));
            }
            else
            {
                gui_label(id, " ", GUI_SML, 0, 0);
            }
        }

        gui_layout(id, 0, 0);
    }

    return id;
}
Example #2
0
static int conf_gui(void)
{
    int id;

    /* Initialize the configuration GUI. */

    if ((id = gui_vstack(0)))
    {
        int sound = config_get_d(CONFIG_SOUND_VOLUME);
        int music = config_get_d(CONFIG_MUSIC_VOLUME);
        int mouse = MOUSE_RANGE_MAP(config_get_d(CONFIG_MOUSE_SENSE));

        const char *player = config_get_s(CONFIG_PLAYER);
        const char *ball   = config_get_s(CONFIG_BALL_FILE);

        int name_id = 0, ball_id = 0;

        conf_header(id, _("Options"), GUI_BACK);

        conf_state(id, _("Graphics"), _("Configure"), CONF_VIDEO);

        gui_space(id);

        conf_slider(id, _("Mouse Sensitivity"), CONF_MOUSE_SENSE, mouse,
                    mouse_id, ARRAYSIZE(mouse_id));

        gui_space(id);

        conf_slider(id, _("Sound Volume"), CONF_SOUND_VOLUME, sound,
                    sound_id, ARRAYSIZE(sound_id));
        conf_slider(id, _("Music Volume"), CONF_MUSIC_VOLUME, music,
                    music_id, ARRAYSIZE(music_id));

        gui_space(id);

        name_id = conf_state(id, _("Player Name"), " ", CONF_PLAYER);
        ball_id = conf_state(id, _("Ball Model"), " ", CONF_BALL);

        gui_layout(id, 0, 0);

        gui_set_trunc(name_id, TRUNC_TAIL);
        gui_set_trunc(ball_id, TRUNC_TAIL);

        gui_set_label(name_id, player);
        gui_set_label(ball_id, base_name(ball));
    }

    return id;
}
Example #3
0
void progress_rename(int set_only)
{
    const char *player = config_get_s(CONFIG_PLAYER);

    if (curr_mode() == MODE_STANDALONE)
    {
        /* HACK Avoid touching the set. */

        level_rename_player(level, time_rank, goal_rank, coin_rank, player);
        demo_rename_player(USER_REPLAY_FILE, player);

        return;
    }

    if (set_only)
    {
        set_rename_player(score_rank, times_rank, player);
    }
    else
    {
        level_rename_player(level, time_rank, goal_rank, coin_rank, player);
        demo_rename_player(USER_REPLAY_FILE, player);

        if (progress_done())
            set_rename_player(score_rank, times_rank, player);
    }

    set_store_hs();
}
Example #4
0
static int tilt_func(void *data)
{
    wiimote_t   wiimote = WIIMOTE_INIT;
    const char *address = config_get_s(CONFIG_WIIMOTE_ADDR);

    if (strlen(address) > 0)
    {
        if (wiimote_connect(&wiimote, address) < 0)
            log_printf("Wiimote error (%s)\n", wiimote_get_error());
        else
        {
            int running = 1;

            wiimote.mode.bits = WIIMOTE_MODE_ACC;
            wiimote.led.one   = 1;

            SDL_mutexP(mutex);
            state.status = running;
            SDL_mutexV(mutex);

            while (mutex && running && wiimote_is_open(&wiimote))
            {
                if (wiimote_update(&wiimote) < 0)
                    break;

                SDL_mutexP(mutex);
                {
                    running = state.status;

                    set_button(&state.A,     wiimote.keys.a);
                    set_button(&state.B,     wiimote.keys.b);
                    set_button(&state.plus,  wiimote.keys.plus);
                    set_button(&state.minus, wiimote.keys.minus);
                    set_button(&state.home,  wiimote.keys.home);
                    set_button(&state.L,     wiimote.keys.left);
                    set_button(&state.R,     wiimote.keys.right);
                    set_button(&state.U,     wiimote.keys.up);
                    set_button(&state.D,     wiimote.keys.down);

                    if (isnormal(wiimote.tilt.y))
                    {
                        state.x = (state.x * (FILTER - 1) +
                                   wiimote.tilt.y) / FILTER;
                    }
                    if (isnormal(wiimote.tilt.x))
                    {
                        state.z = (state.z * (FILTER - 1) +
                                   wiimote.tilt.x) / FILTER;
                    }
                }
                SDL_mutexV(mutex);
            }

            wiimote_disconnect(&wiimote);
        }
    }
    return 0;
}
Example #5
0
int goto_name(struct state *ok, struct state *cancel, unsigned int back)
{
    SAFECPY(player, config_get_s(CONFIG_PLAYER));

    ok_state     = ok;
    cancel_state = cancel;
    draw_back    = back;

    return goto_state(&st_name);
}
Example #6
0
static int name_enter(struct state *st, struct state *prev)
{
    if (draw_back)
    {
        game_client_free(NULL);
        back_init("back/gui.png");
    }

    text_input_start(on_text_input);
    text_input_str(config_get_s(CONFIG_PLAYER), 0);

    return name_gui();
}
Example #7
0
static int save_enter(struct state *st, struct state *prev)
{
    const char *name;

    name = demo_format_name(config_get_s(CONFIG_REPLAY_NAME),
                            set_id(curr_set()),
                            level_name(curr_level()));

    text_input_start(on_text_input);
    text_input_str(name);

    return save_gui();
}
Example #8
0
int set_score_update(int timer, int coins, int *score_rank, int *times_rank)
{
    struct set *s = SET_GET(sets, curr);
    const char *player = config_get_s(CONFIG_PLAYER);

    score_coin_insert(&s->coin_score, score_rank, player, timer, coins);
    score_time_insert(&s->time_score, times_rank, player, timer, coins);

    if ((score_rank && *score_rank < RANK_LAST) ||
        (times_rank && *times_rank < RANK_LAST))
        return 1;
    else
        return 0;
}
Example #9
0
static int title_action(int tok, int val)
{
    static const char keyphrase[] = "xyzzy";
    static char queue[sizeof (keyphrase)] = "";

    size_t queue_len = strlen(queue);

    audio_play(AUD_MENU, 1.0f);

    switch (tok)
    {
    case GUI_BACK:
        return 0;
        break;

    case TITLE_PLAY:
        if (strlen(config_get_s(CONFIG_PLAYER)) == 0)
            return goto_name(&st_set, &st_title, 0);
        else
            return goto_state(&st_set);
        break;

    case TITLE_HELP: return goto_state(&st_help); break;
    case TITLE_DEMO: return goto_state(&st_demo); break;
    case TITLE_CONF: return goto_state(&st_conf); break;
    case GUI_CHAR:

        /* Let the queue fill up. */

        if (queue_len < sizeof (queue) - 1)
        {
            queue[queue_len]     = (char) val;
            queue[queue_len + 1] = '\0';
        }

        /* Advance the queue before adding the new element. */

        else
        {
            int k;

            for (k = 1; k < queue_len; k++)
                queue[k - 1] = queue[k];

            queue[queue_len - 1] = (char) val;
        }

        if (strcmp(queue, keyphrase) == 0)
        {
            config_set_cheat();
            gui_set_label(play_id, sgettext("menu^Cheat"));
            gui_pulse(play_id, 1.2f);
        }
        else if (config_cheat())
        {
            config_clr_cheat();
            gui_set_label(play_id, sgettext("menu^Play"));
            gui_pulse(play_id, 1.2f);
        }

        break;
    }
    return 1;
}