Quick question about ui-menu.c

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nppangband
    NPPAngband Maintainer
    • Dec 2008
    • 926

    Quick question about ui-menu.c

    I am working on getting the NPP squelch using the latest UI from Angband, and I can't figure something out.

    Inside the sval squelch menu, I am trying to make it so the player can navigate by menu selections as well as the arrow keys. The original menu.cmd_keys was this:

    const char cmd_keys[] = { ARROW_LEFT, ARROW_RIGHT, '\0' };
    menu.cmd_keys = cmd_keys;

    The up and down arrows worked to navigate the screen, and left and right toggled the settings.

    I am trying to do the same thing, except let the player type a single letter to jump to another setting using the menu.selection option.

    So I have this in there (I need to reserve ANSL for the 4 NPP squelch settings, and I wanted them to be able to be toggled by + and - as well as the arrow left and right keys:

    menu.cmd_keys = "ANLS+-\x8A\x8B\x8C\x8D\n\r"; /* \x8A-D = ARROW DIRECTION KEYS */
    menu.selections = "abcdefghijklmnopqrstuvwxyzBCDEFGHIJKMOPRTUVWXYZ12 3467890";

    When I add the menu selections line. I lose the use of the arrow up and down keys to navigate. When I comment it out, I lose the arrow up and down keys for navigation. Arrow left and right don't get any response either way.

    My sval action is squelch.c looks like this:

    switch (cmd)
    {

    case 'S':
    {
    k_info[idx].squelch = SQUELCH_ALWAYS;
    return (TRUE);
    }
    case 'L':
    {
    k_info[idx].squelch = NO_SQUELCH_NEVER_PICKUP;
    return (TRUE);
    }
    case 'A':
    {
    k_info[idx].squelch = NO_SQUELCH_ALWAYS_PICKUP;
    return (TRUE);
    }
    case 'N':
    {
    k_info[idx].squelch = SQUELCH_NEVER;
    return (TRUE);
    }

    case '+':
    case ARROW_RIGHT:
    {
    change_squelch_setting(idx, 1);
    return TRUE;
    }
    case '-':
    case ARROW_LEFT:
    {
    change_squelch_setting(idx, -1);
    return TRUE;
    }
    default: break;
    }


    What am I missing to get all the direction keys and the menu.selection option working at the same time? Thanks.
    NPPAngband current home page: http://nppangband.bitshepherd.net/
    Source code repository:
    https://github.com/nppangband/NPPAngband_QT
    Downloads:
    https://app.box.com/s/1x7k65ghsmc31usmj329pb8415n1ux57
  • PowerDiver
    Prophet
    • Mar 2008
    • 2820

    #2
    This is most likely incorrect advice, but I remember the last time I tried something with a constant similar to abcdefghijklmnopqrstuvwxyzBCDEFGHIJKMOPRTUVWXYZ12 3467890 it turned out there were two of them depending upon roguelike keyset, and I wasn't modding the one that matched my key setting.

    Comment

    • Pete Mack
      Prophet
      • Apr 2007
      • 6883

      #3
      Did you get this worked out? Eddie's comment about roguelike keyset is very likely the right one.

      Comment

      Working...
      😀
      😂
      🥰
      😘
      🤢
      😎
      😞
      😡
      👍
      👎