The online racing simulator
Load an image inside a button
1
(27 posts, started )
#1 - sun
Load an image inside a button
hi,

How do you load an image inside a button ? in CTRA they have an image of your self or a friend or what ever what you can upload to the website and be displayed in game.

Regards

Owen.
Owen, you cannot display images in-game.
#3 - sun
well how do CTRA do it ?
I have an image in my ctra account but I have never seen it ingame. Are you sure of what you mean?

Anyway, if that can be done, some tweaking must have been done somewhere because that's not an standard insim buttons feature.
#5 - sun
yes..
Well, then please tell me how can I see my ctra image ingame. An consider asking becky rose about it, though I think she doesn't share her code. Inside a button you can only have 240 bytes that will be represented by LFS as text. If there's some way to trick LFS into loading a external image using that text (like a URL or something) I don't know how to do it.

Anyway, I'd like to see an ingame image first.
#7 - sun
oh yer... my mistake sorry! i was supposed to say, how do you make a button that when it is clicked it brings up a dilog box where you can enter your information
A few basics, use BTT and BTC. I can't explain it all to you, but that is what is needed.
Quote from sun :oh yer... my mistake sorry! i was supposed to say, how do you make a button that when it is clicked it brings up a dilog box where you can enter your information

Dude that's another thing

From the InSim documentation (people should try reading this before asking these kinds of questions):

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
[COLOR=Red][B]byte TypeIn; // max chars to type in - see below[/B][/COLOR]

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
};

// ClickID byte : this value is returned in IS_BTC and IS_BTT packets.

// Host buttons and local buttons are stored separately, so there is no chance of a conflict between
// a host control system and a local system (although the buttons could overlap on screen).

// Programmers of local InSim programs may wish to consider using a configurable button range and
// possibly screen position, in case their users will use more than one local InSim program at once.

[COLOR=Blue]// TypeIn byte : if set, the user can click this button to type in text.

// Lowest 7 bits are the maximum number of characters to type in (0 to 95)
// Highest bit (128) can be set to initialise dialog with the button's text

// On clicking the button, a text entry dialog will be opened, allowing the specified number of
// characters to be typed in. The caption on the text entry dialog is optionally customisable using
// Text in the IS_BTN packet. If the first character of IS_BTN's Text field is zero, LFS will read
// the caption up to the second zero. The visible button text then follows that second zero.

// Text : 0-65-66-0 would display button text "AB" and no caption

// Text : 0-65-66-67-0-68-69-70-71-0-0-0 would display button text "DEFG" and caption "ABC"[/COLOR]

And...

// If the TypeIn byte is set in IS_BTN the user can type text into the button
// In that case no IS_BTC is sent - an IS_BTT is sent when the user presses ENTER

struct IS_BTT // BuTton Type - sent back when user types into a text entry button
{
byte Size; // 104
byte Type; // ISP_BTT
byte ReqI; // ReqI as received in the IS_BTN
byte UCID; // connection that typed into the button (zero if local)

byte ClickID; // button identifier originally sent in IS_BTN
byte Inst; // used internally by InSim
byte TypeIn; // from original button specification
byte Sp3;

char Text[96]; // typed text, zero to TypeIn specified in IS_BTN
};

#10 - SamH
We don't deliver any images in the CTRA X-System, FYI.
Quote from SamH :We don't deliver any images in the CTRA X-System, FYI.

Would be a nice feature, I believe I requested it somewhere *shrugs*. Or was meant to at least
It would be nice to be able to show images in-game. GIFs should be small enough for it to work.
#13 - sun
ya, good job i thought of that... let me know if oyu can load .GIF images -
Quote from dougie-lampkin :It would be nice to be able to show images in-game. GIFs should be small enough for it to work.

PNG is better. It's losslessly compressed, true color, and has 8bits of alpha as opposed to the one bit that you get with GIF. I created the same 1024x1024 test image in GIMP and the GIF is 239KB, and the PNG is 249KB. It still would be a pain to transfer, say, 1MB of images, and you would have to pre load images while connecting to the server.
Agree, stupid not to support PNG files! I like GIFs, but they had there place in the 90s (they where made in 87, but only really became popular in the 90s) when compuserve made them, let's leave them in the 90s please.
Yes, but I'm talking about little GIFs, say max 200x200 or 100KB, whichever would be smaller. Isn't GIF better at small images though? And if there was a limit to say no more than 5 a minute (which would still almost cripple a 56KB/S line :razz, it would work quite well I'd say. No idea how images could actually be loaded into an InSim packet without the language having some sort of special support for decoding images (do they already?), but that's another kettle of fish
You would need an image packet to be able to be sent. That would be a normal InSim packet that would then be able to handle Image data (a pure InSim solution that would not need any data on the server side.) The insim packet would provide the image data by it's self.
Ah, I see. So it would be kind of like opening an image in notepad and sending the contents of that, in a normal text packet?
Quote from dougie-lampkin :Ah, I see. So it would be kind of like opening an image in notepad and sending the contents of that, in a normal text packet?

Data is data, where is it makes any sense depends on how you read it. Try changing any txt file on your computer to an gif extension, an image could not be displayed from that as it's not in the right format (and if it is, then that is a freak coincidence.)

The real problem with IMG packets is that they would be inherently different sizes based on the image you send. And they should really be cached client side as well as server side so they don't have to be sent across the wire each time you want to update it's placement or area. So I would recommend that if they do impalement it, that they make the IMG packet it's self just a way of transporting the file, then InSim can send an acknowledgment back with the image resource ID for that image, then you use that resource id to place that image where you would like (in a button, stand alone, ect.)

It would be awesome if we could change the buttons background to an image, and then place text on top of that ...
Or it would be defined by an image hosted on a website server.

And you have to input the URL into the insim packet. *shrugs*
Quote from Krammeh :Or it would be defined by an image hosted on a website server.

And you have to input the URL into the insim packet. *shrugs*

Like the sv_downloadurl in Counter-Strike? Yeah, that' always an awesome option, take some of the load of the server. Only problem, what if that connection goes down (Web server crashes, ect)?
Quote from Dygear :Like the sv_downloadurl in Counter-Strike? Yeah, that' always an awesome option, take some of the load of the server. Only problem, what if that connection goes down (Web server crashes, ect)?

There could be alternate text in case the image doesn't load for some reason.
or a horrid red X like IE :P
Or the lovely Safari question mark
Attached images
missingImage.png
Quote from SamH :We don't deliver any images in the CTRA X-System, FYI.

what provides the x-system logo in the bottom left corner?
1

Load an image inside a button
(27 posts, started )
FGED GREDG RDFGDR GSFDG