diff --git a/build/data/obs-studio/locale/en.txt b/build/data/obs-studio/locale/en.txt index 388ff37bc8de19907b4acbf1deea3b622c8ff3ef..5eb58a4e41ab3844965094a6b78a5c48bf9195bc 100644 --- a/build/data/obs-studio/locale/en.txt +++ b/build/data/obs-studio/locale/en.txt @@ -25,6 +25,7 @@ Settings="Settings" Settings.General="General" Settings.General.Language="Language:" +Settings.General.LanguageChanged="The program must be restarted in order to change the language" Settings.Outputs="Outputs" diff --git a/obs/CMakeLists.txt b/obs/CMakeLists.txt index 3db0544a8bbf12d6813e63c5b9a6b4a7fdbd7e8a..94da97815c157c6fafce5ceb14932cee8939caaa 100644 --- a/obs/CMakeLists.txt +++ b/obs/CMakeLists.txt @@ -44,6 +44,7 @@ add_executable(obs window-main-basic.cpp window-settings-basic.cpp settings-basic-general.cpp + settings-basic-video.cpp wx-subclass.cpp wx-wrappers.cpp obs-app.cpp diff --git a/obs/makefile.am b/obs/makefile.am index 21d509493e2d1cc609c43c891284d1b2818cdde9..ccb7daed5b7b6d0cc62b66d246d1bd7b6712e370 100644 --- a/obs/makefile.am +++ b/obs/makefile.am @@ -15,6 +15,7 @@ obs_LDADD = $(top_srcdir)/libobs/libobs.la obs_SOURCES = window-main-basic.cpp \ window-settings-basic.cpp \ settings-basic-general.cpp \ + settings-basic-video.cpp \ obs-app.cpp \ wx-subclass.cpp \ wx-wrappers.cpp \ diff --git a/obs/obs-app.hpp b/obs/obs-app.hpp index 966e78d525470ca4dbe0b5d406a73a4eee10639a..8fb12ebcece1add762c15591b9f75a1390a71419 100644 --- a/obs/obs-app.hpp +++ b/obs/obs-app.hpp @@ -54,3 +54,4 @@ wxDECLARE_APP(OBSApp); inline config_t GetGlobalConfig() {return wxGetApp().GlobalConfig();} #define Str(lookupVal) wxGetApp().GetString(lookupVal) +#define WXStr(lookupVal) wxString(Str(lookupVal), wxConvUTF8) diff --git a/obs/settings-basic-general.cpp b/obs/settings-basic-general.cpp index 35ea3ce86053d6277c02beaeb0a528f518231eaf..c02f4e5b67201c085859562cf53a2d23e5c138de 100644 --- a/obs/settings-basic-general.cpp +++ b/obs/settings-basic-general.cpp @@ -15,15 +15,13 @@ along with this program. If not, see . ******************************************************************************/ -#include - #include "obs-app.hpp" #include "settings-basic.hpp" #include "window-settings-basic.hpp" #include "wx-wrappers.hpp" #include "platform.hpp" -class GeneralSettings : public BasicSettingsData { +class BasicGenData : public BasicSettingsData { ConfigFile localeIni; WXConnector languageBoxConnector; @@ -33,7 +31,7 @@ class GeneralSettings : public BasicSettingsData { void FillLanguageList(const char *currentLang); public: - GeneralSettings(OBSBasicSettings *window); + BasicGenData(OBSBasicSettings *window); virtual void Apply(); }; @@ -55,14 +53,14 @@ public: } }; -int GeneralSettings::AddLanguage(const char *tag) +int BasicGenData::AddLanguage(const char *tag) { LanguageInfo *info = new LanguageInfo(localeIni, tag); return window->languageList->Append(wxString(info->name, wxConvUTF8), info); } -void GeneralSettings::FillLanguageList(const char *currentLang) +void BasicGenData::FillLanguageList(const char *currentLang) { size_t numSections = config_num_sections(localeIni); for (size_t i = 0; i < numSections; i++) { @@ -74,7 +72,7 @@ void GeneralSettings::FillLanguageList(const char *currentLang) } } -GeneralSettings::GeneralSettings(OBSBasicSettings *window) +BasicGenData::BasicGenData(OBSBasicSettings *window) : BasicSettingsData (window) { string path; @@ -90,18 +88,31 @@ GeneralSettings::GeneralSettings(OBSBasicSettings *window) languageBoxConnector.Connect( window->languageList, wxEVT_COMBOBOX, - wxCommandEventHandler(GeneralSettings::LanguageChanged), + wxCommandEventHandler(BasicGenData::LanguageChanged), NULL, this); + + window->generalText->Hide(); } -void GeneralSettings::LanguageChanged(wxCommandEvent &event) +void BasicGenData::LanguageChanged(wxCommandEvent &event) { + dataChanged = true; + window->generalText->SetLabel( + WXStr("Settings.General.LanguageChanged")); + window->generalText->Show(); } -void GeneralSettings::Apply() +void BasicGenData::Apply() { - + int sel = window->languageList->GetSelection(); + if (sel == wxNOT_FOUND) + return; + + LanguageInfo *info = static_cast( + window->languageList->GetClientData(sel)); + + config_set_string(GetGlobalConfig(), "General", "Language", info->tag); } BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window) @@ -109,7 +120,7 @@ BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window) BasicSettingsData *data = NULL; try { - data = new GeneralSettings(window); + data = new BasicGenData(window); } catch (const char *error) { blog(LOG_ERROR, "CreateBasicGeneralSettings failed: %s", error); } diff --git a/obs/settings-basic-video.cpp b/obs/settings-basic-video.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aa64f21a2667300128f5208b7d08cc45f0ce4a5f --- /dev/null +++ b/obs/settings-basic-video.cpp @@ -0,0 +1,46 @@ +/****************************************************************************** + Copyright (C) 2013 by 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, see . +******************************************************************************/ + +#include "obs-app.hpp" +#include "settings-basic.hpp" +#include "window-settings-basic.hpp" +#include "wx-wrappers.hpp" + +#include +using namespace std; + +class BasicVideoData : public BasicSettingsData { + ConnectorList connections; + + void BaseResListChanged(wxCommandEvent &event); + +public: + BasicVideoData(OBSBasicSettings *window); +}; + +BasicVideoData::BasicVideoData(OBSBasicSettings *window) + : BasicSettingsData(window) +{ + connections.Add(window->baseResList, wxEVT_COMBOBOX, + wxCommandEventHandler( + BasicVideoData::BaseResListChanged), + NULL, this); +} + +void BasicVideoData::BaseResListChanged(wxCommandEvent &event) +{ +} diff --git a/obs/settings-basic.hpp b/obs/settings-basic.hpp index 97bab99266d2a80f43b85cbfb278ccfb9c785791..64261ba20ec96da8b4e9cc9375e2b98a8c5a5845 100644 --- a/obs/settings-basic.hpp +++ b/obs/settings-basic.hpp @@ -30,3 +30,4 @@ public: }; BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window); +BasicSettingsData *CreateBasicVideoSettings(OBSBasicSettings *window); diff --git a/obs/window-settings-basic.cpp b/obs/window-settings-basic.cpp index 8398029650897413377ac0081f49ff0184d99ed1..2f902d1db42648f7f500860f3874eae9912bbdd9 100644 --- a/obs/window-settings-basic.cpp +++ b/obs/window-settings-basic.cpp @@ -31,3 +31,8 @@ void OBSBasicSettings::PageChanged(wxListbookEvent &event) void OBSBasicSettings::PageChanging(wxListbookEvent &event) { } + +void OBSBasicSettings::OnClose(wxCloseEvent &event) +{ + Destroy(); +} diff --git a/obs/window-settings-basic.hpp b/obs/window-settings-basic.hpp index 9a81295b1ef713a85d28261b27e530b7d2201bc9..1de35722a1d4d0f564c3580414d13d7473f1c916 100644 --- a/obs/window-settings-basic.hpp +++ b/obs/window-settings-basic.hpp @@ -29,6 +29,7 @@ protected: virtual void PageChanged(wxListbookEvent &event); virtual void PageChanging(wxListbookEvent &event); + virtual void OnClose(wxCloseEvent &event); public: OBSBasicSettings(wxWindow *parent); diff --git a/obs/wx-wrappers.hpp b/obs/wx-wrappers.hpp index 2fc9490fa4fc5a62546dfbb28d363f61902981cb..40b7ef5f0e3d259a43da089801cf44f82d1218f6 100644 --- a/obs/wx-wrappers.hpp +++ b/obs/wx-wrappers.hpp @@ -20,6 +20,8 @@ #include #include +#include + struct gs_window; gs_window WxToGSWindow(const wxWindow *window); @@ -61,6 +63,16 @@ public: obj->Connect(eventType, func, userData, eventSink); } + inline WXConnector(WXConnector &&c) + : obj (c.obj), + eventType (c.eventType), + func (c.func), + userData (c.userData), + eventSink (c.eventSink) + { + c.obj = NULL; + } + inline ~WXConnector() { Disconnect(); @@ -83,8 +95,22 @@ public: inline void Disconnect() { - if (obj) + if (obj) { obj->Disconnect(eventType, func, userData, eventSink); - obj = NULL; + obj = NULL; + } + } +}; + +class ConnectorList { + std::vector connectors; + +public: + inline void Add(wxEvtHandler *obj, wxEventType type, + wxObjectEventFunction func, wxObject *userData, + wxEvtHandler *eventSink) + { + WXConnector connector(obj, type, func, userData, eventSink); + connectors.push_back(std::move(connector)); } }; diff --git a/vs/2010/OBS/OBS.vcxproj b/vs/2010/OBS/OBS.vcxproj index 002186baf53de852b87887569c2a3b8d0909fe3e..4169a3e834c3832299abaaa303dcc2b65959bb69 100644 --- a/vs/2010/OBS/OBS.vcxproj +++ b/vs/2010/OBS/OBS.vcxproj @@ -171,6 +171,7 @@ + diff --git a/vs/2010/OBS/OBS.vcxproj.filters b/vs/2010/OBS/OBS.vcxproj.filters index 78cca2a7b0df7e1de7bbfb9993f313a27a872209..950e93859caf60652513b6c1dc3be849cbfebad5 100644 --- a/vs/2010/OBS/OBS.vcxproj.filters +++ b/vs/2010/OBS/OBS.vcxproj.filters @@ -42,6 +42,9 @@ Source Files + + Source Files +