/** Creates buttons for each party, allowing the user to select one of them. */ private void updatePartyList() { CoM.CleanParties(); partyList.Clear(); int yPos = 0; foreach (MDRParty party in CoM.PartyList) { var partyButton = new GuiPartySpan(party) { X = 0, Y = yPos }; partyButton.OnMouseClicked += delegate { selectParty(partyButton.Party); }; partyList.Add(partyButton); yPos += partyButton.Height; } if (AllowCreateParty) { //var createButton = new GuiButton("Create New Party", GuiPartySpan.WIDTH, GuiPartySpan.HEIGHT) { X = 0, Y = yPos }; var createButton = new GuiPartySpan(null) { X = 0, Y = yPos }; createButton.Editable = false; createButton.Caption = "Create New Party"; createButton.Color = Color.gray; createButton.OnMouseClicked += delegate { var party = MDRParty.Create(); CoM.PartyList.Add(party); var state = new EditPartyState(party, true); Engine.PushState(state); }; partyList.Add(createButton); yPos += createButton.Height; } partyList.FitToChildren(); }
public AboutMenuState() : base("AboutState") { var window = new GuiWindow(420, 400, "About"); Add(window, 0, 0); window.Add(Util.CreateBackButton("Done"), 0, -10); window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow"); window.Background.Color = new Color(0.4f, 0.42f, 0.62f); var scrollBox = new GuiScrollableArea((int)window.ContentsFrame.width, (int)window.ContentsFrame.height - 40, ScrollMode.VerticalOnly); window.Add(scrollBox); var label = new GuiLabel(0, 20, AboutString, (int)window.ContentsBounds.width - 30); label.WordWrap = true; label.TextAlign = TextAnchor.UpperCenter; scrollBox.Add(label); scrollBox.FitToChildren(); }
/** * Creates ui elements to configure each settings in given group. * * Returns a GuiComponent containing the controls. */ private GuiComponent CreateUIFromSettingsGroup(SettingsGroup group) { GuiContainer result = new GuiScrollableArea(WINDOW_WIDTH - 50, WINDOW_HEIGHT - 150) { Y = 50 }; result.Name = group.Name; int atY = 10; var binding = (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly); foreach (var property in group.GetType().GetProperties(binding)) { var attribute = getAttribute <SettingAttribute>(property, SettingAttribute.Default); var divider = getAttribute <SettingDivider>(property); // filter out some properties if (property.Name == "Item") { continue; } if (!property.CanRead) { continue; } if (attribute.Ignore) { continue; } GuiLabeledComponent control = CreateControl(group, property); if (control == null) { Trace.Log("No suitable control found for property " + property.Name + " of type " + property.PropertyType); continue; } if (group.isDisabled(property.Name)) { if (control is GuiToggleButton) { (control as GuiToggleButton).Value = false; } control.SelfEnabled = false; } if (divider != null) { string dividerText = divider.Name; var dividerControl = new GuiLabel(dividerText); dividerControl.TextAlign = TextAnchor.MiddleLeft; dividerControl.FontColor = new Color(0.75f, 0.75f, 0.75f); result.Add(dividerControl, 20, atY + 3); atY += (dividerText == "") ? 5 : 30; } // apply attributes if (control.Enabled) { control.LabelColor = attribute.Color; } else { control.LabelColor = Color.Lerp(attribute.Color, Color.gray, 0.75f); } control.LabelText = attribute.DisplayName ?? property.Name; result.Add(control, 200, atY); int spacing = Util.ClampInt(control.Height + 10, 30, 999); atY += spacing; } result.FitToChildren(); result = GuiWindow.CreateFrame(result); (result as GuiWindow).WindowStyle = GuiWindowStyle.Transparent; result.Color = new Color(0.25f, 0.25f, 0.25f, 0.5f); result.FitToChildren(); result.Width = WINDOW_WIDTH - 40; return(result); }