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!

Streaming HTML to GUMP, not displaying all text

thedamit

Sorceror
Hey everyone!

I've been pulling my hair out on this one, and I figured I'd reach out and see if someone had an idea of what I might be doing wrong, or why this isn't working.

I've created a Shard Welcome Gump that displays when player's log in. I am loading in an HTML file before I display it. Currently, only part of the full text from the HTML file is being displayed on the GUMP. Like 752 characters out of 1231 total. I don't see a size limit for HTML on a GUMP. I've been trying to make sure all of the text from the HTML is loaded before displaying the GUMP.

I appreciate any insight someone might have. Here is a screenshot of the missing text (the lines exist, but no text), and my LoginStats.cs that I modified to load the information before displaying the GUMP.

welcomegump.png

LoginStats.cs
C#:
using System;
using Server.Network;
using Server.Gumps;
using System.IO;
using System.Text;

namespace Server.Misc
{
    public class LoginStats
    {
        static string path = @"C:\Users\MyName\Documents\UO - R\RunUO-2.6\Scripts\ShardWelcomeGump\shardupdates.html";
        static string loadText = "";

        public static string ReadText()
        {
            using (StreamReader reader = new StreamReader(path))
            {
                string line = "";

                StringBuilder stringBuilder = new StringBuilder();

                while ((line = reader.ReadLine()) != null)
                {
                    stringBuilder.Append(line);
                }

                return stringBuilder.ToString();

                reader.Close();
            }
        }

        public static void Initialize()
        {
            // Register our event handler
            EventSink.Login += new LoginEventHandler( EventSink_Login );
            loadText = ReadText();
        }

        private static void EventSink_Login( LoginEventArgs args )
        {
            int userCount = NetState.Instances.Count;
            int itemCount = World.Items.Count;
            int mobileCount = World.Mobiles.Count;

            Mobile m = args.Mobile;

            m.SendMessage( "Welcome, {0}! There {1} currently {2} user{3} online, with {4} item{5} and {6} mobile{7} in the world.",
                args.Mobile.Name,
                userCount == 1 ? "is" : "are",
                userCount, userCount == 1 ? "" : "s",
                itemCount, itemCount == 1 ? "" : "s",
                mobileCount, mobileCount == 1 ? "" : "s" );

            m.SendGump(new ShardWelcomeGump(loadText));
        }
    }
}

Thanks again for anyone who can help!
 

+Colibri

Wanderer
First, make sure you are only using basic HTML markup elements... <b> <i> <p> <basefont>, nothing fancy.

Otherwise, the text length of a gump HTML is limited to about 16k characters - you're not yet at this limit. But keep in mind that's 16k for the HTML source code, not the characters that get displayed. I'd recommend tinkering with the contents of the .html file, first just put generic unformatted text, then start formatting it piece by piece, until you get to what you currently have in the .html now. Somewhere along the way, you will find what breaks it.

You can use the built-in ReadText method:
public static void Initialize()
{
// Register our event handler
EventSink.Login += new LoginEventHandler( EventSink_Login );
loadText = File.ReadAllText( @"Scripts\ShardWelcomeGump\shardupdates.html" );
}
For further examination, also include the ShardWelcomeGump class, maybe there's something specific there that breaks it.
 

thedamit

Sorceror
First, make sure you are only using basic HTML markup elements... <b> <i> <p> <basefont>, nothing fancy.

Otherwise, the text length of a gump HTML is limited to about 16k characters - you're not yet at this limit. But keep in mind that's 16k for the HTML source code, not the characters that get displayed. I'd recommend tinkering with the contents of the .html file, first just put generic unformatted text, then start formatting it piece by piece, until you get to what you currently have in the .html now. Somewhere along the way, you will find what breaks it.

You can use the built-in ReadText method:

For further examination, also include the ShardWelcomeGump class, maybe there's something specific there that breaks it.

I really appreciate your reply.

I have a feeling it was something in the HTML file itself that was causing the issue. I logged in recently and noticed the entire text was displaying... and was confused as to why.

I definitely updated that file within the last few days.

Thanks again!
 
Top