[Inform 6] "split must stay vertical" error after restart

After playing Emily Short’s “Bronze” the other night, I decided to implement a similar “these are the directions you an leave the room” status-line compass rose. It works perfectly! Unfortunately, due to weird font-sizing issues, it doesn’t display nicely in Quixe at all. However, I’m using Glulx only, so I decided to be smart and split the statusline into another window, and then use that to draw the compass rose in.

This worked perfectly.

However, restarting the game using the ‘restart’ verb results in the following error message: “Glk library error: window_set_arrangement: split must stay vertical”.

I’m initalising the new window in the Initialise method, and obviously Initialise is called a second time when the game is restarted – but when the statusline has already been split. My solution around this problem was to replace the RestartSub and use glk_window_close to close the window.

This prevented the statusline from being split a second time, but still results in that error message. I attempted to check to see if gg_statuswin_time (my global variable for the Window ID) was set to zero in the Initialise function, but that still resulted in the window being re-split.

As a last-ditch attempt, I tried to set-up the split statusline in the InitGlkWindow entry-point, but this didn’t seem to be early enough in the process to actually do anything.

I’m a bit rusty at Inform 6, and this is the first time I’ve ever written anything with Glulx, so it’s very likely that I’m missing something extremely obvious.

The source is [url=http://wxwhatever.com/due/test.inf]http://wxwhatever.com/due/test.inf[/url] and the compiled ulx is [url=http://wxwhatever.com/due/test.ulx]http://wxwhatever.com/due/test.ulx[/url]. Hopefully someone can point me in the right direction!

I haven’t looked at your source code. However, the way this is supposed to work is that the GGRecoverObjects() function detects all open windows by the rock value. After it’s run, your window global variable will be properly set (if the window was ever created) or not set (if the game is just starting up and the window was never created.) This is called after all startup/restart/restore/undo events.

You can hack GGRecoverObjects(), or add a IdentifyGlkObject() function – not normally defined by the I6 or I7 libraries – to the the job.

After that, your initialise function can look at the window global variable to decide whether it needs to create a new window.

Ah, thanks for the hint! I’ve been working through it a couple of times, and have tried implementing an IdentifyGlkObject routine, based on what I saw in your twocol.inf example file. Unfortunately, this didn’t seem to actually /do/ anything. Additionally, hooking the window to be closed after restart/undo/load/etc caused it to only ever have the single window (not constantly resplitting the status), but still presented with the error message.

I have partially confirmed that my code functions as I expected by doing a horizontal split instead of a vertical split (winmethod_Below instead of winmethod_Left), and that caused the error message to go away entirely.

I’m planning on working through it a bit more methodically, and I’ll definitely check out GGRecoverObjects. I’ve been skimming the source of the Glulx Status Window Control extension for Inform 7, and it seems to be managing the status window entirely of its own according, suggesting that it is closed and then re-opened by the engine. If I can’t work it out, I’ll have a go at managing it all myself…

Thanks again :slight_smile:

Ahah! I’ve managed to solve it.

The issue in question was StatusLineHeight:

[ StatusLineHeight hgt parwin; if (gg_statuswin == 0) return; if (hgt == gg_statuswin_cursize) return; parwin = glk($0029, gg_statuswin); ! window_get_parent glk($0026, parwin, $12, hgt, 0); ! window_set_arrangement gg_statuswin_cursize = hgt; ];

Setting up the correct routines in IndentifyGlkObject, etc, results in restarting and loading not re-splitting the status window. However, the parameters that StatusLineHeight is calling window_set_arrangement with are incompatible with it having been split into two pieces. I’ll have to dive a little bit deeper into the Glulx reference to work out what to actually call it with, but replacing this function and commenting out that line solves the issue.