Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gui): wad3 cleanup #181

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/cli/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ void pack(const argparse::ArgumentParser& cli, const std::string& inputPath) {
if (auto* vpk = dynamic_cast<VPK*>(packFile.get())) {
vpk->setChunkSize(preferredChunkSize);
}
} else if (type == "wad3") {
packFile = WAD3::create(outputPath);
}
if (!packFile) {
std::cerr << "Failed to create pack file!" << std::endl;
Expand Down Expand Up @@ -412,7 +414,7 @@ int main(int argc, const char* const* argv) {
cli.add_argument(ARG_P(TYPE))
.help("(Pack) The type of the output pack file.")
.default_value("vpk")
.choices("bmz", "fpx", "pak", "pck", "vpk_vtmb", "vpk", "zip")
.choices("bmz", "fpx", "pak", "pck", "vpk_vtmb", "vpk", "wad3", "zip")
.nargs(1);

cli.add_argument(ARG_L(NO_PROGRESS))
Expand Down
14 changes: 13 additions & 1 deletion src/gui/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ Window::Window(QWidget* parent)
this->createEmptyMenu->addAction(this->style()->standardIcon(QStyle::SP_FileIcon), "VPK", [this] {
this->newVPK(false);
});
this->createEmptyMenu->addAction(this->style()->standardIcon(QStyle::SP_FileIcon), "WAD3", [this] {
this->newWAD3(false);
});
this->createEmptyMenu->addAction(this->style()->standardIcon(QStyle::SP_FileIcon), "ZIP", [this] {
this->newZIP(false);
});
Expand All @@ -108,6 +111,9 @@ Window::Window(QWidget* parent)
this->createFromDirMenu->addAction(this->style()->standardIcon(QStyle::SP_FileIcon), "VPK", [this] {
this->newVPK(true);
});
this->createFromDirMenu->addAction(this->style()->standardIcon(QStyle::SP_FileIcon), "WAD3", [this] {
this->newWAD3(true);
});
this->createFromDirMenu->addAction(this->style()->standardIcon(QStyle::SP_FileIcon), "ZIP", [this] {
this->newZIP(true);
});
Expand Down Expand Up @@ -468,7 +474,7 @@ Window::Window(QWidget* parent)

template<PackFileType Type>
void newPackFile(Window* window, bool fromDirectory, const QString& startPath, const QString& name, const QString& extension) {
static_assert(Type == PackFileType::FPX || Type == PackFileType::PAK || Type == PackFileType::PCK || Type == PackFileType::VPK || Type == PackFileType::ZIP);
static_assert(Type == PackFileType::FPX || Type == PackFileType::PAK || Type == PackFileType::PCK || Type == PackFileType::VPK || Type == PackFileType::WAD3 || Type == PackFileType::ZIP);

if (window->isModified() && window->promptUserToKeepModifications()) {
return;
Expand Down Expand Up @@ -514,6 +520,8 @@ void newPackFile(Window* window, bool fromDirectory, const QString& startPath, c
if (auto* vpk = dynamic_cast<VPK*>(packFile.get())) {
vpk->setChunkSize(options->vpk_chunkSize);
}
} else if constexpr (Type == PackFileType::WAD3) {
packFile = WAD3::create(packFilePath.toLocal8Bit().constData());
} else if constexpr (Type == PackFileType::ZIP) {
packFile = ZIP::create(packFilePath.toLocal8Bit().constData());
} else {
Expand Down Expand Up @@ -605,6 +613,10 @@ void Window::newVPK(bool fromDirectory, const QString& startPath) {
return ::newPackFile<PackFileType::VPK>(this, fromDirectory, startPath, "VPK", ".vpk");
}

void Window::newWAD3(bool fromDirectory, const QString& startPath) {
return ::newPackFile<PackFileType::WAD3>(this, fromDirectory, startPath, "WAD3", ".wad");
}

void Window::newZIP(bool fromDirectory, const QString& startPath) {
return ::newPackFile<PackFileType::ZIP>(this, fromDirectory, startPath, "ZIP", ".zip");
}
Expand Down
2 changes: 2 additions & 0 deletions src/gui/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class Window : public QMainWindow {

void newVPK(bool fromDirectory, const QString& startPath = QString());

void newWAD3(bool fromDirectory, const QString& startPath = QString());

void newZIP(bool fromDirectory, const QString& startPath = QString());

void openDir(const QString& startPath = QString(), const QString& dirPath = QString());
Expand Down
8 changes: 6 additions & 2 deletions src/gui/previews/MDLPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,14 @@ void MDLPreview::setMesh(const QString& path, PackFile& packFile) const {
if (!mdlData || !vvdData || !vtxData) {
QString error{tr("Unable to find all the required files the model is composed of!") + '\n'};
if (!mdlData) {
error += "\n- " + basePath + ".mdl";
error += "\n- ";
error += basePath.c_str();
error += ".mdl";
}
if (!vvdData) {
error += "\n- " + basePath + ".vvd";
error += "\n- ";
error += basePath.c_str();
error += ".vvd";
}
if (!vtxData) {
error += "\n- " + tr("One of the following:") +
Expand Down