diff options
author | miramor <danlev@norwoodlight.com> | 2012-05-10 11:37:54 -0400 |
---|---|---|
committer | Bardur Arantsson <bardur@scientician.net> | 2012-05-12 16:33:30 +0200 |
commit | fe5dd7b9e92838bd0116270a884ef034e52237ce (patch) | |
tree | 2f328000c55db8350c52b8ed4decd6dce6a6a7dd | |
parent | 13543856597dc59f3cf8b7ecbf7d2e77e07c7f69 (diff) |
SDL: make window sizing automatic depending on font size
-rw-r--r-- | src/main-sdl.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/src/main-sdl.c b/src/main-sdl.c index 840859e9..b34325be 100644 --- a/src/main-sdl.c +++ b/src/main-sdl.c @@ -35,19 +35,13 @@ /************************************************* GLOBAL SDL-ToME PROPERTIES *************************************************/ - -/* Default window properties - used if none are available -from other places*/ -#define DEF_SCREEN_WIDTH 800 -#define DEF_SCREEN_HEIGHT 600 -#define DEF_SCREEN_BPP 16 /*Main window properties that may be loaded at runtime from a preference file or environmental variables. However, default values (defined above) can be used. */ -static int arg_width = DEF_SCREEN_WIDTH; -static int arg_height = DEF_SCREEN_HEIGHT; -static int arg_bpp = DEF_SCREEN_BPP; +static int arg_width = 0; +static int arg_height = 0; +static int arg_bpp = 16; /**************/ @@ -2137,6 +2131,26 @@ errr init_sdl(int argc, char **argv) else videoFlags = SDL_SWSURFACE; + /* Now ready the fonts! */ + + DB("initializing SDL_ttf"); + if(TTF_Init()==-1) { + printf("TTF_Init: %s\n", TTF_GetError()); + sdl_quit("Bah"); + } + + DB("loading font..."); + + /* load and render the font */ + loadAndRenderFont(arg_font_name,arg_font_size); + + /* Make the window a nice default size if none is specified */ + if (arg_width < 1 || arg_height < 1) + { + arg_width = 80 * t_width; + arg_height = 24 * t_height; + } + /* now set the video mode that has been configured */ screen = SDL_SetVideoMode( arg_width, arg_height, arg_bpp, videoFlags ); @@ -2155,19 +2169,6 @@ errr init_sdl(int argc, char **argv) DB("SDL Window Created!"); - /* Now ready the fonts! */ - - DB("initializing SDL_ttf"); - if(TTF_Init()==-1) { - printf("TTF_Init: %s\n", TTF_GetError()); - sdl_quit("Bah"); - } - - DB("loading font..."); - - /* load and render the font */ - loadAndRenderFont(arg_font_name,arg_font_size); - /* Graphics! ---- If graphics are selected, then load graphical tiles! */ if (arg_graphics_type != NO_GRAPHICS) |