- Timestamp:
- Jan 18, 2013, 4:45:11 PM (12 years ago)
- Location:
- AE/installer2/src/net/oni2/aeinstaller
- Files:
-
- 5 added
- 1 deleted
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
AE/installer2/src/net/oni2/aeinstaller/AEInstaller.properties
r630 r631 1 1 appname=AE Installer 2 2 appversion=0. 892 appversion=0.90 -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/Mod.java
r623 r631 216 216 } 217 217 218 private String getSanitizedPathName() { 219 return name.replaceAll("[^a-zA-Z0-9_.-]", "_"); 220 } 221 218 222 /** 219 223 * @return Path to local mod folder … … 233 237 } 234 238 235 return new File(Paths.getModsPath(), folderStart); 239 return new File(Paths.getModsPath(), folderStart 240 + getSanitizedPathName()); 236 241 } 237 242 … … 254 259 255 260 /** 261 * @return Is mod installed? 262 */ 263 public boolean isInstalled() { 264 return ModManager.getInstance().isModInstalled(this); 265 } 266 267 /** 256 268 * @return Name of mod 257 269 */ … … 376 388 return exeFile; 377 389 } 390 378 391 /** 379 392 * @return Icon file of this tool -
AE/installer2/src/net/oni2/aeinstaller/backend/mods/ModManager.java
r626 r631 334 334 * @return Is mod installed? 335 335 */ 336 publicboolean isModInstalled(Mod m) {336 boolean isModInstalled(Mod m) { 337 337 return currentlyInstalled.contains(m.getPackageNumber()); 338 338 } -
AE/installer2/src/net/oni2/aeinstaller/backend/oni/Installer.java
r625 r631 8 8 import java.io.FilenameFilter; 9 9 import java.io.IOException; 10 import java.io.InputStream; 10 11 import java.io.PrintWriter; 11 12 import java.text.SimpleDateFormat; … … 19 20 import java.util.Vector; 20 21 22 import net.oni2.aeinstaller.AEInstaller2; 21 23 import net.oni2.aeinstaller.backend.Paths; 22 24 import net.oni2.aeinstaller.backend.Settings; … … 244 246 combineBSLFolders(mods, listener); 245 247 246 if (Settings.getInstance().get("copyintro", false)) { 247 File src = new File(Paths.getVanillaGDF(), "intro.bik"); 248 if (src.exists()) { 249 try { 250 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF()); 251 } catch (IOException e) { 252 e.printStackTrace(); 253 } 254 } 255 } 256 if (Settings.getInstance().get("copyoutro", true)) { 257 File src = new File(Paths.getVanillaGDF(), "outro.bik"); 258 if (src.exists()) { 259 try { 260 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF()); 261 } catch (IOException e) { 262 e.printStackTrace(); 263 } 264 } 265 } 248 copyVideos(); 266 249 267 250 if (unlockLevels.size() > 0) { 268 File dat = new File(Paths.getEditionBasePath(), "persist.dat"); 269 if (dat.exists()) { 270 PersistDat save = new PersistDat(dat); 271 HashSet<Integer> currentlyUnlocked = save.getUnlockedLevels(); 272 currentlyUnlocked.addAll(unlockLevels); 273 save.setUnlockedLevels(currentlyUnlocked); 274 save.close(); 275 } else { 276 // TODO: what if persist.dat does not exist? 277 } 251 unlockLevels(unlockLevels); 278 252 } 279 253 } … … 445 419 } 446 420 421 private static void copyVideos() { 422 if (Settings.getInstance().get("copyintro", false)) { 423 File src = new File(Paths.getVanillaGDF(), "intro.bik"); 424 if (src.exists()) { 425 try { 426 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF()); 427 } catch (IOException e) { 428 e.printStackTrace(); 429 } 430 } 431 } 432 if (Settings.getInstance().get("copyoutro", true)) { 433 File src = new File(Paths.getVanillaGDF(), "outro.bik"); 434 if (src.exists()) { 435 try { 436 FileUtils.copyFileToDirectory(src, Paths.getEditionGDF()); 437 } catch (IOException e) { 438 e.printStackTrace(); 439 } 440 } 441 } 442 } 443 444 private static void unlockLevels(HashSet<Integer> unlockLevels) { 445 File dat = new File(Paths.getEditionBasePath(), "persist.dat"); 446 if (!dat.exists()) { 447 InputStream is = AEInstaller2.class.getResourceAsStream("/net/oni2/aeinstaller/resources/persist.dat"); 448 try { 449 FileUtils.copyInputStreamToFile(is, dat); 450 } catch (IOException e) { 451 // TODO Auto-generated catch block 452 e.printStackTrace(); 453 } 454 } 455 PersistDat save = new PersistDat(dat); 456 HashSet<Integer> currentlyUnlocked = save.getUnlockedLevels(); 457 currentlyUnlocked.addAll(unlockLevels); 458 save.setUnlockedLevels(currentlyUnlocked); 459 save.close(); 460 } 461 447 462 /** 448 463 * Initializes the Edition core -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.java
r630 r631 4 4 import java.awt.Desktop; 5 5 import java.awt.event.ActionEvent; 6 import java.awt.event.ActionListener;7 6 import java.awt.event.ItemEvent; 8 7 import java.awt.event.ItemListener; 9 import java.awt.event.MouseAdapter;10 import java.awt.event.MouseEvent;11 8 import java.io.File; 12 9 import java.io.IOException; 13 10 import java.net.URL; 14 import java.util.ArrayList;15 11 import java.util.HashMap; 16 12 import java.util.HashSet; 17 import java.util.List;18 13 import java.util.ResourceBundle; 19 14 import java.util.TreeMap; … … 27 22 import javax.swing.JCheckBox; 28 23 import javax.swing.JComboBox; 29 import javax.swing.JComponent;30 24 import javax.swing.JFileChooser; 31 25 import javax.swing.JFrame; … … 35 29 import javax.swing.JOptionPane; 36 30 import javax.swing.JPanel; 37 import javax.swing.JPopupMenu;38 31 import javax.swing.JRadioButton; 39 32 import javax.swing.JSplitPane; 40 import javax.swing.JTable;41 import javax.swing.ListSelectionModel;42 import javax.swing.RowSorter;43 import javax.swing.SortOrder;44 33 import javax.swing.SwingUtilities; 45 import javax.swing.event.ListSelectionEvent; 46 import javax.swing.event.ListSelectionListener; 34 import javax.swing.ToolTipManager; 47 35 import javax.swing.filechooser.FileFilter; 48 import javax.swing.table.TableRowSorter;49 36 50 37 import net.oni2.aeinstaller.AEInstaller2; … … 68 55 import net.oni2.aeinstaller.gui.downloadwindow.Downloader; 69 56 import net.oni2.aeinstaller.gui.modtable.DownloadSizeListener; 70 import net.oni2.aeinstaller.gui.modtable.Mod TableFilter;71 import net.oni2.aeinstaller.gui.modtable.ModTable Model;57 import net.oni2.aeinstaller.gui.modtable.ModSelectionListener; 58 import net.oni2.aeinstaller.gui.modtable.ModTable; 72 59 import net.oni2.aeinstaller.gui.settings.SettingsDialog; 73 60 import net.oni2.aeinstaller.gui.toolmanager.ToolManager; … … 84 71 */ 85 72 public class MainWin extends JFrame implements ApplicationListener, 86 DownloadSizeListener {73 DownloadSizeListener, ModSelectionListener { 87 74 private static final long serialVersionUID = -4027395051382659650L; 88 75 … … 103 90 private JRadioButton radOnline; 104 91 private JRadioButton radLocal; 105 private JTable tblMods; 106 private ModTableModel model; 107 private TableRowSorter<ModTableModel> sorter; 92 private ModTable tblMods; 108 93 private JLabel lblDownloadSizeVal; 109 94 … … 136 121 137 122 contents.setDividerLocation(400); 123 contents.setResizeWeight(0.4); 138 124 139 125 if (Settings.getPlatform() == Platform.MACOS) { 140 126 mainMenu.setVisible(false); 141 127 } 128 129 ToolTipManager.sharedInstance().setInitialDelay(250); 142 130 143 131 getRootPane().setDefaultButton(btnInstall); 144 132 lblDownloadSizeVal.setText(SizeFormatter.format(0, 2)); 145 133 radAll.setSelected(true); 134 135 tblMods.addModSelectionListener(this); 136 tblMods.addDownloadSizeListener(this); 146 137 } 147 138 … … 158 149 } 159 150 cmbModTypes.setSelectedIndex(0); 160 }161 162 private void initTable() {163 tblMods.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);164 tblMods.getSelectionModel().addListSelectionListener(165 new ListSelectionListener() {166 @Override167 public void valueChanged(ListSelectionEvent e) {168 int viewRow = tblMods.getSelectedRow();169 if (viewRow < 0) {170 modSelection(null);171 } else {172 int modelRow = tblMods173 .convertRowIndexToModel(viewRow);174 Mod mod = (Mod) model.getValueAt(modelRow, -1);175 modSelection(mod);176 }177 }178 });179 tblMods.addMouseListener(new MouseAdapter() {180 private void common(MouseEvent e) {181 int r = tblMods.rowAtPoint(e.getPoint());182 if (r >= 0 && r < tblMods.getRowCount())183 tblMods.setRowSelectionInterval(r, r);184 else185 tblMods.clearSelection();186 187 int rowindex = tblMods.getSelectedRow();188 if (rowindex >= 0) {189 if (e.isPopupTrigger()190 && e.getComponent() instanceof JTable) {191 int modelRow = tblMods.convertRowIndexToModel(rowindex);192 final Mod mod = (Mod) model.getValueAt(modelRow, -1);193 194 if (mod.isLocalAvailable()) {195 JPopupMenu popup = new JPopupMenu();196 JMenuItem openModFolder = new JMenuItem(bundle197 .getString("openModFolder.text"));198 openModFolder199 .addActionListener(new ActionListener() {200 @Override201 public void actionPerformed(202 ActionEvent arg0) {203 try {204 Desktop.getDesktop().open(205 mod.getLocalPath());206 } catch (IOException e) {207 e.printStackTrace();208 }209 }210 });211 popup.add(openModFolder);212 popup.show(e.getComponent(), e.getX(), e.getY());213 }214 }215 }216 }217 218 @Override219 public void mousePressed(MouseEvent e) {220 common(e);221 }222 223 @Override224 public void mouseReleased(MouseEvent e) {225 common(e);226 }227 });228 // To get checkbox-cells with background of row229 ((JComponent) tblMods.getDefaultRenderer(Boolean.class))230 .setOpaque(true);231 232 model = new ModTableModel();233 model.addDownloadSizeListener(this);234 235 tblMods.setModel(model);236 237 sorter = new TableRowSorter<ModTableModel>(model);238 tblMods.setRowSorter(sorter);239 240 sorter.setRowFilter(new ModTableFilter(null, 0));241 242 List<RowSorter.SortKey> sortKeys = new ArrayList<RowSorter.SortKey>();243 sortKeys.add(new RowSorter.SortKey(1, SortOrder.ASCENDING));244 sorter.setSortKeys(sortKeys);245 246 for (int i = 0; i < model.getColumnCount(); i++) {247 model.setColumnConstraints(i, tblMods.getColumnModel().getColumn(i));248 }249 151 } 250 152 … … 279 181 } 280 182 ModManager.getInstance().init(); 281 initTable();183 tblMods.reloadData(); 282 184 initModTypeBox(); 283 185 … … 430 332 if (res == JFileChooser.APPROVE_OPTION) { 431 333 if (fc.getSelectedFile().exists()) 432 model.reloadSelection(fc.getSelectedFile());334 tblMods.reloadSelection(fc.getSelectedFile()); 433 335 } 434 336 } … … 443 345 f = new File(f.getParentFile(), f.getName() + ".xml"); 444 346 ModManager.getInstance().saveModSelection(f, 445 model.getSelectedMods());347 tblMods.getSelectedMods()); 446 348 } 447 349 } … … 500 402 @SuppressWarnings("unused") 501 403 private void revertSelection() { 502 model.revertSelection();404 tblMods.revertSelection(); 503 405 } 504 406 … … 548 450 TreeSet<Mod> mods = new TreeSet<Mod>(); 549 451 mods.addAll(ModManager.getInstance().getMandatoryMods()); 550 mods.addAll( model.getSelectedMods());452 mods.addAll(tblMods.getSelectedMods()); 551 453 552 454 boolean instReady = false; … … 644 546 } 645 547 646 private void modSelection(Mod m) { 548 @Override 549 public void modSelectionChanged(ModTable source, Mod m) { 647 550 lblSubmitterVal.setText(""); 648 551 lblCreatorVal.setText(""); … … 678 581 if (radLocal.isSelected()) 679 582 downloadState = 2; 680 sorter.setRowFilter(new ModTableFilter(t, downloadState));583 tblMods.setFilter(t, downloadState); 681 584 } 682 585 -
AE/installer2/src/net/oni2/aeinstaller/gui/MainWin.yml
r630 r631 56 56 - ButtonGroup: [radAll,radOnline,radLocal] 57 57 - JScrollPane(name=scrollMods, vScrollBar=always, hScrollBar=never): 58 JTable(name=tblMods, visible=false)58 ModTable(name=tblMods, visible=false) 59 59 - JButton(name=btnRevertSelection, icon=img.undo16, text=btnRevertSelection.text, toolTipText=btnRevertSelection.tooltip, onAction=[revertSelection]) 60 60 - JButton(name=btnInstall, icon=img.install, text=btnInstall.text, toolTipText=btnInstall.tooltip, onAction=[install,installDone]) -
AE/installer2/src/net/oni2/aeinstaller/gui/modtable/ModTableModel.java
r630 r631 21 21 22 22 private ResourceBundle bundle = ResourceBundle 23 .getBundle("net.oni2.aeinstaller.localization." 24 + getClass().getSimpleName()); 23 .getBundle("net.oni2.aeinstaller.localization.ModTable"); 25 24 26 25 private Vector<Mod> items = new Vector<Mod>(); … … 33 32 */ 34 33 public ModTableModel() { 35 reloadData();36 34 } 37 35 … … 50 48 case 3: 51 49 return mod.getCreator(); 50 case 4: 51 String res = ""; 52 res += (install.get(row) ? "I" : "_"); 53 res += (mod.isLocalAvailable() && mod.isNewerAvailable() ? "U" 54 : "_"); 55 res += (mod.isLocalAvailable() ? "D" : "_"); 56 return res; 52 57 } 53 58 return null; … … 65 70 case 3: 66 71 return bundle.getString("mod.creator"); 72 case 4: 73 return bundle.getString("mod.state"); 67 74 } 68 75 return null; … … 76 83 @Override 77 84 public int getColumnCount() { 78 return 4;85 return 5; 79 86 } 80 87 … … 89 96 return String.class; 90 97 case 3: 98 return String.class; 99 case 4: 91 100 return String.class; 92 101 } … … 123 132 col.setPreferredWidth(90); 124 133 break; 134 case 4: 135 w = 55; 136 col.setPreferredWidth(w); 137 col.setMinWidth(w); 138 col.setMaxWidth(w); 139 break; 125 140 } 126 141 } … … 141 156 install.clear(); 142 157 for (int i = 0; i < items.size(); i++) { 143 install.add(i, ModManager.getInstance() 144 .isModInstalled(items.get(i))); 158 install.add(i, items.get(i).isInstalled()); 145 159 } 146 160 fireTableDataChanged(); -
AE/installer2/src/net/oni2/aeinstaller/localization/MainWin.properties
r630 r631 42 42 lblDownloadSize.text=Size of files to download: 43 43 44 openModFolder.text=Open mod folder45 46 44 lblSubmitter.text=Submitter: 47 45 lblCreator.text=Creator:
Note:
See TracChangeset
for help on using the changeset viewer.