mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-21 17:34:57 -05:00
Cleanup
This commit is contained in:
parent
a3b3cf9818
commit
c99b5f1feb
|
|
@ -1,6 +1,7 @@
|
|||
#include "macro-condition-virtual-cam.hpp"
|
||||
#include "layout-helpers.hpp"
|
||||
|
||||
#include <obs.hpp>
|
||||
#include <obs-frontend-api.h>
|
||||
|
||||
namespace advss {
|
||||
|
|
@ -12,29 +13,22 @@ bool MacroConditionVCam::_registered = MacroConditionFactory::Register(
|
|||
{MacroConditionVCam::Create, MacroConditionVCamEdit::Create,
|
||||
"AdvSceneSwitcher.condition.virtualCamera"});
|
||||
|
||||
const static std::map<VCamState, std::string> VCamStates = {
|
||||
{VCamState::STOP,
|
||||
"AdvSceneSwitcher.condition.virtualCamera.state.stop"},
|
||||
{VCamState::START,
|
||||
"AdvSceneSwitcher.condition.virtualCamera.state.start"},
|
||||
};
|
||||
|
||||
bool MacroConditionVCam::CheckCondition()
|
||||
{
|
||||
bool stateMatch = false;
|
||||
bool match = false;
|
||||
#if LIBOBS_API_VER >= MAKE_SEMANTIC_VERSION(27, 0, 0)
|
||||
switch (_state) {
|
||||
case VCamState::STOP:
|
||||
stateMatch = !obs_frontend_virtualcam_active();
|
||||
case Condition::STOP:
|
||||
match = !obs_frontend_virtualcam_active();
|
||||
break;
|
||||
case VCamState::START:
|
||||
stateMatch = obs_frontend_virtualcam_active();
|
||||
case Condition::START:
|
||||
match = obs_frontend_virtualcam_active();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return stateMatch;
|
||||
return match;
|
||||
}
|
||||
|
||||
bool MacroConditionVCam::Save(obs_data_t *obj) const
|
||||
|
|
@ -47,38 +41,39 @@ bool MacroConditionVCam::Save(obs_data_t *obj) const
|
|||
bool MacroConditionVCam::Load(obs_data_t *obj)
|
||||
{
|
||||
MacroCondition::Load(obj);
|
||||
_state = static_cast<VCamState>(obs_data_get_int(obj, "state"));
|
||||
_state = static_cast<Condition>(obs_data_get_int(obj, "state"));
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline void populateStateSelection(QComboBox *list)
|
||||
{
|
||||
for (auto entry : VCamStates) {
|
||||
list->addItem(obs_module_text(entry.second.c_str()));
|
||||
static const std::map<MacroConditionVCam::Condition, std::string>
|
||||
conditions = {
|
||||
{MacroConditionVCam::Condition::STOP,
|
||||
"AdvSceneSwitcher.condition.virtualCamera.state.stop"},
|
||||
{MacroConditionVCam::Condition::START,
|
||||
"AdvSceneSwitcher.condition.virtualCamera.state.start"},
|
||||
};
|
||||
|
||||
for (const auto &[_, name] : conditions) {
|
||||
list->addItem(obs_module_text(name.c_str()));
|
||||
}
|
||||
}
|
||||
|
||||
MacroConditionVCamEdit::MacroConditionVCamEdit(
|
||||
QWidget *parent, std::shared_ptr<MacroConditionVCam> entryData)
|
||||
: QWidget(parent)
|
||||
: QWidget(parent),
|
||||
_states(new QComboBox(this))
|
||||
{
|
||||
_states = new QComboBox();
|
||||
|
||||
populateStateSelection(_states);
|
||||
QWidget::connect(_states, SIGNAL(currentIndexChanged(int)), this,
|
||||
SLOT(StateChanged(int)));
|
||||
|
||||
populateStateSelection(_states);
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
|
||||
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
|
||||
{"{{states}}", _states},
|
||||
};
|
||||
|
||||
auto layout = new QHBoxLayout;
|
||||
PlaceWidgets(obs_module_text(
|
||||
"AdvSceneSwitcher.condition.virtualCamera.entry"),
|
||||
mainLayout, widgetPlaceholders);
|
||||
setLayout(mainLayout);
|
||||
layout, {{"{{states}}", _states}});
|
||||
setLayout(layout);
|
||||
|
||||
_entryData = entryData;
|
||||
UpdateEntryData();
|
||||
|
|
@ -88,7 +83,7 @@ MacroConditionVCamEdit::MacroConditionVCamEdit(
|
|||
void MacroConditionVCamEdit::StateChanged(int value)
|
||||
{
|
||||
GUARD_LOADING_AND_LOCK();
|
||||
_entryData->_state = static_cast<VCamState>(value);
|
||||
_entryData->_state = static_cast<MacroConditionVCam::Condition>(value);
|
||||
}
|
||||
|
||||
void MacroConditionVCamEdit::UpdateEntryData()
|
||||
|
|
|
|||
|
|
@ -6,11 +6,6 @@
|
|||
|
||||
namespace advss {
|
||||
|
||||
enum class VCamState {
|
||||
STOP,
|
||||
START,
|
||||
};
|
||||
|
||||
class MacroConditionVCam : public MacroCondition {
|
||||
public:
|
||||
MacroConditionVCam(Macro *m) : MacroCondition(m) {}
|
||||
|
|
@ -23,7 +18,12 @@ public:
|
|||
return std::make_shared<MacroConditionVCam>(m);
|
||||
}
|
||||
|
||||
VCamState _state = VCamState::STOP;
|
||||
enum class Condition {
|
||||
STOP,
|
||||
START,
|
||||
};
|
||||
|
||||
Condition _state = Condition::STOP;
|
||||
|
||||
private:
|
||||
static bool _registered;
|
||||
|
|
@ -49,11 +49,10 @@ public:
|
|||
private slots:
|
||||
void StateChanged(int value);
|
||||
|
||||
protected:
|
||||
QComboBox *_states;
|
||||
std::shared_ptr<MacroConditionVCam> _entryData;
|
||||
|
||||
private:
|
||||
QComboBox *_states;
|
||||
|
||||
std::shared_ptr<MacroConditionVCam> _entryData;
|
||||
bool _loading = true;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user