Преглед изворни кода

finish up preliminary settings stuff

jp9000 пре 12 година
родитељ
комит
a8ada497b3

+ 3 - 1
build/data/obs-studio/locale/en.txt

@@ -24,6 +24,8 @@ MainWindow.Volume="Volume:"
 Settings="Settings"
 
 Settings.StreamRestart="All streaming/recording must be stopped in order for these changes to take effect"
+Settings.ConfirmTitle="Confirm Changes"
+Settings.Confirm="You have unsaved changes.  Save changes?"
 
 Settings.General="General"
 Settings.General.Language="Language:"
@@ -45,7 +47,7 @@ Settings.Video.FPS.Nanoseconds="Frame Interval (nanoseconds)"
 Settings.Video.FPS.Numerator="Numerator:"
 Settings.Video.FPS.Denominator="Denominator:"
 Settings.Video.Renderer="Renderer:"
-Settings.Video.InvalidResolution="Invalid base resolution value.  Must be [width]x[height] (i.e. 1920x1080)"
+Settings.Video.InvalidResolution="Invalid resolution value.  Must be [width]x[height] (i.e. 1920x1080)"
 
 Settings.Audio="Audio"
 Settings.Audio.DesktopAudioDevice="Desktop Audio Device:"

+ 1 - 0
obs/CMakeLists.txt

@@ -43,6 +43,7 @@ endif()
 add_executable(obs
 	window-main-basic.cpp
 	window-settings-basic.cpp
+	settings-basic.cpp
 	settings-basic-general.cpp
 	settings-basic-video.cpp
 	wx-subclass.cpp

+ 1 - 0
obs/makefile.am

@@ -14,6 +14,7 @@ obs_PROGRAMS = obs
 obs_LDADD = $(top_srcdir)/libobs/libobs.la
 obs_SOURCES = window-main-basic.cpp \
 	      window-settings-basic.cpp \
+	      settings-basic.cpp \
 	      settings-basic-general.cpp \
 	      settings-basic-video.cpp \
 	      obs-app.cpp \

+ 2 - 3
obs/settings-basic-general.cpp

@@ -99,7 +99,7 @@ BasicGenData::BasicGenData(OBSBasicSettings *window)
 
 void BasicGenData::LanguageChanged(wxCommandEvent &event)
 {
-	dataChanged = true;
+	SetChanged();
 	window->generalChangedText->SetLabel(
 			WXStr("Settings.General.LanguageChanged"));
 	window->generalChangedText->Show();
@@ -118,8 +118,7 @@ void BasicGenData::Apply()
 
 	config_save(GetGlobalConfig());
 
-	window->generalChangedText->Hide();
-	dataChanged = false;
+	SetSaved();
 }
 
 BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window)

+ 19 - 7
obs/settings-basic-video.cpp

@@ -50,10 +50,16 @@ class BasicVideoData : public BasicSettingsData {
 	void SaveFPSFraction();
 	void SaveFPSNanoseconds();
 
+	virtual void SetChanged()
+	{
+		BasicSettingsData::SetChanged();
+		window->videoChangedText->Show();
+	}
+
 public:
 	BasicVideoData(OBSBasicSettings *window);
 
-	void Apply();
+	virtual void Apply();
 };
 
 struct BaseLexer {
@@ -107,7 +113,7 @@ int BasicVideoData::AddRes(uint32_t cx, uint32_t cy)
 {
 	stringstream res;
 	res << cx << "x" << cy;
-	return window->baseResList->Append(res.str().c_str());
+	return window->baseResList->Append(res.str());
 }
 
 void BasicVideoData::LoadOther()
@@ -264,7 +270,13 @@ void BasicVideoData::ResetScaleList(uint32_t cx, uint32_t cy)
 		res << uint32_t(double(cx) / vals[i]);
 		res << "x";
 		res << uint32_t(double(cy) / vals[i]);
-		window->outputResList->Append(res.str().c_str());
+		window->outputResList->Append(res.str());
+	}
+
+	if (numVals) {
+		stringstream str;
+		str << cx << "x" << cy;
+		window->outputResList->SetValue(str.str());
 	}
 }
 
@@ -298,7 +310,7 @@ void BasicVideoData::BaseResListChanged(wxCommandEvent &event)
 		return;
 	}
 
-	dataChanged = true;
+	SetChanged();
 	window->videoChangedText->SetLabel(WXStr("Settings.StreamRestart"));
 	window->videoChangedText->Show();
 
@@ -315,7 +327,7 @@ void BasicVideoData::OutputResListChanged(wxCommandEvent &event)
 		return;
 	}
 
-	dataChanged = true;
+	SetChanged();
 	window->videoChangedText->SetLabel(WXStr("Settings.StreamRestart"));
 	window->videoChangedText->Show();
 }
@@ -398,9 +410,9 @@ void BasicVideoData::Apply()
 	SaveOther();
 	SaveFPSData();
 
-	window->videoChangedText->Hide();
 	config_save(GetGlobalConfig());
-	dataChanged = false;
+
+	SetSaved();
 }
 
 BasicSettingsData *CreateBasicVideoSettings(OBSBasicSettings *window)

+ 31 - 0
obs/settings-basic.cpp

@@ -0,0 +1,31 @@
+/******************************************************************************
+    Copyright (C) 2013 by Hugh Bailey <[email protected]>
+
+    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 <http://www.gnu.org/licenses/>.
+******************************************************************************/
+
+#include "settings-basic.hpp"
+#include "window-settings-basic.hpp"
+
+void BasicSettingsData::SetChanged()
+{
+	dataChanged = true;
+	window->applyButton->Enable();
+}
+
+void BasicSettingsData::SetSaved()
+{
+	dataChanged = false;
+	window->applyButton->Disable();
+}

+ 3 - 0
obs/settings-basic.hpp

@@ -27,6 +27,9 @@ protected:
 
 public:
 	inline BasicSettingsData(OBSBasicSettings *window) : window(window) {}
+
+	virtual void SetChanged();
+	virtual void SetSaved();
 };
 
 BasicSettingsData *CreateBasicGeneralSettings(OBSBasicSettings *window);

+ 3 - 0
obs/settings.hpp

@@ -27,5 +27,8 @@ public:
 	inline SettingsData() : dataChanged(false) {}
 	virtual void Apply()=0;
 
+	virtual void SetChanged()=0;
+	virtual void SetSaved()=0;
+
 	inline bool DataChanged() const {return dataChanged;}
 };

+ 1 - 0
vs/2013/OBS/OBS.vcxproj

@@ -176,6 +176,7 @@
     <ClCompile Include="..\..\..\obs\platform-windows.cpp" />
     <ClCompile Include="..\..\..\obs\settings-basic-general.cpp" />
     <ClCompile Include="..\..\..\obs\settings-basic-video.cpp" />
+    <ClCompile Include="..\..\..\obs\settings-basic.cpp" />
     <ClCompile Include="..\..\..\obs\window-main-basic.cpp" />
     <ClCompile Include="..\..\..\obs\window-settings-basic.cpp" />
     <ClCompile Include="..\..\..\obs\wx-subclass.cpp" />

+ 3 - 0
vs/2013/OBS/OBS.vcxproj.filters

@@ -45,6 +45,9 @@
     <ClCompile Include="..\..\..\obs\settings-basic-video.cpp">
       <Filter>Source Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\..\obs\settings-basic.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\..\obs\obs-app.hpp">