curiousdannii / parchment

The Interactive Fiction web app
https://iplayif.com
MIT License
429 stars 60 forks source link

Bronze's grid background is the wrong color sometimes #84

Closed dfabulich closed 2 years ago

dfabulich commented 2 years ago

https://iplayif.com/?story=http%3A%2F%2Fwww.ifarchive.org%2Fif-archive%2Fgames%2Fzcode%2FBronze.zblorb

Sometimes, Bronze's grid background is the wrong color. I'm not 100% sure what causes it, but I've found one reliable repro, which is to make your browser window narrow, type a command, and the resize the browser window wide.

image

dfabulich commented 2 years ago

This issue doesn't happen in Lectrote. When it happens, the GridWindow is missing its reverse class.

curiousdannii commented 2 years ago

Right, Lectrote doesn't have my style code.

dfabulich commented 2 years ago

I'm not sure if this is the same bug, but Photopia has a similar problem with its colored grid on a black background getting split up into lines.

https://iplayif.com/?story=http%3A%2F%2Fwww.ifarchive.org%2Fif-archive%2Fgames%2Fzcode%2Fphotopia.z5

image

https://iplayif.com/?story=http%3A%2F%2Fifarchive.org%2Fif-archive%2Fgames%2Fzcode%2Fanchor.z8

Something similar happens to Anchorhead 1997.

image

curiousdannii commented 2 years ago

Is this only when you're zooming in? I wonder if we should enable that thing to stop the browser doing its own zooming adjustments.

dfabulich commented 2 years ago

No, I can repro all of these with no browser zoom. Bronze does require resizing the window a little, but Photopia and Anchorhead bugs happen naturally during an ordinary play session, without requiring resizing the browser.

(Do you repro these bugs?)

curiousdannii commented 2 years ago

Not on my computer. Must be something with measuring font sizes on a HiDPI screen.

dfabulich commented 2 years ago

OK, I think the striped background issue is separate; I've filed it as #93 because it only appears to repro on macOS, not even on HiDPI Windows 11 ARM running in Parallels on the same device.

However, the Bronze issue is still there on Windows 11 ARM, it just doesn't have a striped background. This is a screenshot of Bronze after resizing wide on Windows 11 ARM Firefox.

image

curiousdannii commented 2 years ago

Oh, is the Bronze issue just that it's not full width when you resize it wider? I think all Z-Machine terps have that limitation - Gargoyle and Windows Frotz do at least. Each time it draws the status line, after an input, it will use the current width. Unlike Glulx, the Z-Machine doesn't have the opportunity to redraw the status line while input is pending.

dfabulich commented 2 years ago

I think that's part of it, but the status bar also loses its reverse class when resizing larger, causing it to lose its border, even on Windows ARM. (In the screenshot above, the black border should extend to the very top of the viewport.)

dfabulich commented 2 years ago

So I think this is really three bugs:

  1. Z-machine can't resize the status bar while input is pending (can't fix)
  2. The status bar loses its border while resizing
  3. 93 that only affects macOS

93 affects Anchorhead and Photopia without resizing, and it affects Bronze only when issue #2 crops up.

Maybe the moral of this story is that the missing-border issue 2 isn't really worth fixing, since we can't fix the Z-machine resize issue 1 in any case. So perhaps the only "real" remaining issue is is #93…?

curiousdannii commented 2 years ago

So when you resize the browser window wider, the grid window becomes larger, and the extra width is filled with spaces. If it was Glulx then it would refresh the grid window to use all the space, but the Z-Machine can't do that, so it leaves them just as empty spaces.

What happens next is my GlkOte fork runs a function to check if all of the grid window's contents are reverse mode. If they are, then it sets the whole window to be reverse so that the window padding will be the same colour, if not, then it removes reverse from the window. It's pretty hacky, but it's necessary in order to support 'quote' boxes (like Photopia and Anchorhead above), while also filling in the padding when the whole status bar is reverse mode. You can see this in a game like troll.z5, type "think" to see the quote: https://iplayif.com/?story=https://www.ifarchive.org/if-archive/games/zcode/troll.z5

dfabulich commented 2 years ago

That sounds like a convincing explanation of the border bug; I'm prepared to say that the border issue 2 isn't worth fixing if we can't fix the Z-machine resize issue 1, and so I'm going to close this issue in favor of #93.