Abusing ShowMenu

Hey folks :)

There was a recent thread about making ShowMenu() allow the user to type the option. And that got me wondering how hard it would be to make the menu not appear as a numbered list. This is the first thing off the top of my head.

<function name="StartShowMenu" parameters="caption">
  game.menuoutputsection = StartNewOutputSection()
  msg (caption)
  game.menuoptionskeys = NewStringList()
  game.menucallback => {
    error ("Menu started but not completed")
  }
</function>

<function name="ShowMenuOption" type="string" parameters="option, result">
  if (TypeOf(option) = "object") {
    optionText = GetDisplayAlias(option)
    optionTag = option.name
    if (HasString(option, "linkcolour") and GetUIOption("UseGameColours") = "true") {
      colour = option.linkcolour
    }
    else {
      colour = GetLinkTextColour()
    }
    style = GetCurrentTextFormat(colour)
  }
  else if (TypeOf(option) = "string") {
    optionText = option
    optionTag = option
    style = GetCurrentLinkTextFormat()
  }
  else {
    optionText = ToString(option)
    optionTag = optionText
    style = ""
  }
  if (IsDefined("result")) {
    if (TypeOf(result) = "string") {
      if (LengthOf(result) > 0) {
        optiontag = result
      }
    }
    else if (TypeOf(result) = "object") {
      optionTag = result.name
    }
  }
  list add (game.menuoptionskeys, optionTag)
  return ("<a class=\"cmdlink\" style=\"" + style + "\" onclick=\"ASLEvent('ShowMenuResponse','" + EscapeQuotes(optionTag) + "')\">" + optionText + "</a>")
</function>

<function name="EndShowMenu" parameters="allowCancel, hideAfterMenu, callback">
  if (HasAttribute(game, "menuoptionskeys")) {
    error("Haven't got any menu options")
  }
  EndOutputSection (game.menuoutputsection)
  if (!hideAfterMenu) {
    // Should I replace this with the ID of a section that doesn't exist? Needs testing
    game.menuoutputsection = null
  }
  game.menuallowcancel = allowCancel
  game.menucallback = callback
</function>

So then you'd use that to do something like…

StartShowMenu("Pick a colour!")
msg ("Would you rather have "+ShowMenuOption("the colour of blood", "red")+" or "+ShowMenuOption("green", "green") + "?")
msg ("Or maybe you think "+ShowMenuOption("grey")+" might be a nice compromise?")
EndShowMenu(true, true) {
  msg ("Thanks! You picked: "+result)
}

Basically, a couple of functions that do some of the gruntwork of ShowMenu, but returning one option at a time so you can put the options in a numbered list, or within a paragraph, as you prefer.


That's much cooler than the boring crap I had going on!

  <function name="ShowMenuNoNumbers" parameters="caption, options, allowCancel, callback"><![CDATA[
    outputsection = StartNewOutputSection()
    msg (caption)
    count = 0
    game.menuoptionskeys = NewStringList()
    foreach (option, options) {
      list add (game.menuoptionskeys, option)
      count = count + 1
      if (TypeOf(options) = "stringlist") {
        optionText = option
      }
      else {
        optionText = StringDictionaryItem(options, option)
      }
      msg ("<a class=\"cmdlink\" style=\"" + GetCurrentLinkTextFormat() + "\" onclick=\"ASLEvent('ShowMenuResponse','" + option + "')\">" + optionText + "</a>")
    }
    game.menuopt = option
    EndOutputSection (outputsection)
    game.menuoptions = options
    game.menuallowcancel = allowCancel
    game.menucallback = callback
    game.menuoutputsection = outputsection
  ]]></function>

You can already type out things/option choices.

Here is my "a show menu" function. If that helps.

