SC2Mapster Forums

Resources > Trigger Libraries & Scripts

[Library] getResolution

    #1 Jan 11, 2011 at 11:46 UTC - 0 likes

    getResolution v1.20

    About

    This library obtains the player's resolution, UI resolution, and scale value with a mouseclick.

    Changelog

    New from v1.10

    • Works better on battle.net (No longer have to ask the player to hold while clicking)
    • Screen flips due to the validation trigger removed
    • Able to check if the player's resolution has changed with the use of a dialog
    • Incorrect numbers clicking while moving the mouse fixed

    New from v1.00

    • Will now work with ANY resolution
    • Retrieves the player's UI screen size (Essential for creating dialogs)
    • Now works in Windowed Mode
    • Nearly half the size of v1.00 (5.30KB compressed)
    • Ability to check resolution to ensure its validity
    • Able to initiate the system for individual players
    • No longer required to enter Camera bounds

    How to use

    There are two functions that can be used:

    • Player Resolution, UI Resolution, Scale Value

    Use this function to initiate the system and obtain the selected player's resolution information.

    InitializationGrammar

    • Check Resolution

    Use this function to check if the player's resolution has changed. It will display an invisible dialog button at the location of their mouse relative to the UI resolution of what it has stored. If the mouse does not enter the dialog then the resolution has been changed. The system will then be reinitialized for that player.

    Check Resolution Grammar

    Creating Dialogs/Screen objects

    After the system has been initiated for the selected player, the information obtained will be stored in three variables:

    • getResolution_PlayerResolution[15][1]
    • getResolution_PlayerUIResolution[15][1]
    • getResolution_PlayerScaleValue[15]

    The first dimension of the arrays are the player's number (0-15). The second dimension of the resolution variables are the Width(0) and Height(1).

    When creating dialog or screen objects, you use the PlayerUIResolution variable. You multiply this variable from a range of 0 to 1. 1 being 100%. Here is an example dialog that takes up 25% of the player's screen.

    Example Dialog Setup

    If the player's UI resolution were 1600x1200, then the above example dialog would translate to:

    Set size of ExampleDialog to ((1600 * .5),(1200 * .5))
    

    which is 25%.

    With this, you can setup dialogs to be exact sizes and at exact positions on the player's screen. Example Dialogs in-game

    Debug

    Here is with debugging enabled:

    Debug

    Download

    Library

    http://www.sc2mapster.com/media/files/543/832/getResolutionv120_GUI.SC2Lib

    Map

    http://www.sc2mapster.com/media/files/543/831/getResolution_v1.20_GUI.SC2Map

    Last edited Sep 26, 2011 by desiderius1
    #2 Jan 24, 2011 at 08:15 UTC - 0 likes

    Very nice library, will definitely use this in my map (and give credit of course).

    #3 Jan 24, 2011 at 10:03 UTC - 0 likes

    yeah, very nice, you could also add how to use it, for example we can only change dialogs size with custom script for each player without making a dialog for every player?

    Homepage: www.sc2goa.com

    #4 Jan 24, 2011 at 14:46 UTC - 0 likes

    @Hookah604: Go

    The main intention of this library is to find the value being multiplied to all dialog dimensions on a player's screen for scaling. The scaling is to keep a dialog's size consistent from resolution to resolution.

    This is very useful information when designing, for example, a custom minimap. If you do not know the minimap's dialog dimensions on a player's screen and want to implement the functionality of being able to pan to a certain place in the world by clicking on the minimap then it would not be possible to achieve. Yes, this was my personal dilemma and thus the creation of the library :).

    So, how do you use this library? If you created a dialog of size 512x256 and a player's resolution is set to 1440x900 then the dialog's size for that player would be 384x192 because the value being multiplied to the dialog's dimensions is .75.

    (512 * .75) = 384
    (256 * .75) = 192
    

    The math in trigger form:

    Example
        Events
        Local Variables
            Example_DialogWidth = 512 <Integer>
            Example_DialogHeight = 256 <Integer>
            Player-Example_DialogWidth = 0.0 <Real[16]>
            Player-Example_DialogHeight = 0.0 <Real[16]>
        Conditions
        Actions
            Player Group - Pick each player in (Active Players) and do (Actions)
                Actions
                    Variable - Set Player-Example_DialogWidth[(Picked player)] = ((Real(Example_DialogWidth)) * getResolution_PlayerUIScaleValue[(Picked player)])
                    Variable - Set Player-Example_DialogHeight[(Picked player)] = ((Real(Example_DialogHeight)) * getResolution_PlayerUIScaleValue[(Picked player)])
    
    Quote from Hookah604: Go

    ...for example we can only change dialogs size with custom script for each player without making a dialog for every player?

    If you are asking if we are able to change a dialog's size for each player, then the answer is no. Changing a dialog's size would reflect the change for all of the players. You would have to create a dialog for each player to do what you want (or see my idea below). But, why would you would to do this? It would cause inconsistency in the scaling as it would make the dialog small on one resolution and large on another.

    Let's compare with a dialog of absolute size 512x256 on resolutions 1024x768 and 1920x1200.

    1024 x 768  = (( 1024 * 768)  / ( 512 * 256)) = 1/6  of the screen
    1920 x 1200 = (( 1920 * 1200) / ( 512 * 256)) = 1/17 of the screen
    

    Quite a difference.

    If however, you still want to do this, then I have a way to achieve it. The only negative about it is that you won't be able to use a dialog background which isn't that bad considering you can just make one with a dialog item (image). The idea summed up is you would have to create the dialog according to the resolution 1280x720 as this has the smallest scale value of all of the resolutions (.6). This would make the dialog perfectly sized for that resolution while larger for the other resolutions, depending on their scale values, but never smaller. After that, you simply add "padding" to the dialog with math when creating or manipulating dialog items. The dialog contents would be aligned and sized with the set dimensions you would provide across all resolutions; they would not be scaled down. Just let me know if you, or anyone else, is interested in this feature and I will implement it.

    Hope that helps.

    Last edited Jan 24, 2011 by desiderius1
    #5 Jan 24, 2011 at 21:24 UTC - 0 likes

    @desiderius1: Go I thought I heard it is possible to set the dialogs size/player with custom script.
    Without that I would have to make dialog and dialog item for every player, which in my case would took lots of time for me to do and would take lots size from my map. I think I will just wait that blizz make some kind of fix.

    #6 Jan 25, 2011 at 02:14 UTC - 0 likes
    Quote from Hookah604: Go

    @desiderius1: Go I thought I heard it is possible to set the dialogs size/player with custom script.

    Here is the function and its parameters in galaxy.

    void DialogSetSize ( dialog dialog, int width, int height )
    

    There is no parameter to specify a particular playergroup or player when setting a dialog size.

    Quote from Hookah604: Go

    @desiderius1: Go Without that I would have to make dialog and dialog item for every player, which in my case would took lots of time for me to do and would take lots size from my map. I think I will just wait that blizz make some kind of fix.

    It's hard to help when I do not know what you are trying to accomplish. If you want you can send me a PM regarding the details. But, have you looked at what I posted above and my idea? With that you would only have to create the dialog in question once as well as all of it's contents only once. You would not have to create a dialog/dialog contents for every player.

    Last edited Jan 25, 2011 by desiderius1
    #7 Jan 25, 2011 at 02:41 UTC - 0 likes

    Hmmm. Excellent excellent. I very much like this.

    #8 Jan 25, 2011 at 08:01 UTC - 0 likes

    @desiderius1: Go

    hmm I not really understand what you mean under padding, But anyway I figured out a way for myself, I could simple make 1 dialog for the biggest resolution, than hide its background. Than down scale and reposition all players dialog items according their resolution in it. (I dont know however that you if you can click through hidden dialog background?) And if you still want dialog background just make a image dialog item or separate dialog for everyone behind the current one.

    I am remaking my dialogs for this map: http://www.sc2mapster.com/maps/warring-factions/ and the new dialogs will be set into the info UI...
    I am still not sure if I will use up your stuff or just wait for blizz to make something.

    #9 Jan 30, 2011 at 03:36 UTC - 0 likes

    @Hookah604: Go

    save the scaling factor as a variable

    Then, make your dialog a loop, For each player should work

    Then, set up the dialogs by using a size, or offset, multiplied by the scaling factor

    Store the dialogs using player number(or loop number) in the loop

    Last edited Jan 30, 2011 by Usernameisntworkingright
    #10 Feb 04, 2011 at 09:05 UTC - 0 likes

    @Usernameisntworkingright: Go

    I know that, but that means I have to make every dialog item for every player. Also I have to scale dialog items size and position according to that. I will just wait for blizz to make it optional to dialogs can be scaled according to resolution. I dont think it would be so hard to make it for them and would really help out.

    #11 Feb 04, 2011 at 09:17 UTC - 0 likes

    Ohhh I made workaround!

    Dont use dialog backgrounds and if you really want to use dialog background than make it with sc2layout. (Dialog item size and position can be set / player)

    However in this case you wont be able to add dialogs offset if you want it to work properly.

    Last edited Feb 04, 2011 by Hookah604
    #12 Feb 04, 2011 at 10:56 UTC - 0 likes

    hmm I get syntax error when I add the library and try to save it.

    #13 Feb 06, 2011 at 02:50 UTC - 0 likes
    Quote from Hookah604: Go

    hmm I get syntax error when I add the library and try to save it.

    • Right-click on the "getResolution" library folder inside the Trigger Editor and go to 'Library -> Change Library ID'.
    • Check 'Use Shared ID' and 'Hexadecimal'.
    • Paste this value: "7E9E8E2B" without the quotes
    • Press Ok
    • Save the map
    #14 Feb 06, 2011 at 03:01 UTC - 0 likes

    To clarify, this DOES still require the user to know their own resolution and choose it and hit continue? If so we may have a problem... In windowed mode you can drag the window to be any size you want... I know I've had ones around 1400 by w/e resolutions from my fraps videos.

    Edit: While the window does constrain you to a max widescreen of 16:9 (I think), it might not be as intuitive for people who do not know their resolution.

    Last edited Feb 06, 2011 by OneTwoSC

    SC2 video tutorials: http://www.youtube.com/onetwosc

    #15 Feb 06, 2011 at 04:02 UTC - 0 likes

    @OneTwoSC: Go

    Yes, in windowed mode it does require the player to select their resolution from a list whereas in fullscreen and windowed(fullscreen) they do not but only have to to click their mouse.

    I am working on an update that will grab the player's resolution as soon as the system is initiated. No mouse clicks required (fullscreen). I'm also working on getting the system to work for windowed mode players so they do not have to pick from a list but may have to click their mouse.

    #16 Feb 06, 2011 at 04:06 UTC - 0 likes

    @desiderius1: Go

    That would be awesome... cause I think in the broad spectrum most users don't remember nor perhaps even understand why they have to do it. In essence, their confusion is similar to ours: Why don't we have a way to figure it out easily lol.

    #17 Feb 06, 2011 at 07:56 UTC - 0 likes

    @desiderius1: Go thx

    Hmm, I wonder how will you make it that it detects resolution.

    #18 Feb 06, 2011 at 08:49 UTC - 0 likes

    It doesnt seems to work with windowed mode, (it says please click again, and happens nothing, even if I use the getresolution map )

    edit:

    this doesnt seems right, when I was using on my map: Variable - Set Player-Example_DialogWidth[(Picked player)] = ((Real(Example_DialogWidth)) * getResolution_PlayerUIScaleValue[(Picked player)])

    isnt it: Variable - Set Player-Example_DialogWidth[(Picked player)] = (((Real(Example_DialogWidth)) * (1 / getResolution_PlayerUIScaleValue[(Picked player)])) ?

    Last edited Feb 06, 2011 by Hookah604
    #19 Feb 07, 2011 at 10:40 UTC - 0 likes
    Quote from Hookah604: Go

    It doesnt seems to work with windowed mode, (it says please click again, and happens nothing, even if I use the getresolution map )

    Click again, a list should appear with either standard or widescreen resolutions.

    Quote from Hookah604: Go

    this doesnt seems right, when I was using on my map: Variable - Set Player-Example_DialogWidth[(Picked player)] = ((Real(Example_DialogWidth)) * getResolution_PlayerUIScaleValue[(Picked player)])

    isnt it: Variable - Set Player-Example_DialogWidth[(Picked player)] = (((Real(Example_DialogWidth)) * (1 / getResolution_PlayerUIScaleValue[(Picked player)])) ?

    I was just showing how dialogs are scaled down depending on the resolution set and demonstrated it in trigger form. If you want to set a dialog to be a specific size on a specific resolution, then the way you are doing it is correct.

    Variable - Set Player-Example_DialogWidth[(Picked player)] = (((Real(Example_DialogWidth)) / (getResolution_PlayerUIScaleValue[(Picked player)]))
    
    Last edited Feb 07, 2011 by desiderius1
    #20 Feb 07, 2011 at 11:46 UTC - 0 likes
    Quote from desiderius1: Go

    Click again, a list should appear with either standard or widescreen resolutions.

    well, it doesnt.

    edit, well it not always seems to work.

    Last edited Feb 07, 2011 by Hookah604

You must login to post a comment. Don't have an account? Register to get one!