Starchasers / OCGlasses

mod for minecraft and addon for Open Computers
zlib License
31 stars 17 forks source link

Requesting a function to obtain the current viewport bounds #37

Closed dashkal16 closed 6 years ago

dashkal16 commented 6 years ago

It would be nice to have a way to obtain the 2d overlay bounds, so that UI can be scaled to the player's screen.

glasses.getOverlayBounds(user:string): number, number Returns the maximal x and y coordinates for the given player.

This probably requires a client round-trip to actually query since the current screen size affects these values.

ben-mkiv commented 6 years ago

isn't the resolution static and content is scaled anyways?

512 x 288 if i figured that out correct (while these are float values, not pixels!)

dashkal16 commented 6 years ago

I was getting different values when I resized my game window and tested again. I tested by writing a quick event dump to capture mouse events, then clicking in the lower-right corner.

ben-mkiv commented 6 years ago

are you using some version <1.10.2?

dashkal16 commented 6 years ago

I am not: OpenGlasses-MC1.12.1-1.5.4.jar

ben-mkiv commented 6 years ago

please take a look on this bug, that might help you to actually convert the position the event triggers to the internal resolution of openglasses. but note that this actually is a workaround and could change in future releases: https://github.com/StarChasers/OCGlasses/issues/36

dashkal16 commented 6 years ago

If that's the solution, then aside from needing the bounds (constants would be fine if the coords are to be fixed), that bug definitely needs a squash, because the mouse events for the overlay definitely vary with the screen size.

ben-mkiv commented 6 years ago

@marcin212 i would suggest to expose the internal resolution of 512/288 to the lua backend.

i would put it on my todo list if you agree with that.

marcin212 commented 6 years ago

new event: glasses_screen_size

dashkal16 commented 6 years ago

Much appreciated! I'll give that a poke next release :)