예제 #1
0
wxString wxStandardPaths::GetAppDir() const
{
    if ( m_appDir.empty() )
    {
        m_appDir = wxFileName(wxGetFullModuleName()).GetPath();
    }

    return m_appDir;
}
예제 #2
0
/* static */
wxString wxStandardPaths::GetAppDir()
{
    wxFileName fn(wxGetFullModuleName());

    // allow running the apps directly from build directory in debug builds
#ifdef __WXDEBUG__
    wxString lastdir;
    if ( fn.GetDirCount() )
    {
        lastdir = fn.GetDirs().Last();
        lastdir.MakeLower();
        if ( lastdir.Matches(_T("debug*")) || lastdir.Matches(_T("vc_msw*")) )
            fn.RemoveLastDir();
    }
#endif // __WXDEBUG__

    return fn.GetPath();
}
예제 #3
0
파일: utils.cpp 프로젝트: 252525fb/rpcs3
const wxChar* wxGetHomeDir(wxString *pstr)
{
    wxString& strDir = *pstr;

    // first branch is for Cygwin
#if defined(__UNIX__) && !defined(__WINE__)
    const wxChar *szHome = wxGetenv("HOME");
    if ( szHome == NULL ) {
      // we're homeless...
      wxLogWarning(_("can't find user's HOME, using current directory."));
      strDir = wxT(".");
    }
    else
       strDir = szHome;

    // add a trailing slash if needed
    if ( strDir.Last() != wxT('/') )
      strDir << wxT('/');

    #ifdef __CYGWIN__
        // Cygwin returns unix type path but that does not work well
        static wxChar windowsPath[MAX_PATH];
        cygwin_conv_to_full_win32_path(strDir, windowsPath);
        strDir = windowsPath;
    #endif
#elif defined(__WXWINCE__)
    strDir = wxT("\\");
#else
    strDir.clear();

    // If we have a valid HOME directory, as is used on many machines that
    // have unix utilities on them, we should use that.
    const wxChar *szHome = wxGetenv(wxT("HOME"));

    if ( szHome != NULL )
    {
        strDir = szHome;
    }
    else // no HOME, try HOMEDRIVE/PATH
    {
        szHome = wxGetenv(wxT("HOMEDRIVE"));
        if ( szHome != NULL )
            strDir << szHome;
        szHome = wxGetenv(wxT("HOMEPATH"));

        if ( szHome != NULL )
        {
            strDir << szHome;

            // the idea is that under NT these variables have default values
            // of "%systemdrive%:" and "\\". As we don't want to create our
            // config files in the root directory of the system drive, we will
            // create it in our program's dir. However, if the user took care
            // to set HOMEPATH to something other than "\\", we suppose that he
            // knows what he is doing and use the supplied value.
            if ( wxStrcmp(szHome, wxT("\\")) == 0 )
                strDir.clear();
        }
    }

    if ( strDir.empty() )
    {
        // If we have a valid USERPROFILE directory, as is the case in
        // Windows NT, 2000 and XP, we should use that as our home directory.
        szHome = wxGetenv(wxT("USERPROFILE"));

        if ( szHome != NULL )
            strDir = szHome;
    }

    if ( !strDir.empty() )
    {
        // sometimes the value of HOME may be "%USERPROFILE%", so reexpand the
        // value once again, it shouldn't hurt anyhow
        strDir = wxExpandEnvVars(strDir);
    }
    else // fall back to the program directory
    {
        // extract the directory component of the program file name
        wxSplitPath(wxGetFullModuleName(), &strDir, NULL, NULL);
    }
#endif  // UNIX/Win

    return strDir.c_str();
}
예제 #4
0
wxString wxStandardPaths::GetExecutablePath() const
{
    return wxGetFullModuleName();
}
예제 #5
0
wxString wxStandardPaths::GetPluginsDir() const
{
    return wxFileName(wxGetFullModuleName()).GetPath();
}
예제 #6
0
wxString wxStandardPaths::GetDataDir() const
{
    // under Windows each program is usually installed in its own directory and
    // so its datafiles are in the same directory as its main executable
    return wxFileName(wxGetFullModuleName()).GetPath();
}
예제 #7
0
//------------------------------------------------------------------------------
bool WxMainApp::OnInit()
{
	//get base dir
    wxString strDir;
	wxSplitPath(wxGetFullModuleName(), &strDir, NULL, NULL);
	m_strBaseDir = strDir.char_str(wxConvUTF8).data();
	m_strBaseDir += "\\";

	///////////////////////////////////////////////////////////////////////////////////////////////////
	//initialize guiex system
	try
	{
		CGUIFrameworkEditor::ms_pFramework = new CGUIFrameworkEditor( );
		CGUIFrameworkEditor::ms_pFramework->Initialize( CGUIIntSize(1024,768), "" );

		GSystem->SetDrawExtraInfo( false );
		GSystem->SetPlayingAs( false );
		GSystem->SetEditorMode( true );
	}
	catch (CGUIBaseException& rError)
	{
		wxMessageBox( Gui2wxString(rError.what()), _T("error") );

		if( CGUIFrameworkEditor::ms_pFramework )
		{
			CGUIFrameworkEditor::ms_pFramework->Release();
			delete CGUIFrameworkEditor::ms_pFramework;
			CGUIFrameworkEditor::ms_pFramework = NULL;
		}
	}

	//load scintilla dll
	m_hSciDll = LoadLibrary(_T("SciLexer.DLL"));
	if (m_hSciDll==NULL)
	{
		wxMessageBox(_T("The Scintilla DLL could not be loaded."),
			_T("Error loading Scintilla"), wxOK|wxCENTER|wxICON_ERROR,NULL);
		return false;
	}

	//load localization config file
	if( 0 != CPropertyConfigMgr::Instance()->ReadLocalizationConfig(GetBaseDir() + "../editorconfig/localization_config.xml"))
	{
		wxMessageBox(_T("failed to read config file localization_config.xml!"), _T("error"));
		return false;
	}

	//load base config file
	std::vector<wxFileName> vecBaseConfigFile;
	vecBaseConfigFile.push_back( Gui2wxString(GetBaseDir() + "../editorconfig/libguiex_editor_config.xml"));
	vecBaseConfigFile.push_back( Gui2wxString(GetBaseDir() + "../editorconfig/libguiex_editor_config_box2d.xml"));
	vecBaseConfigFile.push_back( Gui2wxString(GetBaseDir() + "../editorconfig/libguiex_editor_config_game.xml"));

	for( uint32 i=0; i<vecBaseConfigFile.size(); ++i )
	{
		if( 0 != CPropertyConfigMgr::Instance()->ReadPropertyConfig( vecBaseConfigFile[i].GetFullPath()))
		{
			wxMessageBox( wxString::Format( _T("failed to read property config file: %s"), vecBaseConfigFile[i].GetFullPath() ), _T("error"));
			return false;
		}
	}

	//load extend config file
	if( wxMessageBox( _T("Do you want to load extend widget config file?"), _T("Questing"), wxYES_NO | wxICON_QUESTION) == wxYES )
	{
		wxFileDialog aDlg(NULL, _T("Choose widget config files"), Gui2wxString(GetBaseDir() + "../editorconfig/"), wxEmptyString, _T("widget config files (*.xml)|*.xml"), wxFD_OPEN | wxFD_MULTIPLE | wxFD_FILE_MUST_EXIST );
		if( wxID_OK == aDlg.ShowModal())
		{
			//try load
			wxArrayString arrayFiles;
			aDlg.GetPaths( arrayFiles );
			for( uint32 i=0; i<arrayFiles.size(); ++i )
			{
				if( std::find(vecBaseConfigFile.begin(), vecBaseConfigFile.end(), arrayFiles[i]) != vecBaseConfigFile.end() )
				{
					//base config file, ignore it
					continue;
				}

				if( 0 != CPropertyConfigMgr::Instance()->ReadPropertyConfig( arrayFiles[i]))
				{
					wxMessageBox( wxString::Format( _T("failed to read property config file: %s"), arrayFiles[i] ), _T("error"));
					return false;
				}
			}
		}
	}

	//check default property
	if( false == CheckProperty() )
	{
		wxMessageBox(_T("check default property!"), _T("error"));
		return false;
	}

	//create frame
	wxFrame* frame = new WxMainFrame(NULL,
		wxID_ANY,
		wxT("libguiex editor"),
		wxDefaultPosition,
		wxSize(1024, 768));
	SetTopWindow(frame);
	frame->Show();

	wxToolTip::Enable(true);
	wxToolTip::SetDelay(1000);

	return true;
}