Skip to content

Commit

Permalink
Added workaround for cultures 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Nithanim committed Oct 1, 2022
1 parent 5b44827 commit 87ee0c4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ public class Test {
public static void main(String[] args) throws IOException {
Path p = Paths.get(
"/mount/data/games/weltwunder/dosdevices/c:/GOG Games/8th Wonder of the World/DataX/Libs/data0001.lib");
ReadableLibFile lib = new ReadableLibFile(p);
ReadableLibFile lib = new ReadableLibFile(p, LibFormat.CULTURES2);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ public class ReadableLibFile implements AutoCloseable {
private final SeekableByteChannel channel;
private final LibFileDirectory root;

public ReadableLibFile(Path p) throws IOException {
this(Files.newByteChannel(p));
public ReadableLibFile(Path p, LibFormat libFormat) throws IOException {
this(Files.newByteChannel(p), libFormat);
}

public ReadableLibFile(SeekableByteChannel channel) throws IOException {
public ReadableLibFile(SeekableByteChannel channel, LibFormat libFormat) throws IOException {
this.channel = channel;
this.root = new LibFileDirectory(null);
LibFileInfo metas =
LibFileUtil.read(
new NonClosableInputStream(Channels.newInputStream(channel)), LibFormat.CULTURES2);
LibFileUtil.read(new NonClosableInputStream(Channels.newInputStream(channel)), libFormat);
initTree(metas);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import lombok.SneakyThrows;
import me.nithanim.cultures.format.cif.CifFile;
import me.nithanim.cultures.format.cif.CifFileUtil;
import me.nithanim.cultures.format.lib.LibFormat;
import me.nithanim.cultures.format.lib.io.reading.ReadableLibFile;
import me.nithanim.cultures.multitool.helper.FileTreeBuilder;
import me.nithanim.cultures.multitool.helper.FolderTreeBuilder;
Expand All @@ -46,6 +47,7 @@ public class MainController implements Initializable {
@FXML private TreeView<TreeData> fileTree;
@FXML private VBox viewerPane;
@FXML private CheckBox chbBmdView;
@FXML private CheckBox chbCulturesOneWorkaround;

@SneakyThrows
@Override
Expand Down Expand Up @@ -110,7 +112,10 @@ private void readAndUseFolder(Path p) throws IOException {

private void readAndUseFileLib(Path p) throws IOException {
SeekableByteChannel channel = Files.newByteChannel(p);
ReadableLibFile lib = new ReadableLibFile(channel);
ReadableLibFile lib =
new ReadableLibFile(
channel,
chbCulturesOneWorkaround.isSelected() ? LibFormat.CULTURES1 : LibFormat.CULTURES2);

fileTree.setShowRoot(false);
fileTree.setRoot(FileTreeBuilder.buildTree("", lib.getRoot()));
Expand Down
15 changes: 10 additions & 5 deletions gui/src/main/resources/fxml/main.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@
<Button fx:id="btnFileReload" mnemonicParsing="false" text="Reload" />
</children>
</HBox>
<CheckBox fx:id="chbBmdView" mnemonicParsing="false" text="Bmd view">
<VBox.margin>
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
</VBox.margin>
</CheckBox>
<HBox>
<children>
<CheckBox fx:id="chbBmdView" mnemonicParsing="false" text="Bmd view" />
<CheckBox fx:id="chbCulturesOneWorkaround" mnemonicParsing="false" text="Cultures 1 workaround (must be enabled before opening!))">
<HBox.margin>
<Insets left="20.0" />
</HBox.margin>
</CheckBox>
</children>
</HBox>
</children>
</VBox>
</top>
Expand Down

0 comments on commit 87ee0c4

Please sign in to comment.