2022-09-24 22:55:05 +02:00
|
|
|
#pragma once
|
2022-09-18 01:23:17 +02:00
|
|
|
|
|
|
|
#include <QMainWindow>
|
|
|
|
#include <QGraphicsScene>
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
#include "mapcontroller.h"
|
2022-11-27 19:14:14 +02:00
|
|
|
#include "resourceExtractor/ResourceConverter.h"
|
2022-09-18 01:23:17 +02:00
|
|
|
|
|
|
|
class ObjectBrowser;
|
2022-12-04 04:45:39 +02:00
|
|
|
class ObjectBrowserProxyModel;
|
2022-12-05 22:28:01 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
class CMap;
|
2022-09-18 01:23:17 +02:00
|
|
|
class CGObjectInstance;
|
2022-12-05 22:28:01 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|
2022-09-18 01:23:17 +02:00
|
|
|
|
|
|
|
namespace Ui
|
|
|
|
{
|
|
|
|
class MainWindow;
|
|
|
|
const QString teamName = "VCMI Team";
|
|
|
|
const QString appName = "VCMI Map Editor";
|
|
|
|
}
|
|
|
|
|
|
|
|
class MainWindow : public QMainWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
const QString mainWindowSizeSetting = "MainWindow/Size";
|
|
|
|
const QString mainWindowPositionSetting = "MainWindow/Position";
|
2024-05-16 00:01:02 +02:00
|
|
|
const QString lastDirectorySetting = "MainWindow/Directory";
|
2022-09-18 01:23:17 +02:00
|
|
|
|
2022-12-26 23:29:42 +02:00
|
|
|
#ifdef ENABLE_QT_TRANSLATIONS
|
|
|
|
QTranslator translator;
|
|
|
|
#endif
|
2023-09-30 03:42:29 +02:00
|
|
|
|
|
|
|
std::unique_ptr<CMap> openMapInternal(const QString &);
|
2022-12-26 23:29:42 +02:00
|
|
|
|
2022-09-18 01:23:17 +02:00
|
|
|
public:
|
|
|
|
explicit MainWindow(QWidget *parent = nullptr);
|
|
|
|
~MainWindow();
|
|
|
|
|
|
|
|
void initializeMap(bool isNew);
|
|
|
|
|
|
|
|
void saveMap();
|
|
|
|
bool openMap(const QString &);
|
|
|
|
|
2023-04-22 18:41:23 +02:00
|
|
|
//MapView * mapView();
|
2022-09-18 01:23:17 +02:00
|
|
|
|
|
|
|
void loadObjectsTree();
|
|
|
|
|
|
|
|
void setStatusMessage(const QString & status);
|
|
|
|
|
|
|
|
int getMapLevel() const {return mapLevel;}
|
|
|
|
|
|
|
|
MapController controller;
|
|
|
|
|
2022-12-26 23:29:42 +02:00
|
|
|
void loadTranslation();
|
|
|
|
|
2022-09-18 01:23:17 +02:00
|
|
|
private slots:
|
2022-10-08 20:55:15 +02:00
|
|
|
void on_actionOpen_triggered();
|
2022-09-18 01:23:17 +02:00
|
|
|
|
|
|
|
void on_actionSave_as_triggered();
|
|
|
|
|
|
|
|
void on_actionNew_triggered();
|
|
|
|
|
|
|
|
void on_actionLevel_triggered();
|
|
|
|
|
|
|
|
void on_actionSave_triggered();
|
|
|
|
|
|
|
|
void on_actionErase_triggered();
|
|
|
|
|
|
|
|
void on_actionUndo_triggered();
|
|
|
|
|
|
|
|
void on_actionRedo_triggered();
|
|
|
|
|
|
|
|
void on_actionPass_triggered(bool checked);
|
|
|
|
|
|
|
|
void on_actionGrid_triggered(bool checked);
|
|
|
|
|
2022-10-08 21:54:45 +02:00
|
|
|
void terrainButtonClicked(TerrainId terrain);
|
2022-10-08 22:11:29 +02:00
|
|
|
void roadOrRiverButtonClicked(ui8 type, bool isRoad);
|
2023-10-08 20:25:59 +02:00
|
|
|
void currentCoordinatesChanged(int x, int y);
|
2022-09-18 01:23:17 +02:00
|
|
|
|
2023-04-10 13:33:53 +02:00
|
|
|
void on_terrainFilterCombo_currentIndexChanged(int index);
|
2022-09-18 01:23:17 +02:00
|
|
|
|
|
|
|
void on_filter_textChanged(const QString &arg1);
|
|
|
|
|
|
|
|
void on_actionFill_triggered();
|
|
|
|
|
|
|
|
void on_inspectorWidget_itemChanged(QTableWidgetItem *item);
|
|
|
|
|
|
|
|
void on_actionMapSettings_triggered();
|
|
|
|
|
|
|
|
void on_actionPlayers_settings_triggered();
|
|
|
|
|
|
|
|
void on_actionValidate_triggered();
|
|
|
|
|
|
|
|
void on_actionUpdate_appearance_triggered();
|
|
|
|
|
|
|
|
void on_actionRecreate_obstacles_triggered();
|
|
|
|
|
|
|
|
void switchDefaultPlayer(const PlayerColor &);
|
|
|
|
|
2022-12-04 23:32:50 +02:00
|
|
|
void on_actionCut_triggered();
|
|
|
|
|
|
|
|
void on_actionCopy_triggered();
|
|
|
|
|
|
|
|
void on_actionPaste_triggered();
|
|
|
|
|
2023-04-22 18:41:23 +02:00
|
|
|
void on_actionExport_triggered();
|
|
|
|
|
2023-09-28 15:29:43 +02:00
|
|
|
void on_actionTranslations_triggered();
|
2023-09-30 03:42:29 +02:00
|
|
|
|
2023-10-01 02:39:03 +02:00
|
|
|
void on_actionh3m_converter_triggered();
|
2023-09-28 15:29:43 +02:00
|
|
|
|
2023-10-13 05:21:09 +02:00
|
|
|
void on_actionLock_triggered();
|
|
|
|
|
|
|
|
void on_actionUnlock_triggered();
|
|
|
|
|
|
|
|
void on_actionZoom_in_triggered();
|
|
|
|
|
|
|
|
void on_actionZoom_out_triggered();
|
|
|
|
|
|
|
|
void on_actionZoom_reset_triggered();
|
|
|
|
|
2023-10-14 02:58:13 +02:00
|
|
|
void on_toolLine_toggled(bool checked);
|
|
|
|
|
|
|
|
void on_toolBrush2_toggled(bool checked);
|
|
|
|
|
|
|
|
void on_toolBrush_toggled(bool checked);
|
|
|
|
|
|
|
|
void on_toolBrush4_toggled(bool checked);
|
|
|
|
|
|
|
|
void on_toolLasso_toggled(bool checked);
|
|
|
|
|
|
|
|
void on_toolArea_toggled(bool checked);
|
|
|
|
|
|
|
|
void on_toolFill_toggled(bool checked);
|
|
|
|
|
|
|
|
void on_toolSelect_toggled(bool checked);
|
|
|
|
|
2022-09-18 01:23:17 +02:00
|
|
|
public slots:
|
|
|
|
|
|
|
|
void treeViewSelected(const QModelIndex &selected, const QModelIndex &deselected);
|
|
|
|
void loadInspector(CGObjectInstance * obj, bool switchTab);
|
|
|
|
void mapChanged();
|
|
|
|
void enableUndo(bool enable);
|
|
|
|
void enableRedo(bool enable);
|
|
|
|
void onSelectionMade(int level, bool anythingSelected);
|
|
|
|
void onPlayersChanged();
|
|
|
|
|
|
|
|
void displayStatus(const QString& message, int timeout = 2000);
|
|
|
|
|
|
|
|
private:
|
2022-12-04 12:51:01 +02:00
|
|
|
void preparePreview(const QModelIndex & index);
|
2022-09-18 01:23:17 +02:00
|
|
|
void addGroupIntoCatalog(const std::string & groupName, bool staticOnly);
|
|
|
|
void addGroupIntoCatalog(const std::string & groupName, bool useCustomName, bool staticOnly, int ID);
|
|
|
|
|
|
|
|
QAction * getActionPlayer(const PlayerColor &);
|
|
|
|
|
|
|
|
void changeBrushState(int idx);
|
|
|
|
void setTitle();
|
|
|
|
|
|
|
|
void closeEvent(QCloseEvent *event) override;
|
|
|
|
|
|
|
|
bool getAnswerAboutUnsavedChanges();
|
|
|
|
|
|
|
|
void loadUserSettings();
|
|
|
|
void saveUserSettings();
|
|
|
|
|
2022-11-27 19:14:14 +02:00
|
|
|
void parseCommandLine(ExtractionOptions & extractionOptions);
|
2022-11-20 18:48:31 +02:00
|
|
|
|
2022-09-18 01:23:17 +02:00
|
|
|
private:
|
2022-09-24 22:55:05 +02:00
|
|
|
Ui::MainWindow * ui;
|
2022-12-04 04:45:39 +02:00
|
|
|
ObjectBrowserProxyModel * objectBrowser = nullptr;
|
2022-09-18 01:23:17 +02:00
|
|
|
QGraphicsScene * scenePreview;
|
|
|
|
|
2024-01-10 00:38:54 +02:00
|
|
|
QString filename;
|
|
|
|
QString lastSavingDir;
|
2022-09-18 01:23:17 +02:00
|
|
|
bool unsaved = false;
|
|
|
|
|
|
|
|
QStandardItemModel objectsModel;
|
|
|
|
|
|
|
|
int mapLevel = 0;
|
2023-10-13 05:21:09 +02:00
|
|
|
QRectF initialScale;
|
2022-09-18 01:23:17 +02:00
|
|
|
|
|
|
|
std::set<int> catalog;
|
2022-11-20 18:48:31 +02:00
|
|
|
|
|
|
|
// command line options
|
|
|
|
QString mapFilePath; // FilePath to the H3 or VCMI map to open
|
2022-11-24 22:52:31 +02:00
|
|
|
};
|