Author Topic: Working on a HUD, ScrW() is not your friend  (Read 2553 times)

0 Members and 1 Guest are viewing this topic.

Offline Digital Spit

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 1
Working on a HUD, ScrW() is not your friend
« on: December 30, 2013, 06:51:04 PM »
So, I'm trying to create a hud I created a HUD but! the only problem is how it's spaced on different peoples screens... the height is the same among everyone's screens it's the width that I'm having a hard time understanding, someone mind helping me here?

Here is how everyone sees it:


Here is how I see it:


How can I make it appear the same on everyone's screen no matter if they are running full screen, window mode or the res they are on?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Working on a HUD, ScrW() is not your friend
« Reply #1 on: December 30, 2013, 07:20:13 PM »
No exact memory off top of my head, however, the ulx motd, and XGUI, are both reasonably dynamic in where they start.
They grab the users original screen res, then do a multiplication to start at a certain percentage into the width of the screen (height too I think).
Then the code is smart enough I think to remain static if screen res is lower than a certain size.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Working on a HUD, ScrW() is not your friend
« Reply #2 on: December 30, 2013, 07:27:40 PM »
JamminR is correct, we base it off percentages. Percentages brings some unique problems as well, but was the simplest for our purposes.
Experiencing God's grace one day at a time.

Offline Digital Spit

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 1
Re: Working on a HUD, ScrW() is not your friend
« Reply #3 on: December 30, 2013, 07:38:30 PM »
So my best bet is to look at how the MOTD is drawn on the players screen and go from there?

Offline Megiddo

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 6214
  • Karma: 394
  • Project Lead
Re: Working on a HUD, ScrW() is not your friend
« Reply #4 on: January 01, 2014, 12:00:10 PM »
Why not share the code you're currently using to position it?
Experiencing God's grace one day at a time.

Offline LuaTenshi

  • Hero Member
  • *****
  • Posts: 545
  • Karma: 47
  • Just your ordinary moon angel!
    • Mirai.Red
Re: Working on a HUD, ScrW() is not your friend
« Reply #5 on: January 01, 2014, 04:06:00 PM »
Try adding some debug functions to your code to print the current coordinates of the hud as well as ScrW() and ScrH().
I cry every time I see that I am not a respected member of this community.

Offline Digital Spit

  • Jr. Member
  • **
  • Posts: 79
  • Karma: 1
Re: Working on a HUD, ScrW() is not your friend
« Reply #6 on: January 01, 2014, 10:59:02 PM »
The problem has been fixed!