コード例 #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(); });
            new UIElementBorder(ui);
        }