summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-20 21:03:48 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-12-20 21:03:48 +0000
commit91e8400448873bd08bd509862f9b6c7d30f29e5b (patch)
treea44b6984e9496dd257303dcc5d319f6f8620cedd /crawl-ref
parent8be1faf8bf1230e22d272720c54bba62d955bc74 (diff)
downloadcrawl-ref-91e8400448873bd08bd509862f9b6c7d30f29e5b.tar.gz
crawl-ref-91e8400448873bd08bd509862f9b6c7d30f29e5b.zip
Adding auto-sizing for font, map, and window sizes. Windows should fit on the screen by default now. The options are still somewhat of a mess, but I don't think that they'll need to be modified by most people.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7889 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/settings/tiles_options.txt42
-rw-r--r--crawl-ref/source/enum.h9
-rw-r--r--crawl-ref/source/externs.h2
-rw-r--r--crawl-ref/source/initfile.cc21
-rw-r--r--crawl-ref/source/tilereg.cc5
-rw-r--r--crawl-ref/source/tilesdl.cc67
-rw-r--r--crawl-ref/source/tilesdl.h3
7 files changed, 98 insertions, 51 deletions
diff --git a/crawl-ref/settings/tiles_options.txt b/crawl-ref/settings/tiles_options.txt
index 733927b86d..ad4750396d 100644
--- a/crawl-ref/settings/tiles_options.txt
+++ b/crawl-ref/settings/tiles_options.txt
@@ -1,10 +1,11 @@
-### The following lines define the colours of various objects within the
-### tiles minimap. See options_guide.txt for more details.
# tile_show_items = !?/%=([)X}+\_.
# tile_title_screen = false
+### The following lines define the colours of various objects within the
+### tiles minimap. See options_guide.txt for more details.
+
# tile_player_col = white
# tile_monster_col = red
# tile_neutral_col = red
@@ -30,6 +31,8 @@
# tile_tooltip_ms = 1000
+### Note: setting window, map, or font sizes to '0' implies auto-sizing.
+
# tile_window_width = 1024
# tile_window_height = 768
# tile_map_pixels = 4
@@ -45,38 +48,3 @@
# tile_font_tip_size = 15
# tile_font_lbl_file = Vera.ttf
# tile_font_lbl_size = 14
-
-### Predefined layouts for smaller standard resolutions. Any window size
-### at or above 1024x768 should probably use the above defaults.
-
-### 800 x 480 (EeePC)
-# tile_window_width = 800
-# tile_window_height = 480
-# tile_map_pixels = 3
-# tile_full_screen = true
-# tile_font_crt_size = 13
-# tile_font_stat_size = 12
-# tile_font_msg_size = 10
-# tile_font_tip_size = 13
-# tile_font_lbl_size = 11
-
-### 1024 x 600 (EeePC 900+)
-# tile_window_width = 1024
-# tile_window_height = 600
-# tile_map_pixels = 3
-# tile_full_screen = true
-# tile_font_crt_size = 14
-# tile_font_stat_size = 14
-# tile_font_msg_size = 12
-# tile_font_tip_size = 13
-# tile_font_lbl_size = 12
-
-### 800 x 600
-# tile_window_width = 800
-# tile_window_height = 600
-# tile_map_pixels = 3
-# tile_font_crt_size = 14
-# tile_font_stat_size = 11
-# tile_font_msg_size = 12
-# tile_font_tip_size = 13
-# tile_font_lbl_size = 12
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index b6547ae8bc..7b1072c2f6 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -3056,6 +3056,15 @@ enum mlist_targetting_type
};
#endif
+#ifdef USE_TILE
+enum screen_mode
+{
+ SCREENMODE_WINDOW = 0,
+ SCREENMODE_FULL = 1,
+ SCREENMODE_AUTO = 2
+};
+#endif
+
#ifdef WIZARD
enum wizard_option_type
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 609377e42b..a25248dc0d 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -2155,7 +2155,7 @@ public:
std::string tile_font_tip_file;
int tile_font_tip_size;
bool tile_key_repeat;
- bool tile_full_screen;
+ screen_mode tile_full_screen;
int tile_window_width;
int tile_window_height;
int tile_map_pixels;
diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc
index 5763bdc482..6dd78738ba 100644
--- a/crawl-ref/source/initfile.cc
+++ b/crawl-ref/source/initfile.cc
@@ -849,22 +849,22 @@ void game_options::reset_options()
// font selection
tile_font_crt_file = "VeraMono.ttf";
- tile_font_crt_size = 15;
+ tile_font_crt_size = 0;
tile_font_stat_file = "VeraMono.ttf";
- tile_font_stat_size = 16;
+ tile_font_stat_size = 0;
tile_font_msg_file = "VeraMono.ttf";
- tile_font_msg_size = 14;
+ tile_font_msg_size = 0;
tile_font_tip_file = "VeraMono.ttf";
- tile_font_tip_size = 15;
+ tile_font_tip_size = 0;
tile_font_lbl_file = "Vera.ttf";
- tile_font_lbl_size = 14;
+ tile_font_lbl_size = 0;
// window layout
tile_key_repeat = true;
- tile_full_screen = false;
- tile_window_width = 1024;
- tile_window_height = 768;
- tile_map_pixels = 4;
+ tile_full_screen = SCREENMODE_AUTO;
+ tile_window_width = 0;
+ tile_window_height = 0;
+ tile_map_pixels = 0;
tile_tooltip_ms = 1000;
#endif
@@ -2998,7 +2998,8 @@ void game_options::read_option_line(const std::string &str, bool runscript)
}
else INT_OPTION(tile_font_lbl_size, 1, INT_MAX);
else BOOL_OPTION(tile_key_repeat);
- else BOOL_OPTION(tile_full_screen);
+ else if (key == "tile_full_screen")
+ tile_full_screen = (screen_mode)_read_bool(field, tile_full_screen);
else INT_OPTION(tile_window_width, 1, INT_MAX);
else INT_OPTION(tile_window_height, 1, INT_MAX);
else INT_OPTION(tile_map_pixels, 1, INT_MAX);
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc
index 27c3948a99..c2a3a6e8ad 100644
--- a/crawl-ref/source/tilereg.cc
+++ b/crawl-ref/source/tilereg.cc
@@ -172,8 +172,11 @@ bool Region::mouse_pos(int mouse_x, int mouse_y, int &cx, int &cy)
{
int x = mouse_x - ox - sx;
int y = mouse_y - oy - sy;
+
bool valid = (x >= 0 && y >= 0);
+ ASSERT(dx > 0);
+ ASSERT(dy > 0);
x /= dx;
y /= dy;
valid &= ((unsigned int)x < mx && (unsigned int)y < my);
@@ -1718,6 +1721,8 @@ MapRegion::MapRegion(unsigned int pixsz) :
m_buf(NULL),
m_far_view(false)
{
+ ASSERT(pixsz > 0);
+
dx = pixsz;
dy = pixsz;
clear();
diff --git a/crawl-ref/source/tilesdl.cc b/crawl-ref/source/tilesdl.cc
index 688512902b..213022d969 100644
--- a/crawl-ref/source/tilesdl.cc
+++ b/crawl-ref/source/tilesdl.cc
@@ -19,6 +19,20 @@
#include <SDL_opengl.h>
#include <SDL_image.h>
+// Default Screen Settings
+// width, height, map, crt, stat, msg, tip, lbl
+static int _screen_sizes[4][8] =
+{
+ // Default
+ {1024, 700, 4, 15, 16, 14, 15, 14},
+ // Eee PC 900+
+ {1024, 600, 3, 14, 14, 12, 13, 12},
+ // Small screen
+ {800, 600, 3, 14, 11, 12, 13, 12},
+ // Eee PC
+ {800, 480, 3, 13, 12, 10, 13, 11}
+};
+
// Note: these defaults should match the OpenGL defaults
GLState::GLState() :
array_vertex(false),
@@ -130,6 +144,12 @@ bool TilesFramework::initialise()
return false;
}
+ {
+ const SDL_VideoInfo* video_info = SDL_GetVideoInfo();
+ m_screen_width = video_info->current_w;
+ m_screen_height = video_info->current_h;
+ }
+
SDL_EnableUNICODE(true);
SDL_WM_SetCaption(CRAWL " " VERSION, CRAWL);
@@ -158,11 +178,30 @@ bool TilesFramework::initialise()
}
unsigned int flags = SDL_OPENGL;
- if (Options.tile_full_screen)
+
+ bool too_small = (m_screen_width < 1024 || m_screen_height < 800);
+ if (Options.tile_full_screen == SCREENMODE_FULL
+ || (Options.tile_full_screen == SCREENMODE_AUTO && too_small))
+ {
flags |= SDL_FULLSCREEN;
+ }
- m_windowsz.x = Options.tile_window_width;
- m_windowsz.y = Options.tile_window_height;
+ if (Options.tile_window_width && Options.tile_window_height)
+ {
+ m_windowsz.x = Options.tile_window_width;
+ m_windowsz.y = Options.tile_window_height;
+ }
+ else if (flags & SDL_FULLSCREEN)
+ {
+ // By default, fill the whole screen.
+ m_windowsz.x = m_screen_width;
+ m_windowsz.y = m_screen_height;
+ }
+ else
+ {
+ m_windowsz.x = std::max(800, m_screen_width - 100);
+ m_windowsz.y = std::max(480, m_screen_height - 100);
+ }
m_context = SDL_SetVideoMode(m_windowsz.x, m_windowsz.y, 0, flags);
if (!m_context)
@@ -174,6 +213,28 @@ bool TilesFramework::initialise()
if (!m_image.load_textures())
return false;
+ // Find which set of _screen_sizes to use.
+ int auto_size = 0;
+ int num_screen_sizes = sizeof(_screen_sizes) / sizeof(_screen_sizes[0]);
+ do
+ {
+ if (m_windowsz.x >= _screen_sizes[auto_size][0]
+ && m_windowsz.y >= _screen_sizes[auto_size][1])
+ {
+ break;
+ }
+ } while (++auto_size < num_screen_sizes - 1);
+
+ // Auto pick map and font sizes if option is zero.
+#define AUTO(x,y) (x = (x) ? (x) : _screen_sizes[auto_size][(y)])
+ AUTO(Options.tile_map_pixels, 2);
+ AUTO(Options.tile_font_crt_size, 3);
+ AUTO(Options.tile_font_stat_size, 4);
+ AUTO(Options.tile_font_msg_size, 5);
+ AUTO(Options.tile_font_tip_size, 6);
+ AUTO(Options.tile_font_lbl_size, 7);
+#undef AUTO
+
int crt_font = load_font(Options.tile_font_crt_file.c_str(),
Options.tile_font_crt_size, true, true);
int msg_font = load_font(Options.tile_font_msg_file.c_str(),
diff --git a/crawl-ref/source/tilesdl.h b/crawl-ref/source/tilesdl.h
index 89ee8dca5c..37fc599061 100644
--- a/crawl-ref/source/tilesdl.h
+++ b/crawl-ref/source/tilesdl.h
@@ -187,6 +187,9 @@ protected:
unsigned int m_last_tick_moved;
std::string m_tooltip;
+
+ int m_screen_width;
+ int m_screen_height;
};
// Main interface for tiles functions