Skip to content

Commit

Permalink
#5613: Module setup is not finished by the time the PropertyEditorFac…
Browse files Browse the repository at this point in the history
…tory is registering the built-in types, so the sound module may or may not be available at that time. Disable the sound editor if the module is not present in the editor's constructor instead.
  • Loading branch information
codereader committed Oct 17, 2021
1 parent a712aa7 commit 0429c9c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
8 changes: 1 addition & 7 deletions radiant/ui/einspector/PropertyEditorFactory.cpp
@@ -1,6 +1,5 @@
#include "PropertyEditorFactory.h"

#include "isound.h"
#include "itextstream.h"
#include "Vector3PropertyEditor.h"
#include "BooleanPropertyEditor.h"
Expand Down Expand Up @@ -43,12 +42,7 @@ void PropertyEditorFactory::registerBuiltinTypes()
_peMap["texture"] = TexturePropertyEditor::CreateNew;
_peMap["mat"] = TexturePropertyEditor::CreateNew;
_peMap["skin"] = SkinPropertyEditor::CreateNew;

if (module::GlobalModuleRegistry().moduleExists(MODULE_SOUNDMANAGER))
{
_peMap["sound"] = SoundPropertyEditor::CreateNew;
}

_peMap["sound"] = SoundPropertyEditor::CreateNew;
_peMap["float"] = FloatPropertyEditor::CreateNew;
_peMap["model"] = ModelPropertyEditor::CreateNew;
_peMap["classname"] = ClassnamePropertyEditor::CreateNew;
Expand Down
1 change: 0 additions & 1 deletion radiant/ui/einspector/PropertyEditorFactory.h
Expand Up @@ -38,7 +38,6 @@ class PropertyEditorFactory final

// Associate a specific property editor for the given key (regex)
void registerPropertyEditor(const std::string& key, const IPropertyEditor::CreationFunc& creator);

void unregisterPropertyEditor(const std::string& key);

void registerPropertyEditorDialog(const std::string& key, const IPropertyEditorDialog::CreationFunc& create);
Expand Down
6 changes: 6 additions & 0 deletions radiant/ui/einspector/SoundPropertyEditor.cpp
Expand Up @@ -5,6 +5,7 @@
#include "ui/idialogmanager.h"
#include "i18n.h"
#include "ientity.h"
#include "isound.h"

#include <wx/panel.h>
#include <wx/button.h>
Expand All @@ -22,6 +23,11 @@ SoundPropertyEditor::SoundPropertyEditor(wxWindow* parent, IEntitySelection& ent
{
constructBrowseButtonPanel(parent, _("Choose sound..."),
PropertyEditorFactory::getBitmapFor("sound"));

if (!module::GlobalModuleRegistry().moduleExists(MODULE_SOUNDMANAGER))
{
getWidget()->Disable();
}
}

void SoundPropertyEditor::onBrowseButtonClick()
Expand Down
30 changes: 24 additions & 6 deletions test/resources/tdm/maps/entityinspector.map
Expand Up @@ -3,29 +3,47 @@ Version 2
{
"classname" "light_torchflame"
"name" "light_torchflame_1"
"origin" "0 -64 64"
"canBeBlownOut" "0"
"light_center" "0 0 0"
"light_radius" "126 102 79"
"canBeBlownOut" "0"
"origin" "0 -64 64"
"unique_to_1" "unique_value"
}
// entity 1
{
"classname" "light_torchflame"
"name" "light_torchflame_2"
"origin" "224 -64 64"
"canBeBlownOut" "0"
"light_center" "0 0 0"
"light_radius" "126 102 79"
"canBeBlownOut" "0"
"origin" "224 -64 64"
"unique_to_2" "unique_value"
}
// entity 2
{
"classname" "light_torchflame"
"name" "light_torchflame_3"
"origin" "224 128 64"
"canBeBlownOut" "1"
"light_center" "0 0 0"
"light_radius" "126 102 79"
"canBeBlownOut" "1"
"origin" "224 128 64"
"unique_to_3" "unique_value"
}
// entity 3
{
"classname" "speaker"
"name" "speaker_1"
"origin" "-33 116 0"
"s_shader" "steam_engine_01"
"s_mindistance" "0.665232"
"s_maxdistance" "5.543600"
}
// entity 4
{
"classname" "speaker"
"name" "speaker_2"
"origin" "92 237 0"
"s_shader" "steam_engine_01"
"s_mindistance" "0.665232"
"s_maxdistance" "5.543600"
}

0 comments on commit 0429c9c

Please sign in to comment.