示例#1
0
    BehaviorTree* Workspace::LoadBehaviorTree(const char* relativePath)
    {
        behaviac::string strRelativePath(relativePath);

        if (m_behaviortrees[strRelativePath] != NULL)
        {
            return m_behaviortrees[strRelativePath];
        }
        else
        {
            bool bOk = this->Load(relativePath, true);

            if (bOk)
            {
                return m_behaviortrees[strRelativePath];
            }
        }

        return NULL;
    }
示例#2
0
BOOL CTemplateManager::Init()
{
	//Graham 20/10/97
	if (Camelot.DeclareSection( _T("NewTemplates"), 10))
	{
		Camelot.DeclarePref( _T("NewTemplates"), _T("DefaultAnimationFile"), &ms_strDefaultAnimationTemplate);
		Camelot.DeclarePref( _T("NewTemplates"), _T("DefaultDrawingFile"), &ms_strDefaultDrawingTemplate);
	}

	if (ms_strDefaultAnimationTemplate==String_256(_T("")))
	{
		String_256 strNameOfAnimationTemplate( _R(IDS_NEWTEMPLATES_DEFAULTANIMATIONFILE) );
		String_256 strPathOfTemplate( GetTemplatesPath() );
		strPathOfTemplate += strNameOfAnimationTemplate;

		ms_strDefaultAnimationTemplate=strPathOfTemplate;

		TRACEUSER( "jlh92", _T("DefAnimTempl = %s\n"), PCTSTR(ms_strDefaultAnimationTemplate) );
	}

	if( ms_strDefaultDrawingTemplate == String_256( _T("") ) || 
		0 == camStrcmp( ms_strDefaultDrawingTemplate, _T("default.xar") ) )
	{
		ms_strDefaultDrawingTemplate=String_256(_R(IDS_DEFAULTDOCNAME));

PORTNOTETRACE("other","CTemplateManager::Init - remove code to setup paths");
#if !defined(EXCLUDE_FROM_XARALX)
		//Then assume it's the exe path with \templates\drawing.xar on the end
		TCHAR Pathname[MAX_PATH];

		if(GetModuleFileName(NULL, Pathname, MAX_PATH) == 0) //Should be in the winoil really
			return FALSE;

		// Put the path name into a string
		String_256 strPathOfExe(Pathname);
		PathName pathPathOfExe(strPathOfExe);

		strPathOfExe = pathPathOfExe.GetLocation(TRUE);

		//And add "templates\" to the end
		String_256 strTemplatesDirectory(_R(IDS_NEWTEMPLATES_RELATIVEPATH));
		String_256 strNameOfDrawingTemplate(_R(IDS_DEFAULTDOCNAME));

		String_256 strPathOfTemplate=strPathOfExe;
		strPathOfTemplate+=strTemplatesDirectory;
		strPathOfTemplate+=strNameOfDrawingTemplate;

		ms_strDefaultDrawingTemplate=strPathOfTemplate;
#endif
	}

	// As the preference system is up, declare our preference to it
	// This is the pathname that the templates should be loaded from and saved to
	// If blank, the default, then it should use the exe path
	GetApplication()->DeclareSection(TEXT("Templates"), 2);
	GetApplication()->DeclarePref(TEXT("Templates"), TEXT("Path"), &m_TemplatesPath);
	GetApplication()->DeclarePref(TEXT("Templates"), TEXT("LocalPath"), &m_LocalTemplatesPath);
	
	//Graham 21/10/97: If it is blank, then we should use the
	//exe path with "\templates\" on the end
	if( m_TemplatesPath.IsEmpty() || !SGLibOil::DirExists( m_TemplatesPath ) )
	{
		// Put the path name into a string
		m_TemplatesPath = CCamApp::GetResourceDirectory();

		//And add "templates\" to the end
		String_256 strRelativePath(_R(IDS_NEWTEMPLATES_RELATIVEPATH));

		m_TemplatesPath+=strRelativePath;

#if defined(_DEBUG)
		if( !SGLibOil::DirExists( m_TemplatesPath ) )
			m_TemplatesPath = _T("/usr/share/xaralx/Templates/");
#endif
	}

	if( m_LocalTemplatesPath.IsEmpty() || !SGLibOil::DirExists( m_LocalTemplatesPath ) )
	{
		wxString		strHome( ::wxGetHomeDir() );
		m_LocalTemplatesPath = (PCTSTR)strHome;
		m_LocalTemplatesPath += _T("/.xaralx/templates/");
	}

	TRACEUSER( "jlh92", _T("Using %s as template store\n"), PCTSTR(m_TemplatesPath) );
	return TRUE;
}