Jump to content

Recommended Posts

Posted

Hey guys,

 

Sorry for this post, I probably seem a bit stupid but I can't get my head around this at all. I've asked 3 times on IRC but annoyingly every time, the person helping mysteriously disappears half way through...

 

Anyway,

what I want to do is have an overlay rendered on the screen. However, the overlay's position is set in the config file.

So, for example, if the xPos number in the config was 60, the image would start rendering at 60,0 along the top of the screen.

 

Initially, it works fine - but when the screen is rescaled (eg, full screen mode), they don't move to the correct position.

 

I understand I need to use ScaledResolution, and I've got the integers for scaledWidth and scaledHeight.

What I don't understand, is how to make those numbers interact with mine, to keep my stuff in the correct place.

 

Can anyone give me a hand with this?

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

(Sorry, won't let me quote you Alexiy)

 

What I don't understand, is how to make those numbers interact with mine, to keep my stuff in the correct place.

 

I've got as far as using scaled res; I just can't get my head around the math behind implementing it. I'm usually quite good at doing clever math calculations - it took me seconds to do what I was told was "impossible" and round a double to two decimal places, but I just can't get this one for some reason.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

Ok, I'm going to guess, due to the fact everyone seems to stop helping after that point, that ScaledResolution will NOT work for what I want to do.

 

Therefore, the only way I can imagine that I can allow my widgets to be placed anywhere on the screen is like so:

 

If they want it in the top left, they just set X/Y to a positive int

X = 0

Y = 0

 

If they want it right of the crosshair,

rightScreen = true

X = 0 (Or a NEGATIVE offset)

Y = 0 (or a POSITIVE offset)

 

If they want it below the crosshair,

lowerScreen = true

X = 0 (Or a POSITIVE offset)

Y = 0 (Or a NEGATIVE offset)

 

And finally if they want it in the bottom right,

lowerScreen = true

rightScreen = true

X = 0 (Or a NEGATIVE offset)

Y = 0 (Or a NEGATIVE offset)

 

 

As you can see, all that configuration gets VERY confusing. I'd much rather just be able to set X and Y, and it move correctly according to the screen's scale...

Anyone got ANY ideas?

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted
it took me seconds to do what I was told was "impossible" and round a double to two decimal places

 

You mean multiply by 100, round to the nearest int, then divide by 100? :P

 

As you can see, all that configuration gets VERY confusing. I'd much rather just be able to set X and Y, and it move correctly according to the screen's scale...

Anyone got ANY ideas?

 

actualX = configX / intendedDefaultScreenWidth * currentScreenWidth

 

Ditto for Y

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

From memory, something similar to that didn't work.

 

However, I've now got it to work. I caused quite a heated discussion on the whole subject in IRC, but for anyone who wants to do this in the future, here's what I did:

 

First, I run a bit of code in the preInit which checks the screens current resolution, and saves it as a variable.

I then later compare this variable with the current resolution, and work out the % difference.

I turn the % into a double, add 1, and multiply my config value by that.

 

Basically what that does is moves my GUI widget based on the % increase in screen size.

 

 

The ONLY issue with this is relevant spacing; if you have multiple widgets, the gap between them increases with screen size. I got around this by making my config more flexible and offering an offset - so if a user sets the coordinates of two widgets the same, they can use offset to move the second widget in relation to the first. That way, when they get scaled by the screen resizing, they will stay in the same relative position to one another and move together.

 

I also offered a fallback for people who didn't like the X/Y option (as it can be hard to get position exact with it), and allow players to simply choose a corner/side of the screen to use as a base point.

 

It all works absolutely beautifully; when I finish making the initial release widgets, I'll post up a jar here for anyone who wants to see it in action :)

 

I've just got one last bug; but I'll post a new thread for that tomorrow if I can't fix it tonight.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.