minor refactoring

This commit is contained in:
Garux 2020-05-05 12:32:44 +03:00
parent 13f877b7db
commit 002f45d6d9
2 changed files with 20 additions and 21 deletions

View File

@ -232,19 +232,21 @@ DirectoryCleaned( const char* path ) : m_path( path ){
template<typename TextOutputStreamType>
TextOutputStreamType& ostream_write( TextOutputStreamType& ostream, const DirectoryCleaned& path ){
const char* i = path.m_path;
for (; *i != '\0'; ++i )
{
if ( *i == '\\' ) {
if( !string_empty( i ) ){
for (; *i != '\0'; ++i )
{
if ( *i == '\\' ) {
ostream << '/';
}
else
{
ostream << *i;
}
}
--i;
if ( *i != '/' && *i != '\\' ) {
ostream << '/';
}
else
{
ostream << *i;
}
}
char c = *( i - 1 );
if ( c != '/' && c != '\\' && !string_empty( path.m_path ) ) {
ostream << '/';
}
return ostream;
}

View File

@ -1151,22 +1151,20 @@ public:
// parse string of format *pathToLoad/depth*path2ToLoad/depth*
// */depth* for root path
ModelFolders( const char* pathsString ){
char* str = strdup( pathsString );
for( char* s = str; *s; ++s )
if( *s == '\\' )
*s = '/';
StringOutputStream str( 128 );
str << PathCleaned( pathsString );
char* start = str;
const char* start = str.c_str();
while( 1 ){
while( *start == '*' )
++start;
char* end = start;
const char* end = start;
while( *end && *end != '*' )
++end;
if( start == end )
break;
char* slash = nullptr;
for( char* s = start; s != end; ++s )
const char* slash = nullptr;
for( const char* s = start; s != end; ++s )
if( *s == '/' )
slash = s;
if( slash != nullptr && end - slash > 1 ){
@ -1178,7 +1176,6 @@ public:
start = end;
}
free( str );
if( m_modelFoldersMap.empty() )
m_modelFoldersMap.emplace( "models/", 99 );
}
@ -1314,7 +1311,7 @@ GtkWidget* ModelBrowser_constructWindow( GtkWindow* toplevel ){
gtk_table_attach( GTK_TABLE( table ), w, 2, 3, 0, 1, GTK_SHRINK, GTK_FILL, 0, 0 );
gtk_widget_show( w );
GtkAdjustment *vadjustment = gtk_range_get_adjustment( GTK_RANGE( g_ModelBrowser.m_gl_scroll ) );
GtkAdjustment *vadjustment = gtk_range_get_adjustment( GTK_RANGE( w ) );
g_signal_connect( G_OBJECT( vadjustment ), "value_changed", G_CALLBACK( ModelBrowser_scrollbarScroll ), &g_ModelBrowser );
}
{ // gl_widget