Selaa lähdekoodia

Application: use JmeSystem to get asset config URL

shadowislord 10 vuotta sitten
vanhempi
sitoutus
92e08b1f2b
1 muutettua tiedostoa jossa 11 lisäystä ja 9 poistoa
  1. 11 9
      jme3-core/src/main/java/com/jme3/app/Application.java

+ 11 - 9
jme3-core/src/main/java/com/jme3/app/Application.java

@@ -174,28 +174,30 @@ public class Application implements SystemListener {
     }
     }
 
 
     private void initAssetManager(){
     private void initAssetManager(){
+        URL assetCfgUrl = null;
+        
         if (settings != null){
         if (settings != null){
             String assetCfg = settings.getString("AssetConfigURL");
             String assetCfg = settings.getString("AssetConfigURL");
             if (assetCfg != null){
             if (assetCfg != null){
-                URL url = null;
                 try {
                 try {
-                    url = new URL(assetCfg);
+                    assetCfgUrl = new URL(assetCfg);
                 } catch (MalformedURLException ex) {
                 } catch (MalformedURLException ex) {
                 }
                 }
-                if (url == null) {
-                    url = Application.class.getClassLoader().getResource(assetCfg);
-                    if (url == null) {
+                if (assetCfgUrl == null) {
+                    assetCfgUrl = Application.class.getClassLoader().getResource(assetCfg);
+                    if (assetCfgUrl == null) {
                         logger.log(Level.SEVERE, "Unable to access AssetConfigURL in asset config:{0}", assetCfg);
                         logger.log(Level.SEVERE, "Unable to access AssetConfigURL in asset config:{0}", assetCfg);
                         return;
                         return;
                     }
                     }
                 }
                 }
-                assetManager = JmeSystem.newAssetManager(url);
             }
             }
         }
         }
+        if (assetCfgUrl == null) {
+            String assetCfg = JmeSystem.getPlatformAssetConfigPath();
+            assetCfgUrl = Thread.currentThread().getContextClassLoader().getResource(assetCfg);
+        }
         if (assetManager == null){
         if (assetManager == null){
-            assetManager = JmeSystem.newAssetManager(
-                    Thread.currentThread().getContextClassLoader()
-                    .getResource("com/jme3/asset/Desktop.cfg"));
+            assetManager = JmeSystem.newAssetManager(assetCfgUrl);
         }
         }
     }
     }