# HG changeset patch # User Tero Marttila # Date 1231875403 -7200 # Node ID 6c4dc68360eb3f56a0bba4511245cda86105690f # Parent 59c2499fe7bb572b3eda2d141e7c6b0e08e1ed79 remove unused graphics_default, and default to the highest resolution available in fullscreen mode diff -r 59c2499fe7bb -r 6c4dc68360eb src/Application.cc --- a/src/Application.cc Tue Jan 13 21:14:12 2009 +0200 +++ b/src/Application.cc Tue Jan 13 21:36:43 2009 +0200 @@ -56,7 +56,7 @@ arg_resolution = PixelCoordinate(GRAPHICS_RESOLUTION_WIDTH, GRAPHICS_RESOLUTION_HEIGHT); // extra state - bool graphics_default = true; + bool resolution_default = true; try { // parse args @@ -90,10 +90,20 @@ case ARG_FULLSCREEN: arg_fullscreen = true; + + // choose best resolution unless explicitly set + if (resolution_default) { + const CL_DisplayMode best_mode = Graphics::getBestMode(); + const CL_Size best_resolution = best_mode.get_resolution(); + + arg_resolution = PixelCoordinate(best_resolution.width, best_resolution.height); + } + break; case ARG_RESOLUTION: parse_arg_resolution(args.get_argument()); + resolution_default = false; break; case ARG_LIST_MODES: @@ -114,7 +124,7 @@ throw ArgumentError("cannot be both server and client"); // enable graphics by default unless server - if (!arg_server && graphics_default) + if (!arg_server) arg_graphics = true; // continue diff -r 59c2499fe7bb -r 6c4dc68360eb src/Graphics.cc --- a/src/Graphics.cc Tue Jan 13 21:14:12 2009 +0200 +++ b/src/Graphics.cc Tue Jan 13 21:36:43 2009 +0200 @@ -25,6 +25,24 @@ return CL_DisplayMode::get_display_modes(); } +const CL_DisplayMode Graphics::getBestMode (void) { + const std::vector &modes = Graphics::getDisplayModes(); + + const CL_DisplayMode *best_mode = NULL; + + for (std::vector::const_iterator it = modes.begin(); it != modes.end(); it++) + if (best_mode == NULL || ( + it->get_resolution().width * it->get_resolution().height > + best_mode->get_resolution().width * best_mode->get_resolution().height + )) + best_mode = &*it; + + if (best_mode == NULL) + throw Error("No available video modes!"); + + return *best_mode; +} + void Graphics::check_input (void) { LocalPlayer *player; PlayerInput input_mask; diff -r 59c2499fe7bb -r 6c4dc68360eb src/Graphics.hh --- a/src/Graphics.hh Tue Jan 13 21:14:12 2009 +0200 +++ b/src/Graphics.hh Tue Jan 13 21:36:43 2009 +0200 @@ -38,10 +38,23 @@ public: Graphics (Engine &engine, GameState &state, PixelCoordinate resolution, bool fullscreen); - + + /** + * Returns a CL_Font that can be used for drawing text + */ CL_Font& getSimpleFont (void) { return simple_font; } + + /** + * Returns a vector of CL_DisplayModes that lists possible display modes to use for fullscreen mode. + */ + static const std::vector & getDisplayModes (void); - static const std::vector & getDisplayModes (void); + /** + * Returns the "best" CL_DisplayMode to use for fullscreen mode. + * + * Currently, this just means the largest resolution. + */ + static const CL_DisplayMode getBestMode (void); private: /**