void WINAPI QERApp_ReloadShaderFile( const char* name ) { brush_t *b; face_t *f; #ifdef _DEBUG // check the shader name is a reletive path // I hacked together a few quick tests to make sure :-) if (strstr( name, ":\\" ) || !strstr( name, "scripts" )) Sys_Printf("WARNING: is %s a reletive path to a shader file? (QERApp_ReloadShaderFile\n"); #endif // in the actives and global shaders lists, decref and unhook the shaders //++timo NOTE: maybe we'd like to keep track of the shaders we are unhooking? g_ActiveShaders.ReleaseForShaderFile( name ); g_Shaders.ReleaseForShaderFile( name ); // go through a reload of the shader file QERApp_LoadShaderFile( name ); // scan all the brushes, replace all the old ones by refs to their new equivalents for (b=active_brushes.next ; b != NULL && b != &active_brushes ; b=b->next) { if (b->patchBrush && !strcmp(b->pPatch->pShader->getShaderFileName(), name)) SetShader(b->pPatch); else for (f=b->brush_faces ; f ; f=f->next) if (!strcmp(f->pShader->getShaderFileName(), name)) SetShader(f); } for (b=selected_brushes.next ; b != NULL && b != &selected_brushes ; b=b->next) { if (b->patchBrush && !strcmp(b->pPatch->pShader->getShaderFileName(), name)) SetShader(b->pPatch); else for (f=b->brush_faces ; f ; f=f->next) if (!strcmp(f->pShader->getShaderFileName(), name)) SetShader(f); } // call Texture_ShowInUse to clean and display only what's required Texture_ShowInuse(); // Texture_SortTextures(); QERApp_SortActiveShaders(); Sys_UpdateWindows (W_TEXTURE); }
/* ================ Map_LoadFile ================ */ void Map_LoadFile( const char *filename ){ clock_t start, finish; double elapsed_time; start = clock(); Sys_BeginWait(); Select_Deselect(); /*! \todo FIXME TTimo why is this commented out? stability issues maybe? or duplicate feature? forcing to show the console during map load was a good thing IMO */ //SetInspectorMode(W_CONSOLE); Sys_Printf( "Loading map from %s\n", filename ); Map_Free(); //++timo FIXME: maybe even easier to have Group_Init called from Map_Free? Group_Init(); g_qeglobals.d_num_entities = 0; g_qeglobals.d_parsed_brushes = 0; // cancel the map loading process // used when conversion between standard map format and BP format is required and the user cancels the process g_bCancel_Map_LoadFile = false; strcpy( currentmap, filename ); g_bScreenUpdates = false; // leo: avoid redraws while loading the map (see fenris:1952) // prepare to let the map module do the parsing FileStream file; const char* type = strrchr( filename,'.' ); if ( type != NULL ) { type++; } // NOTE TTimo opening has binary doesn't make a lot of sense // but opening as text confuses the scriptlib parser // this may be a problem if we "rb" and use the XML parser, might have an incompatibility if ( file.Open( filename, "rb" ) ) { Map_Import( &file, type ); } else{ Sys_FPrintf( SYS_ERR, "ERROR: failed to open %s for read\n", filename ); } file.Close(); g_bScreenUpdates = true; if ( g_bCancel_Map_LoadFile ) { Sys_Printf( "Map_LoadFile canceled\n" ); Map_New(); Sys_EndWait(); return; } if ( !world_entity ) { Sys_Printf( "No worldspawn in map.\n" ); Map_New(); Sys_EndWait(); return; } finish = clock(); elapsed_time = (double)( finish - start ) / CLOCKS_PER_SEC; Sys_Printf( "--- LoadMapFile ---\n" ); Sys_Printf( "%s\n", filename ); Sys_Printf( "%5i brushes\n", g_qeglobals.d_parsed_brushes ); Sys_Printf( "%5i entities\n", g_qeglobals.d_num_entities ); Sys_Printf( "%5.2f second(s) load time\n", elapsed_time ); Sys_EndWait(); Map_RestoreBetween(); // // move the view to a start position // Map_StartPosition(); Map_RegionOff(); modified = false; Sys_SetTitle( filename ); Texture_ShowInuse(); QERApp_SortActiveShaders(); Sys_UpdateWindows( W_ALL ); }
void WINAPI QERApp_ReloadShaderFile( const char *name ){ brush_t *b; face_t *f; brush_t *active_brushes; brush_t *selected_brushes; brush_t *filtered_brushes; // Sys_Printf("TODO: QERApp_ReloadShaderFile\n"); active_brushes = g_DataTable.m_pfnActiveBrushes(); selected_brushes = g_DataTable.m_pfnSelectedBrushes(); filtered_brushes = g_DataTable.m_pfnFilteredBrushes(); #ifdef _DEBUG // check the shader name is a reletive path // I hacked together a few quick tests to make sure :-) if ( strstr( name, ":\\" ) || !strstr( name, "scripts" ) ) { Sys_Printf( "WARNING: is %s a reletive path to a shader file? (QERApp_ReloadShaderFile\n" ); } #endif // in the actives and global shaders lists, decref and unhook the shaders //++timo NOTE: maybe we'd like to keep track of the shaders we are unhooking? g_ActiveShaders.ReleaseForShaderFile( name ); g_Shaders.ReleaseForShaderFile( name ); // go through a reload of the shader file QERApp_LoadShaderFile( name ); // scan all the brushes, replace all the old ones by refs to their new equivalents for ( b = active_brushes->next; b != NULL && b != active_brushes; b = b->next ) { if ( b->patchBrush && !strcmp( b->pPatch->pShader->getShaderFileName(), name ) ) { SetShader( b->pPatch ); } else{ for ( f = b->brush_faces; f; f = f->next ) if ( !strcmp( f->pShader->getShaderFileName(), name ) ) { SetShader( f ); } } } for ( b = selected_brushes->next; b != NULL && b != selected_brushes; b = b->next ) { if ( b->patchBrush && !strcmp( b->pPatch->pShader->getShaderFileName(), name ) ) { SetShader( b->pPatch ); } else{ for ( f = b->brush_faces; f; f = f->next ) if ( !strcmp( f->pShader->getShaderFileName(), name ) ) { SetShader( f ); } } } // do that to the filtered brushes as well (we might have some region compiling going on) for ( b = filtered_brushes->next; b != NULL && b != filtered_brushes; b = b->next ) { if ( b->patchBrush && !strcmp( b->pPatch->pShader->getShaderFileName(), name ) ) { SetShader( b->pPatch ); } else{ for ( f = b->brush_faces; f; f = f->next ) if ( !strcmp( f->pShader->getShaderFileName(), name ) ) { SetShader( f ); } } } // call Texture_ShowInUse to clean and display only what's required g_ShadersTable.m_pfnTexture_ShowInuse(); QERApp_SortActiveShaders(); g_FuncTable.m_pfnSysUpdateWindows( W_TEXTURE ); }