Beispiel #1
0
        override public void Update()
        {
            bool resetScroll = false;

            if (traitScrollArea == null)
            {
                resetScroll = true;
            }
            else
            {
                scrollPos = traitScrollArea.GetScrollPosition();
            }


            // Border
            UIElement ui = new UIElement();

            ui.SetLocation(UIScaler.GetHCenter(-18), 0, 36, 30);
            new UIElementBorder(ui);

            // Title
            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(-10), 0, 20, 1);
            ui.SetText(_title);

            // Sort Buttons
            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(15.5f), 1, 1, 1);
            ui.SetTextPadding(0);
            if (alphaSort)
            {
                ui.SetText("1", Color.white);
                ui.SetBGColor(Color.black);
            }
            else
            {
                if (reverseSort)
                {
                    ui.SetText("9", Color.black);
                }
                else
                {
                    ui.SetText("1", Color.black);
                }
                ui.SetBGColor(Color.white);
            }
            ui.SetButton(SortNumerical);
            new UIElementBorder(ui);

            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(16.5f), 1, 1, 1);
            ui.SetTextPadding(0);
            if (alphaSort)
            {
                if (reverseSort)
                {
                    ui.SetText("Z", Color.black);
                }
                else
                {
                    ui.SetText("A", Color.black);
                }
                ui.SetBGColor(Color.white);
            }
            else
            {
                ui.SetText("A", Color.white);
                ui.SetBGColor(Color.black);
            }
            ui.SetButton(SortAlpha);
            new UIElementBorder(ui);

            traitScrollArea = new UIElementScrollVertical();
            traitScrollArea.SetLocation(UIScaler.GetHCenter(-17.5f), 2, 13, 25);
            new UIElementBorder(traitScrollArea);

            float offset = 0;

            foreach (TraitGroup tg in traitData)
            {
                ui = new UIElement(traitScrollArea.GetScrollTransform());
                ui.SetLocation(0, offset, 12, 1);
                ui.SetText(tg.GetName(), Color.black);
                ui.SetTextAlignment(TextAnchor.MiddleLeft);
                ui.SetBGColor(new Color(0.5f, 1, 0.5f));
                offset += 1.05f;

                bool noneSelected = tg.NoneSelected();

                foreach (string s in tg.traits.Keys)
                {
                    TraitGroup tmpGroup = tg;
                    string     tmpTrait = s;
                    ui = new UIElement(traitScrollArea.GetScrollTransform());
                    ui.SetLocation(0, offset, 11, 1);
                    if (tg.traits[s].selected)
                    {
                        ui.SetBGColor(Color.white);
                        ui.SetButton(delegate { SelectTrait(tmpGroup, tmpTrait); });
                    }
                    else
                    {
                        int itemCount = 0;
                        foreach (SelectionItemTraits item in tg.traits[s].items)
                        {
                            bool display = true;
                            foreach (TraitGroup g in traitData)
                            {
                                display &= g.ActiveItem(item);
                            }
                            if (display)
                            {
                                itemCount++;
                            }
                        }
                        if (itemCount > 0)
                        {
                            if (noneSelected)
                            {
                                ui.SetBGColor(Color.white);
                            }
                            else
                            {
                                ui.SetBGColor(Color.grey);
                            }
                            ui.SetButton(delegate { SelectTrait(tmpGroup, tmpTrait); });
                        }
                        else
                        {
                            ui.SetBGColor(new Color(0.5f, 0, 0));
                        }
                    }
                    ui.SetText(s, Color.black);

                    // Strikethrough
                    if (tg.traits[s].excluded)
                    {
                        ui = new UIElement(traitScrollArea.GetScrollTransform());
                        ui.SetLocation(0.2f, offset + 0.5f, 10.6f, 0.06f);
                        ui.SetBGColor(Color.black);
                        ui.SetButton(delegate { SelectTrait(tmpGroup, tmpTrait); });
                    }

                    // Exclude
                    ui = new UIElement(traitScrollArea.GetScrollTransform());
                    ui.SetLocation(11, offset, 1, 1);
                    ui.SetBGColor(Color.red);
                    ui.SetTextPadding(0);
                    ui.SetText("X", Color.black);
                    ui.SetButton(delegate { ExcludeTrait(tmpGroup, tmpTrait, true); });

                    offset += 1.05f;
                }
                offset += 1.05f;
            }
            traitScrollArea.SetScrollSize(offset);
            if (!resetScroll)
            {
                traitScrollArea.SetScrollPosition(scrollPos);
            }

            DrawItemList();

            // Cancel button
            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(-4.5f), 28, 9, 1);
            ui.SetBGColor(new Color(0.03f, 0.0f, 0f));
            ui.SetText(CommonStringKeys.CANCEL);
            ui.SetButton(delegate
            {
                Destroyer.Dialog();
                if (callAfterCancel)
                {
                    _call(null);
                }
            });
            new UIElementBorder(ui);
        }
