Esempio n. 1
0
        public SelectPartyState(bool allowCreateParty = false)
            : base("SelectPartyState")
        {
            Util.Assert(CoM.CharacterList != null, "Select Party State requires character list to be created before initialization.");

            _allowCreateParty = allowCreateParty;

            GuiWindow window = new GuiWindow(GuiPartySpan.WIDTH + 40, 400);

            window.WindowStyle       = GuiWindowStyle.Titled;
            window.Background.Sprite = ResourceManager.GetSprite("Gui/InnerWindow");
            window.Background.Color  = Colors.BackgroundGray;
            window.Title             = "Select Party";
            Add(window, 0, 100);

            partyList       = new GuiScrollableArea(100, 100, ScrollMode.VerticalOnly);
            partyList.Align = GuiAlignment.Full;
            window.Add(partyList);

            GuiWindow buttonsWindow = new GuiWindow(500, 80);

            buttonsWindow.Y = (int)window.Bounds.yMax - 5;
            Add(buttonsWindow, 0);

            GuiButton BackButton = new GuiButton("Back");

            buttonsWindow.Add(BackButton, 0, 0);

            BackButton.OnMouseClicked += delegate {
                Engine.PopState();
            };
        }
Esempio n. 2
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);
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
        /** Create the store ui */
        //todo: remove sizes
        public GuiStore(MDRStore store, int width = 800, int height = 600)
            : base(width, height)
        {
            int splitWidth = (width / 2) + 50;

            const int HEADER_HEIGHT = 50;

            WindowStyle         = GuiWindowStyle.ThinTransparent;
            StoreSelectedItemID = -1;
            Store           = store;
            CanReceiveFocus = true;
            DragDropEnabled = true;

            // -----------------------------------------
            // Main areas

            var mainArea = new GuiContainer(0, (int)ContentsBounds.height - HEADER_HEIGHT);

            mainArea.Align = GuiAlignment.Bottom;

            // -----------------------------------------
            // Header

            var headerArea = new GuiContainer((int)ContentsBounds.width, HEADER_HEIGHT);

            headerArea.EnableBackground = true;
            headerArea.Style            = Engine.GetStyleCopy("Frame");
            headerArea.Y     -= 4;
            headerArea.X     -= 4;
            headerArea.Width += 8;

            modeButtons = new GuiRadioButtonGroup();
            modeButtons.AddItem("Buy");
            modeButtons.AddItem("Sell");
            modeButtons.ButtonSize       = new Vector2(120, 30);
            modeButtons.ButtonSpacing    = 50;
            modeButtons.EnableBackground = false;
            headerArea.Add(modeButtons, 0, 0, true);

            modeButtons.OnValueChanged += delegate {
                _mode = (StoreMode)modeButtons.SelectedIndex;
                updateStoreMode();
            };

            Add(headerArea);
            Add(mainArea);

            // -----------------------------------------
            // Item Info Area

            GuiPanel itemInfoPanel = new GuiPanel((int)ContentsBounds.width - splitWidth);

            itemInfoPanel.Align            = GuiAlignment.Right;
            itemInfoPanel.EnableBackground = false;
            mainArea.Add(itemInfoPanel, -1, 1, true);

            itemInfoBackground       = new GuiImage(0, 0, ResourceManager.GetSprite("Gui/InnerWindow"));
            itemInfoBackground.Align = GuiAlignment.Full;
            itemInfoBackground.Color = Colors.StoreItemInfoBackgroundColor;
            itemInfoPanel.Add(itemInfoBackground);

            SelectedItemInfo = new GuiItemToolTip();
            SelectedItemInfo.EnableBackground = false;
            SelectedItemInfo.Align            = GuiAlignment.Full;
            SelectedItemInfo.ShowAllInfo      = true;
            itemInfoPanel.Add(SelectedItemInfo);

            // -----------------------------------------
            // Item Buy Area

            buyItemArea       = new GuiContainer(splitWidth, (int)ContentsBounds.height);
            buyItemArea.Align = GuiAlignment.Left;
            mainArea.Add(buyItemArea);

            itemListingScrollArea = new GuiScrollableArea(buyItemArea.Width, buyItemArea.Height, ScrollMode.VerticalOnly);
            buyItemArea.Add(itemListingScrollArea);

            filterItemsToggle = new GuiToggleButton();
            filterItemsToggle.OnValueChanged += delegate {
                ShowOnlyUsableItems = filterItemsToggle.Value;
            };
            mainArea.Add(filterItemsToggle, -10, -10);
            filterItemsToggle.Visible = false;

            buyButton = new GuiButton("Buy");
            buyButton.OnMouseClicked += DoBuy;
            itemInfoPanel.Add(buyButton, 0, -30);

            notEnoughGold           = new GuiLabel("No enough coins");
            notEnoughGold.FontColor = new Color(0.5f, 0.5f, 0.5f, 0.9f);
            notEnoughGold.Visible   = false;
            itemInfoPanel.Add(notEnoughGold, 0, -56);

            // -----------------------------------------
            // item Sell area

            sellItemArea         = new GuiSellItemArea((int)mainArea.ContentsBounds.width - splitWidth, (int)mainArea.ContentsBounds.height, store);
            sellItemArea.Align   = GuiAlignment.Right;
            sellItemArea.OnSell += delegate {
                Mode = StoreMode.Buy;
            };
            mainArea.Add(sellItemArea);

            // -----------------------------------------

            CoM.Party.OnSelectedChanged += createStoreListings;
            store.OnInventoryChanged    += createStoreListings;

            updateStoreMode();
            createStoreListings();
        }
Esempio n. 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);
        }