Drastic dmap speed boost by reducing prints like in q3map

This commit is contained in:
Robert Beckebans 2024-06-21 18:01:12 +02:00
parent f925217a69
commit c5e5cfeae7
18 changed files with 441 additions and 334 deletions

View file

@ -260,6 +260,9 @@ public:
// and NEVER forces a screen update, which could cause reentrancy problems.
virtual void DPrintf( VERIFY_FORMAT_STRING const char* fmt, ... ) = 0;
// Same as Printf but tool specific to discard most of dmap's output
virtual void VerbosePrintf( VERIFY_FORMAT_STRING const char* fmt, ... ) = 0;
// Prints WARNING %s message and adds the warning message to a queue for printing later on.
virtual void Warning( VERIFY_FORMAT_STRING const char* fmt, ... ) = 0;
@ -357,6 +360,11 @@ public:
virtual void LoadPacifierBinarizeEnd() = 0;
virtual void LoadPacifierBinarizeProgressTotal( int total ) = 0;
virtual void LoadPacifierBinarizeProgressIncrement( int step ) = 0;
virtual void DmapPacifierFilename( const char* filename, const char* reason ) = 0;
virtual void DmapPacifierInfo( VERIFY_FORMAT_STRING const char* fmt, ... ) = 0;
virtual void DmapPacifierCompileProgressTotal( int total ) = 0;
virtual void DmapPacifierCompileProgressIncrement( int step ) = 0;
};
extern idCommon* common;

View file

@ -169,6 +169,7 @@ public:
virtual void Printf( VERIFY_FORMAT_STRING const char* fmt, ... ) ID_INSTANCE_ATTRIBUTE_PRINTF( 1, 2 );
virtual void VPrintf( const char* fmt, va_list arg );
virtual void DPrintf( VERIFY_FORMAT_STRING const char* fmt, ... ) ID_INSTANCE_ATTRIBUTE_PRINTF( 1, 2 );
virtual void VerbosePrintf( VERIFY_FORMAT_STRING const char* fmt, ... ) ID_INSTANCE_ATTRIBUTE_PRINTF( 1, 2 );
virtual void Warning( VERIFY_FORMAT_STRING const char* fmt, ... ) ID_INSTANCE_ATTRIBUTE_PRINTF( 1, 2 );
virtual void DWarning( VERIFY_FORMAT_STRING const char* fmt, ... ) ID_INSTANCE_ATTRIBUTE_PRINTF( 1, 2 );
virtual void PrintWarnings();
@ -443,14 +444,19 @@ public:
// some cases, which includes filename and ETA information, note that
// the progress function takes 0-1 float, not 0-100, and can be called
// very quickly (it will check that enough time has passed when updating)
void LoadPacifierBinarizeFilename( const char* filename, const char* reason );
void LoadPacifierBinarizeInfo( const char* info );
void LoadPacifierBinarizeMiplevel( int level, int maxLevel );
void LoadPacifierBinarizeProgress( float progress );
void LoadPacifierBinarizeEnd();
virtual void LoadPacifierBinarizeFilename( const char* filename, const char* reason );
virtual void LoadPacifierBinarizeInfo( const char* info );
virtual void LoadPacifierBinarizeMiplevel( int level, int maxLevel );
virtual void LoadPacifierBinarizeProgress( float progress );
virtual void LoadPacifierBinarizeEnd();
// for images in particular we can measure more accurately this way (to deal with mipmaps)
void LoadPacifierBinarizeProgressTotal( int total );
void LoadPacifierBinarizeProgressIncrement( int step );
virtual void LoadPacifierBinarizeProgressTotal( int total );
virtual void LoadPacifierBinarizeProgressIncrement( int step );
virtual void DmapPacifierFilename( const char* filename, const char* reason ) {};
virtual void DmapPacifierInfo( VERIFY_FORMAT_STRING const char* fmt, ... ) {};
virtual void DmapPacifierCompileProgressTotal( int total ) {};
virtual void DmapPacifierCompileProgressIncrement( int step ) {};
frameTiming_t frameTiming;
frameTiming_t mainFrameTiming;

View file

@ -282,6 +282,26 @@ void idCommonLocal::Printf( const char* fmt, ... )
va_end( argptr );
}
/*
==================
idCommonLocal::Printf
RB: only for dmap and AAS builder
==================
*/
void idCommonLocal::VerbosePrintf( const char* fmt, ... )
{
if( !dmap_verbose.GetBool() )
{
return;
}
va_list argptr;
va_start( argptr, fmt );
VPrintf( fmt, argptr );
va_end( argptr );
}
/*
==================
idCommonLocal::DPrintf

View file

@ -1215,7 +1215,10 @@ idMapEntity* idMapEntity::Parse( idLexer& src, bool worldSpawn, int version )
}
while( 1 );
mapEnt->CalculateBrushOrigin();
if( version == 220 )
{
mapEnt->CalculateBrushOrigin();
}
return mapEnt;
}

View file

@ -668,10 +668,12 @@ void idImage::FinalizeImage( bool fromBackEnd, nvrhi::ICommandList* commandList
binaryFileTime = im.WriteGeneratedFile( sourceFileTime );
}
#if !defined( DMAP )
if( !commandList )
{
return;
}
#endif
AllocImage();

View file

@ -839,6 +839,8 @@ bool idAASBuild::Build( const idStr& fileName, const idAASSettings* settings )
return false;
}
common->DmapPacifierFilename( name, "Compiling AAS files" );
// check if this map has any entities that use this AAS file
if( !CheckForEntities( mapFile, entityClassNames ) )
{
@ -968,6 +970,7 @@ bool idAASBuild::Build( const idStr& fileName, const idAASSettings* settings )
delete mapFile;
common->Printf( "%6d seconds to create AAS\n", ( Sys_Milliseconds() - startTime ) / 1000 );
common->DmapPacifierInfo( "%6d seconds to create AAS\n", ( Sys_Milliseconds() - startTime ) / 1000 );
return true;
}

View file

@ -1000,13 +1000,14 @@ idAASReach::Build
*/
bool idAASReach::Build( const idMapFile* mapFile, idAASFileLocal* file )
{
int i, j, lastPercent, percent;
int i, j, lastPercent;
this->mapFile = mapFile;
this->file = file;
numReachabilities = 0;
common->Printf( "[Reachability]\n" );
common->DmapPacifierInfo( "[Reachability]\n" );
// delete all existing reachabilities
file->DeleteReachabilities();
@ -1026,8 +1027,10 @@ bool idAASReach::Build( const idMapFile* mapFile, idAASFileLocal* file )
Reachability_EqualFloorHeight( i );
}
common->DmapPacifierCompileProgressTotal( file->areas.Num() - 1 );
lastPercent = -1;
for( i = 1; i < file->areas.Num(); i++ )
for( i = 1; i < file->areas.Num(); i++, common->DmapPacifierCompileProgressIncrement( 1 ) )
{
if( !( file->areas[i].flags & AREA_REACHABLE_WALK ) )
@ -1059,12 +1062,14 @@ bool idAASReach::Build( const idMapFile* mapFile, idAASFileLocal* file )
//Reachability_WalkOffLedge( i );
percent = 100 * i / file->areas.Num();
#if !defined( DMAP )
int percent = 100 * i / file->areas.Num();
if( percent > lastPercent )
{
common->Printf( "\r%6d%%", percent );
lastPercent = percent;
}
#endif
}
if( file->GetSettings().allowFlyReachabilities )

View file

