[libgdx] Skeleton Viewer, use canonical path.

Windows will give a short 8.3 path if the path is very long, then the ".json" extension becomes ".jso".
This commit is contained in:
Nathan Sweet 2022-01-28 17:50:05 -04:00
parent 4bf5c690d0
commit f07d1aef43

View File

@ -119,8 +119,15 @@ public class SkeletonViewer extends ApplicationAdapter {
}
}
boolean loadSkeleton (final @Null FileHandle skeletonFile) {
boolean loadSkeleton (@Null FileHandle skeletonFile) {
if (skeletonFile == null) return false;
try {
skeletonFile = new FileHandle(skeletonFile.file().getCanonicalFile());
} catch (Throwable ex) {
skeletonFile = new FileHandle(skeletonFile.file().getAbsoluteFile());
}
FileHandle oldSkeletonFile = this.skeletonFile;
this.skeletonFile = skeletonFile;
reloadTimer = 0;
@ -139,7 +146,7 @@ public class SkeletonViewer extends ApplicationAdapter {
skeletonData = loader.readSkeletonData(skeletonFile);
if (skeletonData.getBones().size == 0) throw new Exception("No bones in skeleton data.");
} catch (Throwable ex) {
System.out.println("Error loading skeleton: " + skeletonFile.file().getAbsolutePath());
System.out.println("Error loading skeleton: " + skeletonFile.path());
ex.printStackTrace();
ui.toast("Error loading skeleton: " + skeletonFile.name());
this.skeletonFile = oldSkeletonFile;