Added "Import" button in Global Sources Dialog.

The "Import" button opens a "Open" dialog where a user can open a scene collection file then it lists all Global Sources from the selected scene collection in a dialog.

You can Import multiple global sources by holding shift or Ctrl and clicking on the Global sources you want to import.

With this change scene collections have their own Global Sources but users can import Global Sources from other scene collections.

If you make any changes to a Global sources properties and want the change in another scene collection you will need to remove the global source in the other scene collection and then import it again.

You can't import Global Sources if there is already a Global Source with the same name.

Hopefully this makes it simple and fast for users to import their commonly used Global sources like for
example followers alerts.
master
Glought 2014-08-04 14:23:34 -07:00
parent cd704a1c42
commit 7e934f8f16
6 changed files with 176 additions and 12 deletions

11
OBS.rc
View File

@ -333,9 +333,20 @@ BEGIN
PUSHBUTTON "Remove",IDC_REMOVE,143,22,77,14
PUSHBUTTON "Rename",IDC_RENAME,143,37,77,14
PUSHBUTTON "Listbox.Config",IDC_CONFIG,143,52,77,14
PUSHBUTTON "Listbox.ImportButton",IDC_IMPORT,143,67,77,14
DEFPUSHBUTTON "OK",IDOK,169,174,50,14
END
IDD_GLOBAL_SOURCES_IMPORT DIALOGEX 0, 0, 133, 183
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "ImportGlobalSources"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
LISTBOX IDC_SOURCES,7,7,117,153,LBS_EXTENDEDSEL | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
DEFPUSHBUTTON "OK",IDOK,17,164,50,14
PUSHBUTTON "CANCEL",IDCANCEL,69,164,50,14
END
IDD_PLUGINS DIALOGEX 0, 0, 402, 203
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Plugins"

View File

@ -167,18 +167,34 @@ ImageSource* OBS::AddGlobalSourceToScene(CTSTR lpName)
return NULL;
}
void OBS::GetGlobalSourceNames(List<CTSTR> &globalSourceNames)
void OBS::GetGlobalSourceNames(List<CTSTR> &globalSourceNames, bool mainSceneGlobalSourceNames)
{
globalSourceNames.Clear();
XElement *globals = scenesConfig.GetElement(TEXT("global sources"));
if(globals)
if(!mainSceneGlobalSourceNames)
{
UINT numSources = globals->NumElements();
for(UINT i=0; i<numSources; i++)
XElement *globals = scenesConfig.GetElement(TEXT("global sources"));
if(globals)
{
XElement *sourceElement = globals->GetElementByID(i);
globalSourceNames << sourceElement->GetName();
UINT numSources = globals->NumElements();
for(UINT i=0; i<numSources; i++)
{
XElement *sourceElement = globals->GetElementByID(i);
globalSourceNames << sourceElement->GetName();
}
}
}
else
{
XElement *globals = globalSourcesImportConfig.GetElement(TEXT("global sources"));
if(globals)
{
UINT numSources = globals->NumElements();
for(UINT i=0; i<numSources; i++)
{
XElement *sourceElement = globals->GetElementByID(i);
globalSourceNames << sourceElement->GetName();
}
}
}
}

View File

@ -616,6 +616,7 @@ class OBS
UINT encoderSkipThreshold;
XConfig scenesConfig;
XConfig globalSourcesImportConfig;
List<SceneHotkeyInfo> sceneHotkeys;
XElement *sceneElement;
@ -1014,10 +1015,11 @@ private:
static INT_PTR CALLBACK PluginsDialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
void GetGlobalSourceNames(List<CTSTR> &globalSourceNames);
void GetGlobalSourceNames(List<CTSTR> &globalSourceNames,bool mainSceneGlobalSourceNames = false);
XElement* GetGlobalSourceElement(CTSTR lpName);
static INT_PTR CALLBACK GlobalSourcesProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam);
static INT_PTR CALLBACK GlobalSourcesImportProc(HWND hwnd,UINT message, WPARAM wParam, LPARAM lParam);
static bool STDCALL ConfigGlobalSource(XElement *element, bool bCreating);
void CallHotkey(DWORD hotkeyID, bool bDown);

View File

