sinshu / managed-doom

A Doom port written in C#
421 stars 62 forks source link

4 mouse release #5

Closed PiotrZierhoffer closed 4 years ago

PiotrZierhoffer commented 4 years ago

This is a suggestion how to handle #4.

I chose the o key for no real reason.

I assume regaining the focus could be done a little bit better, as now it implies shooting as well.

IceReaper commented 4 years ago

Wouldnt it a better idea to check the window focus state? If not focused, or if in menu, show cursor, else if ingame, and mouse not captured, capture it?

PiotrZierhoffer commented 4 years ago

The problem is that your wouldn't be able to change focus - the game recenters your mouse on each loop. You could alt+tab away, but this would not work with focus-on-hover behavior (which I have on my OS).

ForNeVeR commented 4 years ago

Good idea about release mouse on unfocus anyways.

IceReaper commented 4 years ago

https://github.com/SFML/SFML.Net/blob/4b5c30ec0547b0f68a47c741f297e2bfc52b985e/src/SFML.Window/Window.cs#L402

I would purely rely on whether the window is focused (not hovered) see above link. Having a key to press is extremely uncommon, and i personaly dislike the need to press a specific key.

sinshu commented 4 years ago

Thank you for reporting the issue, and testing on Linux. As I only have Windows machines, it is surprising to me that this port works on Linux without modification.

Regarding the mouse issue, we should consider how other ports handle this issue. I checked GZDoom, PrBoom+ and Crispy Doom, and then found that these ports release mouse when the menu is shown. I like this behavior, as it is more natural, and can be achieved without adding a special key.

I also considered how to handle window focus and some other things, and then made the following rule to determine when to grab/release mouse.

if (window does not have focus)
{
    release mouse
}
else if (fullscreen)
{
    grab mouse
}
else if (in game && menu is not shown)
{
    grab mouse
}
else
{
    release mouse
}

I will try this implementation later.

sinshu commented 4 years ago

Now the mouse cursor is released by the rule above.