Beispiel #2
0
        protected void Update()
        {
            bool resetScroll = false;

            if (traitScrollArea == null)
            {
                resetScroll = true;
            }
            else
            {
                scrollPos = traitScrollArea.GetScrollPosition();
            }


            // Border
            UIElement ui = new UIElement();

            ui.SetLocation(UIScaler.GetHCenter(-18), 0, 36, 30);
            new UIElementBorder(ui);

            // Title
            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(-10), 0, 20, 1);
            ui.SetText(_title);

            traitScrollArea = new UIElementScrollVertical();
            traitScrollArea.SetLocation(UIScaler.GetHCenter(-17.5f), 2, 13, 25);
            new UIElementBorder(traitScrollArea);

            float offset = 0;

            foreach (TraitGroup tg in traitData)
            {
                ui = new UIElement(traitScrollArea.GetScrollTransform());
                ui.SetLocation(0, offset, 12, 1);
                ui.SetText(tg.GetName(), Color.black);
                ui.SetTextAlignment(TextAnchor.MiddleLeft);
                ui.SetBGColor(new Color(0.5f, 1, 0.5f));
                offset += 1.05f;

                bool noneSelected = tg.NoneSelected();

                foreach (string s in tg.traits.Keys)
                {
                    TraitGroup tmpGroup = tg;
                    string     tmpTrait = s;
                    ui = new UIElement(traitScrollArea.GetScrollTransform());
                    ui.SetLocation(0, offset, 12, 1);
                    if (tg.traits[s].selected)
                    {
                        ui.SetBGColor(Color.white);
                        ui.SetButton(delegate { SelectTrait(tmpGroup, tmpTrait); });
                    }
                    else
                    {
                        int itemCount = 0;
                        foreach (SelectionItemTraits item in tg.traits[s].items)
                        {
                            bool display = true;
                            foreach (TraitGroup g in traitData)
                            {
                                display &= g.ActiveItem(item);
                            }
                            if (display)
                            {
                                itemCount++;
                            }
                        }
                        if (itemCount > 0)
                        {
                            if (noneSelected)
                            {
                                ui.SetBGColor(Color.white);
                            }
                            else
                            {
                                ui.SetBGColor(Color.grey);
                            }
                            ui.SetButton(delegate { SelectTrait(tmpGroup, tmpTrait); });
                        }
                        else
                        {
                            ui.SetBGColor(new Color(0.5f, 0, 0));
                        }
                    }
                    ui.SetText(s, Color.black);
                    offset += 1.05f;
                }
                offset += 1.05f;
            }
            traitScrollArea.SetScrollSize(offset);
            if (!resetScroll)
            {
                traitScrollArea.SetScrollPosition(scrollPos);
            }

            DrawItemList();

            // Cancel button
            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(-4.5f), 28, 9, 1);
            ui.SetBGColor(new Color(0.03f, 0.0f, 0f));
            ui.SetText(CommonStringKeys.CANCEL);
            ui.SetButton(delegate { Destroyer.Dialog(); });
            new UIElementBorder(ui);
        }
