The online racing simulator
InSim : Button system (now W30)
(54 posts, closed, started )
#26 - FL!P
FlipCam 1.0b1
I'm releasing the first beta version of FlipCams, a new addon for LFS that allows to save and use five different custom views per car, and cycle through them by pressing CTRL+F11 and CTRL+F12.

Sorry about the spam but I'm posting this here because W29 is required, so I won't advertise FlipCams yet in the Unofficial Addons subforum (I hope this is OK with the devs and moderators). But you can get it from my team's site.

Please let me know if you run into any issue with it. I hope you'll enjoy it!

Thanks again to Scawen for having implemented the /wait command that fast when I needed it!
Quote from hackerx :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)?

Thanks, yes it should be legal. Will fix...
wAlthough I have not been active posting in this thread I have been lurking around, keeping up with the progress.

Quote from Scawen :Considering: Multiple line text boxes

That would be very handy for reasons stated earlier. Originally I was intending to use multiple buttons (just like hx suggests below) but this would be more convenient. Thanks.

Edit: Just had a W28 crash. I was choosing tracks in the single player game mode when LFS suddenly froze and crashed. Im not sure if it froze before or after I selected Aston in the right-hand list of tracks. See attachment for crash address.
Attached images
sshot964.jpg
Actually is quite easy to build with current buttons something that looks like multi-line text box. Unless you want it to be automatically scrolling?
Attached images
textbox.jpg
Typo: IS_BTT size is 68 according to documentation but it should be 104 (4 bytes header + 4 bytes properties + 96 chars of text).
Quote from felplacerad :Edit: Just had a W28 crash. I was choosing tracks in the single player game mode when LFS suddenly froze and crashed. Im not sure if it froze before or after I selected Aston in the right-hand list of tracks. See attachment for crash address.

In W28 it would crash if you clicked on the track selection car selection pictures - fixed in W29.

Quote from BurnOut69 :Typo: IS_BTT size is 68 according to documentation but it should be 104 (4 bytes header + 4 bytes properties + 96 chars of text).

Thanks.
Quote from Scawen :In W28 it would crash if you clicked on the track selection car selection pictures - fixed in W29.

Hm, yes. I just spotted ussbeethoven's post. I guess I wasn't following the progress as closely as I thought I was. Sorry about the duplicate report.
OK, here's W30 - I would like to release a public test patch soon, probably this evening but thought I'd better let you guys have a go first to make sure it's running OK.
One thing to note is I've expanded the clear space for buttons. The recommended area for buttons is now :

x : 0 to 110
y : 30 to 170

LFS will try to keep that region clear if you add buttons. There's a new state flag to let you know if buttons can be seen as well.

Updates in W30 :

- A new ISS_VISIBLE flag so InSim programs know if buttons can be visible
- Optional captions for TypeIn dialogs
- IS_CRS : Notification of car reset
- InSim buttons now visible in SHIFT+U mode
- Entry screen makes more space for InSim buttons
- Added "remote" to PType in IS_NPL

FIX : PLID is local player was zero at start of single player
FIX : IS_NPL packets were not sent at start of single player
FIX : Crash on drawing textless packet (size 12)

Updates in W29 :

- 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
- New command /wait (like /exec but LFS hangs until the program exits)
- Command line command /player (start LFS with specified player name)

Considering :

- Add a packet to notify of autocross penalties / false start
- Always visible buttons (possibly those outside the recommended area)
- Space clearing optional (possibly if any buttons are in the recommended area)
- Multiple line text boxes

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

