Skip to content

Modernize the jQuery UI popup used by Ask()/ShowMenu() expression forms #2006

Description

@alexwarren

Background

While restoring the synchronous Ask()/GetInput()/ShowMenu() expression forms for a new WorldModelVersion.v600 (see #2007), we dug into exactly how Ask/ShowMenu render on screen and found two genuinely different implementations sharing the same names:

  • Ask (...) { } / ShowMenu (...) { } (the FunctionCallScript-sugar forms, addable from the Script Adder) resolve to CoreFunctions.aslx's own Ask/ShowMenu ASLX library functions — the same ones the parser's disambiguation prompt uses internally (ResolveNameFromList in src/Engine/Core/CoreParser.aslx). These print a numbered list of <a class="cmdlink" onclick="ASLEvent(...)"> hyperlinks inline in the game transcript via the ordinary msg() output pipe (src/Engine/Core/CoreFunctions.aslx:196-238, :371-389).
  • Ask(...) / ShowMenu(...) used as value-returning expressions (no trailing { }, e.g. x = Ask("...")) resolve to ExpressionOwner.Ask/ShowMenu (src/Engine/Functions/ExpressionOwner.cs), which call WorldModel.PlayerUi.ShowQuestion/ShowMenu. In both WebPlayer/PlayerCore and WasmPlayer, that renders via showMenu()/showQuestion() in src/PlayerCore/Resources/player.js (player.js:41), which opens a jQuery UI .dialog(...) modal popup. WasmPlayer's index.html loads lib/jquery-ui.min.js plus this same player.js/playercore.js pair specifically to support this path (src/WasmPlayer/index.html:26-37), alongside its own modern Tailwind-based chrome (generated/chrome.css) for everything else.

The old lowercase ask (...)/show menu (...) script commands (AskScript.cs/ShowMenuScript.cs) go through the same PlayerUi.ShowQuestion/ShowMenu popup path — they're intentionally kept out of the Script Adder in favor of the inline-link forms above, and that's unaffected by this issue.

The ask

The jQuery UI popup dialog is visually dated compared to the rest of WasmPlayer's chrome, and it's the one rendering path that still pulls in jQuery UI as a dependency just for these two calls. Now that the expression forms are usable again at v600 (via the Script Adder's "set variable"/"if condition" template pickers), authors have a good reason to reach for the popup specifically when they want blocking modal behavior rather than an inline prompt — so it's worth making that popup look like it belongs in the same app as everything else, rather than removing it.

Possible directions (not decided, worth scoping separately):

  • Restyle the existing jQuery UI dialog to match WasmPlayer's Tailwind chrome instead of the default jQuery UI theme.
  • Replace it with a native modal implemented in WasmPlayer's own chrome stack, dropping the jQuery UI dependency for this one path (jQuery/jQuery UI may still be needed elsewhere - would need auditing).
  • Confirm whether WebPlayer/PlayerCore should get the same treatment, or whether divergence between the two players here is acceptable.

Where to look

  • src/Engine/Functions/ExpressionOwner.csAsk/ShowMenu/GetInput (the expression forms)
  • src/PlayerCore/Resources/player.jsshowMenu/showQuestion (jQuery UI dialog implementation)
  • src/WasmPlayer/WasmPlayerBridge.csIPlayer.ShowMenu/ShowQuestion (JS interop entry points)
  • src/WasmPlayer/index.html — jQuery/jQuery UI script includes
  • src/Engine/Core/CoreFunctions.aslx — the inline-hyperlink Ask/ShowMenu ASLX functions, for comparison/reference on the "nice" rendering style already in use elsewhere

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions