Skip to content

Commit

Permalink
Everywhere: Move source files to separate subdirs
Browse files Browse the repository at this point in the history
Currently all of the source files are located in src/ subdirectory,
although it gets increasingly harder and harder to find anything in this
pile.

This patch moves those files to separate subdirectories that are named
accordingly to the theme that files in them represent, for example -
subdirectory "undostack" will hold undostack and all commands related to
the stack.

There might be code in some places, for example in palettewidget.cpp
that has "undostack" command inside of it, but moving that will come in
a separate refactor PR in the future.
  • Loading branch information
tetektoza authored and AJenbo committed Dec 4, 2023
1 parent aa4264b commit bb49dbb
Show file tree
Hide file tree
Showing 69 changed files with 100 additions and 99 deletions.
63 changes: 32 additions & 31 deletions CMakeLists.txt
Expand Up @@ -12,41 +12,42 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)


include_directories(source/)

set(PROJECT_SOURCES
source/celview.cpp
source/framecmds.cpp
source/config.cpp
source/d1amp.cpp
source/d1cel.cpp
source/d1celframe.cpp
source/d1celtileset.cpp
source/d1celtilesetframe.cpp
source/d1cl2.cpp
source/d1gfx.cpp
source/d1image.cpp
source/d1min.cpp
source/d1pal.cpp
source/d1palhits.cpp
source/d1sol.cpp
source/d1til.cpp
source/d1trn.cpp
source/exportdialog.cpp
source/view.cpp
source/levelcelview.cpp
source/leveltabframewidget.cpp
source/leveltabsubtilewidget.cpp
source/leveltabtilewidget.cpp
source/views/celview.cpp
source/config/config.cpp
source/d1formats/d1amp.cpp
source/d1formats/d1cel.cpp
source/d1formats/d1celframe.cpp
source/d1formats/d1celtileset.cpp
source/d1formats/d1celtilesetframe.cpp
source/d1formats/d1cl2.cpp
source/d1formats/d1gfx.cpp
source/d1formats/d1image.cpp
source/d1formats/d1min.cpp
source/palette/d1pal.cpp
source/palette/d1palhits.cpp
source/d1formats/d1sol.cpp
source/d1formats/d1til.cpp
source/d1formats/d1trn.cpp
source/dialogs/exportdialog.cpp
source/views/view.cpp
source/views/levelcelview.cpp
source/widgets/leveltabframewidget.cpp
source/widgets/leveltabsubtilewidget.cpp
source/widgets/leveltabtilewidget.cpp
source/main.cpp
source/mainwindow.cpp
source/openasdialog.cpp
source/palettewidget.cpp
source/settingsdialog.cpp
source/undostack.cpp
source/undostack.h
source/command.cpp
source/command.h
source/dialogs/openasdialog.cpp
source/widgets/palettewidget.cpp
source/dialogs/settingsdialog.cpp
source/undostack/framecmds.cpp
source/undostack/framecmds.h
source/undostack/undostack.cpp
source/undostack/undostack.h
source/undostack/command.cpp
source/undostack/command.h
)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion source/d1amp.h → source/d1formats/d1amp.h
Expand Up @@ -3,7 +3,7 @@
#include <QList>
#include <QString>

#include "openasdialog.h"
#include "dialogs/openasdialog.h"

