Implementing a scrolling text box

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
jalefkowit
Prole
Posts: 2
Joined: Thu May 12, 2016 4:26 am

Implementing a scrolling text box

Post by jalefkowit »

Hey all... complete LÖVE newbie here, so apologies in advance if this is a dumb question.

I've been learning LÖVE by using it to build out a game idea that's been rattling around in my head forever. For the most part it's super easy to pick up, which is great. However there is one element of the game where I can't figure out what the right way is to implement it. So I figured I'd ask the experts :)

It seems like it should be simple: a text area/pane/panel that can accept an arbitrary amount of text, that offers a scroll bar when the text fills the box, and has old text scroll away and be replaced by new text as it comes in. (The idea is to have a little textual log that runs in a portion of the screen, with flavor text getting dropped into it as various events happen.)

LÖVE's built in tools for working with text are fine for printing things like labels, but they don't seem to be geared for this type of task, where there's going to be an unknown quantity of text flowing through the element. And I haven't found any libraries that add this kind of widget either. (I'm using SUIT for the UI, and it's great for what it is but it doesn't address this either.)

If you're familiar with LibGDX, what I'm thinking of here is something like Scene2D's TextArea control. Just a big dumb text area I can set to a particular width and height and then append text to as it's needed, without having to treat each bit of text as a special snowflake that needs to be individually formatted, positioned, etc.

I guess I could write my own control, but if such a thing already exists somewhere in LÖVEland I'd certainly rather just pick it up and use it so I can get back to working on the actual game. Anyone have any pointers/advice they can share?

Thanks in advance!
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Implementing a scrolling text box

Post by pgimeno »

With Gspöt you can create labels and place them in an automatically scrollable window, then force the scroll bar to the bottom. Probably with other libraries too. I'm not aware of any library with that kind of control built-in.
jalefkowit
Prole
Posts: 2
Joined: Thu May 12, 2016 4:26 am

Re: Implementing a scrolling text box

Post by jalefkowit »

pgimeno wrote:I'm not aware of any library with that kind of control built-in.
That what feels so weird! A scrolling text box is a basic control in just about every GUI toolkit ever, both OS-native and cross-platform. So I was surprised when I couldn't turn one up for LÖVE.

I guess it relates to the biggest thing that's preventing me from getting into LÖVE generally: the absolute train wreck that is interface-building. There's no batteries for that included, and the landscape of add-on modules is full of incomplete projects that are nearly all prominently marked as abandoned. So with LÖVE you have to do a lot of lower-level grunt work defining UI components that other platforms let you skip.

(Which is a shame, because I absolutely adore everything else about LÖVE and Lua compared to heavier, more verbose alternatives like LibGDX.)
User avatar
mr_happy
Citizen
Posts: 84
Joined: Fri Mar 18, 2016 8:57 pm

Re: Implementing a scrolling text box

Post by mr_happy »

jalefkowit wrote: A scrolling text box is a basic control in just about every GUI toolkit ever, both OS-native and cross-platform. So I was surprised when I couldn't turn one up for LÖVE.
To be fair, Love isn't a GUI toolkit, it's a 2D game engine and few of those have any form of GUI elements (even the big boys like SDL). If you want (some) GUI capabilities built-in you might want to look at something like www.godotengine.org
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Implementing a scrolling text box

Post by zorg »

Or, you know, look around for one of the ~5-10 already existing GUIs for löve... well, if they support 0.10...
or wait for Kenny to release the successor to loveframes :3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
pgimeno
Party member
Posts: 3656
Joined: Sun Oct 18, 2015 2:58 pm

Re: Implementing a scrolling text box

Post by pgimeno »

jalefkowit wrote:That what feels so weird! A scrolling text box is a basic control in just about every GUI toolkit ever, both OS-native and cross-platform. So I was surprised when I couldn't turn one up for LÖVE.
Wait. A scrolling text box in Gspöt is just a label inside a scrollgroup, and I'm pretty sure that something like that is supported by most GUIs. I was under the impression that you were after something a bit different, where you added chunks of text separately from the rest and it automatically scrolled to the end. That's not what a "scrolling text box" is to me. That's more like what chat programs use, and it sounds like a somewhat specialized control that is unsurprisingly not that widely supported.

The demo of Gspöt features what pretty much amounts to a "scrolling text box", defined as scrollable text inside a box.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest