Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. Red Dead Redemption 2

      1. PC
      2. Gameplay
      3. Missions
      4. Help & Support
    2. Red Dead Online

      1. Gameplay
      2. Find Lobbies & Outlaws
      3. Help & Support
      4. Frontier Pursuits
    1. Crews & Posses

      1. Recruitment
    2. Events

    1. GTA Online

      1. DLC
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
      7. The Diamond Casino Heist
    2. Grand Theft Auto Series

    3. GTA 6

    4. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    5. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA IV Mods
    6. GTA Chinatown Wars

    7. GTA Vice City Stories

    8. GTA Liberty City Stories

    9. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA SA Mods
    10. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA VC Mods
    11. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA III Mods
    12. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    13. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. News

    2. Forum Support

    3. Site Suggestions

ClareXoBearrx3R9

Text Placement on Varying Resolutions

Recommended Posts

ClareXoBearrx3R9

Hello,

I'm working on a mod that has a 'dashboard' with status text displayed on the screen that can be turned on/off. I'm far from being a graphics pro but when I wrote it, I tested it and placed the positioning on my computer (using 800x600 resolution) and all is fine. The problem is when people use it at other resolutions, like 1900x1200, the positioning becomes stretched and thus looks odd/ugly.

My old method I used was this:

int font = 4, text_drop_shadow[] = { 4, 0, 0, 0, 255 }, text_rgb_color[] = { 255, 255, 255, 255 };;    float text_scale = 0.45;        text = "MOD :"; // Disabled    UI::SET_TEXT_FONT(font);    UI::SET_TEXT_SCALE(text_scale, text_scale);    UI::SET_TEXT_COLOUR(255, 255, 255, 255);    UI::SET_TEXT_WRAP(0.0, 1.0);    UI::SET_TEXT_CENTRE(0); // o = 1.    UI::SET_TEXT_DROPSHADOW(text_drop_shadow[0], text_drop_shadow[1], text_drop_shadow[2], text_drop_shadow[3], text_drop_shadow[4]);    UI::SET_TEXT_EDGE(1, 0, 0, 0, 205);    UI::_SET_TEXT_ENTRY("STRING");    UI::_ADD_TEXT_COMPONENT_STRING((char *)text.c_str());    pos_x = ((.27f)*((float)screen_w)) / 800.0f;    UI::_DRAW_TEXT(0.27f, 0.06f);        if (enabled == false){        text = "Disabled";        UI::SET_TEXT_COLOUR(225, 0, 0, 255);    }    else{        text = "Enabled";        UI::SET_TEXT_COLOUR(0, 225, 0, 255);    }        UI::SET_TEXT_FONT(font);    UI::SET_TEXT_SCALE(text_scale, text_scale);    UI::SET_TEXT_WRAP(0.0, 1.0);    UI::SET_TEXT_CENTRE(0);    UI::SET_TEXT_DROPSHADOW(text_drop_shadow[0], text_drop_shadow[1], text_drop_shadow[2], text_drop_shadow[3], text_drop_shadow[4]);    UI::SET_TEXT_EDGE(1, 0, 0, 0, 205);    UI::_SET_TEXT_ENTRY("STRING");    UI::_ADD_TEXT_COMPONENT_STRING((char *)text.c_str());    UI::_DRAW_TEXT(0.3f, 0.06f);

And this works perfectly on my screen with 800x600 resolution, looking something like this:

MOD: ENABLED

However when used on another resolution, it becomes stretched like this:

MOD: ENABLED