class D1Amp : public QObject {
Q_OBJECT
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion source/d1cel.h → source/d1formats/d1cel.h
Expand Up @@ -4,7 +4,7 @@
#include <QString>

#include "d1gfx.h"
#include "openasdialog.h"
#include "dialogs/openasdialog.h"

class D1Cel {
public:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion source/d1celframe.h → source/d1formats/d1celframe.h
Expand Up @@ -3,7 +3,7 @@
#include <QByteArray>

#include "d1gfx.h"
#include "openasdialog.h"
#include "dialogs/openasdialog.h"

// Class used only for CEL frame width calculation
class D1CelPixelGroup {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion source/d1celtileset.h → source/d1formats/d1celtileset.h
Expand Up @@ -7,7 +7,7 @@

#include "d1celtilesetframe.h"
#include "d1gfx.h"
#include "openasdialog.h"
#include "dialogs/openasdialog.h"

class D1CelTileset {
public:
Expand Down
File renamed without changes.
Expand Up @@ -2,7 +2,7 @@

#include <QByteArray>

#include "openasdialog.h"
#include "dialogs/openasdialog.h"

#define MICRO_WIDTH 32
#define MICRO_HEIGHT 32
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion source/d1cl2.h → source/d1formats/d1cl2.h
Expand Up @@ -4,7 +4,7 @@
#include <QString>

#include "d1gfx.h"
#include "openasdialog.h"
#include "dialogs/openasdialog.h"

class D1Cl2Frame {
friend class D1Cl2;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion source/d1gfx.h → source/d1formats/d1gfx.h
Expand Up @@ -7,7 +7,7 @@
#include <optional>

#include "d1celtilesetframe.h"
#include "d1pal.h"
#include "palette/d1pal.h"

// TODO: move these to some persistency class?
#define SUB_HEADER_SIZE 0x0A
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion source/d1image.h → source/d1formats/d1image.h
Expand Up @@ -4,7 +4,7 @@
#include <QString>

#include "d1gfx.h"
#include "d1pal.h"
#include "palette/d1pal.h"

// alpha value under which the color is considered as transparent
#define COLOR_ALPHA_LIMIT 128
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion source/d1trn.h → source/d1formats/d1trn.h
Expand Up @@ -2,7 +2,7 @@

#include <QPointer>

#include "d1pal.h"
#include "palette/d1pal.h"

#define D1TRN_TRANSLATIONS 256

Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions source/exportdialog.h → source/dialogs/exportdialog.h
Expand Up @@ -3,11 +3,11 @@
#include <QDialog>
#include <QProgressDialog>

#include "d1amp.h"
#include "d1gfx.h"
#include "d1min.h"
#include "d1sol.h"
#include "d1til.h"
#include "d1formats/d1amp.h"
#include "d1formats/d1gfx.h"
#include "d1formats/d1min.h"
#include "d1formats/d1sol.h"
#include "d1formats/d1til.h"

namespace Ui {
class ExportDialog;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -3,7 +3,7 @@
#include <QColorDialog>
#include <QFileDialog>

#include "config.h"
#include "config/config.h"
#include "ui_settingsdialog.h"

SettingsDialog::SettingsDialog(QWidget *parent)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion source/main.cpp
Expand Up @@ -2,7 +2,7 @@
#include <QDebug>
#include <QFile>

#include "config.h"
#include "config/config.h"
#include "mainwindow.h"

int main(int argc, char *argv[])
Expand Down
8 changes: 4 additions & 4 deletions source/mainwindow.cpp
Expand Up @@ -21,10 +21,10 @@
#include <QTime>
#include <QtWidgets>

#include "config.h"
#include "d1cel.h"
#include "d1celtileset.h"
#include "d1cl2.h"
#include "config/config.h"
#include "d1formats/d1cel.h"
#include "d1formats/d1celtileset.h"
#include "d1formats/d1cl2.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow()
Expand Down
28 changes: 14 additions & 14 deletions source/mainwindow.h
Expand Up @@ -8,20 +8,20 @@

#include <memory>

#include "celview.h"
#include "d1gfx.h"
#include "d1min.h"
#include "d1pal.h"
#include "d1palhits.h"
#include "d1sol.h"
#include "d1til.h"
#include "d1trn.h"
#include "exportdialog.h"
#include "levelcelview.h"
#include "openasdialog.h"
#include "palettewidget.h"
#include "settingsdialog.h"
#include <undostack.h>
#include "d1formats/d1gfx.h"
#include "d1formats/d1min.h"
#include "d1formats/d1sol.h"
#include "d1formats/d1til.h"
#include "d1formats/d1trn.h"
#include "dialogs/exportdialog.h"
#include "dialogs/openasdialog.h"
#include "dialogs/settingsdialog.h"
#include "palette/d1pal.h"
#include "palette/d1palhits.h"
#include "undostack/undostack.h"
#include "views/celview.h"
#include "views/levelcelview.h"
#include "widgets/palettewidget.h"

#define D1_GRAPHICS_TOOL_TITLE "Diablo 1 Graphics Tool"
#define D1_GRAPHICS_TOOL_VERSION "1.0.1"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions source/d1palhits.h → source/palette/d1palhits.h
Expand Up @@ -2,9 +2,9 @@

#include <QMap>

#include "d1gfx.h"
#include "d1min.h"
#include "d1til.h"
#include "d1formats/d1gfx.h"
#include "d1formats/d1min.h"
#include "d1formats/d1til.h"

enum class D1PALHITS_MODE {
ALL_COLORS,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion source/framecmds.h → source/undostack/framecmds.h
@@ -1,7 +1,7 @@
#pragma once

#include "celview.h"
#include "command.h"
#include "views/celview.h"

#include <QObject>

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion source/celview.cpp → source/views/celview.cpp
Expand Up @@ -11,9 +11,9 @@
#include <QMessageBox>
#include <QMimeData>

#include "framecmds.h"
#include "mainwindow.h"
#include "ui_celview.h"
#include "undostack/framecmds.h"

CelScene::CelScene(QWidget *v)
: QGraphicsScene()
Expand Down
4 changes: 2 additions & 2 deletions source/celview.h → source/views/celview.h
Expand Up @@ -14,8 +14,8 @@
#include <memory>
#include <stack>

#include "d1gfx.h"
#include "undostack.h"
#include "d1formats/d1gfx.h"
#include "undostack/undostack.h"

#define CEL_SCENE_SPACING 8

Expand Down
2 changes: 1 addition & 1 deletion source/celview.ui → source/views/celview.ui
Expand Up @@ -781,7 +781,7 @@
<customwidget>
<class>View</class>
<extends>QGraphicsView</extends>
<header>view.h</header>
<header>views/view.h</header>
</customwidget>
</customwidgets>
<resources/>
Expand Down
4 changes: 2 additions & 2 deletions source/levelcelview.cpp → source/views/levelcelview.cpp
Expand Up @@ -3,10 +3,10 @@
#include <algorithm>
#include <set>

#include "d1image.h"
#include "framecmds.h"
#include "d1formats/d1image.h"
#include "mainwindow.h"
#include "ui_levelcelview.h"
#include "undostack/framecmds.h"

#include <QAction>
#include <QDebug>
Expand Down
18 changes: 9 additions & 9 deletions source/levelcelview.h → source/views/levelcelview.h
Expand Up @@ -17,15 +17,15 @@
#include <vector>

#include "celview.h"
#include "d1amp.h"
#include "d1gfx.h"
#include "d1min.h"
#include "d1sol.h"
#include "d1til.h"
#include "leveltabframewidget.h"
#include "leveltabsubtilewidget.h"
#include "leveltabtilewidget.h"
#include "undostack.h"
#include "d1formats/d1amp.h"
#include "d1formats/d1gfx.h"
#include "d1formats/d1min.h"
#include "d1formats/d1sol.h"
#include "d1formats/d1til.h"
#include "undostack/undostack.h"
#include "widgets/leveltabframewidget.h"
#include "widgets/leveltabsubtilewidget.h"
#include "widgets/leveltabtilewidget.h"

namespace Ui {
class LevelCelView;
Expand Down
2 changes: 1 addition & 1 deletion source/levelcelview.ui → source/views/levelcelview.ui
Expand Up @@ -1150,7 +1150,7 @@
<customwidget>
<class>View</class>
<extends>QGraphicsView</extends>
<header>view.h</header>
<header>views/view.h</header>
</customwidget>
</customwidgets>
<resources/>
Expand Down
File renamed without changes.
File renamed without changes.
@@ -1,8 +1,8 @@
#include "leveltabframewidget.h"

#include "d1gfx.h"
#include "levelcelview.h"
#include "d1formats/d1gfx.h"
#include "ui_leveltabframewidget.h"
#include "views/levelcelview.h"

LevelTabFrameWidget::LevelTabFrameWidget()
: QWidget(nullptr)
Expand Down
File renamed without changes.
File renamed without changes.
@@ -1,7 +1,7 @@
#include "leveltabsubtilewidget.h"

#include "levelcelview.h"
#include "ui_leveltabsubtilewidget.h"
#include "views/levelcelview.h"

LevelTabSubTileWidget::LevelTabSubTileWidget()
: QWidget(nullptr)
Expand Down
File renamed without changes.
File renamed without changes.
@@ -1,10 +1,10 @@
#include "leveltabtilewidget.h"

#include "d1amp.h"
#include "d1min.h"
#include "d1til.h"
#include "levelcelview.h"
#include "d1formats/d1amp.h"
#include "d1formats/d1min.h"
#include "d1formats/d1til.h"
#include "ui_leveltabtilewidget.h"
#include "views/levelcelview.h"

LevelTabTileWidget::LevelTabTileWidget()
: QWidget(nullptr)
Expand Down
File renamed without changes.
File renamed without changes.
Expand Up @@ -7,7 +7,7 @@
#include <QMessageBox>
#include <QMimeData>

#include "config.h"
#include "config/config.h"
#include "mainwindow.h"
#include "ui_palettewidget.h"

Expand Down

0 comments on commit bb49dbb

Please sign in to comment.