@ -37,6 +37,8 @@ If you have questions concerning this license or the applicable additional terms
===============================================================================
*/
extern idCVar dmap_verbose;
// map processing (also see SuperOptimizeOccluders in tr_local.h)
void Dmap_f( const idCmdArgs& args );

View file

@ -32,6 +32,8 @@ If you have questions concerning this license or the applicable additional terms
#include "dmap.h"
idCVar dmap_verbose( "dmap_verbose", "0", CVAR_BOOL | CVAR_SYSTEM, "dmap developer mode" );
dmapGlobals_t dmapGlobals;
/*
@ -133,21 +135,31 @@ ProcessModels
*/
bool ProcessModels()
{
bool oldVerbose;
uEntity_t* entity;
bool oldVerbose = dmap_verbose.GetBool();
oldVerbose = dmapGlobals.verbose;
common->DmapPacifierCompileProgressTotal( dmapGlobals.num_entities );
for( dmapGlobals.entityNum = 0 ; dmapGlobals.entityNum < dmapGlobals.num_entities ; dmapGlobals.entityNum++ )
idStrStatic<128> entityInfo;
for( dmapGlobals.entityNum = 0; dmapGlobals.entityNum < dmapGlobals.num_entities; dmapGlobals.entityNum++, common->DmapPacifierCompileProgressIncrement( 1 ) )
{
entity = &dmapGlobals.uEntities[dmapGlobals.entityNum];
uEntity_t* entity = &dmapGlobals.uEntities[dmapGlobals.entityNum];
if( !entity->primitives )
{
continue;
}
common->Printf( "############### entity %i ###############\n", dmapGlobals.entityNum );
//ImGui::Text( " Source code :
if( dmapGlobals.entityNum == 0 )
{
common->DmapPacifierInfo( "Current entity : worldspawn" );
}
else
{
common->DmapPacifierInfo( "Current entity : %s", entity->mapEntity->epairs.GetString( "name" ) );
}
//common->Printf( "############### entity %i ###############\n", dmapGlobals.entityNum );
// if we leaked, stop without any more processing
if( !ProcessModel( entity, ( bool )( dmapGlobals.entityNum == 0 ) ) )
@ -159,11 +171,11 @@ bool ProcessModels()
// something strange is going on
if( !dmapGlobals.verboseentities )
{
dmapGlobals.verbose = false;
dmap_verbose.SetBool( false );
}
}
dmapGlobals.verbose = oldVerbose;
dmap_verbose.SetBool( oldVerbose );
return true;
}
@ -200,7 +212,6 @@ void ResetDmapGlobals()
dmapGlobals.uEntities = NULL;
dmapGlobals.entityNum = 0;
dmapGlobals.mapLights.Clear();
dmapGlobals.verbose = false;
dmapGlobals.glview = false;
dmapGlobals.asciiTree = false;
dmapGlobals.noOptimize = false;
@ -279,7 +290,7 @@ void Dmap( const idCmdArgs& args )
else if( !idStr::Icmp( s, "v" ) || !idStr::Icmp( s, "verbose" ) )
{
common->Printf( "verbose = true\n" );
dmapGlobals.verbose = true;
dmap_verbose.SetBool( true );
}
else if( !idStr::Icmp( s, "draw" ) )
{
@ -373,6 +384,8 @@ void Dmap( const idCmdArgs& args )
passedName = "maps/" + passedName;
}
common->DmapPacifierFilename( passedName, "Compiling BSP .proc" );
idStr stripped = passedName;
stripped.StripFileExtension();
idStr::Copynz( dmapGlobals.mapFileBase, stripped, sizeof( dmapGlobals.mapFileBase ) );
@ -444,6 +457,7 @@ void Dmap( const idCmdArgs& args )
end = Sys_Milliseconds();
common->Printf( "-----------------------\n" );
common->Printf( "%5.0f seconds for dmap\n", ( end - start ) * 0.001f );
common->DmapPacifierInfo( "%5.0f seconds for dmap\n", ( end - start ) * 0.001f );
if( !leaked )
{
@ -454,6 +468,8 @@ void Dmap( const idCmdArgs& args )
cmdSystem->BufferCommandText( CMD_EXEC_NOW, "disconnect" );
#endif
common->DmapPacifierFilename( passedName, "Generating .cm collision map" );
// create the collision map
start = Sys_Milliseconds();
@ -464,6 +480,7 @@ void Dmap( const idCmdArgs& args )
end = Sys_Milliseconds();
common->Printf( "-------------------------------------\n" );
common->Printf( "%5.0f seconds to create collision map\n", ( end - start ) * 0.001f );
common->DmapPacifierInfo( "%5.0f seconds to create collision map\n", ( end - start ) * 0.001f );
}
if( !noAAS && !region )
@ -473,6 +490,8 @@ void Dmap( const idCmdArgs& args )
}
}
common->DmapPacifierFilename( passedName, "Done" );
// free the common .map representation
delete dmapGlobals.dmapFile;

View file

@ -278,8 +278,6 @@ typedef struct
idList<mapLight_t*> mapLights;
bool verbose;
bool glview;
bool asciiTree; // BSP tree visualization in the .proc file
bool noOptimize;

View file

@ -434,7 +434,7 @@ tree_t* FaceBSP( bspface_t* list )
start = Sys_Milliseconds();
common->Printf( "--- FaceBSP ---\n" );
common->VerbosePrintf( "--- FaceBSP ---\n" );
tree = AllocTree();
@ -448,7 +448,7 @@ tree_t* FaceBSP( bspface_t* list )
tree->bounds.AddPoint( ( *face->w )[i].ToVec3() );
}
}
common->Printf( "%5i faces\n", count );
common->VerbosePrintf( "%5i faces\n", count );
tree->headnode = AllocNode();
tree->headnode->bounds = tree->bounds;
@ -456,11 +456,11 @@ tree_t* FaceBSP( bspface_t* list )
BuildFaceTree_r( tree->headnode, list );
common->Printf( "%5i leafs\n", c_faceLeafs );
common->VerbosePrintf( "%5i leafs\n", c_faceLeafs );
end = Sys_Milliseconds();
common->Printf( "%5.1f seconds faceBsp\n", ( end - start ) / 1000.0 );
common->VerbosePrintf( "%5.1f seconds faceBsp\n", ( end - start ) / 1000.0 );
return tree;
}

View file

@ -349,7 +349,9 @@ static void ParseBrush( const idMapBrush* mapBrush, int primitiveNum )
// RB: Valve 220 projection support
s->texValve220 = ( ms->GetProjectionType() == idMapBrushSide::PROJECTION_VALVE220 );
// RB: TODO
// RB: we don't need this info if we are actually compiling maps in the original format
// we only load this for the engine in the case we want to convert it to the Valve 220 format
#if !defined( DMAP )
s->texSize = ms->GetTextureSize();
idImage* image = s->material->GetEditorImage();
@ -358,6 +360,7 @@ static void ParseBrush( const idMapBrush* mapBrush, int primitiveNum )
s->texSize.x = image->GetUploadWidth();
s->texSize.y = image->GetUploadHeight();
}
#endif
// RB end
// remove any integral shift, which will help with grouping

View file

