Changeset 600 for AE/installer2/src/net/oni2/aeinstaller/backend
- Timestamp:
- Jan 10, 2013, 12:12:01 AM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller/backend
- Files:
-
- 6 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/backend/Settings.java
r596 r600 10 10 import java.util.Vector; 11 11 12 import net.oni2.aeinstaller.backend.app_launcher.QuickAppExecution;13 12 14 13 import com.thoughtworks.xstream.XStream; … … 112 111 res = QuickAppExecution.execute(cmd); 113 112 } catch (IOException e) { 114 // TODO Auto-generated catch block115 113 e.printStackTrace(); 116 114 } -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/DepotManager.java
r592 r600 18 18 import net.oni2.aeinstaller.backend.depot.model.TaxonomyTerm; 19 19 import net.oni2.aeinstaller.backend.depot.model.TaxonomyVocabulary; 20 import net.oni2.aeinstaller.backend.mods.ECompatiblePlatform; 20 21 import net.oni2.aeinstaller.backend.network.DrupalJSONQuery; 21 22 … … 287 288 288 289 /** 289 * @return Mod-Nodes 290 */ 291 public Vector<NodeMod> getModPackageNodes() { 292 Vector<NodeMod> result = new Vector<NodeMod>(); 293 TaxonomyTerm tt = getTaxonomyTerm(DepotConfig.getTaxonomyName_InstallType_Package()); 294 if (tt == null) 295 return result; 296 297 int packageterm_id = tt.getTid(); 298 290 * Get a node by node id 291 * 292 * @param id 293 * Node id 294 * @return Node 295 */ 296 public Node getNodeById(int id) { 297 return nodes.get(id); 298 } 299 300 /** 301 * Get a Mod-Node by a given package number 302 * 303 * @param packageNumber 304 * Package number to find 305 * @return The Mod-Node or null 306 */ 307 public NodeMod getNodeByPackageNumber(int packageNumber) { 299 308 Vector<Node> files = getNodesByType(DepotConfig.getNodeType_Mod()); 300 309 for (Node n : files) { 301 310 if (n instanceof NodeMod) { 302 311 NodeMod nm = (NodeMod) n; 303 if (nm.getTaxonomyTerms().get(vocabId_instmethod) 304 .contains(packageterm_id)) 312 if (nm.getPackageNumber() == packageNumber) 313 return nm; 314 } 315 } 316 return null; 317 } 318 319 /** 320 * @return Mod-Nodes 321 */ 322 public Vector<NodeMod> getModPackageNodes() { 323 Vector<NodeMod> result = new Vector<NodeMod>(); 324 String instMethName = DepotConfig.getTaxonomyName_InstallType_Package(); 325 326 Vector<Node> files = getNodesByType(DepotConfig.getNodeType_Mod()); 327 for (Node n : files) { 328 if (n instanceof NodeMod) { 329 NodeMod nm = (NodeMod) n; 330 if (nm.getInstallMethod().getName() 331 .equalsIgnoreCase(instMethName)) 305 332 result.add(nm); 306 333 } … … 317 344 */ 318 345 public boolean isModValidOnPlatform(NodeMod node, Settings.Platform platform) { 319 int termId = node.getTaxonomyTerms().get(vocabId_platform).iterator() 320 .next(); 321 String validPlatform = getTaxonomyTerm(termId).getName(); 322 if (validPlatform.equalsIgnoreCase(DepotConfig.getTaxonomyName_Platform_Both())) 323 return true; 324 325 if ((platform == Platform.WIN) || (platform == Platform.LINUX)) 326 return validPlatform.equalsIgnoreCase(DepotConfig.getTaxonomyName_Platform_Win()); 327 else if (platform == Platform.MACOS) 328 return validPlatform.equalsIgnoreCase(DepotConfig.getTaxonomyName_Platform_Mac()); 329 else 330 return false; 346 ECompatiblePlatform plat = node.getPlatform(); 347 switch (plat) { 348 case BOTH: 349 return true; 350 case WIN: 351 return (platform == Platform.WIN) 352 || (platform == Platform.LINUX); 353 case MACOS: 354 return (platform == Platform.MACOS); 355 } 356 return false; 331 357 } 332 358 … … 344 370 */ 345 371 public boolean isModOfType(NodeMod node, HashSet<Integer> type, boolean or) { 346 boolean matching = true; 347 if (or) 348 matching = false; 372 boolean matching = !or; 373 HashSet<TaxonomyTerm> terms = node.getTypes(); 349 374 350 375 for (int t : type) { 351 376 if (or) 352 matching |= node.getTaxonomyTerms().get(vocabId_type) 353 .contains(t); 377 matching |= terms.contains(t); 354 378 else 355 matching &= node.getTaxonomyTerms().get(vocabId_type) 356 .contains(t); 379 matching &= terms.contains(t); 357 380 } 358 381 return matching; 382 } 383 384 /** 385 * @return VocabId of Platform vocabulary 386 */ 387 public int getVocabIdPlatform() { 388 return vocabId_platform; 389 } 390 391 /** 392 * @return VocabId of Install method vocabulary 393 */ 394 public int getVocabIdInstMethod() { 395 return vocabId_instmethod; 396 } 397 398 /** 399 * @return VocabId of Type vocabulary 400 */ 401 public int getVocabIdType() { 402 return vocabId_type; 403 } 404 405 /** 406 * @param id 407 * ID of file to get 408 * @return the file 409 */ 410 public File getFile(int id) { 411 return files.get(id); 359 412 } 360 413 -
AE/installer2/src/net/oni2/aeinstaller/backend/depot/model/NodeMod.java
r592 r600 4 4 import java.util.HashSet; 5 5 import java.util.Vector; 6 7 import net.oni2.aeinstaller.backend.depot.DepotConfig; 8 import net.oni2.aeinstaller.backend.depot.DepotManager; 9 import net.oni2.aeinstaller.backend.mods.ECompatiblePlatform; 6 10 7 11 import org.json.JSONArray; … … 74 78 75 79 /** 76 * @return the taxonomyTerms80 * @return Types 77 81 */ 78 public HashMap<Integer, HashSet<Integer>> getTaxonomyTerms() { 79 return taxonomyTerms; 82 public HashSet<TaxonomyTerm> getTypes() { 83 HashSet<TaxonomyTerm> tt = new HashSet<TaxonomyTerm>(); 84 for (int t : taxonomyTerms.get(DepotManager.getInstance() 85 .getVocabIdType())) { 86 tt.add(DepotManager.getInstance().getTaxonomyTerm(t)); 87 } 88 return tt; 80 89 } 81 90 82 91 /** 83 * @return the fields92 * @return Install method 84 93 */ 85 public HashMap<String, String> getFields() { 86 return fields; 94 public TaxonomyTerm getInstallMethod() { 95 return DepotManager.getInstance().getTaxonomyTerm( 96 taxonomyTerms 97 .get(DepotManager.getInstance().getVocabIdInstMethod()) 98 .iterator().next()); 99 } 100 101 /** 102 * @return Compatible platform 103 */ 104 public ECompatiblePlatform getPlatform() { 105 TaxonomyTerm term = DepotManager.getInstance().getTaxonomyTerm( 106 taxonomyTerms 107 .get(DepotManager.getInstance().getVocabIdPlatform()) 108 .iterator().next()); 109 110 String validPlatform = term.getName(); 111 if (validPlatform.equalsIgnoreCase(DepotConfig 112 .getTaxonomyName_Platform_Both())) 113 return ECompatiblePlatform.BOTH; 114 if (validPlatform.equalsIgnoreCase(DepotConfig 115 .getTaxonomyName_Platform_Win())) 116 return ECompatiblePlatform.WIN; 117 if (validPlatform.equalsIgnoreCase(DepotConfig 118 .getTaxonomyName_Platform_Mac())) 119 return ECompatiblePlatform.MACOS; 120 121 return null; 122 } 123 124 /** 125 * @return Creator of mod 126 */ 127 public String getCreator() { 128 if (fields.get("creator") != null) 129 return fields.get("creator"); 130 else 131 return ""; 132 } 133 134 /** 135 * @return Version of mod 136 */ 137 public String getVersion() { 138 if (fields.get("version") != null) 139 return fields.get("version"); 140 else 141 return ""; 142 } 143 144 /** 145 * @return Package number 146 */ 147 public int getPackageNumber() { 148 return Integer.parseInt(fields.get("package_number")); 87 149 } 88 150 } -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/Mod.java
r598 r600 1 1 package net.oni2.aeinstaller.backend.mods; 2 2 3 import java.io.BufferedReader; 3 4 import java.io.File; 5 import java.io.FileInputStream; 6 import java.io.FileNotFoundException; 7 import java.io.FilenameFilter; 8 import java.io.IOException; 9 import java.io.InputStreamReader; 10 import java.util.HashSet; 11 12 import net.oni2.aeinstaller.backend.Paths; 13 import net.oni2.aeinstaller.backend.Settings; 14 import net.oni2.aeinstaller.backend.Settings.Platform; 15 import net.oni2.aeinstaller.backend.depot.DepotManager; 16 import net.oni2.aeinstaller.backend.depot.model.NodeMod; 17 import net.oni2.aeinstaller.backend.depot.model.TaxonomyTerm; 4 18 5 19 /** … … 7 21 */ 8 22 public class Mod implements Comparable<Mod> { 9 private double aeVersion; 10 private int node; 11 private int packageNumber; 12 13 public double getAEVersion() { 14 return aeVersion; 15 } 16 23 // TODO: Dependencies/Conflicts 24 25 private String name = ""; 26 private int packageNumber = 0; 27 28 private HashSet<Type> types = new HashSet<Type>(); 29 private ECompatiblePlatform platform = null; 30 private String version = ""; 31 private String creator = ""; 32 private EBSLInstallType bslInstallType = null; 33 private String description = ""; 34 private double aeVersion = 0; 35 private int zipSize = 0; 36 private NodeMod node = null; 37 private net.oni2.aeinstaller.backend.depot.model.File file = null; 38 39 private long localTimestamp = 0; 40 41 /** 42 * Create a new Mod entry from a given Mod-Node 43 * 44 * @param nm 45 * Mod-Node 46 */ 47 public Mod(NodeMod nm) { 48 node = nm; 49 name = nm.getTitle(); 50 packageNumber = nm.getPackageNumber(); 51 for (TaxonomyTerm tt : nm.getTypes()) { 52 Type t = ModManager.getInstance().getTypeByName(tt.getName()); 53 types.add(t); 54 t.addEntry(this); 55 } 56 platform = nm.getPlatform(); 57 version = nm.getVersion(); 58 creator = nm.getCreator(); 59 if (nm.getBody() != null) 60 description = nm.getBody().getSafe_value(); 61 file = DepotManager.getInstance().getFile( 62 nm.getUploads().firstElement().getFid()); 63 zipSize = file.getFilesize(); 64 65 if (isLocalAvailable()) 66 updateLocalData(); 67 } 68 69 /** 70 * Update information for local package existence 71 */ 72 public void updateLocalData() { 73 File config = new File(getLocalPath(), "Mod_Info.cfg"); 74 File timestamp = new File(getLocalPath(), "aei.cfg"); 75 if (config.exists()) { 76 try { 77 FileInputStream fstream = new FileInputStream(config); 78 InputStreamReader isr = new InputStreamReader(fstream); 79 BufferedReader br = new BufferedReader(isr); 80 String strLine; 81 while ((strLine = br.readLine()) != null) { 82 if (strLine.indexOf("->") < 1) 83 continue; 84 if (strLine.indexOf("//") >= 0) 85 strLine = strLine.substring(0, strLine.indexOf("//")); 86 String[] split = strLine.split("->", 2); 87 String sName = split[0].trim(); 88 String sVal = split[1].trim(); 89 if (sName.equalsIgnoreCase("AEInstallVersion")) { 90 aeVersion = Double.parseDouble(sVal); 91 } else if (sName.equalsIgnoreCase("NameOfMod")) { 92 if (node == null) 93 name = sVal; 94 } else if (sName.equalsIgnoreCase("Creator")) { 95 if (node == null) 96 creator = sVal; 97 } else if (sName.equalsIgnoreCase("HasBsl")) { 98 if (sVal.equalsIgnoreCase("addon")) 99 bslInstallType = EBSLInstallType.ADDON; 100 else if (sVal.equalsIgnoreCase("yes")) 101 bslInstallType = EBSLInstallType.NORMAL; 102 else 103 bslInstallType = EBSLInstallType.NONE; 104 } else if (sName.equalsIgnoreCase("ModVersion")) { 105 if (node == null) 106 version = sVal; 107 } else if (sName.equalsIgnoreCase("Readme")) { 108 if (node == null) 109 description = sVal.replaceAll("\\\\n", "<br>"); 110 } 111 } 112 isr.close(); 113 } catch (FileNotFoundException e) { 114 } catch (IOException e) { 115 e.printStackTrace(); 116 } 117 } else { 118 System.err.println("No config found for mod folder: " 119 + getLocalPath().getPath()); 120 } 121 if (timestamp.exists()) { 122 try { 123 FileInputStream fstream = new FileInputStream(timestamp); 124 InputStreamReader isr = new InputStreamReader(fstream); 125 BufferedReader br = new BufferedReader(isr); 126 String ts = br.readLine(); 127 localTimestamp = Long.parseLong(ts); 128 isr.close(); 129 } catch (FileNotFoundException e) { 130 } catch (IOException e) { 131 e.printStackTrace(); 132 } 133 } 134 } 135 136 /** 137 * Create a new Mod entry from the given local mod folder 138 * 139 * @param folder 140 * Mod folder with Mod_Info.cfg 141 */ 142 public Mod(File folder) { 143 packageNumber = Integer.parseInt(folder.getName().substring(0, 5)); 144 updateLocalData(); 145 146 Type t = ModManager.getInstance().getTypeByName("-Local-"); 147 types.add(t); 148 t.addEntry(this); 149 150 platform = ECompatiblePlatform.BOTH; 151 } 152 153 /** 154 * @return has separate paths for win/mac/common or not 155 */ 17 156 public boolean hasSeparatePlatformDirs() { 18 157 return aeVersion >= 2; 19 158 } 20 159 160 /** 161 * @return Path to local mod folder 162 */ 21 163 public File getLocalPath() { 22 // TODO 23 return null; 24 } 25 26 public boolean newerAvailable() { 27 //TODO 28 return false; 29 } 30 31 public boolean localAvailable() { 32 //TODO 33 return false; 34 } 35 164 final String folderStart = String.format("%05d", packageNumber); 165 166 if (Paths.getModsPath().exists()) { 167 for (File f : Paths.getModsPath().listFiles(new FilenameFilter() { 168 @Override 169 public boolean accept(File d, String fn) { 170 return fn.startsWith(folderStart); 171 } 172 })) { 173 return f; 174 } 175 } 176 177 return new File(Paths.getModsPath(), folderStart); 178 } 179 180 /** 181 * @return Is there a newer version on the depot? 182 */ 183 public boolean isNewerAvailable() { 184 if (node != null) 185 return node.getUploads().firstElement().getTimestamp() > localTimestamp; 186 else 187 return false; 188 } 189 190 /** 191 * @return Mod exists within mods folder 192 */ 193 public boolean isLocalAvailable() { 194 return getLocalPath().exists(); 195 } 196 197 /** 198 * @return Name of mod 199 */ 200 public String getName() { 201 return name; 202 } 203 204 /** 205 * @return the package number 206 */ 36 207 public int getPackageNumber() { 37 208 return packageNumber; 209 } 210 211 /** 212 * @return Types of mod 213 */ 214 public HashSet<Type> getTypes() { 215 return types; 216 } 217 218 /** 219 * @return Compatible platforms 220 */ 221 public ECompatiblePlatform getPlatform() { 222 return platform; 223 } 224 225 /** 226 * @return Version of mod 227 */ 228 public String getVersion() { 229 return version; 230 } 231 232 /** 233 * @return Creator of mod 234 */ 235 public String getCreator() { 236 return creator; 237 } 238 239 /** 240 * @return Installation type of BSL files 241 */ 242 public EBSLInstallType getBSLInstallType() { 243 return bslInstallType; 244 } 245 246 /** 247 * @return Description of mod 248 */ 249 public String getDescription() { 250 return description; 251 } 252 253 /** 254 * @return Size of Zip file on Depot 255 */ 256 public int getZipSize() { 257 return zipSize; 258 } 259 260 /** 261 * @return Depot Mod-Node 262 */ 263 public NodeMod getNode() { 264 return node; 265 } 266 267 /** 268 * @return Is a mod that is always installed? 269 */ 270 public boolean isDefaultMod() { 271 return packageNumber < 10000; 272 } 273 274 /** 275 * @return Get the depot file entry 276 */ 277 public net.oni2.aeinstaller.backend.depot.model.File getFile() { 278 return file; 279 } 280 281 @Override 282 public String toString() { 283 return name; 284 } 285 286 /** 287 * @return Is this mod valid on the running platform? 288 */ 289 public boolean validOnPlatform() { 290 ECompatiblePlatform plat = platform; 291 switch (plat) { 292 case BOTH: 293 return true; 294 case MACOS: 295 return (Settings.getPlatform() == Platform.MACOS); 296 case WIN: 297 return (Settings.getPlatform() == Platform.WIN) 298 || (Settings.getPlatform() == Platform.LINUX); 299 } 300 return false; 38 301 } 39 302 -
AE/installer2/src/net/oni2/aeinstaller/backend/network/DrupalJSONQuery.java
r591 r600 59 59 + ".json", data); 60 60 } catch (UnsupportedEncodingException e) { 61 // TODO Auto-generated catch block62 61 e.printStackTrace(); 63 62 } … … 170 169 return jA; 171 170 } catch (JSONException e) { 172 // TODO Auto-generated catch block173 171 e.printStackTrace(); 174 172 } catch (UnsupportedEncodingException e) { 175 // TODO Auto-generated catch block176 173 e.printStackTrace(); 177 174 } catch (IOException e) { 178 // TODO Auto-generated catch block179 175 e.printStackTrace(); 180 176 } finally { … … 185 181 input.close(); 186 182 } catch (IOException e) { 187 // TODO Auto-generated catch block188 183 e.printStackTrace(); 189 184 } -
AE/installer2/src/net/oni2/aeinstaller/backend/oni/Installer.java
r599 r600 3 3 import java.io.File; 4 4 import java.io.FileFilter; 5 import java.io.FileNotFoundException; 5 6 import java.io.FilenameFilter; 6 7 import java.io.IOException; 8 import java.io.PrintWriter; 9 import java.text.SimpleDateFormat; 10 import java.util.Date; 7 11 import java.util.HashMap; 8 12 import java.util.List; … … 35 39 } 36 40 37 public static void install(TreeSet<Mod> mods) { 41 public static void install(TreeSet<Mod> mods, 42 InstallProgressListener listener) { 43 38 44 Vector<File> folders = new Vector<File>(); 39 45 folders.add(Paths.getVanillaOnisPath()); … … 59 65 } 60 66 61 for (File f : Paths.getModsPath().listFiles()) {62 63 64 65 }66 combineBinaryFiles(folders );67 // for (File f : Paths.getModsPath().listFiles()) { 68 // File oni = new File(f, "oni"); 69 // if (oni.exists()) 70 // folders.add(oni); 71 // } 72 combineBinaryFiles(folders, listener); 67 73 68 74 // TODO: bsl() 69 75 } 70 76 71 private static void combineBinaryFiles(List<File> srcFolders) { 77 private static void combineBinaryFiles(List<File> srcFoldersFiles, 78 InstallProgressListener listener) { 72 79 try { 80 HashMap<String, Vector<File>> levels = new HashMap<String, Vector<File>>(); 81 82 for (File path : srcFoldersFiles) { 83 for (File levelF : path.listFiles()) { 84 String fn = levelF.getName().toLowerCase(); 85 String levelN = null; 86 if (levelF.isDirectory()) { 87 levelN = fn; 88 } else if (fn.endsWith(".dat")) { 89 levelN = fn.substring(0, fn.lastIndexOf('.')); 90 } 91 if (levelN != null) { 92 if (!levels.containsKey(levelN)) 93 levels.put(levelN, new Vector<File>()); 94 levels.get(levelN).add(levelF); 95 } 96 } 97 } 98 99 int totalSteps = 0; 100 int stepsDone = 0; 101 102 for (@SuppressWarnings("unused") 103 String s : levels.keySet()) 104 totalSteps++; 105 106 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 107 108 File logFile = new File(Paths.getInstallerPath(), 109 "Installation.log"); 110 PrintWriter log = null; 111 try { 112 log = new PrintWriter(logFile); 113 } catch (FileNotFoundException e) { 114 e.printStackTrace(); 115 } 116 117 Date start = new Date(); 118 log.println("Installation of mods started at " + sdf.format(start)); 119 120 log.println("Cleaning directories"); 121 listener.installProgressUpdate(stepsDone, totalSteps, 122 "Cleaning up directories"); 123 73 124 createEmptyPath(Paths.getEditionGDF()); 74 HashMap<String, Vector<File>> levels = new HashMap<String, Vector<File>>(); 75 76 for (File path : srcFolders) { 77 for (File levelF : path.listFiles()) { 78 if (!levels.containsKey(levelF.getName().toLowerCase())) 79 levels.put(levelF.getName().toLowerCase(), 80 new Vector<File>()); 81 levels.get(levelF.getName().toLowerCase()).add(levelF); 82 } 83 } 84 125 126 log.println("Importing levels"); 85 127 for (String l : levels.keySet()) { 86 System.out.println("Level " + l);128 log.println("\tLevel " + l); 87 129 for (File f : levels.get(l)) { 88 System.out.println(" " + f.getPath()); 89 90 } 91 92 OniSplit.importLevel(levels.get(l), 130 log.println("\t\t\t" + f.getPath()); 131 } 132 133 Vector<String> res = OniSplit.packLevel(levels.get(l), 93 134 new File(Paths.getEditionGDF(), l + ".dat")); 94 95 System.out.println(); 96 } 135 if (res != null && res.size() > 0) { 136 for (String s : res) 137 log.println("\t\t" + s); 138 } 139 140 log.println(); 141 } 142 143 Date end = new Date(); 144 log.println("Initialization ended at " + sdf.format(end)); 145 log.println("Process took " 146 + ((end.getTime() - start.getTime()) / 1000) + " seconds"); 147 log.close(); 97 148 } catch (IOException e) { 98 149 // TODO Auto-generated catch block … … 103 154 /** 104 155 * Initializes the Edition core 156 * 157 * @param listener 158 * Listener for status updates 105 159 */ 106 public static void initializeEdition( ) {160 public static void initializeEdition(InstallProgressListener listener) { 107 161 File init = new File(Paths.getTempPath(), "init"); 162 163 int totalSteps = 0; 164 int stepsDone = 0; 165 166 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 167 168 for (@SuppressWarnings("unused") 169 File f : Paths.getVanillaGDF().listFiles(new FilenameFilter() { 170 @Override 171 public boolean accept(File dir, String name) { 172 return name.endsWith(".dat"); 173 } 174 })) { 175 totalSteps++; 176 } 177 totalSteps = totalSteps * 2 + 2; 178 108 179 try { 180 File logFile = new File(Paths.getInstallerPath(), 181 "Initialization.log"); 182 PrintWriter log = new PrintWriter(logFile); 183 184 Date start = new Date(); 185 log.println("Initialization of Edition core started at " 186 + sdf.format(start)); 187 log.println("Cleaning directories"); 188 189 listener.installProgressUpdate(stepsDone, totalSteps, 190 "Cleaning up directories"); 109 191 createEmptyPath(Paths.getVanillaOnisPath()); 110 192 createEmptyPath(init); 111 193 File level0Folder = new File(init, "level0_Final"); 112 194 createEmptyPath(level0Folder); 113 File level0FolderVanilla = new File(Paths.getVanillaOnisPath(), 114 "level0_Final");115 createEmptyPath(level0FolderVanilla); 116 createEmptyPath(new File(level0FolderVanilla, "characters"));195 196 stepsDone++; 197 198 log.println("Exporting levels and moving files to level0"); 117 199 118 200 for (File f : Paths.getVanillaGDF().listFiles(new FilenameFilter() { … … 127 209 int levelNumber = Integer.parseInt(fi.findInLine("[0-9]+")); 128 210 211 log.println("\t" + levelName + ":"); 212 log.println("\t\tExporting"); 213 listener.installProgressUpdate(stepsDone, totalSteps, 214 "Exporting vanilla level " + levelNumber); 215 129 216 // Edition/GameDataFolder/level*_Final/ 130 217 File tempLevelFolder = new File(init, levelName); 131 218 132 219 // Export Vanilla-Level-Dat -> Temp/Level 133 OniSplit.export(tempLevelFolder, f); 134 220 Vector<String> res = OniSplit.export(tempLevelFolder, f); 221 if (res != null && res.size() > 0) { 222 for (String s : res) 223 log.println("\t\t\t" + s); 224 } 225 226 log.println("\t\tMoving files"); 135 227 handleFileGlobalisation(tempLevelFolder, level0Folder, 136 level0FolderVanilla, levelNumber); 137 } 228 levelNumber); 229 stepsDone++; 230 log.println(); 231 } 232 233 log.println("Reimporting levels"); 138 234 139 235 for (File f : init.listFiles()) { 140 236 String levelName = f.getName(); 141 237 142 // Edition/AEInstaller/vanilla/level*_Final/ 143 File vanillaFolder = new File(Paths.getVanillaOnisPath(), 144 levelName); 145 vanillaFolder.mkdirs(); 238 log.println("\t" + levelName); 239 listener.installProgressUpdate(stepsDone, totalSteps, 240 "Creating globalized " + levelName); 146 241 147 242 Vector<File> folders = new Vector<File>(); 148 243 folders.add(f); 149 244 150 OniSplit.importLevel(folders, new File(vanillaFolder, levelName 151 + ".oni")); 152 } 153 245 Vector<String> res = OniSplit.importLevel(folders, new File( 246 Paths.getVanillaOnisPath(), levelName + ".dat")); 247 if (res != null && res.size() > 0) { 248 for (String s : res) 249 log.println("\t\t" + s); 250 } 251 252 log.println(); 253 stepsDone++; 254 } 255 256 listener.installProgressUpdate(stepsDone, totalSteps, 257 "Copying basic files"); 154 258 // Copy Oni-configs 155 259 File persistVanilla = new File(Paths.getOniBasePath(), … … 167 271 168 272 // TODO: FileUtils.deleteDirectory(init); 273 Date end = new Date(); 274 log.println("Initialization ended at " + sdf.format(end)); 275 log.println("Process took " 276 + ((end.getTime() - start.getTime()) / 1000) + " seconds"); 277 log.close(); 169 278 } catch (IOException e) { 170 279 e.printStackTrace(); … … 185 294 186 295 private static void handleFileGlobalisation(File tempFolder, 187 File level0Folder, File level0FolderVanilla,int levelNumber) {296 File level0Folder, int levelNumber) { 188 297 // Move AKEV and related files to subfolder so they're not globalized: 189 298 if (levelNumber != 0) { -
AE/installer2/src/net/oni2/aeinstaller/backend/oni/OniSplit.java
r598 r600 8 8 9 9 import net.oni2.aeinstaller.backend.Paths; 10 import net.oni2.aeinstaller.backend.QuickAppExecution; 10 11 import net.oni2.aeinstaller.backend.Settings; 11 12 import net.oni2.aeinstaller.backend.Settings.Architecture; 12 13 import net.oni2.aeinstaller.backend.Settings.Platform; 13 14 import net.oni2.aeinstaller.backend.WinRegistry; 14 import net.oni2.aeinstaller.backend.app_launcher.QuickAppExecution;15 15 16 16 /** … … 83 83 * @param input 84 84 * Dat file 85 */ 86 public static void export(File targetFolder, File input) { 85 * @return OniSplit output 86 */ 87 public static Vector<String> export(File targetFolder, File input) { 87 88 if (!targetFolder.exists()) 88 89 targetFolder.mkdir(); … … 92 93 cmdLine.add(targetFolder.getPath()); 93 94 cmdLine.add(input.getPath()); 94 // System.out.println(cmdLine.toString()); 95 Vector<String> res = null; 96 try { 97 res = QuickAppExecution.execute(cmdLine); 98 } catch (IOException e) { 99 // TODO Auto-generated catch block 100 e.printStackTrace(); 101 } 102 if (res != null) { 103 // check for errors 104 System.out.println(res.toString()); 105 } 95 Vector<String> res = null; 96 try { 97 res = QuickAppExecution.execute(cmdLine); 98 } catch (IOException e) { 99 // TODO Auto-generated catch block 100 e.printStackTrace(); 101 } 102 return res; 106 103 } 107 104 … … 113 110 * @param targetFile 114 111 * Target .dat-file 115 */ 116 public static void importLevel(Vector<File> sourceFolders, File targetFile) { 112 * @return OniSplit output 113 */ 114 public static Vector<String> importLevel(Vector<File> sourceFolders, File targetFile) { 117 115 Vector<String> cmdLine = getProgramInvocation(); 118 116 cmdLine.add(getImportParam()); … … 120 118 cmdLine.add(f.getPath()); 121 119 cmdLine.add(targetFile.getPath()); 122 // System.out.println(cmdLine.toString()); 123 Vector<String> res = null; 124 try { 125 res = QuickAppExecution.execute(cmdLine); 126 } catch (IOException e) { 127 // TODO Auto-generated catch block 128 e.printStackTrace(); 129 } 130 if (res != null) { 131 // check for errors 132 System.out.println(res.toString()); 133 } 120 Vector<String> res = null; 121 try { 122 res = QuickAppExecution.execute(cmdLine); 123 } catch (IOException e) { 124 // TODO Auto-generated catch block 125 e.printStackTrace(); 126 } 127 return res; 128 } 129 130 /** 131 * Pack a level to a .dat-file. More powerful variant which allows 132 * specifying single .oni/.dat files 133 * 134 * @param sourceFoldersFiles 135 * Folders (for recursive .oni import) or files (.dat and single 136 * .oni) to import 137 * @param targetFile 138 * Target .dat-file 139 * @return OniSplit output 140 */ 141 public static Vector<String> packLevel(Vector<File> sourceFoldersFiles, 142 File targetFile) { 143 Vector<String> cmdLine = getProgramInvocation(); 144 cmdLine.add(getPackParam()); 145 cmdLine.add(getPackTypeParam()); 146 cmdLine.add("-out"); 147 cmdLine.add(targetFile.getPath()); 148 for (File f : sourceFoldersFiles) 149 cmdLine.add(f.getPath()); 150 Vector<String> res = null; 151 try { 152 res = QuickAppExecution.execute(cmdLine); 153 } catch (IOException e) { 154 // TODO Auto-generated catch block 155 e.printStackTrace(); 156 } 157 return res; 134 158 } 135 159 … … 144 168 * @param moveParameter 145 169 * e.g. overwrite, delete 146 */ 147 public static void move(File targetFolder, String input, 170 * @return OniSplit output 171 */ 172 public static Vector<String> move(File targetFolder, String input, 148 173 String moveParameter) { 149 174 if (!targetFolder.exists()) … … 162 187 e.printStackTrace(); 163 188 } 164 if (res != null && res.size() > 0) { 165 // TODO: errors 166 System.out.println(res.toString()); 167 } 189 return res; 168 190 } 169 191 … … 175 197 } 176 198 199 private static String getPackParam() { 200 return "pack"; 201 } 202 203 private static String getPackTypeParam() { 204 if (Settings.getPlatform() == Platform.MACOS) 205 return "-type:macintel"; 206 else 207 return "-type:pc"; 208 } 209 177 210 private static Vector<String> getProgramInvocation() { 178 211 Vector<String> res = new Vector<String>(); 179 212 if (Settings.getPlatform() != Platform.WIN) 180 213 res.add("mono"); 181 res.add(new File(Paths.getInstallerPath(), "Onisplit.exe").getPath()); 214 res.add(new File(new File(Paths.getEditionBasePath(), "Tools"), 215 "Onisplit.exe").getPath()); 182 216 return res; 183 217 }
Note:
See TracChangeset
for help on using the changeset viewer.