public override bool HandlesMouseDown(int mouseX, int mouseY, MouseButton button) { if (!HandlesAllInput || game.HideGui) { return(false); } if (!normalChat.Contains(mouseX, mouseY)) { if (altText.Active && altText.Contains(mouseX, mouseY)) { altText.HandlesMouseDown(mouseX, mouseY, button); UpdateAltTextY(); return(true); } input.HandlesMouseDown(mouseX, mouseY, button); return(true); } int height = normalChat.GetUsedHeight(); int y = normalChat.Y + normalChat.Height - height; if (GuiElement.Contains(normalChat.X, y, normalChat.Width, height, mouseX, mouseY)) { return(HandlesChatClick(mouseX, mouseY)); } return(false); }
public string GetSelected(int mouseX, int mouseY) { for (int i = 0; i < Textures.Length; i++) { Texture tex = Textures[i]; if (tex.IsValid && GuiElement.Contains(tex.X, tex.Y, tex.Width, tex.Height, mouseX, mouseY)) { return(GetUrl(i, mouseX) ?? lines[i]); } } return(null); }
int HighlightedName(int mouseX, int mouseY) { for (int i = 0; i < namesCount; i++) { if (!textures[i].IsValid || IDs[i] == groupNameID) { continue; } Texture t = textures[i]; if (GuiElement.Contains(t.X, t.Y, t.Width, t.Height, mouseX, mouseY)) { return(i); } } return(-1); }
protected unsafe void SetCaretToCursor(int mouseX, int mouseY) { mouseX -= inputTex.X1; mouseY -= inputTex.Y1; DrawTextArgs args = new DrawTextArgs(null, font, true); IDrawer2D drawer = game.Drawer2D; int offset = 0, elemHeight = caretTex.Height; string oneChar = new String('A', 1); for (int y = 0; y < lines.Length; y++) { string line = lines[y]; int xOffset = y == 0 ? prefixWidth : 0; if (line == null) { continue; } for (int x = 0; x < line.Length; x++) { args.Text = line.Substring(0, x); int trimmedWidth = drawer.MeasureSize(ref args).Width + xOffset; // avoid allocating an unnecessary string fixed(char *ptr = oneChar) ptr[0] = line[x]; args.Text = oneChar; int elemWidth = drawer.MeasureSize(ref args).Width; if (GuiElement.Contains(trimmedWidth, y * elemHeight, elemWidth, elemHeight, mouseX, mouseY)) { caret = offset + x; UpdateCaret(); return; } } offset += line.Length; } caret = -1; UpdateCaret(); }
protected void SetCaretToCursor(int mouseX, int mouseY) { mouseX -= inputTex.X1; mouseY -= inputTex.Y1; DrawTextArgs args = new DrawTextArgs(null, font, true); IDrawer2D drawer = game.Drawer2D; int offset = 0, charHeight = caretTex.Height; for (int y = 0; y < lines.Length; y++) { string line = lines[y]; if (line == null) { continue; } for (int x = 0; x < line.Length; x++) { args.Text = line.Substring(0, x); int charOffset = drawer.MeasureText(ref args).Width; if (y == 0) { charOffset += prefixWidth; } args.Text = new string(line[x], 1); int charWidth = drawer.MeasureText(ref args).Width; if (GuiElement.Contains(charOffset, y * charHeight, charWidth, charHeight, mouseX, mouseY)) { caret = offset + x; UpdateCaret(); return; } } offset += line.Length; } caret = -1; UpdateCaret(); }