void CG_LoadPanel_RenderCampaignNameText(panel_button_t *button) { const char *cs; float w; float scaleF; if (cgs.gametype == GT_WOLF_CAMPAIGN) { cs = DC->nameForCampaign(); if (!cs) { return; } cs = va("%s %iof%i", cs, cgs.currentCampaignMap + 1, cgs.campaignData.mapCount); scaleF = campaignNameTextScaleFactor(Q_PrintStrlen(cs)); w = CG_Text_Width_Ext(cs, button->font->scalex * scaleF, 0, button->font->font); CG_Text_Paint_Ext(button->rect.x + (button->rect.w - w) * 0.5f, button->rect.y, button->font->scalex * scaleF, button->font->scaley * scaleF, button->font->colour, cs, 0, 0, 0, button->font->font); } else { if (!cgs.arenaInfoLoaded) { return; } scaleF = campaignNameTextScaleFactor(Q_PrintStrlen(cgs.arenaData.longname)); // FIXME: up to 128 chars ! w = CG_Text_Width_Ext(cgs.arenaData.longname, button->font->scalex * scaleF, 0, button->font->font); CG_Text_Paint_Ext(button->rect.x + (button->rect.w - w) * 0.5f, button->rect.y, button->font->scalex * scaleF, button->font->scaley * scaleF, button->font->colour, cgs.arenaData.longname, 0, 0, 0, button->font->font); } }
/* ================= ServerInfo_MenuDraw ================= */ static void ServerInfo_MenuDraw( void ) { const char *s; char key[MAX_INFO_KEY]; char value[MAX_INFO_VALUE]; int y, i=0; int keylen, vallen, infonum=-1; UI_DrawIngameBG(); UI_DrawProportionalString( 320, 110, "SERVER INFO",UI_CENTER|UI_SMALLFONT,color_black); y = 140;//95; s = s_serverinfo.info; s_serverinfo.numdrawn = 0; while ( s && i < s_serverinfo.numlines ) { i++; Info_NextPair( &s, key, value ); if ( !key[0] ) { break; } infonum++; if(s_serverinfo.firstline>infonum) continue; if(y>260) break; Com_sprintf(key,MAX_INFO_KEY,"%s: ",key); keylen=Q_PrintStrlen(key); vallen=Q_PrintStrlen(value); if(keylen+vallen<20) { UI_DrawString(230,y,key,UI_LEFT|UI_SMALLFONT,color_black); UI_DrawString(230+keylen*8,y,value,UI_LEFT|UI_SMALLFONT,color_blue); s_serverinfo.numdrawn++; } else { int i; // TODO: Also add linebreaks for long keys? UI_DrawString(230,y,key,UI_LEFT|UI_SMALLFONT,color_black); for(i=0;i<vallen;i+=20) { y += SMALLCHAR_HEIGHT; if(y>260) break; UI_DrawString(230,y,va("%20.20s",&value[i]),UI_LEFT|UI_SMALLFONT,color_blue); s_serverinfo.numdrawn++; } } y += SMALLCHAR_HEIGHT; } Menu_Draw( &s_serverinfo.menu ); }
/* ================== CON_UpdateCursor Update the cursor position ================== */ static inline void CON_UpdateCursor(void) { // pdcurses uses a different mechanism to move the cursor than ncurses #ifdef _WIN32 move(LINES - 1, Q_PrintStrlen(PROMPT) + input_field.cursor - input_field.scroll); wnoutrefresh(stdscr); #else wmove(inputwin, 0, input_field.cursor - input_field.scroll); wnoutrefresh(inputwin); #endif }
static INLINE void CON_UpdateCursor( void ) { // pdcurses uses a different mechanism to move the cursor than ncurses #ifdef _WIN32 move( LINES - 1, Q_PrintStrlen( PROMPT ) + 8 + input_field.cursor - input_field.scroll ); wnoutrefresh( stdscr ); #elif defined USE_CURSES_W wmove( inputwin, 0, CON_CursorPosFromScroll() ); wnoutrefresh( inputwin ); #else wmove( inputwin, 0, input_field.cursor - input_field.scroll ); wnoutrefresh( inputwin ); #endif }
void SV_DumpUserResponse(char* globalUserinfo){ int j, l, i; time_t t1; char *nick; Com_Printf("UID: %s\n", Info_ValueForKey( globalUserinfo, "uid" )); Com_Printf("Connections: %s\n", Info_ValueForKey( globalUserinfo, "connections" )); t1 = atoi(Info_ValueForKey( globalUserinfo, "firstseen" )); Com_Printf("Firstseen: %s",ctime(&t1)); t1 = atoi(Info_ValueForKey( globalUserinfo, "lastseen" )); Com_Printf("Lastseen: %s",ctime(&t1)); Com_Printf("Current IP: %s\n", Info_ValueForKey( globalUserinfo, "currentip" )); Com_Printf("Previous used IP: %s\n", Info_ValueForKey( globalUserinfo, "olderip" )); Com_Printf("First Server: %s\n", Info_ValueForKey( globalUserinfo, "firstserver" )); Com_Printf("Last Server: %s\n", Info_ValueForKey( globalUserinfo, "lastserver" )); if(atoi(Info_ValueForKey( globalUserinfo, "banduration" )) != 0){ Com_Printf("Globaly banned user: %i\n", atoi(Info_ValueForKey( globalUserinfo, "banduration" ))); }else{ Com_Printf("Globaly banned user: N/A\n"); } Com_Printf("\nRecent used nicknames\n"); Com_Printf("Name Last used\n"); Com_Printf("--------------- ------------------------\n"); for(i = 0; i < MAX_NICKNAMES ; i++){ t1 = atoi(Info_ValueForKey( globalUserinfo, va("nicklastused%i", i))); if(!t1) continue; nick = Info_ValueForKey( globalUserinfo, va("nickname%i", i)); Com_Printf("%s^7", nick); l = 16 - Q_PrintStrlen(nick); j = 0; do { Com_Printf (" "); j++; } while(j < l); Com_Printf(ctime(&t1)); } Com_Printf("\n"); }
static void PrintClientStats( gclient_t *cl, const playerStat_t *columns, int *bestStats ) { char line[2 * DEFAULT_CONSOLE_WIDTH + 1]; // extra space for color codes char *p = line; const char *e = line + sizeof(line); int stats[STAT_MAX]; int pad; int i; GetStats(stats, cl); pad = MAX_NAME_LEN - Q_PrintStrlen(cl->pers.netname); p += Com_sprintf(p, e - p, "%s%s" S_COLOR_WHITE, cl->pers.netname, Spaces(pad)); for (i = 0; columns[i] != STAT_MAX; i++) { playerStat_t stat = columns[i]; char *value = va("%i", stats[stat]); int len = strlen(value); if (statCol[stat].disabled) continue; if (stats[stat] >= 1000 && len > statCol[stat].width) { value = va("%ik", stats[stat] / 1000); len = strlen(value); } if (len > statCol[stat].width) { value = ""; len = 0; } pad = statCol[stat].width - len; if (stats[stat] == bestStats[stat]) { p += Com_sprintf(p, e - p, S_COLOR_GREEN " %s%s" S_COLOR_WHITE, value, Spaces(pad)); } else { p += Com_sprintf(p, e - p, " %s%s", value, Spaces(pad)); } } trap_SendServerCommand(-1, va("print \"%s\n\"", line)); }
static void CG_DisplayTeamStat(team_t t) { int i, nameLenMax = 0; stats max; memset(&max, 0, sizeof(max)); for (i = 0; i < cg.numScores; i++) { int *enhancedStats = &(cg.enhanced.stats[i].score); int *maxStats = &(max.score); int j; if (!(cg.enhanced.stats[i].team == TEAM_RED || cg.enhanced.stats[i].team == TEAM_BLUE)) continue; int nameLen = Q_PrintStrlen(cg.enhanced.stats[i].name); if (nameLen > nameLenMax) nameLenMax = nameLen; if (cg.enhanced.stats[i].team != t) continue; for (j = 0; j < 11; j++, enhancedStats++, maxStats++) { if (*enhancedStats > *maxStats) *maxStats = *enhancedStats; } } if (nameLenMax < 4) nameLenMax = 4; CG_Printf(S_COLOR_CYAN"TEAM NAME"); for (i = 0; i < nameLenMax-4; i++) CG_Printf(" "); CG_Printf(S_COLOR_CYAN" SCORE CAPS ASSIST DEF ACC TIME "); CG_Printf(S_COLOR_RED "FCKILLS FLAGRETS FLAGHOLD TH/TE\n"); CG_Printf(S_COLOR_CYAN"---- "); for (i = 0; i < nameLenMax; i++) CG_Printf(S_COLOR_CYAN"-"); CG_Printf(S_COLOR_CYAN" ----- ---- ------ --- ---- ---- "); CG_Printf(S_COLOR_CYAN"------- -------- -------- ------\n"); for (i = 0; i < cg.numScores; i++) { int nameLen; if (cg.enhanced.stats[i].team != t) continue; if (t == TEAM_RED) CG_Printf(S_COLOR_RED"RED "); else if (t == TEAM_BLUE) CG_Printf(S_COLOR_BLUE"BLUE "); nameLen = Q_PrintStrlen(cg.enhanced.stats[i].name); CG_Printf(S_COLOR_WHITE"%s", cg.enhanced.stats[i].name); if (nameLen < nameLenMax) { int j, d = nameLenMax - nameLen; for (j = 0; j < d; j++) CG_Printf(" "); } CG_Printf(" "); CG_Printf(S_COLOR_WHITE); CG_PrintfStats("%5d ", cg.enhanced.stats[i].score, max.score); CG_PrintfStats("%4d ", cg.enhanced.stats[i].captures, max.captures); CG_PrintfStats("%6d ", cg.enhanced.stats[i].assist, max.assist); CG_PrintfStats("%3d ", cg.enhanced.stats[i].defend, max.defend); CG_PrintfStats("%3d%% ", cg.enhanced.stats[i].accuracy, max.accuracy); CG_Printf(S_COLOR_WHITE"%4d ", cg.enhanced.stats[i].time); CG_PrintfStats("%7d ", cg.enhanced.stats[i].flagCarrierKills, max.flagCarrierKills); CG_PrintfStats("%8d ", cg.enhanced.stats[i].flagReturns, max.flagReturns); {char flagHold[17]; int secs = (cg.enhanced.stats[i].flagHold / 1000); int mins = (secs / 60); if (cg.enhanced.stats[i].flagHold >= 60000) { secs %= 60; // Com_sprintf(flagHold, sizeof(flagHold), "%d:%02d", mins, secs); Com_sprintf(flagHold, sizeof(flagHold), "%dm %02ds", mins, secs); } else { // Com_sprintf(flagHold, sizeof(flagHold), "%d", secs); Com_sprintf(flagHold, sizeof(flagHold), "%ds", secs); } if (cg.enhanced.stats[i].flagHold == max.flagHold && max.flagHold != 0) CG_Printf(S_COLOR_GREEN"%8s ", flagHold); else CG_Printf(S_COLOR_WHITE"%8s ", flagHold);} CG_PrintfStats("%3d", cg.enhanced.stats[i].teamHeals, max.teamHeals); CG_Printf(S_COLOR_WHITE"/"); CG_PrintfStats("%d", cg.enhanced.stats[i].teamEnergizes, max.teamEnergizes); CG_Printf("\n"); } }
/* ================ Con_CheckResize If the line width has changed, reformat the buffer. ================ */ void Con_CheckResize( void ) { int i, width, oldwidth, oldtotallines, numlines, numchars; conChar_t buf[ CON_TEXTSIZE ]; if ( cls.glconfig.vidWidth ) { if ( scr_conUseOld->integer ) { width = cls.glconfig.vidWidth / SCR_ConsoleFontUnicharWidth( 'W' ); } else { float adjust = 30; SCR_AdjustFrom640( &adjust, NULL, NULL, NULL ); width = ( cls.glconfig.vidWidth - adjust ) / SCR_ConsoleFontUnicharWidth( 'W' ); } g_consoleField.widthInChars = width - Q_PrintStrlen( cl_consolePrompt->string ) - 1; } else { width = 0; } if ( width == con.linewidth ) { // nothing } else if ( width < 1 ) // video hasn't been initialized yet { width = DEFAULT_CONSOLE_WIDTH; con.linewidth = width; con.totallines = CON_TEXTSIZE / con.linewidth; Con_Clear(); con.current = con.totallines - 1; con.display = con.current; } else { SCR_AdjustFrom640( &con.xadjust, NULL, NULL, NULL ); oldwidth = con.linewidth; con.linewidth = width; oldtotallines = con.totallines; con.totallines = CON_TEXTSIZE / con.linewidth; numlines = oldtotallines; if ( con.totallines < numlines ) { numlines = con.totallines; } numchars = oldwidth; if ( con.linewidth < numchars ) { numchars = con.linewidth; } Com_Memcpy( buf, con.text, sizeof( con.text ) ); Con_Clear(); for ( i = 0; i < numlines; i++ ) { memcpy( con.text + ( con.totallines - 1 - i ) * con.linewidth, buf + ( ( con.current - i + oldtotallines ) % oldtotallines ) * oldwidth, numchars * sizeof( conChar_t ) ); } con.current = con.totallines - 1; con.display = con.current; } g_console_field_width = g_consoleField.widthInChars = con.linewidth - 7 - ( cl_consolePrompt ? Q_UTF8Strlen( cl_consolePrompt->string ) : 0 ); }
/* ================== CON_Init Initialize the console in curses mode, fall back to tty mode on failure ================== */ void CON_Init(void) { int col; #ifndef _WIN32 // If the process is backgrounded (running non interactively) // then SIGTTIN or SIGTOU is emitted, if not caught, turns into a SIGSTP signal(SIGTTIN, SIG_IGN); signal(SIGTTOU, SIG_IGN); #endif // Make sure we're on a tty if (isatty(STDIN_FILENO) != 1 || isatty(STDOUT_FILENO) != 1 || isatty(STDERR_FILENO) != 1) { CON_Init_tty(); return; } // Initialize curses and set up the root window if (!curses_on) { SCREEN *test = newterm(NULL, stdout, stdin); if (!test) { CON_Init_tty(); CON_Print_tty("Couldn't initialize curses, falling back to tty\n"); return; } endwin(); delscreen(test); initscr(); cbreak(); noecho(); nonl(); intrflush(stdscr, FALSE); nodelay(stdscr, TRUE); keypad(stdscr, TRUE); wnoutrefresh(stdscr); // Set up colors if (has_colors()) { use_default_colors(); start_color(); init_pair(1, COLOR_BLACK, -1); init_pair(2, COLOR_RED, -1); init_pair(3, COLOR_GREEN, -1); init_pair(4, COLOR_YELLOW, -1); init_pair(5, COLOR_BLUE, -1); init_pair(6, COLOR_CYAN, -1); init_pair(7, COLOR_MAGENTA, -1); init_pair(8, -1, -1); } } // Create the border borderwin = newwin(LOG_LINES + 2, LOG_COLS + 2, 1, 0); CON_SetColor(borderwin, 2); box(borderwin, 0, 0); wnoutrefresh(borderwin); // Create the log window logwin = newpad(MAX_LOG_LINES, LOG_COLS); scrollok(logwin, TRUE); idlok(logwin, TRUE); if (curses_on) CON_ColorPrint(logwin, logbuf, qtrue); getyx(logwin, lastline, col); if (col) lastline++; scrollline = lastline - LOG_LINES; if (scrollline < 0) scrollline = 0; pnoutrefresh(logwin, scrollline, 0, 2, 1, LOG_LINES + 1, LOG_COLS + 1); // Create the scroll bar scrollwin = newwin(LOG_LINES, 1, 2, COLS - 1); CON_DrawScrollBar(); CON_SetColor(stdscr, 3); mvaddch(1, COLS - 1, SCRLBAR_UP); mvaddch(LINES - 2, COLS - 1, SCRLBAR_DOWN); // Create the input field inputwin = newwin(1, COLS - Q_PrintStrlen(PROMPT) - 8, LINES - 1, Q_PrintStrlen(PROMPT) + 8); input_field.widthInChars = COLS - Q_PrintStrlen(PROMPT) - 9; if (curses_on) { if (input_field.cursor < input_field.scroll) input_field.scroll = input_field.cursor; else if (input_field.cursor >= input_field.scroll + input_field.widthInChars) input_field.scroll = input_field.cursor - input_field.widthInChars + 1; CON_ColorPrint(inputwin, input_field.buffer + input_field.scroll, qfalse); } CON_UpdateCursor(); wnoutrefresh(inputwin); // Create the clock clockwin = newwin(1, 8, LINES - 1, 0); CON_UpdateClock(); // Display the title and input prompt move(0, (COLS - Q_PrintStrlen(TITLE)) / 2); CON_ColorPrint(stdscr, TITLE, qtrue); move(LINES - 1, 8); CON_ColorPrint(stdscr, PROMPT, qtrue); wnoutrefresh(stdscr); doupdate(); #ifndef _WIN32 // Catch window resizes signal(SIGWINCH, (void *)CON_Resize); #endif curses_on = qtrue; }