@ -670,11 +670,8 @@ static void AddInteriorEdges( optIsland_t* island )
}
}
if( dmapGlobals.verbose )
{
common->Printf( "%6i tested segments\n", numLengths );
common->Printf( "%6i added interior edges\n", c_addedEdges );
}
common->VerbosePrintf( "%6i tested segments\n", numLengths );
common->VerbosePrintf( "%6i added interior edges\n", c_addedEdges );
Mem_Free( lengths );
}
@ -743,7 +740,7 @@ static void RemoveIfColinear( optVertex_t* ov, optIsland_t* island )
{
// this may still happen legally when a tiny triangle is
// the only thing in a group
common->Printf( "WARNING: vertex with only one edge\n" );
common->VerbosePrintf( "WARNING: vertex with only one edge\n" );
return;
}
@ -879,10 +876,7 @@ static void CombineColinearEdges( optIsland_t* island )
{
c_edges++;
}
if( dmapGlobals.verbose )
{
common->Printf( "%6i original exterior edges\n", c_edges );
}
common->VerbosePrintf( "%6i original exterior edges\n", c_edges );
for( ov = island->verts ; ov ; ov = ov->islandLink )
{
@ -894,10 +888,7 @@ static void CombineColinearEdges( optIsland_t* island )
{
c_edges++;
}
if( dmapGlobals.verbose )
{
common->Printf( "%6i optimized exterior edges\n", c_edges );
}
common->VerbosePrintf( "%6i optimized exterior edges\n", c_edges );
}
@ -1047,7 +1038,7 @@ static void LinkTriToEdge( optTri_t* optTri, optEdge_t* edge )
{
if( edge->backTri )
{
common->Printf( "Warning: LinkTriToEdge: already in use\n" );
common->VerbosePrintf( "Warning: LinkTriToEdge: already in use\n" );
return;
}
edge->backTri = optTri;
@ -1059,7 +1050,7 @@ static void LinkTriToEdge( optTri_t* optTri, optEdge_t* edge )
{
if( edge->frontTri )
{
common->Printf( "Warning: LinkTriToEdge: already in use\n" );
common->VerbosePrintf( "Warning: LinkTriToEdge: already in use\n" );
return;
}
edge->frontTri = optTri;
@ -1154,7 +1145,7 @@ static void CreateOptTri( optVertex_t* first, optEdge_t* e1, optEdge_t* e2, optI
if( !opposite )
{
common->Printf( "Warning: BuildOptTriangles: couldn't locate opposite\n" );
common->VerbosePrintf( "Warning: BuildOptTriangles: couldn't locate opposite\n" );
return;
}
@ -1441,7 +1432,7 @@ static void RegenerateTriangles( optIsland_t* island )
{
// this can happen reasonably when a triangle is nearly degenerate in
// optimization planar space, and winds up being degenerate in 3D space
common->Printf( "WARNING: backwards triangle generated!\n" );
common->VerbosePrintf( "WARNING: backwards triangle generated!\n" );
// discard it
FreeTri( tri );
continue;
@ -1454,10 +1445,7 @@ static void RegenerateTriangles( optIsland_t* island )
FreeOptTriangles( island );
if( dmapGlobals.verbose )
{
common->Printf( "%6i tris out\n", c_out );
}
common->VerbosePrintf( "%6i tris out\n", c_out );
}
//===========================================================================
@ -1512,11 +1500,8 @@ static void RemoveInteriorEdges( optIsland_t* island )
c_exteriorEdges++;
}
if( dmapGlobals.verbose )
{
common->Printf( "%6i original interior edges\n", c_interiorEdges );
common->Printf( "%6i original exterior edges\n", c_exteriorEdges );
}
common->VerbosePrintf( "%6i original interior edges\n", c_interiorEdges );
common->VerbosePrintf( "%6i original exterior edges\n", c_exteriorEdges );
}
//==================================================================================
@ -1622,7 +1607,7 @@ static void AddOriginalTriangle( optVertex_t* v[3] )
// ignore it completely
if( !IsTriangleValid( v[0], v[1], v[2] ) )
{
common->Printf( "WARNING: backwards triangle in input!\n" );
common->VerbosePrintf( "WARNING: backwards triangle in input!\n" );
return;
}
@ -1672,11 +1657,8 @@ static void AddOriginalEdges( optimizeGroup_t* opt )
optVertex_t* v[3];
int numTris;
if( dmapGlobals.verbose )
{
common->Printf( "----\n" );
common->Printf( "%6i original tris\n", CountTriList( opt->triList ) );
}
common->VerbosePrintf( "----\n" );
common->VerbosePrintf( "%6i original tris\n", CountTriList( opt->triList ) );
optBounds.Clear();
@ -1907,13 +1889,10 @@ void SplitOriginalEdgesAtCrossings( optimizeGroup_t* opt )
}
}
if( dmapGlobals.verbose )
{
common->Printf( "%6i original edges\n", numOriginalEdges );
common->Printf( "%6i edges after splits\n", numOptEdges );
common->Printf( "%6i original vertexes\n", numOriginalVerts );
common->Printf( "%6i vertexes after splits\n", numOptVerts );
}
common->VerbosePrintf( "%6i original edges\n", numOriginalEdges );
common->VerbosePrintf( "%6i edges after splits\n", numOptEdges );
common->VerbosePrintf( "%6i original vertexes\n", numOriginalVerts );
common->VerbosePrintf( "%6i vertexes after splits\n", numOptVerts );
}
//=================================================================
@ -1968,11 +1947,8 @@ static void CullUnusedVerts( optIsland_t* island )
}
}
if( dmapGlobals.verbose )
{
common->Printf( "%6i verts kept\n", c_keep );
common->Printf( "%6i verts freed\n", c_free );
}
common->VerbosePrintf( "%6i verts kept\n", c_keep );
common->VerbosePrintf( "%6i verts freed\n", c_free );
}
@ -2195,10 +2171,10 @@ void OptimizeGroupList( optimizeGroup_t* groupList )
SetGroupTriPlaneNums( groupList );
common->Printf( "----- OptimizeAreaGroups Results -----\n" );
common->Printf( "%6i tris in\n", c_in );
common->Printf( "%6i tris after edge removal optimization\n", c_edge );
common->Printf( "%6i tris after final t junction fixing\n", c_tjunc2 );
common->VerbosePrintf( "----- OptimizeAreaGroups Results -----\n" );
common->VerbosePrintf( "%6i tris in\n", c_in );
common->VerbosePrintf( "%6i tris after edge removal optimization\n", c_edge );
common->VerbosePrintf( "%6i tris after final t junction fixing\n", c_tjunc2 );
}
@ -2211,7 +2187,7 @@ void OptimizeEntity( uEntity_t* e )
{
int i;
common->Printf( "----- OptimizeEntity -----\n" );
common->VerbosePrintf( "----- OptimizeEntity -----\n" );
for( i = 0 ; i < e->numAreas ; i++ )
{
OptimizeGroupList( e->areas[i].groups );

View file

@ -535,7 +535,8 @@ void MakeTreePortals_r( node_t* node )
if( node->bounds[0][0] >= node->bounds[1][0] )
{
common->Warning( "node without a volume" );
common->VerbosePrintf( "Warning: node without a volume" );
//common->Warning( "node without a volume" );
}
for( i = 0; i < 3; i++ )
@ -565,7 +566,7 @@ MakeTreePortals
*/
void MakeTreePortals( tree_t* tree )
{
common->Printf( "----- MakeTreePortals -----\n" );
common->VerbosePrintf( "----- MakeTreePortals -----\n" );
MakeHeadnodePortals( tree );
MakeTreePortals_r( tree->headnode );
}
@ -968,7 +969,7 @@ void FindAreas_r( node_t* node )
c_areaFloods = 0;
FloodAreas_r( node );
common->Printf( "area %i has %i leafs\n", c_areas, c_areaFloods );
common->VerbosePrintf( "area %i has %i leafs\n", c_areas, c_areaFloods );
c_areas++;
}
@ -1195,7 +1196,10 @@ Sets e->areas.numAreas
*/
void FloodAreas( uEntity_t* e )
{
common->Printf( "--- FloodAreas ---\n" );
if( e == &dmapGlobals.uEntities[0] )
{
common->Printf( "--- FloodAreas ---\n" );
}
// set all areas to -1
ClearAreas_r( e->tree->headnode );
@ -1204,7 +1208,10 @@ void FloodAreas( uEntity_t* e )
c_areas = 0;
FindAreas_r( e->tree->headnode );
common->Printf( "%5i areas\n", c_areas );
if( e == &dmapGlobals.uEntities[0] )
{
common->Printf( "%5i areas\n", c_areas );
}
e->numAreas = c_areas;
// make sure we got all of them

View file

@ -540,11 +540,8 @@ void FixAreaGroupsTjunctions( optimizeGroup_t* groupList )
startCount = CountGroupListTris( groupList );
if( dmapGlobals.verbose )
{
common->Printf( "----- FixAreaGroupsTjunctions -----\n" );
common->Printf( "%6i triangles in\n", startCount );
}
common->VerbosePrintf( "----- FixAreaGroupsTjunctions -----\n" );
common->VerbosePrintf( "%6i triangles in\n", startCount );
HashTriangles( groupList );
@ -567,10 +564,7 @@ void FixAreaGroupsTjunctions( optimizeGroup_t* groupList )
}
endCount = CountGroupListTris( groupList );
if( dmapGlobals.verbose )
{
common->Printf( "%6i triangles out\n", endCount );
}
common->VerbosePrintf( "%6i triangles out\n", endCount );
}
@ -603,7 +597,7 @@ void FixGlobalTjunctions( uEntity_t* e )
optimizeGroup_t* group;
int areaNum;
common->Printf( "----- FixGlobalTjunctions -----\n" );
common->VerbosePrintf( "----- FixGlobalTjunctions -----\n" );
// clear the hash tables
memset( hashVerts, 0, sizeof( hashVerts ) );

