mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-07 09:05:57 -05:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bad1a548fb | ||
|
|
f706416df5 | ||
|
|
c344c88acd | ||
|
|
2cd9e61717 |
@@ -6,18 +6,18 @@ You have the option to ...
|
|||||||
|
|
||||||
Both methods require [CMake](https://cmake.org/download/).
|
Both methods require [CMake](https://cmake.org/download/).
|
||||||
|
|
||||||
The plugin can be compiled for OBS 27 and above, although using the latest version of OBS is recommended to support all features.
|
The plugin can be compiled for OBS 31 and above, although using the latest version of OBS is recommended to support all features.
|
||||||
|
|
||||||
## Compiling in tree (recommended for development)
|
## Compiling in tree (recommended for development)
|
||||||
This section assumes that you have a working [OBS Studio development environment](https://obsproject.com/wiki/Building-OBS-Studio).
|
This section assumes that you have a working [OBS Studio development environment](https://obsproject.com/wiki/Building-OBS-Studio).
|
||||||
|
|
||||||
Add the "SceneSwitcher" source directory to your obs-studio source directory under obs-studio/UI/frontend-plugins/:
|
Add the "SceneSwitcher" source directory to your obs-studio source directory under obs-studio/plugins:
|
||||||
```
|
```
|
||||||
cd obs-studio/UI/frontend-plugins/
|
cd obs-studio/plugins
|
||||||
git clone --recursive https://github.com/WarmUpTill/SceneSwitcher.git
|
git clone --recursive https://github.com/WarmUpTill/SceneSwitcher.git
|
||||||
```
|
```
|
||||||
|
|
||||||
Then modify the obs-studio/UI/frontend-plugins/CMakeLists.txt Example and add an entry for the scene switcher:
|
Then modify the obs-studio/plugins/CMakeLists.txt and add an entry for the scene switcher:
|
||||||
```
|
```
|
||||||
add_subdirectory(SceneSwitcher)
|
add_subdirectory(SceneSwitcher)
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -65,13 +65,16 @@ ResourceTable::ResourceTable(QWidget *parent, const QString &help,
|
|||||||
[openSettings]() { openSettings(); });
|
[openSettings]() { openSettings(); });
|
||||||
|
|
||||||
auto settingsShortcut = new QShortcut(QKeySequence("F2"), this);
|
auto settingsShortcut = new QShortcut(QKeySequence("F2"), this);
|
||||||
|
settingsShortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||||
QWidget::connect(settingsShortcut, &QShortcut::activated, this,
|
QWidget::connect(settingsShortcut, &QShortcut::activated, this,
|
||||||
openSettings);
|
openSettings);
|
||||||
auto removeShortcut = new QShortcut(QKeySequence("Del"), this);
|
auto removeShortcut = new QShortcut(QKeySequence("Del"), this);
|
||||||
|
removeShortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||||
QWidget::connect(removeShortcut, &QShortcut::activated, this,
|
QWidget::connect(removeShortcut, &QShortcut::activated, this,
|
||||||
[this]() { Remove(); });
|
[this]() { Remove(); });
|
||||||
|
|
||||||
auto newShortcut = new QShortcut(QKeySequence("Ctrl+N"), this);
|
auto newShortcut = new QShortcut(QKeySequence("Ctrl+N"), this);
|
||||||
|
newShortcut->setContext(Qt::WidgetWithChildrenShortcut);
|
||||||
QWidget::connect(newShortcut, &QShortcut::activated, this,
|
QWidget::connect(newShortcut, &QShortcut::activated, this,
|
||||||
[this]() { Add(); });
|
[this]() { Add(); });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "source-helpers.hpp"
|
#include "source-helpers.hpp"
|
||||||
|
#include "canvas-helpers.hpp"
|
||||||
|
|
||||||
#include <obs-frontend-api.h>
|
#include <obs-frontend-api.h>
|
||||||
|
|
||||||
@@ -28,15 +29,43 @@ std::string GetWeakSourceName(obs_weak_source_t *weak_source)
|
|||||||
|
|
||||||
OBSWeakSource GetWeakSourceByName(const char *name)
|
OBSWeakSource GetWeakSourceByName(const char *name)
|
||||||
{
|
{
|
||||||
OBSWeakSource weak;
|
OBSSourceAutoRelease source = obs_get_source_by_name(name);
|
||||||
obs_source_t *source = obs_get_source_by_name(name);
|
|
||||||
if (source) {
|
if (source) {
|
||||||
weak = obs_source_get_weak_source(source);
|
return OBSGetWeakRef(source);
|
||||||
obs_weak_source_release(weak);
|
|
||||||
obs_source_release(source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return weak;
|
#if LIBOBS_API_VER > MAKE_SEMANTIC_VERSION(31, 1, 0)
|
||||||
|
struct SearchData {
|
||||||
|
const char *name;
|
||||||
|
OBSWeakSource &scene;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const auto enumCanvasScenes = [](void *dataPtr,
|
||||||
|
obs_source_t *source) -> bool {
|
||||||
|
auto data = static_cast<SearchData *>(dataPtr);
|
||||||
|
if (strcmp(data->name, obs_source_get_name(source)) == 0) {
|
||||||
|
data->scene = OBSGetWeakRef(source);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const auto enumCanvases = [](void *dataPtr,
|
||||||
|
obs_canvas_t *canvas) -> bool {
|
||||||
|
obs_canvas_enum_scenes(canvas, enumCanvasScenes, dataPtr);
|
||||||
|
|
||||||
|
auto data = static_cast<SearchData *>(dataPtr);
|
||||||
|
return data->scene == nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
OBSWeakSource weakScene;
|
||||||
|
SearchData searchData{name, weakScene};
|
||||||
|
obs_enum_canvases(enumCanvases, &searchData);
|
||||||
|
return weakScene;
|
||||||
|
#else
|
||||||
|
return nullptr;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
OBSWeakSource GetWeakSourceByQString(const QString &name)
|
OBSWeakSource GetWeakSourceByQString(const QString &name)
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace advss {
|
|||||||
enum class HotkeyType;
|
enum class HotkeyType;
|
||||||
|
|
||||||
bool CanSimulateKeyPresses();
|
bool CanSimulateKeyPresses();
|
||||||
void PressKeys(const std::vector<HotkeyType> keys, int duration);
|
void PressKeys(const std::vector<HotkeyType> &keys, int duration);
|
||||||
|
|
||||||
class Hotkey {
|
class Hotkey {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ static const std::unordered_map<HotkeyType, long> keyTable = {
|
|||||||
{HotkeyType::Key_NumpadEnter, XK_KP_Enter},
|
{HotkeyType::Key_NumpadEnter, XK_KP_Enter},
|
||||||
};
|
};
|
||||||
|
|
||||||
void PressKeys(const std::vector<HotkeyType> keys, int duration)
|
void PressKeys(const std::vector<HotkeyType> &keys, int duration)
|
||||||
{
|
{
|
||||||
if (!canSimulateKeyPresses) {
|
if (!canSimulateKeyPresses) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ bool CanSimulateKeyPresses()
|
|||||||
return canSimulateKeyPresses;
|
return canSimulateKeyPresses;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PressKeys(const std::vector<HotkeyType> keys, int duration)
|
void PressKeys(const std::vector<HotkeyType> &, int)
|
||||||
{
|
{
|
||||||
// Not supported on MacOS
|
// Not supported on MacOS
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ static const std::unordered_map<HotkeyType, long> keyTable = {
|
|||||||
{HotkeyType::Key_NumpadEnter, VK_RETURN},
|
{HotkeyType::Key_NumpadEnter, VK_RETURN},
|
||||||
};
|
};
|
||||||
|
|
||||||
void PressKeys(const std::vector<HotkeyType> keys, int duration)
|
void PressKeys(const std::vector<HotkeyType> &keys, int duration)
|
||||||
{
|
{
|
||||||
const int repeatInterval = 100;
|
const int repeatInterval = 100;
|
||||||
|
|
||||||
|
|||||||
@@ -513,7 +513,7 @@ void ScriptHandler::SetVariableValue(void *, calldata_t *data)
|
|||||||
RETURN_SUCCESS();
|
RETURN_SUCCESS();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptHandler::GetRunningStatus(void *ctx, calldata_t *data)
|
void ScriptHandler::GetRunningStatus(void *, calldata_t *data)
|
||||||
{
|
{
|
||||||
calldata_set_bool(data, "is_running", PluginIsRunning());
|
calldata_set_bool(data, "is_running", PluginIsRunning());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,14 +58,16 @@ std::string TwitchChannel::GetUserID(const TwitchToken &token) const
|
|||||||
}
|
}
|
||||||
OBSDataArrayAutoRelease array = obs_data_get_array(res.data, "data");
|
OBSDataArrayAutoRelease array = obs_data_get_array(res.data, "data");
|
||||||
size_t count = obs_data_array_count(array);
|
size_t count = obs_data_array_count(array);
|
||||||
for (size_t i = 0; i < count; i++) {
|
|
||||||
OBSDataAutoRelease arrayObj = obs_data_array_item(array, i);
|
if (count == 0) {
|
||||||
std::string id = obs_data_get_string(arrayObj, "id");
|
userIDCache[_name] = "invalid";
|
||||||
userIDCache[_name] = id;
|
return "invalid";
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
userIDCache[_name] = "invalid";
|
|
||||||
return "invalid";
|
OBSDataAutoRelease arrayObj = obs_data_array_item(array, 0);
|
||||||
|
const std::string id = obs_data_get_string(arrayObj, "id");
|
||||||
|
userIDCache[_name] = id;
|
||||||
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static QDate parseRFC3339Date(const std::string &rfc3339Date)
|
static QDate parseRFC3339Date(const std::string &rfc3339Date)
|
||||||
|
|||||||
@@ -448,7 +448,7 @@ void EventSub::StartServerMigrationClient(const std::string &url)
|
|||||||
auto client = std::make_unique<EventSubWSClient>();
|
auto client = std::make_unique<EventSubWSClient>();
|
||||||
SetupClient(*client);
|
SetupClient(*client);
|
||||||
|
|
||||||
client->set_open_handler([this](connection_hdl hdl) {
|
client->set_open_handler([this](connection_hdl) {
|
||||||
vblog(LOG_INFO, "Twitch EventSub migration client opened");
|
vblog(LOG_INFO, "Twitch EventSub migration client opened");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -829,7 +829,7 @@ void TokenGrabberThread::run()
|
|||||||
if (_serverThread.joinable()) {
|
if (_serverThread.joinable()) {
|
||||||
_serverThread.join();
|
_serverThread.join();
|
||||||
}
|
}
|
||||||
_stopWaiting = {false};
|
_stopWaiting = false;
|
||||||
|
|
||||||
// Generate URI to request token
|
// Generate URI to request token
|
||||||
auto state = generateStateString();
|
auto state = generateStateString();
|
||||||
|
|||||||
Reference in New Issue
Block a user