porymap/include/ui/regionmapeditor.h

149 lines
4.8 KiB
C
Raw Normal View History

#ifndef REGIONMAPEDITOR_H
#define REGIONMAPEDITOR_H
#include "regionmappixmapitem.h"
#include "citymappixmapitem.h"
#include "regionmaplayoutpixmapitem.h"
2019-04-13 02:25:43 +01:00
#include "regionmapentriespixmapitem.h"
#include "regionmap.h"
#include "orderedjson.h"
#include "project.h"
#include <QMainWindow>
#include <QGraphicsSceneMouseEvent>
#include <QCloseEvent>
2019-01-22 20:06:49 +00:00
#include <QResizeEvent>
namespace Ui {
class RegionMapEditor;
}
class RegionMapEditor : public QMainWindow
{
Q_OBJECT
public:
explicit RegionMapEditor(QWidget *parent = 0, Project *pro = nullptr);
~RegionMapEditor();
RegionMap *region_map = nullptr;
tsl::ordered_map<QString, RegionMap *> region_maps;
bool load();
2019-01-28 18:47:20 +00:00
void onRegionMapTileSelectorSelectedTileChanged(unsigned id);
void onRegionMapTileSelectorHoveredTileChanged(unsigned id);
void onRegionMapTileSelectorHoveredTileCleared();
2019-01-28 18:47:20 +00:00
void onRegionMapLayoutSelectedTileChanged(int index);
void onRegionMapLayoutHoveredTileChanged(int index);
void onRegionMapLayoutHoveredTileCleared();
2019-04-13 02:25:43 +01:00
void onRegionMapEntriesSelectedTileChanged(QString) {};
void onRegionMapEntryDragged(int, int);
2019-04-13 02:25:43 +01:00
2022-04-28 18:21:36 +01:00
void resizeTilemap(int width, int height);
2019-01-14 00:27:28 +00:00
QObjectList shortcutableObjects() const;
public slots:
void applyUserShortcuts();
private:
Ui::RegionMapEditor *ui;
Project *project;
poryjson::Json rmConfigJson;
QUndoGroup history;
int currIndex = 0;
unsigned selectedCityTile;
unsigned selectedImageTile;
2019-04-13 02:25:43 +01:00
QString activeEntry;
2019-01-14 00:27:28 +00:00
2019-01-28 18:47:20 +00:00
bool cityMapFirstDraw = true;
bool regionMapFirstDraw = true;
2019-04-13 02:25:43 +01:00
bool entriesFirstDraw = true;
2019-01-22 20:06:49 +00:00
double scaleUpFactor = 2.0;
double initialScale = 30.0;
2019-04-13 02:25:43 +01:00
QGraphicsScene *scene_region_map_image = nullptr;
QGraphicsScene *scene_city_map_image = nullptr;
QGraphicsScene *scene_region_map_layout = nullptr;
QGraphicsScene *scene_region_map_entries = nullptr;
QGraphicsScene *scene_region_map_tiles = nullptr;
QGraphicsScene *scene_city_map_tiles = nullptr;
2019-01-14 00:27:28 +00:00
TilemapTileSelector *mapsquare_selector_item = nullptr;
TilemapTileSelector *city_map_selector_item = nullptr;
2019-04-13 02:25:43 +01:00
RegionMapEntriesPixmapItem *region_map_entries_item = nullptr;
2019-01-14 00:27:28 +00:00
RegionMapLayoutPixmapItem *region_map_layout_item = nullptr;
RegionMapPixmapItem *region_map_item = nullptr;
CityMapPixmapItem *city_map_item = nullptr;
2022-04-28 18:21:36 +01:00
bool saveRegionMap(RegionMap *map);
void saveConfig();
bool loadRegionMapEntries();
bool saveRegionMapEntries();
tsl::ordered_map<QString, MapSectionEntry> region_map_entries;
2022-04-29 01:52:31 +01:00
bool buildConfigDialog();
poryjson::Json configRegionMapDialog();
poryjson::Json buildDefaultJson();
2022-04-29 01:52:31 +01:00
bool verifyConfig(poryjson::Json cfg);
bool modified();
void initShortcuts();
2019-01-14 00:27:28 +00:00
void displayRegionMap();
void displayRegionMapImage();
void displayRegionMapLayout();
2019-04-13 02:25:43 +01:00
void displayRegionMapEntriesImage();
2019-01-14 00:27:28 +00:00
void displayRegionMapLayoutOptions();
2019-01-28 18:47:20 +00:00
void updateRegionMapLayoutOptions(int index);
2019-01-14 00:27:28 +00:00
void displayRegionMapTileSelector();
void updateLayerDisplayed();
2019-04-13 02:25:43 +01:00
void displayRegionMapEntryOptions();
2019-04-13 04:07:00 +01:00
void updateRegionMapEntryOptions(QString);
2022-04-27 21:00:47 +01:00
void setRegionMap(RegionMap *map);
void restoreWindowState();
2019-01-28 18:47:20 +00:00
void closeEvent(QCloseEvent* event);
2019-01-22 20:06:49 +00:00
private slots:
void on_action_RegionMap_Save_triggered();
2022-04-28 18:21:36 +01:00
void on_actionSave_All_triggered();
2019-01-14 00:27:28 +00:00
void on_action_RegionMap_Resize_triggered();
void on_action_RegionMap_ClearImage_triggered();
void on_action_RegionMap_ClearLayout_triggered();
2022-05-06 02:40:13 +01:00
void on_action_RegionMap_ClearEntries_triggered();
void on_action_Swap_triggered();
void on_tabWidget_Region_Map_currentChanged(int);
void on_pushButton_RM_Options_delete_clicked();
2021-02-06 00:43:49 +00:00
void on_comboBox_RM_ConnectedMap_textActivated(const QString &);
void on_comboBox_RM_Entry_MapSection_textActivated(const QString &);
void on_comboBox_regionSelector_textActivated(const QString &);
void on_comboBox_layoutLayer_textActivated(const QString &);
2019-04-13 02:25:43 +01:00
void on_spinBox_RM_Entry_x_valueChanged(int);
void on_spinBox_RM_Entry_y_valueChanged(int);
void on_spinBox_RM_Entry_width_valueChanged(int);
void on_spinBox_RM_Entry_height_valueChanged(int);
void on_pushButton_entryActivate_clicked();
void on_spinBox_RM_LayoutWidth_valueChanged(int);
void on_spinBox_RM_LayoutHeight_valueChanged(int);
void on_spinBox_tilePalette_valueChanged(int);
void on_checkBox_tileHFlip_stateChanged(int);
void on_checkBox_tileVFlip_stateChanged(int);
2019-01-22 20:06:49 +00:00
void on_verticalSlider_Zoom_Map_Image_valueChanged(int);
void on_verticalSlider_Zoom_Image_Tiles_valueChanged(int);
2019-04-13 02:25:43 +01:00
void on_lineEdit_RM_MapName_textEdited(const QString &);
2019-01-28 18:47:20 +00:00
void onHoveredRegionMapTileChanged(int x, int y);
void onHoveredRegionMapTileCleared();
2019-01-28 18:47:20 +00:00
void mouseEvent_region_map(QGraphicsSceneMouseEvent *event, RegionMapPixmapItem *item);
};
#endif // REGIONMAPEDITOR_H