View file

@ -488,7 +488,7 @@ void FilterBrushesIntoTree( uEntity_t* e )
int r;
int c_unique, c_clusters;
common->Printf( "----- FilterBrushesIntoTree -----\n" );
common->VerbosePrintf( "----- FilterBrushesIntoTree -----\n" );
c_unique = 0;
c_clusters = 0;
@ -505,8 +505,8 @@ void FilterBrushesIntoTree( uEntity_t* e )
c_clusters += r;
}
common->Printf( "%5i total brushes\n", c_unique );
common->Printf( "%5i cluster references\n", c_clusters );
common->VerbosePrintf( "%5i total brushes\n", c_unique );
common->VerbosePrintf( "%5i cluster references\n", c_clusters );
}

View file

@ -402,7 +402,7 @@ void ClipSidesByTree( uEntity_t* e )
side_t* side;
primitive_t* prim;
common->Printf( "----- ClipSidesByTree -----\n" );
common->VerbosePrintf( "----- ClipSidesByTree -----\n" );
for( prim = e->primitives ; prim ; prim = prim->next )
{
@ -710,7 +710,7 @@ void PutPrimitivesInAreas( uEntity_t* e )
primitive_t* prim;
mapTri_t* tri;
common->Printf( "----- PutPrimitivesInAreas -----\n" );
common->VerbosePrintf( "----- PutPrimitivesInAreas -----\n" );
// allocate space for surface chains for each area
e->areas = ( uArea_t* )Mem_Alloc( e->numAreas * sizeof( e->areas[0] ), TAG_TOOLS );
@ -901,7 +901,7 @@ void FilterMeshesIntoTree( uEntity_t* e )
int r;
int c_unique, c_clusters;
common->Printf( "----- FilterMeshesIntoTree -----\n" );
common->VerbosePrintf( "----- FilterMeshesIntoTree -----\n" );
c_unique = 0;
c_clusters = 0;
@ -924,8 +924,8 @@ void FilterMeshesIntoTree( uEntity_t* e )
}
}
common->Printf( "%5i total BSP triangles\n", c_unique );
common->Printf( "%5i cluster references\n", c_clusters );
common->VerbosePrintf( "%5i total BSP triangles\n", c_unique );
common->VerbosePrintf( "%5i cluster references\n", c_clusters );
}
// RB end
@ -1165,7 +1165,7 @@ void Prelight( uEntity_t* e )
if( dmapGlobals.shadowOptLevel > 0 )
{
common->Printf( "----- BuildLightShadows -----\n" );
common->VerbosePrintf( "----- BuildLightShadows -----\n" );
start = Sys_Milliseconds();
// calc bounds for all the groups to speed things up
@ -1180,13 +1180,13 @@ void Prelight( uEntity_t* e )
}
end = Sys_Milliseconds();
common->Printf( "%5.1f seconds for BuildLightShadows\n", ( end - start ) / 1000.0 );
common->VerbosePrintf( "%5.1f seconds for BuildLightShadows\n", ( end - start ) / 1000.0 );
}
if( !dmapGlobals.noLightCarve )
{
common->Printf( "----- CarveGroupsByLight -----\n" );
common->VerbosePrintf( "----- CarveGroupsByLight -----\n" );
start = Sys_Milliseconds();
// now subdivide the optimize groups into additional groups for
// each light that illuminates them
@ -1197,7 +1197,7 @@ void Prelight( uEntity_t* e )
}
end = Sys_Milliseconds();
common->Printf( "%5.1f seconds for CarveGroupsByLight\n", ( end - start ) / 1000.0 );
common->VerbosePrintf( "%5.1f seconds for CarveGroupsByLight\n", ( end - start ) / 1000.0 );
}
}

View file

