Changing background colour in glulx

Is there an easy way to do this? I’m upgrading a z-code thing of mine. I’m looking at the documentation for Glulx Text Effects, and I can only see a way to change the colour of the text.

There should be…but I don’t know it. Sorry.

I’ve had trouble doing anything color related in I7/glulx. Basic text coloring is usually okay, but anything beyond that seems to be dark territory only for the brave. Even when I’ve got things looking okay, I’ve had problems with certain interpreters not showing colors correctly or at all.

I know the Flexible Windows extension allows you to set a background color for a window (such as the main screen, which is active even if you don’t want to use windows at all.) However, the documentation warns about using background colors for text windows, so it may not be the right way to go.

Hopefully someone can help shed some light on coloring, since I would also like to know.

I don’t know why background colors were left out in Glulx Text Effects, but you can add them:[code]Section “Setup”

Include Glulx Text Effects by Emily Short.

Include (-
[ SetBackgroundColor S N;
glk_stylehint_set(wintype_TextBuffer, S, stylehint_BackColor, N);
];
-).

To apply (color change - a number) background color to (chosen style - a special-style):
(- SetBackgroundColor({chosen style}, {color change}); -).

Table of Tweaks to User Styles
style name Glulx background color
a special-style a Glulx color value

To initialize user styles:
initialize user styles;
repeat through the Table of Tweaks to User Styles:
if there is a Glulx background color entry, apply (the assigned number of the Glulx background color entry) background color to (the style name entry).

Section “Demo”

Table of Tweaks to User Styles (continued)
style name Glulx background color
italic-style g-light-grey

Place is a room.
“This is [italic type]a room[roman type].”
[/code]

Cool! Any idea how to change the background of the whole screen?

No. Last I knew, Glk doesn’t let you do that, and scanning the spec I don’t see anything. (I have a vague recollection of there being a trick that made it possible in Gargoyle, but I might be misremembering, and, even if I’m not, I couldn’t tell you anymore what that trick was.)

Edit: Okay, apparently Flexible Windows contains the Gargoyle trick, which I should have gathered from abjectadjective’s post. The gist is that it sets the background color for the plain style, and Gargoyle, rather than using this just in rectangles around plain-styled text, draws it over the whole window. The spec doesn’t guarentee this behavior even for color-supporting terps, and several others I tried didn’t exhibit it, so use with caution.

Dannii could confirm this, but I think the newest version of FW allows you to open and close the main window, which should also allow you to change the background color. (You’d close the window, set the color, then open the window again.)

That would work, except that Glk only lets you set a background color for graphics windows. (See Section 7.2 of the spec.)

It may not be to spec, but the major terps on OSX, Windows, iOS, and Linux* all support background colors on text windows. So it should be OK for most purposes. (I’m not sure whether zarf’s iOS terp supports background colors or not, so you’d want to find that out if that is your target…)

  • For Linux, I’m assuming folks are using Gargoyle, I’m not familiar with any other terps there.

github.com/i7/extensions/blob/m … indows.i7x

You can try it out here, but note it’s still a work in progress and there may be bugs. (Though there might always be bugs, even in published extensions!)

My “Glulx Text Styles” extension adds the ability to change the background color of any Glulx style, as well as the attributes from “Glulx Text Effects”.

It appears to be easier in I6 to change the background colour of a Glulx game than in I7 (I say this because, when I read this thread, I immediately thought “Hang on, it can’t be that hard, I just played a game that forced my interpreter to show white text on black background! Darkiss 2!” Then I checked it, and went “Ah, ok, Marco used I6”).

Hmmm, I should really be able to add something a bit more constructive here, but no, turns out I just had this to comment.

Do you know how that was done? I tried to find the source but don’t know Italian.

I can see there is some confusion here. Setting the background color of the main window at the outset of the game should be as simple as this:

[code]Include Flexible Windows by Jon Ingold.

The back-colour of the main-window is g-black.[/code]

It isn’t quite that simple in this case, of course, since you’d also need to change all of the main window’s text styles to ensure that they’re readable on black. (And in all cases Gargoyle users will also need to ensure that the operative .ini file doesn’t block text style hints.)

What gets tricky is when you want to change the existing background color of the main window during play–to change the background color of any text window, you need to be able to open and close it again. Until Dannii recently updated Flexible Windows, it wouldn’t have been possible to do this to the main window w/o some hacking of the I6 library (though it was always possible to do it with surrounding windows).

Hope that clears things up!

Should this be working with "Version 15/161003 of Flexible Windows (for Glulx only) by Jon Ingold "? I get “Problem. The sentence ‘The back-colour of the main-window is g-black’ appears to say two things are the same - I am reading ‘back-colour of the main-window’ and ‘g-black’ as two different thing”, with just these two lines:

[code]Include version 15/161003 of Flexible Windows by Jon Ingold.

The back-colour of the main-window is g-black.[/code]

To set colours you now use CSS colour texts:

The background color of the main-window is "#000000".

That line throws an error: “but the property background color for the main-window is not allowed to exist, because you haven’t said it is. What properties something can have depends on what kind of thing it is: see the Index for details.”

Oh, sorry, remove the hyphen from main window