Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: loominous on Thu 21/07/2005 03:42:03

Title: Selecting textparts in a textbox
Post by: loominous on Thu 21/07/2005 03:42:03
Is it possible to select text as one would in a texteditor? My goal is to enable the player to select any text from the game (and save it), so cumbersome workarounds with clickable invisible objects or such isn't really an option.

Much obliged for any solution.

(To be completely clear, the player should be able to select single words, so just saving individual lines wouldn't do it)
Title: Re: Selecting textparts in a textbox
Post by: Gilbert on Thu 21/07/2005 04:53:47
Not directly unfortunately, that will involve some scriptings.
Title: Re: Selecting textparts in a textbox
Post by: loominous on Thu 21/07/2005 07:25:40
Could you elaborate somewhat? I'm not asking for the script, just an idea of how it could be made, functions to be used etc.

Atm I have no idea how to get the game to respond to clicks on text.

Thanks.
Title: Re: Selecting textparts in a textbox
Post by: Gilbert on Thu 21/07/2005 09:32:14
Well since it's quite hard to explain, I mucked up some crappy demo:
Grab here (http://www.2dadventure.com/ags/gchilight000.zip)
which I worked hard using trial-and-error to get to work (sort of working anyway), it's crapily pieced together so there might be simpler solutions (now it's more like a hack, which requires a fixed width font).

(Compile it with V2.62, not that I don't know how to script in V2.7, I just don't use V2.7+)

Just type something, drag over the text to highlight, release button to see what is copied.
Title: Re: Selecting textparts in a textbox
Post by: loominous on Thu 21/07/2005 23:08:18
My, my, that's really good of you to take the time, thanks a bunch!

As I understand it the script only works with monospaced fonts, so I'm thinking of a solution for proportional ones, since the game depends on them.

The only way I've come up with so far would be to find out the width of each character and then have the script add those values up to figure out the current mouselocation.

Does any easier solution strike anyone?
Title: Re: Selecting textparts in a textbox
Post by: Gilbert on Fri 22/07/2005 03:52:33
I think there're no easy way, if your font is not fixed width it will be much more complex. Afterall AGS was not originally designed to have that many functionalities in that field.
Title: Re: Selecting textparts in a textbox
Post by: GarageGothic on Fri 22/07/2005 11:22:14
I don't think it would be much more difficult just using GetTextWidth, which would allow you to use any font. The main problem seems to be the spacing (or rather, not being able to use spaces for alignment), so you might see the highlighted text slightly misaligned.