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

Add tile data editor GUI #231

Merged
merged 28 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5f284b8
chore: boilerplate for qt6 application
NoxHarmonium Jun 19, 2024
d7001da
chore: add some example art to use to test tiledit
NoxHarmonium Jun 20, 2024
e75c97d
feat(tiledit): can now open a source file and it is displayed
NoxHarmonium Jun 20, 2024
9b5910b
feat(tiledit): add conversion to/from SIRC image format
NoxHarmonium Jun 20, 2024
2c627bf
feat(tiledit): show palette in UI
NoxHarmonium Jun 20, 2024
315b11a
chore(tiledit): disable clang-tidy rule
NoxHarmonium Jun 20, 2024
55ac2c0
refactor(tiledit): do some minor code cleanup
NoxHarmonium Jun 20, 2024
41deeb5
build: add build job for tiledit
NoxHarmonium Jun 20, 2024
2ac1bda
refactor(tiledit): cleanup remaining clang-tidy warnings
NoxHarmonium Jun 20, 2024
46c6258
refactor(tiledit): give imageprocessor a better name
NoxHarmonium Jun 20, 2024
e5f8d3e
feat(tiledit): add palette reduction combo box
NoxHarmonium Jun 20, 2024
1c7a730
feat(tiledit): add quantizer boilerplate
NoxHarmonium Jun 21, 2024
3fa8733
feat(tiledit): got rough quantizer working
NoxHarmonium Jun 21, 2024
b26f5fb
feat(tiledit): fix max bucket size for non powers of two
NoxHarmonium Jun 21, 2024
9959b57
docs(tiledit): add README.md
NoxHarmonium Jun 21, 2024
11df115
build(tiledit): meson-build action doesn't support subdirectories
NoxHarmonium Jun 21, 2024
5609748
build(tiledit): make sure meson version is specified
NoxHarmonium Jun 21, 2024
4305964
build(tiledit): Install QT as part of build
NoxHarmonium Jun 21, 2024
51b587d
build(tiledit): build and lint meson project
NoxHarmonium Jun 21, 2024
143e6a2
chore(tiledit): make linter happy by preventing unreachable
NoxHarmonium Jun 21, 2024
6e43448
build(tiledit): add missing cd
NoxHarmonium Jun 21, 2024
9593c97
build(tiledit): use clang for the CI build
NoxHarmonium Jun 21, 2024
e3a94db
build(tiledit): try to get up-to-date clang
NoxHarmonium Jun 21, 2024
641cf86
build(tiledit): try specific version suffixes
NoxHarmonium Jun 21, 2024
3e5fd2b
build(tiledit): force clang-format/clang-tidy versions
NoxHarmonium Jun 21, 2024
6d55450
build(tiledit): log versions
NoxHarmonium Jun 21, 2024
7914cc4
build(tiledit): try removing old LLVM first
NoxHarmonium Jun 21, 2024
134ea24
build(tiledit): try putting clang tools in path
NoxHarmonium Jun 21, 2024
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
66 changes: 66 additions & 0 deletions .github/workflows/sirc-tiledit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: SIRC Tiledit

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

defaults:
run:
working-directory: ./sirc-tiledit

# Source: https://github.com/mesonbuild/meson/blob/master/docs/markdown/Continuous-Integration.md

