intfiction.org

The Interactive Fiction Community Forum
It is currently Sat May 18, 2013 9:23 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2, 3
Author Message
PostPosted: Sat Nov 05, 2011 12:09 pm 
Offline

Joined: Mon Apr 18, 2011 3:14 am
Posts: 106
Location: Madrid, Spain
ektemple wrote:
rockersuke wrote:
As I told you before, you must put the lines that write the new command at the prompt before calling the glk cancel line function.


No, that's not legal. You can't print* when there's a line event pending, so the cancelation needs to happen first. The only way to prevent the line break is to use the set echo function that Ben mentioned.

--Erik

*Some interpreters will print text to the window while a line event is pending, but it is unambiguously out-of-spec.


Cool! :D That means it was working nicely for me 'cause my terp was acting in an illegal way! :P

OK, as I said, I've been trying with this glk_set_echo_line_event() function (which I checked was supported in my Windows Glulxe)(remember to get the latest infglk.h, not the one in the IF Archive but the one in zarf's github thing). Almost there...!

It happens that, as documented in the GLK 0.7.3 API specification that Ben linked (here), this function only works in subsequent line input requests... So the line break would be there when you catch the hyperlink event but won't appear in subsequent turns... Of course in these subsequent turns ordinary behavoiur is overidden by this save you turn it off, which would then have an effect not in the current turn, but in the following ones...

Save I'm missing something, this make this feature very useful if you know in advance that your work is meant to be used exclusively in one or the other mode, but not if both are supposed to co-exist and you can't predict wether the player is going to type or click.

Still I do hope I'm missing something...

_________________
English posts in my blog!


Top
 Profile Send private message  
 
PostPosted: Sat Nov 05, 2011 12:26 pm 
Offline

Joined: Tue Apr 27, 2010 1:02 pm
Posts: 797
As a practical matter, you would want to turn off the echo when the game starts. Then just print the player's input after line input events - it comes back to you in the event struct - and discard it when you cancel the line input request.

Example code here; demo here.


Top
 Profile Send private message  
 
PostPosted: Sat Nov 05, 2011 12:40 pm 
Offline

Joined: Tue Mar 09, 2010 2:34 pm
Posts: 2127
Location: Burlington, VT
Would it be pushy to ask someone to wrap this up in a nice I7 extension when it's all ironed out? Because that would be great.


Top
 Profile Send private message  
 
PostPosted: Sat Nov 05, 2011 1:22 pm 
Offline

Joined: Thu Oct 22, 2009 4:31 pm
Posts: 1137
matt w wrote:
Would it be pushy to ask someone to wrap this up in a nice I7 extension when it's all ironed out? Because that would be great.

There are already three or four I7 extensions that offer the basic hyperlink functionality, including the ability to link a command that is different that the linked text (e.g., clicking on the text "north" to produce "go north"). What all of them are missing, though, is the new echo functionality to fix the default line break that accompanies a canceled input event. I second the request for an extension or a demo of that for I7...

--Erik

_________________
Glimmr: Advanced Graphics for I7
blog | download | bug-tracker


Top
 Profile Send private message  
 
PostPosted: Sat Nov 05, 2011 4:41 pm 
Offline

Joined: Mon Apr 18, 2011 3:14 am
Posts: 106
Location: Madrid, Spain
bcressey wrote:
As a practical matter, you would want to turn off the echo when the game starts. Then just print the player's input after line input events - it comes back to you in the event struct - and discard it when you cancel the line input request.

Example code here; demo here.


Aha, thanks!
That linked example is not in the format of an actual game and makes its glk calls with numbers instead of meaningful names (which are luckily mentioned after that in comments) so yeah, I'm having the mother of all headaches right now :lol:, but I guess I have a working (and hopefully not based on an illegal feature if WinGlulxe) example:

Code:
!% -G
!% -D

Include "Parser";
Include "Verblib";
Include "Infglk";

Object Room_01 "Room 01"
with
description
[;
   print "You're in Room 01. An exit leads ";
   glk_set_hyperlink(1);
   print "NORTH";
   glk_set_hyperlink(0);
   print_ret ".";
],
n_to Room_02,
has light
;

Object Room_02 "Room 02"
with
description "You're in Room 2",
s_to Room_01,
has light
;

[Initialise;
   glk_request_hyperlink_event(gg_mainwin);
   glk_set_echo_line_event(gg_mainwin,0);
   lookmode = 2;
   location=Room_01;
];

[HandleGlkEvent ev context abortres newcmd cmdlen;
   switch (ev-->0)
   {
      evtype_hyperlink:
         glk_request_hyperlink_event(gg_mainwin);
         glk_cancel_line_event(gg_mainwin,0);
         
         newcmd="go north";
         cmdlen=PrintAnyToArray(abortres+WORDSIZE,INPUT_BUFFER_LEN-WORDSIZE,newcmd);
         abortres-->0=cmdlen;
         
         Command_printing();
         
         return 2;
      evtype_LineInput:
         Command_printing();
   }
];

[Command_printing;
   glk_set_style(style_Input);
   glk_put_buffer(buffer+WORDSIZE, buffer-->0);
   glk_set_style(style_Normal);
   new_line;
];

Include "Grammar";


It's probably too late to help Jim, but I didn't want to just forget about it. What it does is:

-Sets echo off at the begining of the game.
-Uses the line input event to manually print the contents of the player input (calling the Command_printing routine)
-After a click is detected, its command is also printed calling the same routine.

Seems to work, though I've hardly tested it! ^_^' any contraindication or just something that could go wrong with this?

_________________
English posts in my blog!


Top
 Profile Send private message  
 
PostPosted: Sat Nov 05, 2011 6:31 pm 
Offline

Joined: Sun Mar 01, 2009 8:02 pm
Posts: 902
rockersuke wrote:
It's probably too late to help Jim, but I didn't want to just forget about it.

Far from being offended by this unintentional slight, I'm amused. I agree -- I'm quite beyond help!

--JA


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group