coop-deluxe / sm64coopdx

An official continuation of https://github.com/djoslin0/sm64ex-coop on sm64coopdx for the enhancements and progress it already has.
https://sm64coopdx.com
286 stars 41 forks source link

Add `djui_attempting_to_open_playerlist` #195

Open EmeraldLoc opened 1 month ago

EmeraldLoc commented 1 month ago

Resolves #175

Since you can already disable the playerlist via gServerSettings.enablePlayerList, there was only one step to making #175 possible, that being allowing lua to detect if the playerlist was attempting to be opened, as outlined by Isaac.

I'm not fond of the implementation done here, however I couldn't think of a better implementation. Firstly, I create a global variable, gAttemptingToOpenPlayerlist. I create that variable in djui_panel_playerlist.c and define it in the corresponding .h file (could use a different location, since it isn't used in that c file). Then, in smlua_misc_utils.c, I create a function called djui_attempting_to_open_playerlist that just returns gAttemptingToOpenPlayerlist. This variable is set in the djui_interactable_on_key_down and djui_interactable_on_key_up functions, where the playerlist visibility is also set.

Ideally there'd be a way I can detect what input is being pressed when the function djui_attempting_to_open_playerlist is being called, however I didn't find a way.

With this function, it's pretty easy to do what #175 was aiming to do. By first disabling the playerlist using gServerSettings.enablePlayerList, you can simply check if djui_attempting_to_open_playerlist is true. If it is, show the playerlist.