From d7c98c1e3c093f31cae1ded187bbfbcae0060346 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sat, 29 Sep 2018 08:59:47 -0500 Subject: [PATCH 1/4] Remove accidentally-added files --- editor.h | 440 ---------------------------------------------------- map.h | 234 ---------------------------- porymap.pro | 58 ------- tileset.cpp | 120 -------------- 4 files changed, 852 deletions(-) delete mode 100755 editor.h delete mode 100755 map.h delete mode 100755 porymap.pro delete mode 100755 tileset.cpp diff --git a/editor.h b/editor.h deleted file mode 100755 index a98c93f6..00000000 --- a/editor.h +++ /dev/null @@ -1,440 +0,0 @@ -#ifndef EDITOR_H -#define EDITOR_H - -#include -#include -#include -#include -#include -#include -#include - -#include "project.h" -#include "ui_mainwindow.h" - -class DraggablePixmapItem; -class MapPixmapItem; -class CollisionPixmapItem; -class ConnectionPixmapItem; -class MetatilesPixmapItem; -class BorderMetatilesPixmapItem; -class CurrentSelectedMetatilesPixmapItem; -class MovementPermissionsPixmapItem; - -#define SWAP(a, b) do { if (a != b) { a ^= b; b ^= a; a ^= b; } } while (0) - -class Editor : public QObject -{ - Q_OBJECT -public: - Editor(Ui::MainWindow* ui); -public: - Ui::MainWindow* ui; - QObject *parent = nullptr; - Project *project = nullptr; - Map *map = nullptr; - void saveProject(); - void save(); - void undo(); - void redo(); - void setMap(QString map_name); - void updateCurrentMetatilesSelection(); - void displayMap(); - void displayMetatiles(); - void displayBorderMetatiles(); - void displayCurrentMetatilesSelection(); - void redrawCurrentMetatilesSelection(); - void displayCollisionMetatiles(); - void displayElevationMetatiles(); - void displayMapEvents(); - void displayMapConnections(); - void displayMapBorder(); - void displayMapGrid(); - - void setEditingMap(); - void setEditingCollision(); - void setEditingObjects(); - void setEditingConnections(); - void setCurrentConnectionDirection(QString curDirection); - void updateCurrentConnectionDirection(QString curDirection); - void setConnectionsVisibility(bool visible); - void updateConnectionOffset(int offset); - void setConnectionMap(QString mapName); - void addNewConnection(); - void removeCurrentConnection(); - void updateDiveMap(QString mapName); - void updateEmergeMap(QString mapName); - void setSelectedConnectionFromMap(QString mapName); - void updatePrimaryTileset(QString tilesetLabel); - void updateSecondaryTileset(QString tilesetLabel); - void toggleBorderVisibility(bool visible); - - DraggablePixmapItem *addMapEvent(Event *event); - void selectMapEvent(DraggablePixmapItem *object); - void selectMapEvent(DraggablePixmapItem *object, bool toggle); - DraggablePixmapItem *addNewEvent(QString event_type); - Event* createNewEvent(QString event_type); - void deleteEvent(Event *); - void updateSelectedEvents(); - void redrawObject(DraggablePixmapItem *item); - QList *getObjects(); - - QGraphicsScene *scene = nullptr; - QGraphicsPixmapItem *current_view = nullptr; - MapPixmapItem *map_item = nullptr; - ConnectionPixmapItem* selected_connection_item = nullptr; - QList connection_items; - QList connection_edit_items; - CollisionPixmapItem *collision_item = nullptr; - QGraphicsItemGroup *events_group = nullptr; - QList borderItems; - QList gridLines; - - QGraphicsScene *scene_metatiles = nullptr; - QGraphicsScene *scene_current_metatile_selection = nullptr; - QGraphicsScene *scene_selected_border_metatiles = nullptr; - QGraphicsScene *scene_collision_metatiles = nullptr; - QGraphicsScene *scene_elevation_metatiles = nullptr; - MetatilesPixmapItem *metatiles_item = nullptr; - - BorderMetatilesPixmapItem *selected_border_metatiles_item = nullptr; - CurrentSelectedMetatilesPixmapItem *scene_current_metatile_selection_item = nullptr; - MovementPermissionsPixmapItem *collision_metatiles_item = nullptr; - - QList *events = nullptr; - QList *selected_events = nullptr; - - bool lastSelectedMetatilesFromMap = false; - int copiedMetatileSelectionWidth = 0; - int copiedMetatileSelectionHeight = 0; - QList *copiedMetatileSelection = new QList; - - int scale_exp = 0; - double scale_base = sqrt(2); // adjust scale factor with this - - QString map_edit_mode; - QString prev_edit_mode; - QCursor cursor; - - void objectsView_onMousePress(QMouseEvent *event); - void objectsView_onMouseMove(QMouseEvent *event); - void objectsView_onMouseRelease(QMouseEvent *event); - -private: - void setConnectionItemsVisible(bool); - void setBorderItemsVisible(bool, qreal = 1); - void setConnectionEditControlValues(Connection*); - void setConnectionEditControlsEnabled(bool); - void createConnectionItem(Connection* connection, bool hide); - void populateConnectionMapPickers(); - void setDiveEmergeControls(); - void updateDiveEmergeMap(QString mapName, QString direction); - void onConnectionOffsetChanged(int newOffset); - void removeMirroredConnection(Connection*); - void updateMirroredConnectionOffset(Connection*); - void updateMirroredConnectionDirection(Connection*, QString); - void updateMirroredConnectionMap(Connection*, QString); - void updateMirroredConnection(Connection*, QString, QString, bool isDelete = false); - Event* createNewObjectEvent(); - Event* createNewWarpEvent(); - Event* createNewHealLocationEvent(); - Event* createNewCoordScriptEvent(); - Event* createNewCoordWeatherEvent(); - Event* createNewSignEvent(); - Event* createNewHiddenItemEvent(); - Event* createNewSecretBaseEvent(); - -private slots: - void mouseEvent_map(QGraphicsSceneMouseEvent *event, MapPixmapItem *item); - void mouseEvent_collision(QGraphicsSceneMouseEvent *event, CollisionPixmapItem *item); - void onConnectionMoved(Connection*); - void onConnectionItemSelected(ConnectionPixmapItem* connectionItem); - void onConnectionItemDoubleClicked(ConnectionPixmapItem* connectionItem); - void onConnectionDirectionChanged(QString newDirection); - void onBorderMetatilesChanged(); - -signals: - void objectsChanged(); - void selectedObjectsChanged(); - void loadMapRequested(QString, QString); - void tilesetChanged(QString); - void warpEventDoubleClicked(QString mapName, QString warpNum); - void currentMetatilesSelectionChanged(); -}; - - - -class DraggablePixmapItem : public QObject, public QGraphicsPixmapItem { - Q_OBJECT -public: - DraggablePixmapItem(QPixmap pixmap): QGraphicsPixmapItem(pixmap) { - } - Editor *editor = nullptr; - Event *event = nullptr; - QGraphicsItemAnimation *pos_anim = nullptr; - DraggablePixmapItem(Event *event_, Editor *editor_) : QGraphicsPixmapItem(event_->pixmap) { - event = event_; - editor = editor_; - updatePosition(); - } - bool active; - int last_x; - int last_y; - void updatePosition() { - int x = event->getPixelX(); - int y = event->getPixelY(); - setX(x); - setY(y); - setZValue(event->y()); - } - void move(int x, int y); - void emitPositionChanged() { - emit xChanged(event->x()); - emit yChanged(event->y()); - emit elevationChanged(event->elevation()); - } - void updatePixmap() { - QList objects; - objects.append(event); - event->pixmap = QPixmap(); - editor->project->loadEventPixmaps(objects); - this->updatePosition(); - editor->redrawObject(this); - emit spriteChanged(event->pixmap); - } - void bind(QComboBox *combo, QString key) { - connect(combo, static_cast(&QComboBox::currentTextChanged), - this, [this, key](QString value){ - this->event->put(key, value); - }); - connect(this, &DraggablePixmapItem::onPropertyChanged, - this, [combo, key](QString key2, QString value){ - if (key2 == key) { - combo->addItem(value); - combo->setCurrentText(value); - } - }); - } - -signals: - void positionChanged(Event *event); - void xChanged(int); - void yChanged(int); - void elevationChanged(int); - void spriteChanged(QPixmap pixmap); - void onPropertyChanged(QString key, QString value); - -public slots: - void set_x(const QString &text) { - event->put("x", text); - updatePosition(); - } - void set_y(const QString &text) { - event->put("y", text); - updatePosition(); - } - void set_elevation(const QString &text) { - event->put("elevation", text); - updatePosition(); - } - void set_sprite(const QString &text) { - event->put("sprite", text); - updatePixmap(); - } - void set_script(const QString &text) { - event->put("script_label", text); - } - -protected: - void mousePressEvent(QGraphicsSceneMouseEvent*); - void mouseMoveEvent(QGraphicsSceneMouseEvent*); - void mouseReleaseEvent(QGraphicsSceneMouseEvent*); - void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*); -}; - -class EventGroup : public QGraphicsItemGroup { -}; - -class MapPixmapItem : public QObject, public QGraphicsPixmapItem { - Q_OBJECT -public: - MapPixmapItem(QPixmap pixmap): QGraphicsPixmapItem(pixmap) { - } - Map *map = nullptr; - Editor *editor = nullptr; - MapPixmapItem(Map *map_, Editor *editor_) { - map = map_; - editor = editor_; - setAcceptHoverEvents(true); - } - bool active; - bool right_click; - QPoint selection_origin; - QList selection; - virtual void paint(QGraphicsSceneMouseEvent*); - virtual void floodFill(QGraphicsSceneMouseEvent*); - void _floodFill(int x, int y); - void _floodFillSmartPath(int initialX, int initialY); - virtual void pick(QGraphicsSceneMouseEvent*); - virtual void select(QGraphicsSceneMouseEvent*); - virtual void shift(QGraphicsSceneMouseEvent*); - virtual void draw(bool ignoreCache = false); - void updateMetatileSelection(QGraphicsSceneMouseEvent *event); - -private: - void updateCurHoveredTile(QPointF pos); - void paintNormal(int x, int y); - void paintSmartPath(int x, int y); - static QList smartPathTable; - -signals: - void mouseEvent(QGraphicsSceneMouseEvent *, MapPixmapItem *); - -protected: - void hoverMoveEvent(QGraphicsSceneHoverEvent*); - void hoverLeaveEvent(QGraphicsSceneHoverEvent*); - void mousePressEvent(QGraphicsSceneMouseEvent*); - void mouseMoveEvent(QGraphicsSceneMouseEvent*); - void mouseReleaseEvent(QGraphicsSceneMouseEvent*); -}; - -class CollisionPixmapItem : public MapPixmapItem { - Q_OBJECT -public: - CollisionPixmapItem(QPixmap pixmap): MapPixmapItem(pixmap) { - } - CollisionPixmapItem(Map *map_, Editor *editor_): MapPixmapItem(map_, editor_) { - } - void updateMovementPermissionSelection(QGraphicsSceneMouseEvent *event); - virtual void paint(QGraphicsSceneMouseEvent*); - virtual void floodFill(QGraphicsSceneMouseEvent*); - virtual void pick(QGraphicsSceneMouseEvent*); - virtual void draw(bool ignoreCache = false); - -signals: - void mouseEvent(QGraphicsSceneMouseEvent *, CollisionPixmapItem *); - -protected: - void mousePressEvent(QGraphicsSceneMouseEvent*); - void mouseMoveEvent(QGraphicsSceneMouseEvent*); - void mouseReleaseEvent(QGraphicsSceneMouseEvent*); -}; - -class ConnectionPixmapItem : public QObject, public QGraphicsPixmapItem { - Q_OBJECT -public: - ConnectionPixmapItem(QPixmap pixmap, Connection* connection, int x, int y, int baseMapWidth, int baseMapHeight): QGraphicsPixmapItem(pixmap) { - this->basePixmap = pixmap; - this->connection = connection; - setFlag(ItemIsMovable); - setFlag(ItemSendsGeometryChanges); - this->initialX = x; - this->initialY = y; - this->initialOffset = connection->offset.toInt(); - this->baseMapWidth = baseMapWidth; - this->baseMapHeight = baseMapHeight; - } - void render(qreal opacity = 1) { - QPixmap newPixmap = basePixmap.copy(0, 0, basePixmap.width(), basePixmap.height()); - if (opacity < 1) { - QPainter painter(&newPixmap); - int alpha = static_cast(255 * (1 - opacity)); - painter.fillRect(0, 0, newPixmap.width(), newPixmap.height(), QColor(0, 0, 0, alpha)); - painter.end(); - } - this->setPixmap(newPixmap); - } - int getMinOffset(); - int getMaxOffset(); - QPixmap basePixmap; - Connection* connection; - int initialX; - int initialY; - int initialOffset; - int baseMapWidth; - int baseMapHeight; -protected: - QVariant itemChange(GraphicsItemChange change, const QVariant &value); - void mousePressEvent(QGraphicsSceneMouseEvent*); - void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*); -signals: - void connectionItemSelected(ConnectionPixmapItem* connectionItem); - void connectionItemDoubleClicked(ConnectionPixmapItem* connectionItem); - void connectionMoved(Connection*); -}; - -class MetatilesPixmapItem : public QObject, public QGraphicsPixmapItem { - Q_OBJECT -public: - MetatilesPixmapItem(Map *map_) { - map = map_; - setAcceptHoverEvents(true); - connect(map, SIGNAL(paintTileChanged()), this, SLOT(paintTileChanged())); - } - Map* map = nullptr; - virtual void draw(); -private: - void updateSelection(QPointF pos); -protected: - virtual void updateCurHoveredMetatile(QPointF pos); -private slots: - void paintTileChanged(); -protected: - void hoverMoveEvent(QGraphicsSceneHoverEvent*); - void hoverLeaveEvent(QGraphicsSceneHoverEvent*); - void mousePressEvent(QGraphicsSceneMouseEvent*); - void mouseMoveEvent(QGraphicsSceneMouseEvent*); - void mouseReleaseEvent(QGraphicsSceneMouseEvent*); -}; - -class BorderMetatilesPixmapItem : public QObject, public QGraphicsPixmapItem { - Q_OBJECT -public: - BorderMetatilesPixmapItem(Map *map_) { - map = map_; - setAcceptHoverEvents(true); - } - Map* map = nullptr; - virtual void draw(); -signals: - void borderMetatilesChanged(); -protected: - void mousePressEvent(QGraphicsSceneMouseEvent*); -}; - -class CurrentSelectedMetatilesPixmapItem : public QObject, public QGraphicsPixmapItem { - Q_OBJECT -public: - CurrentSelectedMetatilesPixmapItem(Map *map_) { - map = map_; - } - Map* map = nullptr; - virtual void draw(); -}; - -class MovementPermissionsPixmapItem : public MetatilesPixmapItem { - Q_OBJECT -public: - MovementPermissionsPixmapItem(Map *map_): MetatilesPixmapItem(map_) { - connect(map, SIGNAL(paintCollisionChanged(Map*)), this, SLOT(paintCollisionChanged(Map *))); - } - virtual void pick(uint16_t collision, uint16_t elevation) { - map->paint_collision = collision; - map->paint_elevation = elevation; - draw(); - } - virtual void draw() { - setPixmap(map->renderCollisionMetatiles()); - } -protected: - void mousePressEvent(QGraphicsSceneMouseEvent*); - void mouseMoveEvent(QGraphicsSceneMouseEvent*); - void mouseReleaseEvent(QGraphicsSceneMouseEvent*); - virtual void updateCurHoveredMetatile(QPointF pos); -private slots: - void paintCollisionChanged(Map *) { - draw(); - } -}; - -#endif // EDITOR_H diff --git a/map.h b/map.h deleted file mode 100755 index 75e1ec37..00000000 --- a/map.h +++ /dev/null @@ -1,234 +0,0 @@ -#ifndef MAP_H -#define MAP_H - -#include "tileset.h" -#include "blockdata.h" -#include "event.h" - -#include -#include -#include -#include -#include - -class HistoryItem { -public: - Blockdata *metatiles; - int layoutWidth; - int layoutHeight; - HistoryItem(Blockdata *metatiles_, int layoutWidth_, int layoutHeight_) { - this->metatiles = metatiles_; - this->layoutWidth = layoutWidth_; - this->layoutHeight = layoutHeight_; - } - ~HistoryItem() { - if (metatiles) delete metatiles; - } -}; - -template -class History { -public: - History() { - - } - T back() { - if (head > 0) { - return history.at(--head); - } - return NULL; - } - T next() { - if (head + 1 < history.length()) { - return history.at(++head); - } - return NULL; - } - void push(T commit) { - while (head + 1 < history.length()) { - HistoryItem *item = history.last(); - history.removeLast(); - delete item; - } - if (saved > head) { - saved = -1; - } - history.append(commit); - head++; - } - T current() { - if (head < 0 || history.length() == 0) { - return NULL; - } - return history.at(head); - } - void save() { - saved = head; - } - bool isSaved() { - return saved == head; - } - -private: - QList history; - int head = -1; - int saved = -1; -}; - -class Connection { -public: - Connection() { - } -public: - QString direction; - QString offset; - QString map_name; -}; - -class MapLayout { -public: - MapLayout() {} - int index; - QString name; - QString label; - QString width; - QString height; - QString border_label; - QString border_path; - QString blockdata_label; - QString blockdata_path; - QString tileset_primary_label; - QString tileset_secondary_label; - Tileset *tileset_primary = nullptr; - Tileset *tileset_secondary = nullptr; - Blockdata* blockdata = nullptr; - QImage border_image; - QPixmap border_pixmap; - Blockdata *border = nullptr; - Blockdata *cached_blockdata = nullptr; - Blockdata *cached_collision = nullptr; - Blockdata *cached_border = nullptr; - bool has_unsaved_changes = false; -public: - static QString getNameFromLabel(QString label) { - // ASSUMPTION: strip off "_Layout" from layout label. Directories in 'data/layouts/' must be well-formed. - return label.replace(label.lastIndexOf("_Layout"), label.length(), ""); - } -}; - -class Map : public QObject -{ - Q_OBJECT -public: - explicit Map(QObject *parent = nullptr); - -public: - QString name; - QString constantName; - QString group_num; - QString layout_label; - QString events_label; - QString scripts_label; - QString connections_label; - QString song; - QString layout_id; - QString location; - QString requiresFlash; - QString isFlyable; // TODO: implement this - QString weather; - QString type; - QString unknown; - QString show_location; - QString battle_scene; - MapLayout *layout; - - bool isPersistedToFile = true; - -public: - void setName(QString mapName); - static QString mapConstantFromName(QString mapName); - static QString objectEventsLabelFromName(QString mapName); - static QString warpEventsLabelFromName(QString mapName); - static QString coordEventsLabelFromName(QString mapName); - static QString bgEventsLabelFromName(QString mapName); - int getWidth(); - int getHeight(); - uint16_t getSelectedBlockIndex(int); - int getDisplayedBlockIndex(int); - QPixmap render(bool ignoreCache); - QPixmap renderMetatiles(); - - QPixmap renderCollision(bool ignoreCache); - QImage collision_image; - QPixmap collision_pixmap; - QImage getCollisionMetatileImage(Block); - QImage getCollisionMetatileImage(int, int); - QPixmap renderCollisionMetatiles(); - - void drawSelection(int i, int w, int selectionWidth, int selectionHeight, QPainter *painter, int gridWidth); - - bool blockChanged(int, Blockdata*); - void cacheBlockdata(); - void cacheCollision(); - QImage image; - QPixmap pixmap; - QList metatile_images; - bool smart_paths_enabled = false; - int paint_metatile_initial_x; - int paint_metatile_initial_y; - int paint_tile_index; - int paint_tile_width = 1; - int paint_tile_height = 1; - int paint_tile_initial_x; - int paint_tile_initial_y; - int selected_metatiles_width; - int selected_metatiles_height; - QList *selected_metatiles = nullptr; - uint16_t paint_collision; - uint16_t paint_elevation; - - Block *getBlock(int x, int y); - void setBlock(int x, int y, Block block); - void _setBlock(int x, int y, Block block); - - void floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation); - void _floodFillCollisionElevation(int x, int y, uint16_t collision, uint16_t elevation); - - History history; - void undo(); - void redo(); - void commit(); - - QList getAllEvents(); - void removeEvent(Event *event); - void addEvent(Event *event); - QMap> events; - - QList connections; - QPixmap renderConnection(Connection); - void setNewDimensionsBlockdata(int newWidth, int newHeight); - void setDimensions(int newWidth, int newHeight, bool setNewBlockData = true); - - QPixmap renderBorder(); - void cacheBorder(); - - bool hasUnsavedChanges(); - void hoveredTileChanged(int x, int y, int block); - void clearHoveredTile(); - void hoveredMetatileChanged(int block); - void clearHoveredMetatile(); - void hoveredMovementPermissionTileChanged(int collision, int elevation); - void clearHoveredMovementPermissionTile(); - void setSelectedMetatilesFromTilePicker(); - -signals: - void paintTileChanged(); - void paintCollisionChanged(Map *map); - void mapChanged(Map *map); - void mapNeedsRedrawing(); - void statusBarMessage(QString); - -public slots: -}; - -#endif // MAP_H diff --git a/porymap.pro b/porymap.pro deleted file mode 100755 index ba778baf..00000000 --- a/porymap.pro +++ /dev/null @@ -1,58 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2016-08-31T15:19:13 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = porymap -TEMPLATE = app -RC_ICONS = resources/icons/porymap-icon-1.ico -ICON = resources/icons/porymap-icon-1.ico - - -SOURCES += main.cpp\ - mainwindow.cpp \ - project.cpp \ - map.cpp \ - blockdata.cpp \ - block.cpp \ - tileset.cpp \ - tile.cpp \ - event.cpp \ - editor.cpp \ - objectpropertiesframe.cpp \ - graphicsview.cpp \ - parseutil.cpp \ - neweventtoolbutton.cpp \ - noscrollcombobox.cpp \ - noscrollspinbox.cpp \ - heallocation.cpp \ - mapsceneeventfilter.cpp - -HEADERS += mainwindow.h \ - project.h \ - map.h \ - blockdata.h \ - block.h \ - tileset.h \ - tile.h \ - event.h \ - editor.h \ - objectpropertiesframe.h \ - graphicsview.h \ - parseutil.h \ - neweventtoolbutton.h \ - noscrollcombobox.h \ - noscrollspinbox.h \ - heallocation.h \ - mapsceneeventfilter.h - -FORMS += mainwindow.ui \ - objectpropertiesframe.ui - -RESOURCES += \ - resources/images.qrc diff --git a/tileset.cpp b/tileset.cpp deleted file mode 100755 index 3a03ca30..00000000 --- a/tileset.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include "tileset.h" -#include "project.h" - -#include -#include -#include - -Tileset::Tileset() -{ - -} - -Metatile::Metatile() -{ - tiles = new QList; -} - -QImage Metatile::getMetatileImage(int tile, Tileset *primaryTileset, Tileset *secondaryTileset) { - QImage metatile_image(16, 16, QImage::Format_RGBA8888); - - Metatile* metatile = Metatile::getMetatile(tile, primaryTileset, secondaryTileset); - if (!metatile || !metatile->tiles) { - metatile_image.fill(0xffffffff); - return metatile_image; - } - - Tileset* blockTileset = Metatile::getBlockTileset(tile, primaryTileset, secondaryTileset); - if (!blockTileset) { - metatile_image.fill(0xffffffff); - return metatile_image; - } - QList> palettes = Metatile::getBlockPalettes(primaryTileset, secondaryTileset); - - QPainter metatile_painter(&metatile_image); - for (int layer = 0; layer < 2; layer++) - for (int y = 0; y < 2; y++) - for (int x = 0; x < 2; x++) { - Tile tile_ = metatile->tiles->value((y * 2) + x + (layer * 4)); - QImage tile_image = Metatile::getMetatileTile(tile_.tile, primaryTileset, secondaryTileset); - if (tile_image.isNull()) { - // Some metatiles specify tiles that are outside the valid range. - // These are treated as completely transparent, so they can be skipped without - // being drawn unless they're on the bottom layer, in which case we need - // a placeholder. - if (layer == 0) { - metatile_painter.fillRect(x * 8, y * 8, 8, 8, palettes.value(0).value(0)); - } - continue; - } - - // Colorize the metatile tiles with its palette. - if (tile_.palette < palettes.length()) { - QList palette = palettes.value(tile_.palette); - for (int j = 0; j < palette.length(); j++) { - tile_image.setColor(j, palette.value(j)); - } - } else { - qDebug() << "Tile is referring to invalid palette number: " << tile_.palette; - } - - // The top layer of the metatile has its first color displayed at transparent. - if (layer > 0) { - QColor color(tile_image.color(0)); - color.setAlpha(0); - tile_image.setColor(0, color.rgba()); - } - - QPoint origin = QPoint(x*8, y*8); - metatile_painter.drawImage(origin, tile_image.mirrored(tile_.xflip == 1, tile_.yflip == 1)); - } - metatile_painter.end(); - - return metatile_image; -} - -Metatile* Metatile::getMetatile(int index, Tileset *primaryTileset, Tileset *secondaryTileset) { - Tileset *tileset = Metatile::getBlockTileset(index, primaryTileset, secondaryTileset); - int local_index = Metatile::getBlockIndex(index); - if (!tileset || !tileset->metatiles) { - return nullptr; - } - Metatile *metatile = tileset->metatiles->value(local_index, nullptr); - return metatile; -} - -QImage Metatile::getMetatileTile(int tile, Tileset *primaryTileset, Tileset *secondaryTileset) { - Tileset *tileset = Metatile::getBlockTileset(tile, primaryTileset, secondaryTileset); - int local_index = Metatile::getBlockIndex(tile); - if (!tileset || !tileset->tiles) { - return QImage(); - } - return tileset->tiles->value(local_index, QImage()); -} - -Tileset* Metatile::getBlockTileset(int metatile_index, Tileset *primaryTileset, Tileset *secondaryTileset) { - if (metatile_index < Project::getNumMetatilesPrimary()) { - return primaryTileset; - } else { - return secondaryTileset; - } -} - -int Metatile::getBlockIndex(int index) { - if (index < Project::getNumMetatilesPrimary()) { - return index; - } else { - return index - Project::getNumMetatilesPrimary(); - } -} - -QList> Metatile::getBlockPalettes(Tileset *primaryTileset, Tileset *secondaryTileset) { - QList> palettes; - for (int i = 0; i < Project::getNumPalettesPrimary(); i++) { - palettes.append(primaryTileset->palettes->at(i)); - } - for (int i = Project::getNumPalettesPrimary(); i < Project::getNumPalettesTotal(); i++) { - palettes.append(secondaryTileset->palettes->at(i)); - } - return palettes; -} From 497f069d2082a69c75efced90a924e3bd0855352 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sat, 29 Sep 2018 09:10:23 -0500 Subject: [PATCH 2/4] Restructure source tree --- {src => forms}/eventpropertiesframe.ui | 0 {src => forms}/mainwindow.ui | 0 {src => include}/core/block.h | 0 {src => include}/core/blockdata.h | 0 {src => include}/core/event.h | 0 {src => include}/core/heallocation.h | 0 {src => include}/core/history.h | 0 {src => include}/core/historyitem.h | 0 {src => include}/core/map.h | 0 {src => include}/core/mapconnection.h | 0 {src => include}/core/maplayout.h | 0 {src => include}/core/metatile.h | 0 {src => include}/core/parseutil.h | 0 {src => include}/core/tile.h | 0 {src => include}/core/tileset.h | 0 {src => include}/editor.h | 0 {src => include}/mainwindow.h | 0 {src => include}/project.h | 0 {src => include}/settings.h | 0 .../ui/bordermetatilespixmapitem.h | 0 {src => include}/ui/collisionpixmapitem.h | 0 {src => include}/ui/connectionpixmapitem.h | 0 .../ui/currentselectedmetatilespixmapitem.h | 0 {src => include}/ui/eventpropertiesframe.h | 0 {src => include}/ui/graphicsview.h | 0 {src => include}/ui/imageproviders.h | 0 {src => include}/ui/mappixmapitem.h | 0 {src => include}/ui/mapsceneeventfilter.h | 0 {src => include}/ui/metatileselector.h | 0 .../ui/movementpermissionsselector.h | 0 {src => include}/ui/neweventtoolbutton.h | 0 {src => include}/ui/noscrollcombobox.h | 0 {src => include}/ui/noscrollspinbox.h | 0 {src => include}/ui/selectablepixmapitem.h | 0 porymap.pro | 90 ++++++++++++++++++ {src/resources => resources}/icons/add.ico | Bin {src/resources => resources}/icons/cursor.ico | Bin {src/resources => resources}/icons/delete.ico | Bin .../icons/fill_color.ico | Bin .../icons/fill_color_cursor.ico | Bin {src/resources => resources}/icons/folder.ico | Bin .../icons/folder_closed.ico | Bin .../icons/folder_closed_map.ico | Bin .../icons/folder_image.ico | Bin .../icons/folder_map.ico | Bin {src/resources => resources}/icons/image.ico | Bin {src/resources => resources}/icons/map.ico | Bin {src/resources => resources}/icons/move.ico | Bin {src/resources => resources}/icons/pencil.ico | Bin .../icons/pencil_cursor.ico | Bin .../resources => resources}/icons/pipette.ico | Bin .../icons/pipette_cursor.ico | Bin .../icons/porymap-icon-1.ico | Bin {src/resources => resources}/icons/shift.ico | Bin .../icons/shift_cursor.ico | Bin .../icons/viewsprites.ico | Bin {src/resources => resources}/images.qrc | 0 .../images/Entities_16x16.png | Bin .../images/collisions.png | Bin src/porymap.pro | 89 ----------------- src/ui/mapsceneeventfilter.cpp | 2 +- 61 files changed, 91 insertions(+), 90 deletions(-) rename {src => forms}/eventpropertiesframe.ui (100%) rename {src => forms}/mainwindow.ui (100%) rename {src => include}/core/block.h (100%) rename {src => include}/core/blockdata.h (100%) rename {src => include}/core/event.h (100%) rename {src => include}/core/heallocation.h (100%) rename {src => include}/core/history.h (100%) rename {src => include}/core/historyitem.h (100%) rename {src => include}/core/map.h (100%) rename {src => include}/core/mapconnection.h (100%) rename {src => include}/core/maplayout.h (100%) rename {src => include}/core/metatile.h (100%) rename {src => include}/core/parseutil.h (100%) rename {src => include}/core/tile.h (100%) rename {src => include}/core/tileset.h (100%) rename {src => include}/editor.h (100%) rename {src => include}/mainwindow.h (100%) rename {src => include}/project.h (100%) rename {src => include}/settings.h (100%) rename {src => include}/ui/bordermetatilespixmapitem.h (100%) rename {src => include}/ui/collisionpixmapitem.h (100%) rename {src => include}/ui/connectionpixmapitem.h (100%) rename {src => include}/ui/currentselectedmetatilespixmapitem.h (100%) rename {src => include}/ui/eventpropertiesframe.h (100%) rename {src => include}/ui/graphicsview.h (100%) rename {src => include}/ui/imageproviders.h (100%) rename {src => include}/ui/mappixmapitem.h (100%) rename {src => include}/ui/mapsceneeventfilter.h (100%) rename {src => include}/ui/metatileselector.h (100%) rename {src => include}/ui/movementpermissionsselector.h (100%) rename {src => include}/ui/neweventtoolbutton.h (100%) rename {src => include}/ui/noscrollcombobox.h (100%) rename {src => include}/ui/noscrollspinbox.h (100%) rename {src => include}/ui/selectablepixmapitem.h (100%) create mode 100644 porymap.pro rename {src/resources => resources}/icons/add.ico (100%) rename {src/resources => resources}/icons/cursor.ico (100%) rename {src/resources => resources}/icons/delete.ico (100%) rename {src/resources => resources}/icons/fill_color.ico (100%) rename {src/resources => resources}/icons/fill_color_cursor.ico (100%) rename {src/resources => resources}/icons/folder.ico (100%) rename {src/resources => resources}/icons/folder_closed.ico (100%) rename {src/resources => resources}/icons/folder_closed_map.ico (100%) rename {src/resources => resources}/icons/folder_image.ico (100%) rename {src/resources => resources}/icons/folder_map.ico (100%) rename {src/resources => resources}/icons/image.ico (100%) rename {src/resources => resources}/icons/map.ico (100%) rename {src/resources => resources}/icons/move.ico (100%) rename {src/resources => resources}/icons/pencil.ico (100%) rename {src/resources => resources}/icons/pencil_cursor.ico (100%) rename {src/resources => resources}/icons/pipette.ico (100%) rename {src/resources => resources}/icons/pipette_cursor.ico (100%) rename {src/resources => resources}/icons/porymap-icon-1.ico (100%) rename {src/resources => resources}/icons/shift.ico (100%) rename {src/resources => resources}/icons/shift_cursor.ico (100%) rename {src/resources => resources}/icons/viewsprites.ico (100%) rename {src/resources => resources}/images.qrc (100%) rename {src/resources => resources}/images/Entities_16x16.png (100%) rename {src/resources => resources}/images/collisions.png (100%) delete mode 100644 src/porymap.pro diff --git a/src/eventpropertiesframe.ui b/forms/eventpropertiesframe.ui similarity index 100% rename from src/eventpropertiesframe.ui rename to forms/eventpropertiesframe.ui diff --git a/src/mainwindow.ui b/forms/mainwindow.ui similarity index 100% rename from src/mainwindow.ui rename to forms/mainwindow.ui diff --git a/src/core/block.h b/include/core/block.h similarity index 100% rename from src/core/block.h rename to include/core/block.h diff --git a/src/core/blockdata.h b/include/core/blockdata.h similarity index 100% rename from src/core/blockdata.h rename to include/core/blockdata.h diff --git a/src/core/event.h b/include/core/event.h similarity index 100% rename from src/core/event.h rename to include/core/event.h diff --git a/src/core/heallocation.h b/include/core/heallocation.h similarity index 100% rename from src/core/heallocation.h rename to include/core/heallocation.h diff --git a/src/core/history.h b/include/core/history.h similarity index 100% rename from src/core/history.h rename to include/core/history.h diff --git a/src/core/historyitem.h b/include/core/historyitem.h similarity index 100% rename from src/core/historyitem.h rename to include/core/historyitem.h diff --git a/src/core/map.h b/include/core/map.h similarity index 100% rename from src/core/map.h rename to include/core/map.h diff --git a/src/core/mapconnection.h b/include/core/mapconnection.h similarity index 100% rename from src/core/mapconnection.h rename to include/core/mapconnection.h diff --git a/src/core/maplayout.h b/include/core/maplayout.h similarity index 100% rename from src/core/maplayout.h rename to include/core/maplayout.h diff --git a/src/core/metatile.h b/include/core/metatile.h similarity index 100% rename from src/core/metatile.h rename to include/core/metatile.h diff --git a/src/core/parseutil.h b/include/core/parseutil.h similarity index 100% rename from src/core/parseutil.h rename to include/core/parseutil.h diff --git a/src/core/tile.h b/include/core/tile.h similarity index 100% rename from src/core/tile.h rename to include/core/tile.h diff --git a/src/core/tileset.h b/include/core/tileset.h similarity index 100% rename from src/core/tileset.h rename to include/core/tileset.h diff --git a/src/editor.h b/include/editor.h similarity index 100% rename from src/editor.h rename to include/editor.h diff --git a/src/mainwindow.h b/include/mainwindow.h similarity index 100% rename from src/mainwindow.h rename to include/mainwindow.h diff --git a/src/project.h b/include/project.h similarity index 100% rename from src/project.h rename to include/project.h diff --git a/src/settings.h b/include/settings.h similarity index 100% rename from src/settings.h rename to include/settings.h diff --git a/src/ui/bordermetatilespixmapitem.h b/include/ui/bordermetatilespixmapitem.h similarity index 100% rename from src/ui/bordermetatilespixmapitem.h rename to include/ui/bordermetatilespixmapitem.h diff --git a/src/ui/collisionpixmapitem.h b/include/ui/collisionpixmapitem.h similarity index 100% rename from src/ui/collisionpixmapitem.h rename to include/ui/collisionpixmapitem.h diff --git a/src/ui/connectionpixmapitem.h b/include/ui/connectionpixmapitem.h similarity index 100% rename from src/ui/connectionpixmapitem.h rename to include/ui/connectionpixmapitem.h diff --git a/src/ui/currentselectedmetatilespixmapitem.h b/include/ui/currentselectedmetatilespixmapitem.h similarity index 100% rename from src/ui/currentselectedmetatilespixmapitem.h rename to include/ui/currentselectedmetatilespixmapitem.h diff --git a/src/ui/eventpropertiesframe.h b/include/ui/eventpropertiesframe.h similarity index 100% rename from src/ui/eventpropertiesframe.h rename to include/ui/eventpropertiesframe.h diff --git a/src/ui/graphicsview.h b/include/ui/graphicsview.h similarity index 100% rename from src/ui/graphicsview.h rename to include/ui/graphicsview.h diff --git a/src/ui/imageproviders.h b/include/ui/imageproviders.h similarity index 100% rename from src/ui/imageproviders.h rename to include/ui/imageproviders.h diff --git a/src/ui/mappixmapitem.h b/include/ui/mappixmapitem.h similarity index 100% rename from src/ui/mappixmapitem.h rename to include/ui/mappixmapitem.h diff --git a/src/ui/mapsceneeventfilter.h b/include/ui/mapsceneeventfilter.h similarity index 100% rename from src/ui/mapsceneeventfilter.h rename to include/ui/mapsceneeventfilter.h diff --git a/src/ui/metatileselector.h b/include/ui/metatileselector.h similarity index 100% rename from src/ui/metatileselector.h rename to include/ui/metatileselector.h diff --git a/src/ui/movementpermissionsselector.h b/include/ui/movementpermissionsselector.h similarity index 100% rename from src/ui/movementpermissionsselector.h rename to include/ui/movementpermissionsselector.h diff --git a/src/ui/neweventtoolbutton.h b/include/ui/neweventtoolbutton.h similarity index 100% rename from src/ui/neweventtoolbutton.h rename to include/ui/neweventtoolbutton.h diff --git a/src/ui/noscrollcombobox.h b/include/ui/noscrollcombobox.h similarity index 100% rename from src/ui/noscrollcombobox.h rename to include/ui/noscrollcombobox.h diff --git a/src/ui/noscrollspinbox.h b/include/ui/noscrollspinbox.h similarity index 100% rename from src/ui/noscrollspinbox.h rename to include/ui/noscrollspinbox.h diff --git a/src/ui/selectablepixmapitem.h b/include/ui/selectablepixmapitem.h similarity index 100% rename from src/ui/selectablepixmapitem.h rename to include/ui/selectablepixmapitem.h diff --git a/porymap.pro b/porymap.pro new file mode 100644 index 00000000..665b5c19 --- /dev/null +++ b/porymap.pro @@ -0,0 +1,90 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2016-08-31T15:19:13 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = porymap +TEMPLATE = app +RC_ICONS = resources/icons/porymap-icon-1.ico +ICON = resources/icons/porymap-icon-1.ico + + +SOURCES += src/core/block.cpp \ + src/core/blockdata.cpp \ + src/core/event.cpp \ + src/core/heallocation.cpp \ + src/core/historyitem.cpp \ + src/core/map.cpp \ + src/core/maplayout.cpp \ + src/core/metatile.cpp \ + src/core/parseutil.cpp \ + src/core/tile.cpp \ + src/core/tileset.cpp \ + src/ui/bordermetatilespixmapitem.cpp \ + src/ui/collisionpixmapitem.cpp \ + src/ui/connectionpixmapitem.cpp \ + src/ui/currentselectedmetatilespixmapitem.cpp \ + src/ui/eventpropertiesframe.cpp \ + src/ui/graphicsview.cpp \ + src/ui/imageproviders.cpp \ + src/ui/mappixmapitem.cpp \ + src/ui/mapsceneeventfilter.cpp \ + src/ui/metatileselector.cpp \ + src/ui/movementpermissionsselector.cpp \ + src/ui/neweventtoolbutton.cpp \ + src/ui/noscrollcombobox.cpp \ + src/ui/noscrollspinbox.cpp \ + src/ui/selectablepixmapitem.cpp \ + src/editor.cpp \ + src/main.cpp \ + src/mainwindow.cpp \ + src/project.cpp \ + src/settings.cpp + +HEADERS += include/core/block.h \ + include/core/blockdata.h \ + include/core/event.h \ + include/core/heallocation.h \ + include/core/history.h \ + include/core/historyitem.h \ + include/core/map.h \ + include/core/mapconnection.h \ + include/core/maplayout.h \ + include/core/metatile.h \ + include/core/parseutil.h \ + include/core/tile.h \ + include/core/tileset.h \ + include/ui/bordermetatilespixmapitem.h \ + include/ui/collisionpixmapitem.h \ + include/ui/connectionpixmapitem.h \ + include/ui/currentselectedmetatilespixmapitem.h \ + include/ui/eventpropertiesframe.h \ + include/ui/graphicsview.h \ + include/ui/imageproviders.h \ + include/ui/mappixmapitem.h \ + include/ui/mapsceneeventfilter.h \ + include/ui/metatileselector.h \ + include/ui/movementpermissionsselector.h \ + include/ui/neweventtoolbutton.h \ + include/ui/noscrollcombobox.h \ + include/ui/noscrollspinbox.h \ + include/ui/selectablepixmapitem.h \ + include/editor.h \ + include/mainwindow.h \ + include/project.h \ + include/settings.h + +FORMS += forms/mainwindow.ui \ + forms/eventpropertiesframe.ui + +RESOURCES += \ + resources/images.qrc + +INCLUDEPATH += include +INCLUDEPATH += include/core +INCLUDEPATH += include/ui diff --git a/src/resources/icons/add.ico b/resources/icons/add.ico similarity index 100% rename from src/resources/icons/add.ico rename to resources/icons/add.ico diff --git a/src/resources/icons/cursor.ico b/resources/icons/cursor.ico similarity index 100% rename from src/resources/icons/cursor.ico rename to resources/icons/cursor.ico diff --git a/src/resources/icons/delete.ico b/resources/icons/delete.ico similarity index 100% rename from src/resources/icons/delete.ico rename to resources/icons/delete.ico diff --git a/src/resources/icons/fill_color.ico b/resources/icons/fill_color.ico similarity index 100% rename from src/resources/icons/fill_color.ico rename to resources/icons/fill_color.ico diff --git a/src/resources/icons/fill_color_cursor.ico b/resources/icons/fill_color_cursor.ico similarity index 100% rename from src/resources/icons/fill_color_cursor.ico rename to resources/icons/fill_color_cursor.ico diff --git a/src/resources/icons/folder.ico b/resources/icons/folder.ico similarity index 100% rename from src/resources/icons/folder.ico rename to resources/icons/folder.ico diff --git a/src/resources/icons/folder_closed.ico b/resources/icons/folder_closed.ico similarity index 100% rename from src/resources/icons/folder_closed.ico rename to resources/icons/folder_closed.ico diff --git a/src/resources/icons/folder_closed_map.ico b/resources/icons/folder_closed_map.ico similarity index 100% rename from src/resources/icons/folder_closed_map.ico rename to resources/icons/folder_closed_map.ico diff --git a/src/resources/icons/folder_image.ico b/resources/icons/folder_image.ico similarity index 100% rename from src/resources/icons/folder_image.ico rename to resources/icons/folder_image.ico diff --git a/src/resources/icons/folder_map.ico b/resources/icons/folder_map.ico similarity index 100% rename from src/resources/icons/folder_map.ico rename to resources/icons/folder_map.ico diff --git a/src/resources/icons/image.ico b/resources/icons/image.ico similarity index 100% rename from src/resources/icons/image.ico rename to resources/icons/image.ico diff --git a/src/resources/icons/map.ico b/resources/icons/map.ico similarity index 100% rename from src/resources/icons/map.ico rename to resources/icons/map.ico diff --git a/src/resources/icons/move.ico b/resources/icons/move.ico similarity index 100% rename from src/resources/icons/move.ico rename to resources/icons/move.ico diff --git a/src/resources/icons/pencil.ico b/resources/icons/pencil.ico similarity index 100% rename from src/resources/icons/pencil.ico rename to resources/icons/pencil.ico diff --git a/src/resources/icons/pencil_cursor.ico b/resources/icons/pencil_cursor.ico similarity index 100% rename from src/resources/icons/pencil_cursor.ico rename to resources/icons/pencil_cursor.ico diff --git a/src/resources/icons/pipette.ico b/resources/icons/pipette.ico similarity index 100% rename from src/resources/icons/pipette.ico rename to resources/icons/pipette.ico diff --git a/src/resources/icons/pipette_cursor.ico b/resources/icons/pipette_cursor.ico similarity index 100% rename from src/resources/icons/pipette_cursor.ico rename to resources/icons/pipette_cursor.ico diff --git a/src/resources/icons/porymap-icon-1.ico b/resources/icons/porymap-icon-1.ico similarity index 100% rename from src/resources/icons/porymap-icon-1.ico rename to resources/icons/porymap-icon-1.ico diff --git a/src/resources/icons/shift.ico b/resources/icons/shift.ico similarity index 100% rename from src/resources/icons/shift.ico rename to resources/icons/shift.ico diff --git a/src/resources/icons/shift_cursor.ico b/resources/icons/shift_cursor.ico similarity index 100% rename from src/resources/icons/shift_cursor.ico rename to resources/icons/shift_cursor.ico diff --git a/src/resources/icons/viewsprites.ico b/resources/icons/viewsprites.ico similarity index 100% rename from src/resources/icons/viewsprites.ico rename to resources/icons/viewsprites.ico diff --git a/src/resources/images.qrc b/resources/images.qrc similarity index 100% rename from src/resources/images.qrc rename to resources/images.qrc diff --git a/src/resources/images/Entities_16x16.png b/resources/images/Entities_16x16.png similarity index 100% rename from src/resources/images/Entities_16x16.png rename to resources/images/Entities_16x16.png diff --git a/src/resources/images/collisions.png b/resources/images/collisions.png similarity index 100% rename from src/resources/images/collisions.png rename to resources/images/collisions.png diff --git a/src/porymap.pro b/src/porymap.pro deleted file mode 100644 index 2bfd2dcc..00000000 --- a/src/porymap.pro +++ /dev/null @@ -1,89 +0,0 @@ -#------------------------------------------------- -# -# Project created by QtCreator 2016-08-31T15:19:13 -# -#------------------------------------------------- - -QT += core gui - -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -TARGET = porymap -TEMPLATE = app -RC_ICONS = resources/icons/porymap-icon-1.ico -ICON = resources/icons/porymap-icon-1.ico - - -SOURCES += core/block.cpp \ - core/blockdata.cpp \ - core/event.cpp \ - core/heallocation.cpp \ - core/historyitem.cpp \ - core/map.cpp \ - core/maplayout.cpp \ - core/metatile.cpp \ - core/parseutil.cpp \ - core/tile.cpp \ - core/tileset.cpp \ - ui/bordermetatilespixmapitem.cpp \ - ui/collisionpixmapitem.cpp \ - ui/connectionpixmapitem.cpp \ - ui/currentselectedmetatilespixmapitem.cpp \ - ui/eventpropertiesframe.cpp \ - ui/graphicsview.cpp \ - ui/imageproviders.cpp \ - ui/mappixmapitem.cpp \ - ui/metatileselector.cpp \ - ui/movementpermissionsselector.cpp \ - ui/neweventtoolbutton.cpp \ - ui/noscrollcombobox.cpp \ - ui/noscrollspinbox.cpp \ - ui/selectablepixmapitem.cpp \ - editor.cpp \ - main.cpp \ - mainwindow.cpp \ - project.cpp \ - settings.cpp \ - ui/mapsceneeventfilter.cpp - -HEADERS += core/block.h \ - core/blockdata.h \ - core/event.h \ - core/heallocation.h \ - core/history.h \ - core/historyitem.h \ - core/map.h \ - core/mapconnection.h \ - core/maplayout.h \ - core/metatile.h \ - core/parseutil.h \ - core/tile.h \ - core/tileset.h \ - ui/bordermetatilespixmapitem.h \ - ui/collisionpixmapitem.h \ - ui/connectionpixmapitem.h \ - ui/currentselectedmetatilespixmapitem.h \ - ui/eventpropertiesframe.h \ - ui/graphicsview.h \ - ui/imageproviders.h \ - ui/mappixmapitem.h \ - ui/metatileselector.h \ - ui/movementpermissionsselector.h \ - ui/neweventtoolbutton.h \ - ui/noscrollcombobox.h \ - ui/noscrollspinbox.h \ - ui/selectablepixmapitem.h \ - editor.h \ - mainwindow.h \ - project.h \ - settings.h \ - ui/mapsceneeventfilter.h - -FORMS += mainwindow.ui \ - eventpropertiesframe.ui - -RESOURCES += \ - resources/images.qrc - -INCLUDEPATH += core -INCLUDEPATH += ui diff --git a/src/ui/mapsceneeventfilter.cpp b/src/ui/mapsceneeventfilter.cpp index 4c53e614..f8ae14cb 100644 --- a/src/ui/mapsceneeventfilter.cpp +++ b/src/ui/mapsceneeventfilter.cpp @@ -7,7 +7,7 @@ MapSceneEventFilter::MapSceneEventFilter(QObject *parent) : QObject(parent) } -bool MapSceneEventFilter::eventFilter(QObject *obj, QEvent *event) +bool MapSceneEventFilter::eventFilter(QObject*, QEvent *event) { if (event->type() == QEvent::GraphicsSceneWheel) { From 7e6726bef7d3d29292a1113ba284cd76a73fbc31 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sat, 29 Sep 2018 09:13:54 -0500 Subject: [PATCH 3/4] Round zoom number display to 1 decimal place --- src/editor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editor.cpp b/src/editor.cpp index 5dd5222b..23fce69d 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -349,7 +349,7 @@ void Editor::onHoveredMapMetatileChanged(int x, int y) { .arg(x) .arg(y) .arg(QString("%1").arg(tile, 3, 16, QChar('0')).toUpper()) - .arg(QString::number(pow(scale_base, scale_exp)))); + .arg(QString::number(pow(scale_base, scale_exp), 'g', 2))); } } From fe12e0bde52caf590bd3a579cae0d4fa7851f230 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Sat, 29 Sep 2018 09:22:50 -0500 Subject: [PATCH 4/4] Scroll map list to current map --- include/mainwindow.h | 3 ++- src/mainwindow.cpp | 15 +++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/include/mainwindow.h b/include/mainwindow.h index b836b744..7dd7c773 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -127,9 +127,10 @@ private: Ui::MainWindow *ui; QStandardItemModel *mapListModel; QList *mapGroupsModel; + QMap mapListIndexes; Editor *editor = nullptr; QIcon* mapIcon; - void setMap(QString); + void setMap(QString, bool scrollTreeView = false); void redrawMapScene(); void loadDataStructures(); void populateMapList(); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index f5ccda64..70d875f3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -110,7 +110,7 @@ void MainWindow::openProject(QString dir) { setWindowTitle(editor->project->getProjectTitle()); loadDataStructures(); populateMapList(); - setMap(getDefaultMap()); + setMap(getDefaultMap(), true); } else { setWindowTitle(editor->project->getProjectTitle()); loadDataStructures(); @@ -175,7 +175,7 @@ void MainWindow::on_action_Open_Project_triggered() } } -void MainWindow::setMap(QString map_name) { +void MainWindow::setMap(QString map_name, bool scrollTreeView) { qDebug() << QString("setMap(%1)").arg(map_name); if (map_name.isNull()) { return; @@ -184,6 +184,11 @@ void MainWindow::setMap(QString map_name) { redrawMapScene(); displayMapProperties(); + if (scrollTreeView) { + ui->mapList->setCurrentIndex(mapListIndexes.value(map_name)); + ui->mapList->scrollTo(ui->mapList->currentIndex(), QAbstractItemView::PositionAtCenter); + } + setWindowTitle(map_name + " - " + editor->project->getProjectTitle()); connect(editor->map, SIGNAL(mapChanged(Map*)), this, SLOT(onMapChanged(Map *))); @@ -248,7 +253,7 @@ void MainWindow::openWarpMap(QString map_name, QString warp_num) { } // Open the destination map, and select the target warp event. - setMap(map_name); + setMap(map_name, true); QList warp_events = editor->map->events["warp_event_group"]; if (warp_events.length() > warpNum) { Event *warp_event = warp_events.at(warpNum); @@ -450,6 +455,7 @@ void MainWindow::populateMapList() { QString map_name = names.value(j); QStandardItem *map = createMapItem(map_name, i, j); group->appendRow(map); + mapListIndexes.insert(map_name, map->index()); } } @@ -512,6 +518,7 @@ void MainWindow::onAddNewMapToGroupClick(QAction* triggeredAction) int numMapsInGroup = groupItem->rowCount(); QStandardItem *newMapItem = createMapItem(newMapName, groupNum, numMapsInGroup); groupItem->appendRow(newMapItem); + mapListIndexes.insert(newMapName, newMapItem->index()); setMap(newMapName); } @@ -1083,7 +1090,7 @@ void MainWindow::checkToolButtons() { } void MainWindow::onLoadMapRequested(QString mapName, QString fromMapName) { - setMap(mapName); + setMap(mapName, true); editor->setSelectedConnectionFromMap(fromMapName); }