stackotter / delta-client

An open source Minecraft Java Edition client built for speed.
https://deltaclient.app
GNU General Public License v3.0
322 stars 33 forks source link

Hide GUI in spectator mode and implement GUI toggling shortcut (F1) #142

Closed stackotter closed 1 year ago

stackotter commented 1 year ago

These features are both relatively small and interlinked so I have lumped them into a single issue. Currently the hotbar is rendered in every gamemode, but it definitely shouldn't be in spectator mode.

The gamemode check for GUI rendering should go in the update method of GUI in GUI.swift. None of the code should run when the player is in a gamemode that doesn't render GUI. Add a noGUI property to the Gamemode struct that only returns true in spectator mode and then use that in the check just so that it's a bit more generic (maybe plugins will eventually be able to add custom gamemodes). Technically the crosshair shows up while in spectator mode when the player is looking at an entity and is close enough to interact with it (jump to its camera), however this is not required yet if you don't feel up to that, just add a // TODO: comments for someone to come back to later.

To implement GUI toggling you can add a boolean isVisible property to GUIState and then also use that in update along with gamemode.noGUI. You can then add a toggleGUI input to the Input enum (in Input.swift). Then you can add a default key binding in the Keymap struct (use f1 like vanilla does). Then you can add a case to the switch statement in the update method of the PlayerInputSystem struct to handle the toggleGUI input. You will then be able to test out the new shortcut (given that you will already have a Delta Client config file from before you added the keyboard shortcut, you will not get the default keybind and you will need to bind it manually, but for new users the default will be used).

That walkthrough should hopefully give you a pretty good start, but if you get stuck feel free to join the Discord server and ask for help. There are quite a few contributors there (including me) who'll be more than happy to give you a hand 🙂

chinmaym07 commented 1 year ago

Hey @stackotter Can I work on this ?

stackotter commented 1 year ago

Yep definitely! Let me know if you need any help at any point

stackotter commented 1 year ago

Hey, just checking whether you’re still planning on doing this issue or not so that I can free it up for someone else to try if you’ve changed your mind. All good if you just haven’t had the time yet, no rush at all

chinmaym07 commented 1 year ago

Hey Hi @stackotter . Yes I am interested on working on this issue. Sorry for the delay here. I hope to complete this issue by this week.

stackotter commented 1 year ago

Hi, that’s perfectly ok :)

stackotter commented 1 year ago

Hi @chinmaym07 any updates? I'm happy to keep you assigned if you still want to do it eventually (but it's not Hacktoberfest anymore so I'm guessing you won't)

stackotter commented 1 year ago

Done