public override void UnloadContent() { SDL.SDL_GetWindowBordersSize(Window.Handle, out int top, out int left, out int bottom, out int right); Settings.GlobalSettings.WindowPosition = new Point(Math.Max(0, Window.ClientBounds.X - left), Math.Max(0, Window.ClientBounds.Y - top)); Settings.GlobalSettings.Save(); Plugin.OnClosing(); ArtLoader.Instance.Dispose(); GumpsLoader.Instance.Dispose(); TexmapsLoader.Instance.Dispose(); AnimationsLoader.Instance.Dispose(); LightsLoader.Instance.Dispose(); TileDataLoader.Instance.Dispose(); AnimDataLoader.Instance.Dispose(); ClilocLoader.Instance.Dispose(); FontsLoader.Instance.Dispose(); HuesLoader.Instance.Dispose(); MapLoader.Instance.Dispose(); MultiLoader.Instance.Dispose(); MultiMapLoader.Instance.Dispose(); ProfessionLoader.Instance.Dispose(); SkillsLoader.Instance.Dispose(); SoundsLoader.Instance.Dispose(); SpeechesLoader.Instance.Dispose(); Verdata.File?.Dispose(); World.Map?.Destroy(); //NOTE: My dispose related changes, see if they're still necessary _hues_sampler[0]?.Dispose(); _hues_sampler[0] = null; _hues_sampler[1]?.Dispose(); _hues_sampler[1] = null; _scene?.Dispose(); AuraManager.Dispose(); UIManager.Dispose(); Texture2DCache.Dispose(); RenderedText.Dispose(); //NOTE: We force the sockets to disconnect in case they haven't already been disposed //This is good practice since the Client can be quit while the socket is still active if (NetClient.LoginSocket.IsDisposed == false) { NetClient.LoginSocket.Disconnect(); } if (NetClient.Socket.IsDisposed == false) { NetClient.Socket.Disconnect(); } base.UnloadContent(); }
public Button(int buttonID, ushort normal, ushort pressed, ushort over = 0, string caption = "", byte font = 0, bool isunicode = true, ushort normalHue = ushort.MaxValue, ushort hoverHue = ushort.MaxValue) { ButtonID = buttonID; _gumpGraphics[NORMAL] = normal; _gumpGraphics[PRESSED] = pressed; _gumpGraphics[OVER] = over; _textures[NORMAL] = FileManager.Gumps.GetTexture(normal); _textures[PRESSED] = FileManager.Gumps.GetTexture(pressed); if (over > 0) { _textures[OVER] = FileManager.Gumps.GetTexture(over); } SpriteTexture t = _textures[NORMAL]; if (t == null) { Dispose(); return; } Width = t.Width; Height = t.Height; FontHue = normalHue == ushort.MaxValue ? (ushort)0 : normalHue; HueHover = hoverHue == ushort.MaxValue ? normalHue : hoverHue; if (!string.IsNullOrEmpty(caption) && normalHue != ushort.MaxValue) { _caption = caption; _fontTexture[0] = new RenderedText { IsUnicode = isunicode, Hue = FontHue, Font = font, Text = caption }; if (hoverHue != ushort.MaxValue) { _fontTexture[1] = new RenderedText { IsUnicode = isunicode, Hue = HueHover, Font = font, Text = caption }; } } CanMove = false; AcceptMouseInput = true; CanCloseWithRightClick = false; CanCloseWithEsc = false; }
public HSliderBar(int x, int y, int w, int min, int max, int value, HSliderBarStyle style, bool hasText = false, byte font = 0, ushort color = 0, bool unicode = true, bool drawUp = false) { X = x; Y = y; if (hasText) { _text = RenderedText.Create(string.Empty, color, font, unicode); _drawUp = drawUp; } MinValue = min; MaxValue = max; BarWidth = w; _style = style; AcceptMouseInput = true; if (_gumpWidget == null) { switch (_style) { case HSliderBarStyle.MetalWidgetRecessedBar: _gumpSpliderBackground = new UOTexture32[3] { GumpsLoader.Instance.GetTexture(213), GumpsLoader.Instance.GetTexture(214), GumpsLoader.Instance.GetTexture(215) }; _gumpWidget = GumpsLoader.Instance.GetTexture(216); break; case HSliderBarStyle.BlueWidgetNoBar: _gumpWidget = GumpsLoader.Instance.GetTexture(0x845); break; } Width = BarWidth; if (_gumpWidget != null) { Height = _gumpWidget.Height; } //RecalculateSliderX(); CalculateOffset(); } Value = value; }
// ============================================================================================================ // Ctors and BuildGumpling Methods // ============================================================================================================ public TextEntryPage(AControl parent, int x, int y, int width, int height, int pageIndex) : base(parent) { base.HandlesMouseInput = true; base.HandlesKeyboardFocus = true; IsEditable = true; Position = new Vector2Int(x, y); Size = new Vector2Int(width, height); PageIndex = pageIndex; _caratBlinkOn = false; _renderedText = new RenderedText(string.Empty, Width, true); _renderedCarat = new RenderedText(string.Empty, 16, true); }
public CroppedText(string text, Hue hue, int maxWidth = 0) { _gameText = new RenderedText { IsUnicode = true, Font = (byte) (FileManager.ClientVersion >= ClientVersions.CV_305D ? 1 : 0), FontStyle = maxWidth > 0 ? FontStyle.BlackBorder | FontStyle.Cropped : FontStyle.BlackBorder, Hue = hue, MaxWidth = maxWidth, Text = text }; AcceptMouseInput = false; }
public KeyPressControl(AControl parent, int x, int y, int width, int height, int entryID, WinKeys key) : base(parent) { Position = new Point(x, y); Size = new Point(width, height); Key = key; m_RenderedText = new RenderedText(string.Empty, width); IsChanged = false; base.HandlesMouseInput = true; base.HandlesKeyboardFocus = true; LeadingHtmlTag = "<center><span color='#fff' style='font-family: uni2;'>"; }
public void DrawText(string text, float x, float y, int xalign, int yalign, long FontID) { float pos; float xPos; float yPos; float fWidth = FontWidth(FontID); float fHeight = FontHeight(FontID); RenderedText RText = new RenderedText(); //setup the alignment so they can be positioned correctly switch (xalign) { case alignRight: xPos = x + (text.Length * fWidth); break; case alignCenter: xPos = x + ((text.Length * fWidth) / 2.0f); break; case alignLeft: default: xPos = x; break; } switch (yalign) { case alignBottom: yPos = y - fHeight; break; case alignCenter: yPos = y - (fHeight / 2.0f); break; case alignTop: default: yPos = y; break; } RText.Entity = new GameObject(text); RText.Entity.AddComponent <MeshFilter>(); for (pos = 0; pos < text.Length; pos++) { //need to use Framework.MeshSystem.CreateQuad( offsetx, offsety, u1, v1, u2, v2 ) :) RText.Entity.GetComponent <MeshFilter>().mesh = Framework.MeshSystem.CreateQuad(xPos + (pos * 1.0f), yPos, -0.5f, -0.5f, 0.5f, 0.5f); } Text.Add(RText); }
public TextOverheadView(TextOverhead parent, int maxwidth = 0, ushort hue = 0xFFFF, byte font = 0, bool isunicode = false, FontStyle style = FontStyle.None) : base(parent) { RenderedText text = new RenderedText { MaxWidth = maxwidth, Hue = hue, Font = font, IsUnicode = isunicode, FontStyle = style, Text = parent.Text }; Texture = text.Texture; }
public void Add(int damage) { _messages.AddToFront(new TextOverhead { RenderedText = RenderedText.Create(damage.ToString(), (ushort)(Parent == World.Player ? 0x0034 : 0x0021), 3, false), Time = Time.Ticks + 1500 }); if (_messages.Count > 10) { _messages.RemoveFromBack()?.RenderedText?.Destroy(); } }
private void InternalBuild(string text, RenderedText internalText, int hue) { if (!string.IsNullOrEmpty(text)) { uint htmlColor = 0x010101FF; ushort color = 0xFFFF; internalText.MaxWidth -= 9; internalText.HTMLColor = htmlColor; internalText.Hue = color; internalText.HasBackgroundColor = true; internalText.Text = text; } }
public ButtonResizable(AControl parent, int x, int y, int width, int height, string caption, Action onClickLeft = null, Action onClickRight = null) : base(parent) { HandlesMouseInput = true; Position = new Point(x, y); Size = new Point(width, height); m_Caption = new RenderedText(string.Empty, width, true); Caption = caption; m_Gumps[0] = AddControl(new ResizePic(null, 0, 0, GumpUp, Width, Height), 1) as ResizePic; m_Gumps[1] = AddControl(new ResizePic(null, 0, 0, GumpDown, Width, Height), 2) as ResizePic; m_Gumps[2] = AddControl(new ResizePic(null, 0, 0, GumpOver, Width, Height), 3) as ResizePic; m_OnClickLeft = onClickLeft; m_OnClickRight = onClickRight; }
public TextOverhead(GameObject parent, string text = "", int maxwidth = 0, ushort hue = 0xFFFF, byte font = 0, bool isunicode = true, FontStyle style = FontStyle.None, float timeToLive = 0.0f) { Text = text; Parent = parent; MaxWidth = maxwidth; Hue = hue; Font = font; IsUnicode = isunicode; Style = style; TimeToLive = timeToLive; AlphaHue = 0xFF; _text = new RenderedText { MaxWidth = maxwidth, Hue = hue, Font = font, IsUnicode = isunicode, FontStyle = style, SaveHitMap = true, Text = Text }; Texture = _text.Texture; if (Engine.Profile.Current.ScaleSpeechDelay) { int delay = Engine.Profile.Current.SpeechDelay; if (delay < 10) { delay = 10; } if (TimeToLive <= 0.0f) { TimeToLive = 4000 * _text.LinesCount * delay / 100.0f; } } else { long delay = ((5497558140000 * Engine.Profile.Current.SpeechDelay) >> 32) >> 5; if (TimeToLive <= 0.0f) { TimeToLive = (delay >> 31) + delay; } } EdgeDetection = true; }
public CroppedText(string text, ushort hue, int maxWidth = 0) { _gameText = RenderedText.Create ( text, hue, (byte)(Client.Version >= ClientVersion.CV_305D ? 1 : 0), true, maxWidth > 0 ? FontStyle.BlackBorder | FontStyle.Cropped : FontStyle.BlackBorder, maxWidth: maxWidth ); AcceptMouseInput = false; }
public void Add(int damage) { TextObject text_obj = TextObject.Create(); text_obj.RenderedText = RenderedText.Create(damage.ToString(), (ushort)(Parent == World.Player ? 0x0034 : 0x0021), 3, false); text_obj.Time = Time.Ticks + 1500; _messages.AddToFront(text_obj); if (_messages.Count > 10) { _messages.RemoveFromBack()?.RenderedText?.Destroy(); } }
public Button ( int buttonID, ushort normal, ushort pressed, ushort over = 0, string caption = "", byte font = 0, bool isunicode = true, ushort normalHue = ushort.MaxValue, ushort hoverHue = ushort.MaxValue ) { ButtonID = buttonID; _normal = normal; _pressed = pressed; _over = over; if (GumpsLoader.Instance.GetGumpTexture(normal, out var bounds) == null) { Dispose(); return; } Width = bounds.Width; Height = bounds.Height; FontHue = normalHue == ushort.MaxValue ? (ushort)0 : normalHue; HueHover = hoverHue == ushort.MaxValue ? normalHue : hoverHue; if (!string.IsNullOrEmpty(caption) && normalHue != ushort.MaxValue) { _fontTexture = new RenderedText[2]; _caption = caption; _fontTexture[0] = RenderedText.Create(caption, FontHue, font, isunicode); if (hoverHue != ushort.MaxValue) { _fontTexture[1] = RenderedText.Create(caption, HueHover, font, isunicode); } } CanMove = false; AcceptMouseInput = true; //CanCloseWithRightClick = false; CanCloseWithEsc = false; }
public virtual void Destroy() { if (IsDestroyed) return; UnlinkD(); RealScreenPosition = Point.Zero; IsDestroyed = true; RenderedText?.Destroy(); RenderedText = null; Owner = null; _queue.ReturnOne(this); }
public ServerEntryGump(ServerListEntry entry) { _buttonId = entry.Index; _labelName = CreateRenderedText(entry.Name); _labelPing = CreateRenderedText("-"); _labelPacketLoss = CreateRenderedText("-"); _labelName.CreateTexture(); _labelPing.CreateTexture(); _labelPacketLoss.CreateTexture(); AcceptMouseInput = true; Width = 393; Height = new[] { _labelName.Height, _labelPing.Height, _labelPacketLoss.Height }.Max() + 10; X = 0; Y = 0; }
public TextOverheadView(TextOverhead parent, int maxwidth = 0, ushort hue = 0xFFFF, byte font = 0, bool isunicode = false, FontStyle style = FontStyle.None) : base(parent) { _text = new RenderedText { MaxWidth = maxwidth, Hue = hue, Font = font, IsUnicode = isunicode, FontStyle = style, SaveHitMap = true, Text = parent.Text }; Texture = _text.Texture; //Bounds.X = (Texture.Width >> 1) - 22; //Bounds.Y = Texture.Height; //Bounds.Width = Texture.Width; //Bounds.Height = Texture.Height; if (Engine.Profile.Current.ScaleSpeechDelay) { int delay = Engine.Profile.Current.SpeechDelay; if (delay < 10) { delay = 10; } if (parent.TimeToLive <= 0.0f) { parent.TimeToLive = 4000 * _text.LinesCount * delay / 100.0f; } } else { long delay = ((5497558140000 * Engine.Profile.Current.SpeechDelay) >> 32) >> 5; if (parent.TimeToLive <= 0.0f) { parent.TimeToLive = (delay >> 31) + delay; } } parent.Initialized = true; parent.Disposed += ParentOnDisposed; EdgeDetection = true; }
public virtual void Destroy() { if (IsDestroyed) { return; } UnlinkD(); IsDestroyed = true; RenderedText?.Destroy(); RenderedText = null; Owner = null; _queue.ReturnOne(this); }
public Label(string text, bool isunicode, ushort hue, int maxwidth = 0, byte font = 0xFF, FontStyle style = FontStyle.None, TEXT_ALIGN_TYPE align = TEXT_ALIGN_TYPE.TS_LEFT) { _gText = new RenderedText { IsUnicode = isunicode, Font = font, FontStyle = style, Hue = hue, Align = align, MaxWidth = maxwidth, Text = text }; AcceptMouseInput = false; Width = _gText.Width; Height = _gText.Height; }
public Button(int buttonID, ushort normal, ushort pressed, ushort over = 0, string caption = "", byte font = 0, bool isunicode = true, ushort normalHue = ushort.MaxValue, ushort hoverHue = ushort.MaxValue) { ButtonID = buttonID; _gumpGraphics[NORMAL] = normal; _gumpGraphics[PRESSED] = pressed; _gumpGraphics[OVER] = over; _textures[NORMAL] = GumpsLoader.Instance.GetTexture(normal); _textures[PRESSED] = GumpsLoader.Instance.GetTexture(pressed); if (over > 0) { _textures[OVER] = GumpsLoader.Instance.GetTexture(over); } UOTexture32 t = _textures[NORMAL]; if (t == null) { Dispose(); return; } Width = t.Width; Height = t.Height; FontHue = normalHue == ushort.MaxValue ? (ushort)0 : normalHue; HueHover = hoverHue == ushort.MaxValue ? normalHue : hoverHue; if (!string.IsNullOrEmpty(caption) && normalHue != ushort.MaxValue) { _fontTexture = new RenderedText[2]; _caption = caption; _fontTexture[0] = RenderedText.Create(caption, FontHue, font, isunicode); if (hoverHue != ushort.MaxValue) { _fontTexture[1] = RenderedText.Create(caption, HueHover, font, isunicode); } } CanMove = false; AcceptMouseInput = true; //CanCloseWithRightClick = false; CanCloseWithEsc = false; }
public NameOverheadGump(Entity entity) : base(entity.Serial, 0) { CanMove = false; AcceptMouseInput = true; CanCloseWithRightClick = true; Entity = entity; Hue hue = entity is Mobile m?Notoriety.GetHue(m.NotorietyFlag) : (Hue)0x0481; _renderedText = RenderedText.Create(String.Empty, hue, 0xFF, true, FontStyle.BlackBorder, TEXT_ALIGN_TYPE.TS_CENTER, 100, 30, true); Add(_background = new AlphaBlendControl(.3f) { WantUpdateSize = false, Hue = hue }); }
public StbTextBox ( byte font, int max_char_count = -1, int maxWidth = 0, bool isunicode = true, FontStyle style = FontStyle.None, ushort hue = 0, TEXT_ALIGN_TYPE align = 0 ) { AcceptKeyboardInput = true; AcceptMouseInput = true; CanMove = false; IsEditable = true; _maxCharCount = max_char_count; Stb = new TextEdit(this); Stb.SingleLine = true; if (maxWidth > 0) { style |= FontStyle.CropTexture; } _fontStyle = style; if ((style & (FontStyle.Fixed | FontStyle.Cropped)) != 0 && maxWidth <= 0) { Debug.Assert((style & (FontStyle.Fixed | FontStyle.Cropped)) != 0 && maxWidth <= 0); } // stb_textedit will handle part of these tag style &= ~(/*FontStyle.Fixed | */ FontStyle.Cropped | FontStyle.CropTexture); _rendererText = RenderedText.Create(string.Empty, hue, font, isunicode, style, align, maxWidth); _rendererCaret = RenderedText.Create ( "_", hue, font, isunicode, (style & FontStyle.BlackBorder) != 0 ? FontStyle.BlackBorder : FontStyle.None, align ); Height = _rendererCaret.Height; }
public Label ( string text, bool isunicode, ushort hue, int maxwidth = 0, byte font = 0xFF, FontStyle style = FontStyle.None, TEXT_ALIGN_TYPE align = TEXT_ALIGN_TYPE.TS_LEFT, bool ishtml = false ) { _gText = RenderedText.Create(text, hue, font, isunicode, style, align, maxwidth, isHTML: ishtml); AcceptMouseInput = false; Width = _gText.Width; Height = _gText.Height; }
public HSliderBar(int x, int y, int w, int min, int max, int value, HSliderBarStyle style, bool hasText = false, byte font = 0, ushort color = 0, bool unicode = true, bool drawUp = false) { X = x; Y = y; if (hasText) { _text = RenderedText.Create(string.Empty, color, font, unicode); _drawUp = drawUp; } MinValue = min; MaxValue = max; BarWidth = w; Value = value; _style = style; AcceptMouseInput = true; }
public HSliderBar ( int x, int y, int w, int min, int max, int value, HSliderBarStyle style, bool hasText = false, byte font = 0, ushort color = 0, bool unicode = true, bool drawUp = false ) { X = x; Y = y; if (hasText) { _text = RenderedText.Create(string.Empty, color, font, unicode); _drawUp = drawUp; } MinValue = min; MaxValue = max; BarWidth = w; _style = style; AcceptMouseInput = true; var texture = GumpsLoader.Instance.GetGumpTexture((uint)(_style == HSliderBarStyle.MetalWidgetRecessedBar ? 216 : 0x845), out var bounds); Width = BarWidth; if (texture != null) { Height = bounds.Height; } CalculateOffset(); Value = value; }
public void AddEntry(string text, int font, Hue hue, bool isUnicode, DateTime time) { bool maxScroll = _scrollBar.Value == _scrollBar.MaxValue; while (_entries.Count > 199) { _entries.RemoveFromFront().Destroy(); _hours.RemoveFromFront().Destroy(); } RenderedText h = RenderedText.Create($"{time:t} ", 1150, 1, true, FontStyle.BlackBorder); _hours.AddToBack(h); _entries.AddToBack(RenderedText.Create(text, hue, (byte)font, isUnicode, FontStyle.Indention | FontStyle.BlackBorder, maxWidth: Width - (18 + h.Width))); _scrollBar.MaxValue += _entries[_entries.Count - 1].Height; if (maxScroll) _scrollBar.Value = _scrollBar.MaxValue; }
public TextEntry(byte font, int maxcharlength = -1, int maxWidth = 0, int width = 0, bool unicode = true, FontStyle style = FontStyle.None, ushort hue = 0xFFFF) { RenderText = new RenderedText { IsUnicode = unicode, Font = font, MaxWidth = width, FontStyle = style, Hue = hue }; RenderCaret = new RenderedText { IsUnicode = unicode, Font = font, Hue = hue, Text = "_" }; MaxCharCount = maxcharlength; Width = width; MaxWidth = maxWidth; }
public PasswordStbTextBox ( byte font, int max_char_count = -1, int maxWidth = 0, bool isunicode = true, FontStyle style = FontStyle.None, ushort hue = 0, TEXT_ALIGN_TYPE align = TEXT_ALIGN_TYPE.TS_LEFT ) : base ( font, max_char_count, maxWidth, isunicode, style, hue, align ) { _rendererText = RenderedText.Create ( string.Empty, hue, font, isunicode, style, align, maxWidth ); _rendererCaret = RenderedText.Create ( "_", hue, font, isunicode, (style & FontStyle.BlackBorder) != 0 ? FontStyle.BlackBorder : FontStyle.None, align ); NoSelection = true; }
public PinControl(int x, int y) { X = x; Y = y; _text = RenderedText.Create(string.Empty, font: 0, isunicode: false); _pic = new GumpPic(0, 0, 0x139B, 0); Add(_pic); WantUpdateSize = false; Width = _pic.Width; Height = _pic.Height; AcceptMouseInput = true; CanMove = false; _pic.AcceptMouseInput = true; }
private Vector2 DrawPrompt(Vector2 pos) { RenderedText text = new RenderedText { Font = _options.Font, Text = _options.Prompt, Position = pos, Color = _options.PromptColor, Layer = DrawingLayer.Foreground2 }; Engine.SpriteRenderer.DrawString(text); //spriteBatch.DrawString(_options.Font, _options.Prompt, pos, _options.PromptColor); pos.X += _oneCharacterWidth * _options.Prompt.Length + _oneCharacterWidth; return pos; }
private void DrawCursor(Vector2 pos, GameTime gameTime) { if (!IsInBounds(pos.Y)) return; int max = Math.Min(_consoleInputProcessor.Buffer.CursorPosition, _consoleInputProcessor.Buffer.Value.Length); string subString = _consoleInputProcessor.Buffer.Value.Substring(0, max ); pos.X += _options.Font.MeasureString(subString).X; pos.Y -= _options.Font.LineSpacing; RenderedText text = new RenderedText(); text.Font = _options.Font; text.Text = (int)(gameTime.TotalGameTime.TotalSeconds / _options.CursorBlinkSpeed) % 2 == 0 ? _options.Cursor : ""; text.Position = pos; text.Color = _options.CursorColor; Engine.SpriteRenderer.DrawString(text); //spriteBatch.DrawString(_options.Font, // (int) (gameTime.TotalGameTime.TotalSeconds/_options.CursorBlinkSpeed)%2 == 0 // ? _options.Cursor // : "", pos, _options.CursorColor); }
private Vector2 DrawCommand(string command, Vector2 pos, Color color) { //Take into account the prompt character and the space left right after int maxCommandLength = _maxCharactersPerLine - _options.Prompt.Length - 1; var splitLines = command.Length > maxCommandLength ? SplitCommand(command, maxCommandLength) : new[] {command}; foreach (var line in splitLines) { if (IsInBounds(pos.Y)) { RenderedText text = new RenderedText { Font = _options.Font, Text = line, Position = pos, Color = color, Layer = DrawingLayer.Foreground2 }; Engine.SpriteRenderer.DrawString(text); //spriteBatch.DrawString(_options.Font, line, pos, color); } ValidateFirstCommandPosition(pos.Y + _options.Font.LineSpacing); pos.Y += _options.Font.LineSpacing; } return pos; }