public ScrollableListBox(int width = 200, int height = 200) : base(width, height) { ScrollArea = new GuiScrollableArea(Width, Height); ScrollArea.Align = GuiAlignment.Full; ScrollArea.ScrollMode = ScrollMode.VerticalOnly; ListBox = new GuiListBox <T>(0, 0, width - (int)GUI.skin.verticalScrollbar.fixedWidth); ListBox.AutoSize = true; Add(ScrollArea); ScrollArea.Add(ListBox); }
public FramedListBox(int width = 200, int height = 200, string title = "") : base(width, height) { this.WindowStyle = title == "" ? GuiWindowStyle.Normal : GuiWindowStyle.Titled; Title = title; var scrollArea = new GuiScrollableArea(Width, Height); scrollArea.Align = GuiAlignment.Full; scrollArea.ScrollMode = ScrollMode.None; ListBox = new GuiListBox <T>(0, 0); ListBox.Align = GuiAlignment.Full; Add(scrollArea); scrollArea.Add(ListBox); }
/** Creates slots based on the number of slots in the characters inventory */ private void Sync() { Invalidate(); inventoryScrollArea.Clear(); if (Source == null) { return; } slots = new GuiItemSlot[Source.Count]; for (int index = 0; index < Source.Count; index++) { slots[index] = new GuiItemSlot((int)(index % COLUMNS) * SLOT_WIDTH, (int)(index / COLUMNS) * SLOT_HEIGHT, Source[index]); inventoryScrollArea.Add(slots[index]); } inventoryScrollArea.ContentsScrollRect.height = ((int)Math.Ceiling((float)(Source.Count / COLUMNS))) * SLOT_HEIGHT; }
public EditPartyState(MDRParty party = null, bool createInsteadOfEdit = false) : base("Edit Party State") { var windowTitle = createInsteadOfEdit ? "Create Party" : "Edit Party"; window = new GuiWindow(600, 520, windowTitle); window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow"); window.Background.Color = new Color(0.4f, 0.42f, 0.62f); characterSlotsPanel = new GuiPanel(500, 110); characterSlotsPanel.Color = Color.clear; characterSlotsPanel.Align = GuiAlignment.Top; window.Add(characterSlotsPanel); characterSlot = new GuiCharacterSlot[4]; for (int lp = 0; lp < 4; lp++) { var slot = new GuiCharacterSlot(); slot.Tag = lp + 1; characterSlot[lp] = slot; characterSlotsPanel.Add(slot, 0, 10); characterSlotsPanel.PositionComponentToColumns(slot, lp + 1, 4, 100); characterSlot[lp].OnDDContentChanged += delegate { applyToParty(slot.Tag - 1); refreshUnassignedCharacters(); }; } unassignedCharacters = new GuiCharacterGrid(true); unassignedCharacters.DragDropEnabled = true; unassignedCharacters.OnCreateNewCharacter += delegate { refreshUI(); }; unassignedCharactersScrollArea = new GuiScrollableArea(550 + 21, 310, ScrollMode.VerticalOnly); unassignedCharactersScrollArea.Add(unassignedCharacters); var frame = GuiWindow.CreateFrame(unassignedCharactersScrollArea, "", GuiWindowStyle.ThinTransparent); frame.Color = new Color(0.1f, 0.1f, 0.1f); window.Add(frame, 0, -46, true); var unusedCaption = new GuiLabel("<B>Available Heroes</B>", (int)window.ContentsBounds.width + 10, 24); unusedCaption.EnableBackground = true; unusedCaption.TextAlign = TextAnchor.MiddleCenter; unusedCaption.Color = Color.Lerp(Colors.BackgroundRed, Color.black, 0.5f); unusedCaption.FauxEdge = true; unusedCaption.FontColor = new Color(1, 1, 1, 0.9f); unusedCaption.FontSize = 18; window.Add(unusedCaption, 0, frame.Y - 15); doneButton = new GuiButton("Done"); window.Add(doneButton, 0, -10); dispandButton = new GuiButton("Dispand"); UIStyle.RedWarning(dispandButton); window.Add(dispandButton, 0, -10); window.PositionComponentToColumns(dispandButton, 1, 2, 100); window.PositionComponentToColumns(doneButton, 2, 2, 100); doneButton.OnMouseClicked += delegate { applyToParty(); Engine.PopState(); }; dispandButton.OnMouseClicked += delegate { party.Dispand(); Engine.PopState(); }; Party = party; Add(window, 0, 0); }