So I decided to do some math to try and fix the stretching/positioning (just somewhat guessing) as follows:

   int screen_w, screen_h;    GRAPHICS::_GET_SCREEN_ACTIVE_RESOLUTION(&screen_w, &screen_h);    int font = 4, text_drop_shadow[] = { 4, 0, 0, 0, 255 }, text_rgb_color[] = { 255, 255, 255, 255 };;    float text_scale = 0.45;        text = "MOD :";    UI::SET_TEXT_FONT(font);    UI::SET_TEXT_SCALE(text_scale, text_scale);    UI::SET_TEXT_COLOUR(255, 255, 255, 255);    UI::SET_TEXT_WRAP(0.0, 1.0);    UI::SET_TEXT_CENTRE(0); // o = 1.    UI::SET_TEXT_DROPSHADOW(text_drop_shadow[0], text_drop_shadow[1], text_drop_shadow[2], text_drop_shadow[3], text_drop_shadow[4]); // o = all 0's.    UI::SET_TEXT_EDGE(1, 0, 0, 0, 205);    UI::_SET_TEXT_ENTRY("STRING");    UI::_ADD_TEXT_COMPONENT_STRING((char *)text.c_str());    pos_x = ((.27f)*((float)screen_w)) / 800.0f;    UI::_DRAW_TEXT(pos_x, 0.06f);    if (enabled == false){        text = "Disabled";        UI::SET_TEXT_COLOUR(225, 0, 0, 255);    }    else{        text = "Enabled";        UI::SET_TEXT_COLOUR(0, 225, 0, 255);    }        UI::SET_TEXT_FONT(font);    UI::SET_TEXT_SCALE(text_scale, text_scale);    UI::SET_TEXT_WRAP(0.0, 1.0);    UI::SET_TEXT_CENTRE(0);    UI::SET_TEXT_DROPSHADOW(text_drop_shadow[0], text_drop_shadow[1], text_drop_shadow[2], text_drop_shadow[3], text_drop_shadow[4]); // o = all 0's.    UI::SET_TEXT_EDGE(1, 0, 0, 0, 205);    UI::_SET_TEXT_ENTRY("STRING");    UI::_ADD_TEXT_COMPONENT_STRING((char *)text.c_str());    pos_x = ((.3f)*((float)screen_w)) / 800.0f;    UI::_DRAW_TEXT(pos_x, 0.06f);

I'm aware of the positioning being a percentage across each axis. So basically what I figured, was - as long as I have the positioning correct on 800x600 (the width being 800) - I can just 'proportion' it to fit other resolutions. The problem then is that the text is (again) fine for 800x600 but when using any other resolution, everything becomes shifted and overflows like this:

MOD: ENABL
E
D


