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

Export sheets adjusted specifically for Tiled #34

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.5.1 - 2021-
### Added
- New batch export dialog
- Support for Diablo and Hellfire level tiles batch export (compatible with Tiled)

### Changed
- Qt Framework updated to 6.2.1.

## 0.5.0 - 2021-08-12
### Added
- Color palette (PAL) write support.
- Color translation (TRN) write support.
- Multi-selection support in the palette widgets.
- Color editing in the palette widget.
- Translation editing in the palette widgets.
- Undo/redo support for color palette and color translation editing.
- "Show translated colors" display filter for color translations palette widgets.
- CEL level tiles can now be clicked to select the corresponding sub-tile.
- CEL level sub-tiles can now be clicked to select the corresponding frame.
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# Diablo 1 Graphics Tool
![GitHub](https://img.shields.io/github/license/savagesteel/d1-graphics-tool)
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/savagesteel/d1-graphics-tool?include_prereleases)
![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/downloads-pre/savagesteel/d1-graphics-tool/latest/total)
![GitHub](https://img.shields.io/github/license/savagesteel/d1-graphics-tool?style=flat-square)
[![GitHub release (latest by date including pre-releases)](https://img.shields.io/github/v/release/savagesteel/d1-graphics-tool?include_prereleases&style=flat-square)](https://github.com/savagesteel/d1-graphics-tool/releases)
![GitHub all releases](https://img.shields.io/github/downloads/savagesteel/d1-graphics-tool/total?style=flat-square)
[![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/savagesteel/d1-graphics-tool?style=flat-square)](https://www.codefactor.io/repository/github/savagesteel/d1-graphics-tool/overview)

Diablo 1 Graphics Tool can open CEL/CL2 graphics files and display them with chosen color palette (PAL) and color translation (TRN) files.
The tool now also supports PAL/TRN editing.

![Screenshot 1](/images/demo001.gif)

This tool is cross-platform, it can be compiled on Windows, Linux, or macOS (using Qt Framework 6.1.2).
This tool is cross-platform, it can be compiled on Windows, Linux, or macOS (using Qt Framework 6.2.1).
Go to the [releases page](https://github.com/savagesteel/d1-graphics-tool/releases) to download the latest build.

## Features
Expand All @@ -17,6 +18,7 @@ Go to the [releases page](https://github.com/savagesteel/d1-graphics-tool/releas
- PAL/TRN support (read/write).
- Palette hits and color translation hits display.
- Bitmap and PNG export in multiple files or tiled file.
- Batch export with Tiled compatibility for level tiles, objects and monsters.

## Acknowledgements
I would like to thank anyone who contributed to the development, bug reporting or testing of this tool.
47 changes: 34 additions & 13 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,50 @@
## TODO

### 0.5.0
1. Implement multi-color selection in palette widgets
2. Implement undo/redo stack
3. Show all colors when clicking "Pick" button
4. Warn about modified files before closing them
### 0.5.x
### Add

### 0.6.0
- Display hovered index and selection length in the informationLabel
- Index: x, Selection length: y
- Warn about modified files before closing them.

- Implement backup files (.bak) when editing PAL/TRN
- A copy of the PAL/TRN file is created automatically (e.g. redv.trn.bak)
- Only if it does not exist and only when saving
- Add setting to enable/disable the feature (enabled by default)

- Add export options for level tiles to be compatible with Tiled
- https://github.com/diasurgical/modding-tools/tree/master/Tiled
- Special tiles must be merged into the spritesheet (for the right tiles)
- Adjust line/column number
- Add export options for monsters compatible with Tiled
- https://github.com/sergi4ua/opensource-ami/blob/master/gen_monsters_tileset.sh
- https://github.com/diasurgical/modding-tools/blob/3620efe13a62792a5b02f107cda86d68d19f5cdf/Tiled/extensions/diablo-dun.js#L257
- Add export options for item
- https://github.com/sergi4ua/opensource-ami/blob/master/gen_objects_tileset.sh
- https://github.com/diasurgical/modding-tools/blob/3620efe13a62792a5b02f107cda86d68d19f5cdf/Tiled/extensions/diablo-dun.js#L330

- Add CI/CD with appimage build for Linux (and .msi for Windows?).
- Update PowerShell release script to take a Qt build folder as parameter.
- https://github.com/mapeditor/tiled/blob/master/.github/workflows/ubuntu-20.04.yml
- https://github.com/mapeditor/tiled/blob/master/.github/workflows/packages.yml


- Add CEL/CL2/PAL/TRN mappings in a JSON file for diablo and hellfire (retail version).
- Implement shadow selection when picking translation.

### Add
- Add settings
- Background color? (grey, green, magenta, cyan?)
- Default zoom level (depending on CEL/CL2 type?)
- By default: x2
- Automatic dezoom when opening a bigger image?
- PowerShell release script which takes a Qt build folder as parameter
- Application icon
- PCX support
- GIF support

### Change
- Include CEL/CL2 to TRN mapping in the program, especially for monsters.
- Remove CelView and LevelCelView dependencies from PalView by leveraging signals/slots.

- Remove .pcx and .gif from the open dialog until it is implemented.
- Rewrite level CEL frame type detection to leverage associated MIN file when available.
- Port to .NET 6??

### Fix

- File export for Linux
- Last color of PAL/TRN not displayed as transparent??
5 changes: 5 additions & 0 deletions source/D1GraphicsTool.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += main.cpp \
batchexportdialog.cpp \
d1palhits.cpp \
export.cpp \
mainwindow.cpp \
d1cel.cpp \
d1cl2.cpp \
Expand All @@ -39,12 +41,14 @@ SOURCES += main.cpp \
settingsdialog.cpp

HEADERS += mainwindow.h \
batchexportdialog.h \
d1cel.h \
d1cl2.h \
d1pal.h \
d1palhits.h \
d1trn.h \
celview.h \
export.h \
palettewidget.h \
d1min.h \
d1til.h \
Expand All @@ -54,6 +58,7 @@ HEADERS += mainwindow.h \
settingsdialog.h

FORMS += mainwindow.ui \
batchexportdialog.ui \
celview.ui \
palettewidget.ui \
levelcelview.ui \
Expand Down
147 changes: 147 additions & 0 deletions source/batchexportdialog.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#include "batchexportdialog.h"
#include "ui_batchexportdialog.h"

BatchExportDialog::BatchExportDialog(QJsonObject *config, QWidget *parent) :
QDialog(parent),
configuration(config),
ui(new Ui::BatchExportDialog)
{
ui->setupUi(this);
}

BatchExportDialog::~BatchExportDialog()
{
delete ui;
}

void BatchExportDialog::setInputFolder(QString path)
{
ui->inputFolderEdit->setText(path);
}

void BatchExportDialog::exportAllDiabloLevelTilesForTiled()
{
bool exportSuccess = true;
QString inputFolder = ui->inputFolderEdit->text();
QString outputFolder = ui->outputFolderEdit->text();

QImage tiles;
QString outputFilePath;

// Check if cel, special cel, min, til, pal files exist
if(!Export::checkLevelFilePaths(inputFolder,TOWN_FILE_PATHS)
|| !Export::checkLevelFilePaths(inputFolder,L1_FILE_PATHS)
|| !Export::checkLevelFilePaths(inputFolder,L2_FILE_PATHS)
|| !Export::checkLevelFilePaths(inputFolder,L3_FILE_PATHS)
|| !Export::checkLevelFilePaths(inputFolder,L4_FILE_PATHS))
{
QMessageBox::warning( this, "Warning", "Could not find some of the level files." );
return;
}

try
{
// TOWN
//tiles = Export::getAllLevelTilesWithSpecials(
// inputFolder, TOWN_FILE_PATHS, QList<quint16>(), QMap<quint16,QList<quint16>>());
//outputFilePath = outputFolder + "/" + TOWN_FILE_PATHS["png"];
//tiles.save(outputFilePath);

// L1
tiles = Export::getAllLevelTilesWithSpecials(
inputFolder, L1_FILE_PATHS, L1S_BLIT_SUBTILE_INDEXES, L1_TILES_BLIT_SPECIAL_INDEXES);
outputFilePath = outputFolder + "/" + L1_FILE_PATHS["png"];
tiles.save(outputFilePath);

// L2
//tiles = Export::getAllLevelTilesWithSpecials(
// inputFolder, L2_FILE_PATHS, L2S_BLIT_SUBTILE_INDEXES, L2_TILES_BLIT_SPECIAL_INDEXES);
//outputFilePath = outputFolder + "/" + L2_FILE_PATHS["png"];
//tiles.save(outputFilePath);

// L3
tiles = Export::getAllLevelTilesWithSpecials(
inputFolder, L3_FILE_PATHS, QList<quint16>(), QMap<quint16,QList<quint16>>());
outputFilePath = outputFolder + "/" + L3_FILE_PATHS["png"];
tiles.save(outputFilePath);

// L4
//tiles = Export::getAllLevelTilesWithSpecials(
// inputFolder, L4_FILE_PATHS, QList<quint16>(), QMap<quint16,QList<quint16>>());
//outputFilePath = outputFolder + "/" + L4_FILE_PATHS["png"];
//tiles.save(outputFilePath);
}
catch(...)
{
exportSuccess = false;
}

if( exportSuccess )
{
QMessageBox::information( this, "Information", "Export successful." );
this->close();
}
else
QMessageBox::critical( this, "Error", "Export Failed." );
}

void BatchExportDialog::exportAllHellfireLevelTilesForTiled()
{
QString inputFolder = ui->inputFolderEdit->text();
QString outputFolder = ui->outputFolderEdit->text();

// Check if cel, special cel, min, til, pal files exist
if(!Export::checkLevelFilePaths(inputFolder,TOWN_HELLFIRE_FILE_PATHS)
|| !Export::checkLevelFilePaths(inputFolder,L5_FILE_PATHS)
|| !Export::checkLevelFilePaths(inputFolder,L6_FILE_PATHS))
{
QMessageBox::warning( this, "Warning", "Could not find some of the level files." );
return;
}

}

void BatchExportDialog::on_inputFolderBrowseButton_clicked()
{
QString selectedFolder = QFileDialog::getExistingDirectory(
this, "Select Input Folder", QString(), QFileDialog::ShowDirsOnly );

ui->inputFolderEdit->setText( selectedFolder );
}

void BatchExportDialog::on_outputFolderBrowseButton_clicked()
{
QString selectedFolder = QFileDialog::getExistingDirectory(
this, "Select Output Folder", QString(), QFileDialog::ShowDirsOnly );

ui->outputFolderEdit->setText( selectedFolder );
}

void BatchExportDialog::on_batchExportButton_clicked()
{
if(ui->inputFolderEdit->text() == "")
{
QMessageBox::warning( this, "Warning", "Input folder is missing, please choose an input folder." );
return;
}

if(ui->outputFolderEdit->text() == "")
{
QMessageBox::warning( this, "Warning", "Output folder is missing, please choose an output folder." );
return;
}

// Check radio buttons
if(ui->exportAllDiabloLevelTilesRadioButton->isChecked())
exportAllDiabloLevelTilesForTiled();
else if(ui->exportAllHellfireLevelTilesRadioButton->isChecked())
exportAllHellfireLevelTilesForTiled();


}

void BatchExportDialog::on_batchExportCancelButton_clicked()
{
this->close();
}

40 changes: 40 additions & 0 deletions source/batchexportdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#ifndef BATCHEXPORTDIALOG_H
#define BATCHEXPORTDIALOG_H

#include <QDialog>
#include <QJsonObject>
#include <QFileDialog>
#include <QMessageBox>

#include "export.h"

namespace Ui {
class BatchExportDialog;
}

class BatchExportDialog : public QDialog
{
Q_OBJECT

public:
explicit BatchExportDialog(QJsonObject *configuration, QWidget *parent = nullptr);
~BatchExportDialog();

void setInputFolder(QString);

void exportAllDiabloLevelTilesForTiled();
void exportAllHellfireLevelTilesForTiled();

private slots:
void on_inputFolderBrowseButton_clicked();
void on_outputFolderBrowseButton_clicked();
void on_batchExportButton_clicked();
void on_batchExportCancelButton_clicked();

private:
QJsonObject *configuration;

Ui::BatchExportDialog *ui;
};

#endif // BATCHEXPORTDIALOG_H
Loading