/** Creates window using the given object as a source. Window will be sized accordingly */ public static GuiWindow CreateFrame(GuiComponent source, string title = "", GuiWindowStyle style = GuiWindowStyle.Normal) { if (source == null) { throw new ArgumentNullException("source"); } GuiWindow frame = new GuiWindow(0, 0, title); frame.WindowStyle = style; frame.SizeForContent(source.Width, source.Height); frame.Add(source); frame.X = source.X; frame.Y = source.Y; source.X = 0; source.Y = 0; return(frame); }
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); }