void CTextureAtlasCreatorContext::Load() { CHAR8 strOpenName[512] = ""; OPENFILENAMEA FileName; memset(&FileName, 0, sizeof(OPENFILENAMEA)); FileName.lStructSize = sizeof(OPENFILENAMEA); FileName.hwndOwner = reinterpret_cast<HWND>(Ascension::Renderer().GetWindowHandle()); FileName.hInstance = reinterpret_cast<HINSTANCE>(GetModuleHandle(NULL)); FileName.lpstrFilter = NULL; FileName.lpstrCustomFilter = NULL; FileName.nMaxCustFilter = NULL; FileName.lpstrFilter = "Ascension Atlas Files\0*.ascatl;*.ascatledt*\0\0"; FileName.nFilterIndex = 2; FileName.lpstrFile = strOpenName; FileName.nMaxFile = 512; FileName.lpstrFileTitle = NULL; FileName.lpstrTitle = "Open Atlas"; FileName.Flags = OFN_EXPLORER; if(TRUE == GetOpenFileNameA(&FileName)) { LoadAtlas(strOpenName); } }
Object* TextureAtlasLoader::Load (const std::string& filename) { TextureAtlas* texAtlas = new TextureAtlas (""); LoadTexture (filename, texAtlas); std::string atlFilename = filename; std::string extension = FileSystem::GetExtension (filename); Extensions::StringExtend::Replace (atlFilename, extension, ""); atlFilename += ".atlas"; LoadAtlas (atlFilename, texAtlas); return texAtlas; }
EReimportResult::Type USpineAtlasAssetFactory::Reimport (UObject* Obj) { USpineAtlasAsset* asset = Cast<USpineAtlasAsset>(Obj); FString rawString; if (!FFileHelper::LoadFileToString(rawString, *asset->GetAtlasFileName().ToString())) return EReimportResult::Failed; asset->SetRawData(rawString); FString currentSourcePath, filenameNoExtension, unusedExtension; const FString longPackagePath = FPackageName::GetLongPackagePath(asset->GetOutermost()->GetPathName()); FPaths::Split(UFactory::GetCurrentFilename(), currentSourcePath, filenameNoExtension, unusedExtension); LoadAtlas(asset, currentSourcePath, longPackagePath); if (Obj->GetOuter()) Obj->GetOuter()->MarkPackageDirty(); else Obj->MarkPackageDirty(); return EReimportResult::Succeeded; }
UObject* USpineAtlasAssetFactory::FactoryCreateFile (UClass * InClass, UObject * InParent, FName InName, EObjectFlags Flags, const FString & Filename, const TCHAR* Parms, FFeedbackContext * Warn, bool& bOutOperationCanceled) { FString rawString; if (!FFileHelper::LoadFileToString(rawString, *Filename)) { return nullptr; } FString currentSourcePath, filenameNoExtension, unusedExtension; const FString longPackagePath = FPackageName::GetLongPackagePath(InParent->GetOutermost()->GetPathName()); FPaths::Split(UFactory::GetCurrentFilename(), currentSourcePath, filenameNoExtension, unusedExtension); FString name(InName.ToString()); name.Append("-atlas"); USpineAtlasAsset* asset = NewObject<USpineAtlasAsset>(InParent, InClass, FName(*name), Flags); asset->SetRawData(rawString); asset->SetAtlasFileName(FName(*Filename)); LoadAtlas(asset, currentSourcePath, longPackagePath); return asset; }