jobs:
build:
name: Build and Test on ${{ matrix.os }} with Meson v${{ matrix.meson_version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
# TODO: Get version from .tool-versions?
meson_version: ["1.4.1"]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Remove old LLVM
run: |
sudo apt-get purge clang-format-14 clang-tidy-14 clang-tools-14 clang-14 clangd-14 libc++1-14 libc++abi1-14 libclang1-14 libomp5-14 lld-14 lldb-14 llvm-14 python3-clang-14
- name: Install up-to-date LLVM
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 18 all
# TODO: Surely there is an easier way to set default version
ln -s $(which clang-tidy-18) /usr/local/bin/clang-tidy
ln -s $(which clang-format-18) /usr/local/bin/clang-format
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: 6.6.*
- name: Install python based dependencies
run: python -m pip install meson==${{ matrix.meson_version }} ninja
- name: Configure Project
run: >
meson setup build/
env:
CC: clang-18
CXX: clang++-18
- name: Compile Project
run: |
cd build
meson compile
- name: Lint Project
run: |
cd build
clang-tidy --version
ninja clang-tidy
clang-format --version
ninja clang-format-check
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Rust
name: SIRC VM

on:
push:
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions sirc-tiledit/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# see https://clang.llvm.org/docs/ClangFormatStyleOptions.html
---
BasedOnStyle: LLVM
Language: Cpp
Standard: c++17
6 changes: 6 additions & 0 deletions sirc-tiledit/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,cppcoreguidelines-*,modernize-*,-modernize-use-trailing-return-type,-cppcoreguidelines-owning-memory,-cppcoreguidelines-pro-type-vararg'
FormatStyle: llvm

# cppcoreguidelines-owning-memory is disabled because it doesn't really fit with the memory model of QT where the caller doesn't own the widget
# cppcoreguidelines-pro-type-vararg can be useful sometimes, I'll try to use it sparingly
63 changes: 63 additions & 0 deletions sirc-tiledit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Created by https://www.toptal.com/developers/gitignore/api/meson,c++
# Edit at https://www.toptal.com/developers/gitignore?templates=meson,c++

### C++ ###
# Prerequisites
*.d

# Compiled Object files
*.slo
*.lo
*.o
*.obj

# Precompiled Headers
*.gch
*.pch

# Compiled Dynamic libraries
*.so
*.dylib
*.dll

# Fortran module files
*.mod
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib

# Executables
*.exe
*.out
*.app

### Meson ###
# subproject directories
/subprojects/*
!/subprojects/*.wrap

# Meson Directories
meson-logs
meson-private
build

# Meson Files
meson_benchmark_setup.dat
meson_test_setup.dat
sanitycheckcpp.cc # C++ specific
sanitycheckcpp.exe # C++ specific

# Ninja
build.ninja
.ninja_deps
.ninja_logs

# Misc
compile_commands.json


# End of https://www.toptal.com/developers/gitignore/api/meson,c++
18 changes: 18 additions & 0 deletions sirc-tiledit/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "linux-gcc-x64",
"includePath": [
"${workspaceFolder}/**"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "${default}",
"cppStandard": "${default}",
"intelliSenseMode": "linux-gcc-x64",
"compilerArgs": [
""
]
}
],
"version": 4
}
24 changes: 24 additions & 0 deletions sirc-tiledit/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "C/C++ Runner: Debug Session",
"type": "cppdbg",
"request": "launch",
"args": [],
"stopAtEntry": false,
"externalConsole": false,
"cwd": "/var/home/seandawson/Development/Personal/sirc/tiledit/src",
"program": "/var/home/seandawson/Development/Personal/sirc/tiledit/src/build/Debug/outDebug",
"MIMode": "gdb",
"miDebuggerPath": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
59 changes: 59 additions & 0 deletions sirc-tiledit/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"C_Cpp_Runner.cCompilerPath": "gcc",
"C_Cpp_Runner.cppCompilerPath": "g++",
"C_Cpp_Runner.debuggerPath": "gdb",
"C_Cpp_Runner.cStandard": "",
"C_Cpp_Runner.cppStandard": "",
"C_Cpp_Runner.msvcBatchPath": "",
"C_Cpp_Runner.useMsvc": false,
"C_Cpp_Runner.warnings": [
"-Wall",
"-Wextra",
"-Wpedantic",
"-Wshadow",
"-Wformat=2",
"-Wcast-align",
"-Wconversion",
"-Wsign-conversion",
"-Wnull-dereference"
],
"C_Cpp_Runner.msvcWarnings": [
"/W4",
"/permissive-",
"/w14242",
"/w14287",
"/w14296",
"/w14311",
"/w14826",
"/w44062",
"/w44242",
"/w14905",
"/w14906",
"/w14263",
"/w44265",
"/w14928"
],
"C_Cpp_Runner.enableWarnings": true,
"C_Cpp_Runner.warningsAsError": false,
"C_Cpp_Runner.compilerArgs": [],
"C_Cpp_Runner.linkerArgs": [],
"C_Cpp_Runner.includePaths": [],
"C_Cpp_Runner.includeSearch": [
"*",
"**/*"
],
"C_Cpp_Runner.excludeSearch": [
"**/build",
"**/build/**",
"**/.*",
"**/.*/**",
"**/.vscode",
"**/.vscode/**"
],
"C_Cpp_Runner.useAddressSanitizer": false,
"C_Cpp_Runner.useUndefinedSanitizer": false,
"C_Cpp_Runner.useLeakSanitizer": false,
"C_Cpp_Runner.showCompilationTime": false,
"C_Cpp_Runner.useLinkTimeOptimization": false,
"C_Cpp_Runner.msvcSecureNoWarnings": false
}
25 changes: 25 additions & 0 deletions sirc-tiledit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SIRC Tiledit

