Jump to content

Absolute/Relative GUI/DX Resolution Scale Positioning


ReZurrecti0n

Recommended Posts

Actually, the first thing I attempted to do was disable the 'T' and 'Y' keys, but was unsuccessful (Just now thought of unbinding the keys). Anyway, IF I was able to disable the input for chat by disabling those keys, then I could create a new GUI Input to handle the chatbox. But even if successful in that, would still need to put that GUI precisely under the chat box where the "Say:" would appear when you normally hit the 'T' key for all resolutions.

So... I've decided to place a button over the "Say" text which this button will represent the mode to output the chat message as. For example, it's a small button with only enough room for 1 letter and if that button's letter were G, it would stand for global and anything sent to the chat would remain global. Click on that button and it would change the letter to L which would be for local chat. If you better understand what I'm trying to build, you'll understand the problem more I'm currently having.

Now the problem is that I can create that button to cover that "Say" text when you press the 'T' key in a 1920x1080 resolution, but changing that resolution will result in that button no longer covering that "SAY". I've been at this for days and gone through at least 15 threads about it and not to mention the wiki itself. All the formulas found don't work when it comes to keeping that "Say" covered up by the button as the button doesn't position correctly.

Now is the time I finally ask for help in resolving it: How do I keep that GUI Button covering that "Say" text on all resolutions? I suspect it will involve some scaling math to it...

(The following code is what I currently have and does not keep that button covering the "Say" text except of course in the 1920x1080 resolution where it was created)

local SW,SH=guiGetScreenSize()

function onClientKey(button,state)
	if(button=="t")then-- T Key
		if(state)then-- Pressed

			local t1,t2,t3,t4=RelativePosition("ScaleGUI",27,176,23,14)
			ChatButton=guiCreateButton(t1,t2,t3,t4,"G",false)
			guiSetFont(ChatButton,"default-bold-small")

	end
	collectgarbage()
end
  
function RelativePosition(method,xposition,yposition,width,height)
	if(method=="ScaleGUI")then

		local f1,f2,f3,f4=(xposition/1920)*SW,(yposition/1080)*SH,(width/1920)*SW,(height/1080)*SH
		return f1,f2,f3,f4

	end
	collectgarbage()
end

 

Link to comment
  • Moderators
58 minutes ago, ReZurrecti0n said:

I suspect it will involve some scaling math to it...

Yes, I wouldn't agree more.

 

1 hour ago, ReZurrecti0n said:

I've been at this for days and gone through at least 15 threads about it and not to mention the wiki itself.

Also this one? Because afaik the issue lies more with width of the element, which will result in a wrong button position.

\/

 

Your relative function is not suited for pixel perfect designs. It is only useful to get the job quickly done.

 

[Note: I am currently very busy, so will not be able to create examples for you]

 

 

 

Link to comment

