示例#1
0
void menu_create(menu *menu, int x, int y, int w, int h) {
    vector_create(&menu->objs, sizeof(component*));
    menu->x = x;
    menu->y = y;
    menu->w = w;
    menu->h = h;
    menu_background_create(&menu->sur, w, h);
    menu->selected = 0;
}
示例#2
0
int newsroom_create(scene *scene) {
    newsroom_local *local = malloc(sizeof(newsroom_local));

    local->news_id = rand_int(24)*2;
    local->screen = 0;
    menu_background_create(&local->news_bg, 280, 50);
    str_create(&local->news_str);
    str_create(&local->pilot1);
    str_create(&local->pilot2);
    str_create(&local->har1);
    str_create(&local->har2);

    game_player *p1 = game_state_get_player(scene->gs, 0);
    game_player *p2 = game_state_get_player(scene->gs, 1);

    int health = 0;
    if (p2->sp_wins > 0) {
        // AI won, player lost
        local->won = 0;
        health = game_player_get_score(p2)->health;
    } else {
        local->won = 1;
        health = game_player_get_score(p1)->health;
    }

    DEBUG("health is %d", health);

    if (health > 40 && local->won == 1) {
        local->news_id = rand_int(6)*2;
    } else if (local->won == 1) {
        local->news_id = 12+rand_int(6)*2;
    } else if (health < 40 && local->won == 0) {
        local->news_id = 38+rand_int(5)*2;
    } else {
        local->news_id = 24+rand_int(7)*2;
    }

    // XXX TODO get the real sex of pilot
    // XXX TODO strip spaces from the end of the pilots name
    // XXX TODO set winner/loser names properly
    newsroom_set_names(local, lang_get(20+p1->pilot_id),
                              lang_get(20+p2->pilot_id),
                              har_get_name(p1->har_id),
                              har_get_name(p2->har_id),
                              pilot_sex(p1->pilot_id),
                              pilot_sex(p2->pilot_id));
    newsroom_fixup_str(local);

    // Continue Dialog
    dialog_create(&local->continue_dialog, DIALOG_STYLE_YES_NO, "DO YOU WISH TO CONTINUE?", 72, 60);
    local->continue_dialog.userdata = scene;
    local->continue_dialog.clicked = newsroom_continue_dialog_clicked;

    // Set callbacks
    scene_set_userdata(scene, local);
    scene_set_input_poll_cb(scene, newsroom_input_tick);
    scene_set_render_overlay_cb(scene, newsroom_overlay_render);
    scene_set_free_cb(scene, newsroom_free);
    scene_set_static_tick_cb(scene, newsroom_static_tick);
    scene_set_startup_cb(scene, newsroom_startup);

    // Start correct music
    music_play(PSM_MENU);

    // Pick renderer
    video_select_renderer(VIDEO_RENDERER_HW);

    return 0;
}