bool Shader::loadScript( const FilePath& path, std::string& outStr ) const { Filesystem& fs = TSingleton< Filesystem >::getInstance(); File* file = fs.open( path, std::ios_base::in | std::ios_base::binary ); if ( file == NULL ) { LOG( "Shader::loadScript - can't open the file '%s'", path.c_str() ); return false; } StreamBuffer<char> fileContentsBuf( *file ); outStr = fileContentsBuf.getBuffer(); delete file; return true; }
Viewer::Settings::Settings(const std::string& applicationName, const FilePath& filepath): m_FilePath(filepath) { if(tinyxml2::XML_NO_ERROR != m_Document.LoadFile(filepath.c_str())) { throw std::runtime_error("Unable to load viewer settings file"); } if(nullptr == (m_pRoot = m_Document.RootElement())) { throw std::runtime_error("Invalid viewer settings file format (no root element)"); } auto pWindow = m_pRoot->FirstChildElement("Window"); if(!pWindow) { throw std::runtime_error("Invalid viewer settings file format (no Window element)"); } if(!getAttribute(*pWindow, "width", m_WindowSize.x) || !getAttribute(*pWindow, "height", m_WindowSize.y)) { throw std::runtime_error("Invalid viewer settings file format (no width/height params)"); } auto pViewController = m_pRoot->FirstChildElement("ViewController"); if(pViewController) { if(!getAttribute(*pViewController, "speedFarRatio", m_fSpeedFarRatio)) { throw std::runtime_error("Invalid viewer settings file format (no speedFarRatio params in ViewController)"); } } auto pFramebuffer = m_pRoot->FirstChildElement("Framebuffer"); if(!getAttribute(*pFramebuffer, "width", m_FramebufferSize.x) || !getAttribute(*pFramebuffer, "height", m_FramebufferSize.y)) { throw std::runtime_error("Invalid viewer settings file format (no width/height params for the framebuffer)"); } m_fFramebufferRatio = float(m_FramebufferSize.x) / m_FramebufferSize.y; auto cacheDirectory = filepath.directory() + "cache"; createDirectory(cacheDirectory); m_CacheFilePath = cacheDirectory + (applicationName + ".cache.bnz.xml"); if(tinyxml2::XML_NO_ERROR != m_CacheDocument.LoadFile(m_CacheFilePath.c_str())) { auto pRoot = m_CacheDocument.NewElement("Cache"); m_CacheDocument.InsertFirstChild(pRoot); } m_pCacheRoot = m_CacheDocument.RootElement(); }
bool Win32FileGroupDirectory::removeDirectory( const FilePath & _path ) { WChar filePath[MENGINE_MAX_PATH]; if( WINDOWSLAYER_SERVICE(m_serviceProvider) ->concatenateFilePath( m_path, _path, filePath, MENGINE_MAX_PATH ) == false ) { LOGGER_ERROR(m_serviceProvider)("Win32FileSystem::deleteFolder invlalid concatenate filePath '%s':'%s'" , m_path.c_str() , _path.c_str() ); return false; } //Double Zero! size_t fp_len = wcslen(filePath); filePath[fp_len] = L'\0'; filePath[fp_len + 1] = L'\0'; SHFILEOPSTRUCT fileop; ZeroMemory(&fileop, sizeof(SHFILEOPSTRUCT)); fileop.hwnd = NULL; fileop.wFunc = FO_DELETE; fileop.pFrom = filePath; fileop.pTo = NULL; fileop.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; fileop.fAnyOperationsAborted = FALSE; fileop.lpszProgressTitle = NULL; fileop.hNameMappings = NULL; int err = ::SHFileOperation( &fileop ); if( err != 0 ) { LOGGER_ERROR(m_serviceProvider)("Win32FileSystem::deleteFolder %ls error %d" , filePath , err ); return false; } return true; }
bool Win32FileGroupDirectory::existFile( const FilePath & _fileName ) const { WChar filePath[MENGINE_MAX_PATH]; if( WINDOWSLAYER_SERVICE(m_serviceProvider) ->concatenateFilePath( m_path, _fileName, filePath, MENGINE_MAX_PATH ) == false ) { LOGGER_ERROR(m_serviceProvider)("Win32FileSystem::existFile invlalid concatenate filePath '%s':'%s'" , m_path.c_str() , _fileName.c_str() ); return false; } bool result = WINDOWSLAYER_SERVICE(m_serviceProvider) ->fileExists( filePath ); return result; }
bool Win32FileGroupDirectory::openMappedFile( const FilePath & _fileName, const FileMappedInterfacePtr & _stream ) { if( _stream == nullptr ) { LOGGER_ERROR(m_serviceProvider)("Win32FileGroupDirectory::openMappedFile failed _stream == NULL" ); return false; } if( _stream->open( m_path, _fileName ) == false ) { LOGGER_ERROR(m_serviceProvider)("Win32FileGroupDirectory::openMappedFile failed open file '%s':'%s'" , m_path.c_str() , _fileName.c_str() ); return false; } return true; }
TEST(Foundation, FilePath) { { String tempString; FilePath pathCopy; FilePath path( TXT( "C:/Users/Test/File.notext.ext" ) ); HELIUM_TRACE( TraceLevels::Info, TXT( "path: %s\n" ), path.c_str() ); pathCopy = path; tempString = pathCopy.Directory().c_str(); pathCopy.Set( pathCopy.Directory() ); HELIUM_ASSERT( tempString == pathCopy.c_str() ); HELIUM_TRACE( TraceLevels::Info, TXT( "directory name: %s\n" ), *tempString ); pathCopy = path; tempString = pathCopy.Filename().c_str(); pathCopy.Set( pathCopy.Filename() ); HELIUM_ASSERT( tempString == pathCopy.c_str() ); HELIUM_TRACE( TraceLevels::Info, TXT( "filename: %s\n" ), *tempString ); pathCopy = path; tempString = pathCopy.Basename().c_str(); pathCopy.Set( pathCopy.Basename() ); HELIUM_ASSERT( tempString == pathCopy.c_str() ); HELIUM_TRACE( TraceLevels::Info, TXT( "base name: %s\n" ), *tempString ); pathCopy = path; tempString = pathCopy.Extension().c_str(); pathCopy.Set( pathCopy.Extension() ); HELIUM_ASSERT( tempString == pathCopy.c_str() ); HELIUM_TRACE( TraceLevels::Info, TXT( "extension: %s\n" ), *tempString ); } { FilePath dataDirectory; HELIUM_VERIFY( FileLocations::GetDataDirectory( dataDirectory ) ); HELIUM_TRACE( TraceLevels::Debug, TXT( "Data directory: %s\n" ), dataDirectory.c_str() ); HELIUM_UNREF( dataDirectory ); FilePath userDataDirectory; HELIUM_VERIFY( FileLocations::GetUserDataDirectory( userDataDirectory ) ); HELIUM_TRACE( TraceLevels::Debug, TXT( "User data directory: %s\n" ), userDataDirectory.c_str() ); HELIUM_UNREF( userDataDirectory ); } }
ResourceEditor* TamyEditor::createResourceEditor( Resource* resource, const QIcon& icon ) { // no editor can be created without an active project if ( m_activeProject == NULL ) { return NULL; } // and even if there's an active project, the edited resource must be a part of it FilePath resourcePath = resource->getFilePath(); if ( m_activeProject->isMember( resourcePath ) == false ) { return NULL; } // if we got this far, it means that we need a new editor to edit this resource ResourceEditor* editor = GenericFactory< Resource, ResourceEditor >::create( *resource ); if ( editor ) { editor->initialize( resourcePath.c_str(), icon ); } return editor; }
bool Win32FileGroupDirectory::openOutputFile( const FilePath & _fileName, const OutputStreamInterfacePtr & _stream ) { if( _stream == nullptr ) { LOGGER_ERROR(m_serviceProvider)("Win32FileGroupDirectory::openOutputFile failed _stream == NULL" ); return false; } FileOutputStreamInterface * file = stdex::intrusive_get<FileOutputStreamInterface *>(_stream); if( file->open( m_path, _fileName ) == false ) { LOGGER_ERROR(m_serviceProvider)("Win32FileGroupDirectory::openOutputFile failed open file '%s':'%s'" , m_path.c_str() , _fileName.c_str() ); return false; } return true; }
SoundBufferInterfacePtr SoundEngine::createSoundBufferFromFile( const ConstString& _pakName, const FilePath & _fileName, const ConstString & _codecType, bool _streamable ) { if( m_supportStream == false && _streamable == true ) { LOGGER_WARNING(m_serviceProvider)("SoundEngine::createSoundBufferFromFile: unsupport stream sound %s:%s" , _pakName.c_str() , _fileName.c_str() ); _streamable = false; } SoundDecoderInterfacePtr soundDecoder; if( _streamable == false ) { if( PREFETCHER_SERVICE(m_serviceProvider) ->getSoundDecoder( _pakName, _fileName, soundDecoder ) == false ) { soundDecoder = this->createSoundDecoder_( _pakName, _fileName, _codecType, false ); } else { if( soundDecoder->rewind() == false ) { LOGGER_ERROR(m_serviceProvider)("RenderTextureManager::loadTexture invalid rewind decoder '%s':'%s'" , _pakName.c_str() , _fileName.c_str() ); return nullptr; } } } else { soundDecoder = this->createSoundDecoder_( _pakName, _fileName, _codecType, true ); } if( soundDecoder == nullptr ) { LOGGER_ERROR(m_serviceProvider)("SoundEngine::createSoundBufferFromFile invalid create decoder '%s':'%s' type %s" , _pakName.c_str() , _fileName.c_str() , _codecType.c_str() ); return nullptr; } SoundBufferInterfacePtr buffer = SOUND_SYSTEM(m_serviceProvider) ->createSoundBuffer( soundDecoder, _streamable ); if( buffer == nullptr ) { LOGGER_ERROR(m_serviceProvider)("SoundEngine::createSoundBufferFromFile: Can't create sound buffer for file %s:%s" , _pakName.c_str() , _fileName.c_str() ); return nullptr; } return buffer; }
int AppMain() { int argc; LPCWSTR lpCmdLine = GetCommandLineW(); LPWSTR *ppArgv = CommandLineToArgvW(lpCmdLine, &argc); LPCWSTR lpDiskPath = NULL; bool ShowSettingsDialog = false, ForceMountOptions = false, AdminModeOnNetworkShare = false; bool bDisableUAC = false; char DriveLetterToRemount = 0; BazisLib::String tmpString; for (int i = 1; i < argc; i++) { if (ppArgv[i][0] != '/') { if (!lpDiskPath) lpDiskPath = ppArgv[i]; } else { if (!_wcsicmp(ppArgv[i], L"/settings")) ShowSettingsDialog = true; else if (!_wcsicmp(ppArgv[i], L"/ltrselect")) ForceMountOptions = true; else if (!_wcsicmp(ppArgv[i], L"/uac_on_network_share")) AdminModeOnNetworkShare = true; else if (!_wcsicmp(ppArgv[i], L"/uacdisable")) bDisableUAC = true; else if (!_wcsicmp(ppArgv[i], L"/createiso") || !_wcsicmp(ppArgv[i], L"/isofromfolder")) { if (argc < (i + 2)) { MessageBox(HWND_DESKTOP, _TR(IDS_BADCMDLINE, "Invalid command line!"), NULL, MB_ICONERROR); return 1; } ActionStatus st; if (!_wcsicmp(ppArgv[i], L"/isofromfolder")) { wchar_t *pwszFolder = ppArgv[i + 1]; if (pwszFolder[0] && pwszFolder[wcslen(pwszFolder) - 1] == '\"') pwszFolder[wcslen(pwszFolder) - 1] = '\\'; st = BuildISOFromFolder(pwszFolder); } else st = CreateISOFile(ppArgv[i + 1]); if (!st.Successful() && st.GetErrorCode() != OperationAborted) MessageBox(HWND_DESKTOP, st.GetMostInformativeText().c_str(), NULL, MB_ICONERROR); return !st.Successful(); } else if (!_wcsnicmp(ppArgv[i], L"/remount:", 9)) DriveLetterToRemount = (char)ppArgv[i][9]; } } if (bDisableUAC) { RegistryKey driverParametersKey(HKEY_LOCAL_MACHINE, _T("SYSTEM\\CurrentControlSet\\Services\\BazisVirtualCDBus\\Parameters")); int prevVal = driverParametersKey[_T("GrantAccessToEveryone")]; int newVal = 1; driverParametersKey[_T("GrantAccessToEveryone")] = newVal; if (prevVal != newVal) VirtualCDClient::RestartDriver(); return 0; } if (GetKeyState(VK_SHIFT) & (1 << 31)) ForceMountOptions = true; if (!lpDiskPath && DriveLetterToRemount) { const TCHAR *pwszFilter = _TR(IDS_ISOFILTER, "ISO images (*.iso)|*.iso|All files (*.*)|*.*"); TCHAR tszFilter[128] = { 0, }; _tcsncpy(tszFilter, pwszFilter, _countof(tszFilter) - 1); for (size_t i = 0; i < _countof(tszFilter); i++) if (tszFilter[i] == '|') tszFilter[i] = '\0'; CFileDialog dlg(true, _T("iso"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, tszFilter); dlg.m_ofn.lpstrTitle = _TR(IDS_MOUNTIMAGE, "Mount a disc image"); if (dlg.DoModal() != IDOK) return 1; tmpString.assign(dlg.m_szFileName); lpDiskPath = tmpString.c_str(); } if ((argc < 2) || !ppArgv || !lpDiskPath || ShowSettingsDialog) { return ::ShowSettingsDialog(); } MMCProfile detectedProfile = mpInvalid; bool bFileOnNetworkShare = false; { TCHAR tszFullPath[MAX_PATH] = {0,}; GetFullPathName(lpDiskPath, __countof(tszFullPath), tszFullPath, NULL); TCHAR tszRoot[4] = {tszFullPath[0], ':', '\\', 0}; if (GetDriveType(tszRoot) == DRIVE_REMOTE) bFileOnNetworkShare = true; ImageFormatDatabase imageFormatDB; ManagedPointer<AIParsedCDImage> pImage = imageFormatDB.OpenCDImage(ManagedPointer<AIFile>(new ACFile(tszFullPath, FileModes::OpenReadOnly.ShareAll())), tszFullPath); if (!pImage) { if (AdminModeOnNetworkShare) MessageBox(HWND_DESKTOP, _TR(IDS_UACNETWORKWARNING, "Cannot open image file. To mount images from network drives, go to WinCDEmu settings and allow mounting drives without administrator privileges."), NULL, MB_ICONERROR); else MessageBox(HWND_DESKTOP, _TR(ISD_CORRUPTIMAGE, "Unknown or corrupt image file!"), NULL, MB_ICONERROR); return 1; } if (pImage->GetTrackCount() != 1) detectedProfile = mpCdrom; else { UDFAnalysisResult result = AnalyzeUDFImage(pImage); if (!result.isUDF) detectedProfile = mpInvalid; else if (result.foundBDMV) detectedProfile = mpBDRSequentialWritable; else if (result.foundVIDEO_TS) detectedProfile = mpDvdRecordable; } /*if ((detectedProfile == mpCdrom) || (detectedProfile == mpInvalid)) { if (pImage->GetSectorCount() >= ((10LL * 1024LL * 1024LL * 1024LL / 2048))) detectedProfile = mpBDRSequentialWritable; else if (pImage->GetSectorCount() >= ((1LL * 1024LL * 1024LL * 1024LL / 2048))) detectedProfile = mpDvdRecordable; }*/ } wchar_t wszKernelPath[512]; if (!VirtualCDClient::Win32FileNameToKernelFileName(lpDiskPath, wszKernelPath, __countof(wszKernelPath))) { MessageBox(HWND_DESKTOP, _TR(IDS_BADIMGFN, "Invalid image file name!"), NULL, MB_ICONERROR); return 1; } bool bDiskConnected = false; ActionStatus status; { VirtualCDClient clt(&status); if (!clt.Valid()) { if (status.GetErrorCode() == BazisLib::AccessDenied) { if (bFileOnNetworkShare) return (int)CUACInvokerDialog((String(GetCommandLine()) + L" /uac_on_network_share").c_str()).DoModal(); else return (int)CUACInvokerDialog(GetCommandLine()).DoModal(); } MessageBox(HWND_DESKTOP, _TR(IDS_NOBUS, "Cannot connect to BazisVirtualCD.sys!"), NULL, MB_ICONERROR); return 1; } bDiskConnected = clt.IsDiskConnected(wszKernelPath); } if (DriveLetterToRemount != 0) { if (bDiskConnected) { MessageBox(HWND_DESKTOP, String::sFormat(_TR(IDS_ALREADYMOUNTED, "%s is already mounted."), lpDiskPath).c_str(), NULL, MB_ICONERROR); status = MAKE_STATUS(OperationAborted); } else status = VirtualCDClient::MountImageOnExistingDrive(wszKernelPath, DriveLetterToRemount); } else if (!bDiskConnected) { RegistryParams params; char driveLetter = 0; bool disableAutorun = false, persistent = false; if ((params.DriveLetterPolicy == drvlAskEveryTime) || ForceMountOptions) { CLetterSelectionDialog dlg(ForceMountOptions, detectedProfile); if (dlg.DoModal() != IDOK) return 3; driveLetter = dlg.GetDriveLetter(); disableAutorun = dlg.IsAutorunDisabled(); persistent = dlg.IsPersistent(); detectedProfile = dlg.GetMMCProfile(); #ifdef WINCDEMU_DEBUG_LOGGING_SUPPORT if (dlg.IsDebugLoggingEnabled()) { FilePath fpDir = FilePath::GetSpecialDirectoryLocation(SpecialDirFromCSIDL(CSIDL_APPDATA)).PlusPath(L"WinCDEmu.debug"); bool cancel = false; if (!Directory::Exists(fpDir)) cancel = MessageBox(0, String::sFormat(L"WinCDEmu will create a directory for debugging log files (%s). If you encounter problems using WinCDEmu, please submit the most recent log file to [email protected]. Continue?", fpDir.c_str()).c_str() , L"Information", MB_OKCANCEL | MB_ICONINFORMATION) != IDOK; if (!cancel) { CreateDirectory(fpDir.c_str(), NULL); wchar_t wszKernelDirPath[512]; if (VirtualCDClient::Win32FileNameToKernelFileName(fpDir.c_str(), wszKernelDirPath, __countof(wszKernelDirPath))) VirtualCDClient().SetDebugLogDirectory(wszKernelDirPath); } } else VirtualCDClient().SetDebugLogDirectory(NULL); #endif } else { disableAutorun = params.DisableAutorun; persistent = params.PersistentDefault; if (detectedProfile == mpInvalid) detectedProfile = (MMCProfile)params.DefaultMMCProfile; if (params.DriveLetterPolicy == drvlStartingFromGiven) { DWORD dwMask = GetLogicalDrives(); unsigned char ch = 'A' + params.StartingDriveLetterIndex; for (unsigned i = (1 << (ch - 'A')); ch <= 'Z'; ch++, i <<= 1) if (!(dwMask & i)) { driveLetter = ch; break; } } } status = VirtualCDClient().ConnectDisk(wszKernelPath, driveLetter, 0, disableAutorun, persistent, AutorunErrorHandler, detectedProfile); } else status = VirtualCDClient().DisconnectDisk(wszKernelPath); if (!status.Successful()) { if (status.GetErrorCode() != OperationAborted) MessageBox(HWND_DESKTOP, status.GetMostInformativeText().c_str(), NULL, MB_ICONERROR); return 1; } return 0; }
bool ResourceManager::unloadResources( const ConstString & _locale, const ConstString & _pakName, const FilePath & _path ) { Metacode::Meta_DataBlock datablock; bool exist = false; if( LOADER_SERVICE( m_serviceProvider )->load( _pakName, _path, &datablock, exist ) == false ) { if( exist == false ) { LOGGER_ERROR( m_serviceProvider )("ResourceManager::unloadResource: resource '%s:%s' not found" , _pakName.c_str() , _path.c_str() ); } else { LOGGER_ERROR( m_serviceProvider )("ResourceManager::unloadResource: Invalid parse resource '%s:%s'" , _pakName.c_str() , _path.c_str() ); } return false; } ConstString groupName; datablock.swap_Name( groupName ); const Metacode::Meta_DataBlock::TVectorMeta_Include & includes_include = datablock.get_IncludesInclude(); for( Metacode::Meta_DataBlock::TVectorMeta_Include::const_iterator it = includes_include.begin(), it_end = includes_include.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_Include & meta_include = *it; const FilePath & path = meta_include.get_Path(); if( this->unloadResources( _locale, _pakName, path ) == false ) { LOGGER_ERROR( m_serviceProvider )("ResourceManager::unloadResource load %s:%s resource invalid load include %s" , _pakName.c_str() , _path.c_str() , path.c_str() ); return false; } } const Metacode::Meta_DataBlock::TVectorMeta_Resource & includes_resource = datablock.get_IncludesResource(); for( Metacode::Meta_DataBlock::TVectorMeta_Resource::const_iterator it = includes_resource.begin(), it_end = includes_resource.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_Resource * meta_resource = *it; const ConstString & name = meta_resource->get_Name(); const ConstString & type = meta_resource->get_Type(); ResourceReferencePtr has_resource = nullptr; if( this->hasResource( name, &has_resource ) == false ) { const ConstString & resource_category = has_resource->getCategory(); LOGGER_ERROR( m_serviceProvider )("ResourceManager::unloadResource: path %s not found resource name '%s' in group '%s' category '%s' ('%s')\nhas resource category '%s' group '%s' name '%s'" , _path.c_str() , name.c_str() , groupName.c_str() , _pakName.c_str() , resource_category.c_str() , has_resource->getCategory().c_str() , has_resource->getGroup().c_str() , has_resource->getName().c_str() ); return nullptr; } if( this->removeResource( has_resource ) == false ) { LOGGER_ERROR( m_serviceProvider )("ResourceManager::unloadResource: '%s' invalid remove resource '%s:%s' name %s type %s" , _path.c_str() , _pakName.c_str() , groupName.c_str() , name.c_str() , type.c_str() ); return false; } } return true; }
bool LoaderEngine::load( const ConstString & _pak, const FilePath & _path, Metabuf::Metadata * _metadata, bool & _exist ) const { LOGGER_INFO(m_serviceProvider)( "LoaderEngine::load pak '%s:%s'" , _pak.c_str() , _path.c_str() ); if( _path.empty() == true ) { LOGGER_ERROR(m_serviceProvider)("LoaderEngine::import invalid open bin '%s' path is empty" , _pak.c_str() ); return false; } InputStreamInterfacePtr file_bin; if( this->openBin_( _pak, _path, file_bin, _exist ) == false ) { LOGGER_ERROR(m_serviceProvider)("LoaderEngine::import invalid open bin '%s':'%s'" , _pak.c_str() , _path.c_str() ); return false; } if( file_bin == nullptr ) { return true; } bool reimport = false; bool done = this->importBin_( file_bin, _metadata, &reimport ); # ifndef MENGINE_MASTER_RELEASE if( reimport == true ) { file_bin = nullptr; PathString cache_path_xml; cache_path_xml += _path; cache_path_xml.replace_last( "xml" ); ConstString c_cache_path_xml = Helper::stringizeString( m_serviceProvider, cache_path_xml ); if( this->makeBin_( _pak, c_cache_path_xml, _path ) == false ) { LOGGER_ERROR(m_serviceProvider)("LoaderEngine::import invlid rebild bin %s from xml %s" , _path.c_str() , c_cache_path_xml.c_str() ); return false; } file_bin = FILE_SERVICE(m_serviceProvider) ->openInputFile( _pak, _path, false ); done = this->importBin_( file_bin, _metadata, nullptr ); } # endif return done; }
bool LoaderEngine::makeBin_( const ConstString & _pak, const FilePath & _pathXml, const FilePath & _pathBin ) const { XmlDecoderInterfacePtr decoder = CODEC_SERVICE(m_serviceProvider) ->createDecoderT<XmlDecoderInterfacePtr>( STRINGIZE_STRING_LOCAL(m_serviceProvider, "xml2bin") ); if( decoder == nullptr ) { LOGGER_ERROR(m_serviceProvider)("LoaderEngine::makeBin_ invalid create decoder xml2bin for %s:%s" , _pak.c_str() , _pathXml.c_str() ); return false; } if( decoder->prepareData( nullptr ) == false ) { LOGGER_ERROR(m_serviceProvider)("LoaderEngine::makeBin_ invalid initialize decoder xml2bin for %s:%s" , _pak.c_str() , _pathXml.c_str() ); return false; } XmlCodecOptions options; options.pathProtocol = m_protocolPath; FileGroupInterfacePtr fileGroup = FILE_SERVICE(m_serviceProvider) ->getFileGroup( _pak ); if( fileGroup == nullptr ) { LOGGER_ERROR(m_serviceProvider)("LoaderEngine::makeBin_ invalid get file group %s (%s)" , _pak.c_str() , _pathXml.c_str() ); return false; } const FilePath & path = fileGroup->getPath(); options.pathXml = Helper::concatenationFilePath( m_serviceProvider, path, _pathXml ); options.pathBin = Helper::concatenationFilePath( m_serviceProvider, path, _pathBin ); if( decoder->setOptions( &options ) == false ) { return false; } //if( decoder->initialize( m_serviceProvider, 0 ) == false ) //{ //decoder->destroy(); //return false; //} if( decoder->decode( 0, 0 ) == 0 ) { return false; } return true; }
bool is_path_exists(const FilePath& fullpath) { DWORD attr = GetFileAttributes(fullpath.c_str()); return (attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY)); }
template<> inline wxString glue_cast<wxString, FilePath>(const FilePath &value) { return wxString(value.c_str(), wxConvUTF8); }
bool Win32FileMapped::open( const FilePath & _folder, const FilePath & _fileName ) { WChar filePath[MENGINE_MAX_PATH]; if( WINDOWSLAYER_SERVICE(m_serviceProvider) ->concatenateFilePath( _folder, _fileName, filePath, MENGINE_MAX_PATH ) == false ) { LOGGER_ERROR(m_serviceProvider)("Win32MappedInputStream::open invlalid concatenate filePath '%s':'%s'" , _folder.c_str() , _fileName.c_str() ); return false; } m_hFile = WINDOWSLAYER_SERVICE(m_serviceProvider)->createFile( filePath, // file to open GENERIC_READ, // open for reading FILE_SHARE_READ, // share for reading, exclusive for mapping OPEN_EXISTING // existing file only ); if ( m_hFile == INVALID_HANDLE_VALUE) { LOGGER_ERROR(m_serviceProvider)("Win32MappedInputStream::open %ls invalid open" , filePath ); return false; } m_hMapping = CreateFileMapping( m_hFile, NULL, PAGE_READONLY, 0, 0, NULL ); if( m_hMapping == NULL ) { DWORD error = GetLastError(); LOGGER_ERROR(m_serviceProvider)("Win32MappedInputStream::open invalid create file mapping %ls error %d" , filePath , error ); ::CloseHandle( m_hFile ); m_hFile = INVALID_HANDLE_VALUE; return false; } m_memory = MapViewOfFile( m_hMapping, FILE_MAP_READ, 0, 0, 0 ); if( m_memory == NULL ) { DWORD error = GetLastError(); LOGGER_ERROR(m_serviceProvider)("Win32MappedInputStream::open invalid map view of file %ls error %d" , filePath , error ); ::CloseHandle( m_hMapping ); m_hMapping = INVALID_HANDLE_VALUE; ::CloseHandle( m_hFile ); m_hFile = INVALID_HANDLE_VALUE; return false; } return true; }
bool ResourceManager::validateResources( const ConstString & _locale, const ConstString & _pakName, const FilePath & _path ) const { Metacode::Meta_DataBlock datablock; bool exist = false; if( LOADER_SERVICE( m_serviceProvider )->load( _pakName, _path, &datablock, exist ) == false ) { if( exist == false ) { LOGGER_ERROR( m_serviceProvider )("ResourceManager::validateResources resource '%s:%s' not found" , _pakName.c_str() , _path.c_str() ); } else { LOGGER_ERROR( m_serviceProvider )("ResourceManager::validateResources Invalid parse resource '%s:%s'" , _pakName.c_str() , _path.c_str() ); } return false; } bool successful = true; ConstString groupName; datablock.swap_Name( groupName ); const Metacode::Meta_DataBlock::TVectorMeta_Include & includes_include = datablock.get_IncludesInclude(); for( Metacode::Meta_DataBlock::TVectorMeta_Include::const_iterator it = includes_include.begin(), it_end = includes_include.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_Include & meta_include = *it; const FilePath & path = meta_include.get_Path(); if( this->validateResources( _locale, _pakName, path ) == false ) { LOGGER_ERROR( m_serviceProvider )("ResourceManager::validateResources load %s:%s resource invalid load include %s" , _pakName.c_str() , _path.c_str() , path.c_str() ); successful = false; continue; } } const Metacode::Meta_DataBlock::TVectorMeta_Resource & includes_resource = datablock.get_IncludesResource(); for( Metacode::Meta_DataBlock::TVectorMeta_Resource::const_iterator it = includes_resource.begin(), it_end = includes_resource.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_Resource * meta_resource = *it; const ConstString & name = meta_resource->get_Name(); const ConstString & type = meta_resource->get_Type(); bool unique = true; meta_resource->get_Unique( unique ); ResourceReferencePtr resource = this->generateResource( type ); if( resource == nullptr ) { LOGGER_ERROR( m_serviceProvider )("ResourceManager::validateResources '%s' invalid create resource '%s:%s' name %s type %s" , _path.c_str() , _pakName.c_str() , groupName.c_str() , name.c_str() , type.c_str() ); successful = false; continue; } resource->setLocale( _locale ); resource->setCategory( _pakName ); resource->setGroup( groupName ); resource->setName( name ); if( resource->loader( meta_resource ) == false ) { LOGGER_ERROR( m_serviceProvider )("ResourceManager::validateResources '%s' category '%s' group '%s' name '%s' type '%s' invalid load" , _path.c_str() , _pakName.c_str() , groupName.c_str() , name.c_str() , type.c_str() ); successful = false; continue; } # ifndef MENGINE_MASTER_RELEASE if( resource->convert() == false ) { LOGGER_ERROR( m_serviceProvider )("ResourceManager::validateResources %s type [%s] invalid convert" , name.c_str() , type.c_str() ); successful = false; continue; } # endif if( resource->isValid() == false ) { LOGGER_ERROR( m_serviceProvider )("ResourceManager::validateResources %s type [%s] invalidate" , name.c_str() , type.c_str() ); successful = false; continue; } } return successful; }
bool RenderMaterialManager::unloadMaterials( const ConstString& _pakName, const FilePath& _fileName ) { Metacode::Meta_DataBlock datablock; bool exist = false; if( LOADER_SERVICE( m_serviceProvider ) ->load( _pakName, _fileName, &datablock, exist ) == false ) { if( exist == false ) { LOGGER_ERROR( m_serviceProvider )("RenderMaterialManager::loadMaterials: materials '%s:%s' not found" , _pakName.c_str() , _fileName.c_str() ); } else { LOGGER_ERROR( m_serviceProvider )("RenderMaterialManager::loadMaterials: Invalid parse materials '%s:%s'" , _pakName.c_str() , _fileName.c_str() ); } return false; } const ConstString & renderPlatformName = RENDER_SYSTEM( m_serviceProvider ) ->getRenderPlatformName(); const Metacode::Meta_DataBlock::TVectorMeta_FragmentShader & includes_FragmentShader = datablock.get_IncludesFragmentShader(); for( Metacode::Meta_DataBlock::TVectorMeta_FragmentShader::const_iterator it = includes_FragmentShader.begin(), it_end = includes_FragmentShader.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_FragmentShader & meta_FragmentShader = *it; const ConstString & name = meta_FragmentShader.get_Name(); const ConstString & platform = meta_FragmentShader.get_Platform(); if( platform != renderPlatformName ) { continue; } m_fragmentShaders.erase( name ); } const Metacode::Meta_DataBlock::TVectorMeta_VertexShader & includes_VertexShader = datablock.get_IncludesVertexShader(); for( Metacode::Meta_DataBlock::TVectorMeta_VertexShader::const_iterator it = includes_VertexShader.begin(), it_end = includes_VertexShader.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_VertexShader & meta_VertexShader = *it; const ConstString & name = meta_VertexShader.get_Name(); const ConstString & platform = meta_VertexShader.get_Platform(); if( platform != renderPlatformName ) { continue; } m_vertexShaders.erase( name ); } const Metacode::Meta_DataBlock::TVectorMeta_Program & includes_Program = datablock.get_IncludesProgram(); for( Metacode::Meta_DataBlock::TVectorMeta_Program::const_iterator it = includes_Program.begin(), it_end = includes_Program.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_Program & meta_Program = *it; const ConstString & name = meta_Program.get_Name(); const ConstString & platform = meta_Program.get_Platform(); if( platform != renderPlatformName ) { continue; } m_programs.erase( name ); } const Metacode::Meta_DataBlock::TVectorMeta_Material & includes_Material = datablock.get_IncludesMaterial(); for( Metacode::Meta_DataBlock::TVectorMeta_Material::const_iterator it = includes_Material.begin(), it_end = includes_Material.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_Material & meta_Material = *it; const Menge::ConstString & name = meta_Material.get_Name(); m_materialStageIndexer.erase( name ); } return true; }
bool ResourceManager::loadResources( const ConstString & _locale, const ConstString & _pakName, const FilePath & _path, bool _ignored ) { Metacode::Meta_DataBlock datablock; bool exist = false; if( LOADER_SERVICE(m_serviceProvider)->load( _pakName, _path, &datablock, exist ) == false ) { if( exist == false ) { LOGGER_ERROR(m_serviceProvider)("ResourceManager::loadResource: resource '%s:%s' not found" , _pakName.c_str() , _path.c_str() ); } else { LOGGER_ERROR(m_serviceProvider)("ResourceManager::loadResource: Invalid parse resource '%s:%s'" , _pakName.c_str() , _path.c_str() ); } return false; } ConstString groupName; datablock.swap_Name( groupName ); const Metacode::Meta_DataBlock::TVectorMeta_Include & includes_include = datablock.get_IncludesInclude(); for( Metacode::Meta_DataBlock::TVectorMeta_Include::const_iterator it = includes_include.begin(), it_end = includes_include.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_Include & meta_include = *it; const FilePath & path = meta_include.get_Path(); if( this->loadResources( _locale, _pakName, path, _ignored ) == false ) { LOGGER_ERROR(m_serviceProvider)("ResourceManager::loadResource load %s:%s resource invalid load include %s" , _pakName.c_str() , _path.c_str() , path.c_str() ); return false; } } const Metacode::Meta_DataBlock::TVectorMeta_Resource & includes_resource = datablock.get_IncludesResource(); for( Metacode::Meta_DataBlock::TVectorMeta_Resource::const_iterator it = includes_resource.begin(), it_end = includes_resource.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_Resource * meta_resource = *it; const ConstString & name = meta_resource->get_Name(); const ConstString & type = meta_resource->get_Type(); bool unique = true; meta_resource->get_Unique( unique ); ResourceReferencePtr has_resource = nullptr; if( this->hasResource( name, &has_resource ) == true ) { if( unique == false ) { continue; } const ConstString & resource_category = has_resource->getCategory(); LOGGER_ERROR(m_serviceProvider)("ResourceManager::loadResource: path %s already exist resource name '%s' in group '%s' category '%s' ('%s')\nhas resource category '%s' group '%s' name '%s'" , _path.c_str() , name.c_str() , groupName.c_str() , _pakName.c_str() , resource_category.c_str() , has_resource->getCategory().c_str() , has_resource->getGroup().c_str() , has_resource->getName().c_str() ); return nullptr; } ResourceReferencePtr resource = this->createResource( _locale, _pakName, groupName, name, type ); if( resource == nullptr ) { LOGGER_ERROR( m_serviceProvider )("ResourceManager::loadResource: '%s' invalid create resource '%s:%s' name %s type %s" , _path.c_str() , _pakName.c_str() , groupName.c_str() , name.c_str() , type.c_str() ); return false; } if( resource->loader( meta_resource ) == false ) { LOGGER_ERROR(m_serviceProvider)("ResourceManager::loadResource '%s' category '%s' group '%s' name '%s' type '%s' invalid load" , _path.c_str() , _pakName.c_str() , groupName.c_str() , name.c_str() , type.c_str() ); continue; } bool precompile = false; meta_resource->get_Precompile( precompile ); if( precompile == true ) { resource->incrementReference(); } # ifndef MENGINE_MASTER_RELEASE if( _ignored == false && resource->convert() == false ) { LOGGER_ERROR(m_serviceProvider)("ResourceManager::loadResource %s type [%s] invalid convert" , name.c_str() , type.c_str() ); continue; } # endif } return true; }
bool AccountManager::loadAccounts() { bool noLoadAccount = HAS_OPTION( m_serviceProvider, "noaccounts" ); if( noLoadAccount == true ) { return true; } FilePath accountsPath = CONFIG_VALUE( m_serviceProvider, "Game", "AccountsPath", STRINGIZE_STRING_LOCAL( m_serviceProvider, "accounts.ini" ) ); bool accountsExist = FILE_SERVICE(m_serviceProvider) ->existFile( CONST_STRING(m_serviceProvider, user), accountsPath, nullptr ); if( accountsExist == false ) { LOGGER_WARNING(m_serviceProvider)( "AccountManager::loadAccounts not exist accounts '%s'" , accountsPath.c_str() ); return true; } InputStreamInterfacePtr file = FILE_SERVICE(m_serviceProvider) ->openInputFile( CONST_STRING(m_serviceProvider, user), accountsPath, false ); if( file == nullptr ) { LOGGER_ERROR(m_serviceProvider)("AccountManager::loadAccounts open accounts failed '%s'" , accountsPath.c_str() ); return false; } IniUtil::IniStore ini; if( IniUtil::loadIni( ini, file, m_serviceProvider ) == false ) { LOGGER_ERROR(m_serviceProvider)("AccountManager::loadAccounts parsing accounts failed '%s'" , accountsPath.c_str() ); return false; } file = nullptr; //unsigned int playerCount; //config.getSettingUInt( L"SETTINGS", L"AccountCount", playerCount ); if( IniUtil::getIniValue( ini, "SETTINGS", "AccountEnumerator", m_playerEnumerator, m_serviceProvider ) == false ) { LOGGER_ERROR(m_serviceProvider)("AccountManager::loadAccounts get AccountEnumerator failed '%s'" , accountsPath.c_str() ); return false; } if( IniUtil::getIniValue( ini, "SETTINGS", "DefaultAccountID", m_defaultAccountID, m_serviceProvider ) == false ) { LOGGER_INFO(m_serviceProvider)( "AccountManager::loadAccounts get DefaultAccountID failed '%s'" , accountsPath.c_str() ); } WString selectAccountID; if( IniUtil::getIniValue( ini, "SETTINGS", "SelectAccountID", selectAccountID, m_serviceProvider ) == false ) { LOGGER_INFO(m_serviceProvider)( "AccountManager::loadAccounts get SelectAccountID failed '%s'" , accountsPath.c_str() ); } TVectorWString values; if( IniUtil::getIniValue( ini, "ACCOUNTS", "Account", values, m_serviceProvider ) == false ) { LOGGER_INFO(m_serviceProvider)( "AccountManager::loadAccounts get ACCOUNTS failed '%s'" , accountsPath.c_str() ); } AccountInterfacePtr validAccount = nullptr; for( TVectorWString::const_iterator it = values.begin(), it_end = values.end(); it != it_end; ++it ) { const WString & name = *it; AccountInterfacePtr account = this->loadAccount_( name ); if( account == nullptr ) { LOGGER_ERROR(m_serviceProvider)("AccountManager::loadAccountsInfo invalid load account '%ls'" , name.c_str() ); continue; } validAccount = account; m_accounts.insert( std::make_pair( name, account ) ); } if( selectAccountID.empty() == false ) { LOGGER_INFO(m_serviceProvider)( "AccountManager::loadAccounts select account '%ls'" , selectAccountID.c_str() ); if( this->selectAccount( selectAccountID ) == false ) { LOGGER_ERROR(m_serviceProvider)("AccountManager::loadAccounts invalid set select account '%ls'" , selectAccountID.c_str() ); return false; } } else if( m_defaultAccountID.empty() == false ) { LOGGER_INFO(m_serviceProvider)( "AccountManager::loadAccounts set default account '%ls'" , m_defaultAccountID.c_str() ); if( this->selectAccount( m_defaultAccountID ) == false ) { LOGGER_ERROR(m_serviceProvider)("AccountManager::loadAccounts invalid set default account '%ls'" , m_defaultAccountID.c_str() ); return false; } } else if( validAccount != nullptr ) { const WString & accountID = validAccount->getName(); LOGGER_WARNING(m_serviceProvider)( "AccountManager::loadAccounts set valid account '%ls'" , accountID.c_str() ); if( this->selectAccount( accountID ) == false ) { LOGGER_ERROR(m_serviceProvider)("AccountManager::loadAccounts invalid set valid account '%ls'" , accountID.c_str() ); return false; } } else { LOGGER_INFO(m_serviceProvider)("AccountManager::loadAccounts invalid set any accounts" ); } return true; }
bool mkdir(const FilePath& fullpath) { return ::CreateDirectory(fullpath.c_str(), 0) == TRUE; }
bool RenderMaterialManager::loadMaterials( const ConstString& _pakName, const FilePath& _fileName ) { Metacode::Meta_DataBlock datablock; bool exist = false; if( LOADER_SERVICE( m_serviceProvider ) ->load( _pakName, _fileName, &datablock, exist ) == false ) { if( exist == false ) { LOGGER_ERROR( m_serviceProvider )("RenderMaterialManager::loadMaterials: materials '%s:%s' not found" , _pakName.c_str() , _fileName.c_str() ); } else { LOGGER_ERROR( m_serviceProvider )("RenderMaterialManager::loadMaterials: Invalid parse materials '%s:%s'" , _pakName.c_str() , _fileName.c_str() ); } return false; } const ConstString & renderPlatformName = RENDER_SYSTEM( m_serviceProvider ) ->getRenderPlatformName(); const Metacode::Meta_DataBlock::TVectorMeta_FragmentShader & includes_FragmentShader = datablock.get_IncludesFragmentShader(); for( Metacode::Meta_DataBlock::TVectorMeta_FragmentShader::const_iterator it = includes_FragmentShader.begin(), it_end = includes_FragmentShader.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_FragmentShader & meta_FragmentShader = *it; const ConstString & name = meta_FragmentShader.get_Name(); const ConstString & platform = meta_FragmentShader.get_Platform(); if( platform != renderPlatformName ) { continue; } const ConstString & filePath = meta_FragmentShader.get_File_Path(); bool isCompile = false; meta_FragmentShader.get_File_Compile( isCompile ); RenderFragmentShaderInterfacePtr shader = this->createFragmentShader_( name, _pakName, filePath, isCompile ); if( shader == nullptr ) { LOGGER_ERROR( m_serviceProvider )("RenderMaterialManager::loadMaterials material %s:%s invalid load fragment shader %s compile %d" , _pakName.c_str() , _fileName.c_str() , filePath.c_str() , isCompile ); return false; } m_fragmentShaders.insert( std::make_pair( name, shader ) ); } const Metacode::Meta_DataBlock::TVectorMeta_VertexShader & includes_VertexShader = datablock.get_IncludesVertexShader(); for( Metacode::Meta_DataBlock::TVectorMeta_VertexShader::const_iterator it = includes_VertexShader.begin(), it_end = includes_VertexShader.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_VertexShader & meta_VertexShader = *it; const ConstString & name = meta_VertexShader.get_Name(); const ConstString & platform = meta_VertexShader.get_Platform(); if( platform != renderPlatformName ) { continue; } const ConstString & filePath = meta_VertexShader.get_File_Path(); bool isCompile = false; meta_VertexShader.get_File_Compile( isCompile ); RenderVertexShaderInterfacePtr shader = this->createVertexShader_( name, _pakName, filePath, isCompile ); if( shader == nullptr ) { LOGGER_ERROR( m_serviceProvider )("RenderMaterialManager::loadMaterials material %s:%s invalid load vertex shader %s compile %d" , _pakName.c_str() , _fileName.c_str() , filePath.c_str() , isCompile ); return false; } m_vertexShaders.insert( std::make_pair( name, shader ) ); } const Metacode::Meta_DataBlock::TVectorMeta_Program & includes_Program = datablock.get_IncludesProgram(); for( Metacode::Meta_DataBlock::TVectorMeta_Program::const_iterator it = includes_Program.begin(), it_end = includes_Program.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_Program & meta_Program = *it; const ConstString & name = meta_Program.get_Name(); const ConstString & platform = meta_Program.get_Platform(); if( platform != renderPlatformName ) { continue; } const ConstString & vertexShaderName = meta_Program.get_VertexShader_Name(); const ConstString & fragmentShaderName = meta_Program.get_FragmentShader_Name(); uint32_t samplerCount = meta_Program.get_Sampler_Count(); const RenderVertexShaderInterfacePtr & vertexShader = this->getVertexShader_( vertexShaderName ); if( vertexShader == nullptr ) { LOGGER_ERROR( m_serviceProvider )("RenderMaterialManager::loadMaterials material %s:%s program %s not found vertex shader %s" , _pakName.c_str() , _fileName.c_str() , name.c_str() , vertexShaderName.c_str() ); return false; } const RenderFragmentShaderInterfacePtr & fragmentShader = this->getFragmentShader_( fragmentShaderName ); if( fragmentShader == nullptr ) { LOGGER_ERROR( m_serviceProvider )("RenderMaterialManager::loadMaterials material %s:%s program %s not found fragment shader %s" , _pakName.c_str() , _fileName.c_str() , name.c_str() , fragmentShaderName.c_str() ); return false; } RenderProgramInterfacePtr program = RENDER_SYSTEM( m_serviceProvider ) ->createProgram( name, vertexShader, fragmentShader, samplerCount ); if( program == nullptr ) { LOGGER_ERROR( m_serviceProvider )("RenderMaterialManager::loadMaterials material %s:%s invalid create program vertex %s fragment %s" , _pakName.c_str() , _fileName.c_str() , vertexShaderName.c_str() , fragmentShaderName.c_str() ); return false; } m_programs.insert( std::make_pair( name, program ) ); } const Metacode::Meta_DataBlock::TVectorMeta_Material & includes_Material = datablock.get_IncludesMaterial(); for( Metacode::Meta_DataBlock::TVectorMeta_Material::const_iterator it = includes_Material.begin(), it_end = includes_Material.end(); it != it_end; ++it ) { const Metacode::Meta_DataBlock::Meta_Material & meta_Material = *it; const Menge::ConstString & name = meta_Material.get_Name(); bool is_debug = false; meta_Material.get_Debug( is_debug ); RenderMaterialStage stage; meta_Material.get_AlphaBlend_Enable( stage.alphaBlendEnable ); meta_Material.get_BlendFactor_Source( stage.blendSrc ); meta_Material.get_BlendFactor_Dest( stage.blendDst ); meta_Material.get_BlendFactor_Op( stage.blendOp ); ConstString programName; if( meta_Material.get_Program_Name( programName ) == true ) { const RenderProgramInterfacePtr & program = this->getProgram_( programName ); if( program == nullptr ) { //LOGGER_ERROR( m_serviceProvider )("RenderMaterialManager::loadMaterials material %s:%s invalid get program %s" // , _pakName.c_str() // , _fileName.c_str() // , programName.c_str() // ); //return false; } stage.program = program; } const Metacode::Meta_DataBlock::Meta_Material::TVectorMeta_TextureStages & include_TextureStages = meta_Material.get_IncludesTextureStages(); for( Metacode::Meta_DataBlock::Meta_Material::TVectorMeta_TextureStages::const_iterator it_include = include_TextureStages.begin(), it_include_end = include_TextureStages.end(); it_include != it_include_end; ++it_include) { const Metacode::Meta_DataBlock::Meta_Material::Meta_TextureStages & meta_TextureStages = *it_include; uint32_t index = meta_TextureStages.get_Stage(); RenderTextureStage & textureStage = stage.textureStage[index]; textureStage.mipmap = m_defaultTextureFilterMipmap; textureStage.magnification = m_defaultTextureFilterMagnification; textureStage.minification = m_defaultTextureFilterMinification; meta_TextureStages.get_AddressMode_U( textureStage.addressU ); meta_TextureStages.get_AddressMode_V( textureStage.addressV ); textureStage.colorOp = meta_TextureStages.get_Color_Operator(); meta_TextureStages.get_Color_Arg1( textureStage.colorArg1 ); meta_TextureStages.get_Color_Arg2( textureStage.colorArg2 ); textureStage.alphaOp = meta_TextureStages.get_Alpha_Operator(); meta_TextureStages.get_Alpha_Arg1( textureStage.alphaArg1 ); meta_TextureStages.get_Alpha_Arg2( textureStage.alphaArg2 ); meta_TextureStages.get_TextureCoord_Index( textureStage.texCoordIndex ); } const RenderMaterialStage * cache_stage = this->createRenderStageGroup( name, stage ); if( cache_stage == nullptr ) { LOGGER_ERROR( m_serviceProvider )("RenderMaterialManager::loadMaterials material %s:%s invalid create stage group %s" , _pakName.c_str() , _fileName.c_str() , name.c_str() ); return false; } m_materialStageIndexer.insert( std::make_pair( name, cache_stage ) ); if( is_debug == true ) { RenderMaterialInterfacePtr debugMaterial = this->getMaterial( name, PT_LINELIST, 0, nullptr ); this->setDebugMaterial( debugMaterial ); } } return true; }
bool SDLFileInputStream::open( const FilePath & _folder, const FilePath & _fileName, size_t _offset, size_t _size ) { STDEX_THREAD_GUARD_SCOPE( this, "SDLFileInputStream::open" ); # ifdef _DEBUG m_folder = _folder.c_str(); m_fileName = _fileName.c_str(); # endif Char filePath[MENGINE_MAX_PATH]; if( this->openFile_( _folder, _fileName, filePath ) == false ) { return false; } Sint64 size = SDL_RWsize(m_rwops); if( 0 > size ) { this->close_(); LOGGER_ERROR(m_serviceProvider)("SDLFileInputStream::open %s invalid file size" , filePath ); return false; } if( _offset + _size > size ) { LOGGER_ERROR(m_serviceProvider)("SDLFileInputStream::open %s invalid file range %d:%d size %d" , filePath , _offset , _size , size ); return false; } m_size = _size == 0 ? (size_t)size : _size; m_offset = _offset; m_carriage = 0; m_capacity = 0; m_reading = 0; if( m_offset != 0 ) { Sint64 result = SDL_RWseek( m_rwops, static_cast<Sint64>(m_offset), RW_SEEK_SET ); if( 0 > result ) { const char* sdlError = SDL_GetError(); LOGGER_ERROR( m_serviceProvider )("Win32InputStream::open seek offset %d size %d get error %s" , m_offset , m_size , sdlError ); return false; } } return true; }