diff --git a/install/games/darkmod.game b/install/games/darkmod.game index 81bc2af10..98844b3ab 100644 --- a/install/games/darkmod.game +++ b/install/games/darkmod.game @@ -175,6 +175,7 @@ The origin of this object in 3D space The classname of this entity. This must be a recognised class defined in one of the DEF files, and governs the overall behaviour of the entity + The displayed name of this entity. This can be arbitrary, but must be unique across the entire map diff --git a/radiant/CMakeLists.txt b/radiant/CMakeLists.txt index bbf981c2d..ceab0f3fa 100644 --- a/radiant/CMakeLists.txt +++ b/radiant/CMakeLists.txt @@ -55,6 +55,7 @@ add_executable(darkradiant ui/einspector/EntityPropertyEditor.cpp ui/einspector/FloatPropertyEditor.cpp ui/einspector/FxPropertyEditor.cpp + ui/einspector/InheritPropertyEditor.cpp ui/einspector/ModelPropertyEditor.cpp ui/einspector/PropertyEditor.cpp ui/einspector/PropertyEditorFactory.cpp diff --git a/radiant/ui/einspector/ClassnamePropertyEditor.h b/radiant/ui/einspector/ClassnamePropertyEditor.h index 1ebbe4346..c8a31e475 100644 --- a/radiant/ui/einspector/ClassnamePropertyEditor.h +++ b/radiant/ui/einspector/ClassnamePropertyEditor.h @@ -9,7 +9,7 @@ namespace ui { /** - * PropertyEditor displaying a single browse button to allow the selection of + * PropertyEditor displaying a browse button to allow the selection of * an EntityClass using the EntityClassChooser dialog. */ class ClassnamePropertyEditor : diff --git a/radiant/ui/einspector/InheritPropertyEditor.cpp b/radiant/ui/einspector/InheritPropertyEditor.cpp new file mode 100644 index 000000000..52cd7983f --- /dev/null +++ b/radiant/ui/einspector/InheritPropertyEditor.cpp @@ -0,0 +1,51 @@ +#include "InheritPropertyEditor.h" +#include "PropertyEditorFactory.h" + +#include "i18n.h" +#include "ientity.h" +#include "ieclass.h" + +#include +#include +#include +#include "wxutil/sourceview/DeclarationSourceView.h" + +#include "wxutil/Bitmap.h" + +namespace ui +{ + +// Main constructor +InheritPropertyEditor::InheritPropertyEditor(wxWindow* parent, IEntitySelection& entities, const ITargetKey::Ptr& key) +: PropertyEditor(entities), + _key(key) +{ + auto mainVBox = new wxPanel(parent, wxID_ANY); + mainVBox->SetSizer(new wxBoxSizer(wxHORIZONTAL)); + + // Register the main widget in the base class + setMainWidget(mainVBox); + + auto showDefinition = new wxButton(mainVBox, wxID_ANY, _("Show Definition...")); + showDefinition->SetBitmap(wxutil::GetLocalBitmap("decl.png")); + showDefinition->Bind(wxEVT_BUTTON, &InheritPropertyEditor::_onShowDefinition, this); + + mainVBox->GetSizer()->Add(showDefinition, 0, wxALIGN_CENTER_VERTICAL | wxALL, 6); +} + +void InheritPropertyEditor::_onShowDefinition(wxCommandEvent& ev) +{ + auto parentClass = _entities.getSharedKeyValue(_key->getFullKey(), true); + auto eclass = GlobalEntityClassManager().findClass(parentClass); + + if (eclass) + { + auto view = new wxutil::DeclarationSourceView(getWidget()); + view->setDeclaration(eclass); + + view->ShowModal(); + view->Destroy(); + } +} + +} // namespace ui diff --git a/radiant/ui/einspector/InheritPropertyEditor.h b/radiant/ui/einspector/InheritPropertyEditor.h new file mode 100644 index 000000000..9fa3d916f --- /dev/null +++ b/radiant/ui/einspector/InheritPropertyEditor.h @@ -0,0 +1,34 @@ +#pragma once + +#include "PropertyEditor.h" + +#include +#include + +namespace ui +{ + +/** + * PropertyEditor displaying a single "Show Definition". + */ +class InheritPropertyEditor : + public PropertyEditor +{ +private: + // Keyvalue to set + ITargetKey::Ptr _key; + +private: + + void _onShowDefinition(wxCommandEvent& ev); + +public: + InheritPropertyEditor(wxWindow* parent, IEntitySelection& entities, const ITargetKey::Ptr& key); + + static Ptr CreateNew(wxWindow* parent, IEntitySelection& entities, const ITargetKey::Ptr& key) + { + return std::make_shared(parent, entities, key); + } +}; + +} diff --git a/radiant/ui/einspector/PropertyEditorFactory.cpp b/radiant/ui/einspector/PropertyEditorFactory.cpp index 3272f403b..7bc3b5d53 100644 --- a/radiant/ui/einspector/PropertyEditorFactory.cpp +++ b/radiant/ui/einspector/PropertyEditorFactory.cpp @@ -13,6 +13,7 @@ #include "ClassnamePropertyEditor.h" #include "AnglePropertyEditor.h" #include "FxPropertyEditor.h" +#include "InheritPropertyEditor.h" #include @@ -47,6 +48,7 @@ void PropertyEditorFactory::registerBuiltinTypes() _peMap["float"] = FloatPropertyEditor::CreateNew; _peMap["model"] = ModelPropertyEditor::CreateNew; _peMap["classname"] = ClassnamePropertyEditor::CreateNew; + _peMap["inherit"] = InheritPropertyEditor::CreateNew; _peMap["angle"] = AnglePropertyEditor::CreateNew; _peMap["fx"] = FxPropertyEditor::CreateNew; diff --git a/tools/msvc/DarkRadiant.vcxproj b/tools/msvc/DarkRadiant.vcxproj index 1b8886146..1a517d9f2 100644 --- a/tools/msvc/DarkRadiant.vcxproj +++ b/tools/msvc/DarkRadiant.vcxproj @@ -243,6 +243,7 @@ + @@ -441,6 +442,7 @@ + diff --git a/tools/msvc/DarkRadiant.vcxproj.filters b/tools/msvc/DarkRadiant.vcxproj.filters index 8e7f0ad1e..cc6c76255 100644 --- a/tools/msvc/DarkRadiant.vcxproj.filters +++ b/tools/msvc/DarkRadiant.vcxproj.filters @@ -718,6 +718,9 @@ src\xyview + + src\ui\einspector + @@ -1443,6 +1446,9 @@ src\xyview + + src\ui\einspector +