diff --git a/radiant/CMakeLists.txt b/radiant/CMakeLists.txt index 8069e3b8c6..23c62f1e99 100644 --- a/radiant/CMakeLists.txt +++ b/radiant/CMakeLists.txt @@ -37,7 +37,6 @@ add_executable(darkradiant ui/common/ImageFileSelector.cpp ui/common/MapPreview.cpp ui/common/ShaderChooser.cpp - ui/common/ShaderSelector.cpp ui/common/TexturePreviewCombo.cpp ui/common/SkinChooser.cpp ui/common/SoundChooser.cpp @@ -96,6 +95,7 @@ add_executable(darkradiant ui/materials/editor/MaterialEditorModule.cpp ui/materials/editor/MaterialPreview.cpp ui/materials/MaterialPopulator.cpp + ui/materials/MaterialSelector.cpp ui/materials/MaterialTreeView.cpp ui/merge/MergeControlDialog.cpp ui/animationpreview/AnimationPreview.cpp diff --git a/radiant/ui/common/DeclarationSelector.h b/radiant/ui/common/DeclarationSelector.h index ef255eb52f..6e594d2b90 100644 --- a/radiant/ui/common/DeclarationSelector.h +++ b/radiant/ui/common/DeclarationSelector.h @@ -10,6 +10,8 @@ namespace ui /** * Common implementation of a declaration selector widget that can be added to a dialog. + * It features a Declaration Tree View with an associated toolbar for favourite management. + * Preview widgets can optionally be appended to the right or the bottom of the tree view. */ class DeclarationSelector : public wxPanel diff --git a/radiant/ui/common/ShaderChooser.cpp b/radiant/ui/common/ShaderChooser.cpp index 4b6b9b9f3f..ef791f3729 100644 --- a/radiant/ui/common/ShaderChooser.cpp +++ b/radiant/ui/common/ShaderChooser.cpp @@ -7,7 +7,7 @@ #include #include -#include "ShaderSelector.h" +#include "../materials/MaterialSelector.h" namespace ui { @@ -18,7 +18,7 @@ namespace ui } // Construct the dialog -ShaderChooser::ShaderChooser(wxWindow* parent, ShaderSelector::TextureFilter filter, wxTextCtrl* targetEntry) : +ShaderChooser::ShaderChooser(wxWindow* parent, MaterialSelector::TextureFilter filter, wxTextCtrl* targetEntry) : wxutil::DialogBase(_(LABEL_TITLE), parent), _targetEntry(targetEntry), _selector(nullptr) @@ -30,7 +30,7 @@ ShaderChooser::ShaderChooser(wxWindow* parent, ShaderSelector::TextureFilter fil wxBoxSizer* dialogVBox = new wxBoxSizer(wxVERTICAL); mainPanel->GetSizer()->Add(dialogVBox, 1, wxEXPAND | wxALL, 12); - _selector = new ShaderSelector(mainPanel, + _selector = new MaterialSelector(mainPanel, std::bind(&ShaderChooser::shaderSelectionChanged, this), filter); if (_targetEntry != nullptr) @@ -43,7 +43,7 @@ ShaderChooser::ShaderChooser(wxWindow* parent, ShaderSelector::TextureFilter fil _selector->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, &ShaderChooser::_onItemActivated, this); - // Pack in the ShaderSelector and buttons panel + // Pack in the MaterialSelector and buttons panel dialogVBox->Add(_selector, 1, wxEXPAND); createButtons(mainPanel, dialogVBox); diff --git a/radiant/ui/common/ShaderChooser.h b/radiant/ui/common/ShaderChooser.h index c84dcc5b49..9941716340 100644 --- a/radiant/ui/common/ShaderChooser.h +++ b/radiant/ui/common/ShaderChooser.h @@ -1,6 +1,6 @@ #pragma once -#include "ui/common/ShaderSelector.h" +#include "ui/materials/MaterialSelector.h" #include "wxutil/WindowPosition.h" #include "wxutil/dialog/DialogBase.h" #include @@ -12,8 +12,8 @@ class Material; namespace ui { -/* A dialog containing a ShaderSelector widget combo and OK/Cancel - * buttons. The ShaderSelector subclass is automatically populated with +/* A dialog containing a MaterialSelector widget combo and OK/Cancel + * buttons. The MaterialSelector subclass is automatically populated with * all shaders matching the "texture/" prefix. */ class ShaderChooser : @@ -22,9 +22,9 @@ class ShaderChooser : // The text entry the chosen texture is written into (can be NULL) wxTextCtrl* _targetEntry; - // The ShaderSelector widget, that contains the actual selection + // The MaterialSelector widget, that contains the actual selection // tools (treeview etc.) - ShaderSelector* _selector; + MaterialSelector* _selector; // The shader name at dialog startup (to allow proper behaviour on cancelling) std::string _initialShader; @@ -43,7 +43,7 @@ class ShaderChooser : * Also, the initially selected shader will be read from * this field at startup. */ - ShaderChooser(wxWindow* parent, ShaderSelector::TextureFilter filter, wxTextCtrl* targetEntry = nullptr); + ShaderChooser(wxWindow* parent, MaterialSelector::TextureFilter filter, wxTextCtrl* targetEntry = nullptr); std::string getSelectedTexture(); diff --git a/radiant/ui/einspector/TexturePropertyEditor.cpp b/radiant/ui/einspector/TexturePropertyEditor.cpp index 9169f23888..002491dcf2 100644 --- a/radiant/ui/einspector/TexturePropertyEditor.cpp +++ b/radiant/ui/einspector/TexturePropertyEditor.cpp @@ -24,7 +24,7 @@ TexturePropertyEditor::TexturePropertyEditor(wxWindow* parent, IEntitySelection& // Browse button callback void TexturePropertyEditor::onBrowseButtonClick() { - auto dialog = new ShaderChooser(getWidget(), ShaderSelector::TextureFilter::Lights); + auto dialog = new ShaderChooser(getWidget(), MaterialSelector::TextureFilter::Lights); dialog->setSelectedTexture(getKeyValue(_key->getFullKey())); diff --git a/radiant/ui/findshader/FindShader.cpp b/radiant/ui/findshader/FindShader.cpp index e646af2dd6..16bbed7594 100644 --- a/radiant/ui/findshader/FindShader.cpp +++ b/radiant/ui/findshader/FindShader.cpp @@ -106,7 +106,7 @@ void FindAndReplaceShader::performReplace() void FindAndReplaceShader::onChooseFind(wxCommandEvent& ev) { // Construct the modal dialog - ShaderChooser* chooser = new ShaderChooser(this, ShaderSelector::TextureFilter::Regular, + ShaderChooser* chooser = new ShaderChooser(this, MaterialSelector::TextureFilter::Regular, findNamedObject(this, "FindReplaceDialogFindEntry")); chooser->ShowModal(); @@ -116,7 +116,7 @@ void FindAndReplaceShader::onChooseFind(wxCommandEvent& ev) void FindAndReplaceShader::onChooseReplace(wxCommandEvent& ev) { // Construct the modal dialog - ShaderChooser* chooser = new ShaderChooser(this, ShaderSelector::TextureFilter::Regular, + ShaderChooser* chooser = new ShaderChooser(this, MaterialSelector::TextureFilter::Regular, findNamedObject(this, "FindReplaceDialogReplaceEntry")); chooser->ShowModal(); diff --git a/radiant/ui/lightinspector/LightInspector.cpp b/radiant/ui/lightinspector/LightInspector.cpp index 598fe10d01..d10ee35855 100644 --- a/radiant/ui/lightinspector/LightInspector.cpp +++ b/radiant/ui/lightinspector/LightInspector.cpp @@ -175,8 +175,8 @@ void LightInspector::setupTextureWidgets() { wxPanel* parent = findNamedObject(this, "LightInspectorChooserPanel"); - _texSelector = new ShaderSelector(parent, std::bind(&LightInspector::shaderSelectionChanged, this), - ShaderSelector::TextureFilter::Lights); + _texSelector = new MaterialSelector(parent, std::bind(&LightInspector::shaderSelectionChanged, this), + MaterialSelector::TextureFilter::Lights); parent->GetSizer()->Add(_texSelector, 1, wxEXPAND); } diff --git a/radiant/ui/lightinspector/LightInspector.h b/radiant/ui/lightinspector/LightInspector.h index 76f47b53bd..777aeb9889 100644 --- a/radiant/ui/lightinspector/LightInspector.h +++ b/radiant/ui/lightinspector/LightInspector.h @@ -2,7 +2,7 @@ #include "icommandsystem.h" #include "iradiant.h" -#include "ui/common/ShaderSelector.h" +#include "ui/materials/MaterialSelector.h" #include "wxutil/window/TransientWindow.h" #include "wxutil/XmlResourceBasedWidget.h" @@ -35,7 +35,7 @@ class LightInspector : bool _isProjected; // Internal widgets - ShaderSelector* _texSelector; + MaterialSelector* _texSelector; wxSlider* _brightnessSlider; // The light entities to edit diff --git a/radiant/ui/common/ShaderSelector.cpp b/radiant/ui/materials/MaterialSelector.cpp similarity index 87% rename from radiant/ui/common/ShaderSelector.cpp rename to radiant/ui/materials/MaterialSelector.cpp index 70b3d33375..93e4ed1c5d 100644 --- a/radiant/ui/common/ShaderSelector.cpp +++ b/radiant/ui/materials/MaterialSelector.cpp @@ -1,4 +1,4 @@ -#include "ShaderSelector.h" +#include "MaterialSelector.h" #include #include @@ -34,10 +34,10 @@ class ThreadedMaterialLoader final : std::vector _prefixes; public: - ThreadedMaterialLoader(const wxutil::DeclarationTreeView::Columns& columns, ShaderSelector::TextureFilter filter) : + ThreadedMaterialLoader(const wxutil::DeclarationTreeView::Columns& columns, MaterialSelector::TextureFilter filter) : ThreadedDeclarationTreePopulator(decl::Type::Material, columns, TEXTURE_ICON) { - if (filter == ShaderSelector::TextureFilter::Lights) + if (filter == MaterialSelector::TextureFilter::Lights) { _prefixes = game::current::getLightTexturePrefixes(); } @@ -75,7 +75,7 @@ class ThreadedMaterialLoader final : } }; -ShaderSelector::ShaderSelector(wxWindow* parent, const std::function& selectionChanged, +MaterialSelector::MaterialSelector(wxWindow* parent, const std::function& selectionChanged, TextureFilter textureFilter) : DeclarationSelector(parent, decl::Type::Material), _textureFilter(textureFilter), @@ -87,12 +87,12 @@ ShaderSelector::ShaderSelector(wxWindow* parent, const std::function& se PopulateTreeView(std::make_shared(GetColumns(), _textureFilter)); } -MaterialPtr ShaderSelector::getSelectedShader() +MaterialPtr MaterialSelector::getSelectedShader() { return GlobalMaterialManager().getMaterial(GetSelectedDeclName()); } -void ShaderSelector::onTreeViewSelectionChanged() +void MaterialSelector::onTreeViewSelectionChanged() { _previewCombo->SetTexture(GetSelectedDeclName()); diff --git a/radiant/ui/common/ShaderSelector.h b/radiant/ui/materials/MaterialSelector.h similarity index 56% rename from radiant/ui/common/ShaderSelector.h rename to radiant/ui/materials/MaterialSelector.h index 1600d03692..bfa02ee739 100644 --- a/radiant/ui/common/ShaderSelector.h +++ b/radiant/ui/materials/MaterialSelector.h @@ -1,9 +1,8 @@ #pragma once #include -#include "DeclarationSelector.h" - -#include "TexturePreviewCombo.h" +#include "../common/DeclarationSelector.h" +#include "../common/TexturePreviewCombo.h" // FORWARD DECLS class Material; @@ -15,18 +14,18 @@ namespace ui { /** - * A widget that allows the selection of a shader. The widget contains - * three elements - a tree view displaying available shaders as - * identified by the specified prefixes, a TexturePreviewComob displaying a - * preview of the currently-selected shader and a table containing certain - * information about the shader. + * A widget that allows the selection of a material. The widget contains + * three elements - a tree view displaying available materials as + * identified by the specified prefixes, a TexturePreviewCombo displaying a + * preview of the currently-selected material and a table containing certain + * information about it. * - * This widget populates its list of shaders automatically, and offers a method + * This widget populates its list of materials automatically, and offers a method * that allows calling code to retrieve the user's selection. The set of - * displayed textures can be defined by passing the corresponding TextureFilter + * displayed materials can be defined by passing the corresponding TextureFilter * value to the constructor. */ -class ShaderSelector : +class MaterialSelector : public DeclarationSelector { public: @@ -49,7 +48,7 @@ class ShaderSelector : * @selectionChanged: Functor invoked when the tree view selection changes. * @filter: which texture set to show in the selector */ - ShaderSelector(wxWindow* parent, const std::function& selectionChanged, TextureFilter filter); + MaterialSelector(wxWindow* parent, const std::function& selectionChanged, TextureFilter filter); // Get the selected Material MaterialPtr getSelectedShader(); diff --git a/radiant/ui/materials/editor/MaterialEditor.cpp b/radiant/ui/materials/editor/MaterialEditor.cpp index 4baa4e5224..f438c5f251 100644 --- a/radiant/ui/materials/editor/MaterialEditor.cpp +++ b/radiant/ui/materials/editor/MaterialEditor.cpp @@ -411,7 +411,7 @@ void MaterialEditor::setupPreviewLightProperties(wxWindow* previewPanel) getControl("MaterialPreviewRoomMaterialButton")->Bind(wxEVT_BUTTON, [this](wxCommandEvent& ev) { auto textCtrl = getControl("MaterialPreviewRoomMaterial"); - auto selector = new ShaderChooser(this, ShaderSelector::TextureFilter::Regular, textCtrl); + auto selector = new ShaderChooser(this, MaterialSelector::TextureFilter::Regular, textCtrl); selector->ShowModal(); selector->Destroy(); }); diff --git a/radiant/ui/surfaceinspector/SurfaceInspector.cpp b/radiant/ui/surfaceinspector/SurfaceInspector.cpp index 7740184408..af57286a2b 100644 --- a/radiant/ui/surfaceinspector/SurfaceInspector.cpp +++ b/radiant/ui/surfaceinspector/SurfaceInspector.cpp @@ -788,7 +788,7 @@ void SurfaceInspector::onShaderSelect(wxCommandEvent& ev) std::string previousShader = _shaderEntry->GetValue().ToStdString(); // Instantiate the modal dialog, will block execution - auto* chooser = new ShaderChooser(this, ShaderSelector::TextureFilter::Regular, _shaderEntry); + auto* chooser = new ShaderChooser(this, MaterialSelector::TextureFilter::Regular, _shaderEntry); chooser->signal_shaderChanged().connect( sigc::mem_fun(this, &SurfaceInspector::emitShader) diff --git a/tools/msvc/DarkRadiant.vcxproj b/tools/msvc/DarkRadiant.vcxproj index b771c1e4b6..4485e6aa77 100644 --- a/tools/msvc/DarkRadiant.vcxproj +++ b/tools/msvc/DarkRadiant.vcxproj @@ -268,6 +268,7 @@ + @@ -291,7 +292,6 @@ - @@ -474,6 +474,7 @@ + @@ -499,7 +500,6 @@ - diff --git a/tools/msvc/DarkRadiant.vcxproj.filters b/tools/msvc/DarkRadiant.vcxproj.filters index 742e6536f4..7a1864e133 100644 --- a/tools/msvc/DarkRadiant.vcxproj.filters +++ b/tools/msvc/DarkRadiant.vcxproj.filters @@ -226,9 +226,6 @@ src\ui\common - - src\ui\common - src\ui\common @@ -709,6 +706,9 @@ src\ui\common + + src\ui\materials + @@ -744,9 +744,6 @@ src\ui\common - - src\ui\common - src\ui\common @@ -1380,6 +1377,9 @@ src\ui\common + + src\ui\materials +