public static float doVerticalScrollBar(int id, int xPos, int yPos, int drawWidth, int drawHeight, int contentHeight, float scroll) { if (drawHeight > contentHeight) { contentHeight = drawHeight; } var destinationRectangle = new Rectangle(xPos, yPos, drawWidth, drawHeight); if (destinationRectangle.Contains(GuiData.getMousePoint()) || GuiData.active == id) { GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, Color.Gray * 0.1f); } var num1 = scroll; float num2 = contentHeight - drawHeight; var num3 = drawHeight / (float)contentHeight * drawHeight; var num4 = scroll / num2 * (drawHeight - num3); var num5 = DraggableRectangle.doDraggableRectangle(id, xPos, yPos + num4, drawWidth, (int)num3, drawWidth, Color.White, Color.Gray, true, false, xPos, yPos + drawHeight - num3, xPos, yPos).Y; if (Math.Abs(num5) > 0.100000001490116) { num1 = (float)((num4 + (double)num5) / (drawHeight - (double)num3)) * num2; } return(num1); }
public static bool doHoldDownButton(int myID, int x, int y, int width, int height, string text, bool hasOutline, Color?outlineColor, Color?selectedColor) { wasPressedDown = false; wasReleased = false; if (!outlineColor.HasValue) { outlineColor = Color.White; } if (!selectedColor.HasValue) { selectedColor = GuiData.Default_Selected_Color; } var destinationRectangle = GuiData.tmpRect; destinationRectangle.X = x; destinationRectangle.Y = y; destinationRectangle.Width = width; destinationRectangle.Height = height; var flag = GuiData.isMouseLeftDown() && GuiData.active == myID; if (destinationRectangle.Contains(GuiData.getMousePoint())) { GuiData.hot = myID; if (GuiData.mouseWasPressed()) { wasPressedDown = true; } if (GuiData.isMouseLeftDown()) { GuiData.active = myID; flag = true; } } else { if (GuiData.hot == myID) { GuiData.hot = -1; } if (!GuiData.isMouseLeftDown() && GuiData.active == myID && GuiData.active == myID) { GuiData.active = -1; } } if (GuiData.mouseLeftUp()) { wasReleased = true; } GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, GuiData.active == myID ? selectedColor.Value : (GuiData.hot == myID ? GuiData.Default_Lit_Backing_Color : GuiData.Default_Light_Backing_Color)); if (hasOutline) { RenderedRectangle.doRectangleOutline(x, y, width, height, 2, outlineColor); } return(flag); }
public static void doRectangle(int x, int y, int width, int height, Color?color, bool blocking) { RenderedRectangle.doRectangle(x, y, width, height, color); Rectangle tmpRect = GuiData.tmpRect; tmpRect.X = x; tmpRect.Y = y; tmpRect.Width = width; tmpRect.Height = height; if (!blocking || !tmpRect.Contains(GuiData.getMousePoint())) { return; } GuiData.blockingInput = true; }
public static void doRectangle(int x, int y, int width, int height, Color?color, bool blocking) { doRectangle(x, y, width, height, color); var rectangle = GuiData.tmpRect; rectangle.X = x; rectangle.Y = y; rectangle.Width = width; rectangle.Height = height; if (!blocking || !rectangle.Contains(GuiData.getMousePoint())) { return; } GuiData.blockingInput = true; }
public override void PostDrawStep() { base.PostDrawStep(); if (this.inputLocked) { GuiData.blockingInput = false; GuiData.blockingInput = this.guiInputLockStatus; Rectangle bounds = this.bounds; if (bounds.Contains(GuiData.getMousePoint())) { GuiData.spriteBatch.Draw(Utils.white, bounds, Color.Gray * 0.5f); Vector2 position = new Vector2((float)(bounds.X + bounds.Width / 2 - OnCoreModule.LockSprite.Width / 2), (float)(bounds.Y + bounds.Height / 2 - OnCoreModule.LockSprite.Height / 2)); GuiData.spriteBatch.Draw(OnCoreModule.LockSprite, position, Color.White); } } }
public static Vector2 endPanel(int id, Vector2 scroll, Rectangle bounds, float maxScroll, bool onlyScrollWithMouseOver = false) { batches.Peek().End(); var renderTarget2D = targets.Pop(); GuiData.spriteBatch.GraphicsDevice.SetRenderTarget(targets.Peek()); targetPool.Add(renderTarget2D); batchPool.Add(batches.Pop()); GuiData.spriteBatch = batches.Peek(); GuiData.scrollOffset = offsetStack.Pop(); var rectangle1 = GuiData.tmpRect; rectangle1.X = (int)scroll.X; rectangle1.Y = (int)scroll.Y; rectangle1.Width = bounds.Width; rectangle1.Height = bounds.Height; try { GuiData.spriteBatch.Draw(renderTarget2D, bounds, rectangle1, Color.White); } catch (InvalidOperationException ex) { return(scroll); } if (!onlyScrollWithMouseOver || bounds.Contains(GuiData.getMousePoint())) { scroll.Y += GuiData.getMouseWheelScroll() * 20f; } scroll.Y = Math.Max(Math.Min(scroll.Y, maxScroll), 0.0f); var rectangle2 = GuiData.tmpRect; var num1 = 5f; var num2 = bounds.Height / maxScroll * bounds.Height; var num3 = bounds.Height - 4f; var num4 = scroll.Y / maxScroll * (bounds.Height - num2); rectangle2.Y = (int)(num4 - num2 / 2.0 + num2 / 2.0 + bounds.Y); rectangle2.X = (int)(bounds.X + bounds.Width - 1.5 * num1 - 2.0); rectangle2.Height = (int)num2; rectangle2.Width = (int)num1; scroll.Y = ScrollBar.doVerticalScrollBar(id, rectangle2.X, bounds.Y, rectangle2.Width, bounds.Height, renderTarget2D.Height, scroll.Y); scroll.Y = Math.Max(Math.Min(scroll.Y, maxScroll), 0.0f); return(scroll); }
public static bool doCheckBox(int myID, int x, int y, bool isChecked, Color?selectedColor) { if (!selectedColor.HasValue) { selectedColor = GuiData.Default_Selected_Color; } if (GuiData.hot == myID && GuiData.active == myID && GuiData.mouseLeftUp()) { isChecked = !isChecked; GuiData.active = -1; } RenderedRectangle.doRectangleOutline(x, y, 20, 20, 2, GuiData.hot == myID ? GuiData.Default_Lit_Backing_Color : GuiData.Default_Light_Backing_Color); RenderedRectangle.doRectangle(x + 4, y + 4, 12, 12, isChecked ? selectedColor : (GuiData.active == myID ? GuiData.Default_Unselected_Color : GuiData.Default_Backing_Color)); var rectangle = GuiData.tmpRect; rectangle.X = x; rectangle.Y = y; rectangle.Width = 20; rectangle.Height = 20; if (rectangle.Contains(GuiData.getMousePoint())) { GuiData.hot = myID; if (GuiData.isMouseLeftDown()) { GuiData.active = myID; } } else { if (GuiData.hot == myID) { GuiData.hot = -1; } if (GuiData.isMouseLeftDown() && GuiData.active == myID && GuiData.active == myID) { GuiData.active = -1; } } return(isChecked); }
public static Vector2 endPanel(int id, Vector2 scroll, Rectangle bounds, float maxScroll, bool onlyScrollWithMouseOver = false) { ScrollablePanel.batches.Peek().End(); RenderTarget2D renderTarget2D = ScrollablePanel.targets.Pop(); GuiData.spriteBatch.GraphicsDevice.SetRenderTarget(ScrollablePanel.targets.Peek()); ScrollablePanel.targetPool.Add(renderTarget2D); ScrollablePanel.batchPool.Add(ScrollablePanel.batches.Pop()); GuiData.spriteBatch = ScrollablePanel.batches.Peek(); GuiData.scrollOffset = ScrollablePanel.offsetStack.Pop(); Rectangle tmpRect1 = GuiData.tmpRect; tmpRect1.X = (int)scroll.X; tmpRect1.Y = (int)scroll.Y; tmpRect1.Width = bounds.Width; tmpRect1.Height = bounds.Height; try { GuiData.spriteBatch.Draw((Texture2D)renderTarget2D, bounds, new Rectangle?(tmpRect1), Color.White); } catch (InvalidOperationException ex) { return(scroll); } if (!onlyScrollWithMouseOver || bounds.Contains(GuiData.getMousePoint())) { scroll.Y += GuiData.getMouseWheelScroll() * 20f; } scroll.Y = Math.Max(Math.Min(scroll.Y, maxScroll), 0.0f); Rectangle tmpRect2 = GuiData.tmpRect; float num1 = 5f; float num2 = (float)bounds.Height / maxScroll * (float)bounds.Height; float num3 = (float)bounds.Height - 4f; float num4 = scroll.Y / maxScroll * ((float)bounds.Height - num2); tmpRect2.Y = (int)((double)num4 - (double)num2 / 2.0 + (double)num2 / 2.0 + (double)bounds.Y); tmpRect2.X = (int)((double)(bounds.X + bounds.Width) - 1.5 * (double)num1 - 2.0); tmpRect2.Height = (int)num2; tmpRect2.Width = (int)num1; scroll.Y = ScrollBar.doVerticalScrollBar(id, tmpRect2.X, bounds.Y, tmpRect2.Width, bounds.Height, renderTarget2D.Height, scroll.Y); scroll.Y = Math.Max(Math.Min(scroll.Y, maxScroll), 0.0f); return(scroll); }
public static bool doButton(int myID, int x, int y, int width, int height, string text, Color?selectedColor, Texture2D tex) { var flag = false; if (GuiData.hot == myID && !GuiData.blockingInput && GuiData.active == myID && (GuiData.mouseLeftUp() || GuiData.mouse.LeftButton == ButtonState.Released)) { flag = true; GuiData.active = -1; } var rectangle = GuiData.tmpRect; rectangle.X = x; rectangle.Y = y; rectangle.Width = width; rectangle.Height = height; if (rectangle.Contains(GuiData.getMousePoint()) && !GuiData.blockingInput) { GuiData.hot = myID; if (GuiData.isMouseLeftDown() && (!DisableIfAnotherIsActive || GuiData.active == -1)) { GuiData.active = myID; } } else { if (GuiData.hot == myID) { GuiData.hot = -1; } if (GuiData.isMouseLeftDown() && GuiData.active == myID && GuiData.active == myID) { GuiData.active = -1; } } drawModernButton(myID, x, y, width, height, text, selectedColor, tex); return(flag); }
public static float doVerticalScrollBar(int id, int xPos, int yPos, int drawWidth, int drawHeight, int contentHeight, float scroll) { if (drawHeight > contentHeight) { contentHeight = drawHeight; } Rectangle destinationRectangle = new Rectangle(xPos, yPos, drawWidth, drawHeight); if (ScrollBar.AlwaysDrawUnderBar || destinationRectangle.Contains(GuiData.getMousePoint()) || GuiData.active == id) { GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, Color.Gray * 0.1f); } float num1 = scroll; float num2 = (float)(contentHeight - drawHeight); float num3 = (float)drawHeight / (float)contentHeight * (float)drawHeight; float num4 = scroll / num2 * ((float)drawHeight - num3); float y = DraggableRectangle.doDraggableRectangle(id, (float)xPos, (float)yPos + num4, drawWidth, (int)num3, (float)drawWidth, new Color?(Color.White), new Color?(Color.Gray), true, false, (float)xPos, (float)(yPos + drawHeight) - num3, (float)xPos, (float)yPos).Y; if ((double)Math.Abs(y) > 0.100000001490116) { num1 = (float)(((double)num4 + (double)y) / ((double)drawHeight - (double)num3)) * num2; } return(num1); }
public static string doTerminalTextField(int myID, int x, int y, int width, int selectionHeight, int lines, string str, SpriteFont font) { string s = str; if (font == null) { font = GuiData.smallfont; } TextBox.BoxWasActivated = false; TextBox.UpWasPresed = false; TextBox.DownWasPresed = false; TextBox.TabWasPresed = false; Rectangle tmpRect = GuiData.tmpRect; tmpRect.X = x; tmpRect.Y = y; tmpRect.Width = width; tmpRect.Height = 0; if (tmpRect.Contains(GuiData.getMousePoint())) { GuiData.hot = myID; } else if (GuiData.hot == myID) { GuiData.hot = -1; } if (GuiData.mouseWasPressed()) { if (GuiData.hot == myID) { if (GuiData.active == myID) { int num = GuiData.mouse.X - x; bool flag = false; for (int length = 1; length <= str.Length; ++length) { if ((double)font.MeasureString(str.Substring(0, length)).X > (double)num) { TextBox.cursorPosition = length - 1; break; } if (!flag) { TextBox.cursorPosition = str.Length; } } } else { GuiData.active = myID; TextBox.cursorPosition = str.Length; } } else if (GuiData.active == myID) { GuiData.active = -1; } } int active1 = GuiData.active; bool flag1 = false; string filteredStringInput = TextBox.getFilteredStringInput(s, GuiData.getKeyboadState(), GuiData.getLastKeyboadState()); KeyboardState keyboardState = GuiData.getKeyboadState(); int num1; if (keyboardState.IsKeyDown(Keys.Enter)) { keyboardState = GuiData.getLastKeyboadState(); num1 = keyboardState.IsKeyDown(Keys.Enter) ? 1 : 0; } else { num1 = 1; } if (num1 == 0) { TextBox.BoxWasActivated = true; TextBox.cursorPosition = 0; TextBox.textDrawOffsetPosition = 0; } tmpRect.Height = lines * TextBox.LINE_HEIGHT; ++TextBox.FramesSelected; tmpRect.X = x; tmpRect.Y = y; tmpRect.Width = width; tmpRect.Height = 10; tmpRect.X += 2; tmpRect.Y += 2; tmpRect.Width -= 4; tmpRect.Height -= 4; float num2 = (float)(((double)TextBox.LINE_HEIGHT - (double)font.MeasureString(filteredStringInput).Y) / 2.0); string str1 = filteredStringInput; int num3 = 0; int startIndex = 0; int length1; for (string text = str1; (double)font.MeasureString(text).X > (double)(width - 5); text = str1.Substring(startIndex, length1)) { ++num3; length1 = str1.Length - startIndex - (num3 - startIndex); if (length1 < 0) { break; } } if (TextBox.cursorPosition < TextBox.textDrawOffsetPosition) { TextBox.textDrawOffsetPosition = Math.Max(0, TextBox.textDrawOffsetPosition - 1); } while (TextBox.cursorPosition > TextBox.textDrawOffsetPosition + (str1.Length - num3)) { ++TextBox.textDrawOffsetPosition; } if (str1.Length <= num3 || TextBox.textDrawOffsetPosition < 0) { TextBox.textDrawOffsetPosition = TextBox.textDrawOffsetPosition > str1.Length - num3 ? 0 : str1.Length - num3; } else if (TextBox.textDrawOffsetPosition > num3) { num3 = TextBox.textDrawOffsetPosition; } if (num3 > str1.Length) { num3 = str1.Length - 1; } if (TextBox.textDrawOffsetPosition >= str1.Length) { TextBox.textDrawOffsetPosition = 0; } string text1 = str1.Substring(TextBox.textDrawOffsetPosition, str1.Length - num3); if (TextBox.MaskingText) { string str2 = ""; for (int index = 0; index < filteredStringInput.Length; ++index) { str2 += "*"; } text1 = str2; } GuiData.spriteBatch.DrawString(font, text1, Utils.ClipVec2ForTextRendering(new Vector2((float)(x + 2), (float)y + num2)), Color.White); int active2 = GuiData.active; flag1 = false; if (filteredStringInput != "") { int length2 = Math.Min(TextBox.cursorPosition - TextBox.textDrawOffsetPosition, text1.Length); if (length2 <= 0) { length2 = 1; } tmpRect.X = text1.Length != 0 ? (int)((double)x + (double)font.MeasureString(text1.Substring(0, length2)).X) + 3 : x; } else { tmpRect.X = x + 3; } tmpRect.Y = y + 2; tmpRect.Width = 1; tmpRect.Height = TextBox.LINE_HEIGHT - 4; if (LocaleActivator.ActiveLocaleIsCJK()) { tmpRect.Y += 4; } GuiData.spriteBatch.Draw(Utils.white, tmpRect, TextBox.FramesSelected % 60 < 40 ? Color.White : Color.Gray); return(filteredStringInput); }
public static float doSliderBar(int myID, int x, int y, int width, int height, float maxValue, float minValue, float currentValue, float barStep) { var num1 = -1f; var val1 = currentValue; if (GuiData.hot == myID) { if (GuiData.isMouseLeftDown()) { GuiData.active = myID; } else if (GuiData.active == myID) { GuiData.active = -1; } if (GuiData.active == myID) { num1 = Math.Min(Math.Max((GuiData.mouse.X - x) / (float)width, 0.0f), 1f); val1 = minValue + num1 * (maxValue - minValue); } val1 += barStep * GuiData.getMouseWheelScroll(); } if (num1 == -1.0) { var num2 = maxValue - minValue; num1 = currentValue / num2; if (minValue < 0.0) { num1 += 0.5f; } } GuiData.tmpRect.X = x; GuiData.tmpRect.Y = y; GuiData.tmpRect.Width = width; GuiData.tmpRect.Height = height; if (GuiData.tmpRect.Contains(GuiData.getMousePoint())) { GuiData.hot = myID; } else if (GuiData.hot == myID && GuiData.mouse.LeftButton == ButtonState.Released) { GuiData.hot = -1; if (GuiData.active == myID) { GuiData.active = -1; } } var num3 = Math.Min(Math.Max(val1, minValue), maxValue); GuiData.tmpRect.Width = width; GuiData.tmpRect.X = x; GuiData.tmpRect.Height = 10; GuiData.tmpRect.Y = y + height / 4; GuiData.spriteBatch.Draw(Utils.white, GuiData.tmpRect, GuiData.Default_Backing_Color); GuiData.tmpRect.Width -= 4; GuiData.tmpRect.X += 2; GuiData.tmpRect.Height -= 4; GuiData.tmpRect.Y += 2; GuiData.spriteBatch.Draw(Utils.white, GuiData.tmpRect, GuiData.Default_Dark_Background_Color); GuiData.tmpRect.Width = 8; GuiData.tmpRect.X = (int)(x + num1 * (double)width) - 4; GuiData.tmpRect.Y = y - 5; GuiData.tmpRect.Height = height; GuiData.spriteBatch.Draw(Utils.white, GuiData.tmpRect, GuiData.active != myID ? (GuiData.hot == myID ? GuiData.Default_Lit_Backing_Color : GuiData.Default_Selected_Color) : GuiData.Default_Unselected_Color); if (GuiData.active == myID || GuiData.hot == myID) { var format = "0.000"; var text = num3.ToString(format) ?? ""; text.TrimEnd('0'); GuiData.temp.X = (int)(x + num1 * (double)width) + 4; GuiData.temp.Y = y - GuiData.smallfont.MeasureString(text).Y *0.8f; GuiData.spriteBatch.DrawString(GuiData.smallfont, text, GuiData.temp + Vector2.One, Color.Gray, 0.0f, Vector2.Zero, 0.8f, SpriteEffects.None, 0.51f); GuiData.spriteBatch.DrawString(GuiData.smallfont, text, GuiData.temp, Color.White, 0.0f, Vector2.Zero, 0.8f, SpriteEffects.None, 0.5f); } return(num3); }
public static string doTextBox(int myID, int x, int y, int width, int lines, string str, SpriteFont font) { var str1 = str; if (font == null) { font = GuiData.smallfont; } BoxWasActivated = false; var destinationRectangle = GuiData.tmpRect; destinationRectangle.X = x; destinationRectangle.Y = y; destinationRectangle.Width = width; destinationRectangle.Height = lines * LINE_HEIGHT; if (destinationRectangle.Contains(GuiData.getMousePoint())) { GuiData.hot = myID; } else if (GuiData.hot == myID) { GuiData.hot = -1; } if (GuiData.mouseWasPressed()) { if (GuiData.hot == myID) { if (GuiData.active == myID) { var num = GuiData.mouse.X - x; var flag = false; for (var length = 1; length <= str.Length; ++length) { if (font.MeasureString(str.Substring(0, length)).X > (double)num) { cursorPosition = length - 1; break; } if (!flag) { cursorPosition = str.Length; } } } else { GuiData.active = myID; cursorPosition = str.Length; } } else if (GuiData.active == myID) { GuiData.active = -1; } } if (GuiData.active == myID) { GuiData.willBlockTextInput = true; str1 = getStringInput(str1, GuiData.getKeyboadState(), GuiData.getLastKeyboadState()); if (GuiData.getKeyboadState().IsKeyDown(Keys.Enter) && GuiData.getLastKeyboadState().IsKeyDown(Keys.Enter)) { BoxWasActivated = true; GuiData.active = -1; } } ++FramesSelected; destinationRectangle.X = x; destinationRectangle.Y = y; destinationRectangle.Width = width; destinationRectangle.Height = lines * LINE_HEIGHT; GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, GuiData.active == myID ? GuiData.Default_Lit_Backing_Color : (GuiData.hot == myID ? GuiData.Default_Selected_Color : GuiData.Default_Dark_Background_Color)); destinationRectangle.X += 2; destinationRectangle.Y += 2; destinationRectangle.Width -= 4; destinationRectangle.Height -= 4; GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, GuiData.Default_Light_Backing_Color); var num1 = (float)((LINE_HEIGHT - (double)font.MeasureString(str1).Y) / 2.0); GuiData.spriteBatch.DrawString(font, str1, new Vector2(x + 2, y + num1), Color.White); if (GuiData.active == myID) { destinationRectangle.X = (int)(x + (double)font.MeasureString(str1.Substring(0, cursorPosition)).X) + 3; destinationRectangle.Y = y + 2; destinationRectangle.Width = 1; destinationRectangle.Height = LINE_HEIGHT - 4; GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, FramesSelected % 60 < 40 ? Color.White : Color.Gray); } return(str1); }
public static Vector2 doDraggableRectangle(int myID, float x, float y, int width, int height, float selectableBorder, Color?selectedColor, Color?deselectedColor, bool canMoveY, bool canMoveX, float xMax, float yMax, float xMin, float yMin) { isDragging = false; if (!selectedColor.HasValue) { selectedColor = GuiData.Default_Selected_Color; } if (!deselectedColor.HasValue) { deselectedColor = GuiData.Default_Unselected_Color; } var vector2 = GuiData.temp; vector2.X = 0.0f; vector2.Y = 0.0f; var destinationRectangle = GuiData.tmpRect; destinationRectangle.X = (int)x; destinationRectangle.Y = (int)y; destinationRectangle.Width = width; destinationRectangle.Height = height; var rectangle = GuiData.tmpRect; rectangle.X = (int)(x + (double)selectableBorder); rectangle.Y = (int)(y + (double)selectableBorder); rectangle.Width = selectableBorder == -1.0 ? 0 : (int)(width - 2.0 * selectableBorder); rectangle.Height = selectableBorder == -1.0 ? 0 : (int)(height - 2.0 * selectableBorder); if (destinationRectangle.Contains(GuiData.getMousePoint()) && !rectangle.Contains(GuiData.getMousePoint())) { GuiData.hot = myID; if (GuiData.active != myID && GuiData.mouseWasPressed()) { GuiData.active = myID; originalClickPos = GuiData.getMousePos(); originalClickPos.X -= x; originalClickPos.Y -= y; originalClickOffset = new Vector2(originalClickPos.X - x, originalClickPos.Y - y); } } else if (GuiData.hot == myID) { GuiData.hot = -1; } if (GuiData.active == myID) { if (GuiData.mouseLeftUp()) { GuiData.active = -1; } else { if (canMoveX) { vector2.X = GuiData.mouse.X - x - originalClickPos.X; vector2.X = Math.Min(Math.Max(destinationRectangle.X + vector2.X, xMin), xMax) - destinationRectangle.X; } if (canMoveY) { vector2.Y = GuiData.mouse.Y - y - originalClickPos.Y; vector2.Y = Math.Min(Math.Max(destinationRectangle.Y + vector2.Y, yMin), yMax) - destinationRectangle.Y; } destinationRectangle.X += (int)vector2.X; destinationRectangle.Y += (int)vector2.Y; isDragging = true; } } if (GuiData.active == myID || GuiData.hot == myID) { GuiData.blockingInput = true; } GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, GuiData.hot == myID || GuiData.active == myID ? selectedColor.Value : deselectedColor.Value); return(vector2); }
public void Draw(Action <int, Rectangle, SpriteBatch> DrawSection, SpriteBatch sb, Rectangle destination) { this.UpdateInput(destination); this.SetRenderTargetsToFrame(destination); bool flag = destination.Contains(GuiData.getMousePoint()); Vector2 scrollOffset = GuiData.scrollOffset; Vector2 vector2 = new Vector2((float)destination.X, (float)destination.Y - this.ScrollDown % (float)this.PanelHeight); if (flag) { GuiData.scrollOffset = vector2; } SpriteBatch spriteBatch = GuiData.spriteBatch; int index1 = 0; float scrollDown = this.ScrollDown; while ((double)scrollDown >= (double)this.PanelHeight) { scrollDown -= (float)this.PanelHeight; ++index1; } int num1 = 0; if ((double)this.ScrollDown % (double)this.PanelHeight != 0.0) { GuiData.spriteBatch = this.fragmentBatch; this.RenderToTarget(DrawSection, this.AboveFragment, index1, new Rectangle(0, 0, destination.Width, this.PanelHeight)); int height = this.PanelHeight - (int)((double)this.ScrollDown % (double)this.PanelHeight); Rectangle destinationRectangle = new Rectangle(destination.X, destination.Y, destination.Width, height); Rectangle rectangle = new Rectangle(0, this.PanelHeight - destinationRectangle.Height, destination.Width, height); sb.Draw((Texture2D)this.AboveFragment, destinationRectangle, new Rectangle?(rectangle), Color.White); num1 += height; ++index1; } GuiData.spriteBatch = spriteBatch; if (flag) { GuiData.scrollOffset = scrollOffset; } int index2 = index1; Rectangle rectangle1 = new Rectangle(destination.X, destination.Y + num1, destination.Width, this.PanelHeight); while (num1 + this.PanelHeight < destination.Height && index2 < this.NumberOfPanels) { DrawSection(index2, rectangle1, sb); ++index2; num1 += this.PanelHeight; rectangle1.Y = destination.Y + num1; } vector2 = new Vector2((float)destination.X, (float)rectangle1.Y); if (flag) { GuiData.scrollOffset = vector2; } if (index2 < this.NumberOfPanels && destination.Height - num1 > 0) { GuiData.spriteBatch = this.fragmentBatch; this.RenderToTarget(DrawSection, this.BelowFragment, index2, new Rectangle(0, 0, destination.Width, this.PanelHeight)); int height = destination.Height - num1; Rectangle destinationRectangle = new Rectangle(destination.X, rectangle1.Y, destination.Width, height); Rectangle rectangle2 = new Rectangle(0, 0, destination.Width, height); sb.Draw((Texture2D)this.BelowFragment, destinationRectangle, new Rectangle?(rectangle2), Color.White); int num2 = num1 + height; int num3 = index1 + 1; } GuiData.spriteBatch = spriteBatch; if (flag) { GuiData.scrollOffset = scrollOffset; } if (!this.HasScrollBar) { return; } int width = 7; this.DrawScrollBar(new Rectangle(destination.X + destination.Width - width - 2, destination.Y, width, destination.Height - 1), width); }
public static Vector2 doDraggableRectangle(int myID, float x, float y, int width, int height, float selectableBorder, Color?selectedColor, Color?deselectedColor, bool canMoveY, bool canMoveX, float xMax, float yMax, float xMin, float yMin) { DraggableRectangle.isDragging = false; if (!selectedColor.HasValue) { selectedColor = new Color?(GuiData.Default_Selected_Color); } if (!deselectedColor.HasValue) { deselectedColor = new Color?(GuiData.Default_Unselected_Color); } Vector2 temp = GuiData.temp; temp.X = 0.0f; temp.Y = 0.0f; Rectangle tmpRect1 = GuiData.tmpRect; tmpRect1.X = (int)x; tmpRect1.Y = (int)y; tmpRect1.Width = width; tmpRect1.Height = height; Rectangle tmpRect2 = GuiData.tmpRect; tmpRect2.X = (int)((double)x + (double)selectableBorder); tmpRect2.Y = (int)((double)y + (double)selectableBorder); tmpRect2.Width = (double)selectableBorder == -1.0 ? 0 : (int)((double)width - 2.0 * (double)selectableBorder); tmpRect2.Height = (double)selectableBorder == -1.0 ? 0 : (int)((double)height - 2.0 * (double)selectableBorder); if (tmpRect1.Contains(GuiData.getMousePoint()) && !tmpRect2.Contains(GuiData.getMousePoint())) { GuiData.hot = myID; if (GuiData.active != myID && GuiData.mouseWasPressed()) { GuiData.active = myID; DraggableRectangle.originalClickPos = GuiData.getMousePos(); DraggableRectangle.originalClickPos.X -= x; DraggableRectangle.originalClickPos.Y -= y; DraggableRectangle.originalClickOffset = new Vector2(DraggableRectangle.originalClickPos.X - x, DraggableRectangle.originalClickPos.Y - y); } } else if (GuiData.hot == myID) { GuiData.hot = -1; } if (GuiData.active == myID) { if (GuiData.mouseLeftUp()) { GuiData.active = -1; } else { if (canMoveX) { temp.X = (float)GuiData.mouse.X - x - DraggableRectangle.originalClickPos.X; temp.X = Math.Min(Math.Max((float)tmpRect1.X + temp.X, xMin), xMax) - (float)tmpRect1.X; } if (canMoveY) { temp.Y = (float)GuiData.mouse.Y - y - DraggableRectangle.originalClickPos.Y; temp.Y = Math.Min(Math.Max((float)tmpRect1.Y + temp.Y, yMin), yMax) - (float)tmpRect1.Y; } tmpRect1.X += (int)temp.X; tmpRect1.Y += (int)temp.Y; DraggableRectangle.isDragging = true; } } if (GuiData.active == myID || GuiData.hot == myID) { GuiData.blockingInput = true; } GuiData.spriteBatch.Draw(Utils.white, tmpRect1, GuiData.hot == myID || GuiData.active == myID ? selectedColor.Value : deselectedColor.Value); return(temp); }
public static int doList(int myID, int x, int y, int width, int height, string[] text, int lastSelectedIndex, Color?selectedColor) { if (!selectedColor.HasValue) { selectedColor = new Color?(GuiData.Default_Selected_Color); } int num1 = -1; SelectableTextList.wasActivated = false; int num2 = lastSelectedIndex; SelectableTextList.selectionWasChanged = false; Vector2 mousePos = GuiData.getMousePos(); Rectangle tmpRect = GuiData.tmpRect; tmpRect.X = x; tmpRect.Y = y; tmpRect.Width = width; tmpRect.Height = height; if (tmpRect.Contains(GuiData.getMousePoint())) { GuiData.hot = myID; SelectableTextList.scrollOffset += (int)GuiData.getMouseWheelScroll(); SelectableTextList.scrollOffset = Math.Max(0, Math.Min(SelectableTextList.scrollOffset, text.Length - (int)((double)height / 18.0))); } else if (GuiData.hot == myID) { GuiData.hot = -1; } int num3 = Math.Max(0, Math.Min(SelectableTextList.scrollOffset, text.Length - (int)((double)height / 18.0))); if (GuiData.hot == myID) { for (int index = 0; index < text.Length; ++index) { if ((double)mousePos.Y >= (double)y + (double)index * 18.0 && (double)mousePos.Y <= (double)y + (double)(index + 1) * 18.0 && (double)mousePos.Y < (double)(y + height)) { num1 = index + num3; SelectableTextList.wasActivated = true; } } } if (num1 != -1 && num1 != lastSelectedIndex && GuiData.mouseLeftUp()) { lastSelectedIndex = num1; } GuiData.spriteBatch.Draw(Utils.white, tmpRect, GuiData.hot == myID ? GuiData.Default_Lit_Backing_Color : GuiData.Default_Backing_Color); tmpRect.X += 2; tmpRect.Width -= 4; tmpRect.Y += 2; tmpRect.Height -= 4; GuiData.spriteBatch.Draw(Utils.white, tmpRect, GuiData.Default_Dark_Background_Color); Vector2 position = new Vector2((float)tmpRect.X, (float)tmpRect.Y); tmpRect.Height = 18; for (int index = num3; index < text.Length; ++index) { GuiData.spriteBatch.Draw(Utils.white, tmpRect, lastSelectedIndex == index ? selectedColor.Value : (num1 == index ? GuiData.Default_Unselected_Color : GuiData.Default_Dark_Neutral_Color)); Vector2 scale = GuiData.UITinyfont.MeasureString(text[index]); scale.X = (double)scale.X <= (double)(width - 4) ? 1f : (float)(width - 4) / scale.X; scale.Y = (double)scale.Y <= 18.0 ? 1f : 14f / scale.Y; GuiData.spriteBatch.DrawString(GuiData.UITinyfont, text[index], position, Color.White, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.5f); position.Y += 18f; tmpRect.Y += 18; if ((double)position.Y > (double)(y + height - 4)) { break; } } if ((double)text.Length * 18.0 > (double)height) { float num4 = 2f; float num5 = (float)height / ((float)text.Length * 18f) * (float)height; height -= 4; float num6 = (float)-height + (float)(((double)height - (double)num5) * ((double)num3 / (((double)text.Length * 18.0 - (double)height) / 18.0))); tmpRect.X = (int)((double)position.X + (double)width - 3.0 * (double)num4 - 2.0); tmpRect.Y = (int)((double)position.Y + (double)num6 + 2.0); tmpRect.Height = (int)num5; tmpRect.Width = (int)num4; GuiData.spriteBatch.Draw(Utils.white, tmpRect, SelectableTextList.scrollBarColor); } if (lastSelectedIndex != num2) { SelectableTextList.selectionWasChanged = true; } return(lastSelectedIndex); }
public static int doFancyList(int myID, int x, int y, int width, int height, string[] text, int lastSelectedIndex, Color?selectedColor, bool HasDraggableScrollbar = false) { if (!selectedColor.HasValue) { selectedColor = new Color?(GuiData.Default_Selected_Color); } int num1 = -1; SelectableTextList.wasActivated = false; int num2 = lastSelectedIndex; SelectableTextList.selectionWasChanged = false; Vector2 mousePos = GuiData.getMousePos(); Rectangle tmpRect = GuiData.tmpRect; tmpRect.X = x; tmpRect.Y = y; tmpRect.Width = width; tmpRect.Height = height; if (tmpRect.Contains(GuiData.getMousePoint())) { GuiData.hot = myID; SelectableTextList.scrollOffset += (int)GuiData.getMouseWheelScroll(); SelectableTextList.scrollOffset = Math.Max(0, Math.Min(SelectableTextList.scrollOffset, text.Length - (int)((double)height / 18.0))); } else if (GuiData.hot == myID) { GuiData.hot = -1; } int num3 = Math.Max(0, Math.Min(SelectableTextList.scrollOffset, text.Length - (int)((double)height / 18.0))); float num4 = HasDraggableScrollbar ? 4f : 2f; if (GuiData.hot == myID && (!HasDraggableScrollbar || (double)mousePos.X < (double)(x + width) - 2.0 * (double)num4)) { for (int index = 0; index < text.Length; ++index) { if ((double)mousePos.Y >= (double)y + (double)index * 18.0 && (double)mousePos.Y <= (double)y + (double)(index + 1) * 18.0 && (double)mousePos.Y < (double)(y + height)) { num1 = index + num3; } } } if (num1 != -1 && num1 != lastSelectedIndex && GuiData.mouseLeftUp()) { lastSelectedIndex = num1; SelectableTextList.wasActivated = true; } tmpRect.X += 2; tmpRect.Width -= 4; tmpRect.Y += 2; tmpRect.Height -= 4; Vector2 input = new Vector2((float)tmpRect.X, (float)tmpRect.Y); tmpRect.Height = 18; for (int index = num3; index < text.Length; ++index) { GuiData.spriteBatch.Draw(Utils.white, tmpRect, lastSelectedIndex == index ? selectedColor.Value : (num1 == index ? selectedColor.Value * 0.45f : GuiData.Default_Dark_Neutral_Color)); Vector2 scale = GuiData.UITinyfont.MeasureString(text[index]); scale.X = (double)scale.X <= (double)(width - 4) ? 1f : (float)(width - 4) / scale.X; scale.Y = (double)scale.Y <= 18.0 ? 1f : 18f / scale.Y; scale.X = Math.Min(scale.X, scale.Y); scale.Y = Math.Min(scale.X, scale.Y); bool flag = !LocaleActivator.ActiveLocaleIsCJK() && Settings.ActiveLocale != "en-us"; if (flag) { input.Y += 3f; } GuiData.spriteBatch.DrawString(GuiData.UITinyfont, text[index], Utils.ClipVec2ForTextRendering(input), lastSelectedIndex == index ? Color.Black : Color.White, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.5f); if (flag) { input.Y -= 3f; } input.Y += 18f; tmpRect.Y += 18; if ((double)input.Y > (double)(y + height - 4)) { break; } } if ((double)text.Length * 18.0 > (double)height) { float num5 = num4; float num6 = (float)height / ((float)text.Length * 18f) * (float)height; height -= 4; float num7 = (float)-height + (float)(((double)height - (double)num6) * ((double)num3 / (((double)text.Length * 18.0 - (double)height) / 18.0))); tmpRect.X = (int)((double)input.X + (double)width - (HasDraggableScrollbar ? 2.0 : 3.0) * (double)num5 - 2.0); tmpRect.Y = (int)((double)input.Y + (double)num7 + 2.0); tmpRect.Height = (int)num6; tmpRect.Width = (int)num5; if (!HasDraggableScrollbar) { GuiData.spriteBatch.Draw(Utils.white, tmpRect, SelectableTextList.scrollBarColor); } else { SelectableTextList.scrollOffset = (int)((double)ScrollBar.doVerticalScrollBar(myID + 101, tmpRect.X, y, tmpRect.Width, height, (int)((double)text.Length * 18.0), (float)num3 * 18f) / 18.0); } } if (lastSelectedIndex != num2) { SelectableTextList.selectionWasChanged = true; } return(lastSelectedIndex); }
public static string doTerminalTextField(int myID, int x, int y, int width, int selectionHeight, int lines, string str, SpriteFont font) { var s = str; if (font == null) { font = GuiData.smallfont; } BoxWasActivated = false; UpWasPresed = false; DownWasPresed = false; TabWasPresed = false; var destinationRectangle = GuiData.tmpRect; destinationRectangle.X = x; destinationRectangle.Y = y; destinationRectangle.Width = width; destinationRectangle.Height = 0; if (destinationRectangle.Contains(GuiData.getMousePoint())) { GuiData.hot = myID; } else if (GuiData.hot == myID) { GuiData.hot = -1; } if (GuiData.mouseWasPressed()) { if (GuiData.hot == myID) { if (GuiData.active == myID) { var num = GuiData.mouse.X - x; var flag = false; for (var length = 1; length <= str.Length; ++length) { if (font.MeasureString(str.Substring(0, length)).X > (double)num) { cursorPosition = length - 1; break; } if (!flag) { cursorPosition = str.Length; } } } else { GuiData.active = myID; cursorPosition = str.Length; } } else if (GuiData.active == myID) { GuiData.active = -1; } } var num1 = GuiData.active; var filteredStringInput = getFilteredStringInput(s, GuiData.getKeyboadState(), GuiData.getLastKeyboadState()); if (GuiData.getKeyboadState().IsKeyDown(Keys.Enter) && !GuiData.getLastKeyboadState().IsKeyDown(Keys.Enter)) { BoxWasActivated = true; cursorPosition = 0; textDrawOffsetPosition = 0; } destinationRectangle.Height = lines * LINE_HEIGHT; ++FramesSelected; destinationRectangle.X = x; destinationRectangle.Y = y; destinationRectangle.Width = width; destinationRectangle.Height = 10; destinationRectangle.X += 2; destinationRectangle.Y += 2; destinationRectangle.Width -= 4; destinationRectangle.Height -= 4; var num2 = (float)((LINE_HEIGHT - (double)font.MeasureString(filteredStringInput).Y) / 2.0); var str1 = filteredStringInput; var num3 = 0; var startIndex = 0; int length1; for (var text = str1; font.MeasureString(text).X > (double)(width - 5); text = str1.Substring(startIndex, length1)) { ++num3; length1 = str1.Length - startIndex - (num3 - startIndex); } if (cursorPosition < textDrawOffsetPosition) { textDrawOffsetPosition = Math.Max(0, textDrawOffsetPosition - 1); } while (cursorPosition > textDrawOffsetPosition + (str1.Length - num3)) { ++textDrawOffsetPosition; } if (str1.Length <= num3 || textDrawOffsetPosition < 0) { textDrawOffsetPosition = textDrawOffsetPosition > str1.Length - num3 ? 0 : str1.Length - num3; } else if (textDrawOffsetPosition > num3) { num3 = textDrawOffsetPosition; } var text1 = str1.Substring(textDrawOffsetPosition, str1.Length - num3); if (MaskingText) { var str2 = ""; for (var index = 0; index < filteredStringInput.Length; ++index) { str2 += "*"; } text1 = str2; } GuiData.spriteBatch.DrawString(font, text1, new Vector2(x + 2, y + num2), Color.White); var num4 = GuiData.active; if (filteredStringInput != "") { var length2 = Math.Min(cursorPosition - textDrawOffsetPosition, text1.Length); destinationRectangle.X = (int)(x + (double)font.MeasureString(text1.Substring(0, length2)).X) + 3; } else { destinationRectangle.X = x + 3; } destinationRectangle.Y = y + 2; destinationRectangle.Width = 1; destinationRectangle.Height = LINE_HEIGHT - 4; GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, FramesSelected % 60 < 40 ? Color.White : Color.Gray); return(filteredStringInput); }
public static string doTextBox(int myID, int x, int y, int width, int lines, string str, SpriteFont font) { string str1 = str; if (font == null) { font = GuiData.smallfont; } TextBox.BoxWasActivated = false; Rectangle tmpRect = GuiData.tmpRect; tmpRect.X = x; tmpRect.Y = y; tmpRect.Width = width; tmpRect.Height = lines * TextBox.LINE_HEIGHT; if (tmpRect.Contains(GuiData.getMousePoint())) { GuiData.hot = myID; } else if (GuiData.hot == myID) { GuiData.hot = -1; } if (GuiData.mouseWasPressed()) { if (GuiData.hot == myID) { if (GuiData.active == myID) { int num = GuiData.mouse.X - x; bool flag = false; for (int length = 1; length <= str.Length; ++length) { if ((double)font.MeasureString(str.Substring(0, length)).X > (double)num) { TextBox.cursorPosition = length - 1; break; } if (!flag) { TextBox.cursorPosition = str.Length; } } } else { GuiData.active = myID; TextBox.cursorPosition = str.Length; } } else if (GuiData.active == myID) { GuiData.active = -1; } } if (GuiData.active == myID) { GuiData.willBlockTextInput = true; str1 = TextBox.getStringInput(str1, GuiData.getKeyboadState(), GuiData.getLastKeyboadState()); KeyboardState keyboardState = GuiData.getKeyboadState(); int num; if (keyboardState.IsKeyDown(Keys.Enter)) { keyboardState = GuiData.getLastKeyboadState(); num = !keyboardState.IsKeyDown(Keys.Enter) ? 1 : 0; } else { num = 1; } if (num == 0) { TextBox.BoxWasActivated = true; GuiData.active = -1; } } ++TextBox.FramesSelected; tmpRect.X = x; tmpRect.Y = y; tmpRect.Width = width; tmpRect.Height = lines * TextBox.LINE_HEIGHT; GuiData.spriteBatch.Draw(Utils.white, tmpRect, GuiData.active == myID ? GuiData.Default_Lit_Backing_Color : (GuiData.hot == myID ? GuiData.Default_Selected_Color : GuiData.Default_Dark_Background_Color)); tmpRect.X += 2; tmpRect.Y += 2; tmpRect.Width -= 4; tmpRect.Height -= 4; GuiData.spriteBatch.Draw(Utils.white, tmpRect, GuiData.Default_Light_Backing_Color); float num1 = (float)(((double)TextBox.LINE_HEIGHT - (double)font.MeasureString(str1).Y) / 2.0); GuiData.spriteBatch.DrawString(font, str1, new Vector2((float)(x + 2), (float)y + num1), Color.White); if (GuiData.active == myID) { tmpRect.X = (int)((double)x + (double)font.MeasureString(str1.Substring(0, TextBox.cursorPosition)).X) + 3; tmpRect.Y = y + 2; tmpRect.Width = 1; tmpRect.Height = TextBox.LINE_HEIGHT - 4; GuiData.spriteBatch.Draw(Utils.white, tmpRect, TextBox.FramesSelected % 60 < 40 ? Color.White : Color.Gray); } return(str1); }
public void Draw(Action <int, Rectangle, SpriteBatch> DrawSection, SpriteBatch sb, Rectangle destination) { UpdateInput(destination); SetRenderTargetsToFrame(destination); var flag = destination.Contains(GuiData.getMousePoint()); var vector2_1 = GuiData.scrollOffset; var vector2_2 = new Vector2(destination.X, destination.Y - ScrollDown % PanelHeight); if (flag) { GuiData.scrollOffset = vector2_2; } var spriteBatch = GuiData.spriteBatch; var index1 = 0; var num1 = ScrollDown; while (num1 >= (double)PanelHeight) { num1 -= PanelHeight; ++index1; } var num2 = 0; if (ScrollDown % (double)PanelHeight != 0.0) { GuiData.spriteBatch = fragmentBatch; RenderToTarget(DrawSection, AboveFragment, index1, new Rectangle(0, 0, destination.Width, PanelHeight)); var height = PanelHeight - (int)(ScrollDown % (double)PanelHeight); var destinationRectangle = new Rectangle(destination.X, destination.Y, destination.Width, height); var rectangle = new Rectangle(0, PanelHeight - destinationRectangle.Height, destination.Width, height); sb.Draw(AboveFragment, destinationRectangle, rectangle, Color.White); num2 += height; ++index1; } GuiData.spriteBatch = spriteBatch; if (flag) { GuiData.scrollOffset = vector2_1; } var index2 = index1; var rectangle1 = new Rectangle(destination.X, destination.Y + num2, destination.Width, PanelHeight); while (num2 + PanelHeight < destination.Height && index2 < NumberOfPanels) { DrawSection(index2, rectangle1, sb); ++index2; num2 += PanelHeight; rectangle1.Y = destination.Y + num2; } vector2_2 = new Vector2(destination.X, rectangle1.Y); if (flag) { GuiData.scrollOffset = vector2_2; } if (index2 < NumberOfPanels && destination.Height - num2 > 0) { GuiData.spriteBatch = fragmentBatch; RenderToTarget(DrawSection, BelowFragment, index2, new Rectangle(0, 0, destination.Width, PanelHeight)); var height = destination.Height - num2; var destinationRectangle = new Rectangle(destination.X, rectangle1.Y, destination.Width, height); var rectangle2 = new Rectangle(0, 0, destination.Width, height); sb.Draw(BelowFragment, destinationRectangle, rectangle2, Color.White); var num3 = num2 + height; var num4 = index1 + 1; } GuiData.spriteBatch = spriteBatch; if (flag) { GuiData.scrollOffset = vector2_1; } if (!HasScrollBar) { return; } var width = 7; DrawScrollBar( new Rectangle(destination.X + destination.Width - width - 2, destination.Y, width, destination.Height - 1), width); }
public static int doFancyList(int myID, int x, int y, int width, int height, string[] text, int lastSelectedIndex, Color? selectedColor, bool HasDraggableScrollbar = false) { if (!selectedColor.HasValue) selectedColor = GuiData.Default_Selected_Color; var num1 = -1; wasActivated = false; var num2 = lastSelectedIndex; selectionWasChanged = false; var mousePos = GuiData.getMousePos(); var destinationRectangle = GuiData.tmpRect; destinationRectangle.X = x; destinationRectangle.Y = y; destinationRectangle.Width = width; destinationRectangle.Height = height; if (destinationRectangle.Contains(GuiData.getMousePoint())) { GuiData.hot = myID; scrollOffset += (int) GuiData.getMouseWheelScroll(); scrollOffset = Math.Max(0, Math.Min(scrollOffset, text.Length - (int) (height/18.0))); } else if (GuiData.hot == myID) GuiData.hot = -1; var num3 = Math.Max(0, Math.Min(scrollOffset, text.Length - (int) (height/18.0))); var num4 = HasDraggableScrollbar ? 4f : 2f; if (GuiData.hot == myID && (!HasDraggableScrollbar || mousePos.X < x + width - 2.0*num4)) { for (var index = 0; index < text.Length; ++index) { if (mousePos.Y >= y + index*18.0 && mousePos.Y <= y + (index + 1)*18.0 && mousePos.Y < (double) (y + height)) { num1 = index + num3; wasActivated = true; } } } if (num1 != -1 && num1 != lastSelectedIndex && GuiData.mouseLeftUp()) lastSelectedIndex = num1; destinationRectangle.X += 2; destinationRectangle.Width -= 4; destinationRectangle.Y += 2; destinationRectangle.Height -= 4; var position = new Vector2(destinationRectangle.X, destinationRectangle.Y); destinationRectangle.Height = 18; for (var index = num3; index < text.Length; ++index) { GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, lastSelectedIndex == index ? selectedColor.Value : (num1 == index ? selectedColor.Value*0.45f : GuiData.Default_Dark_Neutral_Color)); var scale = GuiData.UITinyfont.MeasureString(text[index]); scale.X = scale.X <= (double) (width - 4) ? 1f : (width - 4)/scale.X; scale.Y = scale.Y <= 18.0 ? 1f : 14f/scale.Y; scale.X = Math.Min(scale.X, scale.Y); scale.Y = Math.Min(scale.X, scale.Y); GuiData.spriteBatch.DrawString(GuiData.UITinyfont, text[index], position, Color.White, 0.0f, Vector2.Zero, scale, SpriteEffects.None, 0.5f); position.Y += 18f; destinationRectangle.Y += 18; if (position.Y > (double) (y + height - 4)) break; } if (text.Length*18.0 > height) { var num5 = num4; var num6 = height/(text.Length*18f)*height; height -= 4; var num7 = -height + (float) ((height - (double) num6)*(num3/((text.Length*18.0 - height)/18.0))); destinationRectangle.X = (int) (position.X + (double) width - (HasDraggableScrollbar ? 2.0 : 3.0)*num5 - 2.0); destinationRectangle.Y = (int) (position.Y + (double) num7 + 2.0); destinationRectangle.Height = (int) num6; destinationRectangle.Width = (int) num5; if (!HasDraggableScrollbar) GuiData.spriteBatch.Draw(Utils.white, destinationRectangle, scrollBarColor); else scrollOffset = (int) (ScrollBar.doVerticalScrollBar(myID + 101, destinationRectangle.X, y, destinationRectangle.Width, height, (int) (text.Length*18.0), num3*18f)/18.0); } if (lastSelectedIndex != num2) selectionWasChanged = true; return lastSelectedIndex; }