So my question is, anyone know how to solve/fix/do this the right way? :(
I've tried everything I can think of (only worried about width right now) and can't come up with anything that appears to work. :/

 

Thanks in advance! :D

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

So I just realized that being a "percentage" of the screen, no additional calculations should need to be done. But ..... I want to prevent the text from being completely spread out. Anyone have any ideas? :panic:

 

So example...:

 

On 800x600, it looks like this:

Jiek5Br.png

 

but on 1980x1200, it looks like this:

D3u9qrg.png

 

and thus sometimes also gets in the way of stuff like your money count and whatnot. Not to mention it looks weird when it's stretched D:

Edited by ClareXoBearrx3

Share this post


Link to post
Share on other sites
m_boy


That's what I use :

int screen_w, screen_h;GRAPHICS::_GET_SCREEN_ACTIVE_RESOLUTION(&screen_w, &screen_h);const float height = 1080.0f;float ratio = (float) screen_w / screen_h;float width = height * ratio;float textX = X / width;float textY = Y / height;   // X and Y - your value

Maybe this will help. Try it!

Share this post


Link to post
Share on other sites
pillow

just use GRAPHICS::_GET_SCREEN_ACTIVE_RESOLUTION(&screen_w, &screen_h);

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

That's what I use :

int screen_w, screen_h;GRAPHICS::_GET_SCREEN_ACTIVE_RESOLUTION(&screen_w, &screen_h);const float height = 1080.0f;float ratio = (float) screen_w / screen_h;float width = height * ratio;float textX = X / width;float textY = Y / height;   // X and Y - your value

Maybe this will help. Try it!

 

 

Thanks!

 

I tried this however and instead, it all got mashed to the left of the screen like this:

 

2BPShCt.png

:blink:

This is the code I'm using (I changed the height to 600 since I'm running at 800x600 and scaling it from there):

 int screen_w, screen_h;    GRAPHICS::_GET_SCREEN_ACTIVE_RESOLUTION(&screen_w, &screen_h);    const float height = 600.0f; // o = 1080.0f    float ratio = (float)screen_w / screen_h;    float width = height * ratio;    float textX_Line1[] = { (0.27f / width), (0.37f / width), (0.47f / width), (0.57f / width), (0.67f / width), (0.77f / width) };    float textY[] = { (0.06f / height) };   // X and Y - your value    if (is_enabled > -1 && is_enabled < 5){        text = "EIS:  ~r~Disabled"; // Disabled    }    else{        text = "EIS:  ~g~Enabled";    }    UI::SET_TEXT_FONT(font);    UI::SET_TEXT_SCALE(text_scale, text_scale);    UI::SET_TEXT_COLOUR(255, 255, 255, 255);    UI::SET_TEXT_WRAP(0.0, 1.0);    UI::SET_TEXT_CENTRE(0); // o = 1.    UI::SET_TEXT_DROPSHADOW(text_drop_shadow[0], text_drop_shadow[1], text_drop_shadow[2], text_drop_shadow[3], text_drop_shadow[4]); // o = all 0's.    UI::SET_TEXT_EDGE(1, 0, 0, 0, 205);    UI::_SET_TEXT_ENTRY("STRING");    UI::_ADD_TEXT_COMPONENT_STRING((char *)text.c_str());    UI::_DRAW_TEXT(textX_Line1[0], textY[0]);    // --- Display only if EIS is enabled ---    if (is_enabled > 4){                if (is_nspjl_enabled >= 0 && is_nspjl_enabled < 5){            text = "PCL:  ~r~Disabled";        }        else{            text = "PCL:  ~g~Enabled";        }        UI::SET_TEXT_FONT(font);        UI::SET_TEXT_SCALE(text_scale, text_scale);        UI::SET_TEXT_COLOUR(255, 255, 255, 255);        UI::SET_TEXT_WRAP(0.0, 1.0);        UI::SET_TEXT_CENTRE(0); // o = 1.        UI::SET_TEXT_DROPSHADOW(text_drop_shadow[0], text_drop_shadow[1], text_drop_shadow[2], text_drop_shadow[3], text_drop_shadow[4]); // o = all 0's.        UI::SET_TEXT_EDGE(1, 0, 0, 0, 205);        UI::_SET_TEXT_ENTRY("STRING");        UI::_ADD_TEXT_COMPONENT_STRING((char *)text.c_str());        UI::_DRAW_TEXT(textX_Line1[1], textY[0]);        if (is_npvds_enabled >= 0 && is_npvds_enabled < 5){            text = "NVDS:  ~r~Disabled";        }        else{            text = "NVDS:  ~g~Enabled";        }        UI::SET_TEXT_FONT(font);        UI::SET_TEXT_SCALE(text_scale, text_scale);        UI::SET_TEXT_COLOUR(255, 255, 255, 255);        UI::SET_TEXT_WRAP(0.0, 1.0);        UI::SET_TEXT_CENTRE(0); // o = 1.        UI::SET_TEXT_DROPSHADOW(text_drop_shadow[0], text_drop_shadow[1], text_drop_shadow[2], text_drop_shadow[3], text_drop_shadow[4]); // o = all 0's.        UI::SET_TEXT_EDGE(1, 0, 0, 0, 205);        UI::_SET_TEXT_ENTRY("STRING");        UI::_ADD_TEXT_COMPONENT_STRING((char *)text.c_str());        UI::_DRAW_TEXT(textX_Line1[2], textY[0]);        //text = "PSEC :";        if (is_pss_enabled >= 0 && is_pss_enabled < 5){            text = "PSEC:  ~r~Disabled";            //UI::SET_TEXT_COLOUR(225, 0, 0, 255);        }        else{            text = "PSEC:  ~g~Enabled";            //UI::SET_TEXT_COLOUR(0, 225, 0, 255);        }        UI::SET_TEXT_FONT(font);        UI::SET_TEXT_SCALE(text_scale, text_scale);        UI::SET_TEXT_COLOUR(255, 255, 255, 255);        UI::SET_TEXT_WRAP(0.0, 1.0);        UI::SET_TEXT_CENTRE(0); // o = 1.        UI::SET_TEXT_DROPSHADOW(text_drop_shadow[0], text_drop_shadow[1], text_drop_shadow[2], text_drop_shadow[3], text_drop_shadow[4]); // o = all 0's.        UI::SET_TEXT_EDGE(1, 0, 0, 0, 205);        UI::_SET_TEXT_ENTRY("STRING");        UI::_ADD_TEXT_COMPONENT_STRING((char *)text.c_str());        UI::_DRAW_TEXT(textX_Line1[3], textY[0]);        if (is_blacklist_enabled >= 0 && is_blacklist_enabled < 5){            text = "TPS:  ~r~Disabled";            //UI::SET_TEXT_COLOUR(225, 0, 0, 255);        }        else{            text = "TPS:  ~g~Enabled";            //UI::SET_TEXT_COLOUR(0, 225, 0, 255);        }        UI::SET_TEXT_FONT(font);        UI::SET_TEXT_SCALE(text_scale, text_scale);        UI::SET_TEXT_COLOUR(255, 255, 255, 255);        UI::SET_TEXT_WRAP(0.0, 1.0);        UI::SET_TEXT_CENTRE(0); // o = 1.        UI::SET_TEXT_DROPSHADOW(text_drop_shadow[0], text_drop_shadow[1], text_drop_shadow[2], text_drop_shadow[3], text_drop_shadow[4]); // o = all 0's.        UI::SET_TEXT_EDGE(1, 0, 0, 0, 205);        UI::_SET_TEXT_ENTRY("STRING");        UI::_ADD_TEXT_COMPONENT_STRING((char *)text.c_str());        UI::_DRAW_TEXT(textX_Line1[4], textY[0]);          if (is_blacklist_custom_enabled >= 0 && is_blacklist_custom_enabled < 5){            text = "CTPS:  ~r~Disabled";            //UI::SET_TEXT_COLOUR(225, 0, 0, 255);        }        else{            text = "CTPS:  ~g~Enabled";            //UI::SET_TEXT_COLOUR(0, 225, 0, 255);        }        UI::SET_TEXT_FONT(font);        UI::SET_TEXT_SCALE(text_scale, text_scale);        UI::SET_TEXT_COLOUR(255, 255, 255, 255);        UI::SET_TEXT_WRAP(0.0, 1.0);        UI::SET_TEXT_CENTRE(0); // o = 1.        UI::SET_TEXT_DROPSHADOW(text_drop_shadow[0], text_drop_shadow[1], text_drop_shadow[2], text_drop_shadow[3], text_drop_shadow[4]); // o = all 0's.        UI::SET_TEXT_EDGE(1, 0, 0, 0, 205);        UI::_SET_TEXT_ENTRY("STRING");        UI::_ADD_TEXT_COMPONENT_STRING((char *)text.c_str());        UI::_DRAW_TEXT(textX_Line1[5], textY[0]);

