+ Changed wxT macro from _T() to _()

+ Added hints to 3d_filename_resolver to help transition from
  legacy 3D model resolver behavior.
This commit is contained in:
Cirilo Bernardo 2016-01-19 11:05:40 +11:00
parent d3f68e6482
commit ec9acfd410
2 changed files with 69 additions and 48 deletions

View File

@ -35,8 +35,9 @@
#define S3D_RESOLVER_CONFIG wxT( "3Dresolver.cfg" ) #define S3D_RESOLVER_CONFIG wxT( "3Dresolver.cfg" )
// flag bits used to track different one-off messages to users // flag bits used to track different one-off messages to users
#define ERRFLG_NODIR (1) #define ERRFLG_ALIAS (1)
#define ERRFLG_RELPATH (2) #define ERRFLG_RELPATH (2)
#define ERRFLG_ENVPATH (4)
static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& aResult ); static bool getHollerith( const std::string& aString, size_t& aIndex, wxString& aResult );
@ -246,7 +247,15 @@ wxString S3D_FILENAME_RESOLVER::ResolvePath( const wxString& aFileName )
return tname; return tname;
} }
// XXX - no such path - consider showing the user a pop-up message if( !( m_errflags & ERRFLG_ENVPATH ) )
{
m_errflags |= ERRFLG_ENVPATH;
wxString errmsg = _( "No such path; ensure the environment var is defined" );
errmsg.append( "\n" );
errmsg.append( tname );
wxMessageBox( errmsg, _( "3D file resolver" ) );
}
return wxEmptyString; return wxEmptyString;
} }
@ -301,7 +310,15 @@ wxString S3D_FILENAME_RESOLVER::ResolvePath( const wxString& aFileName )
if( !SplitAlias( tname, alias, relpath ) ) if( !SplitAlias( tname, alias, relpath ) )
{ {
// XXX - no such path - consider showing the user a pop-up message if( !( m_errflags & ERRFLG_RELPATH ) )
{
m_errflags |= ERRFLG_RELPATH;
wxString errmsg = _( "No such path; ensure KISYS3DMOD is correctly defined" );
errmsg.append( "\n" );
errmsg.append( tname );
wxMessageBox( errmsg, _( "3D file resolver" ) );
}
return wxEmptyString; return wxEmptyString;
} }
@ -328,10 +345,14 @@ wxString S3D_FILENAME_RESOLVER::ResolvePath( const wxString& aFileName )
++sPL; ++sPL;
} }
// XXX - no such path - consider showing the user a pop-up message if( !( m_errflags & ERRFLG_ALIAS ) )
wxString errmsg = _( "filename could not be resolved" ); {
std::cerr << " * [3D Model] " << errmsg.ToUTF8() << " '"; m_errflags |= ERRFLG_ALIAS;
std::cerr << aFileName.ToUTF8() << "'\n"; wxString errmsg = _( "No such path; ensure the path alias is defined" );
errmsg.append( "\n" );
errmsg.append( tname );
wxMessageBox( errmsg, _( "3D file resolver" ) );
}
return wxEmptyString; return wxEmptyString;
} }
@ -361,18 +382,18 @@ bool S3D_FILENAME_RESOLVER::addPath( const S3D_ALIAS& aPath )
if( !sPL->m_pathvar.empty() && !tpath.m_pathvar.empty() if( !sPL->m_pathvar.empty() && !tpath.m_pathvar.empty()
&& !tpath.m_pathvar.Cmp( sPL->m_pathvar ) ) && !tpath.m_pathvar.Cmp( sPL->m_pathvar ) )
{ {
wxString msg = _T( "This alias: " ); wxString msg = _( "This alias: " );
msg.append( tpath.m_alias ); msg.append( tpath.m_alias );
msg.append( wxT( "\n" ) ); msg.append( wxT( "\n" ) );
msg.append( _T( "This path: " ) ); msg.append( _( "This path: " ) );
msg.append( tpath.m_pathvar ); msg.append( tpath.m_pathvar );
msg.append( wxT( "\n" ) ); msg.append( wxT( "\n" ) );
msg.append( _T( "Existing alias: " ) ); msg.append( _( "Existing alias: " ) );
msg.append( sPL->m_alias ); msg.append( sPL->m_alias );
msg.append( wxT( "\n" ) ); msg.append( wxT( "\n" ) );
msg.append( _T( "Existing path: " ) ); msg.append( _( "Existing path: " ) );
msg.append( sPL->m_pathvar ); msg.append( sPL->m_pathvar );
wxMessageBox( msg, _T( "Bad alias (duplicate path)" ) ); wxMessageBox( msg, _( "Bad alias (duplicate path)" ) );
return false; return false;
} }
@ -381,24 +402,24 @@ bool S3D_FILENAME_RESOLVER::addPath( const S3D_ALIAS& aPath )
{ {
if( !tpath.m_pathexp.Cmp( sPL->m_pathexp ) ) if( !tpath.m_pathexp.Cmp( sPL->m_pathexp ) )
{ {
wxString msg = _T( "This alias: " ); wxString msg = _( "This alias: " );
msg.append( tpath.m_alias ); msg.append( tpath.m_alias );
msg.append( wxT( "\n" ) ); msg.append( wxT( "\n" ) );
msg.append( _T( "Existing alias: " ) ); msg.append( _( "Existing alias: " ) );
msg.append( sPL->m_alias ); msg.append( sPL->m_alias );
msg.append( wxT( "\n" ) ); msg.append( wxT( "\n" ) );
msg.append( _T( "This path: " ) ); msg.append( _( "This path: " ) );
msg.append( tpath.m_pathexp ); msg.append( tpath.m_pathexp );
msg.append( wxT( "\n" ) ); msg.append( wxT( "\n" ) );
msg.append( _T( "Existing path: " ) ); msg.append( _( "Existing path: " ) );
msg.append( sPL->m_pathexp ); msg.append( sPL->m_pathexp );
msg.append( wxT( "\n" ) ); msg.append( wxT( "\n" ) );
msg.append( _T( "This full path: " ) ); msg.append( _( "This full path: " ) );
msg.append( tpath.m_pathexp ); msg.append( tpath.m_pathexp );
msg.append( wxT( "\n" ) ); msg.append( wxT( "\n" ) );
msg.append( _T( "Existing full path: " ) ); msg.append( _( "Existing full path: " ) );
msg.append( sPL->m_pathexp ); msg.append( sPL->m_pathexp );
wxMessageBox( msg, _T( "Bad alias (duplicate path)" ) ); wxMessageBox( msg, _( "Bad alias (duplicate path)" ) );
return false; return false;
} }
@ -406,18 +427,18 @@ bool S3D_FILENAME_RESOLVER::addPath( const S3D_ALIAS& aPath )
if( tpath.m_pathexp.find( sPL->m_pathexp ) != wxString::npos if( tpath.m_pathexp.find( sPL->m_pathexp ) != wxString::npos
|| sPL->m_pathexp.find( tpath.m_pathexp ) != wxString::npos ) || sPL->m_pathexp.find( tpath.m_pathexp ) != wxString::npos )
{ {
wxString msg = _T( "This alias: " ); wxString msg = _( "This alias: " );
msg.append( tpath.m_alias ); msg.append( tpath.m_alias );
msg.append( wxT( "\n" ) ); msg.append( wxT( "\n" ) );
msg.append( _T( "This path: " ) ); msg.append( _( "This path: " ) );
msg.append( tpath.m_pathexp ); msg.append( tpath.m_pathexp );
msg.append( wxT( "\n" ) ); msg.append( wxT( "\n" ) );
msg.append( _T( "Existing alias: " ) ); msg.append( _( "Existing alias: " ) );
msg.append( sPL->m_alias ); msg.append( sPL->m_alias );
msg.append( wxT( "\n" ) ); msg.append( wxT( "\n" ) );
msg.append( _T( "Existing path: " ) ); msg.append( _( "Existing path: " ) );
msg.append( sPL->m_pathexp ); msg.append( sPL->m_pathexp );
wxMessageBox( msg, _T( "Bad alias (common path)" ) ); wxMessageBox( msg, _( "Bad alias (common path)" ) );
return false; return false;
} }
@ -425,15 +446,15 @@ bool S3D_FILENAME_RESOLVER::addPath( const S3D_ALIAS& aPath )
if( !tpath.m_alias.Cmp( sPL->m_alias ) ) if( !tpath.m_alias.Cmp( sPL->m_alias ) )
{ {
wxString msg = _T( "Alias: " ); wxString msg = _( "Alias: " );
msg.append( tpath.m_alias ); msg.append( tpath.m_alias );
msg.append( wxT( "\n" ) ); msg.append( wxT( "\n" ) );
msg.append( _T( "This path: " ) ); msg.append( _( "This path: " ) );
msg.append( tpath.m_pathvar ); msg.append( tpath.m_pathvar );
msg.append( wxT( "\n" ) ); msg.append( wxT( "\n" ) );
msg.append( _T( "Existing path: " ) ); msg.append( _( "Existing path: " ) );
msg.append( sPL->m_pathvar ); msg.append( sPL->m_pathvar );
wxMessageBox( msg, _T( "Bad alias (duplicate name)" ) ); wxMessageBox( msg, _( "Bad alias (duplicate name)" ) );
return false; return false;
} }
@ -538,7 +559,7 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
wxString errmsg = _( "3D configuration directory is unknown" ); wxString errmsg = _( "3D configuration directory is unknown" );
std::cerr << " * " << errmsg.ToUTF8() << "\n"; std::cerr << " * " << errmsg.ToUTF8() << "\n";
wxMessageBox( errmsg, _T( "Write 3D search path list" ) ); wxMessageBox( errmsg, _( "Write 3D search path list" ) );
return false; return false;
} }
@ -550,8 +571,8 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
if( m_Paths.empty() || 1 == m_Paths.size() ) if( m_Paths.empty() || 1 == m_Paths.size() )
{ {
wxMessageDialog md( NULL, wxMessageDialog md( NULL,
_T( "3D search path list is empty;\ncontinue to write empty file?" ), _( "3D search path list is empty;\ncontinue to write empty file?" ),
_T( "Write 3D search path list" ), wxYES_NO ); _( "Write 3D search path list" ), wxYES_NO );
if( md.ShowModal() == wxID_YES ) if( md.ShowModal() == wxID_YES )
{ {
@ -559,8 +580,8 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
if( !cfgFile.is_open() ) if( !cfgFile.is_open() )
{ {
wxMessageBox( _T( "Could not open configuration file" ), wxMessageBox( _( "Could not open configuration file" ),
_T( "Write 3D search path list" ) ); _( "Write 3D search path list" ) );
return false; return false;
} }
@ -579,8 +600,8 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; std::cerr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n";
wxString errmsg = _( "could not open configuration file " ); wxString errmsg = _( "could not open configuration file " );
std::cerr << " * " << errmsg.ToUTF8() << " '" << cfgname.ToUTF8() << "'\n"; std::cerr << " * " << errmsg.ToUTF8() << " '" << cfgname.ToUTF8() << "'\n";
wxMessageBox( _T( "Could not open configuration file" ), wxMessageBox( _( "Could not open configuration file" ),
_T( "Write 3D search path list" ) ); _( "Write 3D search path list" ) );
return false; return false;
} }
@ -616,8 +637,8 @@ bool S3D_FILENAME_RESOLVER::writePathList( void )
if( bad ) if( bad )
{ {
wxMessageBox( _T( "Problems writing configuration file" ), wxMessageBox( _( "Problems writing configuration file" ),
_T( "Write 3D search path list" ) ); _( "Write 3D search path list" ) );
return false; return false;
} }

View File

@ -105,8 +105,8 @@ bool DLG_3D_PATH_CONFIG::TransferDataFromWindow()
{ {
if( NULL == m_resolver ) if( NULL == m_resolver )
{ {
wxMessageBox( _T( "[BUG] No valid resolver; data will not be updated" ), wxMessageBox( _( "[BUG] No valid resolver; data will not be updated" ),
_T( "Update 3D search path list" ) ); _( "Update 3D search path list" ) );
return false; return false;
} }
@ -166,14 +166,14 @@ void DLG_3D_PATH_CONFIG::OnDelAlias( wxCommandEvent& event )
if( sel.empty() ) if( sel.empty() )
{ {
wxMessageBox( _T( "No entry selected" ), _T( "Delete alias entry" ) ); wxMessageBox( _( "No entry selected" ), _( "Delete alias entry" ) );
return; return;
} }
if( sel.size() > 1 ) if( sel.size() > 1 )
{ {
wxMessageBox( _T( "Multiple entries selected; please\nselect only one entry" ), wxMessageBox( _( "Multiple entries selected; please\nselect only one entry" ),
_T( "Delete alias entry" ) ); _( "Delete alias entry" ) );
return; return;
} }
@ -206,14 +206,14 @@ void DLG_3D_PATH_CONFIG::OnAliasMoveUp( wxCommandEvent& event )
if( sel.empty() ) if( sel.empty() )
{ {
wxMessageBox( _T( "No entry selected" ), _T( "Move alias up" ) ); wxMessageBox( _( "No entry selected" ), _( "Move alias up" ) );
return; return;
} }
if( sel.size() > 1 ) if( sel.size() > 1 )
{ {
wxMessageBox( _T( "Multiple entries selected; please\nselect only one entry" ), wxMessageBox( _( "Multiple entries selected; please\nselect only one entry" ),
_T( "Move alias up" ) ); _( "Move alias up" ) );
return; return;
} }
@ -247,14 +247,14 @@ void DLG_3D_PATH_CONFIG::OnAliasMoveDown( wxCommandEvent& event )
if( sel.empty() ) if( sel.empty() )
{ {
wxMessageBox( _T( "No entry selected" ), _T( "Move alias down" ) ); wxMessageBox( _( "No entry selected" ), _( "Move alias down" ) );
return; return;
} }
if( sel.size() > 1 ) if( sel.size() > 1 )
{ {
wxMessageBox( _T( "Multiple entries selected; please\nselect only one entry" ), wxMessageBox( _( "Multiple entries selected; please\nselect only one entry" ),
_T( "Move alias down" ) ); _( "Move alias down" ) );
return; return;
} }