Howdy, Stranger!

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

Problems with Sugarcube options

(Continued from a question I had in a previous thread: http://twinery.org/forum/index.php/topic,1410.msg2530.html#msg2530)

Alright, so I looked at the Twine file you gave me and tried to implement the necessary bits into my own game, but I frankly didn't understand a lot of it and basically messed up my CSS in the process blah.

I especially have issues with an option to change the font. I've added this to the CSS passage (and even tried to substitute ".passages" instead of "body" but got the same effect): 
body.default {font-family: 'Schoolbell', cursive;}

body.verdana {font-family: 'Verdana', sans-serif;}

body.helvetica {font-family: 'Helvetica', serif;}

body.arial {font-family: 'Arial', sans-serif;}
and this to the options menu:
<<ensureOptionsExist>>\
!Visual Options
<<optionlist "font" "Schoolbell, Verdana, Helvetica, Arial">>
Select the font used in the main passage text.
<<onchange>>
<<removeclass "body" "default verdana helvetica arial">>
<<if options.font eq "Schoolbell">>
<<addclass "body" "default">>
<<elseif options.font eq "Verdana">>
<<addclass "body" "verdana">>
<<elseif options.font eq "Helvetica">>
<<addclass "body" "helvetica">>
<<elseif options.font eq "Arial">>
<<addclass "body" "arial">>
<<endif>>
<<endoptionlist>>
------
<<optionbar>>
and lastly this to a widget passage:
<<widget "ensureOptionsExist">><<if Object.keys(options) eq 0>><<setOptionsToDefault>><<endif>><</widget>>

<<widget "setOptionsToDefault">>\
<<script>>
options =
{
"font" : ["Default"]
}
<</script>>\
<<saveoptions>>\
<</widget>>
but the fonts don't change on the passages they're supposed to, the sidebar is now bigger than it's supposed to be, and the menu links (Saves, Options, etc.) have reverted back to blue instead of the color I specified in the stylesheet and yeah I have no idea why.

I feel like I'm in way over my head here, and any help you could give me would be really, really appreciated.

Thank you!

Comments

  • You're close.  Your CSS is okay, but you're missing a few necessary passages and you've got the font default set wrong (it should be the string "Schoolbell", not an array containing the string "default").  Try these:

    MenuOptions special passage:

    <<ensureOptionsExist>>\
    !Visual Options
    <<optionlist "font" "Schoolbell, Verdana, Helvetica, Arial">>
    Select the font used in the main passage text.
    <<onchange>>
    /% I moved the code here into a widget since you'll need to call it in multiple places. %/
    <<setFont>>
    <</optionlist>>
    ----
    <<optionbar>>
    Your widget passage:

    <<widget "ensureOptionsExist">><<if Object.keys(options) eq 0>><<setOptionsToDefault>><</if>><</widget>>

    <<widget "setOptionsToDefault">>\
    <<script>>
    options =
    {
    "font" : "Schoolbell"
    }
    <</script>>\
    <<saveoptions>>\
    <</widget>>

    <<widget "setFont">>
    <<silently>>
    <<removeclass "body" "default verdana helvetica arial">>
    <<if options.font eq "Schoolbell">>
    <<addclass "body" "default">>
    <<elseif options.font eq "Verdana">>
    <<addclass "body" "verdana">>
    <<elseif options.font eq "Helvetica">>
    <<addclass "body" "helvetica">>
    <<elseif options.font eq "Arial">>
    <<addclass "body" "arial">>
    <</if>>
    <</silently>>
    <</widget>>
    StoryInit special passage:

    <<ensureOptionsExist>>
    <<setFont>>
    PassageReady special passage:

    <<setFont>>
  • Yep, the fonts now work perfectly, thanks so much!

    And the sidebar issue was actually a problem completely on my end due to some faulty CSS I used on #ui-bar, so yep, set to go.

    Thanks again, it's so nice that always willing to help! ^^

Sign In or Register to comment.