The online racing simulator
InSim : Button system (now W30)
(54 posts, closed, started )
InSim : Button system (now W30)
Hello again programmers.

Here is the first version of the InSim button interface, which allows host control systems or local InSim programs to put buttons on your screen and receive button clicks or text typed on clicking the buttons.

This can be used to provide a better interface (with menus, information, etc) to InSim programs. The user can call up a menu from a host control system by pressing SHIFT+I (if the host controller sends some buttons as a reply). And similarly, local InSim programs can respond to the SHIFT+B key press. SHIFT+I and SHIFT+B also remove any buttons that are there (and in that case they don't send a request for buttons) so they work as a menu toggle.

I recommend you keep your buttons to the left middle of the screen, to avoid overwriting the LFS 2D displays. The menus are displayed in the game setup screen and in game. In the game setup screen the connection and player lists are not visible if any buttons are shown.

Please have a look and let me know what problems you find.

Download : (there are no other changes so this is only for InSim testing)

[ EDIT - download link removed - W30 now available http://www.lfsforum.net/showthread.php?p=432676#post432676 ]
#2 - nikka
Thanks, just what the doctor ordered!

But in my local computer-app (IS_BTN UCID=0), buttons are only visible when connected to a server, not in main menu, connection list screen and so on.. hopefully it's not intended to be this way since IS_MSL's for example are visible everywhere.

Edit: and uhm, shouldn't the buttons disappear when you close your insim app?

Edit again: omg, the thing with clicking the button to open a text input box... it's just awsome! Just what my app needed!

Edit III: would it be possible to add a "char TextCaption[20]" or something to IS_BTN to change the caption in the input box from "Edit" to something else?
Ok finished testing for now. Works pretty good on local mode (ucid = 0, button id > 160).

My buttons are visible in Singleplayer setup and singleplayer. Didn't test in multiplayer.
OK did some quick testing, few thoughts:

I create 60 buttons (as on picture - players list), and it takes somewhere between 1.2 - 1.5 sec. That's quite slow.

Also I think 79 (if I'm not mistaken) local buttons is not enough, for example for creating some bigger tables with many columns. Why there has to be two separate ClickID ranges anyway?
Attached images
buttontest.jpg
Quote from nikka :But in my local computer-app (IS_BTN UCID=0), buttons are only visible when connected to a server, not in main menu, connection list screen and so on.. hopefully it's not intended to be this way since IS_MSL's for example are visible everywhere.

I'm not sure what you mean by this. They should be visible in single player and hot lapping as well, not only when you are connected to a host.

The buttons should be visible in game and in the game setup screen, those are the only two screens where they are supposed to be visible. This is mainly intended as a system for use in game or when connected to a host, it's not supposed to be a replacement for all LFS's buttons or something like that. It would be hard to make it work on other screens as well, and it's not something I've considered at all.

If you can describe to me a reason why you need it on some other screen then I can consider it.
#6 - nikka
Quote from Scawen :If you can describe to me a reason why you need it on some other screen then I can consider it.

Well, what i'm working on right now is an insim messenger client (will maybe make it a jabber client later if i'll ever bother).

I was planning to use the buttons to display people who are online (in messenger), so you can click the button to say something to someone, and also use buttons as a list of active conversations to make it easier to handle multiple ongoing conversations.

Obviously, it would be nice if you could chat with people when not connected (or in single player)... if someone say something to you when you're in the list-of-games-screen, it would not be very user friendly if you'll have to hurry up and join a host so you can reply...

But if it's just me, please don't hold back X for this.. I know you have alot of (more) important things to do. But anyways, thats why I need it
Before I knew the buttons were comming I was looking for a decent and non-messy way of solving this (handling multiple conversations and initiating conversations), and the buttons was a gift from above for my app.
Thanks for the comments. Here's a preview of what's to come.

Done :

- Can show up to 240 local and 240 host buttons
- ISF_ option to include colours in MSO packets
- InSim disconnect clears its own instance's buttons
- Reason for leaving is now shown in the CNL packet
- Faster receive of buttons by using larger TCP buffer
- Allow buttons in main entry screen (left buttons disappear)
- Added an ISF_ flag to specify local or host program (replaces ClickID ranges)
- Simplified the IS_BFN packet - programs can only remove their own buttons
- ViewPlayer removed from STA, SCC and CPP packets - using PLID instead

Other updates slightly relevant to programmers :

- New command /wait (like /exec but LFS hangs until the program exits)
- Command line command /player (start LFS with specified player name)

Considering :

- Some way for InSim programs to know if buttons can be visible
- Add a packet to notify of autocross penalties / false start
- Caption for TypeIn dialogs
- Notification of car reset
- Multiple line text boxes
Quote from Scawen :- Probably will add a packet to notify of autocross penalties / false start

If you could that would be great!
Quote from Scawen :Here's a preview of what's to come.

Beautiful!

And to make this post more useful, little suggestion not related to buttons: CNL packet could have reason for disconnect, normal/connection lost/kick/ban(/something else possible?).
Quote from MoHaX :Is it possible to add new insim packet which will inform insim app if player resets car state (button X by default)? It seems that it's only event which remain hidden from insim app.

Do you mean, the reset car function - the one which fixes damage and puts the car upright?

I would think that's what you mean but you said X by default - but reset car is space bar by default I think.
Yeah. I think he meant car reset that places the car on road, with or without, damage.
I need some way of knowing whether I'm in a screen where I can draw buttons or not (no use of drawing buttons if they're not visible).
Is this possible using excisting insim functionality?
Is that good that left game buttons are not visible ? How can a player join track then if i send him some of my buttons when he connects ?



Great job otherwise . This will be very useful.
Attached images
DefaultButtonsDissappear.JPG
Quote from nikka :I need some way of knowing whether I'm in a screen where I can draw buttons or not (no use of drawing buttons if they're not visible).
Is this possible using excisting insim functionality?

