From 689546ef0f6e19421a6b45e73ed118fe20b0d235 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Wed, 29 Jun 2016 06:52:13 +0200 Subject: [PATCH] Changed start message disable to bool from string --- SceneSwitcher.cpp | 5 +++-- settings.cpp | 15 +++++++++++++++ settings.h | 2 ++ switcher.cpp | 4 ++-- 4 files changed, 22 insertions(+), 4 deletions(-) diff --git a/SceneSwitcher.cpp b/SceneSwitcher.cpp index 8758f4d3..6999dfbd 100644 --- a/SceneSwitcher.cpp +++ b/SceneSwitcher.cpp @@ -33,7 +33,7 @@ void saveKeybinding(string name, obs_data_array_t *hotkeyData) { file.open(string(configPath).append(name), ofstream::trunc); //hotkeyData = obs_hotkey_save(pauseHotkeyId); //doesnt seem to work in obs_module_unload (hotkey data freed already (<- Jim)) size_t num = obs_data_array_count(hotkeyData); - for (int i = 0; i < num; i++) { + for (size_t i = 0; i < num; i++) { string temp = obs_data_get_json(obs_data_array_item(hotkeyData, i)); file << temp; } @@ -166,11 +166,12 @@ obs_properties_t *sceneSwitcherOptionsSourceGetProperties(void *data) { UNUSED_PARAMETER(data); obs_properties_t *props = obs_properties_create(); + obs_properties_add_bool(props,"StartMessageDisable","Disable Start Message"); obs_properties_add_editable_list(props, "WindowList", "Window Name", (enum obs_editable_list_type)0, "", NULL); - obs_properties_add_button(props, "LoadOldSettings", "Load settings from old version (restart OBS after clicking this button)", &loadOldSettings); + obs_properties_add_button(props, "LoadOldSettings", "Load settings from old version of this plugin (restart OBS after clicking this button)", &loadOldSettings); return props; } void sceneSwitcherOptionsSourceSave(void *data, obs_data_t *settings) diff --git a/settings.cpp b/settings.cpp index b36da52a..e50a7847 100644 --- a/settings.cpp +++ b/settings.cpp @@ -30,12 +30,22 @@ void Settings::load() { string line; size_t pos = string::npos; int valueCheck; + bool startMessageDisableFound = false; infile.seekg(0); while (infile.good()) { valueCheck = 0; //read json file getline(infile, line); + //disable the start message? + if (!startMessageDisableFound) { + pos = line.find("\"StartMessageDisable\": "); + if (pos != string::npos) { + startMessageDisableFound = true; + startMessageDisable = line.find("true") == string::npos ? false : true; + } + } + //get switcher info pos = line.find("\"value\":"); if (!line.empty() && pos != string::npos) { string temp = line.substr(pos + 10, string::npos - 1); @@ -73,6 +83,11 @@ void Settings::load() { } } +bool Settings::getStartMessageDisable() +{ + return startMessageDisable; +} + void Settings::addToMap(string s1, string s2) { settings.insert(pair(s1, s2)); } diff --git a/settings.h b/settings.h index f6bdefde..e13d05b5 100644 --- a/settings.h +++ b/settings.h @@ -6,8 +6,10 @@ using namespace std; class Settings { map settings; + bool startMessageDisable = false; public: void load(); + bool getStartMessageDisable(); map getMap(); string getSettingsFilePath(); void setSettingsFilePath(string path); diff --git a/switcher.cpp b/switcher.cpp index e0b385ec..cb3b6d89 100644 --- a/switcher.cpp +++ b/switcher.cpp @@ -83,7 +83,7 @@ void Switcher::switcherThreadFunc() { void Switcher::firstLoad() { settings.load(); settingsMap = settings.getMap(); - if (settingsMap.find("Disable Start Message") == settingsMap.end() || settingsMap.find("Disable Start Message")->second != "Yes") { + if (!settings.getStartMessageDisable()) { string message = "The following settings were found for Scene Switcher:\n"; for (auto it = settingsMap.cbegin(); it != settingsMap.cend(); ++it) { @@ -99,7 +99,7 @@ void Switcher::firstLoad() { void Switcher::firstLoad() { settings.load(); settingsMap = settings.getMap(); - if (settingsMap.find("Disable Start Message") == settingsMap.end() || settingsMap.find("Disable Start Message")->second != "Yes") { + if (!settings.getStartMessageDisable()) { string message = "The following settings were found for Scene Switcher:\n"; for (auto it = settingsMap.cbegin(); it != settingsMap.cend(); ++it) {