@ -3,6 +3,7 @@
Doom 3 GPL Source Code
Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
Copyright (C) 2024 Robert Beckebans
This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
@ -39,7 +40,6 @@ If you have questions concerning this license or the applicable additional terms
#include "imtui/imtui-impl-ncurses.h"
#include "imtui/imtui-demo.h"
idEventLoop* eventLoop;
@ -52,16 +52,14 @@ idEventLoop* eventLoop;
// static ExampleAppLog my_log;
// my_log.AddLog("Hello %d world\n", 123);
// my_log.Draw("title");
struct ExampleAppLog
struct MyAppLog
{
ImGuiTextBuffer Buf;
ImGuiTextFilter Filter;
ImVector<int> LineOffsets; // Index to lines offset. We maintain this with AddLog() calls, allowing us to have a random access on lines
bool AutoScroll; // Keep scrolling if already at the bottom
ExampleAppLog()
MyAppLog()
{
AutoScroll = true;
Clear();
}
@ -88,38 +86,25 @@ struct ExampleAppLog
void Draw( const char* title, bool* p_open = NULL )
{
if( !ImGui::Begin( title, p_open ) )
{
auto wSize = ImGui::GetIO().DisplaySize;
ImGui::SetNextWindowPos( ImVec2( 0, 1 ), ImGuiCond_Always );
ImGui::SetNextWindowSize( ImVec2( wSize.x, wSize.y - 5 ), ImGuiCond_Always );
}
if( !ImGui::Begin( title, p_open, ImGuiWindowFlags_NoDecoration ) )
{
ImGui::End();
return;
}
// Options menu
if( ImGui::BeginPopup( "Options" ) )
{
ImGui::Checkbox( "Auto-scroll", &AutoScroll );
ImGui::EndPopup();
}
// Main window
if( ImGui::Button( "Options" ) )
{
ImGui::OpenPopup( "Options" );
}
bool copy = ImGui::Button( "Copy to Clipboard" );
ImGui::SameLine();
bool clear = ImGui::Button( "Clear" );
ImGui::SameLine();
bool copy = ImGui::Button( "Copy" );
ImGui::SameLine();
Filter.Draw( "Filter", -100.0f );
ImGui::Separator();
ImGui::BeginChild( "scrolling", ImVec2( 0, 0 ), false, ImGuiWindowFlags_HorizontalScrollbar );
if( clear )
{
Clear();
}
if( copy )
{
ImGui::LogToClipboard();
@ -128,6 +113,7 @@ struct ExampleAppLog
ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, ImVec2( 0, 0 ) );
const char* buf = Buf.begin();
const char* buf_end = Buf.end();
#if 0
if( Filter.IsActive() )
{
// In this example we don't use the clipper when Filter is enabled.
@ -145,6 +131,7 @@ struct ExampleAppLog
}
}
else
#endif
{
// The simplest and easy way to display the entire buffer:
// ImGui::TextUnformatted(buf_begin, buf_end);
@ -170,7 +157,7 @@ struct ExampleAppLog
}
ImGui::PopStyleVar();
if( AutoScroll && ImGui::GetScrollY() >= ImGui::GetScrollMaxY() )
//if( ImGui::GetScrollY() >= ImGui::GetScrollMaxY() )
{
ImGui::SetScrollHereY( 1.0f );
}
@ -180,7 +167,7 @@ struct ExampleAppLog
}
};
static ExampleAppLog tuiLog;
static MyAppLog tuiLog;
#define MAXPRINTMSG 4096
@ -194,7 +181,7 @@ static ExampleAppLog tuiLog;
Sys_DebugPrintf( "%s%s%s", pre, msg, post ); \
//idCVar com_developer( "developer", "0", CVAR_BOOL|CVAR_SYSTEM, "developer mode" );
idCVar com_developer( "developer", "0", CVAR_BOOL | CVAR_SYSTEM, "developer mode" );
idCVar com_productionMode( "com_productionMode", "0", CVAR_SYSTEM | CVAR_BOOL, "0 - no special behavior, 1 - building a production build, 2 - running a production build" );
/*
@ -579,10 +566,174 @@ idSys* sys = &idSysLocal;
==============================================================
*/
/*
#include <array>
#include <map>
#include <vector>
#include <string>
#include <functional>
*/
namespace UI
{
enum class ColorScheme : int
{
Default,
Dark,
Green,
Jungle,
COUNT,
};
struct State
{
int hoveredWindowId = 0;
int statusWindowHeight = 4;
ColorScheme colorScheme = ColorScheme::Dark;
bool showHelpWelcome = false;
bool showHelpModal = false;
bool showStatusWindow = true;
#define STATUS_TEXT_SIZE 512
idStrStatic<STATUS_TEXT_SIZE> statusWindowHeader = "Initializing Doom Framework";
idStrStatic<STATUS_TEXT_SIZE> statusActiveTool = "-";
float progress = 1.0f;
void ChangeColorScheme( bool inc = true )
{
if( inc )
{
colorScheme = ( ColorScheme )( ( ( int ) colorScheme + 1 ) % ( ( int )ColorScheme::COUNT ) );
}
ImVec4* colors = ImGui::GetStyle().Colors;
switch( colorScheme )
{
case ColorScheme::Default:
{
colors[ImGuiCol_Text] = ImVec4( 0.00f, 0.00f, 0.00f, 1.00f );
colors[ImGuiCol_TextDisabled] = ImVec4( 0.60f, 0.60f, 0.60f, 1.00f );
colors[ImGuiCol_WindowBg] = ImVec4( 0.96f, 0.96f, 0.94f, 1.00f );
colors[ImGuiCol_TitleBg] = ImVec4( 1.00f, 0.40f, 0.00f, 1.00f );
colors[ImGuiCol_TitleBgActive] = ImVec4( 1.00f, 0.40f, 0.00f, 1.00f );
colors[ImGuiCol_TitleBgCollapsed] = ImVec4( 0.69f, 0.25f, 0.00f, 1.00f );
colors[ImGuiCol_ChildBg] = ImVec4( 0.96f, 0.96f, 0.94f, 1.00f );
colors[ImGuiCol_PopupBg] = ImVec4( 0.96f, 0.96f, 0.94f, 1.00f );
colors[ImGuiCol_ModalWindowDimBg] = ImVec4( 0.00f, 0.00f, 0.00f, 0.00f );
break;
}
case ColorScheme::Dark:
{
colors[ImGuiCol_Text] = ImVec4( 1.00f, 1.00f, 1.00f, 1.00f );
colors[ImGuiCol_TextDisabled] = ImVec4( 0.60f, 0.60f, 0.60f, 1.00f );
colors[ImGuiCol_WindowBg] = ImVec4( 0.10f, 0.10f, 0.10f, 1.00f );
colors[ImGuiCol_TitleBg] = ImVec4( 1.00f, 0.40f, 0.00f, 0.50f );
colors[ImGuiCol_TitleBgActive] = ImVec4( 1.00f, 0.40f, 0.00f, 0.50f );
colors[ImGuiCol_TitleBgCollapsed] = ImVec4( 0.69f, 0.25f, 0.00f, 0.50f );
colors[ImGuiCol_ChildBg] = ImVec4( 0.10f, 0.10f, 0.10f, 1.00f );
colors[ImGuiCol_PopupBg] = ImVec4( 0.20f, 0.20f, 0.20f, 1.00f );
colors[ImGuiCol_ModalWindowDimBg] = ImVec4( 0.00f, 0.00f, 0.00f, 0.00f );
break;
}
case ColorScheme::Green:
{
colors[ImGuiCol_Text] = ImVec4( 0.00f, 1.00f, 0.00f, 1.00f );
colors[ImGuiCol_TextDisabled] = ImVec4( 0.60f, 0.60f, 0.60f, 1.00f );
colors[ImGuiCol_WindowBg] = ImVec4( 0.10f, 0.10f, 0.10f, 1.00f );
colors[ImGuiCol_TitleBg] = ImVec4( 0.25f, 0.25f, 0.25f, 1.00f );
colors[ImGuiCol_TitleBgActive] = ImVec4( 0.25f, 0.25f, 0.25f, 1.00f );
colors[ImGuiCol_TitleBgCollapsed] = ImVec4( 0.50f, 1.00f, 0.50f, 1.00f );
colors[ImGuiCol_ChildBg] = ImVec4( 0.10f, 0.10f, 0.10f, 1.00f );
colors[ImGuiCol_PopupBg] = ImVec4( 0.00f, 0.00f, 0.00f, 1.00f );
colors[ImGuiCol_ModalWindowDimBg] = ImVec4( 0.00f, 0.00f, 0.00f, 0.00f );
break;
}
case ColorScheme::Jungle:
{
// based on BlackDevil style by Naeemullah1 from ImThemes
colors[ImGuiCol_Text] = ImVec4( 0.78f, 0.78f, 0.78f, 1.00f );
colors[ImGuiCol_TextDisabled] = ImVec4( 0.44f, 0.41f, 0.31f, 1.00f );
colors[ImGuiCol_WindowBg] = ImVec4( 0.12f, 0.14f, 0.16f, 0.87f );
colors[ImGuiCol_ChildBg] = ImVec4( 0.06f, 0.12f, 0.16f, 0.78f );
colors[ImGuiCol_PopupBg] = ImVec4( 0.08f, 0.08f, 0.08f, 0.78f );
//colors[ImGuiCol_Border] = ImVec4(0.39f, 0.00f, 0.00f, 0.78f); the red is a bit too aggressive
colors[ImGuiCol_Border] = ImVec4( 0.24f, 0.27f, 0.32f, 0.78f );
colors[ImGuiCol_BorderShadow] = ImVec4( 0.00f, 0.00f, 0.00f, 0.00f );
colors[ImGuiCol_FrameBg] = ImVec4( 0.06f, 0.12f, 0.16f, 0.78f );
colors[ImGuiCol_FrameBgHovered] = ImVec4( 0.12f, 0.24f, 0.35f, 0.78f );
colors[ImGuiCol_FrameBgActive] = ImVec4( 0.35f, 0.35f, 0.12f, 0.78f );
colors[ImGuiCol_TitleBg] = ImVec4( 0.06f, 0.12f, 0.16f, 0.78f );
colors[ImGuiCol_TitleBgActive] = ImVec4( 0.06f, 0.12f, 0.16f, 0.78f );
colors[ImGuiCol_TitleBgCollapsed] = ImVec4( 0.06f, 0.12f, 0.16f, 0.20f );
colors[ImGuiCol_MenuBarBg] = ImVec4( 0.08f, 0.08f, 0.08f, 0.78f );
colors[ImGuiCol_ScrollbarBg] = ImVec4( 0.06f, 0.12f, 0.16f, 0.78f );
colors[ImGuiCol_ScrollbarGrab] = ImVec4( 0.12f, 0.35f, 0.24f, 0.78f );
colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4( 0.12f, 0.35f, 0.35f, 0.78f );
colors[ImGuiCol_ScrollbarGrabActive] = ImVec4( 0.12f, 0.59f, 0.24f, 0.78f );
colors[ImGuiCol_CheckMark] = ImVec4( 0.12f, 0.59f, 0.24f, 0.78f );
colors[ImGuiCol_SliderGrab] = ImVec4( 0.12f, 0.35f, 0.24f, 0.78f );
colors[ImGuiCol_SliderGrabActive] = ImVec4( 0.12f, 0.59f, 0.24f, 0.78f );
colors[ImGuiCol_Button] = ImVec4( 0.35f, 0.35f, 0.12f, 0.78f );
colors[ImGuiCol_ButtonHovered] = ImVec4( 0.35f, 0.47f, 0.24f, 0.78f );
colors[ImGuiCol_ButtonActive] = ImVec4( 0.59f, 0.35f, 0.24f, 0.78f );
colors[ImGuiCol_Header] = ImVec4( 0.06f, 0.12f, 0.16f, 0.78f );
colors[ImGuiCol_HeaderHovered] = ImVec4( 0.12f, 0.35f, 0.35f, 0.78f );
colors[ImGuiCol_HeaderActive] = ImVec4( 0.12f, 0.59f, 0.24f, 0.78f );
colors[ImGuiCol_Separator] = ImVec4( 0.35f, 0.35f, 0.24f, 0.78f );
colors[ImGuiCol_SeparatorHovered] = ImVec4( 0.12f, 0.35f, 0.35f, 0.78f );
colors[ImGuiCol_SeparatorActive] = ImVec4( 0.59f, 0.35f, 0.24f, 0.78f );
colors[ImGuiCol_ResizeGrip] = ImVec4( 0.06f, 0.12f, 0.16f, 0.78f );
colors[ImGuiCol_ResizeGripHovered] = ImVec4( 0.59f, 0.35f, 0.35f, 0.78f );
colors[ImGuiCol_ResizeGripActive] = ImVec4( 0.59f, 0.24f, 0.24f, 0.78f );
colors[ImGuiCol_Tab] = ImVec4( 0.35f, 0.35f, 0.12f, 0.78f );
colors[ImGuiCol_TabHovered] = ImVec4( 0.35f, 0.47f, 0.24f, 0.78f );
colors[ImGuiCol_TabActive] = ImVec4( 0.59f, 0.35f, 0.24f, 0.78f );
colors[ImGuiCol_TabUnfocused] = ImVec4( 0.06f, 0.12f, 0.16f, 0.78f );
colors[ImGuiCol_TabUnfocusedActive] = ImVec4( 0.59f, 0.35f, 0.35f, 0.78f );
// colors[ImGuiCol_DockingPreview] = ImVec4( 0.26f, 0.59f, 0.98f, 0.70f );
// colors[ImGuiCol_DockingEmptyBg] = ImVec4( 0.20f, 0.20f, 0.20f, 1.00f );
colors[ImGuiCol_PlotLines] = ImVec4( 0.39f, 0.78f, 0.39f, 0.78f );
colors[ImGuiCol_PlotLinesHovered] = ImVec4( 1.00f, 0.43f, 0.35f, 0.78f );
colors[ImGuiCol_PlotHistogram] = ImVec4( 0.00f, 0.35f, 0.39f, 0.78f );
colors[ImGuiCol_PlotHistogramHovered] = ImVec4( 0.20f, 0.59f, 0.59f, 0.78f );
colors[ImGuiCol_TableHeaderBg] = ImVec4( 0.19f, 0.19f, 0.20f, 0.78f );
colors[ImGuiCol_TableBorderStrong] = ImVec4( 0.31f, 0.31f, 0.35f, 0.78f );
colors[ImGuiCol_TableBorderLight] = ImVec4( 0.23f, 0.23f, 0.25f, 0.78f );
colors[ImGuiCol_TableRowBg] = ImVec4( 0.00f, 0.00f, 0.00f, 0.78f );
colors[ImGuiCol_TableRowBgAlt] = ImVec4( 1.00f, 1.00f, 1.00f, 0.06f );
colors[ImGuiCol_TextSelectedBg] = ImVec4( 0.39f, 0.35f, 0.39f, 0.39f );
colors[ImGuiCol_DragDropTarget] = ImVec4( 1.00f, 1.00f, 0.00f, 0.90f );
colors[ImGuiCol_NavHighlight] = ImVec4( 0.26f, 0.59f, 0.98f, 1.00f );
colors[ImGuiCol_NavWindowingHighlight] = ImVec4( 1.00f, 1.00f, 1.00f, 0.70f );
colors[ImGuiCol_NavWindowingDimBg] = ImVec4( 0.80f, 0.80f, 0.80f, 0.20f );
colors[ImGuiCol_ModalWindowDimBg] = ImVec4( 0.80f, 0.80f, 0.80f, 0.35f );
break;
}
default:
{
}
}
}
};
}
// UI state
UI::State stateUI;
class idCommonLocal : public idCommon
{
private:
int count = 0;
int expectedCount = 0;
public:
bool com_refreshOnPrint = true; // update the screen every print for dmap
@ -636,7 +787,7 @@ public:
// Update the screen with every message printed.
virtual void SetRefreshOnPrint( bool set )
{
com_refreshOnPrint = set;
//com_refreshOnPrint = set;
}
virtual void Printf( const char* fmt, ... )
@ -645,48 +796,66 @@ public:
if( com_refreshOnPrint )
{
bool captureToImage = false;
common->UpdateScreen( captureToImage );
common->UpdateScreen( false );
}
}
virtual void VPrintf( const char* fmt, va_list arg )
{
Sys_DebugVPrintf( fmt, arg );
if( com_refreshOnPrint )
{
bool captureToImage = false;
common->UpdateScreen( captureToImage );
common->UpdateScreen( false );
}
}
virtual void DPrintf( const char* fmt, ... )
{
STDIO_PRINT( "", "" );
if( com_refreshOnPrint )
if( com_developer.GetBool() )
{
bool captureToImage = false;
common->UpdateScreen( captureToImage );
STDIO_PRINT( "", "" );
if( com_refreshOnPrint )
{
common->UpdateScreen( false );
}
}
}
virtual void VerbosePrintf( const char* fmt, ... )
{
if( dmap_verbose.GetBool() )
{
STDIO_PRINT( "", "" );
if( com_refreshOnPrint )
{
common->UpdateScreen( false );
}
}
}
virtual void Warning( const char* fmt, ... )
{
STDIO_PRINT( "WARNING: ", "\n" );
if( com_refreshOnPrint )
{
bool captureToImage = false;
common->UpdateScreen( captureToImage );
common->UpdateScreen( false );
}
}
virtual void DWarning( const char* fmt, ... )
{
STDIO_PRINT( "WARNING: ", "\n" );
if( com_refreshOnPrint )
if( com_developer.GetBool() )
{
bool captureToImage = false;
common->UpdateScreen( captureToImage );
STDIO_PRINT( "WARNING: ", "\n" );
if( com_refreshOnPrint )
{
common->UpdateScreen( false );
}
}
}
@ -702,8 +871,7 @@ public:
if( com_refreshOnPrint )
{
bool captureToImage = false;
common->UpdateScreen( captureToImage );
common->UpdateScreen( false );
}
exit( 0 );
}
@ -713,8 +881,7 @@ public:
if( com_refreshOnPrint )
{
bool captureToImage = false;
common->UpdateScreen( captureToImage );
common->UpdateScreen( false );
}
exit( 0 );
}
@ -858,19 +1025,51 @@ public:
virtual void QueueShowShell() { }; // Will activate the shell on the next frame.
void InitTool( const toolFlag_t, const idDict*, idEntity* ) {}
//virtual currentGame_t GetCurrentGame() const {
// return DOOM_CLASSIC;
//};
//virtual void SwitchToGame(currentGame_t newGame) {}
void LoadPacifierBinarizeFilename( const char* filename, const char* reason ) {}
void LoadPacifierBinarizeInfo( const char* info ) {}
void LoadPacifierBinarizeMiplevel( int level, int maxLevel ) {}
void LoadPacifierBinarizeProgress( float progress ) {}
void LoadPacifierBinarizeEnd() { };
void LoadPacifierBinarizeProgressTotal( int total ) {}
void LoadPacifierBinarizeProgressIncrement( int step ) {}
void LoadPacifierBinarizeFilename( const char* filename, const char* reason ) {}
void LoadPacifierBinarizeInfo( const char* info ) {}
void LoadPacifierBinarizeMiplevel( int level, int maxLevel ) {}
void LoadPacifierBinarizeProgress( float progress ) {}
void LoadPacifierBinarizeEnd() { };
// for images in particular we can measure more accurately this way (to deal with mipmaps)
void LoadPacifierBinarizeProgressTotal( int total ) {}
void LoadPacifierBinarizeProgressIncrement( int step ) {}
virtual void DmapPacifierFilename( const char* filename, const char* reason )
{
stateUI.statusWindowHeader.Format( "%s | %s", filename, reason );
}
virtual void DmapPacifierInfo( VERIFY_FORMAT_STRING const char* fmt, ... )
{
char msg[STATUS_TEXT_SIZE];
va_list argptr;
va_start( argptr, fmt );
idStr::vsnPrintf( msg, STATUS_TEXT_SIZE - 1, fmt, argptr );
msg[ sizeof( msg ) - 1 ] = '\0';
va_end( argptr );
stateUI.statusActiveTool = msg;
if( com_refreshOnPrint )
{
UpdateScreen( false );
}
}
virtual void DmapPacifierCompileProgressTotal( int total )
{
count = 0;
expectedCount = total;
stateUI.progress = 0;
}
virtual void DmapPacifierCompileProgressIncrement( int step )
{
count += step;
stateUI.progress = float( count ) / expectedCount;
}
};
idCommonLocal commonLocal;
@ -888,6 +1087,10 @@ int com_editors = 0;
#if 0
void idCommonLocal::UpdateScreen( bool captureToImage, bool releaseMouse )
{
}
int main( int argc, char** argv )
{
idLib::common = common;
@ -930,152 +1133,6 @@ int main( int argc, char** argv )
#elif 1
#include <array>
#include <map>
#include <vector>
#include <string>
#include <functional>
namespace UI
{
enum class WindowContent : int
{
Top,
//Best,
Show,
Ask,
New,
Count,
};
enum class ColorScheme : int
{
Default,
Dark,
Green,
COUNT,
};
std::map<WindowContent, std::string> kContentStr =
{
{ WindowContent::Top, "Top" },
//{ WindowContent::Best, "Best" },
{ WindowContent::Show, "Show" },
{ WindowContent::Ask, "Ask" },
{ WindowContent::New, "New" },
};
struct WindowData
{
WindowContent content;
bool showComments = false;
//HN::ItemId selectedStoryId = 0;
int hoveredStoryId = 0;
int hoveredCommentId = 0;
int maxStories = 10;
};
struct State
{
int hoveredWindowId = 0;
int statusWindowHeight = 4;
ColorScheme colorScheme = ColorScheme::Dark;
bool showHelpWelcome = false;
bool showHelpModal = false;
bool showStatusWindow = true;
int nWindows = 1;
char statusWindowHeader[512];
idStrStatic<512> statusActiveTool;
std::map<int, bool> collapsed;
void ChangeColorScheme( bool inc = true )
{
if( inc )
{
colorScheme = ( ColorScheme )( ( ( int ) colorScheme + 1 ) % ( ( int )ColorScheme::COUNT ) );
}
ImVec4* colors = ImGui::GetStyle().Colors;
switch( colorScheme )
{
case ColorScheme::Default:
{
colors[ImGuiCol_Text] = ImVec4( 0.00f, 0.00f, 0.00f, 1.00f );
colors[ImGuiCol_TextDisabled] = ImVec4( 0.60f, 0.60f, 0.60f, 1.00f );
colors[ImGuiCol_WindowBg] = ImVec4( 0.96f, 0.96f, 0.94f, 1.00f );
colors[ImGuiCol_TitleBg] = ImVec4( 1.00f, 0.40f, 0.00f, 1.00f );
colors[ImGuiCol_TitleBgActive] = ImVec4( 1.00f, 0.40f, 0.00f, 1.00f );
colors[ImGuiCol_TitleBgCollapsed] = ImVec4( 0.69f, 0.25f, 0.00f, 1.00f );
colors[ImGuiCol_ChildBg] = ImVec4( 0.96f, 0.96f, 0.94f, 1.00f );
colors[ImGuiCol_PopupBg] = ImVec4( 0.96f, 0.96f, 0.94f, 1.00f );
colors[ImGuiCol_ModalWindowDimBg] = ImVec4( 0.00f, 0.00f, 0.00f, 0.00f );
}
break;
case ColorScheme::Dark:
{
colors[ImGuiCol_Text] = ImVec4( 1.00f, 1.00f, 1.00f, 1.00f );
colors[ImGuiCol_TextDisabled] = ImVec4( 0.60f, 0.60f, 0.60f, 1.00f );
colors[ImGuiCol_WindowBg] = ImVec4( 0.10f, 0.10f, 0.10f, 1.00f );
colors[ImGuiCol_TitleBg] = ImVec4( 1.00f, 0.40f, 0.00f, 0.50f );
colors[ImGuiCol_TitleBgActive] = ImVec4( 1.00f, 0.40f, 0.00f, 0.50f );
colors[ImGuiCol_TitleBgCollapsed] = ImVec4( 0.69f, 0.25f, 0.00f, 0.50f );
colors[ImGuiCol_ChildBg] = ImVec4( 0.10f, 0.10f, 0.10f, 1.00f );
colors[ImGuiCol_PopupBg] = ImVec4( 0.20f, 0.20f, 0.20f, 1.00f );
colors[ImGuiCol_ModalWindowDimBg] = ImVec4( 0.00f, 0.00f, 0.00f, 0.00f );
}
break;
case ColorScheme::Green:
{
colors[ImGuiCol_Text] = ImVec4( 0.00f, 1.00f, 0.00f, 1.00f );
colors[ImGuiCol_TextDisabled] = ImVec4( 0.60f, 0.60f, 0.60f, 1.00f );
colors[ImGuiCol_WindowBg] = ImVec4( 0.10f, 0.10f, 0.10f, 1.00f );
colors[ImGuiCol_TitleBg] = ImVec4( 0.25f, 0.25f, 0.25f, 1.00f );
colors[ImGuiCol_TitleBgActive] = ImVec4( 0.25f, 0.25f, 0.25f, 1.00f );
colors[ImGuiCol_TitleBgCollapsed] = ImVec4( 0.50f, 1.00f, 0.50f, 1.00f );
colors[ImGuiCol_ChildBg] = ImVec4( 0.10f, 0.10f, 0.10f, 1.00f );
colors[ImGuiCol_PopupBg] = ImVec4( 0.00f, 0.00f, 0.00f, 1.00f );
colors[ImGuiCol_ModalWindowDimBg] = ImVec4( 0.00f, 0.00f, 0.00f, 0.00f );
}
break;
default:
{
}
}
}
std::array<WindowData, 3> windows { {
{
WindowContent::Top,
false,
0, 0, 10,
},
{
WindowContent::Show,
false,
0, 0, 10,
},
{
WindowContent::New,
false,
0, 0, 10,
},
} };
};
}
// UI state
UI::State stateUI;
void ShowExampleAppConsole( bool* p_open );
void idCommonLocal::UpdateScreen( bool captureToImage, bool releaseMouse )
{
bool demo = true;
@ -1088,7 +1145,6 @@ void idCommonLocal::UpdateScreen( bool captureToImage, bool releaseMouse )
{
auto wSize = ImGui::GetIO().DisplaySize;
wSize.x /= stateUI.nWindows;
if( stateUI.showStatusWindow )
{
wSize.y -= stateUI.statusWindowHeight;
@ -1096,14 +1152,11 @@ void idCommonLocal::UpdateScreen( bool captureToImage, bool releaseMouse )
wSize.x = int( wSize.x );
ImGui::SetNextWindowPos( ImVec2( 0, 0 ), ImGuiCond_Always );
if( 0 < stateUI.nWindows - 1 )
{
wSize.x -= 1.1;
}
ImGui::SetNextWindowSize( wSize, ImGuiCond_Always );
}
idStr title = va( "RBDMAP version %s %s", ENGINE_VERSION, BUILD_STRING );
//idStr title = va( "RBDMAP version %s %s", ENGINE_VERSION, BUILD_STRING );
idStr title = va( "RBDMAP version %s %s %s %s", ENGINE_VERSION, BUILD_STRING, __DATE__, __TIME__ );
//std::string title = "RBDMAP " + UI::kContentStr[window.content] + ")##" + std::to_string( windowId );
ImGui::Begin( title.c_str(), nullptr,
ImGuiWindowFlags_NoCollapse |
@ -1111,21 +1164,13 @@ void idCommonLocal::UpdateScreen( bool captureToImage, bool releaseMouse )
ImGuiWindowFlags_NoMove |
ImGuiWindowFlags_NoScrollbar );
ImGui::BeginChild( "Current Log:", ImVec2( 0, 0 ), false, ImGuiWindowFlags_None );
// For the demo: add a debug button _BEFORE_ the normal log window contents
// We take advantage of a rarely used feature: multiple calls to Begin()/End() are appending to the _same_ window.
// Most of the contents of the window will be added by the log.Draw() call.
ImGui::SetNextWindowPos( ImVec2( 20, 14 ), ImGuiCond_FirstUseEver );
ImGui::SetNextWindowSize( ImVec2( 100, 30 ), ImGuiCond_FirstUseEver );
//ImGui::Begin( "Example: Log", &conOpen );
//ImGui::End();
//ImGui::BeginChild( "Current Log:", ImVec2( 0, 0 ), false, ImGuiWindowFlags_NoDecoration );
// Actually call in the regular Log helper (which will Begin() into the same window as we just did)
tuiLog.Draw( "Current Log:", &conOpen );
ImGui::EndChild();
//ImGui::EndChild();
//ShowExampleAppConsole( &conOpen );
@ -1139,13 +1184,23 @@ void idCommonLocal::UpdateScreen( bool captureToImage, bool releaseMouse )
ImGui::SetNextWindowPos( ImVec2( 0, wSize.y - stateUI.statusWindowHeight ), ImGuiCond_Always );
ImGui::SetNextWindowSize( ImVec2( wSize.x, stateUI.statusWindowHeight ), ImGuiCond_Always );
}
snprintf( stateUI.statusWindowHeader, 512, "Status %s |", stateUI.statusActiveTool.c_str() );
ImGui::Begin( stateUI.statusWindowHeader, nullptr,
ImGuiWindowFlags_NoCollapse |
ImGuiWindowFlags_NoResize |
ImGuiWindowFlags_NoMove );
//ImGui::Text( " API requests : %d / %d B (next update in %d s)", stateHN.nFetches, ( int ) stateHN.totalBytesDownloaded, stateHN.nextUpdate );
ImGui::Text( " Last API request : " );
if( stateUI.progress < 1.0f )
{
ImGui::ProgressBar( stateUI.progress, ImVec2( 0.0f, 0.0f ) );
}
else
{
ImGui::Text( " " );
}
ImGui::Text( " %s", stateUI.statusActiveTool.c_str() );
ImGui::Text( " Source code : https://github.com/RobertBeckebans/RBDOOM-3-BFG" );
ImGui::End();
@ -1201,7 +1256,7 @@ int main( int argc, char** argv )
Dmap_f( args );
#if 0
#if 1
while( true )
{
bool captureToImage = false;
@ -1220,6 +1275,10 @@ int main( int argc, char** argv )
#include "imtui/imtui-impl-ncurses.h"
#include "imtui/imtui-demo.h"
void idCommonLocal::UpdateScreen( bool captureToImage, bool releaseMouse )
{
}
int main()
{
IMGUI_CHECKVERSION();
@ -1228,6 +1287,8 @@ int main()
auto screen = ImTui_ImplNcurses_Init( true );
ImTui_ImplText_Init();
stateUI.ChangeColorScheme( false );
bool demo = true;
int nframes = 0;
float fval = 1.23f;