Jump to content
Eternal Lands Official Forums
LabRat

Allow dialogue boxes to accept keystrokes

Recommended Posts

https://developer.berlios.de/patch/index.ph...p;group_id=1256

 

Pictures will show it as clearly as I can explain it:

 

Hover the mouse over where the NPC face is (or should be if it missing) then press the key to choose the menu item you desire.

 

Pressing Escape will close the window.

 

If the window has more dialogue text items than will fit the box will automatically resize in the Y axis (the box will get taller).

 

npc1.jpg

 

npc2.jpg

Share this post


Link to post
Share on other sites

if(ch>='z' && ch<='z')
ch-=32; //a-z->A-Z

Typo. This should be ch>='a' && ch<='z'

 

if(ch>='A' && ch<='Z')
ch-=55; //A-Z->11-36
if(ch>='1' && ch<='9')
ch-=49;
if(ch=='0')
ch=10;
if(ch>=36)//out of range
{
return 0;
}

 

I'd rather write this block like

if (ch>='a' && ch<='z') { ch-=87; }
else if (ch>='A' && ch<='Z') { ch-=55; }
else if (ch>='1' && ch<='9') { ch-=49; }
else if (ch=='0') { ch=10; }
else return 0;

This makes it more error prone and easier to understand which characters are passed and which are discarded

 

Edit: Forgot to say: Nice patch :-)

Edited by ago

Share this post


Link to post
Share on other sites

+					if(i==10) //0
+						safe_snprintf(str,sizeof(str),"0] %s",(unsigned char*)dialogue_responces[i].text);
+					else if(i>=0 && i<=9) // 1-9
+						safe_snprintf(str,sizeof(str),"%c] %s",49+i,(unsigned char*)dialogue_responces[i].text);
+					else if(i>=11 && i<=35) // A-Z
+						safe_snprintf(str,sizeof(str),"%c] %s",55+i, (unsigned char*)dialogue_responces[i].text);
+					else // too many dialogue options, you have to click these
+						 safe_snprintf(str,sizeof(str),"%s",(unsigned char*)dialogue_responces[i].text);
+					draw_string_small(dialogue_responces[i].x_start+5,dialogue_responces[i].y_start+7*14,str,1);

 

Perhaps this should be:

i >= 0 && i <= 8 : i + 49; // (1 - 9)

i == 9 : '0'

i >= 10 && i <= 35 : i + 55 (A - Z)

 

And really good patch, more keyboard is always welcome :lipssealed:

Edited by Alia

Share this post


Link to post
Share on other sites

typo corrected and if amended to something like ago's

 

alia your perhaps is pure semantics, no gain would be achieved.

Share this post


Link to post
Share on other sites

alia your perhaps is pure semantics, no gain would be achieved.

 

else if(i>=0 && i<=9) // 1-9
safe_snprintf(str,sizeof(str),"%c] %s",49+i,(unsigned char*)dialogue_responces[i].text);
else if(i>=11 && i<=35) // A-Z
safe_snprintf(str,sizeof(str),"%c] %s",55+i, (unsigned char*)dialogue_responces[i].text);

 

For i=9 this would be 9+49 = 0x3a = ':' and for i=11 -> 11 + 55 = 0x42 = 'B'

 

The mapping should be

'1' <-> 0

'2' <-> 1

...

'9' <-> 8

'0' <-> 9

'A' <-> 10

'B' <-> 11

...

Edited by ago

Share this post


Link to post
Share on other sites

ohh gotcha sorry alia :lipssealed:

 

Patch amended and credited change to you.

Share this post


Link to post
Share on other sites

Is there a way to turn it off? It would be kinda annoying if you are chatting with storage window open (or some other npc window) and you want to type a number... (or press esc to clear line).

Share this post


Link to post
Share on other sites
That's a nice patch. Can people test and see if it works fine in all circumstances?

 

And what happens if more than 9 items?

1-0 then a-z, which gives 36 possible choices, after that it just outputs them as normal options
x] option 34  y] option 35  z] option 36  option 37  option 38

