Allow resolution to be configurable in preferences file...

...using xresolution and yresolution options
This commit is contained in:
Dave White 2003-09-18 12:47:17 +00:00
parent 4e492d7a92
commit 5fd5346808
75 changed files with 128 additions and 6 deletions

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

1
ai.cpp
View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

1
ai.hpp
View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@ -174,10 +175,14 @@ int play_game(int argc, char** argv)
}
}
const int bpp = video.modePossible(1152,864,16,video_flags);
const std::pair<int,int>& resolution = preferences::resolution();
const int bpp = video.modePossible(resolution.first,resolution.second,
16,video_flags);
if(bpp == 0) {
std::cerr << "The required video mode, 1024x768x16 "
std::cerr << "The required video mode, " << resolution.first
<< "x" << resolution.second << "x16 "
<< "is not supported\n";
if(video_flags == FULL_SCREEN && argc == 0)
@ -195,9 +200,12 @@ int play_game(int argc, char** argv)
<< "For best results, run the program on a 16 bpp display\n";
}
const int res = video.setMode(1152,864,16,video_flags);
std::cerr << "setting mode to " << resolution.first << "x" << resolution.second << "\n";
const int res = video.setMode(resolution.first,resolution.second,
16,video_flags);
if(res != 16) {
std::cerr << "required video mode, 1024x768x16 is not supported\n";
std::cerr << "required video mode, " << resolution.first << "x"
<< resolution.second << "x16 is not supported\n";
return 0;
}

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@ -71,11 +72,12 @@ void set_fullscreen(bool ison)
prefs.values["fullscreen"] = (ison ? "true" : "false");
if(disp != NULL) {
const std::pair<int,int>& res = resolution();
CVideo& video = disp->video();
if(video.isFullScreen() != ison) {
const int flags = ison ? FULL_SCREEN : 0;
if(video.modePossible(1024,768,16,flags)) {
video.setMode(1024,768,16,flags);
if(video.modePossible(res.first,res.second,16,flags)) {
video.setMode(res.first,res.second,16,flags);
disp->redraw_everything();
} else {
gui::show_dialog(*disp,NULL,"",string_table["video_mode_fail"],
@ -85,6 +87,41 @@ void set_fullscreen(bool ison)
}
}
std::pair<int,int> resolution()
{
const string_map::const_iterator x = prefs.values.find("xresolution");
const string_map::const_iterator y = prefs.values.find("yresolution");
if(x != prefs.values.end() && y != prefs.values.end() &&
x->second.empty() == false && y->second.empty() == false) {
return std::pair<int,int>(atoi(x->second.c_str()),
atoi(y->second.c_str()));
} else {
return std::pair<int,int>(1024,768);
}
}
void set_resolution(const std::pair<int,int>& res)
{
if(disp != NULL) {
CVideo& video = disp->video();
const int flags = video.isFullScreen() ? FULL_SCREEN : 0;
if(video.modePossible(res.first,res.second,16,flags)) {
video.setMode(res.first,res.second,16,flags);
disp->redraw_everything();
char buf[50];
sprintf(buf,"%d",res.first);
prefs.values["xresolution"] = buf;
sprintf(buf,"%d",res.second);
prefs.values["yresolution"] = buf;
} else {
gui::show_dialog(*disp,NULL,"",string_table["video_mode_fail"],
gui::MESSAGE);
}
}
}
bool turbo()
{
const string_map::const_iterator turbo = prefs.values.find("turbo");

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@ -16,6 +17,7 @@
#include "display.hpp"
#include <string>
#include <utility>
namespace preferences {
@ -34,6 +36,9 @@ namespace preferences {
bool fullscreen();
void set_fullscreen(bool ison);
std::pair<int,int> resolution();
void set_resolution(const std::pair<int,int>& res);
bool turbo();
void set_turbo(bool ison);

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net

View File

@ -1,3 +1,4 @@
/* $Id$ */
/*
Copyright (C) 2003 by David White <davidnwhite@optusnet.com.au>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net