Skip to content

Commit

Permalink
Hexen II gfx.wad exported numbers
Browse files Browse the repository at this point in the history
DoomStruct doesn't properly support WAD2 formatted files, for now we'll export them as PNGs until support is added.
  • Loading branch information
Lemon-King committed Aug 2, 2024
1 parent 739ac52 commit 6701358
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 6 deletions.
Binary file added resources/pakdata/hexen2/gfx.wad/NUM_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/pakdata/hexen2/gfx.wad/NUM_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/pakdata/hexen2/gfx.wad/NUM_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/pakdata/hexen2/gfx.wad/NUM_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/pakdata/hexen2/gfx.wad/NUM_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/pakdata/hexen2/gfx.wad/NUM_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/pakdata/hexen2/gfx.wad/NUM_6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/pakdata/hexen2/gfx.wad/NUM_7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/pakdata/hexen2/gfx.wad/NUM_8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/pakdata/hexen2/gfx.wad/NUM_9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resources/pakdata/hexen2/gfx.wad/NUM_MINUS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions src/main/java/lemon/hxdd/builder/Hexen2Assets.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import lemon.hxdd.Application;
import lemon.hxdd.shared.Util;
import lemon.hxdd.shared.PAKTest;
import net.mtrop.doom.WadFile;
import net.mtrop.doom.graphics.Flat;
import net.mtrop.doom.graphics.PNGPicture;
import net.mtrop.doom.graphics.Palette;
import net.mtrop.doom.graphics.Picture;
import net.mtrop.doom.util.GraphicUtils;

import javax.imageio.ImageIO;
Expand Down Expand Up @@ -160,6 +162,63 @@ public void ExportMusic() {
}
}

public void ExportGFXWad(boolean useResources) {
if (useResources) {
this.app.controller.SetCurrentLabel("Extracting Hexen II gfx.wad data");

String pathTemp = this.app.settings.GetPath("temp");
String path = pathTemp + "/graphics/hexen2/gfx.wad/";
File dirFile = new File(path);
if (!dirFile.exists()) {
dirFile.mkdirs();
}
ZipAssets za = new ZipAssets(this.app);
za.SetFile(this.app.settings.fileResources);
za.ExtractFilesToFolder("pakdata/hexen2/gfx.wad", path);
return;
}

String pathSource = this.app.settings.GetPath("hexen2");
String pathTemp = this.app.settings.GetPath("temp");

this.app.controller.SetCurrentLabel("Exporting Hexen II gfx.wad data");
this.app.controller.SetCurrentProgress(-1);

String[] files = {
"NUM_0", "NUM_1", "NUM_2", "NUM_3", "NUM_4",
"NUM_5", "NUM_6", "NUM_7", "NUM_8", "NUM_9",
"NUM_MINUS"
};

float count = 0;
try {
WadFile wad = new WadFile(pathSource + "/gfx.wad");
for (int i = 0; i < files.length; i++) {
String entry = files[i];
byte[] data = wad.getData(entry);

Picture p = new Picture();
p.fromBytes(data);

Palette pal = GetHexen2Palette();
PNGPicture pngImg = GraphicUtils.createPNGImage(p, pal);

Color colorTarget = new Color(0, 0, 0, 255);
Color colorReplace = new Color(0, 0, 0, 0);
Image texture = replaceColor(pngImg.getImage(), colorTarget, colorReplace);
BufferedImage result = imageToBufferedImage(texture);

File out = new File(pathTemp + String.format("/graphics/HX2_%s.png", entry));
ImageIO.write(result, "PNG", out);

this.app.controller.SetCurrentProgress(++count / (float)files.length);
}
wad.close();
} catch (IOException e) {
e.printStackTrace();
}
}


public void ExportAssets() {
String Settings_PathHexen2 = this.app.settings.GetPath("hexen2");
Expand Down Expand Up @@ -240,6 +299,7 @@ public void ExportAssets() {
//options.add("-vertbones");
options.add("-nofmtexopt");
options.add("-vorder");
options.add("-edgewelder 0.5");
options.add("-smoothnorm \"180\"");
options.add("-texpre " + opt + "\"%s\"");
if (ModelEffect.get(shortName) != null) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/lemon/hxdd/builder/PackageBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public void Start() {
WriteHexen2InstallCVAR(ownedHX2);
Hexen2Assets h2a = new Hexen2Assets(this.app);
h2a.ExtractPakData();
h2a.ExportGFXWad(true);
h2a.ExportAssets();
h2a.ExportSounds();
h2a.ExportMusic();
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/lemon/hxdd/gui/MainViewController.java
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,7 @@ public void handle(ActionEvent actionEvent) {
}

protected void BindOpenFolderButton() {
String storedPath = this.mainApp.GetSettings().Get("PATH_GZDOOM");
if (storedPath.equals("")) {
storedPath = "./";
}

String finalStoredPath = storedPath;
String finalStoredPath = "./";
btnOpenFolder.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
Expand Down

0 comments on commit 6701358

Please sign in to comment.