/******************************************************************************** Copyright (C) 2012 Hugh Bailey This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ********************************************************************************/ #include "Main.h" void OBS::RegisterSceneClass(CTSTR lpClassName, CTSTR lpDisplayName, OBSCREATEPROC createProc, OBSCONFIGPROC configProc) { if(!lpClassName || !*lpClassName) { AppWarning(TEXT("OBS::RegisterSceneClass: No class name specified")); return; } if(!createProc) { AppWarning(TEXT("OBS::RegisterSceneClass: No create procedure specified")); return; } if(GetSceneClass(lpClassName)) { AppWarning(TEXT("OBS::RegisterSceneClass: Tried to register '%s', but it already exists"), lpClassName); return; } ClassInfo *classInfo = sceneClasses.CreateNew(); classInfo->strClass = lpClassName; classInfo->strName = lpDisplayName; classInfo->createProc = createProc; classInfo->configProc = configProc; } void OBS::RegisterImageSourceClass(CTSTR lpClassName, CTSTR lpDisplayName, OBSCREATEPROC createProc, OBSCONFIGPROC configProc) { if(!lpClassName || !*lpClassName) { AppWarning(TEXT("OBS::RegisterImageSourceClass: No class name specified")); return; } if(!createProc) { AppWarning(TEXT("OBS::RegisterImageSourceClass: No create procedure specified")); return; } if(GetImageSourceClass(lpClassName)) { AppWarning(TEXT("OBS::RegisterImageSourceClass: Tried to register '%s', but it already exists"), lpClassName); return; } ClassInfo *classInfo = imageSourceClasses.CreateNew(); classInfo->strClass = lpClassName; classInfo->strName = lpDisplayName; classInfo->createProc = createProc; classInfo->configProc = configProc; } Scene* OBS::CreateScene(CTSTR lpClassName, XElement *data) { for(UINT i=0; iGetString(TEXT("class")); if(!lpClassName) { AppWarning(TEXT("OBS::ConfigureScene: No class specified for scene '%s'"), element->GetName()); return; } for(UINT i=0; iGetString(TEXT("class")); if(!lpClassName) { AppWarning(TEXT("OBS::ConfigureImageSource: No class specified for image source '%s'"), element->GetName()); return; } for(UINT i=0; iGetElement(lpScene); if(!newSceneElement) return false; if(sceneElement == newSceneElement) return true; sceneElement = newSceneElement; CTSTR lpClass = sceneElement->GetString(TEXT("class")); if(!lpClass) { AppWarning(TEXT("OBS::SetScene: no class found for scene '%s'"), newSceneElement->GetName()); return false; } XElement *sceneData = newSceneElement->GetElement(TEXT("data")); //------------------------- Scene *newScene = NULL; if(bRunning) newScene = CreateScene(lpClass, sceneData); //------------------------- HWND hwndSources = GetDlgItem(hwndMain, ID_SOURCES); SendMessage(hwndSources, LB_RESETCONTENT, 0, 0); XElement *sources = sceneElement->GetElement(TEXT("sources")); if(sources) { UINT numSources = sources->NumElements(); for(UINT i=0; iGetElementByID(i); UINT id = (UINT)SendMessage(hwndSources, LB_ADDSTRING, 0, (LPARAM)sourceElement->GetName()); if(bRunning && newScene) newScene->AddImageSource(sourceElement); } } if(scene && newScene->HasMissingSources()) MessageBox(hwndMain, Str("Scene.MissingSources"), NULL, 0); if(bRunning) { //todo: cache scenes maybe? undecided. not really as necessary with global sources OSEnterMutex(hSceneMutex); scene->EndScene(); Scene *previousScene = scene; scene = newScene; scene->BeginScene(); if(!bTransitioning) { bTransitioning = true; transitionAlpha = 0.0f; } OSLeaveMutex(hSceneMutex); delete previousScene; } return true; }