Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate assets.txt in the editor #45

Merged
merged 2 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions editor/CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[0.3.1] ~ TBD
- Added functionality to the editor to generate the assets.txt file, PR #45
- Fix NPE in editor when creating new terrain

[0.3.0] ~ 17/05/2022
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ import com.mbrlabs.mundus.commons.assets.meta.MetaTerrain
import com.mbrlabs.mundus.commons.scene3d.GameObject
import com.mbrlabs.mundus.commons.scene3d.components.AssetUsage
import com.mbrlabs.mundus.commons.utils.FileFormatUtils
import com.mbrlabs.mundus.commons.water.Water
import com.mbrlabs.mundus.editor.Mundus
import com.mbrlabs.mundus.commons.water.WaterFloatAttribute
import com.mbrlabs.mundus.editor.Mundus
import com.mbrlabs.mundus.editor.core.EditorScene
import com.mbrlabs.mundus.editor.core.project.ProjectManager
import com.mbrlabs.mundus.editor.events.LogEvent
Expand Down Expand Up @@ -722,4 +721,31 @@ class EditorAssetManager(assetsRoot: FileHandle) : AssetManager(assetsRoot) {
return skyboxes
}

/**
* Generates a txt file in the projects assets folder that lists all asset files. Overwrites existing
* asset.txt file.
*
* Desktop applications cannot use .list() for internal jar files.
* Desktop apps need to provide an assets.txt file listing all Mundus assets
* in the Mundus assets directory. See [AssetManager.loadAssets] for how the file is used on load.
*/
fun createAssetsTextFile() {
// get path for assets file
val path = FilenameUtils.concat(rootFolder.path(), "assets.txt")

// Build the String listing all asset files
val moreDetails = buildString {
for (asset in assets) {
append(asset.file.name())
appendLine()
append(asset.meta.file.name())
appendLine()
}
}

// Save to file
val fileHandle = FileHandle(path)
fileHandle.writeString(moreDetails, false)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ public ProjectContext createProject(String name, String folder) {
// create standard assets
newProjectContext.assetManager.createStandardAssets();

// Generate assets.txt file
newProjectContext.assetManager.createAssetsTextFile();

return newProjectContext;
}

Expand Down Expand Up @@ -312,6 +315,9 @@ public void saveProject(ProjectContext projectContext) {
}
assetManager.getNewAssets().clear();

// Generate assets.txt file
assetManager.createAssetsTextFile();

// save current in .pro file
kryoManager.saveProjectContext(projectContext);
// save scene in .mundus file
Expand Down