I went a-z so as to not have to worry about keyboard layout issues (azerty/qwerty/dvorak etc)

 

Is there a way to turn it off? It would be kinda annoying if you are chatting with storage window open (or some other npc window) and you want to type a number... (or press esc to clear line).
Sure, just don't put the mouse over the NPC's face in the dialog window and it gets passed straight through the window..

Share this post


Link to post
Share on other sites

I don't get the numbers 1-9.

make your second "if" in display_dialogue_handler (dialogues.c) an "else if"

...
+					if(i>=0 && i<=8) // 1-9
+						safe_snprintf(str,sizeof(str),"%c] %s",49+i,(unsigned char*)dialogue_responces[i].text);
+					else if(i==9) //0
+						safe_snprintf(str,sizeof(str),"0] %s",(unsigned char*)dialogue_responces[i].text);
...

Share this post


Link to post
Share on other sites

Thanks Alberich, patch amended.

 

It's always the small things that slip through the cracks ;)

 

npc3.jpg

 

I hope this makes it clearer as to what happens with the 1-9 and 0 (I did it the way it is on a keyboard, not the way we count).

Share this post


Link to post
Share on other sites

I have aquestion:

Do those numbers/letters appear in the options only after the mouse is palced over the npc icon? Or are they there all the time?

Share this post


Link to post
Share on other sites

Currently all the time, but I was considering making them popup when the mouse hovered over the face.

 

Won't take but a few lines of code to achieve that effect should you want it.

Share this post


Link to post
Share on other sites

Patch updated with The_Piper's suggestion.

 

Now the patch can be toggled in the Options window->controls tab.

 

There are 2 options:

Keypresses in dialogue boxes

and

Keypresses allowed anywhere in dialogue boxes

The first one activates the patch, the second one chooses between the mouse being over the NPC face [ ] and anywhere in the window [X].

 

Comments are always welcomed (see the loads of posts above :whistle:)

Edited by LabRat

Share this post


Link to post
Share on other sites

IMO dialogs with numbers are a pain to read.

I don't know perhaps something like [1] or (1): would be better? (opinions)

(was it always possible to close the box with ESC?)

dialog.png

 

btw: nobody can buy 1k needles or 50 picks

Share this post


Link to post
Share on other sites

I don't fill in the NPC information, the server does that. The server would happily sell you 1000 needles apart from the fact they are unstackable.

 

Patch amended, now it only shows the 1] 2] 3] when the mouse is in the window or in the npc face area (if either is appropriate).

 

Making this patch is fun :whistle:

Share this post


Link to post
Share on other sites

For me it looked better, when numbers were visible all the time.

To make it easier readable, perhaps different color for them should be used.

Share this post


Link to post
Share on other sites
I've been it for while and I'd really appreciate if it worked with cursos just over npc's window not only over it's face.
It has that capability, revert and redownload the patch then apply it again. I added that in the post 4 before yours.

 

Other than that, any issues?

Share this post


Link to post
Share on other sites

Just a check:

 

I have been using this patch constantly and am having no issues with the last iteration of the code.

 

Has it killed anyone's cat?

 

Are there any more usability suggestions from anyone?

 

If not, may we take that as the code is ready to be committed to CVS as Ent himself likes the code?

Share this post


Link to post
Share on other sites

I've been using the patch for the past week or so and it works as advertised for me :) I do like being able to use keystrokes so the patch is very much appreciated :)

 

The only slight issue I have is that even when the keystrokes are disabled extra spaces are added to the dialogue box, which means options are not where they normally are. However I'm sure I'll get used to the new positions soon :)

Share this post


Link to post
Share on other sites

I'll look into that as soon as I finish this post :)

Share this post


Link to post
Share on other sites

Patch has been updated, thanks Terrier :)

Share this post


Link to post
Share on other sites

Just a ping to check if anyone has had any problems with this patch in its latest form, if not I will nudge a passing client dev to merge it.

 

I only thought about it as I used it a second ago without thinking, it has become second nature to me now, and sure helps me spend my pickpoints easier :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×