[ EDIT : link removed - W31 is out http://www.lfsforum.net/showthread.php?t=24877 ]
W32
I've released W32 in the test patch forum.

Note : I added one flag to the NCN packet so you know if it's a remote connection. This way you know which connection is your own, similar to the new flag in the NPL packet.

http://www.lfsforum.net/showthread.php?t=24877
-
(hackerx) DELETED by hackerx : no reason really...
Quote from Scawen :- Always visible buttons (possibly those outside the recommended area)
- Space clearing optional (possibly if any buttons are in the recommended area)

That would be nice. For space clearing maybe BFN packet could be used, with commands like "clear space", "unclear space", "make this ClickID always visible/not affecting space clearing", etc.

And few questions...

I noticed that buttons don't work at all in MPR replay. Is that intentional or not done yet?

Is it somehow possible to use on buttons those seven-segment numbers LFS uses to display times?
Well I was thinking of making it automatic, so that any button outside the "recommended area" was always on, and any button inside that area, caused that whole area to be kept clear (but is not visible in option screens, etc).

The idea would be that if you use the recommended area, you can have the largest menu space, when possible. And if you want something permanently on, you'd better use the top and bottom screen edges.

In that way, no extra flags are needed. It seems to me that covers most situations I can think of.
Hmm after some thinking, this automatic system isn't perhaps that good, or so to say future compatible. Suppose one day you want to make LFS UI fully configurable. Which is quite likely I guess. Or just rearrange screens. In this case "recommended area" has no meaning any more.

Anyway, simplest solution is perhaps clear screen completely on shift+B/I, if InSim program requests that (with BFN?). Plus possibility to make "always on" buttons, which would be then treated as part of LFS interface. Simple, but quite flexible.
I'm currently testing the custom buttons with W32. I have two short questions.

Question 1:
I saw that when I click a custom button on the main screen (where you can select single or multiplayer mode) then a ISP_STA pack is sent back to my application. Also when I click OK or CANCEL when changing the button text. Is that intended?

Question 2:
Is it correct, that after editing a button text the new text is not shown on the button? The new text is only sent back in a ISP_BTT packet and I have to change the text via an IS_BTN packet?
Quote from LupusC :Question 1:
I saw that when I click a custom button on the main screen (where you can select single or multiplayer mode) then a ISP_STA pack is sent back to my application. Also when I click OK or CANCEL when changing the button text. Is that intended?

The IS_STA packet is sent whenever any info in the state pack changes, In the case of typing in text, it's the button visibility flag that changes. At least, that explains the IS_STA being sent when you edit the text - that is an annoying result of including the button visibilty flag in the state pack.

I have no idea why you would get an IS_STA packet just because you clicked on a standard clickable button, unless that button caused the state info to change.

Quote from LupusC :Question 2:
Is it correct, that after editing a button text the new text is not shown on the button? The new text is only sent back in a ISP_BTT packet and I have to change the text via an IS_BTN packet?

Yes, I took this decision for a few reasons - for a start, I wanted the user to really know if the application had received your text. If it changed automatically without a reply you wouldn't really know that, and also you could enter invalid text. For example, if a text box was supposed to be a numerical field and you entered a word, or it was a filename and you entered illegal characters. That's why I left it to the external program to change the text. Buit you can do that quite easily by returning with a zero width and height button with the same ClickId, specially coded for this purpose - the zero width and height means "leave all info unchanged except for this new text".
Quote from Scawen :I have no idea why you would get an IS_STA packet just because you clicked on a standard clickable button, unless that button caused the state info to change.

Ok, I only mentioned it because it was strange for me.


Quote from Scawen :Yes, I took this decision for a few reasons - for a start, I wanted the user to really know if the application had received your text. If it changed automatically without a reply you wouldn't really know that, and also you could enter invalid text.

Ok, perfect.

Thanks for your info.
Just notifying you of some more InSim and other relevant updates in W33.

Can now save MPR from dedicated host (auto or manual - using /save_mpr)
FIX : /end command in single player did not exit correctly
InSim : ISS_VISIBLE no longer changes due to text entry dialog box
InSim : IS_PEN packets now sent on autox false start or wrong route
InSim : Total time penalty is now included in IS_RES (compatible)

http://www.lfsforum.net/showthread.php?t=24877
Just a sidenote:

In the insim document there are the following lines
#define ISS_SHIFTU_NO_OPT 64 // buttons are hidden
#define ISS_VISIBLE 16384 // buttons are visible

I think the first one means the buttons in shift+u mode and the second one the insim-creaded buttons, but the comment is a bit confusing.
OK, I've improved the comments. I won't add it to the list of updates, so I'm just confirming that here.
OK... W35 is out now.

http://www.lfsforum.net/showthread.php?t=25054

I've added the "always on" option for buttons. Please use that in very rare cases (probably a button right at the top or bottom of the screen that for some reason you need to be visible even when the user is in options or garage). Always on buttons can't be used with TypeIn.

And the "recommended area" is now only cleared if there are actually buttons in the recommended area.
I've uploaded W36 and the buttons can now appear in MPR or SPR played from the replay selection screen.

Please let me know if you find the recommended area clearing and the always on buttons seem to work well.

http://www.lfsforum.net/showthread.php?t=25134
In the InSim doc, the IS_BTN structure is like this :
struct IS_BTN // BuTtoN - button header - followed by 0 to 240 characters
{
byte Size; // 12 + TEXT_SIZE (a multiple of 4)
byte Type; // ISP_BTN
byte ReqI; // non-zero (returned in IS_BTC and IS_BTT packets)
byte UCID; // connection to display the button (0 = local / 255 = all)

byte ClickID; // button ID (0 to 239)
byte Inst; // some extra flags - see below
byte BStyle; // button style flags - see below
byte TypeIn; // max chars to type in - see below

byte L; // left : 0 - 200
byte T; // top : 0 - 200
byte W; // width : 0 - 200
byte H; // height : 0 - 200

// char Text[TEXT_SIZE]; // 0 to 240 characters of text
};

Why the "Text" line is in comment ?
I've put it in a comment because that structure is just a header really. The text is a variable sized quantity that follows that header. I just figured that if the text was not commented out, it would suggest that it was a fixed size packet.
Hmm ok, I understand.
Thanks for the answer.
Shift + B doesn't seem to work in MPR replay.
I'm writing a driver-list repleacement atm and one thing bugs me

I don't know when there is an info window in the lower left corner like F9-F12 or Connection List. Is there any free byte in the status pack to indicate if there is some window showing?

And the position behaviour someone stated already when finishing the race. The ap count should count +1 and the position should "freeze" :/
This thread is closed

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