shorten some StringOutputStream uses
This commit is contained in:
parent
b013f9954c
commit
02874bebee
|
|
@ -256,15 +256,12 @@ void Pointfile_Parse( CPointfile& pointfile ){
|
||||||
|
|
||||||
const char* mapname = Map_Name( g_map );
|
const char* mapname = Map_Name( g_map );
|
||||||
StringOutputStream name( 256 );
|
StringOutputStream name( 256 );
|
||||||
name << PathExtensionless( mapname ) << ".lin";
|
|
||||||
|
|
||||||
size = LoadFile( name.c_str(), (void**)&data );
|
size = LoadFile( name( PathExtensionless( mapname ), ".lin" ), (void**)&data );
|
||||||
if ( size == -1 ) {
|
if ( size == -1 ) {
|
||||||
globalErrorStream() << "Pointfile " << name.c_str() << " not found\n";
|
globalErrorStream() << "Pointfile " << name.c_str() << " not found\n";
|
||||||
/* try .pts (q1) */
|
/* try .pts (q1) */
|
||||||
name.clear();
|
size = LoadFile( name( PathExtensionless( mapname ), ".pts" ), (void**)&data );
|
||||||
name << PathExtensionless( mapname ) << ".pts";
|
|
||||||
size = LoadFile( name.c_str(), (void**)&data );
|
|
||||||
if ( size == -1 ) {
|
if ( size == -1 ) {
|
||||||
globalErrorStream() << "Pointfile " << name.c_str() << " not found\n";
|
globalErrorStream() << "Pointfile " << name.c_str() << " not found\n";
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
|
|
@ -362,9 +362,8 @@ void CGameDialog::Reset(){
|
||||||
if ( !g_Preferences.m_global_rc_path ) {
|
if ( !g_Preferences.m_global_rc_path ) {
|
||||||
InitGlobalPrefPath();
|
InitGlobalPrefPath();
|
||||||
}
|
}
|
||||||
StringOutputStream strGlobalPref( 256 );
|
|
||||||
strGlobalPref << g_Preferences.m_global_rc_path->str << "global.pref";
|
file_remove( StringOutputStream( 256 )( g_Preferences.m_global_rc_path->str, "global.pref" ) );
|
||||||
file_remove( strGlobalPref.c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGameDialog::Init(){
|
void CGameDialog::Init(){
|
||||||
|
|
|
||||||
|
|
@ -86,35 +86,28 @@ void QE_InitVFS(){
|
||||||
if( !string_empty( extrapath ) )
|
if( !string_empty( extrapath ) )
|
||||||
GlobalFileSystem().initDirectory( extrapath );
|
GlobalFileSystem().initDirectory( extrapath );
|
||||||
|
|
||||||
|
StringOutputStream str( 256 );
|
||||||
// if we have a mod dir
|
// if we have a mod dir
|
||||||
if ( !string_equal( gamename, basegame ) ) {
|
if ( !string_equal( gamename, basegame ) ) {
|
||||||
// ~/.<gameprefix>/<fs_game>
|
// ~/.<gameprefix>/<fs_game>
|
||||||
if ( userRoot && !string_equal( globalRoot, userRoot ) ) {
|
if ( !string_equal( globalRoot, userRoot ) ) {
|
||||||
StringOutputStream userGamePath( 256 );
|
GlobalFileSystem().initDirectory( str( userRoot, gamename, '/' ) ); // userGamePath
|
||||||
userGamePath << userRoot << gamename << '/';
|
|
||||||
GlobalFileSystem().initDirectory( userGamePath.c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// <fs_basepath>/<fs_game>
|
// <fs_basepath>/<fs_game>
|
||||||
{
|
{
|
||||||
StringOutputStream globalGamePath( 256 );
|
GlobalFileSystem().initDirectory( str( globalRoot, gamename, '/' ) ); // globalGamePath
|
||||||
globalGamePath << globalRoot << gamename << '/';
|
|
||||||
GlobalFileSystem().initDirectory( globalGamePath.c_str() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ~/.<gameprefix>/<fs_main>
|
// ~/.<gameprefix>/<fs_main>
|
||||||
if ( userRoot && !string_equal( globalRoot, userRoot ) ) {
|
if ( !string_equal( globalRoot, userRoot ) ) {
|
||||||
StringOutputStream userBasePath( 256 );
|
GlobalFileSystem().initDirectory( str( userRoot, basegame, '/' ) ); // userBasePath
|
||||||
userBasePath << userRoot << basegame << '/';
|
|
||||||
GlobalFileSystem().initDirectory( userBasePath.c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// <fs_basepath>/<fs_main>
|
// <fs_basepath>/<fs_main>
|
||||||
{
|
{
|
||||||
StringOutputStream globalBasePath( 256 );
|
GlobalFileSystem().initDirectory( str( globalRoot, basegame, '/' ) ); // globalBasePath
|
||||||
globalBasePath << globalRoot << basegame << '/';
|
|
||||||
GlobalFileSystem().initDirectory( globalBasePath.c_str() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -172,19 +165,20 @@ void bsp_init(){
|
||||||
build_set_variable( "GameName", gamename_get() );
|
build_set_variable( "GameName", gamename_get() );
|
||||||
|
|
||||||
const char* mapname = Map_Name( g_map );
|
const char* mapname = Map_Name( g_map );
|
||||||
|
StringOutputStream stream( 256 );
|
||||||
{
|
{
|
||||||
build_set_variable( "BspFile", StringOutputStream( 256 )( PathExtensionless( mapname ), ".bsp" ).c_str() );
|
build_set_variable( "BspFile", stream( PathExtensionless( mapname ), ".bsp" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( g_region_active ){
|
if( g_region_active ){
|
||||||
build_set_variable( "MapFile", StringOutputStream( 256 )( PathExtensionless( mapname ), ".reg" ).c_str() );
|
build_set_variable( "MapFile", stream( PathExtensionless( mapname ), ".reg" ) );
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
build_set_variable( "MapFile", mapname );
|
build_set_variable( "MapFile", mapname );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
build_set_variable( "MapName", StringOutputStream( 64 )( PathFilename( mapname ) ).c_str() );
|
build_set_variable( "MapName", stream( PathFilename( mapname ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -226,11 +226,8 @@ void create(){
|
||||||
// create shader
|
// create shader
|
||||||
{
|
{
|
||||||
StringOutputStream filename( 256 );
|
StringOutputStream filename( 256 );
|
||||||
filename << GlobalRadiant().getAppPath() << "gl/lighting_DBS_omni_vp.glsl";
|
createShader( m_program, filename( GlobalRadiant().getAppPath(), "gl/lighting_DBS_omni_vp.glsl" ), GL_VERTEX_SHADER_ARB );
|
||||||
createShader( m_program, filename.c_str(), GL_VERTEX_SHADER_ARB );
|
createShader( m_program, filename( GlobalRadiant().getAppPath(), "gl/lighting_DBS_omni_fp.glsl" ), GL_FRAGMENT_SHADER_ARB );
|
||||||
filename.clear();
|
|
||||||
filename << GlobalRadiant().getAppPath() << "gl/lighting_DBS_omni_fp.glsl";
|
|
||||||
createShader( m_program, filename.c_str(), GL_FRAGMENT_SHADER_ARB );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLSLProgram_link( m_program );
|
GLSLProgram_link( m_program );
|
||||||
|
|
@ -335,11 +332,8 @@ void create(){
|
||||||
// create shader
|
// create shader
|
||||||
{
|
{
|
||||||
StringOutputStream filename( 256 );
|
StringOutputStream filename( 256 );
|
||||||
filename << GlobalRadiant().getAppPath() << "gl/zfill_vp.glsl";
|
createShader( m_program, filename( GlobalRadiant().getAppPath(), "gl/zfill_vp.glsl" ), GL_VERTEX_SHADER_ARB );
|
||||||
createShader( m_program, filename.c_str(), GL_VERTEX_SHADER_ARB );
|
createShader( m_program, filename( GlobalRadiant().getAppPath(), "gl/zfill_fp.glsl" ), GL_FRAGMENT_SHADER_ARB );
|
||||||
filename.clear();
|
|
||||||
filename << GlobalRadiant().getAppPath() << "gl/zfill_fp.glsl";
|
|
||||||
createShader( m_program, filename.c_str(), GL_FRAGMENT_SHADER_ARB );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GLSLProgram_link( m_program );
|
GLSLProgram_link( m_program );
|
||||||
|
|
@ -407,14 +401,11 @@ void create(){
|
||||||
glGenProgramsARB( 1, &m_vertex_program );
|
glGenProgramsARB( 1, &m_vertex_program );
|
||||||
glBindProgramARB( GL_VERTEX_PROGRAM_ARB, m_vertex_program );
|
glBindProgramARB( GL_VERTEX_PROGRAM_ARB, m_vertex_program );
|
||||||
StringOutputStream filename( 256 );
|
StringOutputStream filename( 256 );
|
||||||
filename << GlobalRadiant().getAppPath() << "gl/lighting_DBS_omni_vp.glp";
|
createProgram( filename( GlobalRadiant().getAppPath(), "gl/lighting_DBS_omni_vp.glp" ), GL_VERTEX_PROGRAM_ARB );
|
||||||
createProgram( filename.c_str(), GL_VERTEX_PROGRAM_ARB );
|
|
||||||
|
|
||||||
glGenProgramsARB( 1, &m_fragment_program );
|
glGenProgramsARB( 1, &m_fragment_program );
|
||||||
glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, m_fragment_program );
|
glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, m_fragment_program );
|
||||||
filename.clear();
|
createProgram( filename( GlobalRadiant().getAppPath(), "gl/lighting_DBS_omni_fp.glp" ), GL_FRAGMENT_PROGRAM_ARB );
|
||||||
filename << GlobalRadiant().getAppPath() << "gl/lighting_DBS_omni_fp.glp";
|
|
||||||
createProgram( filename.c_str(), GL_FRAGMENT_PROGRAM_ARB );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisable( GL_VERTEX_PROGRAM_ARB );
|
glDisable( GL_VERTEX_PROGRAM_ARB );
|
||||||
|
|
@ -509,14 +500,11 @@ void create(){
|
||||||
glGenProgramsARB( 1, &m_vertex_program );
|
glGenProgramsARB( 1, &m_vertex_program );
|
||||||
glBindProgramARB( GL_VERTEX_PROGRAM_ARB, m_vertex_program );
|
glBindProgramARB( GL_VERTEX_PROGRAM_ARB, m_vertex_program );
|
||||||
StringOutputStream filename( 256 );
|
StringOutputStream filename( 256 );
|
||||||
filename << GlobalRadiant().getAppPath() << "gl/zfill_vp.glp";
|
createProgram( filename( GlobalRadiant().getAppPath(), "gl/zfill_vp.glp" ), GL_VERTEX_PROGRAM_ARB );
|
||||||
createProgram( filename.c_str(), GL_VERTEX_PROGRAM_ARB );
|
|
||||||
|
|
||||||
glGenProgramsARB( 1, &m_fragment_program );
|
glGenProgramsARB( 1, &m_fragment_program );
|
||||||
glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, m_fragment_program );
|
glBindProgramARB( GL_FRAGMENT_PROGRAM_ARB, m_fragment_program );
|
||||||
filename.clear();
|
createProgram( filename( GlobalRadiant().getAppPath(), "gl/zfill_fp.glp" ), GL_FRAGMENT_PROGRAM_ARB );
|
||||||
filename << GlobalRadiant().getAppPath() << "gl/zfill_fp.glp";
|
|
||||||
createProgram( filename.c_str(), GL_FRAGMENT_PROGRAM_ARB );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisable( GL_VERTEX_PROGRAM_ARB );
|
glDisable( GL_VERTEX_PROGRAM_ARB );
|
||||||
|
|
|
||||||
|
|
@ -661,34 +661,24 @@ typedef ReferenceCaller1<TextureBrowser, bool, TextureBrowser_importShowScrollba
|
||||||
==============
|
==============
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool endswith( const char *haystack, const char *needle ){
|
|
||||||
size_t lh = strlen( haystack );
|
|
||||||
size_t ln = strlen( needle );
|
|
||||||
if ( lh < ln ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return !memcmp( haystack + ( lh - ln ), needle, ln );
|
|
||||||
}
|
|
||||||
|
|
||||||
bool texture_name_ignore( const char* name ){
|
bool texture_name_ignore( const char* name ){
|
||||||
StringOutputStream strTemp( string_length( name ) );
|
auto temp = StringOutputStream( 64 )( LowerCase( name ) );
|
||||||
strTemp << LowerCase( name );
|
|
||||||
|
|
||||||
return
|
return
|
||||||
endswith( strTemp.c_str(), ".specular" ) ||
|
string_equal_suffix( temp, ".specular" ) ||
|
||||||
endswith( strTemp.c_str(), ".glow" ) ||
|
string_equal_suffix( temp, ".glow" ) ||
|
||||||
endswith( strTemp.c_str(), ".bump" ) ||
|
string_equal_suffix( temp, ".bump" ) ||
|
||||||
endswith( strTemp.c_str(), ".diffuse" ) ||
|
string_equal_suffix( temp, ".diffuse" ) ||
|
||||||
endswith( strTemp.c_str(), ".blend" ) ||
|
string_equal_suffix( temp, ".blend" ) ||
|
||||||
endswith( strTemp.c_str(), ".alpha" ) ||
|
string_equal_suffix( temp, ".alpha" ) ||
|
||||||
endswith( strTemp.c_str(), "_norm" ) ||
|
string_equal_suffix( temp, "_norm" ) ||
|
||||||
endswith( strTemp.c_str(), "_bump" ) ||
|
string_equal_suffix( temp, "_bump" ) ||
|
||||||
endswith( strTemp.c_str(), "_glow" ) ||
|
string_equal_suffix( temp, "_glow" ) ||
|
||||||
endswith( strTemp.c_str(), "_gloss" ) ||
|
string_equal_suffix( temp, "_gloss" ) ||
|
||||||
endswith( strTemp.c_str(), "_pants" ) ||
|
string_equal_suffix( temp, "_pants" ) ||
|
||||||
endswith( strTemp.c_str(), "_shirt" ) ||
|
string_equal_suffix( temp, "_shirt" ) ||
|
||||||
endswith( strTemp.c_str(), "_reflect" ) ||
|
string_equal_suffix( temp, "_reflect" ) ||
|
||||||
endswith( strTemp.c_str(), "_alpha" ) ||
|
string_equal_suffix( temp, "_alpha" ) ||
|
||||||
0;
|
0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1966,38 +1956,31 @@ void TextureBrowser_constructSearchButton(){
|
||||||
|
|
||||||
void TextureBrowser_checkTagFile(){
|
void TextureBrowser_checkTagFile(){
|
||||||
const char SHADERTAG_FILE[] = "shadertags.xml";
|
const char SHADERTAG_FILE[] = "shadertags.xml";
|
||||||
CopiedString default_filename, rc_filename;
|
|
||||||
StringOutputStream stream( 256 );
|
|
||||||
|
|
||||||
stream << LocalRcPath_get();
|
auto rc_filename = StringOutputStream( 256 )( LocalRcPath_get(), SHADERTAG_FILE );
|
||||||
stream << SHADERTAG_FILE;
|
|
||||||
rc_filename = stream.c_str();
|
|
||||||
|
|
||||||
if ( file_exists( rc_filename.c_str() ) ) {
|
if ( file_exists( rc_filename ) ) {
|
||||||
g_TextureBrowser.m_tags = TagBuilder.OpenXmlDoc( rc_filename.c_str() );
|
g_TextureBrowser.m_tags = TagBuilder.OpenXmlDoc( rc_filename );
|
||||||
|
|
||||||
if ( g_TextureBrowser.m_tags ) {
|
if ( g_TextureBrowser.m_tags ) {
|
||||||
globalOutputStream() << "Loading tag file " << rc_filename.c_str() << ".\n";
|
globalOutputStream() << "Loading tag file " << rc_filename << ".\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// load default tagfile
|
// load default tagfile
|
||||||
stream.clear();
|
auto default_filename = StringOutputStream( 256 )( g_pGameDescription->mGameToolsPath.c_str(), SHADERTAG_FILE );
|
||||||
stream << g_pGameDescription->mGameToolsPath.c_str();
|
|
||||||
stream << SHADERTAG_FILE;
|
|
||||||
default_filename = stream.c_str();
|
|
||||||
|
|
||||||
if ( file_exists( default_filename.c_str() ) ) {
|
if ( file_exists( default_filename ) ) {
|
||||||
g_TextureBrowser.m_tags = TagBuilder.OpenXmlDoc( default_filename.c_str(), rc_filename.c_str() );
|
g_TextureBrowser.m_tags = TagBuilder.OpenXmlDoc( default_filename, rc_filename );
|
||||||
|
|
||||||
if ( g_TextureBrowser.m_tags ) {
|
if ( g_TextureBrowser.m_tags ) {
|
||||||
globalOutputStream() << "Loading default tag file " << default_filename.c_str() << ".\n";
|
globalOutputStream() << "Loading default tag file " << default_filename << ".\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
globalWarningStream() << "Unable to find default tag file " << default_filename.c_str() << ". No tag support. Plugins -> ShaderPlug -> Create tag file: to start using texture tags\n";
|
globalWarningStream() << "Unable to find default tag file " << default_filename << ". No tag support. Plugins -> ShaderPlug -> Create tag file: to start using texture tags\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1820,22 +1820,17 @@ void XYWnd::PaintSizeInfo( const int nDim1, const int nDim2 ){
|
||||||
v[nDim1] = mid[nDim1];
|
v[nDim1] = mid[nDim1];
|
||||||
v[nDim2] = min[nDim2] - ( 10 + 2 + fontHeight ) / m_fScale;
|
v[nDim2] = min[nDim2] - ( 10 + 2 + fontHeight ) / m_fScale;
|
||||||
glRasterPos3fv( vector3_to_array( v ) );
|
glRasterPos3fv( vector3_to_array( v ) );
|
||||||
dimensions << dimStrings[nDim1] << size[nDim1];
|
GlobalOpenGL().drawString( dimensions( dimStrings[nDim1], size[nDim1] ) );
|
||||||
GlobalOpenGL().drawString( dimensions.c_str() );
|
|
||||||
dimensions.clear();
|
|
||||||
|
|
||||||
v[nDim1] = max[nDim1] + 16.f / m_fScale;
|
v[nDim1] = max[nDim1] + 16.f / m_fScale;
|
||||||
v[nDim2] = mid[nDim2] - fontHeight / m_fScale / 2;
|
v[nDim2] = mid[nDim2] - fontHeight / m_fScale / 2;
|
||||||
glRasterPos3fv( vector3_to_array( v ) );
|
glRasterPos3fv( vector3_to_array( v ) );
|
||||||
dimensions << dimStrings[nDim2] << size[nDim2];
|
GlobalOpenGL().drawString( dimensions( dimStrings[nDim2], size[nDim2] ) );
|
||||||
GlobalOpenGL().drawString( dimensions.c_str() );
|
|
||||||
dimensions.clear();
|
|
||||||
|
|
||||||
v[nDim1] = min[nDim1] + 4.f;
|
v[nDim1] = min[nDim1] + 4.f;
|
||||||
v[nDim2] = max[nDim2] + 5.f / m_fScale;
|
v[nDim2] = max[nDim2] + 5.f / m_fScale;
|
||||||
glRasterPos3fv( vector3_to_array( v ) );
|
glRasterPos3fv( vector3_to_array( v ) );
|
||||||
dimensions << "(" << dimStrings[nDim1] << min[nDim1] << " " << dimStrings[nDim2] << max[nDim2] << ")";
|
GlobalOpenGL().drawString( dimensions( "(", dimStrings[nDim1], min[nDim1], " ", dimStrings[nDim2], max[nDim2], ")" ) );
|
||||||
GlobalOpenGL().drawString( dimensions.c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class XYRenderer : public Renderer
|
class XYRenderer : public Renderer
|
||||||
|
|
@ -2123,9 +2118,7 @@ void XYWnd::XY_Draw(){
|
||||||
|
|
||||||
glRasterPos3f( 2.f, 0.f, 0.0f );
|
glRasterPos3f( 2.f, 0.f, 0.0f );
|
||||||
extern const char* Renderer_GetStats();
|
extern const char* Renderer_GetStats();
|
||||||
StringOutputStream stream;
|
GlobalOpenGL().drawString( StringOutputStream( 64 )( Renderer_GetStats(), " | f2f: ", m_render_time.elapsed_msec() ) );
|
||||||
stream << Renderer_GetStats() << " | f2f: " << m_render_time.elapsed_msec();
|
|
||||||
GlobalOpenGL().drawString( stream.c_str() );
|
|
||||||
m_render_time.start();
|
m_render_time.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user