source: AE/installer2/src/net/oni2/aeinstaller/backend/packages/Mod_Info.java@ 678

Last change on this file since 678 was 672, checked in by alloc, 12 years ago

AEI2 0.99q:

  • Updates dialog: Updating the to-download-size on (un)checking updates to download
  • Updates dialog: Show download size of individual updates
  • Tool execution: Support for .NET tools (Mod_Info.cfg added ExeType flag)
  • Depot backend: Ignore mod nodes with an empty package number field
File size: 5.7 KB
Line 
1package net.oni2.aeinstaller.backend.packages;
2
3import java.io.BufferedReader;
4import java.io.File;
5import java.io.FileInputStream;
6import java.io.FileNotFoundException;
7import java.io.IOException;
8import java.io.InputStreamReader;
9import java.util.HashSet;
10
11import net.oni2.aeinstaller.backend.Paths;
12
13/**
14 * @author Christian Illy
15 */
16public class Mod_Info {
17 private double aeVersion = 0;
18 private String name = "";
19 private String creator = "";
20 private EBSLInstallType bslInstallType = EBSLInstallType.NORMAL;
21 private String version = "";
22 private String description = "";
23
24 private HashSet<Integer> incompatibilities = new HashSet<Integer>();
25 private HashSet<Integer> dependencies = new HashSet<Integer>();
26 private HashSet<Integer> unlockLevel = new HashSet<Integer>();
27
28 private File exeFile = null;
29 private EExeType exeType = EExeType.OSBINARY;
30 private File iconFile = null;
31 private String workingDir = "Base";
32
33 /**
34 * @param f
35 * Mod_Info.cfg
36 * @param packageNumber
37 * Package number this Mod_Info belongs to
38 */
39 public Mod_Info(File f, int packageNumber) {
40 InputStreamReader isr = null;
41 try {
42 FileInputStream fstream = new FileInputStream(f);
43 isr = new InputStreamReader(fstream);
44 BufferedReader br = new BufferedReader(isr);
45 String strLine;
46 while ((strLine = br.readLine()) != null) {
47 if (strLine.indexOf("->") < 1)
48 continue;
49 int pos = strLine.indexOf("//");
50 while (pos >= 0) {
51 if ((pos < 6)
52 || !strLine.substring(pos - 5, pos).equals("http:")) {
53 strLine = strLine.substring(0, pos);
54 break;
55 } else {
56 pos = strLine.indexOf("//", pos + 1);
57 }
58 }
59 String[] split = strLine.split("->", 2);
60 String sName = split[0].trim();
61 String sVal = split[1].trim();
62 if (sName.equalsIgnoreCase("AEInstallVersion")) {
63 aeVersion = Double.parseDouble(sVal);
64 } else if (sName.equalsIgnoreCase("NameOfMod")) {
65 name = sVal;
66 } else if (sName.equalsIgnoreCase("Creator")) {
67 creator = sVal;
68 } else if (sName.equalsIgnoreCase("HasBsl")) {
69 if (sVal.equalsIgnoreCase("addon"))
70 bslInstallType = EBSLInstallType.ADDON;
71 } else if (sName.equalsIgnoreCase("ModVersion")) {
72 version = sVal;
73 } else if (sName.equalsIgnoreCase("Readme")) {
74 description = "<p>" + sVal.replaceAll("\\\\n", "<br>")
75 + "</p>";
76 } else if (sName.equalsIgnoreCase("DependsOn")) {
77 String[] depsS = sVal.split(",");
78 for (String s : depsS) {
79 try {
80 int dep = Integer.parseInt(s);
81 dependencies.add(dep);
82 } catch (NumberFormatException e) {
83 System.err
84 .format("Mod_Info of %05d does contain a non-number dependency: '%s'\n",
85 packageNumber, s);
86 }
87 }
88 } else if (sName.equalsIgnoreCase("IncompatibleWith")) {
89 String[] confS = sVal.split(",");
90 for (String s : confS) {
91 try {
92 int conf = Integer.parseInt(s);
93 incompatibilities.add(conf);
94 } catch (NumberFormatException e) {
95 System.err
96 .format("Mod_Info of %05d does contain a non-number incompatibility: '%s'\n",
97 packageNumber, s);
98 }
99 }
100 } else if (sName.equalsIgnoreCase("UnlockLevel")) {
101 String[] levelsS = sVal.split(",");
102 for (String s : levelsS) {
103 try {
104 int level = Integer.parseInt(s);
105 unlockLevel.add(level);
106 } catch (NumberFormatException e) {
107 System.err
108 .format("Mod_Info of %05d does contain a non-number UnlockLevel value: '%s'\n",
109 packageNumber, s);
110 }
111 }
112 } else if (sName.equalsIgnoreCase("ExeName")) {
113 exeFile = new File(Paths.getEditionBasePath(), sVal);
114 } else if (sName.equalsIgnoreCase("ExeType")) {
115 if (sVal.equalsIgnoreCase("OSBinary"))
116 exeType = EExeType.OSBINARY;
117 else if (sVal.equalsIgnoreCase("DotNet"))
118 exeType = EExeType.DOTNET;
119 else if (sVal.equalsIgnoreCase("Jar"))
120 exeType = EExeType.JAR;
121 } else if (sName.equalsIgnoreCase("WorkingDir")) {
122 workingDir = sVal;
123 } else if (sName.equalsIgnoreCase("IconName")) {
124 iconFile = new File(Paths.getEditionBasePath(), sVal);
125 }
126 }
127 if (exeFile != null) {
128 if (exeFile.getName().toLowerCase().endsWith(".jar"))
129 exeType = EExeType.JAR;
130 }
131 } catch (FileNotFoundException e) {
132 } catch (IOException e) {
133 e.printStackTrace();
134 } finally {
135 if (isr != null) {
136 try {
137 isr.close();
138 } catch (IOException e) {
139 // TODO Auto-generated catch block
140 e.printStackTrace();
141 }
142 }
143 }
144 }
145
146 /**
147 * @return the aeVersion
148 */
149 public double getAeVersion() {
150 return aeVersion;
151 }
152
153 /**
154 * @return the name
155 */
156 public String getName() {
157 return name;
158 }
159
160 /**
161 * @return the creator
162 */
163 public String getCreator() {
164 return creator;
165 }
166
167 /**
168 * @return the bslInstallType
169 */
170 public EBSLInstallType getBslInstallType() {
171 return bslInstallType;
172 }
173
174 /**
175 * @return the version
176 */
177 public String getVersion() {
178 return version;
179 }
180
181 /**
182 * @return the description
183 */
184 public String getDescription() {
185 return description;
186 }
187
188 /**
189 * @return the incompatibilities
190 */
191 public HashSet<Integer> getIncompatibilities() {
192 return incompatibilities;
193 }
194
195 /**
196 * @return the dependencies
197 */
198 public HashSet<Integer> getDependencies() {
199 return dependencies;
200 }
201
202 /**
203 * @return the unlockLevel
204 */
205 public HashSet<Integer> getUnlockLevel() {
206 return unlockLevel;
207 }
208
209 /**
210 * @return the exeFile
211 */
212 public File getExeFile() {
213 return exeFile;
214 }
215
216 /**
217 * @return the exeType
218 */
219 public EExeType getExeType() {
220 return exeType;
221 }
222
223 /**
224 * @return the iconFile
225 */
226 public File getIconFile() {
227 return iconFile;
228 }
229
230 /**
231 * @return the workingDir
232 */
233 public String getWorkingDir() {
234 return workingDir;
235 }
236
237}
Note: See TracBrowser for help on using the repository browser.