//------------------------------------------------------------------------ // Init the plotter //------------------------------------------------------------------------ void CPlotter::Init(CFuiCanva *cn, CFont *fnt, CFuiPopupMenu *pm, CVehicleObject *vh) { font = fnt; pop = pm; cnv = cn; mveh = vh; srf = cnv->GetSurface(); x0 = fnt->CharWidth('H'); y0 = fnt->CharHeight('H'); y1 = cnv->GetHeight(); yL = RealY(y1); yT = yL + y0; // Real top line yB = RealY(y0); // Real bottom line xF = cnv->GetWidth(); scale = 1; //---Compute vertical height ------------------ vht = (y1 - y0); //---Compute horizontal width------------------ hwd = (xF - x0); //----Init color parameters ------------------- green = MakeRGBA (0, 255, 0, 255); red = MakeRGBA (255, 0, 0, 255); //--- Create data menu ------------------------ mveh->AddToPlotMenu(plotMENU,0); pop->CreatePage(&pMEN,plotMENU); pop->SetButtonText((char*)pMEN.aText[0]); //--- No dependent ---------------------------- pPRM.dpnd = 0; return; }
/* ============== SCR_DrawFPS ============== */ void SCR_DrawFPS( void ) { float calc; rgba_t color; static double nexttime = 0, lasttime = 0; static double framerate = 0; static int framecount = 0; static int minfps = 9999; static int maxfps = 0; double newtime; char fpsstring[64]; int offset; if( cls.state != ca_active ) return; if( !cl_showfps->integer || cl.background ) return; switch( cls.scrshot_action ) { case scrshot_normal: case scrshot_snapshot: case scrshot_inactive: break; default: return; } newtime = Sys_DoubleTime(); if( newtime >= nexttime ) { framerate = framecount / (newtime - lasttime); lasttime = newtime; nexttime = max( nexttime + 1, lasttime - 1 ); framecount = 0; } framecount++; calc = framerate; if( calc == 0 ) return; if( calc < 1.0f ) { Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i spf", (int)(1.0f / calc + 0.5f)); MakeRGBA( color, 255, 0, 0, 255 ); } else { int curfps = (int)(calc + 0.5f); if( curfps < minfps ) minfps = curfps; if( curfps > maxfps ) maxfps = curfps; if( cl_showfps->integer == 2 ) Q_snprintf( fpsstring, sizeof( fpsstring ), "fps: ^1%4i min, ^3%4i cur, ^2%4i max", minfps, curfps, maxfps ); else Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i fps", curfps ); MakeRGBA( color, 255, 255, 255, 255 ); } Con_DrawStringLen( fpsstring, &offset, NULL ); Con_DrawString( scr_width->integer - offset - 2, 4, fpsstring, color ); }
/** * Draw a string to the screen. * @param strid String to draw. * @param colour Colour of the text. * @param x X position at the screen. * @param y Y position at the screen. * @param width Maximal width of the text. * @param align Horizontal alignment of the string. * @param outline Whether to make the string "bold" (default false). */ void DrawString(StringID strid, uint8 colour, int x, int y, int width, Alignment align, bool outline) { uint8 buffer[1024]; // Arbitrary limit. DrawText(strid, buffer, lengthof(buffer)); /** \todo Reduce the naiviness of this. */ if (outline) { _video.BlitText(buffer, MakeRGBA(0, 0, 0, OPAQUE), x + 1, y, width, align); _video.BlitText(buffer, MakeRGBA(0, 0, 0, OPAQUE), x, y + 1, width, align); _video.BlitText(buffer, MakeRGBA(0, 0, 0, OPAQUE), x - 1, y, width, align); _video.BlitText(buffer, MakeRGBA(0, 0, 0, OPAQUE), x, y - 1, width, align); } _video.BlitText(buffer, _palette[colour], x, y, width, align); }
bool CGLImageData::LoadTexture(const char *filename) { if (!LoadBMP(filename)) if(!LoadPNG(filename)) { sLog(DEFAULT_LOG_NAME, LOG_WARNING_EV, "Can't load image->"); return false; } else { if (!MakeTexture()) { sLog(DEFAULT_LOG_NAME, LOG_WARNING_EV, "Can't load texture in video adapter."); return false; } } else { if(!MakeRGBA()) { sLog(DEFAULT_LOG_NAME, LOG_WARNING_EV, "Can't load texture."); return false; } if (!MakeTexture()) { sLog(DEFAULT_LOG_NAME, LOG_WARNING_EV, "Can't load texture in video memory."); return false; } } { delete [] data; data = NULL; } return true; }
/* ============== SCR_NetSpeeds same as r_speeds but for network channel ============== */ void SCR_NetSpeeds( void ) { static char msg[MAX_SYSPATH]; int x, y, height; char *p, *start, *end; float time = cl.mtime[0]; rgba_t color; if( !net_speeds->integer ) return; if( cls.state != ca_active ) return; switch( net_speeds->integer ) { case 1: if( cls.netchan.compress ) { Q_snprintf( msg, sizeof( msg ), "Game Time: %02d:%02d\nTotal received from server:\n Huffman %s\nUncompressed %s\n", (int)(time / 60.0f ), (int)fmod( time, 60.0f ), Q_memprint( cls.netchan.total_received ), Q_memprint( cls.netchan.total_received_uncompressed )); } else { Q_snprintf( msg, sizeof( msg ), "Game Time: %02d:%02d\nTotal received from server:\nUncompressed %s\n", (int)(time / 60.0f ), (int)fmod( time, 60.0f ), Q_memprint( cls.netchan.total_received_uncompressed )); } break; case 2: if( cls.netchan.compress ) { Q_snprintf( msg, sizeof( msg ), "Game Time: %02d:%02d\nTotal sended to server:\nHuffman %s\nUncompressed %s\n", (int)(time / 60.0f ), (int)fmod( time, 60.0f ), Q_memprint( cls.netchan.total_sended ), Q_memprint( cls.netchan.total_sended_uncompressed )); } else { Q_snprintf( msg, sizeof( msg ), "Game Time: %02d:%02d\nTotal sended to server:\nUncompressed %s\n", (int)(time / 60.0f ), (int)fmod( time, 60.0f ), Q_memprint( cls.netchan.total_sended_uncompressed )); } break; default: return; } x = scr_width->integer - 320; y = 256; Con_DrawStringLen( NULL, NULL, &height ); MakeRGBA( color, 255, 255, 255, 255 ); p = start = msg; do { end = Q_strchr( p, '\n' ); if( end ) msg[end-start] = '\0'; Con_DrawString( x, y, p, color ); y += height; if( end ) p = end + 1; else break; } while( 1 ); }
/* ================ SCR_RSpeeds ================ */ void SCR_RSpeeds( void ) { char msg[MAX_SYSPATH]; if( R_SpeedsMessage( msg, sizeof( msg ))) { int x, y, height; char *p, *start, *end; rgba_t color; x = scr_width->integer - 320; y = 64; Con_DrawStringLen( NULL, NULL, &height ); MakeRGBA( color, 255, 255, 255, 255 ); p = start = msg; do { end = Q_strchr( p, '\n' ); if( end ) msg[end-start] = '\0'; Con_DrawString( x, y, p, color ); y += height; if( end ) p = end + 1; else break; } while( 1 ); } }
/* ============== SCR_DrawPos Draw local player position, angles and velocity ============== */ void SCR_DrawPos( void ) { static char msg[MAX_SYSPATH]; float speed; cl_entity_t *pPlayer; rgba_t color; if( cls.state != ca_active ) return; if( !cl_showpos->integer || cl.background ) return; pPlayer = CL_GetLocalPlayer(); speed = VectorLength( cl.frame.local.client.velocity ); Q_snprintf( msg, MAX_SYSPATH, "pos: %.2f %.2f %.2f\n" "ang: %.2f %.2f %.2f\n" "velocity: %.2f", pPlayer->origin[0], pPlayer->origin[1], pPlayer->origin[2], pPlayer->angles[0], pPlayer->angles[1], pPlayer->angles[2], speed ); MakeRGBA( color, 255, 255, 255, 255 ); Con_DrawString( scr_width->integer / 2, 4, msg, color ); }
void R_Strobe_DrawDebugInfo( void ) { rgba_t color; int offsetY; int fixer; double curTime = Sys_DoubleTime( ); static double oldTime = 0; static int offsetX = 0; static char debugStr[2048] = {0}; if ( !r_strobe->integer ) return; if ( cls.state != ca_active ) return; if ( ( !r_strobe_debug->integer && !cl_showfps->integer ) || cl.background ) return; /* switch ( cls.scrshot_action ) { case scrshot_normal: case scrshot_snapshot: case scrshot_inactive: break; default: return; } */ if ( r_strobe_debug->integer ) { if ( ( curTime - oldTime > 0.100 ) ) { _generateDebugInfo( debugStr, sizeof( debugStr ) ); oldTime = curTime; } } else if ( cl_showfps->integer ) { Q_snprintf( debugStr, sizeof( debugStr ), "%3d eFPS", (int)round( _effectiveFPS( ) ) ); } MakeRGBA( color, 255, 255, 255, 255 ); Con_DrawStringLen( debugStr, &fixer, &offsetY ); if ( r_strobe_debug->integer ) Con_DrawString( scr_width->integer - offsetX - 50, 4, debugStr, color ); else Con_DrawString( scr_width->integer - offsetX - 2, offsetY + 8, debugStr, color ); if ( abs( fixer - offsetX ) > 50 || offsetX == 0 ) // 50 is for 1080p ! offsetX = fixer; }
/* ============== SCR_DrawFPS ============== */ void SCR_DrawFPS( void ) { float calc; rgba_t color; static double nexttime = 0, lasttime = 0; static double framerate = 0; static int framecount = 0; double newtime; char fpsstring[32]; if( cls.state != ca_active ) return; if( !cl_showfps->integer || cl.background ) return; if( cls.scrshot_action != scrshot_inactive ) return; newtime = Sys_DoubleTime(); if( newtime >= nexttime ) { framerate = framecount / (newtime - lasttime); lasttime = newtime; nexttime = max( nexttime + 1, lasttime - 1 ); framecount = 0; } framecount++; calc = framerate; if( calc < 1.0f ) { Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i spf", (int)(1.0f / calc + 0.5)); MakeRGBA( color, 255, 0, 0, 255 ); } else { Q_snprintf( fpsstring, sizeof( fpsstring ), "%4i fps", (int)(calc + 0.5)); MakeRGBA( color, 255, 255, 255, 255 ); } Con_DrawString( scr_width->integer - 68, 4, fpsstring, color ); }
/** * Redraw (parts of) the windows. * @todo [medium/difficult] Do this much less stupid. * @ingroup window_group */ void WindowManager::UpdateWindows() { if (!_video.DisplayNeedsRepaint()) return; /* Until the entire background is covered by the main display, clean the entire display to ensure deleted * windows truly disappear (even if there is no other window behind it). */ Rectangle32 rect(0, 0, _video.GetXSize(), _video.GetYSize()); _video.FillRectangle(rect, MakeRGBA(0, 0, 0, OPAQUE)); GuiWindow *sel_window = this->GetSelector(); MouseModeSelector *selector = (sel_window == nullptr) ? nullptr : sel_window->selector; for (Window *w = this->bottom; w != nullptr; w = w->higher) w->OnDraw(selector); _video.FinishRepaint(); }
/** * Redraw (parts of) the windows. * @todo [medium/difficult] Do this much less stupid. * @ingroup window_group */ void UpdateWindows() { if (!_video.DisplayNeedsRepaint()) return; /* Until the entire background is covered by the main display, clean the entire display to ensure deleted * windows truly disappear (even if there is no other window behind it). */ Rectangle32 rect(0, 0, _video.GetXSize(), _video.GetYSize()); _video.FillRectangle(rect, MakeRGBA(0, 0, 0, OPAQUE)); Window *w = _window_manager.bottom; while (w != nullptr) { w->OnDraw(); w = w->higher; } _video.FinishRepaint(); }
//===================================================================================== // Window to control camera //===================================================================================== CFuiCamControl::CFuiCamControl(Tag idn, const char *filename) :CFuiWindow(idn,filename,240,180,0) { SetProperty(FUI_TRANSPARENT); SetProperty(FUI_NO_BORDER); //---- Set the back bitmap ---------------------- SetBackPicture("CamControl.bmp"); CFuiWindow::ReadFinished(); //----Create all buttons ------------------------ U_INT col = MakeRGBA(255,255,255,255); lrot = new CFuiLabel (43,48,47,19,this); lrot->RazProperty(FUI_NO_BORDER); lrot->SetColour(col); AddChild('lrot',lrot,""); rtlf = new CFuiButton( 6,48,36,20,this); AddChild('rtlf',rtlf,"-",FUI_REPEAT_BT); rtrt = new CFuiButton(91,48,36,20,this); AddChild('rtrt',rtrt,"+",FUI_REPEAT_BT); rtup = new CFuiButton(40,26,52,20,this); AddChild('rtup',rtup,"+",FUI_REPEAT_BT); rtdn = new CFuiButton(40,68,52,20,this); AddChild('rtdn',rtdn,"-",FUI_REPEAT_BT); //----Create range items ------------------------ lrng = new CFuiLabel (168,48,36,19,this); lrng->RazProperty(FUI_NO_BORDER); lrng->SetColour(col); AddChild('lrng',lrng,""); rnut = new CFuiButton(168,26,36,20,this); AddChild('rnut',rnut,"+",FUI_REPEAT_BT); rnin = new CFuiButton(168,68,36,20,this); AddChild('rnin',rnin,"-",FUI_REPEAT_BT); //----Create zoom items ------------------------- lzom = new CFuiLabel (101,130,38,19,this); lzom->RazProperty(FUI_NO_BORDER); lzom->SetColour(col); AddChild('lzom',lzom,""); zmin = new CFuiButton( 64,129,36,20,this); AddChild('zmin',zmin,"-",FUI_REPEAT_BT); zmup = new CFuiButton(140,129,36,20,this); AddChild('zmup',zmup,"+",FUI_REPEAT_BT); }
//======================================================================================= // CFuiStat: Display statistic info //======================================================================================= CFuiStat::CFuiStat(Tag idn, const char *filename) :CFuiWindow(idn,filename,240,400,0) { strncpy(text,"SYSTEM STATISTICS",255); title = 1; close = 1; zoom = 0; mini = 0; U_INT wit = MakeRGBA(255,255,255,255); SetTransparentMode(); //--------Create info canvas ------------------------------ info = new CFuiCanva(10,10,220,380,this); AddChild('info',info,"",FUI_TRANSPARENT,wit); //--------Display subsystems ------------------------------ CFuiWindow::ReadFinished(); //-------------------------------------------------- CVehicleObject *veh = globals->pln; pit = (veh)?(veh->GetPIT()):(0); tcm = globals->tcm; txw = globals->txw; m3d = globals->m3d; dbc = globals->dbc; }
void GuiWindow::OnDraw(MouseModeSelector *selector) { this->tree->Draw(this); if ((this->flags & WF_HIGHLIGHT) != 0) _video.DrawRectangle(this->rect, MakeRGBA(255, 255, 255, OPAQUE)); }
void CImageBMP::DrawToSurface (SSurface* surface, int x, int y) { // Check that valid image data exists if (image == NULL) { WARNINGLOG ("CImageBMP::DrawToSurface : NULL image data for %s", filename); return; } int sybase = surface->ySize - y - ih.h; // Copy pixel by pixel unsigned long i, j; unsigned long imageOffset, sx, sy; for (i=0; i<ih.h; i++) { for (j=0; j<ih.w; j++) { switch (ih.nPlanes) { case 1: // 24-bit RGB data { imageOffset = ((i * ih.w) + j) * 3; GLubyte r = image[imageOffset]; GLubyte g = image[imageOffset+1]; GLubyte b = image[imageOffset+2]; GLubyte a = 0xFF; unsigned int rgba = MakeRGBA (r, g, b, a); sx = x+j; sy = sybase+i; if ((sx >= 0) && (sx < (int)surface->xSize) && (sy >= 0) && (sy < (int)surface->ySize)) { unsigned long surfOffset = (sy * surface->xSize) + sx; surface->drawBuffer[surfOffset] = rgba; } } break; case 3: // Pallettized data { imageOffset = (i * ih.w) + j; GLubyte cmapIndex = image[imageOffset]; GLubyte b = cmap[cmapIndex]; GLubyte g = cmap[cmapIndex+1]; GLubyte r = cmap[cmapIndex+2]; GLubyte a = 0xFF; unsigned int rgba = MakeRGBA (r, g, b, a); sx = x+j; sy = sybase+i; if ((sx >= 0) && (sx < (int)surface->xSize) && (sy >= 0) && (sy < (int)surface->ySize)) { unsigned long surfOffset = (sy * surface->xSize) + sx; surface->drawBuffer[surfOffset] = rgba; } } break; } } } }