Merge pull request #372 from Palakis/frontend-events-ifelse-refactor

events: refactor the massive if else chain in the frontend event callback
This commit is contained in:
Stéphane Lepin 2019-09-03 02:40:07 +02:00 committed by GitHub
commit 6c881a5da7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -132,87 +132,112 @@ void WSEvents::FrontendEventHandler(enum obs_frontend_event event, void* private
return; return;
} }
if (event == OBS_FRONTEND_EVENT_FINISHED_LOADING) { switch (event) {
case OBS_FRONTEND_EVENT_FINISHED_LOADING:
owner->hookTransitionBeginEvent(); owner->hookTransitionBeginEvent();
} break;
else if (event == OBS_FRONTEND_EVENT_SCENE_CHANGED) {
case OBS_FRONTEND_EVENT_SCENE_CHANGED:
owner->OnSceneChange(); owner->OnSceneChange();
} break;
else if (event == OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED) {
case OBS_FRONTEND_EVENT_SCENE_LIST_CHANGED:
owner->OnSceneListChange(); owner->OnSceneListChange();
} break;
else if (event == OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED) {
case OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED:
owner->hookTransitionBeginEvent(); owner->hookTransitionBeginEvent();
owner->OnSceneCollectionChange(); owner->OnSceneCollectionChange();
} break;
else if (event == OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED) {
case OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED:
owner->OnSceneCollectionListChange(); owner->OnSceneCollectionListChange();
} break;
else if (event == OBS_FRONTEND_EVENT_TRANSITION_CHANGED) {
case OBS_FRONTEND_EVENT_TRANSITION_CHANGED:
owner->OnTransitionChange(); owner->OnTransitionChange();
} break;
else if (event == OBS_FRONTEND_EVENT_TRANSITION_LIST_CHANGED) {
case OBS_FRONTEND_EVENT_TRANSITION_LIST_CHANGED:
owner->hookTransitionBeginEvent(); owner->hookTransitionBeginEvent();
owner->OnTransitionListChange(); owner->OnTransitionListChange();
} break;
else if (event == OBS_FRONTEND_EVENT_PROFILE_CHANGED) {
case OBS_FRONTEND_EVENT_PROFILE_CHANGED:
owner->OnProfileChange(); owner->OnProfileChange();
} break;
else if (event == OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED) {
case OBS_FRONTEND_EVENT_PROFILE_LIST_CHANGED:
owner->OnProfileListChange(); owner->OnProfileListChange();
} break;
else if (event == OBS_FRONTEND_EVENT_STREAMING_STARTING) {
case OBS_FRONTEND_EVENT_STREAMING_STARTING:
owner->OnStreamStarting(); owner->OnStreamStarting();
} break;
else if (event == OBS_FRONTEND_EVENT_STREAMING_STARTED) {
case OBS_FRONTEND_EVENT_STREAMING_STARTED:
owner->streamStatusTimer.start(STATUS_INTERVAL); owner->streamStatusTimer.start(STATUS_INTERVAL);
owner->StreamStatus(); owner->StreamStatus();
owner->OnStreamStarted(); owner->OnStreamStarted();
} break;
else if (event == OBS_FRONTEND_EVENT_STREAMING_STOPPING) {
case OBS_FRONTEND_EVENT_STREAMING_STOPPING:
owner->streamStatusTimer.stop(); owner->streamStatusTimer.stop();
owner->OnStreamStopping(); owner->OnStreamStopping();
} break;
else if (event == OBS_FRONTEND_EVENT_STREAMING_STOPPED) {
case OBS_FRONTEND_EVENT_STREAMING_STOPPED:
owner->OnStreamStopped(); owner->OnStreamStopped();
} break;
else if (event == OBS_FRONTEND_EVENT_RECORDING_STARTING) {
case OBS_FRONTEND_EVENT_RECORDING_STARTING:
owner->OnRecordingStarting(); owner->OnRecordingStarting();
} break;
else if (event == OBS_FRONTEND_EVENT_RECORDING_STARTED) {
case OBS_FRONTEND_EVENT_RECORDING_STARTED:
owner->OnRecordingStarted(); owner->OnRecordingStarted();
} break;
else if (event == OBS_FRONTEND_EVENT_RECORDING_STOPPING) {
case OBS_FRONTEND_EVENT_RECORDING_STOPPING:
owner->OnRecordingStopping(); owner->OnRecordingStopping();
} break;
else if (event == OBS_FRONTEND_EVENT_RECORDING_STOPPED) {
case OBS_FRONTEND_EVENT_RECORDING_STOPPED:
owner->OnRecordingStopped(); owner->OnRecordingStopped();
} break;
else if (event == OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTING) {
case OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTING:
owner->OnReplayStarting(); owner->OnReplayStarting();
} break;
else if (event == OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTED) {
case OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTED:
owner->OnReplayStarted(); owner->OnReplayStarted();
} break;
else if (event == OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPING) {
case OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPING:
owner->OnReplayStopping(); owner->OnReplayStopping();
} break;
else if (event == OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPED) {
case OBS_FRONTEND_EVENT_REPLAY_BUFFER_STOPPED:
owner->OnReplayStopped(); owner->OnReplayStopped();
} break;
else if (event == OBS_FRONTEND_EVENT_STUDIO_MODE_ENABLED) {
case OBS_FRONTEND_EVENT_STUDIO_MODE_ENABLED:
owner->OnStudioModeSwitched(true); owner->OnStudioModeSwitched(true);
} break;
else if (event == OBS_FRONTEND_EVENT_STUDIO_MODE_DISABLED) {
case OBS_FRONTEND_EVENT_STUDIO_MODE_DISABLED:
owner->OnStudioModeSwitched(false); owner->OnStudioModeSwitched(false);
} break;
else if (event == OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED) {
case OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED:
owner->OnPreviewSceneChanged(); owner->OnPreviewSceneChanged();
} break;
else if (event == OBS_FRONTEND_EVENT_EXIT) {
case OBS_FRONTEND_EVENT_EXIT:
owner->unhookTransitionBeginEvent(); owner->unhookTransitionBeginEvent();
owner->OnExit(); owner->OnExit();
break;
} }
} }