UofTMADLab / reach

A VR format for Twine
0 stars 0 forks source link

Allow default text panel content in a passage #59

Open titaniumbones opened 4 years ago

titaniumbones commented 4 years ago

As I've been working with reach, I find I often create a passage whose raison d'etre is to present a text in an appropriate environment. Twine is after all usually an environment for text-based games or projects.

So it's a bit confusing that text content in a normal passage is not rendered by reach, and instead has to be inserted into a separate pseudo-passage text or HTML panel. This also has the effect of making the project structure more complex -- each scene in my projects is a pernt for a number of leaf nodes, and sometimes I get a little bit lost (this is in gneeral a problem with Twine for me).

SO I'm wondering if we could add a syntax for default text passages, maybe something like this:

{"direction":3,[etc etc]}'''
passage text content goes here
'''

I haven't looked at the regexes you have already built, and maybe something else would be better, but I think this is a feature worth adding. If it's easy, it might also be nice to have something like:

{"direction":3,[etc etc]}<<<
passage html content goes here
>>>

Under the hood, you'd just be making text and html panels, but they could live inside a smaller number of passages.

What do you think?

samesimilar commented 4 years ago

This makes sense to me and shouldn't be hard to do in the way you suggest. For now there are a couple workarounds you can try:

To reduce the number of arrows flying around the Twine editor, you can insert a ';' character in the link just after the first '[' bracket:

[['NormalTextPassage']] (shows an arrow) [;['SameIdeaButWithoutArrow']] (hides the arrow in the twine editor)

To insert a text panel directly, you can use Javascript Template code: <% p.textPanel("Hello world", {"direction": etc.}); %> or <% p.htmlPanel("Text for html", {"direction": etc}); %>

But the Javascript method is a bit too complex I think, and doesn't easily allow text strings with line-breaks (unless you use escape codes like \n) A benefit of your suggested syntax is that it would be more natural for non-javascript programmers.

I think something even more in the spirit of Twine would be to take all of the bare text in the passage (after stripping out any codes) and to render it as a single default text panel in the scene. We'd have to find a way to add options like direction, etc. A benefit would be that it could maybe be easier to adapt a text-based story to Twine and not have to modify the structure of the document very much.

titaniumbones commented 4 years ago

I link your suggestion, which helps keep the "format" as something more like what the word implies (rather than as a complete transformation of the tool!).

I'll try the workarounds but probably most of the time I want arrows so I know what the child panels are for.

the JS method is not so great for students who don't code, and even for me entering lots of \n is a bit cumbersome, so I probably won't use it for now.

titaniumbones commented 4 years ago

Looking over this again I think I see 2 small issues with the "default text panel" approach:

Anyway, both suggest to me that it would be very common for users to want to have control over placement of the default panel. So there's still need to be some kind of syntax for that, I guess.

samesimilar commented 4 years ago

Ok I've addressed this in the latest commit. Let me know if you think it works.

By default, now, any plain text you type into a passage will be rendered as a text panel in the scene.

If you want the text to be rendered as html, use the Twine 'tag' feature to add a tag named html.

If you want to change the display options for the text (for example , to put it at a position other than 0), add your options on a separate line like this:

{{"direction":3, "etc": etc}}

Which applies the same kind of options as for a regular text/html panel, just with double brackets and no [[]].

One of the options can be "html":true if you want to avoid using the tag feature of twine.

If you want to go back to the old behaviour, add a hideText tag to the passage (or option {{"hideText":true}}

Important note: If you 'hoist' in a passage, e.g. &[[otherPassage]] then the default text in this passage behaves the same way and will be rendered in its own text box. You can set the options for the text using JSON in otherPassage.

Also I disabled the old method of adding text boxes with the backtick character:

`[[oldTextBox]]

since it has been superseded by [['text']] and [[<html>]] style passages, and now also by integrated text.

samesimilar commented 4 years ago

BTW this introduces yet another affordance (using the 'tags' feature of Twine), which I'm not sure is a good idea. But tags could be useful and are fairly easy to use and understand and in this case lets users decide how the text is rendered without getting into using JSON.

At some point I'll have to unify some of these concepts. Maybe instead of using passage titles like 'text' or or %code% to specify how things are rendered, we could use tags. But it's nice that you can tell the type of content in a passage just by looking at the title.