fullscreen_width = 800;
fullscreen_height = 600;
- projection_width = 800;
- projection_height = 600;
- scale_projection = true;
+ magnification = 1.0f;
aspect_width = 4;
aspect_height = 3;
config_video_lisp->get("window_width", window_width);
config_video_lisp->get("window_height", window_height);
- config_video_lisp->get("projection_width", projection_width);
- config_video_lisp->get("projection_height", projection_height);
- config_video_lisp->get("scale_projection", scale_projection);
-
config_video_lisp->get("aspect_width", aspect_width);
config_video_lisp->get("aspect_height", aspect_height);
}
writer.write_int("window_width", window_width);
writer.write_int("window_height", window_height);
- writer.write_int("projection_width", projection_width);
- writer.write_int("projection_height", projection_height);
- writer.write_bool("scale_projection", scale_projection);
-
writer.write_int("aspect_width", aspect_width);
writer.write_int("aspect_height", aspect_height);
int window_width;
int window_height;
- // the projection area size before aspectratio is applied
- int projection_width;
- int projection_height;
-
- // scale the projection area or leave it at 1:1 pixel mapping
- bool scale_projection;
-
// the aspect ratio
int aspect_width;
int aspect_height;
+
+ float magnification;
bool use_fullscreen;
VideoSystem video;
// just to be sure...
main_controller->reset();
}
+
+void
+Menu::recalc_pos()
+{
+ if (current_)
+ current_->set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
+
+ for(std::vector<Menu*>::iterator i = last_menus.begin(); i != last_menus.end(); ++i)
+ {
+ // FIXME: This is of course not quite right, since it ignores any previous set_pos() calls
+ (*i)->set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
+ }
+}
\f
MenuItem::MenuItem(MenuItemKind _kind, int _id)
: kind(_kind) , id(_id)
static void push_current(Menu* pmenu);
+ static void recalc_pos();
+
/** Return the current active menu or NULL if none is active */
static Menu* current()
{
config->fullscreen_width = 800;
config->fullscreen_height = 600;
- config->projection_width = 800;
- config->projection_height = 600;
- config->scale_projection = true;
-
config->aspect_width = 4;
config->aspect_height = 3;
}
else
{
- config->projection_width = width;
- config->projection_height = height;
-
config->window_width = width;
config->window_height = height;
}
#endif
- // FIXME: Add aspect handling
- SCREEN_WIDTH = config->projection_width;
- SCREEN_HEIGHT = config->projection_height;
+ // FIXME: Add something here
+ SCREEN_WIDTH = 800;
+ SCREEN_HEIGHT = 600;
context_pointer->init_renderer();
screen = SDL_GetVideoSurface();
SDL_ShowCursor(0);
log_info << (config->use_fullscreen?"fullscreen ":"window ")
- << " Window: " << config->window_width << "x" << config->window_height
+ << " Window: " << config->window_width << "x" << config->window_height
<< " Fullscreen: " << config->fullscreen_width << "x" << config->fullscreen_height
- << " Projection: " << config->projection_width << "x" << config->projection_height
- << " Area: " << config->aspect_width << "x" << config->aspect_height << std::endl;
+ << " Area: " << config->aspect_width << "x" << config->aspect_height << std::endl;
}
static void init_audio()
case SDL_VIDEORESIZE:
Renderer::instance()->resize(event.resize.w, event.resize.h);
+ Menu::recalc_pos();
break;
case SDL_KEYDOWN:
add_toggle(MNID_SOUND, _("Profile on Startup"), config->sound_enabled)
->set_help(_("Display the profile menu when the game is newly started"));
- // FIXME: Implement me: if (get_parent() == main_menu)
add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen)
->set_help(_("Let the game cover the whole screen"));
+ MenuItem* fullscreen_res = add_string_select(MNID_FULLSCREEN_RESOLUTION, _("Resolution"));
+ fullscreen_res->set_help(_("Change the Resolution to be used in Fullscreen Mode, you have to toggle fullscreen mode to let this change take effect"));
+
MenuItem* maginfication = add_string_select(MNID_MAGINFICATION, _("Maginfication"));
maginfication->set_help(_("Change the magnification, to small values will result in a black border around the screen"));
- maginfication->list.push_back("-2");
- maginfication->list.push_back("-1");
- maginfication->list.push_back("0");
- maginfication->list.push_back("1");
- maginfication->list.push_back("2");
+ maginfication->list.push_back("0.5");
+ maginfication->list.push_back("0.625");
+ maginfication->list.push_back("0.8");
+ maginfication->list.push_back("1.0");
+ maginfication->list.push_back("1.25");
+ maginfication->list.push_back("1.6");
+ maginfication->list.push_back("2.0");
- MenuItem* fullscreen_res = add_string_select(MNID_FULLSCREEN_RESOLUTION, _("Resolution"));
- fullscreen_res->set_help(_("Change the Resolution to be used in Fullscreen Mode, you have to toggle fullscreen mode to let this change take effect"));
+ SDL_Rect** modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_OPENGL);
- // FIXME: Hardcoded values are evil, these should be queried from the Xorg server
- fullscreen_res->list.push_back("640x480");
- fullscreen_res->list.push_back("800x600");
- fullscreen_res->list.push_back("1024x768");
- fullscreen_res->list.push_back("1152x864");
- fullscreen_res->list.push_back("1280x960");
- fullscreen_res->list.push_back("1280x1024");
- fullscreen_res->list.push_back("1440x900");
- fullscreen_res->list.push_back("1680x1050");
- fullscreen_res->list.push_back("1600x1200");
- fullscreen_res->list.push_back("1920x1080");
- fullscreen_res->list.push_back("1920x1200");
+ if (modes == (SDL_Rect **)0)
+ { // No resolutions at all available, bad
+
+ }
+ else if(modes == (SDL_Rect **)-1)
+ { // All resolutions sould work, so we fall back to hardcoded defaults
+ fullscreen_res->list.push_back("640x480");
+ fullscreen_res->list.push_back("800x600");
+ fullscreen_res->list.push_back("1024x768");
+ fullscreen_res->list.push_back("1152x864");
+ fullscreen_res->list.push_back("1280x960");
+ fullscreen_res->list.push_back("1280x1024");
+ fullscreen_res->list.push_back("1440x900");
+ fullscreen_res->list.push_back("1680x1050");
+ fullscreen_res->list.push_back("1600x1200");
+ fullscreen_res->list.push_back("1920x1080");
+ fullscreen_res->list.push_back("1920x1200");
+ }
+ else
+ {
+ for(int i = 0; modes[i]; ++i)
+ {
+ std::ostringstream out;
+ out << modes[i]->w << "x" << modes[i]->h;
+ fullscreen_res->list.push_back(out.str());
+ }
+ }
MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ratio"));
aspect->set_help(_("Adjust the aspect ratio"));
{
switch (item->id) {
case MNID_ASPECTRATIO:
- { // FIXME: Really crude and ugly here, move to video or so
+ {
if(sscanf(item->list[item->selected].c_str(), "%d:%d", &config->aspect_width, &config->aspect_height) == 2)
{
Renderer::instance()->apply_config();
-
- // Reposition the menu to be in the center of the screen again
- // FIXME: We need to relayout the whole menu stack! Not just current
- set_pos(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
+ Menu::recalc_pos();
}
}
break;
+ case MNID_MAGINFICATION:
+ if(sscanf(item->list[item->selected].c_str(), "%f", &config->magnification) == 1)
+ {
+ Renderer::instance()->apply_config();
+ Menu::recalc_pos();
+ }
+ break;
+
+ case MNID_FULLSCREEN_RESOLUTION:
+ if(sscanf(item->list[item->selected].c_str(), "%dx%d", &config->fullscreen_width, &config->fullscreen_height) == 2)
+ {
+ Renderer::instance()->apply_config();
+ Menu::recalc_pos();
+ }
+ break;
+
case MNID_FULLSCREEN:
if(config->use_fullscreen != options_menu->is_toggled(MNID_FULLSCREEN)) {
config->use_fullscreen = !config->use_fullscreen;
void
Renderer::apply_config()
{
- std::cout << "Applying Config: " << config->aspect_width << ":" << config->aspect_height << std::endl;
+ std::cout << "Applying Config:"
+ << "\n Desktop: " << desktop_width << "x" << desktop_height
+ << "\n Window: " << config->window_width << "x" << config->window_height
+ << "\n FullRes: " << config->fullscreen_width << "x" << config->fullscreen_height
+ << "\n Aspect: " << config->aspect_width << ":" << config->aspect_height
+ << "\n Magnif: " << config->magnification
+ << std::endl;
int w,h;
float target_aspect = float(config->aspect_width) / float(config->aspect_height);
h = config->window_height;
}
- std::cout
- << " -> " << w << "x" << h << " -> " << target_aspect << " " << desktop_aspect << std::endl;
-
if (target_aspect > 1.0f)
{
SCREEN_WIDTH = w * (target_aspect / desktop_aspect);
SCREEN_HEIGHT = h * (target_aspect / desktop_aspect);
}
- // Limit must take aspect into account
- //SCREEN_WIDTH = std::min(w, 1024);
- //SCREEN_HEIGHT = std::min(h, 768);
+ SCREEN_WIDTH *= config->magnification;
+ SCREEN_HEIGHT *= config->magnification;
+
+ int max_width = 1600;
+ int max_height = 1200;
+
+ // A little wonky
+ if (SCREEN_WIDTH > max_width)
+ {
+ float scale = float(max_width)/SCREEN_WIDTH;
+ SCREEN_WIDTH *= scale;
+ SCREEN_HEIGHT *= scale;
+ }
+ else if (SCREEN_HEIGHT > max_height)
+ {
+ float scale = float(max_height)/SCREEN_HEIGHT;
+ SCREEN_WIDTH *= scale;
+ SCREEN_HEIGHT *= scale;
+ }
+
+ std::cout << " -> " << SCREEN_WIDTH << "x" << SCREEN_HEIGHT << std::endl;
- // Position the Viewport in the center of the window
- glViewport(std::max(0, (config->window_width - w)/2),
- std::max(0, (config->window_height - h)/2),
- w, h);
+ glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();