/// <summary> /// Add a text entry field to the gump /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="width"> width of the area</param> /// <param name="height"> height of the area</param> /// <param name="hue"> to color the text</param> /// <param name="entryID"> id to be returned with text to identify the input field</param> /// <param name="initialText"> initial text string to be displayed</param> public static void AddTextEntry(ref GumpData gd, int x, int y, int width, int height, int hue, int entryID, string initialText) { gd.gumpStrings.Add(initialText); string textEntry = String.Format("{{ textentry {0} {1} {2} {3} {4} {5} {6} }}", x, y, width, height, hue, entryID, gd.gumpStrings.Count - 1); gd.gumpDefinition += textEntry; }
/// <summary> /// Sends a gump using an existing GumpData structure /// </summary> /// public static void SendGump(GumpData gd, uint x, uint y) { m_gumpData[gd.gumpId] = gd; GenericGump gg = new GenericGump(gd.gumpId, gd.serial, gd.x, gd.y, gd.gumpDefinition, gd.gumpStrings); Assistant.Client.Instance.SendToClientWait(gg); }
/// <summary> /// Add colored text to gump /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="hue"> to color the text</param> /// <param name="text"> text string to be displayed</param> public static void AddLabel(ref GumpData gd, int x, int y, int hue, string text) { gd.gumpStrings.Add(text); string textEntry = String.Format("{{ text {0} {1} {2} {3} }}", x, y, hue, gd.gumpStrings.Count - 1); gd.gumpDefinition += textEntry; }
/// <summary> /// Waits for a specific Gump to appear, for a maximum amount of time. If gumpid is 0 it will match any Gump. /// </summary> /// <param name="gumpid">ID of the gump. (0: any)</param> /// <param name="delay">Maximum wait, in milliseconds.</param> /// <returns>True: wait found the gump - False: otherwise.</returns> public static bool WaitForGump(uint gumpid, int delay) // Delay in MS { int subdelay = delay; bool found = false; if (gumpid == 0) { while (subdelay > 0) { if (World.Player.HasGump == true) { found = true; break; } else { Thread.Sleep(2); subdelay -= 2; } } } else { if (Gumps.m_gumpData.ContainsKey(gumpid)) { GumpData gd = Gumps.m_gumpData[gumpid]; while (subdelay > 0) { if (gd.hasResponse == true) { found = true; break; } else { Thread.Sleep(2); subdelay -= 2; } } } else { while (subdelay > 0) { if (World.Player.HasGump == true && World.Player.CurrentGumpI == gumpid) { found = true; break; } else { Thread.Sleep(2); subdelay -= 2; } } } } return(found); }
public static GumpData GetGumpData(uint gumpid) { GumpData gd = null; if (Gumps.m_gumpData.ContainsKey(gumpid)) { gd = Gumps.m_gumpData[gumpid]; } return(gd); }
/// <summary> /// Add colored text to gump /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="hue"> to color the text</param> /// <param name="textID"> index into string passed to the gump</param> public static void AddLabel(ref GumpData gd, int x, int y, int hue, int textID) { string textEntry = String.Format("{{ text {0} {1} {2} {3} }}", x, y, hue, textID); if (gd.gumpStrings.Count > textID) { gd.gumpDefinition += textEntry; } else { // I think this is not a good thing } }
/// <summary> /// Add colored text to gump, will be truncated if area is too small /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="width"> width of the area</param> /// <param name="height"> height of the area</param> /// <param name="hue"> to color the text</param> /// <param name="textID"> index into string list passed to gump</param> public static void AddLabelCropped(ref GumpData gd, int x, int y, int width, int height, int hue, int textID) { string textEntry = String.Format("{{ croppedtext {0} {1} {2} {3} {4} {5} }}", x, y, width, height, hue, textID); if (gd.gumpStrings.Count > textID) { gd.gumpDefinition += textEntry; } else { // I think this is not a good thing } }
/// <summary> /// Add a textured background for the gump. Its a transparent background /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="width"> width of the html block</param> /// <param name="height"> height of the html block</param> /// <param name="textID"> An index (zero based) into the string being passed</param> /// <param name="background"> False makes background transparent</param> /// <param name="scrollbar"> True adds a scroll bar to the control</param> public static void AddHtml(ref GumpData gd, int x, int y, int width, int height, int textID, bool background, bool scrollbar) { string textEntry = String.Format("{{ htmlgump {0} {1} {2} {3} {4} {5} {6} }}", x, y, width, height, textID, background ? 1 : 0, scrollbar ? 1 : 0); if (gd.gumpStrings.Count > textID) { gd.gumpDefinition += textEntry; } else { // I think this is not a good thing } }
/// <summary> /// Add a text entry field to the gump /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="width"> width of the area</param> /// <param name="height"> height of the area</param> /// <param name="hue"> to color the text</param> /// <param name="entryID"> id to be returned with text to identify the input field</param> /// <param name="initialTextID"> index into the list of strings passed to the gump</param> public static void AddTextEntry(ref GumpData gd, int x, int y, int width, int height, int hue, int entryID, int initialTextID) { string textEntry = String.Format("{{ textentry {0} {1} {2} {3} {4} {5} {6} }}", x, y, width, height, hue, entryID, initialTextID); if (gd.gumpStrings.Count > initialTextID) { gd.gumpDefinition += textEntry; } else { // I think this is not a good thing } }
/// <summary> /// Add button from the Gumps.mul replicated enough to fill an area (guessing) /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="normalID"> id of the button to used when unpressed</param> /// <param name="pressedID"> id of the button to show when button is pressed</param> /// <param name="buttonID"> button id to return if this is pressed</param> /// <param name="type"> button can have a type of 0 - Page or 1 - Reply (I have no idea what Page does)</param> /// <param name="param"> button can have a param of any integer (I have no idea what param does)</param> /// <param name="itemID"> maybe the button id to be used?</param> /// <param name="hue"> color to apply to image</param> /// <param name="width"> width of the area</param> /// <param name="height"> height of the area</param> public static void AddImageTiledButton(ref GumpData gd, int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param, int itemID, int hue, int width, int height) { string textEntry = String.Format("{{ buttontileart {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} }}", x, y, normalID, pressedID, (int)type, param, buttonID, itemID, hue, width, height); gd.gumpDefinition += textEntry; }
/// <summary> /// Hack some gump test stuff /// </summary> /// public static void SendGump(uint gumpid, uint serial, uint x, uint y, string gumpDefinition, List <string> gumpStrings) { GumpData gd = new GumpData { gumpId = gumpid, serial = serial, x = x, y = y, hasResponse = false, gumpDefinition = gumpDefinition, gumpStrings = new List <string>() }; gd.gumpStrings.AddRange(gumpStrings); // m_gumpData[gumpid] = gd; GenericGump gg = new GenericGump(gd.gumpId, gd.serial, gd.x, gd.y, gd.gumpDefinition, gd.gumpStrings); Assistant.Client.Instance.SendToClientWait(gg); }
/// <summary> /// Creates an initialized GumpData structure /// </summary> /// <param name="movable"> allow the gump to be moved</param> /// <param name="closable"> allow the gump to be right clicked to close</param> /// <param name="disposable"> allow the gump to be disposed (beats me what it does)</param> /// <param name="resizeable"> allow the gump to be resized</param> public static GumpData CreateGump(bool movable = true, bool closable = true, bool disposable = true, bool resizeable = true) { GumpData gd = new GumpData(); if (!movable) { gd.gumpDefinition += "{ nomove}"; } if (!closable) { gd.gumpDefinition += "{ noclose}"; } if (!disposable) { gd.gumpDefinition += "{ nodispose}"; } if (!resizeable) { gd.gumpDefinition += "{ noresize}"; } return(gd); }
protected override void Initialize() { Content.RootDirectory = "Content"; // Create all the services we need. UltimaServices.Register <SpriteBatch3D>(new SpriteBatch3D(this)); UltimaServices.Register <SpriteBatchUI>(new SpriteBatchUI(this)); Network = UltimaServices.Register <INetworkClient>(new NetworkClient()); Input = UltimaServices.Register <InputManager>(new InputManager(Window.Handle)); UserInterface = UltimaServices.Register <UserInterfaceService>(new UserInterfaceService()); // Make sure we have a UO installation before loading IO. if (!FileManager.IsUODataPresent) { return; } // Initialize and load data AnimData.Initialize(); Animations.Initialize(GraphicsDevice); ArtData.Initialize(GraphicsDevice); ASCIIText.Initialize(GraphicsDevice); TextUni.Initialize(GraphicsDevice); GumpData.Initialize(GraphicsDevice); HuesXNA.Initialize(GraphicsDevice); TexmapData.Initialize(GraphicsDevice); StringData.LoadStringList("enu"); SkillsData.Initialize(); GraphicsDevice.Textures[1] = HuesXNA.HueTexture0; GraphicsDevice.Textures[2] = HuesXNA.HueTexture1; EngineVars.EngineRunning = true; EngineVars.InWorld = false; ActiveModel = new LoginModel(); }
// pass bool = false to get the width of the line to be drawn without actually drawing anything. Useful for aligning text. unsafe void writeTexture_Line(List <AAtom> atoms, uint *rPtr, ref int x, int y, int linewidth, int maxHeight, ref int lineheight, bool draw) { for (int i = 0; i < atoms.Count; i++) { AFont font = TextUni.GetFont((int)atoms[i].Font); if (lineheight < font.Height) { lineheight = font.Height; } if (draw) { if (atoms[i] is CharacterAtom) { CharacterAtom atom = (CharacterAtom)atoms[i]; ACharacter character = font.GetCharacter(atom.Character); // HREF links should be colored white, because we will hue them at runtime. uint color = atom.IsHREF ? 0xFFFFFFFF : Utility.UintFromColor(atom.Color); character.WriteToBuffer(rPtr, x, y, linewidth, maxHeight, font.Baseline, atom.Style_IsBold, atom.Style_IsItalic, atom.Style_IsUnderlined, atom.Style_IsOutlined, color, 0xFF000008); } else if (atoms[i] is ImageAtom) { ImageAtom atom = (ImageAtom)atoms[i]; if (lineheight < atom.Height) { lineheight = atom.Height; } Images.AddImage(new Rectangle(x, y + (lineheight - atom.Height) / 2, atom.Width, atom.Height), atom.Texture, GumpData.GetGumpXNA(atom.ValueOver), GumpData.GetGumpXNA(atom.ValueDown)); atom.AssociatedImage = Images[Images.Count - 1]; } } x += atoms[i].Width; } }
/// <summary> /// Add a textured background for the gump. Its a transparent background /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="width"> width of the transparent backround</param> /// <param name="height"> height of the transparent backround</param> /// <param name="gumpID"> The gumpID from gumps.mul that will be used for background</param> public static void AddBackground(ref GumpData gd, int x, int y, int width, int height, int gumpID) { string textEntry = String.Format("{{ resizepic {0} {1} {2} {3} {4} }}", x, y, gumpID, width, height); gd.gumpDefinition += textEntry; }
/// <summary> /// Add a button to the gump /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="normalID"> id of the button to used when unpressed</param> /// <param name="pressedID"> id of the button to show when button is pressed</param> /// <param name="buttonID"> button id to return if this is pressed</param> /// <param name="type"> button can have a type of 0 - Page or 1 - Reply (I have no idea what Page does)</param> /// <param name="param"> button can have a param of any integer (I have no idea what param does)</param> public static void AddButton(ref GumpData gd, int x, int y, int normalID, int pressedID, int buttonID, int type, int param) { string textEntry = String.Format("{{ button {0} {1} {2} {3} {4} {5} {6} }}", x, y, normalID, pressedID, (int)type, param, buttonID); gd.gumpDefinition += textEntry; }
/// <summary> /// Add group to the gump /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="group"> group identifier (I have no idea what this control does)</param> public static void AddGroup(ref GumpData gd, int group) { string textEntry = String.Format("{{ group {0} }}", group); gd.gumpDefinition += textEntry; }
/// <summary> /// Add tooltip to the previously added control /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="number"> cliloc for tooltip</param> public static void AddTooltip(ref GumpData gd, int number) { string textEntry = string.Format("{{ tooltip {0} }}", number); gd.gumpDefinition += textEntry; }
/// <summary> /// Add tooltip to the previously added control /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="text"> string for tooltip</param> public static void AddTooltip(ref GumpData gd, string text) { string textEntry = string.Format("{{ tooltip {0} @{1}@ }}", 1114778, text); gd.gumpDefinition += textEntry; }
/// <summary> /// Add a textured background for the gump. Its a transparent background /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="width"> width of the html block</param> /// <param name="height"> height of the html block</param> /// <param name="text"> The html text to be shown</param> /// <param name="background"> False makes background transparent</param> /// <param name="scrollbar"> True adds a scroll bar to the control</param> public static void AddHtml(ref GumpData gd, int x, int y, int width, int height, string text, bool background, bool scrollbar) { gd.gumpStrings.Add(text); AddHtml(ref gd, x, y, width, height, gd.gumpStrings.Count - 1, background, scrollbar); }
/// <summary> /// Add a radio button to the gump /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="inactiveID"> id of the checkmark to used when unclicked</param> /// <param name="activeID"> id of the checkmark to use when clicked</param> /// <param name="initialState"> active or inactive initially</param> /// <param name="switchID"> switch id to return if this is changed</param> public static void AddRadio(ref GumpData gd, int x, int y, int inactiveID, int activeID, bool initialState, int switchID) { string textEntry = String.Format("{{ radio {0} {1} {2} {3} {4} {5} }}", x, y, inactiveID, activeID, initialState ? 1 : 0, switchID); gd.gumpDefinition += textEntry; }
/// <summary> /// No idea at all why this is different than the OTHER htmml, but SERVEUO had it /// </summary> public static void AddHtmlLocalized(ref GumpData gd, int x, int y, int width, int height, int number, string args, int color, bool background, bool scrollbar) { string textEntry = String.Format("{{ xmfhtmltok {0} {1} {2} {3} {4} {5} {6} {7} @{8}@ }}", x, y, width, height, background ? 1 : 0, scrollbar ? 1 : 0, color, number, args); gd.gumpDefinition += textEntry; }
/// <summary> /// Add colored text to gump, will be truncated if area is too small /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="width"> width of the area</param> /// <param name="height"> height of the area</param> /// <param name="hue"> to color the text</param> /// <param name="text"> text string to be displayed</param> public static void AddLabelCropped(ref GumpData gd, int x, int y, int width, int height, int hue, string text) { gd.gumpStrings.Add(text); AddLabelCropped(ref gd, x, y, width, height, hue, gd.gumpStrings.Count - 1); }
/// <summary> /// beats me, maybe a resizable image? /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="gumpID"> id used to reference gumps.mul</param> /// <param name="width"> width of the html block</param> /// <param name="height"> height of the html block</param> /// <param name="sx"> maybe stretch X?</param> /// <param name="sy"> maybe stretch Y?</param> public static void AddSpriteImage(ref GumpData gd, int x, int y, int gumpID, int width, int height, int sx, int sy) { string textEntry = String.Format("{{ picinpic {0} {1} {2} {3} {4} {5} {6} }}", x, y, gumpID, width, height, sx, sy); gd.gumpDefinition += textEntry; }
/// <summary> /// Add hued image from the Gumps.mul /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="gumpID"> id used to reference gumps.mul</param> /// <param name="hue"> to re-color the image</param> public static void AddImage(ref GumpData gd, int x, int y, int gumpID, int hue) { string textEntry = String.Format("{{ gumppic {0} {1} {2} hue={3} }}", x, y, gumpID, hue); gd.gumpDefinition += textEntry; }
/// <summary> /// Add an alpha region for the gump. Its a transparent background /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="width"> width of the transparent backround</param> /// <param name="height"> height of the transparent backround</param> public static void AddAlphaRegion(ref GumpData gd, int x, int y, int width, int height) { string textEntry = String.Format("{{ checkertrans {0} {1} {2} {3} }}", x, y, width, height); gd.gumpDefinition += textEntry; }
/// <summary> /// Add image from the Gumps.mul replicated enough to fill an area /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="width"> width of the area</param> /// <param name="height"> height of the area</param> /// <param name="gumpID">id of gump to be added</param> public static void AddImageTiled(ref GumpData gd, int x, int y, int width, int height, int gumpID) { string textEntry = String.Format("{{ gumppictiled {0} {1} {2} {3} {4} }}", x, y, width, height, gumpID); gd.gumpDefinition += textEntry; }
/// <summary> /// Add a re-colored item from the statics.mul /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="x"> x co-ordinate of the origin</param> /// <param name="y"> y co-ordinate of the origin</param> /// <param name="itemID"> id used to reference statics.mul</param> /// <param name="hue"> to re-color the image</param> public static void AddItem(ref GumpData gd, int x, int y, int itemID, int hue) { string textEntry = String.Format("{{ tilepichue {0} {1} {2} {3} }}", x, y, itemID, hue); gd.gumpDefinition += textEntry; }
/// <summary> /// Add a page for the gump to have additional pages /// </summary> /// <param name="gd"> GumpData structure</param> /// <param name="page"> the number of the page being added</param> public static void AddPage(ref GumpData gd, int page) { string textEntry = String.Format("{{ page {0} }}", page); gd.gumpDefinition += textEntry; }