multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.41k stars 438 forks source link

showCursor bug can't disable cursor from another resource #3638

Open Proxy-99 opened 3 months ago

Proxy-99 commented 3 months ago

Describe the bug

use showCursor(true) in a resource folder

try to disable it from another resource folder

bindKey ("F", "down", function() 
        showCursor(false)
    end) 

won't work for some reason

Steps to reproduce

as described above

Version

Multi Theft Auto v1.6-release-22650

Additional context

No response

Relevant log output

No response

Security Policy

FileEX commented 3 months ago

Read #891

TracerDS commented 3 months ago

Read #891

We need to fix that issue. For some reason the cursor is being managed by a resource and not game itself which is ridiculous.

Client\mods\deathmatch\logic\CResource.cpp

Proxy-99 commented 3 months ago

Read #891

We need to fix that issue. For some reason the cursor is being managed by a resource and not game itself which is ridiculous.

Client\mods\deathmatch\logic\CResource.cpp

hope someone put the time and effort to fix this and add like isServerCursorEnabled() and check from it the cursor status

TheNormalnij commented 3 months ago

It's not a bug. Current behavior prevents additional cursor managment in scripts. You can use showCursor without thinking about other resources. Global behavior adds much pain for scripters.

It looks like you are doing something nasty, if you need this.

TracerDS commented 3 months ago

It's not a bug. Current behavior prevents additional cursor managment in scripts. You can use showCursor without thinking about other resources. Global behavior adds much pain for scripters.

It looks like you are doing something nasty, if you need this.

Quite the opposite actually. If you need to show cursor depending on the state, you have isCursorShowing. Thats the point: to not care about other resources otherwise it causes chaos like in this case. Its completely pointless to have the cursor dependant on other resources instead of making it like a simple switch.

Proxy-99 commented 3 months ago

It's not a bug. Current behavior prevents additional cursor managment in scripts. You can use showCursor without thinking about other resources. Global behavior adds much pain for scripters.

It looks like you are doing something nasty, if you need this.

Well, I have two resources one for login page and the other for lobby page I do not see why can't force it to works on others

TheNormalnij commented 3 months ago

If you need to show cursor depending on the state, you have isCursorShowing.

You should use events and binds to control the state. isCursorShowing has many edge cases.

Its completely pointless to have the cursor dependant on other resources instead of making it like a simple switch.

You can't have a simple switch, You need sync a moment when you can hide cursor in independent resources.

Simple case: You have two resources and they show independent windows. First resource uses binds to show/hide his window, second resource shows his window after onMarkerHit event and a player should fill some data to close it. You can't have a simple switch in first resource, because the switch soft locks a player.

There are many cases like this.

Current behavior is simplest solution, i see no reason for changes

TracerDS commented 3 months ago

You should use events and binds to control the state. isCursorShowing has many edge cases.

like?

Simple case: You have two resources and they show independent windows. First resource uses binds to show/hide his window, second resource shows his window after onMarkerHit event and a player should fill some data to close it. You can't have a simple switch in first resource, because the switch soft locks a player.

if you properly utilise isCursorShowing then you wont soft lock any player.

TheNormalnij commented 3 months ago

if you properly utilise isCursorShowing then you wont soft lock any player.

Only if you put this check with 'onClientRender' to show cursor when it returns false. And you need this check in every gui resource. Otherwise you can't be sure, when you are allowed to hide cursor.

like?

Chatbox, console, pause menu activate cursor.

TracerDS commented 3 months ago

Only if you put this check with 'onClientRender' to show cursor when it returns false. And you need this check in every gui resource. Otherwise you can't be sure, when you are allowed to hide cursor.

huh? Why onClientRender?

Chatbox, console, pause menu activate cursor.

I mean, what are the edge cases? Can you explain them?

TheNormalnij commented 3 months ago

huh? Why onClientRender?

Because there is no another option to do it with isCursorShowing in independent resources. If you know one, provide it. There is always a combination of opening and closing when your logic doesn't work. I've solved this issue by using reference counter in my gui library.

I mean, what are the edge cases? Can you explain them?

You can't control these menus and can't hide cursor when they are open (it's not allowed).

dmi7ry commented 3 months ago

Well, I have two resources one for login page and the other for lobby page I do not see why can't force it to works on others

When the login page shows the window, do showCursor(true) in the login resource. When it closes the window, do showCursor(false). Same with the lobby. And what is wrong with it in your case?

Proxy-99 commented 3 months ago

Well, I have two resources one for login page and the other for lobby page I do not see why can't force it to works on others

When the login page shows the window, do showCursor(true) in the login resource. When it closes the window, do showCursor(false). Same with the lobby. And what is wrong with it in your case?

well after login you will be moved to lobby which you can't control the cursor so I have to use export or disable the cursor within login resource before loading the lobby page which is thing I do not like, simply you can't override showCursor(false) won't work

dmi7ry commented 3 months ago

well after login you will be moved to lobby which you can't control the cursor so I have to use export or disable the cursor within login resource before loading the lobby page which is thing I do not like, simply you can't override showCursor(false) won't work

If lobby needs cursor then let the lobby turn on the cursor when it needs it and turn it off when it doesn't. Same for login page. Show cursor only when it really needed. If you don't, it means, that your architecture is wrong.