Skip to content

Commit

Permalink
#6162: Update controls when the skin declaration is changed. Fix skin…
Browse files Browse the repository at this point in the history
… decl generation.
  • Loading branch information
codereader committed Nov 14, 2022
1 parent a0bc779 commit ffbdd03
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
18 changes: 17 additions & 1 deletion radiant/ui/skin/SkinEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ SkinEditor::SkinEditor() :

SkinEditor::~SkinEditor()
{

_skinModifiedConn.disconnect();
}

void SkinEditor::setupModelTreeView()
Expand Down Expand Up @@ -307,6 +307,22 @@ void SkinEditor::onSkinSelectionChanged(wxDataViewEvent& ev)
{
if (_controlUpdateInProgress) return;

_skinModifiedConn.disconnect();

auto skin = getSelectedSkin();

if (skin)
{
_skinModifiedConn = skin->signal_DeclarationChanged().connect(
sigc::mem_fun(*this, &SkinEditor::onSkinDeclarationChanged));
}

updateSkinControlsFromSelection();
}

void SkinEditor::onSkinDeclarationChanged()
{
// Refresh all controls
updateSkinControlsFromSelection();
}

Expand Down
6 changes: 6 additions & 0 deletions radiant/ui/skin/SkinEditor.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include <sigc++/connection.h>

#include "icommandsystem.h"
#include "modelskin.h"

Expand Down Expand Up @@ -66,6 +68,8 @@ class SkinEditor final :

bool _controlUpdateInProgress;

sigc::connection _skinModifiedConn;

private:
SkinEditor();
~SkinEditor() override;
Expand Down Expand Up @@ -100,6 +104,8 @@ class SkinEditor final :
void onSkinModelSelectionChanged(wxDataViewEvent& ev);
void onSkinSelectionChanged(wxDataViewEvent& ev);

void onSkinDeclarationChanged();

template<typename ObjectClass>
ObjectClass* getControl(const std::string& name)
{
Expand Down
4 changes: 3 additions & 1 deletion radiantcore/skins/Doom3ModelSkin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ std::string Skin::generateSyntax()
{
std::stringstream output;

output << std::endl;

// Export models (indentation one tab)
for (const auto& model : _current->matchingModels)
{
output << "\t" << model << std::endl;
output << "\tmodel\t\"" << model << "\"" << std::endl;
}

if (!_current->matchingModels.empty())
Expand Down

0 comments on commit ffbdd03

Please sign in to comment.