Exemple #1
0
        /** Creates the listings for the store */
        protected void createStoreListings()
        {
            itemListingScrollArea.Clear();
            int yPos     = 0;
            int position = 0;

            foreach (MDRItem item in CoM.Items)
            {
                if (Store.GetQuantity(item) <= 0)
                {
                    continue;
                }
                if (item.CurseType != ItemCurseType.None)
                {
                    continue;
                }
                if (ShowOnlyUsableItems && (item.GetCanNotEquipItemReason(CoM.Party.Selected) != ""))
                {
                    continue;
                }
                GuiStoreListing listing = new GuiStoreListing(this, 0, 1 + yPos, item.ID, Store.SellPrice(item), Store.GetQuantity(item));
                listing.PositionIndex = position++;
                listing.Width         = (int)itemListingScrollArea.ContentsBounds.width;
                itemListingScrollArea.Add(listing);
                listing.Update();
                yPos += listing.Height;
                if (StoreSelectedItemID == -1)
                {
                    StoreSelectedItemID = listing.ItemID;
                }
            }
            itemListingScrollArea.ContentsScrollRect.height = yPos;
        }
Exemple #2
0
        /** 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();
        }
Exemple #3
0
        // todo: this has all kinds of problems with auto sizing
        public ModalNotificaionState(string title, string text, TextAnchor textAlignment = TextAnchor.MiddleCenter, int width = 400)
            : base(title)
        {
            Window.Width = width;
            GuiLabel Text = new GuiLabel("", (int)Window.ContentsBounds.width - 20);

            Text.WordWrap  = true;
            Text.TextAlign = textAlignment;
            Text.Caption   = text;

            Window.Height = Text.Height + 20 + 45 + 30;

            // Create scroll box for really large messages.
            if (Window.Height > width * 0.75f)
            {
                Text.Width    = width - 60;              // make room for scroller
                Window.Height = (int)(width * 0.75f);
                var scrollBox = new GuiScrollableArea((int)Window.ContentsFrame.width - 10, (int)Window.ContentsFrame.height - 60, ScrollMode.VerticalOnly)
                {
                    X = 10,
                    Y = 10
                };
                scrollBox.ContentsScrollRect.height = Text.Height + 40;
                scrollBox.Add(Text);
                Window.Add(scrollBox);
            }
            else
            {
                Window.Add(Text, 10, 15);
                // this is because sometimes the width estimation is wrong and text wraps incorrently without it.
                Text.Width += 8;
            }

            ConfirmationButton = new GuiButton("OK", 150, 30);
            ConfirmationButton.OnMouseClicked += delegate {
                Close();
            };
            Window.Add(ConfirmationButton, 0, -12);

            DefaultControl = ConfirmationButton;

            PositionComponent(Window, 0, 0);
        }
Exemple #4
0
        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();
        }
Exemple #5
0
        /**
         * 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);
        }