No. But there is a reason to send buttons even if they can't be seen. Because they will be seen as soon as they leave the options screen or whatever screen they are in. Now that it's visible in game, the game setup screen and the front end screen, that means they should usually be visible. Why would someone "hang around" in one of the other screens? I'm just trying to understand if we really do need some kind of "buttons are visible" notification, as the idea is that shouldn't be needed.

Quote from MonkOnHotTinRoof :Is that good that left game buttons are not visible ? How can a player join track then if i send him some of my buttons when he connects ?



Great job otherwise . This will be very useful.

Well he could just press SHIFT+I and your buttons will vanish. Or he could type /join.

I don't really know how this system could work at all if I don't make some buttons disappear. But, ok, I'll leave the join race button there, I'll just not draw the connection list and the start grid.
There seems to be a bug in W28: if you choose a car or a track (here always) by clicking on the picture instead of the text LFS will crash; tested online and offline.
Thanks but if it is a trouble to do, don't bother. I can use ordinary messages or write a message for user to press shift+i.

Another request that would be very useful for multi-purpose sim . I would like to force guests to remove all default text while on track (thing that already happens when clicking shift+f), so they only see custom buttons. I don't see any way now to do it, unless asking very nicely in welcome screen players to press shift+f when joining track . (main reason is I wouldn't like for players to see a map and wrong way messages on my host). Probably this should be hosts option, but maybe can be done with insim by somehow forcing commands from host to guests? Um, security issues .
Quote from Scawen :No. But there is a reason to send buttons even if they can't be seen. Because they will be seen as soon as they leave the options screen or whatever screen they are in. Now that it's visible in game, the game setup screen and the front end screen, that means they should usually be visible. Why would someone "hang around" in one of the other screens? I'm just trying to understand if we really do need some kind of "buttons are visible" notification, as the idea is that shouldn't be needed.

Well, I told you about my app. I just need an alternative way of handling stuff when a user is in a screen where buttons are invisible, so I need to know when the user is in such a screen.
And no, I don't expect people to "hang around" in these screens, I just want to cover every possible situation.

BTW, a typo in insim.txt (W28):
Quote :byte ReqI; // non-zero (returned in IS_BCL and IS_BTT packets)

Should be "IS_BTC and IS_BTT" i guess.

Speaking of, I don't quite see the point with ReqI in button packets. ClickID is the identifier you should keep track of anyways, or am I missing something?
Quote from ussbeethoven :There seems to be a bug in W28: if you choose a car or a track (here always) by clicking on the picture instead of the text LFS will crash; tested online and offline.

