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 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; }