component* menu_video_confirm_create(scene *s, settings_video *old_settings) { video_menu_confirm_data *local = malloc(sizeof(video_menu_confirm_data)); memset(local, 0, sizeof(video_menu_confirm_data)); local->video_accept_secs = 20; local->old_video_settings = old_settings; time(&local->video_accept_timer); // Text config text_settings tconf; text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; tconf.cforeground = color_create(0, 121, 0, 255); component* menu = menu_create(11); menu_attach(menu, label_create(&tconf, "ACCEPT RESOLUTION?")); menu_attach(menu, filler_create()); local->timeout_label = label_create(&tconf, ""); menu_attach(menu, local->timeout_label); menu_attach(menu, filler_create()); menu_attach(menu, textbutton_create(&tconf, "OK", COM_ENABLED, video_confirm_ok_clicked, local)); menu_attach(menu, textbutton_create(&tconf, "CANCEL", COM_ENABLED, video_confirm_cancel_clicked, local)); menu_set_userdata(menu, local); menu_set_free_cb(menu, menu_video_confirm_free); menu_set_tick_cb(menu, menu_video_confirm_tick); menu_video_confirm_update(menu); return menu; }
component* menu_connect_create(scene *s) { connect_menu_data *local = malloc(sizeof(connect_menu_data)); memset(local, 0, sizeof(connect_menu_data)); local->s = s; // Text config text_settings tconf; text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; tconf.cforeground = color_create(0, 121, 0, 255); component* menu = menu_create(11); menu_attach(menu, label_create(&tconf, "CONNECT TO SERVER")); menu_attach(menu, filler_create()); local->addr_input = textinput_create(&tconf, "Host/IP", settings_get()->net.net_connect_ip); local->connect_button = textbutton_create(&tconf, "CONNECT", COM_ENABLED, menu_connect_start, s); local->cancel_button = textbutton_create(&tconf, "CANCEL", COM_ENABLED, menu_connect_cancel, s); widget_set_id(local->connect_button, NETWORK_CONNECT_IP_BUTTON_ID); menu_attach(menu, local->addr_input); menu_attach(menu, local->connect_button); menu_attach(menu, local->cancel_button); menu_set_userdata(menu, local); menu_set_free_cb(menu, menu_connect_free); menu_set_tick_cb(menu, menu_connect_tick); return menu; }
component* menu_audio_create(scene *s) { // Menu userdata audio_menu_data *local = malloc(sizeof(audio_menu_data)); memset(local, 0, sizeof(audio_menu_data)); local->old_audio_settings = settings_get()->sound; // Text config text_settings tconf; text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; tconf.cforeground = color_create(0, 121, 0, 255); // Create menu and its header component* menu = menu_create(11); menu_attach(menu, label_create(&tconf, "AUDIO")); menu_attach(menu, filler_create()); menu_attach(menu, textslider_create_bind(&tconf, "SOUND", 10, 1, menu_audio_sound_slide, NULL, &settings_get()->sound.sound_vol)); menu_attach(menu, textslider_create_bind(&tconf, "MUSIC", 10, 1, menu_audio_music_slide, NULL, &settings_get()->sound.music_vol)); menu_attach(menu, textselector_create_bind_opts(&tconf, "MONO", NULL, NULL, &settings_get()->sound.music_mono, mono_opts, 2)); local->lib_selector = textselector_create(&tconf, "PLAYBACK:", menu_audio_library_toggled, local); module_source *sources = music_get_module_sources(); for(int i = 0; sources[i].name != 0; i++) { textselector_add_option(local->lib_selector, sources[i].name); if(sources[i].id == settings_get()->sound.music_library) { textselector_set_pos(local->lib_selector, i); } } menu_attach(menu, local->lib_selector); local->freq_selector = textselector_create(&tconf, "FREQUENCY:", menu_audio_freq_toggled, local); menu_audio_reset_freqs(local, 1); menu_attach(menu, local->freq_selector); local->resampler_selector = textselector_create(&tconf, "RESAMPLE:", menu_audio_resampler_toggled, local); menu_audio_reset_resamplers(local, 1); menu_attach(menu, local->resampler_selector); menu_attach(menu, textbutton_create(&tconf, "DONE", COM_ENABLED, menu_audio_done, local)); // Userdata & free function for it menu_set_userdata(menu, local); menu_set_free_cb(menu, menu_audio_free); return menu; }
component* menu_listen_create(scene *s) { listen_menu_data *local = malloc(sizeof(listen_menu_data)); s->gs->role = ROLE_SERVER; local->s = s; // Form address (host) ENetAddress address; address.host = ENET_HOST_ANY; address.port = settings_get()->net.net_listen_port; // Set up host local->host = enet_host_create(&address, 1, 2, 0, 0); if(local->host == NULL) { DEBUG("Failed to initialize ENet server"); free(local); return NULL; } enet_socket_set_option(local->host->socket, ENET_SOCKOPT_REUSEADDR, 1); // Text config text_settings tconf; text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; tconf.cforeground = color_create(0, 121, 0, 255); // Create the menu component* menu = menu_create(11); menu_attach(menu, label_create(&tconf, "START SERVER")); menu_attach(menu, filler_create()); menu_attach(menu, label_create(&tconf, "Waiting ...")); menu_attach(menu, filler_create()); local->cancel_button = textbutton_create(&tconf, "CANCEL", COM_ENABLED, menu_listen_cancel, s); menu_attach(menu, local->cancel_button); menu_set_userdata(menu, local); menu_set_free_cb(menu, menu_listen_free); menu_set_tick_cb(menu, menu_listen_tick); return menu; }
component* menu_gameplay_create(scene *s) { const char* fightmode_opts[] = {"NORMAL","HYPER"}; const char* hazard_opts[] = {"OFF","ON"}; // Text config text_settings tconf; text_defaults(&tconf); tconf.font = FONT_BIG; tconf.halign = TEXT_CENTER; tconf.cforeground = color_create(0, 121, 0, 255); component* menu = menu_create(11); menu_attach(menu, label_create(&tconf, "GAMEPLAY")); menu_attach(menu, filler_create()); menu_attach(menu, textslider_create_bind(&tconf, "SPEED", 10, 1, menu_gameplay_speed_slide, s, &settings_get()->gameplay.speed)); menu_attach(menu, textselector_create_bind_opts(&tconf, "FIGHT MODE", NULL, NULL, &settings_get()->gameplay.fight_mode, fightmode_opts, 2)); menu_attach(menu, textslider_create_bind(&tconf, "POWER 1", 8, 0, NULL, NULL, &settings_get()->gameplay.power1)); menu_attach(menu, textslider_create_bind(&tconf, "POWER 2", 8, 0, NULL, NULL, &settings_get()->gameplay.power2)); menu_attach(menu, textselector_create_bind_opts(&tconf, "HAZARDS", NULL, NULL, &settings_get()->gameplay.hazards_on, hazard_opts, 2)); menu_attach(menu, textselector_create_bind_opts(&tconf, "CPU:", NULL, NULL, &settings_get()->gameplay.difficulty, ai_difficulty_names, NUMBER_OF_AI_DIFFICULTY_TYPES)); menu_attach(menu, textselector_create_bind_opts(&tconf, "", NULL, NULL, &settings_get()->gameplay.rounds, round_type_names, NUMBER_OF_ROUND_TYPES)); menu_attach(menu, textbutton_create(&tconf, "DONE", COM_ENABLED, menu_gameplay_done, NULL)); return menu; }
int cutscene_create(scene *scene) { cutscene_local *local = malloc(sizeof(cutscene_local)); memset(local, 0, sizeof(cutscene_local)); text_defaults(&local->text_conf); local->text_conf.halign = TEXT_CENTER; local->text_conf.font = FONT_SMALL; game_player *p1 = game_state_get_player(scene->gs, 0); const char *text = ""; switch (scene->id) { case SCENE_END: music_play(PSM_END); text = lang_get(END_TEXT); local->text_x = 10; local->text_y = 5; local->text_width = 300; local->text_conf.cforeground = COLOR_YELLOW; break; case SCENE_END1: text = lang_get(END1_TEXT+p1->pilot_id); local->text_x = 10; local->text_y = 157; local->text_width = 300; local->text_conf.cforeground = COLOR_RED; // Pilot face animation *ani = &bk_get_info(&scene->bk_data, 3)->ani; object *obj = malloc(sizeof(object)); object_create(obj, scene->gs, vec2i_create(0,0), vec2f_create(0, 0)); object_set_animation(obj, ani); object_select_sprite(obj, p1->pilot_id); object_set_halt(obj, 1); game_state_add_object(scene->gs, obj, RENDER_LAYER_TOP, 0, 0); // Face effects ani = &bk_get_info(&scene->bk_data, 10+p1->pilot_id)->ani; obj = malloc(sizeof(object)); object_create(obj, scene->gs, vec2i_create(0,0), vec2f_create(0, 0)); object_set_animation(obj, ani); game_state_add_object(scene->gs, obj, RENDER_LAYER_TOP, 0, 0); break; case SCENE_END2: text = lang_get(END2_TEXT+p1->pilot_id); local->text_x = 10; local->text_y = 160; local->text_width = 300; local->text_conf.cforeground = COLOR_GREEN; break; } local->len = strlen(text)-1; local->pos = 0; local->text = malloc(strlen(text)+1); strcpy(local->text, text); local->current = local->text; char *p; if ((p = strchr(local->text, '\n'))) { // null out the byte *p = '\0'; } // Callbacks scene_set_userdata(scene, local); scene_set_free_cb(scene, cutscene_free); scene_set_input_poll_cb(scene, cutscene_input_tick); scene_set_startup_cb(scene, cutscene_startup); scene_set_render_overlay_cb(scene, cutscene_render_overlay); // Pick renderer video_select_renderer(VIDEO_RENDERER_HW); return 0; }
component* lab_dash_main_create(scene *s, dashboard_widgets *dw) { component *xy = xysizer_create(); text_settings tconf_dark; text_defaults(&tconf_dark); tconf_dark.font = FONT_SMALL; tconf_dark.cforeground = color_create(0, 200, 0, 255); text_settings tconf_light; text_defaults(&tconf_light); tconf_light.font = FONT_SMALL; tconf_light.cforeground = color_create(50, 240, 50, 255); // Pilot image dw->photo = pilotpic_create(PIC_PLAYERS, 1); xysizer_attach(xy, dw->photo, 12, -1, -1, -1); // Texts dw->name = label_create(&tconf_light, "NO NAME"); dw->rank = label_create(&tconf_dark, "RANK: 0"); dw->wins = label_create(&tconf_dark, "WINS: 0"); dw->losses = label_create(&tconf_dark, "LOSES: 0"); dw->money = label_create(&tconf_dark, "MONEY: $ 0K"); dw->tournament = label_create(&tconf_light, "NO TOURNAMENT"); xysizer_attach(xy, dw->name, 12, 58, 200, 6); xysizer_attach(xy, dw->rank, 18, 64, 200, 6); xysizer_attach(xy, dw->wins, 18, 70, 200, 6); xysizer_attach(xy, dw->losses, 12, 76, 200, 6); xysizer_attach(xy, dw->money, 12, 82, 200, 6); xysizer_attach(xy, dw->tournament, 12, 88, 200, 6); // Bars and texts (bottom left side) xysizer_attach(xy, label_create(&tconf_dark, "POWER"), 12, 95, -1, -1); dw->power = gauge_create(GAUGE_SMALL, 25, 3); xysizer_attach(xy, dw->power, 12, 102, -1, -1); xysizer_attach(xy, label_create(&tconf_dark, "AGILITY"), 12, 106, -1, -1); dw->agility = gauge_create(GAUGE_SMALL, 25, 3); xysizer_attach(xy, dw->agility, 12, 113, -1, -1); xysizer_attach(xy, label_create(&tconf_dark, "ENDURANCE"), 12, 117, -1, -1); dw->endurance = gauge_create(GAUGE_SMALL, 25, 3); xysizer_attach(xy, dw->endurance, 12, 124, -1, -1); // Bars and texts (bottom middle) xysizer_attach(xy, label_create(&tconf_dark, "ARM POWER"), 125, 95, 200, 6); dw->arm_power = gauge_create(GAUGE_BIG, 8, 3); xysizer_attach(xy, dw->arm_power, 125, 102, -1, -1); xysizer_attach(xy, label_create(&tconf_dark, "LEG POWER"), 125, 106, 200, 6); dw->leg_power = gauge_create(GAUGE_BIG, 8, 3); xysizer_attach(xy, dw->leg_power, 125, 113, -1, -1); xysizer_attach(xy, label_create(&tconf_dark, "ARMOR"), 125, 117, 200, 6); dw->armor = gauge_create(GAUGE_BIG, 8, 3); xysizer_attach(xy, dw->armor, 125, 124, -1, -1); // Bars and texts (bottom right side) xysizer_attach(xy, label_create(&tconf_dark, "ARM SPEED"), 228, 95, 200, 6); dw->arm_speed = gauge_create(GAUGE_BIG, 8, 3); xysizer_attach(xy, dw->arm_speed, 228, 102, -1, -1); xysizer_attach(xy, label_create(&tconf_dark, "LEG SPEED"), 228, 106, 200, 6); dw->leg_speed = gauge_create(GAUGE_BIG, 7, 3); xysizer_attach(xy, dw->leg_speed, 228, 113, -1, -1); xysizer_attach(xy, label_create(&tconf_dark, "STUN RES"), 228, 117, 200, 6); dw->stun_resistance = gauge_create(GAUGE_BIG, 7, 3); xysizer_attach(xy, dw->stun_resistance, 228, 124, -1, -1); return xy; }