Beispiel #3
0
        protected override void DrawItemList()
        {
            Game game = Game.Get();
            UIElementScrollVertical itemScrollArea = new UIElementScrollVertical();

            itemScrollArea.SetLocation(UIScaler.GetHCenter(-3.5f), 2, 21, 25);
            new UIElementBorder(itemScrollArea);


            List <SelectionItemTraits> toDisplay = new List <SelectionItemTraits>(traitItems.Values);

            if (alphaSort)
            {
                toDisplay = new List <SelectionItemTraits>(alphaTraitItems.Values);
            }
            if (reverseSort)
            {
                toDisplay.Reverse();
            }

            float offset  = 0;
            float xOffset = 0;
            float yOffset = 4;

            foreach (SelectionItemTraits item in toDisplay)
            {
                bool display = true;
                foreach (TraitGroup tg in traitData)
                {
                    display &= tg.ActiveItem(item);
                }

                if (!display)
                {
                    continue;
                }

                if (spriteCache.ContainsKey(item.GetKey()))
                {
                    if (20 - xOffset < spriteCache[item.GetKey()].width)
                    {
                        offset += yOffset;
                        xOffset = 0;
                    }
                    xOffset = DrawItem(item.GetKey(), itemScrollArea.GetScrollTransform(), offset, xOffset, out yOffset);
                }
                else
                {
                    if (xOffset > 0)
                    {
                        offset += yOffset;
                    }
                    xOffset = 0;
                    offset  = DrawItem(item, itemScrollArea.GetScrollTransform(), offset);
                }
            }
            if (xOffset != 0)
            {
                offset += yOffset;
            }
            itemScrollArea.SetScrollSize(offset);
        }
Beispiel #4
0
        virtual public void Update()
        {
            // Border
            UIElement ui = new UIElement();

            ui.SetLocation(UIScaler.GetHCenter(-11), 0, 22, 30);
            new UIElementBorder(ui);

            // Title
            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(-10), 0, 20, 1);
            ui.SetText(_title);

            // Sort Buttons
            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(8.5f), 1, 1, 1);
            if (alphaSort)
            {
                ui.SetText("1", Color.white);
                ui.SetBGColor(Color.black);
            }
            else
            {
                if (reverseSort)
                {
                    ui.SetText("9", Color.black);
                }
                else
                {
                    ui.SetText("1", Color.black);
                }
                ui.SetBGColor(Color.white);
            }
            ui.SetButton(SortNumerical);
            new UIElementBorder(ui);

            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(9.5f), 1, 1, 1);
            if (alphaSort)
            {
                if (reverseSort)
                {
                    ui.SetText("Z", Color.black);
                }
                else
                {
                    ui.SetText("A", Color.black);
                }
                ui.SetBGColor(Color.white);
            }
            else
            {
                ui.SetText("A", Color.white);
                ui.SetBGColor(Color.black);
            }
            ui.SetButton(SortAlpha);
            new UIElementBorder(ui);

            UIElementScrollVertical scrollArea = new UIElementScrollVertical();

            scrollArea.SetLocation(UIScaler.GetHCenter(-10.5f), 2, 21, 25);
            new UIElementBorder(scrollArea);

            List <SelectionItem> toDisplay = new List <SelectionItem>(items.Values);

            if (alphaSort)
            {
                toDisplay = new List <SelectionItem>(alphaItems.Values);
            }
            if (reverseSort)
            {
                toDisplay.Reverse();
            }

            int lineNum = 0;

            foreach (SelectionItem item in toDisplay)
            {
                // Print the name but select the key
                string key = item.GetKey();
                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(0, (lineNum * 1.05f), 20, 1);
                if (key != null)
                {
                    ui.SetButton(delegate { SelectItem(key); });
                }
                ui.SetBGColor(item.GetColor());
                ui.SetText(item.GetDisplay(), Color.black);
                lineNum++;
            }

            scrollArea.SetScrollSize(items.Count * 1.05f);

            // Cancel button
            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(-4.5f), 28, 9, 1);
            ui.SetBGColor(new Color(0.03f, 0.0f, 0f));
            ui.SetText(CommonStringKeys.CANCEL);
            ui.SetButton(delegate { Destroyer.Dialog(); });
            new UIElementBorder(ui);
        }