I remember the 300 and 50 from somewhere and was able to create the button centered on the screen regardless of screen resolution and it also appeared to change to the right size as well (To cover up that "Say" text perfectly), just couldn't figure out how to position it on the screen. Of course adding pixels to the X and Y won't work, but maybe by adding/subtracting using relative values instead? But I do know that using relative values alone instead do not work either. Actually, should have included that in the code I posted, will update it: (NM, can't seem to edit the OP for some reason, but listed below anyway)

(0.0141,0.1630,0.0120,0.0130) Relative Values for the GUI Button

Edited by ReZurrecti0n
Link to comment
  • Moderators

 

22 minutes ago, ReZurrecti0n said:

, just couldn't figure out how to position it on the screen. Of course adding pixels to the X and Y won't work, but maybe by adding/subtracting using relative values instead? But I do know that using relative values alone instead do not work either

 

My reply on that same topic, might give you a hand in figuring out how position things on the screen. Everything is already ready for you to copy and past. Please be lazy for once in your life.

See:

 

Edited by IIYAMA
Link to comment
2 minutes ago, IIYAMA said:

Please be lazy for once in your life.

This is why I don't like posting threads for help and why I'm rarely heard from...

I read the OP on that thread, then went down the first page of replies as well. Yes, maybe the answer does lie within somewhere, I'm just not grasping it

Truth of the matter is, I'm tired of wasting so many hours on something for other people's entertainment (The Players)

Don't worry about it, if I don't figure it out on my own, I'll find some work around. Either that or just give up the entire project altogether, not like I'm getting paid for this anyway

Feel free to lock the topic if you want to

Link to comment
12 minutes ago, ReZurrecti0n said:

This is why I don't like posting threads for help and why I'm rarely heard from...

I read the OP on that thread, then went down the first page of replies as well. Yes, maybe the answer does lie within somewhere, I'm just not grasping it

Truth of the matter is, I'm tired of wasting so many hours on something for other people's entertainment (The Players)

Don't worry about it, if I don't figure it out on my own, I'll find some work around. Either that or just give up the entire project altogether, not like I'm getting paid for this anyway

Feel free to lock the topic if you want to

I don't understand, what is your problem here? He gave you a good topic where this stuff is pretty decently explained, don't need to get all upset about it if you can't figure it out. Also what's all this gotta do with the "entertainment of the players". If you want to learn how to make stuff, do it. If not, just quit it. It goes as simple as that.

Link to comment
  • Moderators
46 minutes ago, ReZurrecti0n said:

This is why I don't like posting threads for help and why I'm rarely heard from...

If you didn't post this topic, you wouldn't have access to a possible solution.

But not scrolling down the page to the replies, (most of the time a gold mine), is actually something you should consider doing next time.

?

Link to comment

I apologize IIYAMA because two wrongs never make a right, I've let anger get the best of me. You mentioned you were very busy and most likely already frustrated with something else and so was I especially when it comes to math. Seems we were both vulnerable to anger more than usual. The trigger for me was "Lazy" and my response to it was no better...

I've mistaken the link you sent and failed to notice it was to a reply on the thread, so I clicked the thread headline link instead which of course directed me to the OP of the thread. I read and seen it was for scaling and did continue down the page to read the replies. If I had not mistaken the link in the first place, then I would have payed more attention to the reply you directed me to and would've noticed it sooner that it was indeed about positioning.

Anyway, now after reading that reply with closer attention, it's all coming together slowly and I'm finally grasping the idea of how to position/scale correctly to fit all resolutions. This math is not my strong suit, will take me time, but am likely to understand it soon. I don't just want to copy and paste code, but also learn what makes that code work etc. And that tutorial will surely teach me, just took me a bit of time before realizing it. I do appreciate the time and effort you sacrifice to help those in need.

It'll likely take me another day of "studying" that tutorial, but will keep everyone updated with the new results...

(Actually make take me longer because I think I need a few days break from coding in general after tonight's episode)

Edited by ReZurrecti0n
Link to comment
  • Moderators
2 hours ago, ReZurrecti0n said:

Seems we were both vulnerable to anger more than usual. The trigger for me was "Lazy" and my response to it was no better...

Hmm, I was never angry. But my words choice might be a little bit incorrect. My apologize for the inconvenience.

I meant: Don't be afraid to just copy, it will save you time. If it works, you can analyse it later.

 

 

2 hours ago, ReZurrecti0n said:

nyway, now after reading that reply with closer attention, it's all coming together slowly and I'm finally grasping the idea of how to position/scale correctly to fit all resolutions. This math is not my strong suit, will take me time, but am likely to understand it soon. I don't just want to copy and paste code, but also learn what makes that code work etc. And that tutorial will surely teach me, just took me a bit of time before realizing it. I do appreciate the time and effort you sacrifice to help those in need.

Keep up the good work!

Edited by IIYAMA
Link to comment

Well, I got the positioning and scaling code to work as I understand more of it now which is great for displaying things such as menus, health bars, cash, etc. But not designed to precisely keep up with the chatbox's positioning/scaling (Although it does come close). So I want to try another approach...

There is a function I recall from some thread that was able to return information about the chatbox, but do not remember the function, nor the thread I read it from. However, by using the x,y start values of the chatbox combined with the width and height of the chatbox. I can come up with the left/bottom position of the chatbox and then use those positions to offset the button to cover that "Say" text and in that sense, should get to the correct position everytime regardless of resolution. I'll worry about making sure the button is big enough(scaling) to cover it in every resolution because the chat does change size between resolutions.

Anyway, can anyone reveal the function's name to get the chatbox's values?

Link to comment

(Unable to edit the last post)

While browsing through the threads trying to find that function, I came across how to disable the "T" & "Y" chat inputs which now I can just make custom chat inputs and no longer need to worry about covering the "Say" or "TeamChat" text. I can also use what I just learned with positioning and scaling to properly place the new chat input under the chatbox...

For those of you wondering: Just use this function to disable both chat inputs:

toggleControl("chatbox",false)-- Client Side

toggleControl(source,"chatbox",false)-- Server Side

Just for future reference though, if you do know the name of that function that returns the chatbox values, please share it (In case someone with a similar problem finds this thread)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...