Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
#5537: SoundChooser cleanup
  • Loading branch information
codereader committed Sep 23, 2022
1 parent 2746e3c commit 5330d97
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 50 deletions.
1 change: 1 addition & 0 deletions libs/wxutil/decl/DeclarationSelectorDialog.cpp
Expand Up @@ -29,6 +29,7 @@ DeclarationSelectorDialog::DeclarationSelectorDialog(decl::Type declType,
// Bottom row
auto grid = new wxFlexGridSizer(1, 2, 0, 12);
grid->AddGrowableCol(0);
grid->AddGrowableCol(1);

// Left half
_bottomRowSizer = new wxBoxSizer(wxHORIZONTAL);
Expand Down
38 changes: 5 additions & 33 deletions radiant/ui/common/SoundChooser.cpp
@@ -1,46 +1,18 @@
#include "SoundChooser.h"

#include "i18n.h"
#include "ui/UserInterfaceModule.h"

#include <wx/stattext.h>

#include "ui/common/SoundShaderSelector.h"

namespace ui
{

// Constructor
SoundChooser::SoundChooser(wxWindow* parent) :
DeclarationSelectorDialog(decl::Type::SoundShader, _("Choose sound"), "SoundChooser", parent),
_selector(nullptr)
{
_selector = new SoundShaderSelector(this);
SetSelector(_selector);

auto dblClickHint = new wxStaticText(this, wxID_ANY, _("Ctrl + Double Click on treeview items for quick play"));
AddItemToBottomRow(dblClickHint);
}

void SoundChooser::loadSoundShaders()
{
_selector->Populate();
}

void SoundChooser::_onReloadSounds(wxCommandEvent& ev)
DeclarationSelectorDialog(decl::Type::SoundShader, _("Choose sound"), "SoundChooser", parent)
{
SetSelectedDeclName({});

// Send the command to the SoundManager
// After parsing it will fire the sounds reloaded signal => onShadersReloaded()
GlobalCommandSystem().executeCommand("ReloadSounds");
}

void SoundChooser::onShadersReloaded()
{
// This signal is fired by the SoundManager, possibly from a non-UI thread
GetUserInterfaceModule().dispatch([this]()
{
loadSoundShaders();
});
SetSelector(new SoundShaderSelector(this));
AddItemToBottomRow(new wxStaticText(this, wxID_ANY, _("Ctrl + Double Click on treeview items for quick play")));
}

std::string SoundChooser::chooseResource(const std::string& shaderToPreselect)
Expand Down
17 changes: 0 additions & 17 deletions radiant/ui/common/SoundChooser.h
Expand Up @@ -2,10 +2,6 @@

#include "ui/iresourcechooser.h"
#include "wxutil/decl/DeclarationSelectorDialog.h"
#include "ui/common/SoundShaderSelector.h"

#include <string>
#include <sigc++/connection.h>

namespace ui
{
Expand All @@ -17,19 +13,6 @@ class SoundChooser :
public wxutil::DeclarationSelectorDialog,
public IResourceChooser
{
private:
SoundShaderSelector* _selector;

sigc::connection _shadersReloaded;

private:
void loadSoundShaders();

// callbacks
void _onReloadSounds(wxCommandEvent& ev);

void onShadersReloaded();

public:
SoundChooser(wxWindow* parent = nullptr);

Expand Down

0 comments on commit 5330d97

Please sign in to comment.