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

[L4D2] Panel Items with ITEMDRAW_DISABLED / ITEMDRAW_NOTEXT are still functional when selected #2206

Open
3 tasks done
Mute-255 opened this issue Sep 29, 2024 · 1 comment

Comments

@Mute-255
Copy link

Help us help you

  • I have checked that my issue doesn't exist yet.
  • I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
  • I can always reproduce the issue with the provided description below.

Left 4 Dead 2 on Linux server, SM 1.11.0.6968 / MM 1.11.0-dev+1155

Description

If a Panel created with CreatePanel has items with the ITEMDRAW_DISABLED or ITEMDRAW_NOTEXT draw style flags, in the past selecting these options would simply close the panel without passing the action == MenuAction_Select check in the callback (or maybe it didn't call the callback at all, I don't know). However, these options are now passing through when they shouldn't, meaning disabled and hidden menu options are incorrectly functioning equivalent to regular menu options. This does not seem to happen to Menus created with CreateMenu.

Example Code

public Action PanelTest(int client, int args)
{
  Panel panel = CreatePanel();
  DrawPanelItem(panel, "disabled option", ITEMDRAW_DISABLED);
  DrawPanelItem(panel, "functional option");
  SendPanelToClient(panel, client, PanelTestHandler, 999);
  CloseHandle(panel);
  return Plugin_Handled;
}

public PanelTestHandler(Menu menu, MenuAction action, int param1, int param2)
{
  if(action == MenuAction_Select)
  {
  	switch(param2)
  	{
  		case 1:
  			PrintToChatAll("this shouldnt be visible");
  		case 2:
  			PrintToChatAll("this should be visible");
  	}
  }
}
@asherkin
Copy link
Member

I believe this has always been the case for L4D2, it's related to the RadioMenuClosesOnInvalidSlot workaround:

"#default"
{
"#supported"
{
"engine" "left4dead"
"engine" "left4dead2"
"engine" "nucleardawn"
}
"Keys"
{
"RadioMenuClosesOnInvalidSlot" "yes"
}
}

// Some games have implemented CHudMenu::SelectMenuItem to close the menu
// even if an invalid slot has been selected, which causes us a problem as
// we'll never get any notification from the client and we'll keep the menu
// alive on our end indefinitely. For these games, pretend that every slot
// is valid for selection so we're guaranteed to get a menuselect command.
// We don't want to do this for every game as the common SelectMenuItem
// implementation ignores invalid selections and keeps the menu open, which
// is a much nicer user experience.
display_keys = s_RadioClosesOnInvalidSlot ? 0x7ff : keys;

The menu system does have it's own validity concept which it uses to filter these out of the callback, but panels are meant to be a very low-level abstraction. MenuStyle_Radio does have the true key map, so it could filter them out itself in ClientPressedKey if the workaround is in use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants