Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Opening and Closing the SugarCube UI

Twine 1.4.2 with SugarCube 2.

I'm trying to get the UI to unstow up when the player visits a certain passage - and stow itself again when they leave it. I can't seem to get the call to UI.Open to work. Anyone got an example that does work?

Comments

  • You can control the hiding/showing of the side bar by adding/removing a stowed class to/from the #ui-bar HTML element.

    You can do this either using the DOM (Classes) Macros or via Javascript.

    1. Macros - The following example shows you how to use the addclass, removeclass and toggleclass macros:
    <<click "Hide UI">><<addclass "#ui-bar" "stowed">><</click>>
    <<click "Show UI">><<removeclass "#ui-bar" "stowed">><</click>>
    <<click "Toggle UI">><<toggleclass "#ui-bar" "stowed">><</click>>
    

    2. Javascript: The follow show the equivalents of the above three macros:
    $("#ui-bar").addClass("stowed");
    $("#ui-bar").removeClass("stowed");
    $("#ui-bar").toggleClass("stowed");
    
  • The UI.open() method is for opening the UI dialog. It has nothing to do with the UI bar. I'm unsure how you got the impression that it did from its documentation.

    There's currently no specific API for controlling the (un)stowed state of the UI bar. As noted by greyelf, it's controlled by the presence/absence of the stowed class upon it.
  • Google ;-) 'Sugarcube open ui' brings up a UI API, which sounds like it controls the UI.

    Got it working anyway, thanks.
Sign In or Register to comment.