Browse Source

object selector

Laserlicht 5 months ago
parent
commit
9c101af161

+ 4 - 0
lib/rmg/ObjectConfig.h

@@ -16,6 +16,10 @@ VCMI_LIB_NAMESPACE_BEGIN
 
 class DLL_LINKAGE ObjectConfig
 {
+#ifdef ENABLE_TEMPLATE_EDITOR
+	friend class ObjectSelector;
+#endif
+
 public:
 
 	enum class EObjectCategory

+ 3 - 0
mapeditor/CMakeLists.txt

@@ -61,6 +61,7 @@ if(ENABLE_TEMPLATE_EDITOR)
 		templateeditor/factionselector.cpp
 		templateeditor/mineselector.cpp
 		templateeditor/treasureselector.cpp
+		templateeditor/objectselector.cpp
 	)
 endif()
 
@@ -128,6 +129,7 @@ if(ENABLE_TEMPLATE_EDITOR)
 		templateeditor/factionselector.h
 		templateeditor/mineselector.h
 		templateeditor/treasureselector.h
+		templateeditor/objectselector.h
 	)
 endif()
 
@@ -173,6 +175,7 @@ if(ENABLE_TEMPLATE_EDITOR)
 		templateeditor/factionselector.ui
 		templateeditor/mineselector.ui
 		templateeditor/treasureselector.ui
+		templateeditor/objectselector.ui
 	)
 endif()
 

+ 44 - 0
mapeditor/templateeditor/objectselector.h

@@ -0,0 +1,44 @@
+/*
+ * objectselector.h, part of VCMI engine
+ *
+ * Authors: listed in file AUTHORS in main folder
+ *
+ * License: GNU General Public License v2.0 or later
+ * Full text of license available in license.txt file, in main folder
+ *
+ */
+#pragma once
+#include <QWidget>
+
+#include "../StdInc.h"
+#include "../../lib/rmg/CRmgTemplate.h"
+
+namespace Ui {
+class ObjectSelector;
+}
+
+class ObjectSelector : public QDialog
+{
+	Q_OBJECT
+
+public:
+	explicit ObjectSelector(ObjectConfig & obj);
+
+	static void showObjectSelector(ObjectConfig & obj);
+
+private slots:
+	void on_buttonBoxResult_accepted();
+    void on_buttonBoxResult_rejected();
+
+private:
+	Ui::ObjectSelector *ui;
+
+	ObjectConfig & obj;
+
+	void fillBannedObjectCategories();
+	void getBannedObjectCategories();
+	void fillBannedObjects();
+	void getBannedObjects();
+	void fillCustomObjects();
+	void getCustomObjects();
+};

+ 58 - 0
mapeditor/templateeditor/objectselector.ui

@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ObjectSelector</class>
+ <widget class="QDialog" name="ObjectSelector">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>600</width>
+    <height>480</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Select Objects</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QLabel" name="labelObjects">
+     <property name="text">
+      <string>Objects</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QTableWidget" name="tableWidgetObjects"/>
+   </item>
+   <item>
+    <widget class="QLabel" name="labelBannedObjects">
+     <property name="text">
+      <string>Banned Objects</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QTableWidget" name="tableWidgetBannedObjects"/>
+   </item>
+   <item>
+    <widget class="QLabel" name="labelBannedObjectCategories">
+     <property name="text">
+      <string>Banned Object Categories</string>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QTableWidget" name="tableWidgetBannedObjectCategories"/>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBoxResult">
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>

+ 2 - 2
mapeditor/templateeditor/templateeditor.cpp

@@ -16,6 +16,7 @@
 #include "factionselector.h"
 #include "mineselector.h"
 #include "treasureselector.h"
+#include "objectselector.h"
 #include "GeometryAlgorithm.h"
 
 #include "../helper.h"
@@ -1059,6 +1060,5 @@ void TemplateEditor::on_pushButtonMines_clicked()
 
 void TemplateEditor::on_pushButtonCustomObjects_clicked()
 {
-	//TODO: Implement dialog
-	QMessageBox::critical(this, tr("Error"), tr("Not implemented yet!"));
+	ObjectSelector::showObjectSelector(templates[selectedTemplate]->getZones().at(selectedZone)->objectConfig);
 }