Skip to content

Commit

Permalink
#5537: Rename ShaderChooser to MaterialChooser and move its file pair…
Browse files Browse the repository at this point in the history
… to ui/materials/ folder
  • Loading branch information
codereader committed Sep 16, 2022
1 parent 72c3302 commit cb7b110
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions install/user.xml
Expand Up @@ -90,9 +90,9 @@
<window xPosition="158" yPosition="241" width="400" height="380"/>
</mergeControlDialog>
<textures>
<shaderChooser>
<materialChooser>
<window xPosition="200" yPosition="100" width="550" height="500" />
</shaderChooser>
</materialChooser>
<browser>
<hideUnused value="0" />
<textureScale value="3" />
Expand Down
2 changes: 1 addition & 1 deletion radiant/CMakeLists.txt
Expand Up @@ -36,7 +36,6 @@ add_executable(darkradiant
ui/common/ImageFilePopulator.cpp
ui/common/ImageFileSelector.cpp
ui/common/MapPreview.cpp
ui/common/ShaderChooser.cpp
ui/common/TexturePreviewCombo.cpp
ui/common/SkinChooser.cpp
ui/common/SoundChooser.cpp
Expand Down Expand Up @@ -94,6 +93,7 @@ add_executable(darkradiant
ui/materials/editor/MaterialEditor.cpp
ui/materials/editor/MaterialEditorModule.cpp
ui/materials/editor/MaterialPreview.cpp
ui/materials/MaterialChooser.cpp
ui/materials/MaterialPopulator.cpp
ui/materials/MaterialSelector.cpp
ui/materials/MaterialTreeView.cpp
Expand Down
4 changes: 2 additions & 2 deletions radiant/ui/einspector/TexturePropertyEditor.cpp
@@ -1,5 +1,5 @@
#include "TexturePropertyEditor.h"
#include "ui/common/ShaderChooser.h"
#include "ui/materials/MaterialChooser.h"
#include "PropertyEditorFactory.h"

#include "i18n.h"
Expand All @@ -24,7 +24,7 @@ TexturePropertyEditor::TexturePropertyEditor(wxWindow* parent, IEntitySelection&
// Browse button callback
void TexturePropertyEditor::onBrowseButtonClick()
{
auto dialog = new ShaderChooser(getWidget(), MaterialSelector::TextureFilter::Lights);
auto dialog = new MaterialChooser(getWidget(), MaterialSelector::TextureFilter::Lights);

dialog->setSelectedTexture(getKeyValue(_key->getFullKey()));

Expand Down
6 changes: 3 additions & 3 deletions radiant/ui/findshader/FindShader.cpp
Expand Up @@ -5,7 +5,7 @@
#include "imousetoolmanager.h"
#include "ishaderclipboard.h"

#include "ui/common/ShaderChooser.h"
#include "ui/materials/MaterialChooser.h"
#include "wxutil/dialog/MessageBox.h"
#include "wxutil/MouseButton.h"
#include "wxutil/Modifier.h"
Expand Down Expand Up @@ -106,7 +106,7 @@ void FindAndReplaceShader::performReplace()
void FindAndReplaceShader::onChooseFind(wxCommandEvent& ev)
{
// Construct the modal dialog
ShaderChooser* chooser = new ShaderChooser(this, MaterialSelector::TextureFilter::Regular,
auto chooser = new MaterialChooser(this, MaterialSelector::TextureFilter::Regular,
findNamedObject<wxTextCtrl>(this, "FindReplaceDialogFindEntry"));

chooser->ShowModal();
Expand All @@ -116,7 +116,7 @@ void FindAndReplaceShader::onChooseFind(wxCommandEvent& ev)
void FindAndReplaceShader::onChooseReplace(wxCommandEvent& ev)
{
// Construct the modal dialog
ShaderChooser* chooser = new ShaderChooser(this, MaterialSelector::TextureFilter::Regular,
auto chooser = new MaterialChooser(this, MaterialSelector::TextureFilter::Regular,
findNamedObject<wxTextCtrl>(this, "FindReplaceDialogReplaceEntry"));

chooser->ShowModal();
Expand Down
2 changes: 1 addition & 1 deletion radiant/ui/lightinspector/LightInspector.cpp
Expand Up @@ -20,7 +20,7 @@
#include <wx/radiobut.h>


#include "ui/common/ShaderChooser.h" // for static displayLightInfo() function
#include "ui/materials/MaterialChooser.h" // for static displayLightInfo() function
#include "util/ScopedBoolLock.h"
#include "gamelib.h"

Expand Down
@@ -1,4 +1,4 @@
#include "ShaderChooser.h"
#include "MaterialChooser.h"

#include "i18n.h"
#include "ishaders.h"
Expand All @@ -13,12 +13,12 @@ namespace ui
{
namespace
{
const char* const LABEL_TITLE = N_("Choose Shader");
const std::string RKEY_WINDOW_STATE = "user/ui/textures/shaderChooser/window";
const char* const LABEL_TITLE = N_("Choose Material");
const std::string RKEY_WINDOW_STATE = "user/ui/textures/materialChooser/window";
}

// Construct the dialog
ShaderChooser::ShaderChooser(wxWindow* parent, MaterialSelector::TextureFilter filter, wxTextCtrl* targetEntry) :
MaterialChooser::MaterialChooser(wxWindow* parent, MaterialSelector::TextureFilter filter, wxTextCtrl* targetEntry) :
wxutil::DialogBase(_(LABEL_TITLE), parent),
_targetEntry(targetEntry),
_selector(nullptr)
Expand All @@ -31,7 +31,7 @@ ShaderChooser::ShaderChooser(wxWindow* parent, MaterialSelector::TextureFilter f
mainPanel->GetSizer()->Add(dialogVBox, 1, wxEXPAND | wxALL, 12);

_selector = new MaterialSelector(mainPanel,
std::bind(&ShaderChooser::shaderSelectionChanged, this), filter);
std::bind(&MaterialChooser::shaderSelectionChanged, this), filter);

if (_targetEntry != nullptr)
{
Expand All @@ -41,7 +41,7 @@ ShaderChooser::ShaderChooser(wxWindow* parent, MaterialSelector::TextureFilter f
_selector->SetSelectedDeclName(_initialShader);
}

_selector->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, &ShaderChooser::_onItemActivated, this);
_selector->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, &MaterialChooser::_onItemActivated, this);

// Pack in the MaterialSelector and buttons panel
dialogVBox->Add(_selector, 1, wxEXPAND);
Expand All @@ -55,23 +55,23 @@ ShaderChooser::ShaderChooser(wxWindow* parent, MaterialSelector::TextureFilter f
_windowPosition.applyPosition();
}

std::string ShaderChooser::getSelectedTexture()
std::string MaterialChooser::getSelectedTexture()
{
return _selector->GetSelectedDeclName();
}

void ShaderChooser::setSelectedTexture(const std::string& textureName)
void MaterialChooser::setSelectedTexture(const std::string& textureName)
{
_selector->SetSelectedDeclName(textureName);
}

void ShaderChooser::shutdown()
void MaterialChooser::shutdown()
{
// Tell the position tracker to save the information
_windowPosition.saveToPath(RKEY_WINDOW_STATE);
}

void ShaderChooser::_onItemActivated(wxDataViewEvent& ev)
void MaterialChooser::_onItemActivated(wxDataViewEvent& ev)
{
if (!_selector->GetSelectedDeclName().empty())
{
Expand All @@ -86,23 +86,23 @@ void ShaderChooser::_onItemActivated(wxDataViewEvent& ev)
}

// Construct the buttons
void ShaderChooser::createButtons(wxPanel* mainPanel, wxBoxSizer* dialogVBox)
void MaterialChooser::createButtons(wxPanel* mainPanel, wxBoxSizer* dialogVBox)
{
wxBoxSizer* buttons = new wxBoxSizer(wxHORIZONTAL);

wxButton* okButton = new wxButton(mainPanel, wxID_OK);
wxButton* cancelButton = new wxButton(mainPanel, wxID_CANCEL);

okButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(ShaderChooser::callbackOK), NULL, this);
cancelButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(ShaderChooser::callbackCancel), NULL, this);
okButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(MaterialChooser::callbackOK), NULL, this);
cancelButton->Connect(wxEVT_BUTTON, wxCommandEventHandler(MaterialChooser::callbackCancel), NULL, this);

buttons->Add(okButton);
buttons->Add(cancelButton, 0, wxLEFT, 6);

dialogVBox->Add(buttons, 0, wxALIGN_RIGHT | wxTOP, 6);
}

void ShaderChooser::shaderSelectionChanged()
void MaterialChooser::shaderSelectionChanged()
{
if (_targetEntry)
{
Expand All @@ -113,7 +113,7 @@ void ShaderChooser::shaderSelectionChanged()
_shaderChangedSignal.emit();
}

void ShaderChooser::revertShader()
void MaterialChooser::revertShader()
{
// Revert the shadername to the value it had at dialog startup
if (_targetEntry)
Expand All @@ -125,7 +125,7 @@ void ShaderChooser::revertShader()
}
}

void ShaderChooser::callbackCancel(wxCommandEvent& ev)
void MaterialChooser::callbackCancel(wxCommandEvent& ev)
{
// Revert the shadername to the value it had at dialog startup
revertShader();
Expand All @@ -134,7 +134,7 @@ void ShaderChooser::callbackCancel(wxCommandEvent& ev)
ev.Skip();
}

void ShaderChooser::callbackOK(wxCommandEvent& ev)
void MaterialChooser::callbackOK(wxCommandEvent& ev)
{
if (_targetEntry)
{
Expand Down
Expand Up @@ -16,7 +16,7 @@ namespace ui
* buttons. The MaterialSelector subclass is automatically populated with
* all shaders matching the "texture/" prefix.
*/
class ShaderChooser :
class MaterialChooser :
public wxutil::DialogBase
{
// The text entry the chosen texture is written into (can be NULL)
Expand All @@ -43,7 +43,7 @@ class ShaderChooser :
* Also, the initially selected shader will be read from
* this field at startup.
*/
ShaderChooser(wxWindow* parent, MaterialSelector::TextureFilter filter, wxTextCtrl* targetEntry = nullptr);
MaterialChooser(wxWindow* parent, MaterialSelector::TextureFilter filter, wxTextCtrl* targetEntry = nullptr);

std::string getSelectedTexture();

Expand Down
4 changes: 2 additions & 2 deletions radiant/ui/materials/editor/MaterialEditor.cpp
Expand Up @@ -40,7 +40,7 @@
#include "CheckBoxBinding.h"
#include "MapExpressionEntry.h"
#include "TexturePreview.h"
#include "ui/common/ShaderChooser.h"
#include "../MaterialChooser.h"

namespace ui
{
Expand Down Expand Up @@ -411,7 +411,7 @@ void MaterialEditor::setupPreviewLightProperties(wxWindow* previewPanel)
getControl<wxButton>("MaterialPreviewRoomMaterialButton")->Bind(wxEVT_BUTTON, [this](wxCommandEvent& ev)
{
auto textCtrl = getControl<wxTextCtrl>("MaterialPreviewRoomMaterial");
auto selector = new ShaderChooser(this, MaterialSelector::TextureFilter::Regular, textCtrl);
auto selector = new MaterialChooser(this, MaterialSelector::TextureFilter::Regular, textCtrl);
selector->ShowModal();
selector->Destroy();
});
Expand Down
5 changes: 3 additions & 2 deletions radiant/ui/surfaceinspector/SurfaceInspector.cpp
Expand Up @@ -24,6 +24,7 @@

#include "textool/TexTool.h"
#include "ui/patch/PatchInspector.h"
#include "ui/materials/MaterialChooser.h"

namespace ui
{
Expand Down Expand Up @@ -376,7 +377,7 @@ void SurfaceInspector::populateWindow()
_shaderEntry->Connect(wxEVT_TEXT_ENTER, wxCommandEventHandler(SurfaceInspector::onShaderEntryActivate), NULL, this);
shaderHBox->Add(_shaderEntry, 1, wxEXPAND);

// Create the icon button to open the ShaderChooser
// Create the icon button to open the MaterialChooser
_selectShaderButton = new wxBitmapButton(
this, wxID_ANY, wxutil::GetLocalBitmap(FOLDER_ICON)
);
Expand Down Expand Up @@ -788,7 +789,7 @@ void SurfaceInspector::onShaderSelect(wxCommandEvent& ev)
std::string previousShader = _shaderEntry->GetValue().ToStdString();

// Instantiate the modal dialog, will block execution
auto* chooser = new ShaderChooser(this, MaterialSelector::TextureFilter::Regular, _shaderEntry);
auto* chooser = new MaterialChooser(this, MaterialSelector::TextureFilter::Regular, _shaderEntry);

chooser->signal_shaderChanged().connect(
sigc::mem_fun(this, &SurfaceInspector::emitShader)
Expand Down
1 change: 0 additions & 1 deletion radiant/ui/surfaceinspector/SurfaceInspector.h
Expand Up @@ -6,7 +6,6 @@
#include "iradiant.h"
#include "wxutil/window/TransientWindow.h"
#include "wxutil/FormLayout.h"
#include "ui/common/ShaderChooser.h"
#include "messages/TextureChanged.h"

#include <sigc++/connection.h>
Expand Down
4 changes: 2 additions & 2 deletions tools/msvc/DarkRadiant.vcxproj
Expand Up @@ -267,6 +267,7 @@
<ClCompile Include="..\..\radiant\ui\materials\editor\MaterialEditor.cpp" />
<ClCompile Include="..\..\radiant\ui\materials\editor\MaterialEditorModule.cpp" />
<ClCompile Include="..\..\radiant\ui\materials\editor\MaterialPreview.cpp" />
<ClCompile Include="..\..\radiant\ui\materials\MaterialChooser.cpp" />
<ClCompile Include="..\..\radiant\ui\materials\MaterialPopulator.cpp" />
<ClCompile Include="..\..\radiant\ui\materials\MaterialSelector.cpp" />
<ClCompile Include="..\..\radiant\ui\materials\MaterialTreeView.cpp" />
Expand All @@ -291,7 +292,6 @@
<ClCompile Include="..\..\radiant\ui\commandlist\ShortcutChooser.cpp" />
<ClCompile Include="..\..\radiant\ui\common\EntityChooser.cpp" />
<ClCompile Include="..\..\radiant\ui\common\MapPreview.cpp" />
<ClCompile Include="..\..\radiant\ui\common\ShaderChooser.cpp" />
<ClCompile Include="..\..\radiant\ui\common\TexturePreviewCombo.cpp" />
<ClCompile Include="..\..\radiant\ui\einspector\AddPropertyDialog.cpp" />
<ClCompile Include="..\..\radiant\ui\einspector\AnglePropertyEditor.cpp" />
Expand Down Expand Up @@ -473,6 +473,7 @@
<ClInclude Include="..\..\radiant\ui\materials\editor\SpinCtrlBinding.h" />
<ClInclude Include="..\..\radiant\ui\materials\editor\TestModelSkin.h" />
<ClInclude Include="..\..\radiant\ui\materials\editor\TexturePreview.h" />
<ClInclude Include="..\..\radiant\ui\materials\MaterialChooser.h" />
<ClInclude Include="..\..\radiant\ui\materials\MaterialPopulator.h" />
<ClInclude Include="..\..\radiant\ui\materials\MaterialSelector.h" />
<ClInclude Include="..\..\radiant\ui\materials\MaterialTreeView.h" />
Expand All @@ -499,7 +500,6 @@
<ClInclude Include="..\..\radiant\ui\commandlist\ShortcutChooser.h" />
<ClInclude Include="..\..\radiant\ui\common\EntityChooser.h" />
<ClInclude Include="..\..\radiant\ui\common\MapPreview.h" />
<ClInclude Include="..\..\radiant\ui\common\ShaderChooser.h" />
<ClInclude Include="..\..\radiant\ui\common\TexturePreviewCombo.h" />
<ClInclude Include="..\..\radiant\ui\einspector\AddPropertyDialog.h" />
<ClInclude Include="..\..\radiant\ui\einspector\AnglePropertyEditor.h" />
Expand Down
12 changes: 6 additions & 6 deletions tools/msvc/DarkRadiant.vcxproj.filters
Expand Up @@ -223,9 +223,6 @@
<ClCompile Include="..\..\radiant\ui\common\MapPreview.cpp">
<Filter>src\ui\common</Filter>
</ClCompile>
<ClCompile Include="..\..\radiant\ui\common\ShaderChooser.cpp">
<Filter>src\ui\common</Filter>
</ClCompile>
<ClCompile Include="..\..\radiant\ui\common\TexturePreviewCombo.cpp">
<Filter>src\ui\common</Filter>
</ClCompile>
Expand Down Expand Up @@ -709,6 +706,9 @@
<ClCompile Include="..\..\radiant\ui\materials\MaterialSelector.cpp">
<Filter>src\ui\materials</Filter>
</ClCompile>
<ClCompile Include="..\..\radiant\ui\materials\MaterialChooser.cpp">
<Filter>src\ui\materials</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\radiant\camera\CameraSettings.h">
Expand Down Expand Up @@ -741,9 +741,6 @@
<ClInclude Include="..\..\radiant\ui\common\MapPreview.h">
<Filter>src\ui\common</Filter>
</ClInclude>
<ClInclude Include="..\..\radiant\ui\common\ShaderChooser.h">
<Filter>src\ui\common</Filter>
</ClInclude>
<ClInclude Include="..\..\radiant\ui\common\TexturePreviewCombo.h">
<Filter>src\ui\common</Filter>
</ClInclude>
Expand Down Expand Up @@ -1380,6 +1377,9 @@
<ClInclude Include="..\..\radiant\ui\materials\MaterialSelector.h">
<Filter>src\ui\materials</Filter>
</ClInclude>
<ClInclude Include="..\..\radiant\ui\materials\MaterialChooser.h">
<Filter>src\ui\materials</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\radiant\darkradiant.rc" />
Expand Down

0 comments on commit cb7b110

Please sign in to comment.