make several adventure resources common (particle_effects, skin, sprites, ui, most of world)
@@ -41,6 +41,7 @@ import java.util.List;
|
|||||||
public class Config {
|
public class Config {
|
||||||
private static Config currentConfig;
|
private static Config currentConfig;
|
||||||
private final String prefix;
|
private final String prefix;
|
||||||
|
private final String commonPrefix;
|
||||||
private final HashMap<String, FileHandle> Cache = new HashMap<String, FileHandle>();
|
private final HashMap<String, FileHandle> Cache = new HashMap<String, FileHandle>();
|
||||||
private ConfigData configData;
|
private ConfigData configData;
|
||||||
private final String[] adventures;
|
private final String[] adventures;
|
||||||
@@ -97,6 +98,7 @@ public class Config {
|
|||||||
|
|
||||||
//prefix = "forge-gui/res/adventure/Shandalar/";
|
//prefix = "forge-gui/res/adventure/Shandalar/";
|
||||||
prefix = getPlanePath(settingsData.plane);
|
prefix = getPlanePath(settingsData.plane);
|
||||||
|
commonPrefix = getPlanePath("common");
|
||||||
|
|
||||||
currentConfig = this;
|
currentConfig = this;
|
||||||
if (FModel.getPreferences() != null)
|
if (FModel.getPreferences() != null)
|
||||||
@@ -144,18 +146,33 @@ public class Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FileHandle getFile(String path) {
|
public FileHandle getFile(String path) {
|
||||||
String fullPath = prefix + path;
|
String fullPath = (prefix + path).replace("//","/");
|
||||||
fullPath = fullPath.replace("//","/");
|
String commonPath= (commonPrefix+path).replace("//","/");
|
||||||
if (!Cache.containsKey(fullPath)) {
|
int x=0;
|
||||||
|
if(Cache.containsKey(fullPath)) x=1;
|
||||||
String fileName = fullPath.replaceFirst("[.][^.]+$", "");
|
else if(Cache.containsKey(commonPath)) x=2;
|
||||||
String ext = fullPath.substring(fullPath.lastIndexOf('.'));
|
switch(x) {
|
||||||
String langFile = fileName + "-" + Lang + ext;
|
case 2:
|
||||||
if (Files.exists(Paths.get(langFile))) {
|
return Cache.get(commonPath);
|
||||||
Cache.put(fullPath, new FileHandle(langFile));
|
case 0:
|
||||||
} else {
|
String fileName = fullPath.replaceFirst("[.][^.]+$", "");
|
||||||
Cache.put(fullPath, new FileHandle(fullPath));
|
String commonFileName = commonPath.replaceFirst("[.][^.]+$", "");
|
||||||
}
|
String ext = fullPath.substring(fullPath.lastIndexOf('.'));
|
||||||
|
String langFile = fileName + "-" + Lang + ext;
|
||||||
|
String commonLangFile = commonFileName + "-" + Lang + ext;
|
||||||
|
boolean isCommon = false;
|
||||||
|
if (Files.exists(Paths.get(langFile))) {
|
||||||
|
Cache.put(fullPath, new FileHandle(langFile));
|
||||||
|
} else if (Files.exists(Paths.get(commonLangFile))) {
|
||||||
|
Cache.put(commonPath, new FileHandle(langFile));
|
||||||
|
isCommon = true;
|
||||||
|
} else if (Files.exists(Paths.get(fullPath))) {
|
||||||
|
Cache.put(fullPath, new FileHandle(fullPath));
|
||||||
|
} else if (Files.exists(Paths.get(commonPath))) {
|
||||||
|
Cache.put(commonPath, new FileHandle(commonPath));
|
||||||
|
isCommon = true;
|
||||||
|
}
|
||||||
|
if (isCommon) return Cache.get(commonPath);
|
||||||
}
|
}
|
||||||
return Cache.get(fullPath);
|
return Cache.get(fullPath);
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 441 B After Width: | Height: | Size: 441 B |
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
|
Before Width: | Height: | Size: 650 B After Width: | Height: | Size: 650 B |
|
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 338 B After Width: | Height: | Size: 338 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 402 B After Width: | Height: | Size: 402 B |