|
From: <gi...@cr...> - 2017-06-25 17:15:13
|
via 268a196dd2b011645c53579cfe60336e34e78215 (commit)
from b3e98cc5569973af76d871fdfdbd6a2b93bd11c3 (commit)
-----------------------------------------------------------------------
commit 268a196dd2b011645c53579cfe60336e34e78215
Author: advil <ra...@gm...>
Date: Sun Jun 25 19:08:56 2017 +0200
Fix behavior of tile_full_screen with some associated refactoring
This value defaulted to something it couldn't be set to in the rc file,
and the behavior on reading this field was also weird (including a
somewhat iffy cast from screen_mode to bool and back that breaks the
default setting on an bad value). This lets it be explicitly set to a
third value and fixes the documentation.
-----------------------------------------------------------------------
Summary of changes:
crawl-ref/docs/options_guide.txt | 7 +++++--
crawl-ref/source/game-options.cc | 31 +++++++++++++++++--------------
crawl-ref/source/game-options.h | 2 ++
crawl-ref/source/initfile.cc | 19 ++++++++++---------
4 files changed, 34 insertions(+), 25 deletions(-)
diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt
index 3e5707d..a28d1bc 100644
--- a/crawl-ref/docs/options_guide.txt
+++ b/crawl-ref/docs/options_guide.txt
@@ -1972,8 +1972,11 @@ tile_force_overlay = false
the same number of lines. Increase the view_max_height option if you
find yourself with unused screen estate.
-tile_full_screen = false
- Setting this option to true will start Crawl in full screen mode.
+tile_full_screen = auto
+ Setting this option to true or false will force full screen mode to be
+ on or off. Setting it to anything else will put it in auto mode, which
+ enables full screen mode only if the screen resolution is smaller than
+ width 1200, or height 800.
tile_font_crt_file = VeraMono.ttf
tile_font_stat_file = VeraMono.ttf
diff --git a/crawl-ref/source/game-options.cc b/crawl-ref/source/game-options.cc
index 06bb35b..b030600 100644
--- a/crawl-ref/source/game-options.cc
+++ b/crawl-ref/source/game-options.cc
@@ -7,6 +7,7 @@
#include "game-options.h"
#include "options.h"
+#include "misc.h"
static unsigned _curses_attribute(const string &field, string &error)
{
@@ -39,43 +40,45 @@ static unsigned _curses_attribute(const string &field, string &error)
return CHATTR_NORMAL;
}
-static bool _read_bool(const string &field, string &error)
+/**
+ * Read a maybe bool field. Accepts anything for the third value.
+ */
+maybe_bool read_maybe_bool(const string &field)
{
+ // TODO: check for "maybe" explicitly or something?
if (field == "true" || field == "1" || field == "yes")
- return true;
+ return MB_TRUE;
if (field == "false" || field == "0" || field == "no")
- return false;
+ return MB_FALSE;
- error = make_stringf("Bad boolean: %s (should be true or false)",
- field.c_str());
- return false;
+ return MB_MAYBE;
}
bool read_bool(const string &field, bool def_value)
{
- string error;
- const bool result = _read_bool(field, error);
- if (error.empty())
- return result;
+ const maybe_bool result = read_maybe_bool(field);
+ if (result != MB_MAYBE)
+ return tobool(result, false);
- Options.report_error("%s", error.c_str());
+ Options.report_error("Bad boolean: %s (should be true or false)", field.c_str());
return def_value;
}
+
void BoolGameOption::reset() const { value = default_value; }
string BoolGameOption::loadFromString(string field, rc_line_type) const
{
string error;
- const bool result = _read_bool(field, error);
- if (!error.empty())
+ const maybe_bool result = read_maybe_bool(field);
+ if (result == MB_MAYBE)
{
return make_stringf("Bad %s value: %s (should be true or false)",
name().c_str(), field.c_str());
}
- value = result;
+ value = tobool(result, false);
return "";
}
diff --git a/crawl-ref/source/game-options.h b/crawl-ref/source/game-options.h
index 52c824d..a8c7034 100644
--- a/crawl-ref/source/game-options.h
+++ b/crawl-ref/source/game-options.h
@@ -11,6 +11,7 @@
#include "colour.h"
#include "stringutil.h"
+#include "maybe-bool.h"
enum rc_line_type
{
@@ -201,3 +202,4 @@ private:
};
bool read_bool(const std::string &field, bool def_value);
+maybe_bool read_maybe_bool(const std::string &field);
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 5c60829..299ff94 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -3311,18 +3311,19 @@ void game_options::read_option_line(const string &str, bool runscript)
#ifdef USE_TILE
#ifdef USE_TILE_LOCAL
else if (key == "tile_full_screen")
- tile_full_screen = (screen_mode)read_bool(field, tile_full_screen);
-#endif // USE_TILE_LOCAL
-#ifdef TOUCH_UI
- else if (key == "tile_use_small_layout")
{
- if (field == "true")
- tile_use_small_layout = MB_TRUE;
- else if (field == "false")
- tile_use_small_layout = MB_FALSE;
+ const maybe_bool fs_val = read_maybe_bool(field);
+ if (fs_val == MB_TRUE)
+ tile_full_screen = SCREENMODE_FULL;
+ else if (fs_val == MB_FALSE)
+ tile_full_screen = SCREENMODE_WINDOW;
else
- tile_use_small_layout = MB_MAYBE;
+ tile_full_screen = SCREENMODE_AUTO;
}
+#endif // USE_TILE_LOCAL
+#ifdef TOUCH_UI
+ else if (key == "tile_use_small_layout")
+ tile_use_small_layout = read_maybe_bool(field);
#endif
else if (key == "tile_show_player_species" && field == "true")
{
--
Dungeon Crawl Stone Soup
|