Thanks, good timing, I'm just about to upload what I've done so far today, so I've fixed that crash as well.
Quote from nikka :Well, I told you about my app. I just need an alternative way of handling stuff when a user is in a screen where buttons are invisible, so I need to know when the user is in such a screen.
And no, I don't expect people to "hang around" in these screens, I just want to cover every possible situation.

OK, I've added it to my notes to consider, along with a few other things that still need to be done, like the edit caption thing.

Quote from nikka :BTW, a typo in insim.txt (W28):

Should be "IS_BTC and IS_BTT" i guess.

Thanks, fixed.

Quote from nikka :Speaking of, I don't quite see the point with ReqI in button packets. ClickID is the identifier you should keep track of anyways, or am I missing something?

Yes, just set ReqI to whatever you like and forget about it. It's mainly for relay support. A relay server can poke a ReqI into any request packets (including buttons) and it can then divert the reply packets back to the correct recipient, according to the ReqI value. ReqI is only a user value for external programs. Usually just make it non-zero... 1 is quite a good choice
Quote from Scawen :I don't really know how this system could work at all if I don't make some buttons disappear. But, ok, I'll leave the join race button there, I'll just not draw the connection list and the start grid.

Say I want to just add one small button to race setup screen... then disappearing LFS buttons seems kinda weird. Why not make disappearing LFS buttons optional, controlled by InSim in some way? Could be special TINY packet. BStyle in BTN is already all used... Maybe Instance could be removed and BStyle made a word?
Quote from MonkOnHotTinRoof :Another request that would be very useful for multi-purpose sim . I would like to force guests to remove all default text while on track (thing that already happens when clicking shift+f), so they only see custom buttons. I don't see any way now to do it, unless asking very nicely in welcome screen players to press shift+f when joining track

Haven't tried it myself yet, but take a look at IS_SFP packet, ISS_SHOW_2D there could be what you looking for.

Edit: hmm no that's local only.
W29 - several updates - mostly button system
Updates since W28 :

- Can show up to 240 local and 240 host buttons
- ISF_ option to include colours in MSO packets
- InSim disconnect clears its own instance's buttons
- Reason for leaving is now shown in the CNL packet
- Faster receive of buttons by using larger TCP buffer
- Allow buttons in main entry screen (left buttons disappear)
- Added an ISF_ flag to specify local or host program (replaces ClickID ranges)
- Simplified the IS_BFN packet - programs can only remove their own buttons
- ViewPlayer removed from STA, SCC and CPP packets - using PLID instead

Other updates slightly relevant to programmers :

- New command /wait (like /exec but LFS hangs until the program exits)
- Command line command /player (start LFS with specified player name)

Considering :

- Some way for InSim programs to know if buttons can be visible
- Add a packet to notify of autocross penalties / false start
- Caption for TypeIn dialogs
- Notification of car reset
- Multiple line text boxes

Download : (mainly for InSim testing - not many other changes)

[ EDIT W30 now available http://www.lfsforum.net/showthread.php?p=432676#post432676 ]
Quote from Scawen :
- Can show up to 240 local and 240 host buttons
- Added an ISF_ flag to specify local or host program (replaces ClickID ranges)

Excelent, but you might consider removing this comment to prevent confusion:

Quote :
// ClickID byte : buttons from the host and local buttons are kept separate.
// If you are writing a host program to show buttons on host or guests. use
// the range 0 to 159. If you are writing a strictly local InSim program you
// must use the values 160 to 239 so that your program can be used online.
// This allows local InSim buttons at the same time as host buttons.
// Local InSim programmers should try to avoid overlapping host buttons.

Anyways, I really admire your pace... thanks!
Thanks, yes, that comment in InSim.txt is completely wrong and useless now.

Host and Local button separation is all done now with that one flag ISF_LOCAL in the InSimInit packet.
LFS crash on receiving some (probably invalid) BTN packets: 0040FFE7.

Edit: seems that packets that cause crash are not invalid after all, but with no text. I understand that this should be legal (BTN packet size 12)?
This thread is closed

InSim : Button system (now W30)
(54 posts, closed, started )
FGED GREDG RDFGDR GSFDG