Add option to resolve variable values in ToString()

This commit is contained in:
WarmUpTill 2022-12-27 14:40:44 +01:00 committed by WarmUpTill
parent cd74534e4c
commit 7ae490ca25
6 changed files with 21 additions and 7 deletions

View File

@ -186,13 +186,16 @@ SceneItemSelection::GetSceneItems(SceneSelection &sceneSelection) const
return ret;
}
std::string SceneItemSelection::ToString() const
std::string SceneItemSelection::ToString(bool resolve) const
{
if (_type == Type::VARIABLE) {
auto var = _variable.lock();
if (!var) {
return "";
}
if (resolve) {
return var->Name() + "[" + var->Value() + "]";
}
return var->Name();
}
return GetWeakSourceName(_sceneItem);

View File

@ -28,7 +28,7 @@ public:
Type GetType() const { return _type; }
IdxType GetIndexType() const { return _idxType; }
std::vector<obs_scene_item *> GetSceneItems(SceneSelection &s) const;
std::string ToString() const;
std::string ToString(bool resolve = false) const;
private:
OBSWeakSource _sceneItem;

View File

@ -121,13 +121,19 @@ OBSWeakSource SceneSelection::GetScene(bool advance) const
return nullptr;
}
std::string SceneSelection::ToString() const
std::string SceneSelection::ToString(bool resolve) const
{
switch (_type) {
case Type::SCENE:
return GetWeakSourceName(_scene);
case Type::GROUP:
if (_group) {
if (resolve) {
return _group->name + "[" +
GetWeakSourceName(
_group->getCurrentScene()) +
"]";
}
return _group->name;
}
break;
@ -142,6 +148,9 @@ std::string SceneSelection::ToString() const
if (!var) {
return "";
}
if (resolve) {
return var->Name() + "[" + var->Value() + "]";
}
return var->Name();
}
default:

View File

@ -22,7 +22,7 @@ public:
Type GetType() const { return _type; }
OBSWeakSource GetScene(bool advance = true) const;
std::string ToString() const;
std::string ToString(bool resolve = false) const;
private:
OBSWeakSource _scene;

View File

@ -82,7 +82,7 @@ void SourceSelection::SetSource(OBSWeakSource source)
_source = source;
}
std::string SourceSelection::ToString() const
std::string SourceSelection::ToString(bool resolve) const
{
switch (_type) {
case Type::SOURCE:
@ -92,6 +92,9 @@ std::string SourceSelection::ToString() const
if (!var) {
return "";
}
if (resolve) {
return var->Name() + "[" + var->Value() + "]";
}
return var->Name();
}
default:

View File

@ -5,7 +5,6 @@
#include <QComboBox>
class SourceSelection {
public:
void Save(obs_data_t *obj, const char *name = "source") const;
@ -19,7 +18,7 @@ public:
Type GetType() const { return _type; }
OBSWeakSource GetSource() const;
void SetSource(OBSWeakSource);
std::string ToString() const;
std::string ToString(bool resolve = false) const;
private:
// TODO: Remove in future version