Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
Merge pull request #25 from Mgamerz/dev
Browse files Browse the repository at this point in the history
Mod Manager 4.4 Build 62
  • Loading branch information
Mgamerz committed Sep 27, 2016
2 parents 0e93f0a + 2fecb2a commit be4ac83
Show file tree
Hide file tree
Showing 41 changed files with 2,188 additions and 683 deletions.
Binary file added commons-io-2.5.jar
Binary file not shown.
Binary file added commons-lang3-3.4.jar
Binary file not shown.
Binary file added httpclient-4.5.2.jar
Binary file not shown.
Binary file added httpcore-4.4.5.jar
Binary file not shown.
53 changes: 46 additions & 7 deletions src/com/me3tweaks/modmanager/ASIModWindow.java
Expand Up @@ -57,6 +57,7 @@
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

import com.me3tweaks.modmanager.modupdater.ManifestModFile;
import com.me3tweaks.modmanager.objects.ASIMod;
import com.me3tweaks.modmanager.objects.ASIUpdateGroup;
import com.me3tweaks.modmanager.objects.InstalledASIMod;
Expand Down Expand Up @@ -105,7 +106,7 @@ private void setupWindow() {
setPreferredSize(new Dimension(800, 600));
setMinimumSize(new Dimension(300, 200));
loadLocalManifest(true);
loadInstalledASIMods();
installedASIs = loadInstalledASIMods(asiDir);

ArrayList<ASIMod> latestASIs = getLatestASIs();

Expand Down Expand Up @@ -164,7 +165,7 @@ public void actionPerformed(ActionEvent e) {
//String filepath = ModManager.appendSlash(asiDir.getAbsolutePath()) + asifile;
Object[] row = new Object[3];
row[COL_ASIFILENAME] = mod;
row[COL_DESCRIPTION] = "Manually installed ASI. This ASI has not been verified by ME3Tweaks. If you wish to have it verifed, please visit the forums.";
row[COL_DESCRIPTION] = "Manually installed ASI. This ASI has not been verified by ME3Tweaks. If you wish to have it verified, please visit the forums.";
row[COL_ACTION] = "<html><center>Manually Installed</center></html>";
model.addRow(row);
}
Expand Down Expand Up @@ -270,15 +271,15 @@ private InstalledASIMod findOutdatedInstalledModByManifestMod(ASIMod mod) {
return null;
}

private void loadInstalledASIMods() {
private static ArrayList<InstalledASIMod> loadInstalledASIMods(File asiDir) {
String[] installedASIfiles = asiDir.list(new FilenameFilter() {
@Override
public boolean accept(File current, String name) {
return name.endsWith(".asi");
}
});

installedASIs = new ArrayList<>();
ArrayList<InstalledASIMod> installedASIs = new ArrayList<>();
for (String installed : installedASIfiles) {
InstalledASIMod iam = new InstalledASIMod();
iam.setInstalledPath(ModManager.appendSlash(asiDir.getAbsolutePath()) + installed);
Expand All @@ -291,6 +292,8 @@ public boolean accept(File current, String name) {
ModManager.debugLogger.writeErrorWithException("ASI mod is installed but unable to get hash: " + installed, e1);
}
}

return installedASIs;
}

/**
Expand Down Expand Up @@ -554,6 +557,10 @@ public void actionPerformed(ActionEvent e) {

@Override
public void actionPerformed(ActionEvent e) {
if (ModManager.isMassEffect3Running()) {
JOptionPane.showMessageDialog(ModManagerWindow.ACTIVE_WINDOW, "Mass Effect 3 must be closed before you can install an ASI.","MassEffect3.exe is running", JOptionPane.ERROR_MESSAGE);
return;
}
new ASIModInstaller(mod).execute();
dispose();
}
Expand All @@ -563,6 +570,10 @@ public void actionPerformed(ActionEvent e) {

@Override
public void actionPerformed(ActionEvent e) {
if (ModManager.isMassEffect3Running()) {
JOptionPane.showMessageDialog(ModManagerWindow.ACTIVE_WINDOW, "Mass Effect 3 must be closed before you can uninstall an ASI.","MassEffect3.exe is running", JOptionPane.ERROR_MESSAGE);
return;
}
InstalledASIMod im = installedmod;
if (im == null) {
im = getInstalledModByHash(mod.getHash());
Expand Down Expand Up @@ -602,7 +613,7 @@ public void actionPerformed(ActionEvent e) {
}
}
}
loadInstalledASIMods();
installedASIs = loadInstalledASIMods(asiDir);
dispose();
}
}
Expand Down Expand Up @@ -710,7 +721,7 @@ protected Integer doInBackground() throws Exception {
public void done() {
//TODO: RELOAD TABLE INFO?
try {
loadInstalledASIMods();
installedASIs = loadInstalledASIMods(asiDir);
int retval = get();
//OK
TableModel model = table.getModel();
Expand Down Expand Up @@ -754,7 +765,7 @@ public static boolean IsASIModGroupInstalled(int group) {
amw.asiDir.mkdirs();
}
amw.loadLocalManifest(true);
amw.loadInstalledASIMods();
amw.installedASIs = amw.loadInstalledASIMods(amw.asiDir);

ASIUpdateGroup ug = null;
for (ASIUpdateGroup g : amw.updategroups) {
Expand All @@ -777,4 +788,32 @@ public static boolean IsASIModGroupInstalled(int group) {
}
return false;
}

public static ArrayList<InstalledASIMod> getOutdatedASIMods(String biogamedir) {
ArrayList<InstalledASIMod> outdatedasi = new ArrayList<>();
ASIModWindow amw = new ASIModWindow();
amw.gamedir = new File(ModManagerWindow.ACTIVE_WINDOW.fieldBiogameDir.getText()).getParent();
String asidir = ModManager.appendSlash(amw.gamedir) + "Binaries/win32/asi";
amw.asiDir = new File(asidir);
if (!amw.asiDir.exists()) {
amw.asiDir.mkdirs();
}
amw.loadLocalManifest(true);
amw.installedASIs = loadInstalledASIMods(amw.asiDir);
ArrayList<ASIMod> latestASIs = amw.getLatestASIs();
ModManager.debugLogger.writeMessage("Looking for outdated versions of installed ASIs...");
for (int i = 0; i < latestASIs.size(); i++) {
ASIMod mod = latestASIs.get(i);
if (amw.getInstalledModByHash(mod.getHash()) == null) {
//check for it in the update group...
InstalledASIMod outdatedmod = amw.findOutdatedInstalledModByManifestMod(mod);
if (outdatedmod != null) {
ModManager.debugLogger.writeMessage("Found outdated ASI "+outdatedmod);
outdatedasi.add(outdatedmod);
}
}
}
ModManager.debugLogger.writeMessage("Outdated ASI check has completed.");
return outdatedasi;
}
}
20 changes: 16 additions & 4 deletions src/com/me3tweaks/modmanager/AutoTocWindow.java
Expand Up @@ -65,6 +65,10 @@ public class AutoTocWindow extends JDialog {
* @param biogameDir
*/
public AutoTocWindow(String biogameDir) {
if (ModManager.isMassEffect3Running()) {
JOptionPane.showMessageDialog(ModManagerWindow.ACTIVE_WINDOW, "Mass Effect 3 must be closed in order to run AutoTOC on it.","MassEffect3.exe is running", JOptionPane.ERROR_MESSAGE);
return;
}
setupWindow("Updating Basegame and DLC TOC files");
updatedGameTOCs = new HashMap<String, String>();
ModManager.debugLogger.writeMessage("===Starting AutoTOC. Mode: GAME-WIDE ===");
Expand Down Expand Up @@ -263,11 +267,15 @@ public Boolean call() throws Exception {
}

//break into batches
for (String addFile : job.addFiles) {
/* for (String addFile : job.addFiles) {
String filename = FilenameUtils.getName(addFile);
if (filename.equals("PCConsoleTOC.bin")) {
continue; //this doens't need updated.
}
if (!addFile.startsWith("/BIOGame/")) {
System.out.println(addFile);
continue;
}
modulePath = FilenameUtils.getFullPath(addFile);
tbd.addNameSizePair(filename, (new File(addFile)).length());
numJobsInCurrentBatch++;
Expand All @@ -276,7 +284,9 @@ public Boolean call() throws Exception {
tbd = new TocBatchDescriptor();
numJobsInCurrentBatch = 0;
}
}
}*/

//Autotoc once installed. Don't bother with add files otherwise

if (numJobsInCurrentBatch > 0) {
batchJobs.add(tbd); //enter last batch task
Expand All @@ -301,13 +311,12 @@ public Boolean call() throws Exception {
}
String[] command = commandBuilder.toArray(new String[commandBuilder.size()]);

ModManager.debugLogger.writeMessage("["+job.getJobName()+"]Performing a batch TOC update on the following files:");
String str = "";
for (SimpleEntry<String, Long> nsp : batchJob.getNameSizePairs()) {
str += nsp.getKey() + " " + nsp.getValue();
str += "\n";
}
ModManager.debugLogger.writeMessage(str);
ModManager.debugLogger.writeMessage("["+job.getJobName()+"]Performing a batch TOC update on the following files:\n"+str);

int returncode = 1;
ProcessBuilder pb = new ProcessBuilder(command);
Expand All @@ -327,6 +336,9 @@ public Boolean call() throws Exception {
}
return true;
}
if (job.getFilesToReplace().size() == 0) {
return true;
}

return false;
}
Expand Down

0 comments on commit be4ac83

Please sign in to comment.