Ancurio / mkxp

Free Software implementation of the Ruby Game Scripting System (RGSS)
GNU General Public License v2.0
512 stars 130 forks source link

In fullscreen mouse is not locked to map area #99

Closed ghost closed 3 years ago

ghost commented 9 years ago

My laptop has a resolution of 1366x768 which results in a black column either side of the map when an rpgmaker xp game is in fullscreen. In rpgmaker the mouse is locked inside the map area which is how I would expect it to behave. In MKXP however the mouse is allowed to stray into these black areas.

It might not seem like a big deal but it kind of ruins the effect of the game when you are using the mouse for certain things.

Ancurio commented 9 years ago

The mouse is not "locked", it's just that your monitor creates those black bars when RMXP forces a resolution switch. The OS doesn't know about the black area at all.

mkxp is different because there are no user hostile forced resolution changes, everything happens at the native resolution, as such the engine creates the black bars. You have two optins: either use fixedAspectRatio=false, or change the source code to use SDL_WINDOW_FULLSCREEN instead of SDL_WNDOW_FULLSCREEN_DESKTOP (not recommended).

ghost commented 9 years ago

ok that makes sense. But is there a reason why the engine can't or shouldn't disable a mouse when entering this black area? It doesn't seem useful to have the mouse enabled outside the map area.

To The Moon seem to handle this ok so there must be a way t script around the problem, so I guess I'll give that a shot.

Ancurio commented 9 years ago

What do you mean by "mouse disabled"? In To the Moon you can move the mouse into the black area all the same.

ghost commented 9 years ago

Maybe I should have chosen my words better. In To the Moon the mouse might go into that area but you can't see the pointer when it does (its not visible). At least with my script the pointer goes from being hidden in a border area around the edge of the screen to visible when in the black area seeming to ignore my previous settings, it could just be an error in my script but it seems like you would never want the pointer to be visible when in this area.

Ancurio commented 9 years ago

Ok, I think I know what is happening here. What you mean is that the OS provided cursor is turned back on once the pointer leaves the "visible" area. I'm pretty sure this is related to your Win32-using mouse script, which checks whether the pointer is inside the game window and either turns off or turns on the OS cursor based on it, however it wrongly detects the black area as "outside the window" and turns the cursor on for it.

I think if you delete the class ShowCursor from my win32 wrapper, the cursor should stay turned off.

ghost commented 9 years ago

That turns off the cursor completely, but you gave me an idea I already have a tracking function that's called to move the cursor when the mouse moves outside of a container I've defined. When the cursor moves so I've just added a call to turn the cursor off here and it seems to do the job.

x, y = *Mouse.position
rect = @container.rect
if x >= 0 && y >= 0
  @cont_sprite.x = [[x, rect.x].max, rect.x + rect.width].min
  @cont_sprite.y = [[y, rect.y].max, rect.y + rect.height].min
else
  $ShowCursor.call(0)
end

I guess I could also try find what's turning it back on but this work for now. Thanks for your help.

ghost commented 9 years ago

Actually I don't need to do that I just need to call $ShowCursor.call(0) once. Hmm sorry about that I think this may be cause because I modified the mouse script so that it can be disabled and enabled when you want to use the mouse. It must also reset the system cursor setting.