Skip to content

Commit

Permalink
#5655: Create Speaker window remembers the last selected item
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Jul 26, 2021
1 parent 9183f7f commit 172fd13
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion radiant/ui/common/SoundChooser.cpp
Expand Up @@ -34,6 +34,7 @@ namespace
const char* const SHOW_SHADER_DEF_ICON = "icon_script.png";

const char* const RKEY_WINDOW_STATE = "user/ui/soundChooser/window";
const char* const RKEY_LAST_SELECTED_SHADER = "user/ui/soundChooser/lastSelectedShader";
}

/**
Expand Down Expand Up @@ -304,8 +305,11 @@ void SoundChooser::onShadersReloaded()
});
}

std::string SoundChooser::chooseResource(const std::string& preselected)
std::string SoundChooser::chooseResource(const std::string& shaderToPreselect)
{
auto preselected = !shaderToPreselect.empty() ? shaderToPreselect :
registry::getValue<std::string>(RKEY_LAST_SELECTED_SHADER);

if (!preselected.empty())
{
setSelectedShader(preselected);
Expand All @@ -316,6 +320,11 @@ std::string SoundChooser::chooseResource(const std::string& preselected)
if (ShowModal() == wxID_OK)
{
selectedShader = getSelectedShader();

if (!selectedShader.empty())
{
registry::setValue(RKEY_LAST_SELECTED_SHADER, selectedShader);
}
}

return selectedShader;
Expand Down

0 comments on commit 172fd13

Please sign in to comment.