Skip to content

Commit

Permalink
exprot script
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Ski committed Oct 13, 2023
1 parent 7424f13 commit 3852a43
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion editor/assets/preferencesLayout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<block name="general" title="General">
<path name = "exportPath" default="" project="true">Export Path</path>
<!-- TODO: bring back when re-doing scripts -->
<!-- <string name="exportScript" project="true" default="">Export Script</string>-->
<string name="exportScript" project="true" default="">Export Script</string>
</block>
<block name="assets" title="Assets">
<number name="defaultPixelPerMeter" default="100" shared-project="true">Default Pixel Per Unit</number>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,30 +76,31 @@ public void onExport (ExportRequest event) {
String projectFilePath = projectPrefs.getString("project.general.exportPath", "");

logger.info("checking project path {}", projectFilePath);

BaseAssetRepository.AssetRepositoryCatalogueExportOptions settings = new BaseAssetRepository.AssetRepositoryCatalogueExportOptions();
settings.loadFromPrefs(projectPrefs);

if (projectFilePath.isEmpty()) {
Toasts.getInstance().showInfoToast("Provide export path to enable exporting");
SharedResources.ui.showPreferencesWindow();
} else {
try {
BaseAssetRepository.AssetRepositoryCatalogueExportOptions settings = new BaseAssetRepository.AssetRepositoryCatalogueExportOptions();
settings.loadFromPrefs(projectPrefs);
AssetRepository.getInstance().exportToFile(settings, event.isOptimized());
} catch (Exception e) {
logger.error("Error when exporting", e);
}
}

if(!exportScript.isEmpty()) {
FileHandle exportScriptHandle = settings.getExportScriptHandle();
String projectPath = currentProject.rootProjectDir().path();

FileHandle handle = Gdx.files.absolute(projectPath + File.separator + exportScript);

if (handle.exists() && !handle.isDirectory()) {
if (exportScriptHandle.exists() && !exportScriptHandle.isDirectory()) {
Runtime rt = Runtime.getRuntime();

try {
String nodeCommand = "node";
String buildScriptPath = handle.path();
String buildScriptPath = exportScriptHandle.path();
String projectDirectoryPath = "\"" + projectPath + "\"";
String projectFilePathComm = "\"" + projectFilePath + "\"";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public static class AssetRepositoryCatalogueExportOptions {
private FileHandle exportPathHandle;

public void loadFromPrefs (Preferences projectPrefs) {
exportScriptHandle = Gdx.files.absolute(projectPrefs.getString("project.general.exportScript", ""));
String exportScriptPath = projectPrefs.getString("project.general.exportScript", null);
if (exportScriptPath != null) {
exportScriptHandle = Gdx.files.absolute(exportScriptPath);
}
exportPathHandle = Gdx.files.absolute(projectPrefs.getString("project.general.exportPath", ""));
}
}
Expand Down

0 comments on commit 3852a43

Please sign in to comment.