Wumads now use the same scheme/base as the wuds

This commit is contained in:
Maschell 2019-06-04 12:14:30 +02:00
parent 0132848dae
commit 4f95745f5b
3 changed files with 78 additions and 74 deletions

View File

@ -3,97 +3,48 @@ package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional; import java.util.Optional;
import de.mas.wiiu.jnus.NUSTitle; import de.mas.wiiu.jnus.WumadLoader;
import de.mas.wiiu.jnus.NUSTitleLoaderFST;
import de.mas.wiiu.jnus.NUSTitleLoaderWumad;
import de.mas.wiiu.jnus.entities.fst.FSTEntry;
import de.mas.wiiu.jnus.fuse_wiiu.Settings; import de.mas.wiiu.jnus.fuse_wiiu.Settings;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory; import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory;
import de.mas.wiiu.jnus.implementations.FSTDataProviderNUSTitle; import de.mas.wiiu.jnus.implementations.wud.wumad.WumadInfo;
import de.mas.wiiu.jnus.implementations.wud.wumad.WumadParser;
import de.mas.wiiu.jnus.interfaces.FSTDataProvider; import de.mas.wiiu.jnus.interfaces.FSTDataProvider;
import de.mas.wiiu.jnus.utils.FSTUtils;
public class WUMADFuseContainer extends GroupFuseContainer { public class WUMADFuseContainer extends PartitionFuseContainer<WumadInfo> {
private final File file;
public WUMADFuseContainer(Optional<FuseDirectory> parent, File c) { public WUMADFuseContainer(Optional<FuseDirectory> parent, File c) {
super(parent); super(parent, c);
this.file = c;
} }
@Override @Override
protected void doInit() { protected Optional<WumadInfo> loadInfo(File input) {
if (input != null && input.exists()) {
FSTDataProvider dp;
try { try {
dp = new FSTDataProviderNUSTitle(getNUSTitle()); return Optional.of(WumadParser.createWumadInfo(input));
this.addFuseContainer("[EMULATED] [P01]", new FSTDataProviderContainer(Optional.of(this), () -> {
try {
return dp;
} catch (Exception e1) {
e1.printStackTrace();
return null;
}
}));
GroupFuseContainer children = new GroupFuseContainerDefault(Optional.of(this));
this.addFuseContainer("[EMULATED] [P01] [EXTRA] ", children);
for (FSTEntry tmd : FSTUtils.getFSTEntriesByRegEx(dp.getRoot(), ".*tmd")) {
Optional<FSTEntry> parentOpt = tmd.getParent();
if (parentOpt.isPresent()) {
FSTEntry parent = parentOpt.get();
if (parent.getFileChildren().stream().filter(f -> f.getFilename().endsWith(".app")).findAny().isPresent()) {
FSTDataProvider fdp = null;
try {
fdp = new FSTDataProviderNUSTitle(NUSTitleLoaderFST.loadNUSTitle(dp, parent, Settings.retailCommonKey));
} catch (IOException | ParseException e) {
try {
fdp = new FSTDataProviderNUSTitle(NUSTitleLoaderFST.loadNUSTitle(dp, parent, Settings.devCommonKey));
} catch (Exception e1) {
System.out.println("Ignoring " + parent.getFilename() + " :" + e1.getClass().getName() + " " + e1.getMessage());
continue;
}
} catch (Exception e) {
System.out.println("Ignoring " + parent.getFilename() + " :" + e.getClass().getName() + " " + e.getMessage());
continue;
}
FSTDataProvider fdpCpy = fdp;
children.addFuseContainer("[P01] [DECRYPTED] [" + dp.getName() + "] " + parent.getFilename(),
new FSTDataProviderContainer(getParent(), fdpCpy));
}
}
}
} catch (IOException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
} catch (ParseException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
}
private NUSTitle getNUSTitle() throws IOException, ParseException {
NUSTitle t = null;
try {
try {
t = NUSTitleLoaderWumad.loadNUSTitle(file, Settings.retailCommonKey);
} catch (ParseException e) {
t = NUSTitleLoaderWumad.loadNUSTitle(file, Settings.devCommonKey);
}
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
System.out.println("Ignoring " + file.getAbsolutePath() + " :" + e.getClass().getName() + " " + e.getMessage()); }
}
return Optional.empty();
} }
return t; @Override
protected List<FSTDataProvider> getDataProvider(WumadInfo info) {
List<FSTDataProvider> dps = new ArrayList<>();
try {
dps = WumadLoader.getPartitonsAsFSTDataProvider(info, Settings.retailCommonKey);
} catch (Exception e) {
try {
dps = WumadLoader.getPartitonsAsFSTDataProvider(info, Settings.devCommonKey);
} catch (IOException | ParseException e1) {
return dps;
}
}
return dps;
} }
} }

View File

@ -0,0 +1,50 @@
package de.mas.wiiu.jnus.fuse_wiiu.implementation;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import de.mas.wiiu.jnus.WumadLoader;
import de.mas.wiiu.jnus.fuse_wiiu.Settings;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory;
import de.mas.wiiu.jnus.implementations.wud.wumad.WumadInfo;
import de.mas.wiiu.jnus.implementations.wud.wumad.WumadParser;
import de.mas.wiiu.jnus.interfaces.FSTDataProvider;
public class WUMADMountedFuseContainer extends RecursivePartitionFuseContainer<WumadInfo> {
public WUMADMountedFuseContainer(Optional<FuseDirectory> parent, File c) {
super(parent, c);
}
@Override
protected Optional<WumadInfo> loadInfo(File input) {
if (input != null && input.exists()) {
try {
return Optional.of(WumadParser.createWumadInfo(input));
} catch (Exception e) {
e.printStackTrace();
}
}
return Optional.empty();
}
@Override
protected List<FSTDataProvider> getDataProvider(WumadInfo info) {
List<FSTDataProvider> dps = new ArrayList<>();
try {
dps = WumadLoader.getPartitonsAsFSTDataProvider(info, Settings.retailCommonKey);
} catch (Exception e) {
try {
dps = WumadLoader.getPartitonsAsFSTDataProvider(info, Settings.devCommonKey);
} catch (IOException | ParseException e1) {
return dps;
}
}
return dps;
}
}

View File

@ -12,6 +12,7 @@ import de.mas.wiiu.jnus.fuse_wiiu.implementation.WUDFuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.WUDMountedFuseContainer; import de.mas.wiiu.jnus.fuse_wiiu.implementation.WUDMountedFuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.WUDToWUDContainer; import de.mas.wiiu.jnus.fuse_wiiu.implementation.WUDToWUDContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.WUMADFuseContainer; import de.mas.wiiu.jnus.fuse_wiiu.implementation.WUMADFuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.WUMADMountedFuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.implementation.WoomyNUSTitleContainer; import de.mas.wiiu.jnus.fuse_wiiu.implementation.WoomyNUSTitleContainer;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseContainer; import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseContainer;
import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory; import de.mas.wiiu.jnus.fuse_wiiu.interfaces.FuseDirectory;
@ -50,6 +51,8 @@ public class FuseContainerWrapper {
if (c.exists() && c.getName().endsWith(".wumad")) { if (c.exists() && c.getName().endsWith(".wumad")) {
result.put(prefix + c.getName(), new WUMADFuseContainer(parent, c)); result.put(prefix + c.getName(), new WUMADFuseContainer(parent, c));
result.put(prefix + "[EXTRA] " + c.getName(), new WUMADMountedFuseContainer(parent, c));
return result; return result;
} }