Browse Source

Build: Builtin asset import moved to import tool
- Also updated `bsf` version

BearishSun 7 years ago
parent
commit
b20a6a8ae2

+ 6 - 1
CMakeLists.txt

@@ -38,7 +38,12 @@ set(GENERATE_SCRIPT_BINDINGS OFF CACHE BOOL "If true, script binding files will
 check_and_update_binary_deps(Banshee ${PROJECT_SOURCE_DIR}/Dependencies/ ${BS_PREBUILT_DEPENDENCIES_VERSION})
 check_and_update_binary_deps(Banshee ${PROJECT_SOURCE_DIR}/Dependencies/ ${BS_PREBUILT_DEPENDENCIES_VERSION})
 
 
 ## Check data dependencies
 ## Check data dependencies
-check_and_update_builtin_assets(Banshee ${PROJECT_SOURCE_DIR}/Data ${BS_BUILTIN_ASSETS_VERSION} YES)
+check_and_update_builtin_assets(Banshee ${PROJECT_SOURCE_DIR}/Data Data ${BS_BUILTIN_ASSETS_VERSION} NO)
+		
+## Import built-in assets
+if(${BUILD_ASSETS})
+	run_import_tool(Banshee ${PROJECT_SOURCE_DIR} "--editor")
+endif()
 		
 		
 # Generate script bindings
 # Generate script bindings
 include(${BSF_SOURCE_DIR}/CMake/GenerateScriptBindings.cmake)
 include(${BSF_SOURCE_DIR}/CMake/GenerateScriptBindings.cmake)

+ 23 - 0
Data/Raw/DataList.json

@@ -1,4 +1,27 @@
 {
 {
+	"Fonts": [
+		{
+			"Path": "arial.ttf",
+			"Name": "arial.ttf",
+			"Sizes": [ 8 ],
+			"Antialiasing": true,
+			"UUID": "6ce69053-00d7-4c60-a229-249b8d8fd60e"
+		},
+		{
+			"Path": "arial.ttf",
+			"Name": "arialAA.ttf",
+			"Sizes": [ 16 ],
+			"Antialiasing": true,
+			"UUID": "10999b74-d976-4116-9f72-21e489a7a8e4"
+		}
+	],
+	"GUISkin": {
+		"Path": "GUISkin.json",
+		"UUID": "ec0ea68d-efa5-4a3b-a6fc-b15aaec9689f"
+	},
+	"SplashScreen": {
+		"Path": "SplashScreen.png"
+	},
     "Icons": [
     "Icons": [
         {
         {
             "Path": "AnimationAddEventIcon.png",
             "Path": "AnimationAddEventIcon.png",

+ 0 - 0
Data/ShaderDependencies.json → Data/Raw/ShaderDependencies.json


+ 5 - 294
Source/EditorCore/Build/BsBuiltinEditorResources.cpp

@@ -118,55 +118,14 @@ namespace bs
 
 
 		ResourceManifestPath = BuiltinDataFolder + "ResourceManifest.asset";
 		ResourceManifestPath = BuiltinDataFolder + "ResourceManifest.asset";
 
 
-		// Update from raw assets if needed
-		if (FileSystem::exists(BuiltinRawDataFolder))
-		{
-			time_t lastUpdateTime;
-			UINT32 modifications = BuiltinResourcesHelper::checkForModifications(BuiltinRawDataFolder,
-				BuiltinDataFolder + "Timestamp.asset", lastUpdateTime);
-
-			// Check if manifest needs to be rebuilt
-			if (modifications == 0 && !FileSystem::exists(ResourceManifestPath))
-				modifications = 1;
-
-			if (modifications > 0)
-			{
-				bool forceReimport = modifications == 2;
-
-				SPtr<ResourceManifest> oldResourceManifest;
-				if (!forceReimport && FileSystem::exists(ResourceManifestPath))
-				{
-					oldResourceManifest = ResourceManifest::load(ResourceManifestPath, BuiltinDataFolder);
-					if (oldResourceManifest != nullptr)
-						gResources().registerResourceManifest(oldResourceManifest);
-				}
-
-				if (oldResourceManifest)
-					mResourceManifest = oldResourceManifest;
-				else
-				{
-					mResourceManifest = ResourceManifest::create("BuiltinResources");
-					gResources().registerResourceManifest(mResourceManifest);
-				}
-
-				preprocess(modifications == 2, lastUpdateTime);
-				BuiltinResourcesHelper::writeTimestamp(BuiltinDataFolder + "Timestamp.asset");
-
-				ResourceManifest::save(mResourceManifest, ResourceManifestPath, BuiltinDataFolder);
-			}
-		}
-
 		// Load manifest
 		// Load manifest
-		if (mResourceManifest == nullptr)
-		{
-			if (FileSystem::exists(ResourceManifestPath))
-				mResourceManifest = ResourceManifest::load(ResourceManifestPath, BuiltinDataFolder);
+		if (FileSystem::exists(ResourceManifestPath))
+			mResourceManifest = ResourceManifest::load(ResourceManifestPath, BuiltinDataFolder);
 
 
-			if (mResourceManifest == nullptr)
-				mResourceManifest = ResourceManifest::create("BuiltinResources");
+		if (mResourceManifest == nullptr)
+			mResourceManifest = ResourceManifest::create("BuiltinResources");
 
 
-			gResources().registerResourceManifest(mResourceManifest);
-		}
+		gResources().registerResourceManifest(mResourceManifest);
 
 
 		// Load basic resources
 		// Load basic resources
 		mShaderDockOverlay = getShader(ShaderDockOverlayFile);
 		mShaderDockOverlay = getShader(ShaderDockOverlayFile);
@@ -194,254 +153,6 @@ namespace bs
 		mSkin = gResources().load<GUISkin>(BuiltinDataFolder + (GUISkinFile + ".asset"));
 		mSkin = gResources().load<GUISkin>(BuiltinDataFolder + (GUISkinFile + ".asset"));
 	}
 	}
 
 
-	void BuiltinEditorResources::preprocess(bool forceImport, time_t lastUpdateTime)
-	{
-		Resources::instance().unloadAllUnused();
-
-		Path dataListsFilePath = BuiltinRawDataFolder + DATA_LIST_JSON;
-		SPtr<DataStream> dataListStream = FileSystem::openFile(dataListsFilePath);
-
-		json dataListJSON = json::parse(dataListStream->getAsString().c_str());
-
-		json skinJSON = dataListJSON["Skin"];
-		json iconsJSON = dataListJSON["Icons"];
-		json includesJSON = dataListJSON["Includes"];
-		json shadersJSON = dataListJSON["Shaders"];
-
-		// Update DataList.json if needed
-		bool updatedDataLists = false;
-		updatedDataLists |= BuiltinResourcesHelper::updateJSON(
-			EditorRawIconsFolder,
-			BuiltinResourcesHelper::AssetType::Sprite,
-			iconsJSON);
-
-		updatedDataLists |= BuiltinResourcesHelper::updateJSON(
-			EditorRawShaderIncludeFolder,
-			BuiltinResourcesHelper::AssetType::Normal,
-			includesJSON);
-
-		updatedDataLists |= BuiltinResourcesHelper::updateJSON(
-			EditorRawShaderFolder,
-			BuiltinResourcesHelper::AssetType::Normal,
-			shadersJSON);
-
-		updatedDataLists |= BuiltinResourcesHelper::updateJSON(
-			EditorRawSkinFolder,
-			BuiltinResourcesHelper::AssetType::Sprite,
-			skinJSON);
-
-		dataListStream->close();
-
-		if (updatedDataLists)
-		{
-			FileSystem::remove(dataListsFilePath);
-
-			dataListJSON["Skin"] = skinJSON;
-			dataListJSON["Icons"] = iconsJSON;
-			dataListJSON["Includes"] = includesJSON;
-			dataListJSON["Shaders"] = shadersJSON;
-
-			String jsonString = dataListJSON.dump(4).c_str();
-			dataListStream = FileSystem::createAndOpenFile(dataListsFilePath);
-			dataListStream->writeString(jsonString);
-			dataListStream->close();
-		}
-
-		// If forcing import, clear all data folders since everything will be recreated anyway
-		Path shaderDependenciesFile = BuiltinDataFolder + "ShaderDependencies.json";
-		if(forceImport)
-		{
-			FileSystem::remove(EditorIconFolder);
-			FileSystem::remove(EditorShaderIncludeFolder);
-			FileSystem::remove(EditorShaderFolder);
-			FileSystem::remove(EditorSkinFolder);
-			
-			FileSystem::remove(shaderDependenciesFile);
-		}
-
-		// Read shader dependencies JSON
-		json shaderDependenciesJSON;
-		if(FileSystem::exists(shaderDependenciesFile))
-		{
-			SPtr<DataStream> stream = FileSystem::openFile(shaderDependenciesFile);
-			shaderDependenciesJSON = json::parse(stream->getAsString().c_str());
-			stream->close();
-		}
-
-		// Import icons
-		{
-			BuiltinResourcesHelper::updateManifest(
-				EditorIconFolder,
-				iconsJSON,
-				mResourceManifest,
-				BuiltinResourcesHelper::AssetType::Sprite);
-
-			Vector<bool> importFlags = BuiltinResourcesHelper::generateImportFlags(
-				iconsJSON,
-				EditorRawIconsFolder,
-				lastUpdateTime,
-				forceImport);
-
-			BuiltinResourcesHelper::importAssets(
-				iconsJSON,
-				importFlags,
-				EditorRawIconsFolder,
-				EditorIconFolder,
-				mResourceManifest,
-				BuiltinResourcesHelper::AssetType::Sprite);
-		}
-
-		// Import shaders
-		{
-			BuiltinResourcesHelper::updateManifest(
-				EditorShaderIncludeFolder,
-				includesJSON,
-				mResourceManifest,
-				BuiltinResourcesHelper::AssetType::Normal);
-
-			BuiltinResourcesHelper::updateManifest(
-				EditorShaderFolder,
-				shadersJSON,
-				mResourceManifest,
-				BuiltinResourcesHelper::AssetType::Normal);
-
-			Vector<bool> includeImportFlags = BuiltinResourcesHelper::generateImportFlags(
-				includesJSON,
-				EditorRawShaderIncludeFolder,
-				lastUpdateTime,
-				forceImport);
-
-			Vector<bool> shaderImportFlags = BuiltinResourcesHelper::generateImportFlags(
-				shadersJSON,
-				EditorRawShaderFolder,
-				lastUpdateTime,
-				forceImport,
-				&shaderDependenciesJSON,
-				EditorRawShaderIncludeFolder);
-
-			// Hidden dependency: Includes must be imported before shaders, but import flags for shaders must be generated
-			// before includes are imported, since the process checks if imports changed
-			BuiltinResourcesHelper::importAssets(
-				includesJSON,
-				includeImportFlags,
-				EditorRawShaderIncludeFolder,
-				EditorShaderIncludeFolder,
-				mResourceManifest,
-				BuiltinResourcesHelper::AssetType::Normal);
-
-			BuiltinResourcesHelper::importAssets(
-				shadersJSON,
-				shaderImportFlags,
-				EditorRawShaderFolder,
-				EditorShaderFolder,
-				mResourceManifest,
-				BuiltinResourcesHelper::AssetType::Normal,
-				&shaderDependenciesJSON);
-		}
-
-		// Import GUI sprites
-		{
-			BuiltinResourcesHelper::updateManifest(
-				EditorSkinFolder,
-				skinJSON,
-				mResourceManifest,
-				BuiltinResourcesHelper::AssetType::Sprite);
-
-			Vector<bool> includeImportFlags = BuiltinResourcesHelper::generateImportFlags(
-				skinJSON,
-				EditorRawSkinFolder,
-				lastUpdateTime,
-				forceImport);
-
-			BuiltinResourcesHelper::importAssets(
-				skinJSON,
-				includeImportFlags,
-				EditorRawSkinFolder,
-				EditorSkinFolder,
-				mResourceManifest,
-				BuiltinResourcesHelper::AssetType::Sprite);
-		}
-
-		// Update shader dependencies JSON
-		{
-			String jsonString = shaderDependenciesJSON.dump(4).c_str();
-
-			dataListStream = FileSystem::createAndOpenFile(shaderDependenciesFile);
-			dataListStream->writeString(jsonString);
-			dataListStream->close();
-		}
-
-		// Import fonts
-		BuiltinResourcesHelper::importFont(
-			BuiltinRawDataFolder + DefaultFontFilename,
-			DefaultFontFilename,
-			BuiltinDataFolder,
-			{ DefaultFontSize },
-			true,
-			UUID("6ce69053-00d7-4c60-a229-249b8d8fd60e"),
-			mResourceManifest);
-
-		BuiltinResourcesHelper::importFont(
-			BuiltinRawDataFolder + DefaultFontFilename,
-			DefaultAAFontFilename,
-			BuiltinDataFolder,
-			{ TitleFontSize },
-			true,
-			UUID("10999b74-d976-4116-9f72-21e489a7a8e4"),
-			mResourceManifest);
-
-		// Import splash screen
-		{
-			Path inputPath = BuiltinRawDataFolder + String(SplashScreenName);
-			Path outputPath = BuiltinDataFolder + (String(SplashScreenName) + ".asset");
-
-			auto textureIO = gImporter().createImportOptions<TextureImportOptions>(inputPath);
-			textureIO->setCPUCached(true);
-			textureIO->setGenerateMipmaps(false);
-			HTexture splashTexture = gImporter().import<Texture>(inputPath, textureIO);
-
-			SPtr<PixelData> splashPixelData = splashTexture->getProperties().allocBuffer(0, 0);
-			splashTexture->readCachedData(*splashPixelData);
-
-			FileEncoder fe(outputPath);
-			fe.encode(splashPixelData.get());
-		}
-
-		// Generate & save GUI skin
-		{
-			SPtr<GUISkin> skin = generateGUISkin();
-			Path outputPath = BuiltinDataFolder + (GUISkinFile + ".asset");
-
-			HResource skinResource = gResources()._createResourceHandle(skin, UUID("ec0ea68d-efa5-4a3b-a6fc-b15aaec9689f"));
-
-			gResources().save(skinResource, outputPath, true);
-			mResourceManifest->registerResource(skinResource.getUUID(), outputPath);
-		}
-
-		Resources::instance().unloadAllUnused();
-	}
-
-	SPtr<GUISkin> BuiltinEditorResources::generateGUISkin()
-	{		
-		BuiltinResourceGUIElementStyleLoader loader(BuiltinDataFolder, EditorSkinSpritesFolder);
-
-		Path guiSkinPath = BuiltinRawDataFolder + GUI_SKIN_JSON;
-		SPtr<DataStream> guiSkinStream = FileSystem::openFile(guiSkinPath);
-		json guiSkinJSON = json::parse(guiSkinStream->getAsString().c_str());
-
-		SPtr<GUISkin> skin = GUISkin::_createPtr();
-
-		for (auto& entry : guiSkinJSON)
-		{
-			std::string name = entry["name"];
-
-			GUIElementStyle style = BuiltinResourcesHelper::loadGUIStyleFromJSON(entry, loader);
-			skin->setStyle(name.c_str(), style);
-		}
-
-		return skin;
-	}
-
 	HSpriteTexture BuiltinEditorResources::getGUIIcon(const String& name) const
 	HSpriteTexture BuiltinEditorResources::getGUIIcon(const String& name) const
 	{
 	{
 		Path texturePath = EditorIconSpritesFolder;
 		Path texturePath = EditorIconSpritesFolder;

+ 0 - 14
Source/EditorCore/Utility/BsBuiltinEditorResources.h

@@ -178,17 +178,6 @@ namespace bs
 		static const String TextureFieldClearBtnStyleName;
 		static const String TextureFieldClearBtnStyleName;
 
 
 	private:
 	private:
-		/**
-		 * Imports all necessary resources and converts them to engine-ready format.
-		 *
-		 * @note	
-		 * Normally you only want to use this during development phase and then ship with engine-ready format only.
-		 */
-		void preprocess(bool forceImport, time_t lastUpdateTime);
-
-		/**	Generates the default editor skin and all GUI element styles. */
-		SPtr<GUISkin> generateGUISkin();
-
 		/**	Loads a GUI icon with the specified filename. */
 		/**	Loads a GUI icon with the specified filename. */
 		HSpriteTexture getGUIIcon(const String& name) const;
 		HSpriteTexture getGUIIcon(const String& name) const;
 
 
@@ -223,9 +212,6 @@ namespace bs
 		static const char* ShaderIncludeFolder;
 		static const char* ShaderIncludeFolder;
 		static const char* SpriteSubFolder;
 		static const char* SpriteSubFolder;
 
 
-		static constexpr const char* DATA_LIST_JSON = "DataList.json";
-		static constexpr const char* GUI_SKIN_JSON = "GUISkin.json";
-
 		Path BuiltinDataFolder;
 		Path BuiltinDataFolder;
 		Path EditorSkinFolder;
 		Path EditorSkinFolder;
 		Path EditorSkinSpritesFolder;
 		Path EditorSkinSpritesFolder;

+ 1 - 1
Source/bsf

@@ -1 +1 @@
-Subproject commit 447210d87a17e8db1ceaa6decf0c6a71d38c59a7
+Subproject commit 794d8c7ed852e62853dcd8ad87be306caedbfcb6