just use GRAPHICS::_GET_SCREEN_ACTIVE_RESOLUTION(&screen_w, &screen_h);

 

I tried that and it didn't help :(

 

Am I doing something wrong? :panic:

Edited by ClareXoBearrx3

Share this post


Link to post
Share on other sites
m_boy

 

That's what I use :

int screen_w, screen_h;GRAPHICS::_GET_SCREEN_ACTIVE_RESOLUTION(&screen_w, &screen_h);const float height = 1080.0f;float ratio = (float) screen_w / screen_h;float width = height * ratio;float textX = X / width;float textY = Y / height;   // X and Y - your value

Maybe this will help. Try it!

 

 

Thanks!

 

I tried this however and instead, it all got mashed to the left of the screen like this:

 

2BPShCt.png

:blink:

This is the code I'm using (I changed the height to 600 since I'm running at 800x600 and scaling it from there):

 

No, your X and Y values are too small. This method is not used as decimal values. Example: 0.27f will become 270.0f.

float textX_Line1[] = { (270.0f / width), (370.0f / width), (470.0f / width), (570.0f / width), (670.0f / width), (770.0f / width) };float textY[] = { (6.0f / height) };
  • Like 1

Share this post


Link to post
Share on other sites
ClareXoBearrx3R9

Ah, perfect!

 

I had to re-calculate the percentages a bit (e.g.: textX_Line1[0] = width*.27 = 216) to normalize the values, but it now looks perfect :D

 

Thanks a lot!! :D

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • 2 Users Currently Viewing
    0 members, 0 Anonymous, 2 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.