eventhandler: Add ScreenshotSaved event

No, this does not trigger with `Get/SaveScreenshot`. I've tried to make
that super clear in the docs. Hopefully people don't get too confused.
This commit is contained in:
tt2468 2022-11-17 22:19:12 -08:00
parent 9cfca3c7d1
commit 8cabe24b77
3 changed files with 39 additions and 7 deletions

View File

@ -353,12 +353,6 @@ void EventHandler::OnFrontendEvent(enum obs_frontend_event event, void *private_
blog_debug("[EventHandler::OnFrontendEvent] Finished.");
break;
case OBS_FRONTEND_EVENT_STUDIO_MODE_ENABLED:
eventHandler->HandleStudioModeStateChanged(true);
break;
case OBS_FRONTEND_EVENT_STUDIO_MODE_DISABLED:
eventHandler->HandleStudioModeStateChanged(false);
break;
// Config
case OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGING: {
@ -477,6 +471,17 @@ void EventHandler::OnFrontendEvent(enum obs_frontend_event event, void *private_
eventHandler->HandleReplayBufferSaved();
break;
// Ui
case OBS_FRONTEND_EVENT_STUDIO_MODE_ENABLED:
eventHandler->HandleStudioModeStateChanged(true);
break;
case OBS_FRONTEND_EVENT_STUDIO_MODE_DISABLED:
eventHandler->HandleStudioModeStateChanged(false);
break;
case OBS_FRONTEND_EVENT_SCREENSHOT_TAKEN:
eventHandler->HandleScreenshotSaved();
break;
default:
break;
}

View File

@ -78,7 +78,6 @@ private:
// General
void HandleExitStarted();
void HandleStudioModeStateChanged(bool enabled);
// Config
void HandleCurrentSceneCollectionChanging();
@ -170,4 +169,8 @@ private:
static void HandleMediaInputPlaybackEnded(void *param,
calldata_t *data); // Direct callback
void HandleMediaInputActionTriggered(obs_source_t *source, ObsMediaInputAction action);
// Ui
void HandleStudioModeStateChanged(bool enabled);
void HandleScreenshotSaved();
};

View File

@ -38,3 +38,27 @@ void EventHandler::HandleStudioModeStateChanged(bool enabled)
eventData["studioModeEnabled"] = enabled;
BroadcastEvent(EventSubscription::Ui, "StudioModeStateChanged", eventData);
}
/**
* A screenshot has been saved.
*
* Note: Triggered for the screenshot feature available in `Settings -> Hotkeys -> Screenshot Output` ONLY.
* Applications using `Get/SaveSourceScreenshot` should implement a `CustomEvent` if this kind of inter-client
* communication is desired.
*
* @dataField savedScreenshotPath | String | Path of the saved image file
*
* @eventType ScreenshotSaved
* @eventSubscription Ui
* @complexity 2
* @rpcVersion -1
* @initialVersion 5.1.0
* @api events
* @category ui
*/
void EventHandler::HandleScreenshotSaved()
{
json eventData;
eventData["savedScreenshotPath"] = Utils::Obs::StringHelper::GetLastScreenshotFileName();
BroadcastEvent(EventSubscription::Ui, "ScreenshotSaved", eventData);
}