Lokai

Moderator
Lokai submitted a new resource:

GumpStringTooltip.cs - Add complex custom strings to Gump Tooltip to save on Gump space

This is not exactly Core, and not exactly Custom. You can add it anywhere, and you could certainly place it in the core with other Gump Entries if you want, but really anywhere is fine.

The reason for this script is that GumpTooltip only accepts an int input, so it can only display the Cliloc text with no parameters. This allows you to add custom text including dynamically generated text. Example in the image attached. Hover over the button, and it can display context appropriate text...

Read more about this resource...
 
By the way, in case you were wondering, you add it a bit differently than some other Gump Entries. Example:

Add(new GumpStringTooltip(text: string.Format("Return to {0}", city.Name)));
 
There is a problem. It seems that the text mode only supports English. If Chinese is used, it will be displayed as '??'
Add(new GumpStringTooltip(0, "测试"));
1775422050010.png
The reason for the issue seems to be that the AppendLayout method only provides support for ASCII
Cause of the Issue

  • Encoding issue: ServUO's Gump system transmits strings using ASCII encoding.
  • Chinese characters cannot be displayed: Chinese characters are not within the ASCII range, so they are either converted to ?? or displayed as numeric indexes.
  • Core limitation: Both PacketWriter.WriteAsciiFixed and IGumpWriter.AppendLayout(string) only support ASCII.
Solution Approach

  1. Modify PacketWriter.cs
    • Add a new WriteUTF8Fixed(string value, int size) method to support UTF8 encoding.
  2. Modify Packets.cs
    • Add AppendLayoutUTF8(string) and AppendLayoutUTF8(byte[]) methods to the IGumpWriter interface.
    • Implement these two methods in the DisplayGumpPacked and DisplayGumpFast classes.
    • Use the new UTF8 methods to write tooltip text.
  3. Modify GumpStringTooltip.cs
    • Replace AppendLayout with AppendLayoutUTF8 when passing Chinese strings.
    • 1775424310403.png
1775424864161.gif
 
Last edited:

Donations

Total amount
$50.00
Goal
$500.00

Shards

Back