options = Split("Pokemon;The game;The anime;Card game;Combat;Items;Finish game;Item Limit", ";")
ShowMenu ("Pokémon Information", options, true) {
  switch (result) {
    case ("Pokemon") {
      msg ("")
      msg ("Depending on whether you've watched the anime, played the game, read the manga, etc., Pokemon are either magical animals so overpowered you enslave them, or they are magical animals that are your friends, who, for some reason, follow you because you've beat them in battle, I assume that's Greek or anime logic, or something.<br/>This is satire, and parody. Be prepared for drunk old men, and intoxicated Slowpoke.<br/><br/>Pokemon is an RPG game.<br/>The name is short for \"Pocket Monsters.\" The Japanese developers thought  the name wouldn't catch on in the West, so they renamed it \"Pokemon.\" Don't ask me why, I think Pocket Monsters is better.<br/>")
      a show menu
    }
    case ("The anime") {
      msg ("")
      msg ("Ah yes, the anime. The anime has run from 1998 (or 1997 JP), onward until today. And who knows if it will stop? There are actually multiple anime series based on the games, but there is one that is very famous: the one with Ash Ketchum and his Pikachu. The anime can be summed up as follows: Funny but awkward first season with a noticably lacking budget, a second season without Brock, and Ash actually won a league, the Johto series which was 90% filler and went on forever, an okay Advanced Series, an Awesome Battle Frontier series with major improvement past all former series, a decent Sinnoh series, and all the other series so far were just 'meh.' Currently, they are having a series where Ash Ketchum goes to school. Seriously. Pokemon Sun and Moon. Look it up. Also, Ketchum is an actual English last name. Wikipedia. https://en.wikipedia.org/wiki/Ketchum_(surname) There are also various other small episodes shows, mainly written for new games. An example: The Pokémon Mystery Dungeon Series. I also recommend Pokémon Generations and Pokémon Origins.Ah yes, the anime. The anime has run from 1998 (or 1997 JP), onward until today. And who knows if it will stop? There are actually multiple anime series based on the games, but there is one that is very famous: the one with Ash Ketchum and his Pikachu. The anime can be summed up as follows: Funny but awkward first season with a noticably lacking budget, a second season without Brock, and Ash actually won a league, the Johto series which was 90% filler and went on forever, an okay Advanced Series, an Awesome Battle Frontier series with major improvement past all former series, a decent Sinnoh series, and all the other series so far were just 'meh.' Currently, they are having a series where Ash Ketchum goes to school. Seriously. Pokemon Sun and Moon. Look it up. Also, Ketchum is an actual English last name. Wikipedia. https://en.wikipedia.org/wiki/Ketchum_(surname) There are also various other small episodes shows, mainly written for new games. An example: The Pokémon Mystery Dungeon Series. I also recommend Pokémon Generations and Pokémon Origins.")
      a show menu
    }
    case ("Card game") {
      msg ("")
      msg ("Ohhh.... yeah, the Card game. This is different since I don't play the card game. I only collect them... for fun. And I like to look at them. As far as I know, the card game can be bought at any Walmart, usually for around $4-$5 per pack. The inside usually contains one good card, some okay cards, and if you're unlucky you'll get a Caterpie card. The game is played in a Magic the Gathering type fashion. Each 'Trainer' has 20 HP points. You try to 'faint' (but everyone says kill) the other Pokemon/trainer. There are energy cards. You get the gist of it. The good part about this game, is at least you don't have to blurt out \"I activate my Voltorb... now I use my Electroshock for 30 damage on your active Pokemon.\" ...Usually.")
      a show menu
    }
    case ("Combat") {
      msg ("")
      msg ("Combat coming soon. Just set the Pokémon. Remember to save!")
      a show menu
    }
    case ("Items") {
      msg ("")
      msg ("The berries heal health, and heal other status ailments. Oran Berries and Sitrus Berries heal health. Full restore heals health and heal all status conditions. Pecha Berries heal poison. More about items soon to come.")
      a show menu
    }
    case ("Finish game") {
      msg ("")
      msg ("There is no ending. It's an open world RPG. To win the game, you will need to get 8 badges, and then defeat the Elite Four. I'm not even done editing the game yet...")
      a show menu
    }
    case ("Item Limit") {
      msg ("")
      msg ("You have an inventory limit of 50 items. You have a Pokémon team limit of 8 Pokémon.")
      a show menu
    }
    case ("The game") {
      msg ("")
      msg ("Ah yes, the game. The original game is a simple RPG. The original games were Pokemon Green in Blue, released in Japan in 1995. They were released as Red and Blue in the US and more in 1997. It can be summed up as follows: 20 minutes story, 300 hours grinding, 5 minutes x 8 gym leaders = 40 minutes for gym leaders, 35 minutes for the Elite Four, 200 hours trading/completing the Pokedex, and an optional 200 hours battling. Most casual/novice players stop after they've caught the final legendary, believing they completed the final game. The actual fun parts of the game are all online, and if you can't do that (and you don't have a friend/buy multiple games) you basically have an un-glorified Pokédex. Pokemon Diamond sucks in particular since you can't connect online anymore, and you can't get Spiritomb... sorry, I'm just complaining...")
      a show menu
    }
  }
}

(Note - the functions above should include setting up the game.menudisplayedoptions that I mentioned in the previous thread … I just couldn't find that post when I made the first one here. I'm sure it won't be too hard to merge the two)

@jmnevil54
Not sure what you mean there.
That's a pretty huge example, but it doesn't use the modified functions I posted. In fact, it just seems to be a large example of the standard ShowMenu function.


I'm a ShowMenu abuser. That's why I go to ShowMenuAbusersAnonymous. :/ I like the idea of not having the lists numbered as well, but at the same time, the lists being numbered doesn't exactly look ugly or anything. Still, the option of having numbered or not numbered ShowMenu lists would be pretty amazing :)

Anonynn.


Make sure to get the code from the previous thread to which mrangel linked in his last post!

It lets the player actually type in their response, instead of having to click or enter a number.


I'm going to tweak this some more.

I think in a lot of cases, you might want to do something like have a list of choices, with some other things like "help", "back", and "exit" in a line at the bottom. Those options don't need numbers, and they can all go on a single line at the bottom, stylistically separating them from the "actual" choices.

In that case, I'd split the default ShowMenu function out into a separate one that generates a numbered list. And have ShowMenu being a shorthand alias for starting a menu, displaying a list, and ending the menu.

And now I'm thinking about other things that could be useful; like allowing multiple menus to display at once, with their own callbacks. Would just have a ScriptDictionary mapping optionTag onto the right callback.


I am not sure, but it maybe that visually impaired players using screen readers would use the numbers.


Could be. But that would mean that they're trying to remember a list of options and which number goes with which. In that case I would expect that being able to type the name of the menu option would be beneficial to at least some users (so another reason to combine that)

Hmm… I'm not sure whether putting options within a paragraph of text might be a problem for people with screen readers. But any issue that arises from this code would similarly apply to {command:...} links in a description (or anywhere else).

If there's a usability issue, the code could be modified to put the number after the text. We could still get the index from the number of elements in the list after adding a new one.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums