add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen)
->set_help(_("Let the game cover the whole screen"));
- MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ration"));
+ MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ratio"));
aspect->set_help(_("Adjust the aspect ratio"));
+
aspect->list.push_back("16:9");
aspect->list.push_back("16:10");
aspect->list.push_back("4:3");
aspect->list.push_back("5:4");
+ std::ostringstream out;
+ out << config->aspect_width << ":" << config->aspect_height;
+ std::string aspect_ratio = out.str();
+ for(std::vector<std::string>::iterator i = aspect->list.begin(); i != aspect->list.end(); ++i)
+ {
+ if(*i == aspect_ratio)
+ {
+ aspect_ratio.clear();
+ break;
+ }
+ }
+
+ if (!aspect_ratio.empty())
+ {
+ aspect->selected = aspect->list.size();
+ aspect->list.push_back(aspect_ratio);
+ }
+
if (sound_manager->is_audio_enabled()) {
add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled)
->set_help(_("Disable all sound effects in the game"));
switch (item->id) {
case MNID_ASPECTRATIO:
{ // FIXME: Really crude and ugly here, move to video or so
- int aspect_width;
- int aspect_height;
-
- if(sscanf(item->list[item->selected].c_str(), "%d:%d", &aspect_width, &aspect_height) == 2)
+ if(sscanf(item->list[item->selected].c_str(), "%d:%d", &config->aspect_width, &config->aspect_height) == 2)
{
- config->aspect_ratio = static_cast<double>(aspect_width) /
- static_cast<double>(aspect_height);
+ float aspect_ratio = static_cast<double>(config->aspect_width) /
+ static_cast<double>(config->aspect_height);
- if (config->aspect_ratio > 1) {
- SCREEN_WIDTH = static_cast<int> (600 * config->aspect_ratio + 0.5);
+ if (aspect_ratio > 1) {
+ SCREEN_WIDTH = static_cast<int> (600 * aspect_ratio + 0.5);
SCREEN_HEIGHT = 600;
} else {
SCREEN_WIDTH = 600;
- SCREEN_HEIGHT = static_cast<int> (600 * 1/config->aspect_ratio + 0.5);
+ SCREEN_HEIGHT = static_cast<int> (600 * 1/aspect_ratio + 0.5);
}
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
std::cout << __FILE__ << ":" << __LINE__ << ": change aspect ratio to " << item->list[item->selected] << std::endl;
+
+ // Reposition the menu to be in the center of the screen again
+ set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
}
}
break;