Skip to content

Commit

Permalink
Remove warnings, add .desktop entry
Browse files Browse the repository at this point in the history
  • Loading branch information
Atari2 committed Mar 29, 2024
1 parent ec6e555 commit 275f115
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 27 deletions.
10 changes: 10 additions & 0 deletions CFGEditorPlusPlus.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Type=Application
Version=1.0
Name=CFGEditorPlusPlus
Comment=A Pixi config editor
Exec=CFGEditorPlusPlus
Icon=VioletEgg
GenericName=CFGEditorPlusPlus
Categories=Development
Terminal=false
17 changes: 15 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,29 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
COMMENT "Running windeployqt..."
)
endif()
elseif(UNIX)
install(TARGETS CFGEditorPlusPlus
BUNDLE DESTINATION .
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
qt_generate_deploy_app_script(
TARGET CFGEditorPlusPlus
OUTPUT_SCRIPT deploy_script
NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
endif()
else()
add_executable(CFGEditorPlusPlus
${PROJECT_SOURCES}
)
endif()

if (RELEASE_BUILD AND ON_WINDOWS)
if (RELEASE_BUILD)
message(STATUS "Building Release, removing qDebug()")
target_compile_definitions(CFGEditorPlusPlus PRIVATE QT_NO_DEBUG_OUTPUT)
target_link_options(CFGEditorPlusPlus PRIVATE /SUBSYSTEM:windows /ENTRY:mainCRTStartup)
if (ON_WINDOWS)
target_link_options(CFGEditorPlusPlus PRIVATE /SUBSYSTEM:windows /ENTRY:mainCRTStartup)
endif()
endif()
target_link_libraries(CFGEditorPlusPlus PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
Binary file added VioletEgg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion cfgeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void CFGEditor::populateDisplays() {
}
}

Display CFGEditor::createDisplay(const DisplayData& data) {
JSONDisplay CFGEditor::createDisplay(const DisplayData& data) {
QVector<Tile> tiles;
tiles.reserve(data.Tiles().length());
for (auto& t : data.Tiles()) {
Expand Down
2 changes: 1 addition & 1 deletion cfgeditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class CFGEditor : public QMainWindow
void removeExistingRow();
void changeTilePropGroupState(bool, TileChangeType type = TileChangeType::All);
void setTilePropGroupState(FullTile tileInfo);
Display createDisplay(const DisplayData& data);
JSONDisplay createDisplay(const DisplayData& data);
void populateDisplays();
void populateGFXFiles();

Expand Down
4 changes: 2 additions & 2 deletions eightbyeightview.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class EightByEightView : public QGraphicsView
EightByEightView(QGraphicsScene* scene);
void updateForChange(QImage* image);
void setComboBox(QComboBox* comboBox);
void mouseMoveEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event) override;
void keyPressEvent(QKeyEvent* event) override;
~EightByEightView();
void open();
Expand All @@ -34,7 +34,7 @@ class EightByEightView : public QGraphicsView
QGraphicsPixmapItem* currentItem = nullptr;
QComboBox* m_paletteComboBox = nullptr;
bool m_open = false;
void closeEvent(QCloseEvent* event);
void closeEvent(QCloseEvent* event) override;
int convertPointToTile(const QPointF& point);
};

Expand Down
12 changes: 6 additions & 6 deletions jsonsprite.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "jsonsprite.h"

Display::Display(const QJsonObject& d, DisplayType type) {
JSONDisplay::JSONDisplay(const QJsonObject& d, DisplayType type) {
description = d["Description"].toString();
extrabit = d["ExtraBit"].toBool();
if (auto it = d.find("GFXInfo"); it != d.constEnd()) {
Expand All @@ -27,7 +27,7 @@ Display::Display(const QJsonObject& d, DisplayType type) {
}
}

Display::Display(const QString& d, const QVector<Tile>& ts, bool bit, int xx, int yy, bool text, const QString& disp, const GFXInfo& info) :
JSONDisplay::JSONDisplay(const QString& d, const QVector<Tile>& ts, bool bit, int xx, int yy, bool text, const QString& disp, const GFXInfo& info) :
description(d),
extrabit(bit),
x_or_index(xx),
Expand All @@ -39,7 +39,7 @@ Display::Display(const QString& d, const QVector<Tile>& ts, bool bit, int xx, in
tiles.append(ts);
}

QJsonObject Display::toJson(DisplayType type) const {
QJsonObject JSONDisplay::toJson(DisplayType type) const {
QJsonObject obj{};
obj["Description"] = description;
obj["ExtraBit"] = extrabit;
Expand Down Expand Up @@ -240,7 +240,7 @@ JsonSprite::JsonSprite() {
addbcountclear = 0;
addbcountset = 0;
map16 = QString();
displays = QVector<Display>();
displays = QVector<JSONDisplay>();
collections = QVector<Collection>();
dispType = DisplayType::XY;
}
Expand Down Expand Up @@ -290,7 +290,7 @@ void JsonSprite::deserialize() {
displays.reserve(dispArr.size());
collections.reserve(collArr.size());
std::for_each(dispArr.cbegin(), dispArr.cend(), [&](auto& d) {
displays.push_back(Display(d.toObject(), dispType));
displays.push_back(JSONDisplay(d.toObject(), dispType));
});
std::for_each(collArr.cbegin(), collArr.cend(), [&](auto& c) {
collections.push_back(Collection(c.toObject()));
Expand Down Expand Up @@ -370,7 +370,7 @@ void JsonSprite::addCollections(QTableView* view) {
}
}

void JsonSprite::addDisplay(const Display& display) {
void JsonSprite::addDisplay(const JSONDisplay& display) {
displays.append(display);
}

Expand Down
10 changes: 5 additions & 5 deletions jsonsprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct Tile {
QJsonObject toJson() const;
};

struct Display {
struct JSONDisplay {
QString description;
QVector<Tile> tiles;
bool extrabit;
Expand All @@ -52,8 +52,8 @@ struct Display {
bool useText;
QString displaytext;
GFXInfo gfxinfo{};
Display(const QJsonObject& t, DisplayType type);
Display(const QString& d, const QVector<Tile>& ts, bool bit, int xx, int yy, bool text, const QString& disp, const GFXInfo& info);
JSONDisplay(const QJsonObject& t, DisplayType type);
JSONDisplay(const QString& d, const QVector<Tile>& ts, bool bit, int xx, int yy, bool text, const QString& disp, const GFXInfo& info);
QJsonObject toJson(DisplayType type) const;
};

Expand All @@ -75,7 +75,7 @@ class JsonSprite {
void serialize();
QByteArray serialize_cfg();
void addCollections(QTableView* view);
void addDisplay(const Display& display);
void addDisplay(const JSONDisplay& display);
void setMap16(const QString& mapdata);
QByteArray to_text(const QString& filename);
void to_file(QString name = "");
Expand All @@ -94,7 +94,7 @@ class JsonSprite {
int addbcountclear;
int addbcountset;
QString map16;
QVector<Display> displays;
QVector<JSONDisplay> displays;
QVector<Collection> collections;
QString m_name;
QJsonObject obj;
Expand Down
2 changes: 1 addition & 1 deletion map16provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void Map16Provider::keyPressEvent(QKeyEvent *event) {
event->accept();
}

void Map16Provider::deserializeDisplays(const QVector<Display>& displays, Map16GraphicsView* view) {
void Map16Provider::deserializeDisplays(const QVector<JSONDisplay>& displays, Map16GraphicsView* view) {

// clear all to prepare for new displays
m_displays.clear();
Expand Down
2 changes: 1 addition & 1 deletion map16provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Map16Provider : public QLabel
void changeDisplay(int newindex);
void cloneDisplay(int index = -1);
void serializeDisplays(QVector<DisplayData>& data);
void deserializeDisplays(const QVector<Display>& display, Map16GraphicsView* view);
void deserializeDisplays(const QVector<JSONDisplay>& display, Map16GraphicsView* view);
private:
TiledPosition invalid = TiledPosition::getInvalid();
TiledPosition& findIndex(size_t index);
Expand Down
2 changes: 1 addition & 1 deletion spritedatamodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ DisplayData::DisplayData(const DisplayData& other) {
this->operator=(other);
}

DisplayData::DisplayData(const Display& other) {
DisplayData::DisplayData(const JSONDisplay& other) {
m_extra_bit = other.extrabit;
m_x_or_index = other.x_or_index;
m_y_or_value = other.y_or_value;
Expand Down
2 changes: 1 addition & 1 deletion spritedatamodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class DisplayData : QObject {
public:
DisplayData& operator=(const DisplayData& other);
DisplayData(const DisplayData& other);
DisplayData(const Display& other);
DisplayData(const JSONDisplay& other);
void setUseText(bool enabled);
void setExtraBit(bool enabled);
void setDescription(const QString& description);
Expand Down
12 changes: 6 additions & 6 deletions utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,37 @@ bool assert_filesize(S name, qsizetype size) {
if constexpr (std::is_same_v<T, Equal>) {
result = file.size() == size;
if (!result) {
DefaultAlertImpl(nullptr, QString::asprintf("This type of file must be exactly %d bytes in size", size))();
DefaultAlertImpl(nullptr, QString::asprintf("This type of file must be exactly %lld bytes in size", size))();
}
}
else if constexpr (std::is_same_v<T, Different>) {
result = file.size() != size;
if (!result) {
DefaultAlertImpl(nullptr, QString::asprintf("This type of file must not be exactly %d bytes in size", size))();
DefaultAlertImpl(nullptr, QString::asprintf("This type of file must not be exactly %lld bytes in size", size))();
}
}
else if constexpr (std::is_same_v<T, LessThan>) {
result = file.size() < size;
if (!result) {
DefaultAlertImpl(nullptr, QString::asprintf("This type of file must be less than %d bytes in size", size))();
DefaultAlertImpl(nullptr, QString::asprintf("This type of file must be less than %lld bytes in size", size))();
}
}
else if constexpr (std::is_same_v<T, MoreThan>) {
result = file.size() > size;
if (!result) {
DefaultAlertImpl(nullptr, QString::asprintf("This type of file must be more than %d bytes in size", size))();
DefaultAlertImpl(nullptr, QString::asprintf("This type of file must be more than %lld bytes in size", size))();
}
}
else if constexpr (std::is_same_v<T, LessThanOrEqual>) {
result = file.size() <= size;
if (!result) {
DefaultAlertImpl(nullptr, QString::asprintf("This type of file must be less than or equal to %d bytes in size", size))();
DefaultAlertImpl(nullptr, QString::asprintf("This type of file must be less than or equal to %lld bytes in size", size))();
}
}
else if constexpr (std::is_same_v<T, MoreThanOrEqual>) {
result = file.size() == size;
if (!result) {
DefaultAlertImpl(nullptr, QString::asprintf("This type of file must be more than or equal to %d bytes in size", size))();
DefaultAlertImpl(nullptr, QString::asprintf("This type of file must be more than or equal to %lld bytes in size", size))();
}
} else {
Q_ASSERT(false);
Expand Down

0 comments on commit 275f115

Please sign in to comment.