RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Function AddHtml

pyro17

Sorceror
The function AddHtml just has no overloads for color unlike AddHtmlLocalized.

Yes I know there is AddLabel where I can set the color but there the text will have a border in black. It can't be turned off via an overload or changed according to the text color.
 

Vorspire

Knight
AddLabel supports a hue for the font - correct, but did you know that it will only use the first and last blocks of the hue when applying to a font in UO?

A hue consists of 32 'blocks' of separate colors in the RGB555 format.
When a gump displays a label, it takes the first block of color as the stroke (outline) and the last block of color as the fill, so if you use a hue that starts with a black block and ends with a red block, you'll get a red font with a black outline.

***

When you use AddHtml, wrap your HTML string with this HTML tag;

HTML:
<basefont color=#FF0000>Hello World

Don't use a </basefont> tag though, because it will make the rest of the text hidden (client issue)

Coloring a specific portion of text can be achieved by uing the <basefont> tag multiple times, each succesvive color will replace the last;

HTML:
<basefont color=#FF0000>Hello <basefont color=#00FF00>World

Note that we're using the #RRGGBB format in these examples, you can also define named colors, though the selection is limited;

HTML:
<basefont color=red>Hello <basefont color=green>World

This is why AddHtml doesn't support a color/hue argument - and you can't use UO hues in HTML.

On a side note, this is also the way in which you can format the properties in the mouse-hover list on items and mobiles.
 

pyro17

Sorceror
Wow thats a really nice information regarding that! No I didn't know that it splits the color value to get stroke and fill color. Thats a really good point.

About the basefont one .. I am kinda embarrassed as I didn't think about that.
So thank you a lot Vorspire.
 

Vorspire

Knight
There's another neat trick you can do, if you don't want to figure out the HTML HEX #RRGGBB values, you can ue System.Drawing.Color to get a pre-defined color;

C#:
string text = String.Format( "<basefont color=#{0:X6}>Hello World", System.Drawing.Color.Red.ToArgb() );

Using {0:X6} as the place-holder for where the color value will go, where 'X6' means it will convert the given value to a 6-digit Hexidecimal value.

System.Drawing.Color.Red is the color you want, and to provide the correct value for String.Format to replace {0:X6} you call ToArgb()

The above example will output:

HTML:
<basefont color=#FF0000>Hello World

And yet another awesome trick... TRANSPARENT text with BLACK outline;

HTML:
<basefont color=#00000000>Hello World

Though I've only tested this in the item/mobile hover-lists, it does work - note the extra two 0's in #00000000
This value is interpreted by the client as AARRGGBB.
I've not dabbled much with AARRGGBB, sticking with standard 6-digit hex, maybe you can further the research :p

If you want to explore what other HTML tags are available when using Gump AddHtml entries, check this out;
http://core.vita-nex.com/svn/Text/BBCodeUtility.cs
 

pyro17

Sorceror
Well I guess it just looked like that to you there ;). Basefont just uses rgb values as playing with the a has no effect at all.

Even if you just use #000000 you get transparent text with outline ;). My guess is that it takes the length of the color and cuts it to 6 digits.
And it gets trasparent if it hits the transparency color that Ultima uses even for items. This is just my guess on that though.

But what is possible with an running script is making an sign or whatever kind of item and let the name be displayed like disco lights ;).
 

Vorspire

Knight
Which client version are you using?
There's a lot of things that can be done with coloring HTML :)
 

Attachments

  • QuiverPreview.png
    21 KB · Views: 26
  • ImbueCraftItem.jpg
    233.1 KB · Views: 26

pyro17

Sorceror
6.0.14.3
But I don't think they added more functuality to the colors to support 8-digit colors for alpha/stroke.

And yes your pictures look good :).
 
Top