Author Topic: [done] Allow mod / scenario images to have diff images for diff aspect ratios  (Read 1108 times)

Omega

  • MegaGlest Team
  • Dragon
  • ********
  • Posts: 6,167
  • Professional bug writer
    • View Profile
    • Personal site
Mods and recently scenarios have loading images (or background images in the case of scenarios) which are resolution independent: the same image is used for all aspect ratios, and is simply stretched or compressed as needed. I'd like to propose an optional alternative for modders to use (which is especially useful if their backgrounds contain elements that don't stretch or compress well, such as text).

In factions (for example), the loading image is simply an image named loading_screen.* in the root faction folder. I propose that if there are any files in the format loading_screen_#.* (where "#" is any number), they will instead be used. What does the number mean? It's the ratio of the width to the height (when height is equal to 1). So for example, the standard 16:9 ratio can be written as 1.78:1, so we'd name the file loading_screen_1.78.*. The file used as the loading image would be whatever number the used aspect ratio is closest to.

So for example, suppose I made loading screen images in the two most common formats, 16:9 and 4:3. The file names would then be loading_screen_1.78.jpg and loading_screen_1.33.jpg. If the player is using a resolution that has an aspect ratio of 8:5, the ratio of width to height is 1.6. This is closer to the 1.78 (from the 16:9 image), so loading_screen_1.78.jpg is used.

So why bother with this instead of just letting the game automatically compress or stretch images? Because the difference between a 4:3 aspect ratio and a 16:9 ratio is quite large. While a simple image of buildings might have some noticeable distortion, that's usually fine. But for things like text, fine shapes, things that should have obvious proportions (such as circles), etc, the distortion isn't so good. For the modder, this could be as simple as cropping the image and resaving it (20 seconds of work), although more complex images may need elements to be moved to properly fit the different aspect ratio. For the most part, an image for each of the two most common resolutions: 16:9 and 4:3 would be all modders would have to do (since other aspect ratios are generally rather close to one of these, and would just use whatever is closest).
« Last Edit: 11 February 2013, 23:56:42 by softcoder »
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

GunChleoc

  • Horseman
  • ****
  • Posts: 202
    • View Profile
    • Fòram na Gàidhlig
Squashed and stretched images are one of my pet peeves, to this gets a thumbs up from me :)

Coldfusionstorm

  • Golem
  • ******
  • Posts: 868
    • View Profile
This sounds like a good idea.
WiP Game developer.
I do danish translations.
"i break stuff"

softcoder

  • MegaGlest Team
  • Battle Machine
  • ********
  • Posts: 2,239
    • View Profile
This is now commited in svn. There is no special naming convention required to find other textures other than they must start with:

const char * GameConstants::LOADING_SCREEN_FILE_FILTER = "loading_screen*.*";
const char * GameConstants::PREVIEW_SCREEN_FILE_FILTER = "preview_screen*.*";
const char * GameConstants::HUD_SCREEN_FILE_FILTER     = "hud*.*";

So you can name they with anything you want as long as the filenames start with the names above. We then load the image to check its width and height and select the closest that matches your screen resolution.