Changeset 608 for AE/installer2/src/net/oni2/aeinstaller/backend/oni
- Timestamp:
- Jan 14, 2013, 6:49:25 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/backend/oni/Installer.java
r606 r608 9 9 import java.text.SimpleDateFormat; 10 10 import java.util.Date; 11 import java.util.HashMap; 11 12 import java.util.List; 12 13 import java.util.Scanner; … … 18 19 import net.oni2.aeinstaller.backend.Settings; 19 20 import net.oni2.aeinstaller.backend.Settings.Platform; 21 import net.oni2.aeinstaller.backend.mods.EBSLInstallType; 20 22 import net.oni2.aeinstaller.backend.mods.Mod; 21 23 import net.oni2.aeinstaller.backend.mods.ModManager; … … 27 29 */ 28 30 public class Installer { 31 private static FileFilter dirFileFilter = new FileFilter() { 32 @Override 33 public boolean accept(File pathname) { 34 return pathname.isDirectory(); 35 } 36 }; 37 29 38 /** 30 39 * @return Is Edition Core initialized … … 97 106 } 98 107 } 108 99 109 /** 100 110 * Install the given set of mods … … 116 126 ModManager.getInstance().saveModSelection(installCfg, mods); 117 127 118 Vector<File> folders = new Vector<File>();119 folders .add(Paths.getVanillaOnisPath());128 Vector<File> foldersOni = new Vector<File>(); 129 foldersOni.add(Paths.getVanillaOnisPath()); 120 130 121 131 for (Mod m : mods) { … … 127 137 File oniWin = new File(oni, "win_only"); 128 138 if (oniCommon.exists()) 129 folders .add(oniCommon);139 foldersOni.add(oniCommon); 130 140 if (Settings.getPlatform() == Platform.MACOS 131 141 && oniMac.exists()) 132 folders .add(oniMac);142 foldersOni.add(oniMac); 133 143 else if (oniWin.exists()) 134 folders .add(oniWin);144 foldersOni.add(oniWin); 135 145 } else { 136 folders.add(oni); 137 } 138 } 139 } 140 141 combineBinaryFiles(folders, listener); 142 143 // TODO: bsl() 146 foldersOni.add(oni); 147 } 148 } 149 } 150 combineBinaryFiles(foldersOni, listener); 151 combineBSLFolders(mods, listener); 152 } 153 154 private static void combineBSLFolders(TreeSet<Mod> mods, 155 InstallProgressListener listener) { 156 listener.installProgressUpdate(95, 100, "Installing BSL files"); 157 158 HashMap<EBSLInstallType, Vector<Mod>> modsToInclude = new HashMap<EBSLInstallType, Vector<Mod>>(); 159 modsToInclude.put(EBSLInstallType.NORMAL, new Vector<Mod>()); 160 modsToInclude.put(EBSLInstallType.ADDON, new Vector<Mod>()); 161 162 for (Mod m : mods.descendingSet()) { 163 File bsl = new File(m.getLocalPath(), "bsl"); 164 if (bsl.exists()) { 165 if (m.hasSeparatePlatformDirs()) { 166 File bslCommon = new File(bsl, "common"); 167 File bslMac = new File(bsl, "mac_only"); 168 File bslWin = new File(bsl, "win_only"); 169 if ((Settings.getPlatform() == Platform.MACOS && bslMac 170 .exists()) 171 || ((Settings.getPlatform() == Platform.WIN || Settings 172 .getPlatform() == Platform.LINUX) && bslWin 173 .exists()) || bslCommon.exists()) { 174 modsToInclude.get(m.getBSLInstallType()).add(m); 175 } 176 } else { 177 modsToInclude.get(m.getBSLInstallType()).add(m); 178 } 179 } 180 } 181 182 for (Mod m : modsToInclude.get(EBSLInstallType.NORMAL)) { 183 copyBSL(m, false); 184 } 185 for (Mod m : modsToInclude.get(EBSLInstallType.ADDON)) { 186 copyBSL(m, true); 187 } 188 } 189 190 private static void copyBSL(Mod sourceMod, boolean addon) { 191 File targetBaseFolder = new File(Paths.getEditionGDF(), "IGMD"); 192 if (!targetBaseFolder.exists()) 193 targetBaseFolder.mkdir(); 194 195 Vector<File> sources = new Vector<File>(); 196 File bsl = new File(sourceMod.getLocalPath(), "bsl"); 197 if (sourceMod.hasSeparatePlatformDirs()) { 198 File bslCommon = new File(bsl, "common"); 199 File bslMac = new File(bsl, "mac_only"); 200 File bslWin = new File(bsl, "win_only"); 201 if (Settings.getPlatform() == Platform.MACOS && bslMac.exists()) { 202 for (File f : bslMac.listFiles(dirFileFilter)) { 203 File targetBSL = new File(targetBaseFolder, f.getName()); 204 if (addon || !targetBSL.exists()) 205 sources.add(f); 206 } 207 } 208 if ((Settings.getPlatform() == Platform.WIN || Settings 209 .getPlatform() == Platform.LINUX) && bslWin.exists()) { 210 for (File f : bslWin.listFiles(dirFileFilter)) { 211 File targetBSL = new File(targetBaseFolder, f.getName()); 212 if (addon || !targetBSL.exists()) 213 sources.add(f); 214 } 215 } 216 if (bslCommon.exists()) { 217 for (File f : bslCommon.listFiles(dirFileFilter)) { 218 File targetBSL = new File(targetBaseFolder, f.getName()); 219 if (addon || !targetBSL.exists()) 220 sources.add(f); 221 } 222 } 223 } else { 224 for (File f : bsl.listFiles(dirFileFilter)) { 225 File targetBSL = new File(targetBaseFolder, f.getName()); 226 if (addon || !targetBSL.exists()) 227 sources.add(f); 228 } 229 } 230 231 System.out.println("For mod: " + sourceMod.getName() 232 + " install BSL folders: " + sources.toString()); 233 for (File f : sources) { 234 File targetPath = new File(targetBaseFolder, f.getName()); 235 if (!targetPath.exists()) 236 targetPath.mkdir(); 237 for (File fbsl : f.listFiles()) { 238 File targetFile = new File(targetPath, fbsl.getName()); 239 if (!targetFile.exists()) { 240 try { 241 FileUtils.copyFile(fbsl, targetFile); 242 } catch (IOException e) { 243 // TODO Auto-generated catch block 244 e.printStackTrace(); 245 } 246 } 247 } 248 } 144 249 } 145 250 … … 171 276 String s : levels.keySet()) 172 277 totalSteps++; 278 totalSteps++; 173 279 174 280 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); … … 202 308 203 309 log.println(); 310 stepsDone++; 204 311 } 205 312
Note:
See TracChangeset
for help on using the changeset viewer.