Skip to content

Commit

Permalink
made it so --desktop-fullscreen is not persistent, because that's as …
Browse files Browse the repository at this point in the history
…annoying as hell
  • Loading branch information
davewx7 committed May 25, 2017
1 parent 97a72fa commit ea3479d
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
Expand Up @@ -72,7 +72,7 @@
]",

_toggle_fullscreen: "def() ->commands [
game_preferences().set_preference_value('desktop_fullscreen', not game_preferences().get_bool_preference_value('desktop_fullscreen'));
game_preferences().set_preference_value('desktop_fullscreen', not game_preferences().get_bool_preference_value('desktop_fullscreen'), [enum persistent]);
game_preferences().save_preferences();
update_and_restart()
Expand Down
3 changes: 2 additions & 1 deletion modules/tbs/data/objects/settings_screen.cfg
Expand Up @@ -65,7 +65,8 @@
set(_need_restart, not _need_restart);
_preferences.set_preference_value('desktop_fullscreen', value);
debug(['SET PREFERENCE', value]);
_preferences.set_preference_value('desktop_fullscreen', value, [enum persistent]);
_preferences.save_preferences()
]",

Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Expand Up @@ -137,8 +137,8 @@ namespace

PREF_INT(auto_size_ideal_width, 0, "");
PREF_INT(auto_size_ideal_height, 0, "");
PREF_BOOL_PERSISTENT(desktop_fullscreen, false, "Sets the game window to be a fullscreen window the size of the desktop");
PREF_BOOL_PERSISTENT(desktop_fullscreen_force, false, "(Windows) forces desktop fullscreen to actually use fullscreen rather than a borderless window the size of the desktop");
PREF_BOOL(desktop_fullscreen, false, "Sets the game window to be a fullscreen window the size of the desktop");
PREF_BOOL(desktop_fullscreen_force, false, "(Windows) forces desktop fullscreen to actually use fullscreen rather than a borderless window the size of the desktop");
PREF_BOOL(msaa, false, "Use msaa");


Expand Down
20 changes: 18 additions & 2 deletions src/preferences.cpp
Expand Up @@ -892,9 +892,10 @@ namespace preferences
}

for(std::map<std::string, RegisteredSetting>::iterator i = g_registered_settings().begin(); i != g_registered_settings().end(); ++i) {
if(i->second.persistent && node.has_key(i->first)) {
if(node.has_key(i->first)) {
i->second.read(node[i->first]);
i->second.has_been_set_from_persistent = true;
i->second.persistent = true;
}
}

Expand Down Expand Up @@ -1346,13 +1347,28 @@ namespace preferences
return variant(*it->second.double_value);
END_DEFINE_FN

BEGIN_DEFINE_FN(set_preference_value, "(string, any)->commands")
BEGIN_DEFINE_FN(set_preference_value, "(string, any, null|[enum {persistent}]=null)->commands")
const std::string key = FN_ARG(0).as_string();
variant val = FN_ARG(1);
auto it = g_registered_settings().find(key);
ASSERT_LOG(it != g_registered_settings().end(), "Unknown preference setting: " << key);

bool force_persistent = false;

if(NUM_FN_ARGS > 2 && FN_ARG(2).is_list()) {
variant flags = FN_ARG(2);
for(variant flag : flags.as_list()) {
if(flag.as_enum() == "persistent") {
force_persistent = true;
}
}
}

return variant(new game_logic::FnCommandCallable("set_preference_value", [=]() {
if(force_persistent) {
it->second.persistent = true;
}

if(it->second.int_value) {
*it->second.int_value = val.as_int();
} else if(it->second.bool_value) {
Expand Down

0 comments on commit ea3479d

Please sign in to comment.