A QT based GUI for manipulating tile data.

## Building

I've been using Qt Creator to work on this project
but it should be able to work in other IDEs that
support clangd (although you wouldn't get the
UI editor)

```
$ meson setup build
$ cd build
$ meson compile
$ meson test
```

# Roadmap

- [x] Get a boilerplate QT app running
- [x] Get some quantization working to reduce palette size for tile data
- [ ] Export tile data as assembly files for import into projects
- [ ] Manage tilemap data
- [ ] Manage sprite data
26 changes: 26 additions & 0 deletions sirc-tiledit/include/aboutdialog.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef ABOUTDIALOG_H
#define ABOUTDIALOG_H

#include <QDialog>

namespace Ui {
class AboutDialog;
}

class AboutDialog : public QDialog {
Q_OBJECT

public:
explicit AboutDialog(QWidget *parent = nullptr);
~AboutDialog() override;

AboutDialog(const AboutDialog &) = delete;
AboutDialog &operator=(const AboutDialog &) = delete;
AboutDialog(AboutDialog &&) noexcept = delete;
AboutDialog &operator=(AboutDialog &&) noexcept = delete;

private:
Ui::AboutDialog *ui;
};

#endif // ABOUTDIALOG_H
48 changes: 48 additions & 0 deletions sirc-tiledit/include/mainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "quantizer.h"
#include "sircimage.h"
#include <QMainWindow>

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow {
Q_OBJECT

public:
MainWindow(QWidget *parent = nullptr);
~MainWindow() override;

MainWindow(const MainWindow &) = delete;
MainWindow &operator=(const MainWindow &) = delete;
MainWindow(MainWindow &&) noexcept = delete;
MainWindow &operator=(MainWindow &&) noexcept = delete;

protected:
#ifndef QT_NO_CONTEXTMENU
void contextMenuEvent(QContextMenuEvent *event) override;
#endif // QT_NO_CONTEXTMENU

private slots:
// Menu Actions
void on_actionOpen_triggered();
void on_actionAbout_triggered();

private:
[[nodiscard]] PaletteReductionBpp getPaletteReductionBpp() const;

// UI Setup
void setupPaletteReductionOptions();
void setupSourceImageView(const QPixmap &scaledPixmap);
void setupTargetImageView(const SircImage &imageProcessor);
void setupPaletteView(const SircImage &imageProcessor);

Ui::MainWindow *ui;
QString openedSourceFilename;
};
#endif // MAINWINDOW_H
22 changes: 22 additions & 0 deletions sirc-tiledit/include/mediancutquantizer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef MEDIANCUTQUANTIZER_H
#define MEDIANCUTQUANTIZER_H

#include "quantizer.h"

/**
* @brief A simple quantizer that can only reduce the palette in multiples of
* two
*
* @see
* https://gowtham000.hashnode.dev/median-cut-a-popular-colour-quantization-strategy
*/
class MedianCutQuantizer : public Quantizer {
public:
MedianCutQuantizer() = default;

[[nodiscard]] SircImage
quantize(const SircImage &sircImage,
const PaletteReductionBpp bpp) const override;
};

#endif // MEDIANCUTQUANTIZER_H
Loading