private List<SFontStyle> loadFontStylesFromResourceList(List<SResource> files) { FontStyleXMLAnalyzer analyzer = new FontStyleXMLAnalyzer(); for (SResource res : files) { try { SFile f = (SFile) res; MpqFile mpqFile = new MpqFile(f.getMpqFilePath()); MpqEntry mpqEntry = mpqFile.getEntry(f.getFilePath()); InputStream is = mpqFile.getInputStream(mpqEntry); analyzer.analyze(is); } catch (Exception e) { } } return analyzer.getStyles(); }
private void loadList() { List<SFile> files = new ArrayList<SFile>(); List<String> mpqStrings = App.getApp().getPreferences().getArrayString("options.path.mpq.list", null); if (mpqStrings == null) return; List<MpqFile> mpqFiles = new ArrayList<MpqFile>(); for (int i = 0; i < mpqStrings.size(); i++) { try { MpqFile mpq = new MpqFile(mpqStrings.get(i)); Iterator<MpqEntry> it = mpq.iterator(); while (it.hasNext()) { String fileName = it.next().getName(); if (fileName != null) files.add(new SFile(mpqStrings.get(i), fileName)); } } catch (Exception e) { } } // Now send lists to good ones. List<SResource> listForTab0 = new ArrayList<SResource>(); List<SResource> listForTab1 = new ArrayList<SResource>(); List<SResource> listForTab2 = new ArrayList<SResource>(); List<SResource> listForTab3 = new ArrayList<SResource>(); List<SResource> listForTab4 = new ArrayList<SResource>(); for (SFile file : files) { if (file.getFilePath().endsWith(".otf") || file.getFilePath().endsWith(".ttf")) listForTab0.add(file); if (file.getFilePath().endsWith(".dds") || file.getFilePath().endsWith(".tga")) listForTab1.add(file); if (file.getFilePath().endsWith(".xml")) listForTab2.add(file); if (file.getFilePath().endsWith(".SC2Style")) listForTab3.add(file); if (!listForTab0.contains(file) && !listForTab1.contains(file) && !listForTab2.contains(file) && !listForTab3.contains(file)) listForTab4.add(file); } // Populate tabs mTab0.sendResources(listForTab0); mTab1.sendResources(listForTab1); mTab2.sendResources(listForTab2); mTab3.sendResources(listForTab3); mTab4.sendResources(listForTab4); // The third tab is a font style type, we must get the styles. List<SResource> fontStyles = new ArrayList<SResource>(); fontStyles.addAll(loadFontStylesFromResourceList(listForTab3)); // for (SResource res : fontStyles) // System.out.println(res.toString()); mTab3.sendResources(fontStyles); }