Page 1 of 1

screen resolution

Posted: Tue Jun 23, 2015 11:57 pm
by AndakRainor
Hello!

What are the different screen resolutions to consider when creating a mod ? Is it important ? Have you done anything to adapt your GUI custom elements to it ?

I just have added a water bar next to the food bar in the onDrawInventory, onDrawStats, onDrawSkills and onDrawTraits events of the party. I realized I had to use GraphicsContext.drawImage2(image, x, y, srcX, srcY, srcWidth, srcHeight, destWidth, destHeight) to match the size of the UI in the editor which is a little smaller than in full screen due to window mode. I could not even use the font size used by the game at different resolutions with the text drawing functions, only drawImage2 allows me to match any resolution. Also, GrimTK elements are defined in absolute pixel positions and sizes.

I didn't pay attention to it before trying to customize the GUI, but isn't it a big problem ? I played the game in full screen 1920x1080 mode so I never considered it, but one can also play in windowed mode, so...

Am I going too far on this subject ? Does it matter ? What is the resolution you use while playing, and do you create your mod with only that target resolution in mind ?

Re: screen resolution

Posted: Wed Jun 24, 2015 12:13 am
by minmay
Yes, you need to account for variable resolution. The game actually supports any resolution (via editing the config file or just resizing the window) so you should generalize your code to offset and scale correctly for any width and height. I would consider it a major bug if your mod doesn't do that.
Grimrock 2's builtin GUI elements seem to generally scale with the vertical axis, but not the horizontal one (they just move to remain centered/right/left/etc).

The resolutions offered to me in the options menu are:
1024x768
1152x864
1280x720
1280x800
1280x1024
1360x765
1440x900
1680x1050
1920x1080

It is reasonable to treat 1024 as a minimum width and 720 as a minimum height, I doubt anyone really plays with lower resolution than that.

Re: screen resolution

Posted: Wed Jun 24, 2015 12:25 am
by AndakRainor
Do you use GrimTK in your mod ? How do you adapt the positions and sizes of those elements ? Do you do it once when creating the elements, or dynamically in case the context resolution changes at any time, as it could do in a windowed mode ?

Re: screen resolution

Posted: Wed Jun 24, 2015 1:07 am
by minmay
Yes, you need to do so dynamically as the resolution could change every frame. For example, for a center-aligned element, you can just multiply (or divide, if you prefer) context.width and context.height to get your desired position, then subtract half the width and half the height of the element to center it on that position regardless of resolution.

Re: screen resolution

Posted: Wed Jun 24, 2015 9:01 am
by AndakRainor
I totally see how to do it in all functions where a GraphicsContext parameter is available, but for the GrimTK elements, I never saw anything similar to this in the examples. I don't know if functions exist to update positions and sizes in the framework, or if the GrimTK objects must be redefined, and from which function with a GraphicsContext they should be ?