void kmatrix_draw_names(int *sorted) { int j, x, color; if(Netgame.FairColors) selected_player_rgb = player_rgb_all_blue; else if(Netgame.BlackAndWhitePyros) selected_player_rgb = player_rgb_alt; else selected_player_rgb = player_rgb; for (j=0; j<N_players; j++) { if (Game_mode & GM_TEAM) color = get_team(sorted[j]); else color = sorted[j]; x = FSPACX (70 + CENTERING_OFFSET(N_players) + j*25); if (Players[sorted[j]].connected==CONNECT_DISCONNECTED) gr_set_fontcolor(gr_find_closest_color(31,31,31),-1); else gr_set_fontcolor(BM_XRGB(selected_player_rgb[color].r,selected_player_rgb[color].g,selected_player_rgb[color].b),-1 ); gr_printf( x, FSPACY(40), "%c", Players[sorted[j]].callsign[0] ); } x = FSPACX(72 + CENTERING_OFFSET(N_players) + N_players*25); gr_set_fontcolor( BM_XRGB(31,31,31),-1 ); gr_string( x, FSPACY(40), "K/E"); }
void show_framerate() { static int fps_count = 0, fps_rate = 0; int y = GHEIGHT; static fix64 fps_time = 0; gr_set_curfont(GAME_FONT); gr_set_fontcolor(BM_XRGB(0,31,0),-1); if (PlayerCfg.CockpitMode[1] == CM_FULL_SCREEN) { if ((Game_mode & GM_MULTI) || (Newdemo_state == ND_STATE_PLAYBACK && Newdemo_game_mode & GM_MULTI)) y -= LINE_SPACING * 10; else y -= LINE_SPACING * 4; } else if (PlayerCfg.CockpitMode[1] == CM_STATUS_BAR) { if ((Game_mode & GM_MULTI) || (Newdemo_state == ND_STATE_PLAYBACK && Newdemo_game_mode & GM_MULTI)) y -= LINE_SPACING * 6; else y -= LINE_SPACING * 1; } else { if ((Game_mode & GM_MULTI) || (Newdemo_state == ND_STATE_PLAYBACK && Newdemo_game_mode & GM_MULTI)) y -= LINE_SPACING * 7; else y -= LINE_SPACING * 2; } fps_count++; if (timer_query() >= fps_time + F1_0) { fps_rate = fps_count; fps_count = 0; fps_time = timer_query(); } gr_printf(SWIDTH-(GameArg.SysMaxFPS>999?FSPACX(43):FSPACX(37)),y,"FPS: %i",fps_rate); }
static void con_draw(void) { int i = 0, y = 0, done = 0; if (con_size <= 0) return; gr_set_current_canvas(NULL); gr_set_curfont(GAME_FONT); gr_setcolor(BM_XRGB(0,0,0)); gr_settransblend(7, GR_BLEND_NORMAL); gr_rect(0,0,SWIDTH,(LINE_SPACING*(con_size))+FSPACY(1)); gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL); y=FSPACY(1)+(LINE_SPACING*con_size); i+=con_scroll_offset; { cxx_con_interactive_print(&y); if (y<=0) done=1; } while (!done) { int w,h,aw; switch (con_buffer[CON_LINES_MAX-1-i].priority) { case CON_CRITICAL: gr_set_fontcolor(BM_XRGB(28,0,0),-1); break; case CON_URGENT: gr_set_fontcolor(BM_XRGB(54,54,0),-1); break; case CON_DEBUG: case CON_VERBOSE: gr_set_fontcolor(BM_XRGB(14,14,14),-1); break; case CON_HUD: gr_set_fontcolor(BM_XRGB(0,28,0),-1); break; default: gr_set_fontcolor(BM_XRGB(255,255,255),-1); break; } gr_get_string_size(con_buffer[CON_LINES_MAX-1-i].line,&w,&h,&aw); y-=h+FSPACY(1); gr_string(FSPACX(1),y,con_buffer[CON_LINES_MAX-1-i].line); i++; if (y<=0 || CON_LINES_MAX-1-i <= 0 || i < 0) done=1; } gr_setcolor(BM_XRGB(0,0,0)); gr_rect(0,0,SWIDTH,LINE_SPACING); gr_set_fontcolor(BM_XRGB(255,255,255),-1); gr_printf(FSPACX(1),FSPACY(1),"%s LOG", DESCENT_VERSION); gr_string(SWIDTH-FSPACX(110),FSPACY(1),"PAGE-UP/DOWN TO SCROLL"); }
void kmatrix_draw_coop_item( int i, int *sorted ) { int x, y; y = FSPACY(50+i*9); gr_printf( FSPACX(CENTERING_OFFSET(N_players)), y, "%s", Players[sorted[i]].callsign ); x = CENTERSCREEN; gr_set_fontcolor( BM_XRGB(60,40,10),-1 ); gr_printf( x, y, "%d", Players[sorted[i]].score ); x = CENTERSCREEN+FSPACX(50); gr_set_fontcolor( BM_XRGB(60,40,10),-1 ); gr_printf( x, y, "%d", Players[sorted[i]].net_killed_total); }
void kmatrix_draw_item( int i, int *sorted ) { int j, x, y; char temp[10]; y = FSPACY(50+i*9); gr_printf( FSPACX(CENTERING_OFFSET(N_players)), y, "%s", Players[sorted[i]].callsign ); for (j=0; j<N_players; j++) { x = FSPACX(70 + CENTERING_OFFSET(N_players) + j*25); if (sorted[i]==sorted[j]) { if (kill_matrix[sorted[i]][sorted[j]] == 0) { gr_set_fontcolor( BM_XRGB(10,10,10),-1 ); gr_printf( x, y, "%d", kill_matrix[sorted[i]][sorted[j]] ); } else { gr_set_fontcolor( BM_XRGB(25,25,25),-1 ); gr_printf( x, y, "-%d", kill_matrix[sorted[i]][sorted[j]] ); } } else { if (kill_matrix[sorted[i]][sorted[j]] <= 0) { gr_set_fontcolor( BM_XRGB(10,10,10),-1 ); gr_printf( x, y, "%d", kill_matrix[sorted[i]][sorted[j]] ); } else { gr_set_fontcolor( BM_XRGB(25,25,25),-1 ); gr_printf( x, y, "%d", kill_matrix[sorted[i]][sorted[j]] ); } } } if (Players[sorted[i]].net_killed_total+Players[sorted[i]].net_kills_total==0) sprintf (temp,"NA"); else sprintf (temp,"%d%%",(int)((float)((float)Players[sorted[i]].net_kills_total/((float)Players[sorted[i]].net_killed_total+(float)Players[sorted[i]].net_kills_total))*100.0)); x = FSPACX(60 + CENTERING_OFFSET(N_players) + N_players*25); gr_set_fontcolor( BM_XRGB(25,25,25),-1 ); gr_printf( x ,y,"%4d/%s",Players[sorted[i]].net_kills_total,temp); }
void scores_draw_item( int i, stats_info * stats ) { char buffer[20]; int y; y = 77+i*9; if (i==0) y -= 8; if ( i==MAX_HIGH_SCORES ) y += 8; else scores_rprintf( 57, y-3, "%d.", i+1 ); y -= 3; if (strlen(stats->name)==0) { gr_printf( FSPACX(66), FSPACY(y), TXT_EMPTY ); return; } gr_printf( FSPACX(66), FSPACY(y), "%s", stats->name ); int_to_string(stats->score, buffer); scores_rprintf( 149, y, "%s", buffer ); gr_printf( FSPACX(166), FSPACY(y), "%s", MENU_DIFFICULTY_TEXT(stats->diff_level) ); if ( (stats->starting_level > 0 ) && (stats->ending_level > 0 )) scores_rprintf( 232, y, "%d-%d", stats->starting_level, stats->ending_level ); else if ( (stats->starting_level < 0 ) && (stats->ending_level > 0 )) scores_rprintf( 232, y, "S%d-%d", -stats->starting_level, stats->ending_level ); else if ( (stats->starting_level < 0 ) && (stats->ending_level < 0 )) scores_rprintf( 232, y, "S%d-S%d", -stats->starting_level, -stats->ending_level ); else if ( (stats->starting_level > 0 ) && (stats->ending_level < 0 )) scores_rprintf( 232, y, "%d-S%d", stats->starting_level, -stats->ending_level ); { int h, m, s; h = stats->seconds/3600; s = stats->seconds%3600; m = s / 60; s = s % 60; scores_rprintf( 276, y, "%d:%02d:%02d", h, m, s ); } }
void kmatrix_draw_coop_names(int *sorted) { sorted=sorted; gr_set_fontcolor( BM_XRGB(63,31,31),-1 ); gr_string( CENTERSCREEN, FSPACY(40), "SCORE"); gr_set_fontcolor( BM_XRGB(63,31,31),-1 ); gr_string( CENTERSCREEN+FSPACX(50), FSPACY(40), "DEATHS"); }
static void con_draw(void) { int i = 0, y = 0; if (con_size <= 0) return; gr_set_default_canvas(); auto &canvas = *grd_curcanv; auto &game_font = *GAME_FONT; gr_set_curfont(canvas, GAME_FONT); const uint8_t color = BM_XRGB(0, 0, 0); gr_settransblend(canvas, 7, GR_BLEND_NORMAL); const auto &&fspacy1 = FSPACY(1); const auto &&line_spacing = LINE_SPACING(*canvas.cv_font, *GAME_FONT); y = fspacy1 + (line_spacing * con_size); gr_rect(canvas, 0, 0, SWIDTH, y, color); gr_settransblend(canvas, GR_FADE_OFF, GR_BLEND_NORMAL); i+=con_scroll_offset; gr_set_fontcolor(canvas, BM_XRGB(255, 255, 255), -1); y = cli_draw(y, line_spacing); const auto &&fspacx = FSPACX(); const auto &&fspacx1 = fspacx(1); for (;;) { auto &b = con_buffer[CON_LINES_MAX - 1 - i]; gr_set_fontcolor(canvas, get_console_color_by_priority(b.priority), -1); int w,h; gr_get_string_size(game_font, b.line, &w, &h, nullptr); y -= h + fspacy1; gr_string(canvas, game_font, fspacx1, y, b.line, w, h); i++; if (y<=0 || CON_LINES_MAX-1-i <= 0 || i < 0) break; } gr_rect(canvas, 0, 0, SWIDTH, line_spacing, color); gr_set_fontcolor(canvas, BM_XRGB(255, 255, 255),-1); gr_printf(canvas, game_font, fspacx1, fspacy1, "%s LOG", DESCENT_VERSION); gr_string(canvas, game_font, SWIDTH - fspacx(110), fspacy1, "PAGE-UP/DOWN TO SCROLL"); }
void scores_rprintf(int x, int y, char * format, ... ) { va_list args; char buffer[128]; int w, h, aw; char *p; va_start(args, format ); vsprintf(buffer,format,args); va_end(args); //replace the digit '1' with special wider 1 for (p=buffer;*p;p++) if (*p=='1') *p=132; gr_get_string_size(buffer, &w, &h, &aw ); gr_string( FSPACX(x)-w, FSPACY(y), buffer ); }
void scores_view(stats_info *last_game, int citem) { scores_menu *menu; MALLOC(menu, scores_menu, 1); if (!menu) return; menu->citem = citem; menu->t1 = timer_query(); menu->looper = 0; if (last_game) menu->last_game = *last_game; newmenu_free_background(); scores_read(&menu->scores); set_screen_mode(SCREEN_MENU); show_menus(); window_create(&grd_curscreen->sc_canvas, (SWIDTH - FSPACX(320))/2, (SHEIGHT - FSPACY(200))/2, FSPACX(320), FSPACY(200), (int (*)(window *, d_event *, void *))scores_handler, menu); }
void game_draw_hud_stuff() { #ifdef CROSSHAIR if ( Viewer->type == OBJ_PLAYER ) laser_do_crosshair(Viewer); #endif #ifndef NDEBUG draw_window_label(); #endif #ifdef NETWORK game_draw_multi_message(); #endif if ((Newdemo_state == ND_STATE_PLAYBACK) || (Newdemo_state == ND_STATE_RECORDING)) { char message[128]; int y; if (Newdemo_state == ND_STATE_PLAYBACK) { if (Newdemo_show_percentage) { sprintf(message, "%s (%d%%%% %s)", TXT_DEMO_PLAYBACK, newdemo_get_percent_done(), TXT_DONE); } else { sprintf (message, " "); } } else { extern int Newdemo_num_written; sprintf (message, "%s (%dK)", TXT_DEMO_RECORDING, (Newdemo_num_written / 1024)); } gr_set_curfont( GAME_FONT ); gr_set_fontcolor( BM_XRGB(27,0,0), -1 ); y = GHEIGHT-(LINE_SPACING*2); if (PlayerCfg.CockpitMode[1] == CM_FULL_COCKPIT) y = grd_curcanv->cv_bitmap.bm_h / 1.2 ; if (PlayerCfg.CockpitMode[1] != CM_REAR_VIEW) gr_printf(0x8000, y, message ); } render_countdown_gauge(); render_spec_status(); // jinx 02-01-13 spec // this should be made part of hud code some day if (( Player_num > -1 && Viewer->type==OBJ_PLAYER && Viewer->id==Player_num && PlayerCfg.CockpitMode[1] != CM_REAR_VIEW) || ((Players[Player_num].spec_flags & PLAYER_FLAGS_SPECTATING) && in_free)) { int x = FSPACX(1); int y = grd_curcanv->cv_bitmap.bm_h; gr_set_curfont( GAME_FONT ); gr_set_fontcolor( BM_XRGB(0, 31, 0), -1 ); if ((Cruise_speed > 0) || ((Players[Player_num].spec_flags & PLAYER_FLAGS_SPECTATING) && in_free)) { if (PlayerCfg.CockpitMode[1]==CM_FULL_SCREEN) { if (Game_mode & GM_MULTI) y -= LINE_SPACING * 10; else y -= LINE_SPACING * 6; } else if (PlayerCfg.CockpitMode[1] == CM_STATUS_BAR) { if (Game_mode & GM_MULTI) y -= LINE_SPACING * 6; else y -= LINE_SPACING * 1; } else { if (Game_mode & GM_MULTI) y -= LINE_SPACING * 7; else y -= LINE_SPACING * 2; } if (Players[Player_num].spec_flags & PLAYER_FLAGS_SPECTATING) gr_printf( x, y, "Free Fly Speed %2d%%", 100 + f2i((Cruise_speed))); // f2i(100 + (Cruise_speed / SPEC_SPEED_MOD))); else gr_printf( x, y, "%s %2d%%", TXT_CRUISE, f2i(Cruise_speed) ); } } if (GameCfg.FPSIndicator && PlayerCfg.CockpitMode[1] != CM_REAR_VIEW) show_framerate(); if (Newdemo_state == ND_STATE_PLAYBACK) Game_mode = Newdemo_game_mode; draw_hud(); if (Newdemo_state == ND_STATE_PLAYBACK) Game_mode = GM_NORMAL; if ( Player_is_dead ) player_dead_message(); }
void show_netplayerinfo() { int x=0, y=0, i=0, color=0; gr_set_current_canvas(NULL); gr_set_curfont(GAME_FONT); gr_set_fontcolor(255,-1); x=(SWIDTH/2)-FSPACX(120); y=(SHEIGHT/2)-FSPACY(84); gr_settransblend(14, GR_BLEND_NORMAL); gr_setcolor( BM_XRGB(0,0,0) ); gr_rect((SWIDTH/2)-FSPACX(120),(SHEIGHT/2)-FSPACY(84),(SWIDTH/2)+FSPACX(120),(SHEIGHT/2)+FSPACY(84)); gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL); // general game information y+=LINE_SPACING; gr_printf(0x8000,y,"%s",Netgame.game_name); #ifndef SHAREWARE y+=LINE_SPACING; gr_printf(0x8000,y,"%s - lvl: %i",Netgame.mission_title,Netgame.levelnum); #endif x+=FSPACX(8); y+=LINE_SPACING*2; gr_printf(x,y,"game mode: %s",GMNames[Netgame.gamemode]); y+=LINE_SPACING; gr_printf(x,y,"difficulty: %s",MENU_DIFFICULTY_TEXT(Netgame.difficulty)); y+=LINE_SPACING; gr_printf(x,y,"level time: %i:%02i:%02i",Players[Player_num].hours_level,f2i(Players[Player_num].time_level) / 60 % 60,f2i(Players[Player_num].time_level) % 60); y+=LINE_SPACING; gr_printf(x,y,"total time: %i:%02i:%02i",Players[Player_num].hours_total,f2i(Players[Player_num].time_total) / 60 % 60,f2i(Players[Player_num].time_total) % 60); y+=LINE_SPACING; if (Netgame.KillGoal) gr_printf(x,y,"Kill goal: %d",Netgame.KillGoal*5); // player information (name, kills, ping, game efficiency) y+=LINE_SPACING*2; gr_printf(x,y,"player"); if (Game_mode & GM_MULTI_COOP) gr_printf(x+FSPACX(8)*7,y,"score"); else { gr_printf(x+FSPACX(8)*7,y,"kills"); gr_printf(x+FSPACX(8)*12,y,"deaths"); } gr_printf(x+FSPACX(8)*18,y,"ping"); gr_printf(x+FSPACX(8)*23,y,"efficiency"); // process players table for (i=0; i<MAX_PLAYERS; i++) { if (!Players[i].connected) continue; y+=LINE_SPACING; if (Game_mode & GM_TEAM) color=get_team(i); else color=i; gr_set_fontcolor(BM_XRGB(player_rgb[color].r,player_rgb[color].g,player_rgb[color].b),-1 ); gr_printf(x,y,"%s\n",Players[i].callsign); if (Game_mode & GM_MULTI_COOP) gr_printf(x+FSPACX(8)*7,y,"%-6d",Players[i].score); else { gr_printf(x+FSPACX(8)*7,y,"%-6d",Players[i].net_kills_total); gr_printf(x+FSPACX(8)*12,y,"%-6d",Players[i].net_killed_total); } gr_printf(x+FSPACX(8)*18,y,"%-6d",Netgame.players[i].ping); if (i != Player_num) gr_printf(x+FSPACX(8)*23,y,"%d/%d",kill_matrix[Player_num][i],kill_matrix[i][Player_num]); } y+=LINE_SPACING*2+(LINE_SPACING*(MAX_PLAYERS-N_players)); // printf team scores if (Game_mode & GM_TEAM) { gr_set_fontcolor(255,-1); gr_printf(x,y,"team"); gr_printf(x+FSPACX(8)*8,y,"score"); y+=LINE_SPACING; gr_set_fontcolor(BM_XRGB(player_rgb[get_team(0)].r,player_rgb[get_team(0)].g,player_rgb[get_team(0)].b),-1 ); gr_printf(x,y,"%s:",Netgame.team_name[0]); gr_printf(x+FSPACX(8)*8,y,"%i",team_kills[0]); y+=LINE_SPACING; gr_set_fontcolor(BM_XRGB(player_rgb[get_team(1)].r,player_rgb[get_team(1)].g,player_rgb[get_team(1)].b),-1 ); gr_printf(x,y,"%s:",Netgame.team_name[1]); gr_printf(x+FSPACX(8)*8,y,"%i",team_kills[1]); y+=LINE_SPACING*2; } }
unsigned CLIState::draw(unsigned y, unsigned line_spacing) { using wrap_result = std::pair<const char *, unsigned>; /* At most this many lines of wrapped input can be shown at once. * Any excess lines will be hidden. * * Use a power of 2 to make the modulus optimize into a fast masking * operation. * * Zero-initialize for safety, but also mark it as initially * undefined for Valgrind. Assuming no bugs, any element of wraps[] * accessed by the second loop will have been initialized by the * first loop. */ std::array<wrap_result, 8> wraps{}; DXX_MAKE_VAR_UNDEFINED(wraps); const auto margin_width = FSPACX(1); const char prompt_string[2] = {g_prompt_strings[0], 0}; int prompt_width, h; gr_get_string_size(*grd_curcanv->cv_font, prompt_string, &prompt_width, &h, nullptr); y -= line_spacing; const auto canvas_width = grd_curcanv->cv_bitmap.bm_w; const unsigned max_pixels_per_line = canvas_width - (margin_width * 2) - prompt_width; const unsigned unknown_cursor_line = ~0u; const auto line_position = m_line_position; const auto line_begin = m_line.c_str(); std::size_t last_wrap_line = 0; unsigned cursor_line = unknown_cursor_line; /* Search the text and initialize wraps[] to record where line * breaks will appear. If the wrapped text is more than * wraps.size() vertical lines, only the most recent wraps.size() * lines are saved and shown. */ for (const char *p = line_begin;; ++last_wrap_line) { auto &w = wraps[last_wrap_line % wraps.size()]; w = gr_get_string_wrap(*grd_curcanv->cv_font, p, max_pixels_per_line); /* Record the vertical line on which the cursor will appear as * `cursor_line`. */ if (cursor_line == unknown_cursor_line) { const auto unseen_position = w.first - p; if (line_position < unseen_position) cursor_line = last_wrap_line; } /* If more text exists than can be shown, then stop at * (wraps.size() / 2) lines past the cursor line. */ else if (last_wrap_line >= wraps.size() && cursor_line + (wraps.size() / 2) < last_wrap_line) break; p = w.first; if (!*p) break; } const auto line_left = margin_width + prompt_width + 1; const auto cursor_string = (m_insert_type == CLI_insert_type::insert ? CLI_INS_CURSOR : CLI_OVR_CURSOR); int cursor_width, cursor_height; gr_get_string_size(*grd_curcanv->cv_font, cursor_string, &cursor_width, &cursor_height, nullptr); if (line_position == m_line.size()) { const auto &w = wraps[last_wrap_line % wraps.size()]; if (cursor_width + line_left + w.second > max_pixels_per_line) { auto &w2 = wraps[++last_wrap_line % wraps.size()]; w2 = {w.first, 0}; assert(!*w2.first); } cursor_line = last_wrap_line; } for (unsigned i = std::min(last_wrap_line + 1, wraps.size());; --last_wrap_line) { const auto &w = wraps[last_wrap_line % wraps.size()]; const auto p = w.first; if (!p) { assert(p); break; } std::string::const_pointer q; if (last_wrap_line) { q = wraps[(last_wrap_line - 1) % wraps.size()].first; if (!q) { assert(q); break; } } else q = line_begin; std::string::pointer mc; std::string::value_type c; /* If the parsing loop exited by the cursor_line test, then this * test is true on every pass through this loop. * * If the parsing loop exited by !*p, then this test is false on * the first pass through this loop and true on every other * pass. * * If the input text requires only one vertical line, then the * parsing loop will have exited through the !*p test and this * loop will only run iteration. */ if (*p) { /* Temporarily write a null into the text string for the * benefit of null-terminator based code in the gr_string* * functions. The original character is saved in `c` and * will be restored later. */ mc = &m_line[p - q]; c = *mc; *mc = 0; } else { /* No need to write to the std::string because a * null-terminator is already present. */ mc = nullptr; c = 0; } gr_string(*grd_curcanv, *grd_curcanv->cv_font, line_left, y, q, w.second, h); if (--i == cursor_line) { unsigned cx = line_left + w.second, cy = y; if (m_insert_type == CLI_insert_type::insert) cy += m_cursor_underline_y_shift; if (line_position != p - line_begin) { int cw; gr_get_string_size(*grd_curcanv->cv_font, &line_begin[line_position], &cw, nullptr, nullptr); cx -= cw; } gr_string(*grd_curcanv, *grd_curcanv->cv_font, cx, cy, cursor_string, cursor_width, cursor_height); } /* Restore the original character, if one was overwritten. */ if (mc) *mc = c; if (!i) break; y -= h; } gr_string(*grd_curcanv, *grd_curcanv->cv_font, margin_width, y, prompt_string, prompt_width, h); return y; }
// Process a character for the briefing, // including special characters preceded by a '$'. // Return 1 when page is finished, 0 otherwise static int briefing_process_char(grs_canvas &canvas, briefing *const br) { auto &game_font = *GAME_FONT; char ch = *br->message++; if (ch == '$') { ch = *br->message++; #if defined(DXX_BUILD_DESCENT_II) if (ch=='D') { br->cur_screen = DefineBriefingBox(canvas.cv_bitmap, br->message); br->screen.reset(&Briefing_screens[br->cur_screen]); init_char_pos(br, br->screen->text_ulx, br->screen->text_uly); br->line_adjustment=0; br->prev_ch = 10; // read to eoln } else if (ch=='U') { br->cur_screen = get_message_num(br->message); br->screen.reset(&Briefing_screens[br->cur_screen]); init_char_pos(br, br->screen->text_ulx, br->screen->text_uly); br->prev_ch = 10; // read to eoln } else #endif if (ch == 'C') { auto cc = get_message_num(br->message) - 1; if (cc < 0) cc = 0; else if (cc > Briefing_text_colors.size() - 1) cc = Briefing_text_colors.size() - 1; Current_color = &Briefing_text_colors[cc]; br->prev_ch = 10; } else if (ch == 'F') { // toggle flashing cursor br->flashing_cursor = !br->flashing_cursor; br->prev_ch = 10; while (*br->message++ != 10) ; } else if (ch == 'T') { br->tab_stop = get_message_num(br->message); br->prev_ch = 10; // read to eoln } else if (ch == 'R') { br->robot_canv.reset(); #if defined(DXX_BUILD_DESCENT_II) if (br->robot_playing) { DeInitRobotMovie(br->pMovie); br->robot_playing=0; } #endif if (EMULATING_D1) { init_spinning_robot(canvas, *br); br->robot_num = get_message_num(br->message); #if defined(DXX_BUILD_DESCENT_II) while (*br->message++ != 10) ; #endif } else { #if defined(DXX_BUILD_DESCENT_II) char spinRobotName[]="RBA.MVE", kludge; // matt don't change this! kludge=*br->message++; spinRobotName[2]=kludge; // ugly but proud br->robot_playing=InitRobotMovie(spinRobotName, br->pMovie); // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 ); if (br->robot_playing) { RotateRobot(br->pMovie); set_briefing_fontcolor(*br); } #endif } br->prev_ch = 10; // read to eoln } else if ((ch == 'N' && (br->animating_bitmap_type = 0, true)) || (ch == 'O' && (br->animating_bitmap_type = 1, true))) { br->robot_canv.reset(); br->prev_ch = 10; get_message_name(br->message, br->bitmap_name, "#0"); } else if (ch=='A') { #if defined(DXX_BUILD_DESCENT_II) br->line_adjustment=1-br->line_adjustment; #endif } else if (ch=='Z') { #if defined(DXX_BUILD_DESCENT_II) char fname[15]; int i; br->got_z=1; br->dumb_adjust=1; i=0; while ((fname[i]=*br->message) != '\n') { i++; br->message++; } fname[i]=0; if (*br->message != 10) while (*br->message++ != 10) // Get and drop eoln ; { char fname2[15]; i=0; while (fname[i]!='.') { fname2[i] = fname[i]; i++; } fname2[i++]='b'; fname2[i++]='.'; fname2[i++]='p'; fname2[i++]='c'; fname2[i++]='x'; fname2[i++]=0; if ((HIRESMODE && PHYSFSX_exists(fname2,1)) || !PHYSFSX_exists(fname,1)) strcpy(fname,fname2); load_briefing_screen(*grd_curcanv, br, fname); } #endif } else if (ch == 'B') { array<char, 32> bitmap_name; palette_array_t temp_palette; int iff_error; br->robot_canv.reset(); get_message_name(br->message, bitmap_name, ".bbm"); br->guy_bitmap.reset(); iff_error = iff_read_bitmap(&bitmap_name[0], br->guy_bitmap, &temp_palette); #if defined(DXX_BUILD_DESCENT_II) gr_remap_bitmap_good( br->guy_bitmap, temp_palette, -1, -1 ); #endif Assert(iff_error == IFF_NO_ERROR); (void)iff_error; br->prev_ch = 10; } else if (ch == 'S') { #if defined(DXX_BUILD_DESCENT_II) br->chattering = 0; br->printing_channel.reset(); #endif br->new_screen = 1; return 1; } else if (ch == 'P') { // New page. #if defined(DXX_BUILD_DESCENT_II) if (!br->got_z) { Int3(); // Hey ryan!!!! You gotta load a screen before you start // printing to it! You know, $Z !!! load_briefing_screen(*grd_curcanv, br, HIRESMODE ? "end01b.pcx" : "end01.pcx"); } br->chattering = 0; br->printing_channel.reset(); #endif br->new_page = 1; while (*br->message != 10) { br->message++; // drop carriage return after special escape sequence } br->message++; br->prev_ch = 10; return 1; } #if defined(DXX_BUILD_DESCENT_II) else if (ch == ':') { br->prev_ch = 10; auto p = br->message; /* Legacy clients do not understand $: and will instead show * the remainder of the line. However, if the next two * characters after $: are $F, legacy clients will treat * the $F as above, toggle the flashing_cursor flag, then * discard the rest of the line. This special case allows * briefing authors to hide the directive from legacy * clients, but get the same state of flashing_cursor for * both legacy and aware clients. Briefing authors will * likely need an additional $F nearby to balance this * toggle, but no additional code here is needed to support * that. * * The trailing colon is cosmetic, so that the compatibility * $F is not directly adjacent to the directive. */ if (!strncmp(p, "$F:", 3)) { br->flashing_cursor = !br->flashing_cursor; p += 3; } auto &rotate_robot_label = "Rebirth.rotate.robot "; constexpr auto rotate_robot_len = sizeof(rotate_robot_label) - 1; if (!strncmp(p, rotate_robot_label, rotate_robot_len)) { char *p2; const auto id = strtoul(p + rotate_robot_len, &p2, 10); if (*p2 == '\n') { p = p2; br->robot_canv.reset(); if (br->robot_playing) { br->robot_playing = 0; DeInitRobotMovie(br->pMovie); } init_spinning_robot(canvas, *br); /* This modifies the appearance of the frame, which * is unfortunate. However, without it, all robots * come out blue shifted. */ gr_use_palette_table("groupa.256"); br->robot_num = id; } } else { const char *p2 = p; /* Suppress non-printing characters. No need to support * encodings. */ for (char c; (c = *p2) >= ' ' && c <= '~'; ++p2) { } con_printf(CON_VERBOSE, "warning: unknown briefing directive \"%.*s\"", DXX_ptrdiff_cast_int(p2 - p), p); } for (char c; (c = *p) && (++p, c) != '\n';) { /* Discard through newline. On break, *p is '\0' or * p[-1] is '\n'. */ } br->message = p; } #endif else if (ch == '$' || ch == ';') // Print a $/; put_char_delay(game_font, br, ch); } else if (ch == '\t') { // Tab const auto &&fspacx = FSPACX(); if (br->text_x - br->screen->text_ulx < fspacx(br->tab_stop)) br->text_x = br->screen->text_ulx + fspacx(br->tab_stop); } else if ((ch == ';') && (br->prev_ch == 10)) { while (*br->message++ != 10) ; br->prev_ch = 10; } else if (ch == '\\') { br->prev_ch = ch; } else if (ch == 10) { if (br->prev_ch != '\\') { br->prev_ch = ch; #if defined(DXX_BUILD_DESCENT_II) if (br->dumb_adjust) br->dumb_adjust--; else #endif br->text_y += FSPACY(5)+FSPACY(5)*3/5; br->text_x = br->screen->text_ulx; if (br->text_y > br->screen->text_uly + br->screen->text_height) { #if defined(DXX_BUILD_DESCENT_I) load_briefing_screen(*grd_curcanv, br, D1_Briefing_screens[br->cur_screen].bs_name); #elif defined(DXX_BUILD_DESCENT_II) load_briefing_screen(*grd_curcanv, br, Briefing_screens[br->cur_screen].bs_name); #endif br->text_x = br->screen->text_ulx; br->text_y = br->screen->text_uly; } } else { if (ch == 13) //Can this happen? Above says ch==10 Int3(); br->prev_ch = ch; } } else { #if defined(DXX_BUILD_DESCENT_II) if (!br->got_z) { LevelError("briefing wrote to screen without using $Z to load a screen; loading default."); //Int3(); // Hey ryan!!!! You gotta load a screen before you start // printing to it! You know, $Z !!! load_briefing_screen(*grd_curcanv, br, HIRESMODE ? "end01b.pcx" : "end01.pcx"); } #endif put_char_delay(game_font, br, ch); } return 0; }
void show_netplayerinfo() { int x=0, y=0, i=0, color=0, eff=0; static const char *const eff_strings[]={"trashing","really hurting","seriously affecting","hurting","affecting","tarnishing"}; gr_set_current_canvas(NULL); gr_set_curfont(GAME_FONT); gr_set_fontcolor(255,-1); x=(SWIDTH/2)-FSPACX(120); y=(SHEIGHT/2)-FSPACY(84); gr_settransblend(14, GR_BLEND_NORMAL); gr_setcolor( BM_XRGB(0,0,0) ); gr_rect((SWIDTH/2)-FSPACX(120),(SHEIGHT/2)-FSPACY(84),(SWIDTH/2)+FSPACX(120),(SHEIGHT/2)+FSPACY(84)); gr_settransblend(GR_FADE_OFF, GR_BLEND_NORMAL); // general game information y+=LINE_SPACING; gr_printf(0x8000,y,"%s",Netgame.game_name); #ifndef SHAREWARE y+=LINE_SPACING; gr_printf(0x8000,y,"%s - lvl: %i",Netgame.mission_title,Netgame.levelnum); #endif x+=FSPACX(8); y+=LINE_SPACING*2; unsigned gamemode = Netgame.gamemode; gr_printf(x,y,"game mode: %s",gamemode < (sizeof(GMNames) / sizeof(GMNames[0])) ? GMNames[gamemode] : "INVALID"); int base_flags_left = SWIDTH/2 - FSPACX(15); int flags_x = base_flags_left + FSPACX(30); int letter_spacing = FSPACX(7); int word_spacing = FSPACX(46); if(Netgame.RetroProtocol) { draw_flag("RetroP2P", 1, base_flags_left + word_spacing*0, y); } else if(Netgame.ShortPackets) { draw_flag("ShortPkt", 1, base_flags_left + word_spacing*0, y); } else { draw_flag("LongPkt", 1, base_flags_left + word_spacing*0, y); } char pps_string[16]; sprintf(pps_string, "PPS %d", Netgame.PacketsPerSec); draw_flag(pps_string, 1, base_flags_left + word_spacing*1, y); if(Netgame.SpawnStyle == SPAWN_STYLE_NO_INVUL ) { draw_flag("NoInvul", 1, base_flags_left + word_spacing*2, y); } else if (Netgame.SpawnStyle == SPAWN_STYLE_SHORT_INVUL ) { draw_flag("ShortInv", 1, base_flags_left + word_spacing*2, y); } else if (Netgame.SpawnStyle == SPAWN_STYLE_LONG_INVUL ) { draw_flag("LongInv", 1, base_flags_left + word_spacing*2, y); } else { draw_flag("Preview", 1, base_flags_left + word_spacing*2, y); } set_font_newline(); y+=LINE_SPACING; gr_printf(x,y,"difficulty: %s",MENU_DIFFICULTY_TEXT(Netgame.difficulty)); draw_flag("ColorLgt", Netgame.AllowColoredLighting, base_flags_left + word_spacing*0, y); draw_flag("BrtShips", Netgame.BrightPlayers, base_flags_left + word_spacing*1, y); draw_flag("ConcResp", Netgame.RespawnConcs, base_flags_left + word_spacing*2, y); set_font_newline(); y+=LINE_SPACING; gr_printf(x,y,"level time: %i:%02i:%02i",Players[Player_num].hours_level,f2i(Players[Player_num].time_level) / 60 % 60,f2i(Players[Player_num].time_level) % 60); char disp_string[16]; sprintf(disp_string, "Guns x%d", Netgame.PrimaryDupFactor == 0 ? 1 : Netgame.PrimaryDupFactor); draw_flag(disp_string, Netgame.PrimaryDupFactor > 1, base_flags_left + word_spacing*0, y); sprintf(disp_string, "Msls x%d", Netgame.SecondaryDupFactor == 0 ? 1 : Netgame.SecondaryDupFactor); draw_flag(disp_string, Netgame.SecondaryDupFactor > 1, base_flags_left + word_spacing*1, y); sprintf(disp_string, "Mcap %s", Netgame.SecondaryCapFactor == 0 ? "ALL" : (Netgame.SecondaryCapFactor == 1 ? "6" : "2")); draw_flag(disp_string, Netgame.SecondaryCapFactor > 0, base_flags_left + word_spacing*2, y); set_font_newline(); y+=LINE_SPACING; gr_printf(x,y,"total time: %i:%02i:%02i",Players[Player_num].hours_total,f2i(Players[Player_num].time_total) / 60 % 60,f2i(Players[Player_num].time_total) % 60); set_font_newline(); y+=LINE_SPACING; if (Netgame.KillGoal) gr_printf(x,y,"Kill goal: %d",Netgame.KillGoal*10); gr_printf(base_flags_left, y, "Items: "); draw_flag("L", Netgame.AllowedItems & NETFLAG_DOLASER, flags_x, y); flags_x += letter_spacing; draw_flag("Q", Netgame.AllowedItems & NETFLAG_DOQUAD, flags_x, y); flags_x += letter_spacing; draw_flag("V", Netgame.AllowedItems & NETFLAG_DOVULCAN, flags_x, y); flags_x += letter_spacing; draw_flag("A", Netgame.AllowedItems & NETFLAG_DOVULCANAMMO,flags_x, y); flags_x += letter_spacing; draw_flag("S", Netgame.AllowedItems & NETFLAG_DOSPREAD, flags_x, y); flags_x += letter_spacing; draw_flag("P", Netgame.AllowedItems & NETFLAG_DOPLASMA, flags_x, y); flags_x += letter_spacing; draw_flag("F", Netgame.AllowedItems & NETFLAG_DOFUSION, flags_x, y); flags_x += letter_spacing; draw_flag("C", 1, flags_x, y); flags_x += letter_spacing; draw_flag("H", Netgame.AllowedItems & NETFLAG_DOHOMING, flags_x, y); flags_x += letter_spacing; draw_flag("P", Netgame.AllowedItems & NETFLAG_DOPROXIM, flags_x, y); flags_x += letter_spacing; draw_flag("S", Netgame.AllowedItems & NETFLAG_DOSMART, flags_x, y); flags_x += letter_spacing; draw_flag("M", Netgame.AllowedItems & NETFLAG_DOMEGA, flags_x, y); flags_x += letter_spacing; draw_flag("C", Netgame.AllowedItems & NETFLAG_DOCLOAK, flags_x, y); flags_x += letter_spacing; draw_flag("I", Netgame.AllowedItems & NETFLAG_DOINVUL, flags_x, y); flags_x += letter_spacing; // player information (name, kills, ping, game efficiency) set_font_newline(); y+=LINE_SPACING*3; gr_printf(x,y,"player"); if (Game_mode & GM_MULTI_COOP) gr_printf(x+FSPACX(8)*7,y,"score"); else { gr_printf(x+FSPACX(8)*7,y,"kills"); gr_printf(x+FSPACX(8)*12,y,"deaths"); } gr_printf(x+FSPACX(8)*18,y,"ping"); gr_printf(x+FSPACX(8)*23,y,"efficiency"); if(Netgame.FairColors) selected_player_rgb = player_rgb_all_blue; else if(Netgame.BlackAndWhitePyros) selected_player_rgb = player_rgb_alt; else selected_player_rgb = player_rgb; // process players table for (i=0; i<MAX_PLAYERS; i++) { if (!Players[i].connected) continue; y+=LINE_SPACING; if (Game_mode & GM_TEAM) color=get_team(i); else color=Netgame.players[i].color;//i; gr_set_fontcolor( BM_XRGB(selected_player_rgb[color].r,selected_player_rgb[color].g,selected_player_rgb[color].b),-1 ); gr_printf(x,y,"%s\n",Players[i].callsign); if (Game_mode & GM_MULTI_COOP) gr_printf(x+FSPACX(8)*7,y,"%-6d",Players[i].score); else { gr_printf(x+FSPACX(8)*7,y,"%-6d",Players[i].net_kills_total); gr_printf(x+FSPACX(8)*12,y,"%-6d",Players[i].net_killed_total); } gr_printf(x+FSPACX(8)*18,y,"%-6d",Netgame.players[i].ping + Netgame.players[Player_num].ping); if (i != Player_num) gr_printf(x+FSPACX(8)*23,y,"%d/%d",kill_matrix[Player_num][i],kill_matrix[i][Player_num]); } y+=LINE_SPACING*2+(LINE_SPACING*(MAX_PLAYERS-N_players)); // printf team scores if (Game_mode & GM_TEAM) { gr_set_fontcolor(255,-1); gr_printf(x,y,"team"); gr_printf(x+FSPACX(8)*8,y,"score"); y+=LINE_SPACING; gr_set_fontcolor(BM_XRGB(selected_player_rgb[0].r,selected_player_rgb[0].g,selected_player_rgb[0].b),-1 ); gr_printf(x,y,"%s:",Netgame.team_name[0]); gr_printf(x+FSPACX(8)*8,y,"%i",team_kills[0]); y+=LINE_SPACING; gr_set_fontcolor(BM_XRGB(selected_player_rgb[1].r,selected_player_rgb[1].g,selected_player_rgb[1].b),-1 ); gr_printf(x,y,"%s:",Netgame.team_name[1]); gr_printf(x+FSPACX(8)*8,y,"%i",team_kills[1]); y+=LINE_SPACING*2; } else y+=LINE_SPACING*4; gr_set_fontcolor(255,-1); // additional information about game - ranking eff=(int)((float)((float)PlayerCfg.NetlifeKills/((float)PlayerCfg.NetlifeKilled+(float)PlayerCfg.NetlifeKills))*100.0); if (eff<0) eff=0; if (!PlayerCfg.NoRankings) { gr_printf(0x8000,y,"Your lifetime efficiency of %d%% (%d/%d)",eff,PlayerCfg.NetlifeKills,PlayerCfg.NetlifeKilled); y+=LINE_SPACING; if (eff<60) gr_printf(0x8000,y,"is %s your ranking.",eff_strings[eff/10]); else gr_printf(0x8000,y,"is serving you well."); y+=LINE_SPACING; gr_printf(0x8000,y,"your rank is: %s",RankStrings[GetMyNetRanking()]); } }
void con_show(void) { int i=0, y; static float con_size=0; int done=0; if (con_render) { if (con_size < CON_LINES_ONSCREEN && FixedStep & EPS30) { con_size++; } } else { if (con_size > 0 && FixedStep & EPS30) { con_size--; } } if (!con_size) return; gr_set_current_canvas(NULL); gr_set_curfont(GAME_FONT); gr_setcolor(0); Gr_scanline_darkening_level = 1*7; gr_rect(0,0,SWIDTH,(LINE_SPACING*(con_size))+FSPACY(1)); Gr_scanline_darkening_level = GR_FADE_LEVELS; y=FSPACY(1)+(LINE_SPACING*con_size); i+=con_scroll_offset; while (!done) { int w,h,aw; switch (con_buffer[CON_LINES_MAX-1-i].priority) { case CON_CRITICAL: gr_set_fontcolor(BM_XRGB(28,0,0),-1); break; case CON_URGENT: gr_set_fontcolor(BM_XRGB(54,54,0),-1); break; case CON_DEBUG: case CON_VERBOSE: gr_set_fontcolor(BM_XRGB(14,14,14),-1); break; case CON_HUD: gr_set_fontcolor(BM_XRGB(0,28,0),-1); break; default: gr_set_fontcolor(255,-1); break; } gr_get_string_size(con_buffer[CON_LINES_MAX-1-i].line,&w,&h,&aw); y-=h+FSPACY(1); gr_printf(FSPACX(1),y,"%s",con_buffer[CON_LINES_MAX-1-i].line); i++; if (y<=0 || CON_LINES_MAX-1-i <= 0 || i < 0) done=1; } gr_setcolor(0); gr_rect(0,0,SWIDTH,LINE_SPACING); gr_set_fontcolor(255,-1); gr_printf(FSPACX(1),FSPACY(1),"%s LOG", DESCENT_VERSION); gr_printf(SWIDTH-FSPACX(110),FSPACY(1),"PAGE-UP/DOWN TO SCROLL"); }
int scores_handler(window *wind, d_event *event, scores_menu *menu) { int i; int k; sbyte fades[64] = { 1,1,1,2,2,3,4,4,5,6,8,9,10,12,13,15,16,17,19,20,22,23,24,26,27,28,28,29,30,30,31,31,31,31,31,30,30,29,28,28,27,26,24,23,22,20,19,17,16,15,13,12,10,9,8,6,5,4,4,3,2,2,1,1 }; int w = FSPACX(290), h = FSPACY(170); switch (event->type) { case EVENT_WINDOW_ACTIVATED: game_flush_inputs(); break; case EVENT_KEY_COMMAND: k = event_key_get(event); switch( k ) { case KEY_CTRLED+KEY_R: if ( menu->citem < 0 ) { // Reset scores... if ( nm_messagebox( NULL, 2, TXT_NO, TXT_YES, TXT_RESET_HIGH_SCORES )==1 ) { PHYSFS_delete(SCORES_FILENAME); scores_view(&menu->last_game, menu->citem); // create new scores window window_close(wind); // then remove the old one } } return 1; case KEY_ENTER: case KEY_SPACEBAR: case KEY_ESC: window_close(wind); return 1; } break; case EVENT_MOUSE_BUTTON_DOWN: case EVENT_MOUSE_BUTTON_UP: if (event_mouse_get_button(event) == MBTN_LEFT || event_mouse_get_button(event) == MBTN_RIGHT) { window_close(wind); return 1; } break; case EVENT_IDLE: timer_delay2(50); break; case EVENT_WINDOW_DRAW: gr_set_current_canvas(NULL); nm_draw_background(((SWIDTH-w)/2)-BORDERX,((SHEIGHT-h)/2)-BORDERY,((SWIDTH-w)/2)+w+BORDERX,((SHEIGHT-h)/2)+h+BORDERY); gr_set_current_canvas(window_get_canvas(wind)); grd_curcanv->cv_font = MEDIUM3_FONT; gr_string( 0x8000, FSPACY(15), TXT_HIGH_SCORES ); grd_curcanv->cv_font = GAME_FONT; gr_set_fontcolor( BM_XRGB(31,26,5), -1 ); gr_string( FSPACX( 71), FSPACY(50), TXT_NAME ); gr_string( FSPACX(122), FSPACY(50), TXT_SCORE ); gr_string( FSPACX(167), FSPACY(50), TXT_SKILL ); gr_string( FSPACX(210), FSPACY(50), TXT_LEVELS ); gr_string( FSPACX(253), FSPACY(50), TXT_TIME ); if ( menu->citem < 0 ) gr_string( 0x8000, FSPACY(175), TXT_PRESS_CTRL_R ); gr_set_fontcolor( BM_XRGB(28,28,28), -1 ); gr_printf( 0x8000, FSPACY(31), "%c%s%c - %s", 34, menu->scores.cool_saying, 34, menu->scores.stats[0].name ); for (i=0; i<MAX_HIGH_SCORES; i++ ) { gr_set_fontcolor( BM_XRGB(28-i*2,28-i*2,28-i*2), -1 ); scores_draw_item( i, &menu->scores.stats[i] ); } if ( menu->citem > -1 ) { gr_set_fontcolor( BM_XRGB(7+fades[menu->looper],7+fades[menu->looper],7+fades[menu->looper]), -1 ); if (timer_query() >= menu->t1+F1_0/128) { menu->t1 = timer_query(); menu->looper++; if (menu->looper>63) menu->looper=0; } if ( menu->citem == MAX_HIGH_SCORES ) scores_draw_item( MAX_HIGH_SCORES, &menu->last_game ); else scores_draw_item( menu->citem, &menu->scores.stats[menu->citem] ); } gr_set_current_canvas(NULL); break; case EVENT_WINDOW_CLOSE: d_free(menu); break; default: break; } return 0; }