Copy and paste support for parsers?

Started by mkennedy, Sat 22/12/2018 09:54:19

Previous topic - Next topic

mkennedy

Is it possible to have a parser based game that would allow players to copy and paste text in the text entry box or possibly even copy text from ingame text windows? How difficult would such a thing be to code? The first one might be feasible, but the second would be a lot more trickier I imagine.

Cassiebsg

#1
I know Snarky made or was working on copy/pasting function for the AGS Awards, think he might have posted it as a module.

Edit: Here you go, it's a plugin though.
http://www.adventuregamestudio.co.uk/forums/index.php?topic=55922.0
There are those who believe that life here began out there...

Khris

The hard thing is being able to select part of a text. Just copying all text displayed in a label is simple:
Code: ags
  clipboard = lblMessage.Text;


So how feasible it is depends on what exactly you're after. You need to be way more specific, as in, how exactly would the user select text? How does the text appear? Via Display()? And so on.

Snarky

If you just want the copy/paste to work inside the game, that's pretty simple in concept, as Khris says. If you want it to work between your game and other applications (the Windows clipboard), then you need to use my plugin.

Text selection is the biggest thing you might have to implement yourself, although there are some modules that implement it for some cases. (I think the French boards have one, for example.)

mkennedy

#4
Quote from: Cassiebsg on Sat 22/12/2018 10:58:19
I know Snarky made or was working on copy/pasting function for the AGS Awards, think he might have posted it as a module.

Edit: Here you go, it's a plugin though.
http://www.adventuregamestudio.co.uk/forums/index.php?topic=55922.0
Thanks, I'll take a look at that.


Quote from: Khris on Sat 22/12/2018 11:49:52
The hard thing is being able to select part of a text. Just copying all text displayed in a label is simple:
Code: ags
  clipboard = lblMessage.Text;


So how feasible it is depends on what exactly you're after. You need to be way more specific, as in, how exactly would the user select text? How does the text appear? Via Display()? And so on.
Ideally the player would be able to select a portion of text using the cursor and then paste it into the text input window.

Snarky

AGS doesn't offer a way to make a selection on any of its GUI controls that deal with text (TextBox, Label, Button and to some extent TextWindow â€" ListBox lets you select a ListEntry line, but not part of a line), nor with text that is displayed through a built-in mechanism, such as speech.

Therefore, you would have to implement it yourself. You could do the logic as extensions to the existing controls, but the problem is that you can't really display the selection in any way, so unless you want to work blind you'll have to create a new control where you handle all aspects of the appearance and interaction. (This is typically done as a type of Button where you draw the text as a dynamic sprite.) You can implement your own version of a Label pretty easily, while a TextBox is more complicated.

Then you would have to implement:
-A way to calculate the position in the text String of a given coordinate, if you want to be able to click-and-drag to select
-Logic to handle the selection action (click-and-drag gesture or keyboard selection)
-Logic to display the selection region
-If the text is to be editable: logic to handle edits in the middle of the string, delete/insert text actions, text cursor positioning, etc.
-... and then you could easily add cut/copy/paste functionality

Most of this is fairly doable if the text is only a single line, but when you have text broken over multiple lines it starts to get pretty hairy. As I said, there are modules that do at least some of it (the TextInput module that's used in the Clipboard demo is one of them), but I don't know that any are fully featured and fully working.

SMF spam blocked by CleanTalk