Skip to content

Commit

Permalink
#5827: cleanup inconsistent tabs/spaces in PropertyEditorFactory.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Mott committed Oct 25, 2022
1 parent 8f327dc commit 4c02bee
Showing 1 changed file with 33 additions and 36 deletions.
69 changes: 33 additions & 36 deletions radiant/ui/einspector/PropertyEditorFactory.cpp
Expand Up @@ -38,15 +38,15 @@ void PropertyEditorFactory::registerBuiltinTypes()
_peMap["vector3"] = Vector3PropertyEditor::CreateNew;
_peMap["bool"] = BooleanPropertyEditor::CreateNew;
_peMap["entity"] = EntityPropertyEditor::CreateNew;
_peMap["colour"] = ColourPropertyEditor::CreateNew;
_peMap["color"] = ColourPropertyEditor::CreateNew;
_peMap["texture"] = TexturePropertyEditor::CreateNew;
_peMap["mat"] = TexturePropertyEditor::CreateNew;
_peMap["skin"] = SkinPropertyEditor::CreateNew;
_peMap["sound"] = SoundPropertyEditor::CreateNew;
_peMap["float"] = FloatPropertyEditor::CreateNew;
_peMap["model"] = ModelPropertyEditor::CreateNew;
_peMap["classname"] = ClassnamePropertyEditor::CreateNew;
_peMap["colour"] = ColourPropertyEditor::CreateNew;
_peMap["color"] = ColourPropertyEditor::CreateNew;
_peMap["texture"] = TexturePropertyEditor::CreateNew;
_peMap["mat"] = TexturePropertyEditor::CreateNew;
_peMap["skin"] = SkinPropertyEditor::CreateNew;
_peMap["sound"] = SoundPropertyEditor::CreateNew;
_peMap["float"] = FloatPropertyEditor::CreateNew;
_peMap["model"] = ModelPropertyEditor::CreateNew;
_peMap["classname"] = ClassnamePropertyEditor::CreateNew;
_peMap["angle"] = AnglePropertyEditor::CreateNew;
_peMap["fx"] = FxPropertyEditor::CreateNew;

Expand All @@ -66,46 +66,46 @@ void PropertyEditorFactory::registerPropertyEditor(const std::string& key, const

void PropertyEditorFactory::unregisterPropertyEditor(const std::string& key)
{
auto found = _customEditors.find(key);
auto found = _customEditors.find(key);

if (found != _customEditors.end())
{
_customEditors.erase(found);
if (found != _customEditors.end())
{
_customEditors.erase(found);
return;
}
}

rWarning() << "Cannot unregister property editor for key " << key << std::endl;
}

IPropertyEditor::Ptr PropertyEditorFactory::create(wxWindow* parent, const std::string& className,
IEntitySelection& entities, const ITargetKey::Ptr& key)
{
// greebo: First, search the custom editors for a match
for (const auto& pair : _customEditors)
{
if (pair.first.empty()) continue; // skip empty keys
// greebo: First, search the custom editors for a match
for (const auto& pair : _customEditors)
{
if (pair.first.empty()) continue; // skip empty keys

// Try to match the entity key against the regex (i->first)
std::regex expr(pair.first);
std::smatch matches;
// Try to match the entity key against the regex (i->first)
std::regex expr(pair.first);
std::smatch matches;

auto fullKey = key->getFullKey();
if (!std::regex_match(fullKey, matches, expr)) continue;
if (!std::regex_match(fullKey, matches, expr)) continue;

// We have a match, invoke the creation function
return pair.second(parent, entities, key);
}
// We have a match, invoke the creation function
return pair.second(parent, entities, key);
}

// No custom editor found, search for the named property editor type
// No custom editor found, search for the named property editor type
auto iter = _peMap.find(className);

// If the type is not found, return NULL otherwise create a new instance of
// the associated derived type.
if (iter == _peMap.end())
if (iter == _peMap.end())
{
return {};
}
}

return iter->second(parent, entities, key);
}

Expand Down Expand Up @@ -134,13 +134,10 @@ void PropertyEditorFactory::unregisterPropertyEditorDialog(const std::string& ke

wxBitmap PropertyEditorFactory::getBitmapFor(const std::string& type)
{
// Sanity check
if (type.empty()) return wxNullBitmap;

std::string iconName = "icon_" + type + ".png";

auto candidate = wxutil::GetLocalBitmap(iconName);
// Sanity check
if (type.empty()) return wxNullBitmap;

auto candidate = wxutil::GetLocalBitmap("icon_" + type + ".png");
return candidate.IsOk() ? candidate : wxutil::GetLocalBitmap("empty.png");
}

Expand Down

0 comments on commit 4c02bee

Please sign in to comment.