mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-04-19 16:47:22 -05:00
Add option to resolve variable values in ToString()
This commit is contained in:
parent
cd74534e4c
commit
7ae490ca25
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user