@ -2110,6 +2110,59 @@ INT_PTR CALLBACK OBS::GlobalSourcesProc(HWND hwnd, UINT message, WPARAM wParam,
break;
}
case IDC_IMPORT:
{
TCHAR lpFile[MAX_PATH + 1];
zero(lpFile, sizeof(lpFile));
OPENFILENAME ofn;
zero(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = lpFile;
ofn.hwndOwner = hwndMain;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFilter = TEXT("Scene Files (*.xconfig)\0*.xconfig\0");
ofn.nFilterIndex = 1;
ofn.lpstrInitialDir = GlobalConfig->GetString(L"General", L"LastImportExportPath");
TCHAR curDirectory[MAX_PATH + 1];
GetCurrentDirectory(MAX_PATH, curDirectory);
BOOL bOpenFile = GetOpenFileName(&ofn);
SetCurrentDirectory(curDirectory);
if(!bOpenFile)
break;
if(GetPathExtension(lpFile).IsEmpty())
scat(lpFile, L".xconfig");
String strSelectedSceneCollectionGlobalSourcesConfig;
strSelectedSceneCollectionGlobalSourcesConfig = lpFile;
if(!App->globalSourcesImportConfig.Open(strSelectedSceneCollectionGlobalSourcesConfig))
CrashError(TEXT("Could not open '%s"), strSelectedSceneCollectionGlobalSourcesConfig.Array());
if(OBSDialogBox(hinstMain, MAKEINTRESOURCE(IDD_GLOBAL_SOURCES_IMPORT), hwnd, OBS::GlobalSourcesImportProc) == IDOK)
{
HWND hwndSources = GetDlgItem(hwnd, IDC_SOURCES);
SendMessage(hwndSources, LB_RESETCONTENT, 0, 0);
XElement *globals = App->scenesConfig.GetElement(TEXT("global sources"));
if(globals)
{
UINT numGlobals = globals->NumElements();
for(UINT i = 0; i < numGlobals; i++)
{
XElement *globalSource = globals->GetElementByID(i);
SendMessage(hwndSources, LB_ADDSTRING, 0, (LPARAM)globalSource->GetName());
}
}
App->globalSourcesImportConfig.Close();
}
break;
}
case IDC_CONFIG:
{
UINT id = (UINT)SendMessage(GetDlgItem(hwnd, IDC_SOURCES), LB_GETCURSEL, 0, 0);
@ -2229,17 +2282,93 @@ INT_PTR CALLBACK OBS::GlobalSourcesProc(HWND hwnd, UINT message, WPARAM wParam,
}*/
case IDOK:
EndDialog(hwnd, IDOK);
{
App->scenesConfig.Save();
EndDialog(hwnd, IDOK);
}
}
break;
case WM_CLOSE:
EndDialog(hwnd, IDOK);
{
App->scenesConfig.Save();
EndDialog(hwnd, IDOK);
}
}
return FALSE;
}
INT_PTR CALLBACK OBS::GlobalSourcesImportProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_INITDIALOG:
{
LocalizeWindow(hwnd);
HWND hwndSources = GetDlgItem(hwnd, IDC_SOURCES);
XElement *globals = App->globalSourcesImportConfig.GetElement(TEXT("global sources"));
if(globals)
{
UINT numGlobals = globals->NumElements();
for(UINT i=0; i<numGlobals; i++)
{
XElement *globalSource = globals->GetElementByID(i);
SendMessage(hwndSources, LB_ADDSTRING, 0, (LPARAM)globalSource->GetName());
}
}
return TRUE;
}
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
{
HWND hSources = GetDlgItem(hwnd, IDC_SOURCES);
int selectedItemsArray[8192];
UINT selectedItems = (UINT)SendMessage(hSources, LB_GETSELITEMS, 512, (LPARAM) selectedItemsArray);
if( selectedItems == LB_ERR)
break;
for(UINT i = 0; i < selectedItems; i++)
{
XElement *selectedGlobals = App->globalSourcesImportConfig.GetElement(TEXT("global sources"));
XElement *selectedGlobalSources = selectedGlobals->GetElementByID(selectedItemsArray[i]);
XElement *currentSceneGlobalSources = App->scenesConfig.GetElement(TEXT("global sources"));
if(!currentSceneGlobalSources)
currentSceneGlobalSources = App->scenesConfig.CreateElement(TEXT("global sources"));
if(currentSceneGlobalSources)
{
XElement *foundGlobalSource = currentSceneGlobalSources->GetElement(selectedGlobalSources->GetName());
if(foundGlobalSource != NULL && selectedGlobalSources->GetName() != foundGlobalSource->GetName())
{
String strExists = Str("ImportGlobalSourceNameExists");
strExists.FindReplace(TEXT("$1"), selectedGlobalSources->GetName());
OBSMessageBox(hwnd, strExists, NULL, 0);
break;
}
}
XElement *newSourceElement = currentSceneGlobalSources->CopyElement(selectedGlobalSources, selectedGlobalSources->GetName());
newSourceElement->SetString(TEXT("class"), selectedGlobalSources->GetString(TEXT("class")));
}
}
case IDCANCEL:
EndDialog(hwnd, LOWORD(wParam));
break;
}
}
return 0;
}
//----------------------------
struct ReconnectInfo

View File

@ -41,6 +41,7 @@
#define IDD_LOGUPLOADED 147
#define IDD_SETTINGS_HOTKEYS 149
#define IDD_SETTINGS_QSV 150
#define IDD_GLOBAL_SOURCES_IMPORT 151
#define IDC_SETTINGSLIST 1006
#define IDC_SUBDIALOG 1007
#define IDC_MODE 1008
@ -354,6 +355,7 @@
#define IDC_USECUSTOMPARAMS 1207
#define IDC_USEGLOBALBITRATE 1208
#define IDC_USEGLOBALBUFFERSIZE 1209
#define IDC_IMPORT 1210
#define IDA_SOURCE_MOVEUP 40018
#define IDA_SOURCE_MOVEDOWN 40019
#define IDA_SOURCE_MOVETOTOP 40020
@ -420,9 +422,9 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 151
#define _APS_NEXT_RESOURCE_VALUE 152
#define _APS_NEXT_COMMAND_VALUE 40081
#define _APS_NEXT_CONTROL_VALUE 1208
#define _APS_NEXT_CONTROL_VALUE 1209
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -44,6 +44,9 @@ StreamReport="Stream Report"
MessageBoxWarningCaption="Warning"
NoSourcesFound="You haven't added any sources! Are you sure you want to stream a black screen?"
ImportGlobalSourceNameExists="The global source '$1' already exists in the current scene collection."
ImportGlobalSources="Import Global Sources"
ImportCollectionReplaceWarning.Title="Import Scene Collection"
ImportCollectionReplaceWarning.Text="The current scene data will be lost. Are you sure you want to import?"
@ -77,6 +80,7 @@ Listbox.Positioning="Position/Size"
Listbox.ResetSize="Reset Size"
Listbox.SetHotkey="Set Hotkey"
ListBox.ResetCrop="Reset Cropping"
Listbox.ImportButton="Import"
MainMenu.SceneCollection="&Scene Collection"
MainMenu.SceneCollection.New="&New"