mainwindow.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #pragma once
  2. #include <QMainWindow>
  3. #include <QGraphicsScene>
  4. #include <QStandardItemModel>
  5. #include "mapcontroller.h"
  6. #include "../lib/Terrain.h"
  7. #include "resourceExtractor/ResourceConverter.h"
  8. class ObjectBrowser;
  9. class ObjectBrowserProxyModel;
  10. VCMI_LIB_NAMESPACE_BEGIN
  11. class CMap;
  12. class CGObjectInstance;
  13. VCMI_LIB_NAMESPACE_END
  14. namespace Ui
  15. {
  16. class MainWindow;
  17. const QString teamName = "VCMI Team";
  18. const QString appName = "VCMI Map Editor";
  19. }
  20. class MainWindow : public QMainWindow
  21. {
  22. Q_OBJECT
  23. const QString mainWindowSizeSetting = "MainWindow/Size";
  24. const QString mainWindowPositionSetting = "MainWindow/Position";
  25. public:
  26. explicit MainWindow(QWidget *parent = nullptr);
  27. ~MainWindow();
  28. void initializeMap(bool isNew);
  29. void saveMap();
  30. bool openMap(const QString &);
  31. MapView * mapView();
  32. void loadObjectsTree();
  33. void setStatusMessage(const QString & status);
  34. int getMapLevel() const {return mapLevel;}
  35. MapController controller;
  36. private slots:
  37. void on_actionOpen_triggered();
  38. void on_actionSave_as_triggered();
  39. void on_actionNew_triggered();
  40. void on_actionLevel_triggered();
  41. void on_actionSave_triggered();
  42. void on_actionErase_triggered();
  43. void on_actionUndo_triggered();
  44. void on_actionRedo_triggered();
  45. void on_actionPass_triggered(bool checked);
  46. void on_actionGrid_triggered(bool checked);
  47. void on_toolBrush_clicked(bool checked);
  48. void on_toolArea_clicked(bool checked);
  49. void terrainButtonClicked(TerrainId terrain);
  50. void roadOrRiverButtonClicked(ui8 type, bool isRoad);
  51. void on_toolErase_clicked();
  52. void on_terrainFilterCombo_currentTextChanged(const QString &arg1);
  53. void on_filter_textChanged(const QString &arg1);
  54. void on_actionFill_triggered();
  55. void on_toolBrush2_clicked(bool checked);
  56. void on_toolBrush4_clicked(bool checked);
  57. void on_inspectorWidget_itemChanged(QTableWidgetItem *item);
  58. void on_actionMapSettings_triggered();
  59. void on_actionPlayers_settings_triggered();
  60. void on_actionValidate_triggered();
  61. void on_actionUpdate_appearance_triggered();
  62. void on_actionRecreate_obstacles_triggered();
  63. void switchDefaultPlayer(const PlayerColor &);
  64. public slots:
  65. void treeViewSelected(const QModelIndex &selected, const QModelIndex &deselected);
  66. void loadInspector(CGObjectInstance * obj, bool switchTab);
  67. void mapChanged();
  68. void enableUndo(bool enable);
  69. void enableRedo(bool enable);
  70. void onSelectionMade(int level, bool anythingSelected);
  71. void onPlayersChanged();
  72. void displayStatus(const QString& message, int timeout = 2000);
  73. private:
  74. void preparePreview(const QModelIndex & index);
  75. void addGroupIntoCatalog(const std::string & groupName, bool staticOnly);
  76. void addGroupIntoCatalog(const std::string & groupName, bool useCustomName, bool staticOnly, int ID);
  77. QAction * getActionPlayer(const PlayerColor &);
  78. void changeBrushState(int idx);
  79. void setTitle();
  80. void closeEvent(QCloseEvent *event) override;
  81. bool getAnswerAboutUnsavedChanges();
  82. void loadUserSettings();
  83. void saveUserSettings();
  84. void parseCommandLine(ExtractionOptions & extractionOptions);
  85. private:
  86. Ui::MainWindow * ui;
  87. ObjectBrowserProxyModel * objectBrowser = nullptr;
  88. QGraphicsScene * scenePreview;
  89. QString filename;
  90. bool unsaved = false;
  91. QStandardItemModel objectsModel;
  92. int mapLevel = 0;
  93. std::set<int> catalog;
  94. // command line options
  95. QString mapFilePath; // FilePath to the H3 or VCMI map to open
  96. };