int grph_init(void) { char s[200]; int i, lang; memset(fnt, 0, sizeof(fnt[0]*NUM_FONTS)); lang = lang_get(); for(i=0; i<NUM_FONTS;i++) { sprintf(s, "%s/%s/%s/%s.%s", USBDISK_PATH, "fonts", lang_fontdir[lang], gui_fonts[i].fname, "ykf"); fnt[i] = ykf_open(s); if (fnt[i] == 0) { sprintf(s, "%s/%s/%s/%s.%s", "/usr/local", "fonts", lang_fontdir[lang], gui_fonts[i].fname, "ykf"); fnt[i] = ykf_open(s); if (fnt[i] == 0) { error("font %s/%s.%s not found\n", lang_fontdir[lang], gui_fonts[i].fname, "ykf"); } } } return 0; }
char* S(char* id) { if (!asset_hndl_isnull(&curr_lang)) { return lang_get(asset_hndl_ptr(&curr_lang), id); } else { error("Current Language hasn't been set!"); return NULL; } }
void vs_render(scene *scene) { vs_local *local = scene_get_userdata(scene); game_player *player1 = game_state_get_player(scene->gs, 0); game_player *player2 = game_state_get_player(scene->gs, 1); // player 1 HAR object_render(&local->player1_har); // player 2 HAR object_render(&local->player2_har); // player 1 portrait object_render(&local->player1_portrait); // player 2 portrait object_render(&local->player2_portrait); font_render_shadowed(&font_small, local->vs_str, 160-((strlen(local->vs_str)*font_small.w)/2), 0, COLOR_YELLOW, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); if (player2->selectable) { // arena selection video_render_sprite(&local->arena_select_bg, 55, 150, BLEND_ALPHA, 0); object_render(&local->arena_select); // arena name font_render_wrapped(&font_small, lang_get(56+local->arena), 56+72, 153, (211-72)-4, COLOR_GREEN); // arena description font_render_wrapped(&font_small, lang_get(66+local->arena), 56+72, 160, (211-72)-4, COLOR_GREEN); } else if (player2->pilot_id == 10 && settings_get()->gameplay.difficulty < 2) { // kriessack, but not on Veteran or higher font_render_wrapped(&font_small, lang_get(747), 59, 160, 200, COLOR_YELLOW); } else { font_render_wrapped(&font_small, lang_get(749+(11*player1->pilot_id)+player2->pilot_id), 59, 160, 150, COLOR_YELLOW); font_render_wrapped(&font_small, lang_get(870+(11*player2->pilot_id)+player1->pilot_id), 320-(59+150), 180, 150, COLOR_YELLOW); } }
int vs_create(scene *scene) { // Init local data vs_local *local = malloc(sizeof(vs_local)); scene_set_userdata(scene, local); game_player *player1 = game_state_get_player(scene->gs, 0); game_player *player2 = game_state_get_player(scene->gs, 1); snprintf(local->vs_str, 128, "%s VS. %s", lang_get(20+player1->pilot_id), lang_get(20+player2->pilot_id)); animation *ani; palette *mpal = video_get_base_palette(); palette_set_player_color(mpal, 0, player1->colors[2], 0); palette_set_player_color(mpal, 0, player1->colors[1], 1); palette_set_player_color(mpal, 0, player1->colors[0], 2); palette_set_player_color(mpal, 1, player2->colors[2], 0); palette_set_player_color(mpal, 1, player2->colors[1], 1); palette_set_player_color(mpal, 1, player2->colors[0], 2); video_force_pal_refresh(); // HAR ani = &bk_get_info(&scene->bk_data, 5)->ani; object_create(&local->player1_har, scene->gs, vec2i_create(160,0), vec2f_create(0, 0)); object_set_animation(&local->player1_har, ani); object_select_sprite(&local->player1_har, player1->har_id); object_create(&local->player2_har, scene->gs, vec2i_create(160,0), vec2f_create(0, 0)); object_set_animation(&local->player2_har, ani); object_select_sprite(&local->player2_har, player2->har_id); object_set_direction(&local->player2_har, OBJECT_FACE_LEFT); object_set_pal_offset(&local->player2_har, 48); // PLAYER ani = &bk_get_info(&scene->bk_data, 4)->ani; object_create(&local->player1_portrait, scene->gs, vec2i_create(-10,150), vec2f_create(0, 0)); object_set_animation(&local->player1_portrait, ani); object_select_sprite(&local->player1_portrait, player1->pilot_id); object_create(&local->player2_portrait, scene->gs, vec2i_create(330,150), vec2f_create(0, 0)); object_set_animation(&local->player2_portrait, ani); object_select_sprite(&local->player2_portrait, player2->pilot_id); object_set_direction(&local->player2_portrait, OBJECT_FACE_LEFT); // clone the left side of the background image // Note! We are touching the scene-wide background surface! surface_sub(&scene->bk_data.background, // DST Surface &scene->bk_data.background, // SRC Surface 160, 0, // DST 0, 0, // SRC 160, 200, // Size SUB_METHOD_MIRROR); // Flip the right side horizontally if (player2->selectable) { // player1 gets to choose, start at arena 0 local->arena = 0; } else { // pick a random arena for 1 player mode local->arena = rand_int(5); // srand was done in melee } // Arena if(player2->selectable) { ani = &bk_get_info(&scene->bk_data, 3)->ani; object_create(&local->arena_select, scene->gs, vec2i_create(59,155), vec2f_create(0, 0)); object_set_animation(&local->arena_select, ani); object_select_sprite(&local->arena_select, local->arena); } // SCIENTIST int scientistpos = rand_int(4); vec2i scientistcoord = spawn_position(scientistpos, 1); if (scientistpos % 2) { scientistcoord.x += 50; } else { scientistcoord.x -= 50; } object *o_scientist = malloc(sizeof(object)); ani = &bk_get_info(&scene->bk_data, 8)->ani; object_create(o_scientist, scene->gs, scientistcoord, vec2f_create(0, 0)); object_set_animation(o_scientist, ani); object_select_sprite(o_scientist, 0); object_set_direction(o_scientist, scientistpos % 2 ? OBJECT_FACE_LEFT : OBJECT_FACE_RIGHT); game_state_add_object(scene->gs, o_scientist, RENDER_LAYER_MIDDLE, 0, 0); // WELDER int welderpos = rand_int(6); // welder can't be on the same gantry or the same *side* as the scientist // he also can't be on the same 'level' // but he has 10 possible starting positions while ((welderpos % 2) == (scientistpos % 2) || (scientistpos < 2 && welderpos < 2) || (scientistpos > 1 && welderpos > 1 && welderpos < 4)) { welderpos = rand_int(6); } object *o_welder = malloc(sizeof(object)); ani = &bk_get_info(&scene->bk_data, 7)->ani; object_create(o_welder, scene->gs, spawn_position(welderpos, 0), vec2f_create(0, 0)); object_set_animation(o_welder, ani); object_select_sprite(o_welder, 0); object_set_spawn_cb(o_welder, cb_vs_spawn_object, (void*)scene); object_set_destroy_cb(o_welder, cb_vs_destroy_object, (void*)scene); object_set_direction(o_welder, welderpos % 2 ? OBJECT_FACE_LEFT : OBJECT_FACE_RIGHT); game_state_add_object(scene->gs, o_welder, RENDER_LAYER_MIDDLE, 0, 0); // GANTRIES object *o_gantry_a = malloc(sizeof(object)); ani = &bk_get_info(&scene->bk_data, 11)->ani; object_create(o_gantry_a, scene->gs, vec2i_create(0,0), vec2f_create(0, 0)); object_set_animation(o_gantry_a, ani); object_select_sprite(o_gantry_a, 0); game_state_add_object(scene->gs, o_gantry_a, RENDER_LAYER_TOP, 0, 0); object *o_gantry_b = malloc(sizeof(object)); object_create(o_gantry_b, scene->gs, vec2i_create(320,0), vec2f_create(0, 0)); object_set_animation(o_gantry_b, ani); object_select_sprite(o_gantry_b, 0); object_set_direction(o_gantry_b, OBJECT_FACE_LEFT); game_state_add_object(scene->gs, o_gantry_b, RENDER_LAYER_TOP, 0, 0); // Background tex menu_background2_create(&local->arena_select_bg, 211, 50); // Quit Dialog dialog_create(&local->quit_dialog, DIALOG_STYLE_YES_NO, "ARE YOU SURE YOU WANT TO QUIT THIS GAME?", 72, 60); local->quit_dialog.userdata = scene; local->quit_dialog.clicked = vs_quit_dialog_clicked; // Too Pathetic Dialog char insult[512]; snprintf(insult, 512, lang_get(748), "Veteran", "Major Kreissack"); dialog_create(&local->too_pathetic_dialog, DIALOG_STYLE_OK, insult, 72, 60); local->too_pathetic_dialog.userdata = scene; local->too_pathetic_dialog.clicked = vs_too_pathetic_dialog_clicked; if (player2->pilot_id == 10 && settings_get()->gameplay.difficulty < 2) { // kriessack, but not on Veteran or higher dialog_show(&local->too_pathetic_dialog, 1); } // Callbacks scene_set_render_cb(scene, vs_render); scene_set_render_overlay_cb(scene, vs_render_overlay); scene_set_input_poll_cb(scene, vs_input_tick); scene_set_dynamic_tick_cb(scene, vs_dynamic_tick); scene_set_static_tick_cb(scene, vs_static_tick); scene_set_free_cb(scene, vs_free); // Pick renderer video_select_renderer(VIDEO_RENDERER_HW); return 0; }
void newsroom_fixup_str(newsroom_local *local) { /* * Substitution table 1= Player1 - Crystal 2= Player2 - Steffan 3= HAR1 - jaguar 4= HAR2 - shadow 5= Arena - power plant 6= His/Her P1 - Her 7= Him/Her P1 - Her 8= He/She P1 - She 10= Him/Her P2 - Him 11= He/She P2 - He */ const char *text = NULL; if(local->screen == 0) { text = lang_get(NEWSROOM_TEXT+local->news_id); } else { text = lang_get(NEWSROOM_TEXT+local->news_id+1); } str textstr; size_t prevpos=0, pos = 0; str_create_from_cstr(&textstr, text); str_free(&local->news_str); while(str_next_of(&textstr, '~', &pos)) { str tmp; str_create(&tmp); str_substr(&tmp, &textstr, prevpos, pos); str_append(&local->news_str, &tmp); str_free(&tmp); // replace ~n tokens char n = str_at(&textstr, pos+1); char nn = str_at(&textstr, pos+2); switch(n) { case '1': if(nn == '0') { // ~10 str_append_c(&local->news_str, object_pronoun(local->sex2)); pos++; } else if(nn == '1') { // ~11 str_append_c(&local->news_str, subject_pronoun(local->sex2)); pos++; } else { // ~1 str_append(&local->news_str, &local->pilot1); } break; case '2': str_append(&local->news_str, &local->pilot2); break; case '3': str_append(&local->news_str, &local->har1); break; case '4': str_append(&local->news_str, &local->har2); break; case '5': str_append_c(&local->news_str, "Stadium"); break; case '6': str_append_c(&local->news_str, "The"); break; case '7': str_append_c(&local->news_str, object_pronoun(local->sex1)); break; case '8': str_append_c(&local->news_str, subject_pronoun(local->sex1)); break; case '9': str_append_c(&local->news_str, "WTF"); break; } pos+=2; prevpos = pos; } str tmp; str_create(&tmp); str_substr(&tmp, &textstr, pos, str_size(&textstr)); str_append(&local->news_str, &tmp); str_free(&tmp); str_free(&textstr); }
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; }
/** Handle message from agent socket. */ int connhipd_handle_msg(struct hip_common *msg, struct sockaddr_un *addr) { /* Variables. */ struct hip_tlv_common *param = NULL, *param2 = NULL; struct hip_common *emsg; hip_hdr_type_t type; HIT_Remote hit, *r; HIT_Local *l; socklen_t alen; struct in6_addr *lhit, *rhit; int err = 0, ret, n, direction, check; char chit[128], *type_s; struct in6_addr hitr ; type = hip_get_msg_type(msg); if (type == SO_HIP_AGENT_PING_REPLY) { HIP_DEBUG("Received ping reply from daemon. Connection to daemon established.\n"); gui_set_info(lang_get("gui-info-000")); hip_agent_connected = 1; } else if (type == SO_HIP_SET_NAT_ON) { gui_update_nat(1); HIP_DEBUG("NAT extensions on.\n"); } else if (type == SO_HIP_SET_NAT_OFF) { gui_update_nat(0); HIP_DEBUG("NAT extensions off.\n"); } else if (type == SO_HIP_DAEMON_QUIT) { HIP_DEBUG("Daemon quit. Waiting daemon to wake up again...\n"); gui_set_info(lang_get("gui-info-001")); hip_agent_connected = 0; } else if (type == SO_HIP_ADD_DB_HI) { HIP_DEBUG("Message received successfully from daemon with type" " HIP_ADD_DB_HI (%d).\n", type); n = 0; while((param = hip_get_next_param(msg, param))) { if (hip_get_param_type(param) == HIP_PARAM_HIT) { lhit = (struct in6_addr *)hip_get_param_contents_direct(param); HIP_HEXDUMP("Adding local HIT:", lhit, 16); print_hit_to_buffer(chit, lhit); hit_db_add_local(chit, lhit); n++; } } } else if (type == SO_HIP_UPDATE_HIU) { n = 0; gui_hiu_clear(); while((param = hip_get_next_param(msg, param))) { /*param2 = hip_get_next_param(msg, param); if (param2 == NULL) break;*/ if (hip_get_param_type(param) == HIP_PARAM_HIT)/* && hip_get_param_type(param2) == HIP_PARAM_HIT)*/ { rhit = (struct in6_addr *)hip_get_param_contents_direct(param); //lhit = hip_get_param_contents_direct(param2); r = hit_db_find(NULL, rhit); if (r) { gui_hiu_add(r); n++; } } } gui_hiu_count(n); } else if (type == HIP_I1 || type == HIP_R1) { NAMECPY(hit.name, ""); URLCPY(hit.url, "<notset>"); URLCPY(hit.port, ""); HIP_DEBUG("Message from daemon, %d bytes.\n", hip_get_msg_total_len(msg)); /* Get original message, which is encapsulated inside received one. */ emsg = (struct hip_common *)hip_get_param_contents(msg, HIP_PARAM_ENCAPS_MSG); HIP_IFEL(!emsg, -1, "Could not get msg parameter!\n"); HIP_HEXDUMP("msg->hits: ", &emsg->hits, 16); HIP_HEXDUMP("msg->hitr: ", &emsg->hitr, 16); /* Find out, which of the HITs in the message is local HIT. */ l = hit_db_find_local(NULL, &emsg->hits); if (!l) { l = hit_db_find_local(NULL, &emsg->hitr); if (l) { memcpy(&hit.hit, &emsg->hits, sizeof(hit.hit)); } HIP_IFEL(!l, -1, "Did not find local HIT for message!\n"); } else { memcpy(&hit.hit, &emsg->hitr, sizeof(hit.hit)); } HIP_DEBUG("Received %s %s from daemon.\n", "incoming", type == HIP_I1 ? "I1" : "R1"); /* Check the remote HIT from database. */ if (l) { memcpy(&hitr,&hit.hit, sizeof(struct in6_addr)); ret = check_hit(&hit, 0); /*Send our hits -- peer hit to daemon*/ if (ret == 1) ret = 0; /*hit already exist in the database and is accepted so no need to send it to daemon*/ else if (ret == 0) connhipd_send_hitdata_to_daemon (msg, &hitr, &hit.g->l->lhit) ; /* Reset local HIT, if outgoing I1. */ /*HIP_HEXDUMP("Old local HIT: ", &msg->hits, 16); HIP_HEXDUMP("New local HIT: ", &hit.g->l->lhit, 16); HIP_HEXDUMP("Old remote HIT: ", &msg->hitr, 16); HIP_HEXDUMP("New remote HIT: ", &hit.hit, 16);*/ } /* If neither HIT in message was local HIT, then drop the packet! */ else { HIP_DEBUG("Failed to find local HIT from database for packet." " Rejecting packet automatically.\n"); HIP_HEXDUMP("msg->hits: ", &msg->hits, 16); HIP_HEXDUMP("msg->hitr: ", &msg->hits, 16); ret = -1; } /* Now either reject or accept the packet, according to previous results. */ if (ret == 0) { HIP_DEBUG("Message accepted, sending back to daemon, %d bytes.\n", hip_get_msg_total_len(msg)); n = hip_send_recv_daemon_info((char *)msg, 1, hip_agent_sock); HIP_IFEL(n < 0, -1, "Could not send message back to daemon" " (%d: %s).\n", errno, strerror(errno)); HIP_DEBUG("Reply sent successfully.\n"); } else if (type == HIP_R1) { HIP_DEBUG("Message rejected.\n"); n = 1; HIP_IFE(hip_build_param_contents(msg, &n, HIP_PARAM_AGENT_REJECT, sizeof(n)), -1); n = hip_send_recv_daemon_info((char *)msg, 1, hip_agent_sock); HIP_IFEL(n < 0, -1, "Could not send message back to daemon" " (%d: %s).\n", errno, strerror(errno)); HIP_DEBUG("Reply sent successfully.\n"); } else { HIP_DEBUG("Message rejected.\n"); } } out_err: // HIP_DEBUG("Message handled.\n"); return (err); }
int cutscene_create(scene *scene) { cutscene_local *local = malloc(sizeof(cutscene_local)); game_player *p1 = game_state_get_player(scene->gs, 0); const char *text = ""; switch (scene->id) { case SCENE_END: cutscene_music(PSM_END); text = lang_get(END_TEXT); local->text_x = 10; local->text_y = 5; local->text_width = 300; local->color = COLOR_YELLOW; break; case SCENE_END1: text = lang_get(END1_TEXT+p1->pilot_id); local->text_x = 10; local->text_y = 160; local->text_width = 300; local->color = 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); obj->halt=1; game_state_add_object(scene->gs, obj, RENDER_LAYER_TOP); // 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); 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->color = 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_event_cb(scene, cutscene_event); 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; }
void melee_render(scene *scene) { animation *ani; int current_a = 5*row_a + column_a; int current_b = 5*row_b + column_b; if (selection == 0) { video_render_sprite_flip(&feh, 70, 0, BLEND_ALPHA, FLIP_NONE); video_render_sprite_flip(&bleh, 0, 62, BLEND_ALPHA, FLIP_NONE); // player bio font_render_wrapped(&font_small, lang_get(135+current_a), 4, 66, 152, COLOR_GREEN); // player stats font_render(&font_small, lang_get(216), 74+27, 4, COLOR_GREEN); font_render(&font_small, lang_get(217), 74+19, 22, COLOR_GREEN); font_render(&font_small, lang_get(218), 74+12, 40, COLOR_GREEN); progressbar_render(&bar_power[0]); progressbar_render(&bar_agility[0]); progressbar_render(&bar_endurance[0]); if (scene->player2.selectable) { video_render_sprite_flip(&feh, 320-70-feh.w, 0, BLEND_ALPHA, FLIP_NONE); video_render_sprite_flip(&bleh, 320-bleh.w, 62, BLEND_ALPHA, FLIP_NONE); // player bio font_render_wrapped(&font_small, lang_get(135+current_b), 320-bleh.w+4, 66, 152, COLOR_GREEN); // player stats font_render(&font_small, lang_get(216), 320-66-feh.w+27, 4, COLOR_GREEN); font_render(&font_small, lang_get(217), 320-66-feh.w+19, 22, COLOR_GREEN); font_render(&font_small, lang_get(218), 320-66-feh.w+12, 40, COLOR_GREEN); progressbar_render(&bar_power[1]); progressbar_render(&bar_agility[1]); progressbar_render(&bar_endurance[1]); } else { // 'choose your pilot' font_render_wrapped(&font_small, lang_get(187), 160, 97, 160, COLOR_GREEN); } } ani = array_get(&scene->animations, 5); if (scene->player2.selectable) { video_render_sprite_flip(array_get(&ani->sprites, 0), 254, 0, BLEND_ALPHA, FLIP_NONE); } else { video_render_sprite_flip(array_get(&ani->sprites, 1), 162, 0, BLEND_ALPHA, FLIP_NONE); } if (selection == 0) { // player 1 name font_render_wrapped(&font_small, lang_get(20+current_a), 0, 52, 66, COLOR_BLACK); if (scene->player2.selectable) { // player 2 name font_render_wrapped(&font_small, lang_get(20+current_b), 320-66, 52, 66, COLOR_BLACK); } render_highlights(scene); for(int i = 0; i < 10; i++) { ani = array_get(&scene->animations, 3); video_render_sprite_flip(array_get(&ani->sprites, i), players[i].sprite->pos_x, players[i].sprite->pos_y, BLEND_ALPHA, FLIP_NONE); if (i == current_a) { // render the big portrait ani = array_get(&scene->animations, 4); video_render_sprite_flip(array_get(&ani->sprites, i), players_big[i].sprite->pos_x, players_big[i].sprite->pos_y, BLEND_ALPHA, FLIP_NONE); } if (scene->player2.selectable && i == current_b) { // render the big portrait ani = array_get(&scene->animations, 4); video_render_sprite_flip(array_get(&ani->sprites, i), 320-(players_big[i].sprite->img->w + players_big[i].sprite->pos_x), players_big[i].sprite->pos_y, BLEND_ALPHA, FLIP_HORIZONTAL); } } } else { // render the stupid unselected HAR portraits before anything // so we can render anything else on top of them sd_sprite *sprite = scene->bk->anims[1]->animation->sprites[0]; ani = array_get(&scene->animations, 1); video_render_sprite_flip(array_get(&ani->sprites, 0), sprite->pos_x, sprite->pos_y, BLEND_ALPHA, FLIP_NONE); render_highlights(scene); // currently selected player ani = array_get(&scene->animations, 4); video_render_sprite_flip(array_get(&ani->sprites, player_id_a), players_big[player_id_a].sprite->pos_x, players_big[player_id_a].sprite->pos_y, BLEND_ALPHA, FLIP_NONE); //currently selected HAR video_render_sprite_flip(&harportraits[current_a], 11 + (62*column_a), 115 + (42*row_a), BLEND_ALPHA, FLIP_NONE); animationplayer_render(&harplayer_a); // player 1 name font_render_wrapped(&font_small, lang_get(20+player_id_a), 0, 52, 66, COLOR_BLACK); if (scene->player2.selectable) { // player 2 name font_render_wrapped(&font_small, lang_get(20+player_id_b), 320-66, 52, 66, COLOR_BLACK); // currently selected player video_render_sprite_flip(array_get(&ani->sprites, player_id_b), 320-(players_big[player_id_b].sprite->img->w + players_big[player_id_b].sprite->pos_x), players_big[player_id_b].sprite->pos_y, BLEND_ALPHA, FLIP_HORIZONTAL); // currently selected HAR video_render_sprite_flip(&harportraits[current_b], 11 + (62*column_b), 115 + (42*row_b), BLEND_ALPHA, FLIP_NONE); animationplayer_render(&harplayer_b); } else { // 'choose your HAR' font_render_wrapped(&font_small, lang_get(186), 160, 97, 160, COLOR_GREEN); } } }
void melee_render(scene *scene) { melee_local *local = scene_get_userdata(scene); game_player *player2 = game_state_get_player(scene->gs, 1); int current_a = 5*local->row_a + local->column_a; int current_b = 5*local->row_b + local->column_b; if (local->selection == 0) { video_render_sprite(&local->feh, 70, 0, BLEND_ALPHA, 0); video_render_sprite(&local->bleh, 0, 62, BLEND_ALPHA, 0); // player bio font_render_wrapped_shadowed(&font_small, lang_get(135+current_a), 4, 66, 152, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); // player stats font_render_shadowed(&font_small, lang_get(216), 74+27, 4, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); font_render_shadowed(&font_small, lang_get(217), 74+19, 22, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); font_render_shadowed(&font_small, lang_get(218), 74+12, 40, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); component_render(local->bar_power[0]); component_render(local->bar_agility[0]); component_render(local->bar_endurance[0]); if (player2->selectable) { video_render_sprite(&local->feh, 320-70-local->feh.w, 0, BLEND_ALPHA, 0); video_render_sprite(&local->bleh, 320-local->bleh.w, 62, BLEND_ALPHA, 0); // player bio font_render_wrapped_shadowed(&font_small, lang_get(135+current_b), 320-local->bleh.w+4, 66, 152, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); // player stats font_render_shadowed(&font_small, lang_get(216), 320-66-local->feh.w+27, 4, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); font_render_shadowed(&font_small, lang_get(217), 320-66-local->feh.w+19, 22, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); font_render_shadowed(&font_small, lang_get(218), 320-66-local->feh.w+12, 40, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); component_render(local->bar_power[1]); component_render(local->bar_agility[1]); component_render(local->bar_endurance[1]); } else { // 'choose your pilot' font_render_wrapped_shadowed(&font_small, lang_get(187), 160, 97, 160, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); } } object_render(&local->player2_placeholder); if (local->selection == 0) { // player 1 name font_render_wrapped_shadowed(&font_small, lang_get(20+current_a), 0, 52, 66, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); if (player2->selectable) { // player 2 name font_render_wrapped_shadowed(&font_small, lang_get(20+current_b), 320-66, 52, 66, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); } render_highlights(scene); for(int i = 0; i < 10; i++) { object_render(&local->pilots[i]); } object_render(&local->bigportrait1); if (player2->selectable) { object_render(&local->bigportrait2); } } else { // render the stupid unselected HAR portraits before anything // so we can render anything else on top of them object_render(&local->unselected_har_portraits); render_highlights(scene); // currently selected player object_render(&local->bigportrait1); //currently selected HAR object_render(&local->harportraits_player1[5*local->row_a + local->column_a]); object_render(&local->har_player1[5*local->row_a + local->column_a]); // player 1 name font_render_wrapped_shadowed(&font_small, lang_get(20+local->pilot_id_a), 0, 52, 66, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); if (player2->selectable) { // player 2 name font_render_wrapped_shadowed(&font_small, lang_get(20+local->pilot_id_b), 320-66, 52, 66, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); // currently selected player object_render(&local->bigportrait2); // currently selected HAR object_render(&local->harportraits_player2[5*local->row_b + local->column_b]); object_render(&local->har_player2[5*local->row_b + local->column_b]); // render HAR name (Har1 VS. Har2) char vstext[48]; strcpy(vstext, har_get_name(5*local->row_a + local->column_a)); strcat(vstext, " VS. "); strcat(vstext, har_get_name(5*local->row_b + local->column_b)); font_render_wrapped_shadowed(&font_small, vstext, 80, 107, 150, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); } else { // 'choose your HAR' font_render_wrapped_shadowed(&font_small, lang_get(186), 160, 97, 160, COLOR_GREEN, TEXT_SHADOW_RIGHT|TEXT_SHADOW_BOTTOM); // render HAR name font_render_wrapped_shadowed(&font_small, har_get_name(5*local->row_a + local->column_a), 130, 107, 66, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); } } if (player2->selectable) { chr_score *s1 = game_player_get_score(game_state_get_player(scene->gs, 0)); chr_score *s2 = game_player_get_score(game_state_get_player(scene->gs, 1)); char winstext[48]; snprintf(winstext, 48, "Wins: %d", s1->wins); font_render_shadowed(&font_small, winstext, 8, 107, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); snprintf(winstext, 48, "Wins: %d", s2->wins); font_render_shadowed(&font_small, winstext, 312-(strlen(winstext)*font_small.w), 107, COLOR_BLACK, TEXT_SHADOW_TOP|TEXT_SHADOW_LEFT); } }
/** Create contents of the accept dialog in here. @return 0 if success, -1 on errors. */ int nhdlg_create_content(void) { /* Variables. */ GtkWidget *window = (GtkWidget *)widget(ID_NHDLG); GtkWidget *frame, *w, *vb, *vb1, *vb2, *sw, *hb, *hp, *exp; gtk_container_set_border_width(GTK_CONTAINER(window), 1); /* Create remote HIT info. */ frame = gtk_frame_new(NULL); gtk_frame_set_label(GTK_FRAME(frame), lang_get("nhdlg-newinfo")); gtk_frame_set_label_align(GTK_FRAME(frame), 0.0, 0.0); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT); gtk_container_set_border_width(GTK_CONTAINER(frame), 5); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), frame, TRUE, TRUE, 3); gtk_widget_show(GTK_WIDGET(frame)); /* This box is for adding everything inside previous frame. */ vb = gtk_vbox_new(FALSE, 1); gtk_container_add(GTK_CONTAINER(frame), vb); gtk_widget_show(GTK_WIDGET(vb)); /* Now create basic information. */ hb = gtk_hbox_new(FALSE, 1); gtk_box_pack_start(GTK_BOX(vb), hb, FALSE, FALSE, 3); gtk_widget_show(GTK_WIDGET(hb)); w = gtk_label_new(lang_get("nhdlg-newhit")); gtk_box_pack_start(GTK_BOX(hb), w, FALSE, FALSE, 3); gtk_widget_show(GTK_WIDGET(w)); w = gtk_entry_new(); gtk_box_pack_start(GTK_BOX(hb), w, TRUE, TRUE, 3); gtk_widget_show(GTK_WIDGET(w)); widget_set(ID_NH_HIT, w); gtk_tooltips_set_tip(widget(ID_TOOLTIPS), w, lang_get("nhdlg-tt-hit"), lang_get("nhdlg-tt-hit-priv")); hb = gtk_hbox_new(FALSE, 1); gtk_box_pack_start(GTK_BOX(vb), hb, FALSE, FALSE, 3); gtk_widget_show(GTK_WIDGET(hb)); w = gtk_label_new(lang_get("nhdlg-name")); gtk_box_pack_start(GTK_BOX(hb), w, FALSE, FALSE, 3); gtk_widget_show(GTK_WIDGET(w)); w = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(w), ""); gtk_box_pack_start(GTK_BOX(hb), w, TRUE, TRUE, 3); gtk_entry_set_activates_default(GTK_ENTRY(w), TRUE); gtk_entry_set_max_length(GTK_ENTRY(w), MAX_NAME_LEN); gtk_widget_show(GTK_WIDGET(w)); widget_set(ID_NH_NAME, w); w = gtk_label_new(lang_get("nhdlg-group")); gtk_box_pack_start(GTK_BOX(hb), w, FALSE, FALSE, 3); gtk_widget_show(GTK_WIDGET(w)); w = gtk_combo_box_new_text(); g_signal_connect(w, "changed", G_CALLBACK(button_event), (gpointer)IDB_NH_RGROUPS); widget_set(ID_NH_RGROUP, w); gtk_box_pack_start(GTK_BOX(hb), w, TRUE, TRUE, 3); gtk_widget_show(GTK_WIDGET(w)); /* Separator between basic and advanced. */ w = gtk_hseparator_new(); gtk_box_pack_start(GTK_BOX(vb), w, FALSE, FALSE, 2); gtk_widget_show(GTK_WIDGET(w)); /* Advanced information. */ exp = gtk_expander_new(lang_get("nhdlg-advanced")); gtk_box_pack_start(GTK_BOX(vb), exp, FALSE, TRUE, 2); gtk_widget_show(GTK_WIDGET(exp)); widget_set(ID_NH_EXPANDER, exp); g_signal_connect(exp, "activate", G_CALLBACK(button_event), (gpointer)IDB_NH_EXPANDER); g_signal_connect(exp, "check-resize", G_CALLBACK(button_event), (gpointer)IDB_NH_EXPANDER); vb2 = gtk_vbox_new(FALSE, 2); gtk_container_add(GTK_CONTAINER(exp), vb2); gtk_widget_show(GTK_WIDGET(vb2)); hb = gtk_hbox_new(FALSE, 1); gtk_box_pack_start(GTK_BOX(vb2), hb, FALSE, FALSE, 1); gtk_widget_show(GTK_WIDGET(hb)); /* w = gtk_label_new(lang_get("nhdlg-url")); gtk_box_pack_start(GTK_BOX(hb), w, FALSE, FALSE, 5); gtk_widget_show(GTK_WIDGET(w)); w = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(w), ""); gtk_box_pack_start(GTK_BOX(hb), w, TRUE, TRUE, 5); gtk_entry_set_max_length(GTK_ENTRY(w), MAX_URL_LEN); gtk_entry_set_activates_default(GTK_ENTRY(w), TRUE); gtk_widget_show(GTK_WIDGET(w)); widget_set(ID_NH_URL, w);*/ /* w = gtk_label_new(lang_get("nhdlg-port")); gtk_box_pack_start(GTK_BOX(hb), w, FALSE, FALSE, 5); gtk_widget_show(GTK_WIDGET(w)); w = gtk_entry_new(); gtk_entry_set_text(GTK_ENTRY(w), "0"); gtk_box_pack_start(GTK_BOX(hb), w, FALSE, TRUE, 5); gtk_widget_set_size_request(GTK_WIDGET(w), 70, -1); gtk_entry_set_max_length(GTK_ENTRY(w), 8); gtk_entry_set_activates_default(GTK_ENTRY(w), TRUE); gtk_widget_show(GTK_WIDGET(w)); widget_set(ID_NH_PORT, w);*/ frame = gtk_frame_new(NULL); gtk_frame_set_label(GTK_FRAME(frame), lang_get("nhdlg-g-info")); gtk_frame_set_label_align(GTK_FRAME(frame), 0.0, 0.0); gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_ETCHED_OUT); gtk_container_set_border_width(GTK_CONTAINER(frame), 5); gtk_box_pack_start(GTK_BOX(vb2), frame, FALSE, FALSE, 1); gtk_widget_show(GTK_WIDGET(frame)); vb2 = gtk_vbox_new(FALSE, 2); gtk_container_add(GTK_CONTAINER(frame), vb2); gtk_widget_show(GTK_WIDGET(vb2)); hb = gtk_hbox_new(FALSE, 1); gtk_box_pack_start(GTK_BOX(vb2), hb, FALSE, FALSE, 1); gtk_widget_show(GTK_WIDGET(hb)); w = gtk_label_new(lang_get("nhdlg-g-localhit")); gtk_box_pack_start(GTK_BOX(hb), w, FALSE, FALSE, 5); gtk_widget_show(GTK_WIDGET(w)); w = gtk_combo_box_new_text(); gtk_box_pack_start(GTK_BOX(hb), w, TRUE, TRUE, 1); gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE); gtk_widget_show(GTK_WIDGET(w)); widget_set(ID_NH_LOCAL, w); hb = gtk_hbox_new(FALSE, 1); gtk_box_pack_start(GTK_BOX(vb2), hb, FALSE, FALSE, 1); gtk_widget_show(GTK_WIDGET(hb)); w = gtk_label_new(lang_get("nhdlg-g-type")); gtk_box_pack_start(GTK_BOX(hb), w, FALSE, FALSE, 5); gtk_widget_show(GTK_WIDGET(w)); w = gtk_combo_box_new_text(); gtk_combo_box_append_text(GTK_COMBO_BOX(w), lang_get("group-type-accept")); gtk_combo_box_append_text(GTK_COMBO_BOX(w), lang_get("group-type-deny")); gtk_combo_box_set_active(GTK_COMBO_BOX(w), 0); gtk_box_pack_start(GTK_BOX(hb), w, TRUE, TRUE, 1); gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE); gtk_widget_show(GTK_WIDGET(w)); widget_set(ID_NH_TYPE1, w); w = gtk_label_new(lang_get("nhdlg-g-lightweight")); gtk_box_pack_start(GTK_BOX(hb), w, FALSE, FALSE, 5); gtk_widget_show(GTK_WIDGET(w)); w = gtk_combo_box_new_text(); gtk_combo_box_append_text(GTK_COMBO_BOX(w), lang_get("group-type2-normal")); gtk_combo_box_append_text(GTK_COMBO_BOX(w), lang_get("group-type2-lightweight")); gtk_combo_box_set_active(GTK_COMBO_BOX(w), 0); gtk_box_pack_start(GTK_BOX(hb), w, TRUE, TRUE, 1); gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE); gtk_widget_show(GTK_WIDGET(w)); widget_set(ID_NH_TYPE2, w); return (0); }