Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make hint text more useful if the command key is unbound #1962

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Kefta
Copy link
Contributor

@Kefta Kefta commented Apr 26, 2023

Additionally

  • Add number length and string sound arguments to GM:AddHint that default to 20 and "ambient/water/drip" .. math.random( 1, 4 ) .. ".wav" respectively
  • Add GM:UnprocessHint( string name )
  • Make ProcessedHints a gamemode table var rather than a local
  • Add helptext to cl_showhints
  • Adjust Annoy# hint times to account for the full-load time discrepancy
  • Change HintTimer_ hook prefix to GMOD_HintTimer_
  • Various optimizations

Additionally
- Add ``bool force`` and ``number length`` arguments to GM:AddHint which default to false and 20 respectively. The ``force`` argument when true will cause the hint to display even if one or more of the keys involved are unbound
- Add GM:UnprocessHint to allow the hint to be re-shown manually
- Use the provided GAMEMODE table in the GM:AddNotify call
- Bump up the hint disabling hints from 5, 7 to 10, 12 to reduce cases where they pop-up before the player is fully in
@robotboy655
Copy link
Collaborator

I disagree. Displaying the hints is still useful to let the player know that a feature exists at all, and that they may have some actions unbound.

@Kefta
Copy link
Contributor Author

Kefta commented Apr 26, 2023

How about putting the command they have unbinded in-place of <NOT BOUND> with an additional note like "(command not bound to a key)"?

(went ahead with it)

@robotboy655 robotboy655 added the Enhancement The pull request enhances current functionality. label Apr 27, 2023
@Kefta Kefta changed the title Don't display hints by default if any of the involved keys are unbound Make hint text more useful if the command key is unbound Apr 27, 2023

CreateClientConVar( "cl_showhints", "1", true, false )
-- A list of hints we've already done so we don't repeat ourselves
GM.ProcessedHints = {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of exposing an internal table to public?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was to introduce the auto-refresh table idiom to the file but I forgot to write the full statement.


if ( ProcessedHints[ name ] ) then return end
if ( !engine.IsPlayingDemo() ) then
timer.Create( "GMOD_HintSystem_" .. name, delay, 1, function()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the point of adding GMOD_ prefix to the timer's ID? Do we not know what game we are?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timer identifiers are global. Hook identifiers are global. ConCommands/ConVars are global. Many other built-in systems (Lua or engine based) share common identifiers - adding the prefix is just a formality to avoid conflict.

local bufferlen = 1
local nextstartpos = 1

repeat
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was the while loop replaced with a repeat loop? This new code looks infinitely less readable, while seemingly providing absolutely no benefit.


end

function GM:AddHint( name, delay, length, sound )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure adding sound parameter is a good idea. What's next, custom icons? Custom render function?

This system should be kept self contained.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no future gateways to customizability in this library because the vanilla hint system is already firmly limited; the additional arguments introduced are just extensions of the default impl to allow scripts to use this system without reimplementing/copying all the Hint code to change a hardcoded time/sound.

The hint system here is a barebones notification feature to introduce people to Sandbox, but since it's in the Sandbox gamemode table, why not allow the standard impl to be configured without expanding its scope or breaking anything?


end

function GM:UnprocessHint( name )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really needed? At what point would you want a hint to be displayed again?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a server wants to allow specific classes/roles/teams/whatever division hints to be displayed every time they switch, then they should be able to use this system freely since it's available in the Sandbox gamemode table. This entire sandbox system sucks but it should be fleshed out into the standard Add + Remove template so it can be utilised as the official "gmod hint system"

@Kefta
Copy link
Contributor Author

Kefta commented Aug 20, 2023

I will update the code to be more concise and readable this week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement The pull request enhances current functionality.
Projects
None yet
2 participants