Changed start message disable to bool from string

This commit is contained in:
WarmUpTill 2016-06-29 06:52:13 +02:00 committed by GitHub
parent daa3efe640
commit 689546ef0f
4 changed files with 22 additions and 4 deletions

View File

@ -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)

View File

@ -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<string, string>(s1, s2));
}

View File

@ -6,8 +6,10 @@
using namespace std;
class Settings {
map<string, string> settings;
bool startMessageDisable = false;
public:
void load();
bool getStartMessageDisable();
map<string, string> getMap();
string getSettingsFilePath();
void setSettingsFilePath(string path);

View File

@ -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)
{