コード例 #1
0
ファイル: UICards.cs プロジェクト: rakeshsingh07/POCTask
        private HashSet <Card> mSelectedCard = new HashSet <Card>(); //Getter  for Seledcted card

        //Set placeholder and careate Cards
        public void CreateCards(string name, Sprite sprite)
        {
            Widget placeHolder = m_Menu.Add("PlaceHolder") as Widget;
            Card   card        = m_CardTemplate.Duplicate(name) as Card;

            card.pImage = sprite;
            placeHolder.AddChild(card);
            card.SetPlaceholder(placeHolder.transform);
        }
コード例 #2
0
        public void AttachPanel(Widget p, Action onCancel)
        {
            if (panel != null)
            {
                throw new InvalidOperationException("Attempted to attach a panel to an open dropdown");
            }
            panel = p;

            // Mask to prevent any clicks from being sent to other widgets
            fullscreenMask              = new MaskWidget();
            fullscreenMask.Bounds       = new Rectangle(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height);
            fullscreenMask.OnMouseDown += mi => { Game.Sound.PlayNotification(ModRules, null, "Sounds", ClickSound, null); RemovePanel(); };
            if (onCancel != null)
            {
                fullscreenMask.OnMouseDown += _ => onCancel();
            }

            panelRoot = PanelRoot == null ? Ui.Root : Ui.Root.Get(PanelRoot);

            panelRoot.AddChild(fullscreenMask);

            var oldBounds = panel.Bounds;
            var panelY    = RenderOrigin.Y + Bounds.Height - panelRoot.RenderOrigin.Y;

            if (panelY + oldBounds.Height > Game.Renderer.Resolution.Height)
            {
                panelY -= (Bounds.Height + oldBounds.Height);
            }

            panel.Bounds = new Rectangle(
                RenderOrigin.X - panelRoot.RenderOrigin.X,
                panelY,
                oldBounds.Width,
                oldBounds.Height);
            panelRoot.AddChild(panel);

            var scrollPanel = panel as ScrollPanelWidget;

            if (scrollPanel != null)
            {
                scrollPanel.ScrollToSelectedItem();
            }
        }
コード例 #3
0
        public Widget LoadWidget(WidgetArgs args, Widget parent, MiniYamlNode node)
        {
            if (!args.ContainsKey("modData"))
            {
                args = new WidgetArgs(args)
                {
                    { "modData", modData }
                }
            }
            ;

            var widget = NewWidget(node.Key, args);

            if (parent != null)
            {
                parent.AddChild(widget);
            }

            if (node.Key.Contains("@"))
            {
                FieldLoader.LoadField(widget, "Id", node.Key.Split('@')[1]);
            }

            foreach (var child in node.Value.Nodes)
            {
                if (child.Key != "Children")
                {
                    FieldLoader.LoadField(widget, child.Key, child.Value.Value);
                }
            }

            widget.Initialize(args);

            foreach (var child in node.Value.Nodes)
            {
                if (child.Key == "Children")
                {
                    foreach (var c in child.Value.Nodes)
                    {
                        LoadWidget(args, widget, c);
                    }
                }
            }

            var logicNode = node.Value.Nodes.FirstOrDefault(n => n.Key == "Logic");
            var logic     = logicNode == null ? null : logicNode.Value.ToDictionary();

            args.Add("logicArgs", logic);

            widget.PostInit(args);

            args.Remove("logicArgs");

            return(widget);
        }
コード例 #4
0
        public PlayerProfileBadgesLogic(Widget widget, PlayerProfile profile, Func <int, int> negotiateWidth)
        {
            var showBadges = profile.Badges.Any();

            widget.IsVisible = () => showBadges;

            var badgeTemplate = widget.Get("BADGE_TEMPLATE");

            widget.RemoveChild(badgeTemplate);

            // Negotiate the label length that the tooltip will allow
            var maxLabelWidth     = 0;
            var templateIcon      = badgeTemplate.Get("ICON");
            var templateLabel     = badgeTemplate.Get <LabelWidget>("LABEL");
            var templateLabelFont = Game.Renderer.Fonts[templateLabel.Font];

            foreach (var badge in profile.Badges)
            {
                maxLabelWidth = Math.Max(maxLabelWidth, templateLabelFont.Measure(badge.Label).X);
            }

            widget.Bounds.Width = negotiateWidth(2 * templateLabel.Bounds.Left - templateIcon.Bounds.Right + maxLabelWidth);

            var badgeOffset = badgeTemplate.Bounds.Y;

            if (profile.Badges.Any())
            {
                badgeOffset += 3;
            }

            foreach (var badge in profile.Badges)
            {
                var b    = badgeTemplate.Clone();
                var icon = b.Get <BadgeWidget>("ICON");
                icon.Badge = badge;

                var label     = b.Get <LabelWidget>("LABEL");
                var labelFont = Game.Renderer.Fonts[label.Font];

                var labelText = WidgetUtils.TruncateText(badge.Label, widget.Bounds.Width - label.Bounds.X - icon.Bounds.X, labelFont);
                label.GetText = () => labelText;

                b.Bounds.Y = badgeOffset;
                widget.AddChild(b);

                badgeOffset += badgeTemplate.Bounds.Height;
            }

            if (badgeOffset > badgeTemplate.Bounds.Y)
            {
                badgeOffset += 5;
            }

            widget.Bounds.Height = badgeOffset;
        }
コード例 #5
0
 private Gui.Widgets.TextProgressBar CreateStatusBar(Widget AddTo, String Label, params String[] PercentageLabels)
 {
     return(AddTo.AddChild(new Gui.Widgets.TextProgressBar
     {
         AutoLayout = AutoLayout.DockTop,
         Label = Label,
         SegmentCount = 10,
         PercentageLabels = PercentageLabels,
         Font = "font8"
     }) as Gui.Widgets.TextProgressBar);
 }
コード例 #6
0
        public override void Construct()
        {
            Transparent = true;

            AddChild(CollapsedContents);
            CollapsedContents.AutoLayout  = AutoLayout.FloatBottom;
            CollapsedContents.Hidden      = Expanded;
            CollapsedContents.MinimumSize = new Point(MinimumSize.X, CollapsedHeight);

            AddChild(ExpandedContents);
            ExpandedContents.Hidden     = !Expanded;
            ExpandedContents.AutoLayout = AutoLayout.DockFill;

            CollapsedContents.AddChild(new Gui.Widgets.ImageButton
            {
                Background  = new Gui.TileReference("round-buttons", 3),
                MinimumSize = new Point(16, 16),
                MaximumSize = new Point(16, 16),
                OnClick     = (sender, args) =>
                {
                    ExpandedContents.Hidden  = false;
                    CollapsedContents.Hidden = true;
                    Expanded = true;
                    Root.SafeCall(OnExpansionChanged, this);
                    Invalidate();
                },
                OnLayout = (sender) =>
                {
                    sender.Rect = new Rectangle(CollapsedContents.Rect.Right - 16, CollapsedContents.Rect.Y, 16, 16);
                }
            });

            ExpandedContents.AddChild(new Gui.Widgets.ImageButton
            {
                Background  = new Gui.TileReference("round-buttons", 7),
                MinimumSize = new Point(16, 16),
                MaximumSize = new Point(16, 16),
                OnClick     = (sender, args) =>
                {
                    ExpandedContents.Hidden  = true;
                    CollapsedContents.Hidden = false;
                    Expanded = false;
                    Root.SafeCall(OnExpansionChanged, this);
                    Invalidate();
                },
                OnLayout = (sender) =>
                {
                    sender.Rect = new Rectangle(ExpandedContents.Rect.Right - 16, ExpandedContents.Rect.Y, 16, 16);
                }
            });

            base.Construct();
        }
コード例 #7
0
        void RebuildModList()
        {
            modList.RemoveChildren();

            var width       = modTemplate.Bounds.Width;
            var height      = modTemplate.Bounds.Height;
            var innerMargin = modTemplate.Bounds.Left;
            var outerMargin = (modList.Bounds.Width - Math.Min(5, allMods.Length) * width - 4 * innerMargin) / 2;
            var stride      = width + innerMargin;

            for (var i = 0; i < 5; i++)
            {
                var j = i + modOffset;
                if (j >= allMods.Length)
                {
                    break;
                }

                var mod = allMods[j];

                var item = modTemplate.Clone() as ButtonWidget;
                item.Bounds        = new Rectangle(outerMargin + i * stride, 0, width, height);
                item.IsHighlighted = () => selectedMod == mod;
                item.OnClick       = () => SelectMod(mod);
                item.OnDoubleClick = () => LoadMod(mod);
                item.OnKeyPress    = e =>
                {
                    if (e.MultiTapCount == 2)
                    {
                        LoadMod(mod);
                    }
                    else
                    {
                        SelectMod(mod);
                    }
                };

                item.TooltipText = mod.Title;

                if (j < 9)
                {
                    item.Key = new Hotkey((Keycode)((int)Keycode.NUMBER_1 + j), Modifiers.None);
                }

                Sprite logo = null;
                logos.TryGetValue(mod.Id, out logo);
                item.Get <RGBASpriteWidget>("MOD_LOGO").GetSprite = () => logo;
                item.Get("MOD_NO_LOGO").IsVisible = () => logo == null;

                modList.AddChild(item);
            }
        }
コード例 #8
0
        static void BindHotkeyPref(HotkeyDefinition hd, HotkeyManager manager, Widget template, Widget parent)
        {
            var key = template.Clone() as Widget;

            key.Id        = hd.Name;
            key.IsVisible = () => true;

            key.Get <LabelWidget>("FUNCTION").GetText = () => hd.Description + ":";

            var textBox = key.Get <HotkeyEntryWidget>("HOTKEY");

            textBox.Key         = manager[hd.Name].GetValue();
            textBox.OnLoseFocus = () => manager.Set(hd.Name, textBox.Key);
            parent.AddChild(key);
        }
コード例 #9
0
        public ButtonTooltipLogic(Widget widget, ButtonWidget button)
        {
            var label      = widget.Get <LabelWidget>("LABEL");
            var font       = Game.Renderer.Fonts[label.Font];
            var text       = button.GetTooltipText();
            var labelWidth = font.Measure(text).X;
            var key        = button.Key.GetValue();

            label.GetText       = () => text;
            label.Bounds.Width  = labelWidth;
            widget.Bounds.Width = 2 * label.Bounds.X + labelWidth;

            if (key.IsValid())
            {
                var hotkey = widget.Get <LabelWidget>("HOTKEY");
                hotkey.Visible = true;

                var hotkeyLabel = "({0})".F(key.DisplayString());
                hotkey.GetText  = () => hotkeyLabel;
                hotkey.Bounds.X = labelWidth + 2 * label.Bounds.X;

                widget.Bounds.Width = hotkey.Bounds.X + label.Bounds.X + font.Measure(hotkeyLabel).X;
            }

            var desc = button.GetTooltipDesc();

            if (!string.IsNullOrEmpty(desc))
            {
                var descTemplate = widget.Get <LabelWidget>("DESC");
                widget.RemoveChild(descTemplate);

                var descFont   = Game.Renderer.Fonts[descTemplate.Font];
                var descWidth  = 0;
                var descOffset = descTemplate.Bounds.Y;
                foreach (var line in desc.Split(new[] { "\\n" }, StringSplitOptions.None))
                {
                    descWidth = Math.Max(descWidth, descFont.Measure(line).X);
                    var lineLabel = (LabelWidget)descTemplate.Clone();
                    lineLabel.GetText  = () => line;
                    lineLabel.Bounds.Y = descOffset;
                    widget.AddChild(lineLabel);
                    descOffset += descTemplate.Bounds.Height;
                }

                widget.Bounds.Width   = Math.Max(widget.Bounds.Width, descTemplate.Bounds.X * 2 + descWidth);
                widget.Bounds.Height += descOffset - descTemplate.Bounds.Y + descTemplate.Bounds.X;
            }
        }
コード例 #10
0
ファイル: ServerListLogic.cs プロジェクト: CombinE88/OpenRA
        void RefreshServerListInner(List <GameServer> games)
        {
            ScrollItemWidget nextServerRow = null;
            List <Widget>    rows          = null;

            if (games != null)
            {
                rows = LoadGameRows(games, out nextServerRow);
            }

            Game.RunAfterTick(() =>
            {
                serverList.RemoveChildren();
                SelectServer(null);

                if (games == null)
                {
                    searchStatus = SearchStatus.Failed;
                    return;
                }

                if (!rows.Any())
                {
                    searchStatus = SearchStatus.NoGames;
                    return;
                }

                searchStatus = SearchStatus.Hidden;

                // Search for any unknown maps
                if (Game.Settings.Game.AllowDownloading)
                {
                    modData.MapCache.QueryRemoteMapDetails(services.MapRepository, games.Where(g => !Filtered(g)).Select(g => g.Map));
                }

                foreach (var row in rows)
                {
                    serverList.AddChild(row);
                }

                if (nextServerRow != null)
                {
                    nextServerRow.OnClick();
                }

                playerCount = games.Sum(g => g.Players);
            });
        }
コード例 #11
0
        public SimpleTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, Func <string> getText)
        {
            var label   = widget.Get <LabelWidget>("LABEL");
            var spacing = widget.Get("LINE_HEIGHT");

            widget.RemoveChildren();

            var font = Game.Renderer.Fonts[label.Font];
            var horizontalPadding = label.Bounds.Width - widget.Bounds.Width;

            if (horizontalPadding <= 0)
            {
                horizontalPadding = 2 * label.Bounds.X;
            }

            var cachedText = "";

            tooltipContainer.BeforeRender = () =>
            {
                var text = getText();
                if (text == cachedText)
                {
                    return;
                }

                var lines     = text.Split('\n');
                var textWidth = font.Measure(text).X;

                // Set up label widgets
                widget.RemoveChildren();
                var bottom = 0;
                for (var i = 0; i < lines.Length; i++)
                {
                    var line     = (LabelWidget)label.Clone();
                    var lineText = lines[i];
                    line.Bounds.Y    += spacing.Bounds.Y + i * spacing.Bounds.Height;
                    line.Bounds.Width = textWidth;
                    line.GetText      = () => lineText;
                    widget.AddChild(line);
                    bottom = line.Bounds.Y + line.Bounds.Height;
                }

                widget.Bounds.Width  = horizontalPadding + textWidth;
                widget.Bounds.Height = bottom + spacing.Bounds.Y;
                cachedText           = text;
            };
        }
コード例 #12
0
ファイル: WidgetLoader.cs プロジェクト: zhangolove/OpenRA
        public Widget LoadWidget(WidgetArgs args, Widget parent, MiniYamlNode node)
        {
            if (!args.ContainsKey("modRules"))
            {
                args = new WidgetArgs(args)
                {
                    { "modRules", modData.DefaultRules }
                }
            }
            ;

            var widget = NewWidget(node.Key, args);

            if (parent != null)
            {
                parent.AddChild(widget);
            }

            if (node.Key.Contains("@"))
            {
                FieldLoader.LoadField(widget, "Id", node.Key.Split('@')[1]);
            }

            foreach (var child in node.Value.Nodes)
            {
                if (child.Key != "Children")
                {
                    FieldLoader.LoadField(widget, child.Key, child.Value.Value);
                }
            }

            widget.Initialize(args);

            foreach (var child in node.Value.Nodes)
            {
                if (child.Key == "Children")
                {
                    foreach (var c in child.Value.Nodes)
                    {
                        LoadWidget(args, widget, c);
                    }
                }
            }

            widget.PostInit(args);
            return(widget);
        }
コード例 #13
0
        private static bool LoadMovieHarmony(GauntletMovie __instance, Widget ____movieRootNode)
        {
            var movie = Instance.MovieRequested(__instance.MovieName);

            if (movie == null)
            {
                return(true);
            }

            var widgetCreationData = new WidgetCreationData(__instance.Context, __instance.WidgetFactory);

            widgetCreationData.AddExtensionData(__instance);
            RootViewProperty.SetValue(__instance, WidgetInstantiationResultDatabindingExtension.GetGauntletView(movie.Instantiate(widgetCreationData)));
            ____movieRootNode.AddChild(__instance.RootView.Target);
            __instance.RootView.RefreshBindingWithChildren();
            return(false);
        }
コード例 #14
0
        public void AddChoice(String Option, Action Callback)
        {
            ChoicePanel.AddChild(new Gui.Widgets.Button()
            {
                Text               = Option,
                MinimumSize        = new Point(0, 20),
                AutoLayout         = AutoLayout.DockTop,
                ChangeColorOnHover = true,
                WrapText           = true,
                OnClick            = (sender, args) =>
                {
                    //Output("> " + sender.Text + "\n");
                    ChoicePanel.Clear();
                    ChoicePanel.Invalidate();

                    Callback();
                }
            });
        }
コード例 #15
0
ファイル: IntroLogic.cs プロジェクト: spooky/KKnD
        public IntroLogic(Widget widget, World world, ModData modData)
        {
            if (state != 0)
            {
                return;
            }

            this.widget  = widget;
            this.world   = world;
            this.modData = modData;

            widget.AddChild(player = new VbcPlayerWidget());

            player.Bounds = new Rectangle(0, 0, Game.Renderer.Resolution.Width, Game.Renderer.Resolution.Height);

            musicPlayList = world.WorldActor.Trait <MusicPlaylist>();
            song          = musicPlayList.CurrentSong();
            musicPlayList.Stop();
        }
コード例 #16
0
        ButtonWidget AddButton(string id, string text)
        {
            var button     = buttonTemplate.Clone() as ButtonWidget;
            var lastButton = buttons.LastOrDefault();

            if (lastButton != null)
            {
                button.Bounds.X = lastButton.Bounds.X + buttonStride.X;
                button.Bounds.Y = lastButton.Bounds.Y + buttonStride.Y;
            }

            button.Id         = id;
            button.IsDisabled = () => leaving;
            button.GetText    = () => text;
            buttonContainer.AddChild(button);
            buttons.Add(button);

            return(button);
        }
コード例 #17
0
        void BindHotkeyPref(HotkeyDefinition hd, Widget template, Widget parent)
        {
            var key = template.Clone() as Widget;

            key.Id        = hd.Name;
            key.IsVisible = () => true;

            key.Get <LabelWidget>("FUNCTION").GetText = () => hd.Description + ":";

            var remapButton = key.Get <ButtonWidget>("HOTKEY");

            WidgetUtils.TruncateButtonToTooltip(remapButton, modData.Hotkeys[hd.Name].GetValue().DisplayString());

            remapButton.IsHighlighted = () => selectedHotkeyDefinition == hd;

            var hotkeyValidColor   = ChromeMetrics.Get <Color>("HotkeyColor");
            var hotkeyInvalidColor = ChromeMetrics.Get <Color>("HotkeyColorInvalid");

            remapButton.GetColor = () =>
            {
                return(modData.Hotkeys.GetFirstDuplicate(hd.Name, modData.Hotkeys[hd.Name].GetValue(), hd) != null ?
                       hotkeyInvalidColor :
                       hotkeyValidColor);
            };

            if (selectedHotkeyDefinition == hd)
            {
                selectedHotkeyButton  = remapButton;
                hotkeyEntryWidget.Key = modData.Hotkeys[hd.Name].GetValue();
                ValidateHotkey();
            }

            remapButton.OnClick = () =>
            {
                selectedHotkeyDefinition = hd;
                selectedHotkeyButton     = remapButton;
                hotkeyEntryWidget.Key    = modData.Hotkeys[hd.Name].GetValue();
                ValidateHotkey();
                hotkeyEntryWidget.TakeKeyboardFocus();
            };

            parent.AddChild(key);
        }
コード例 #18
0
        void BuildMusicTable(Widget list)
        {
            music  = Rules.Music.Where(a => a.Value.Exists).Select(a => a.Value).ToArray();
            random = music.Shuffle(Game.CosmeticRandom).ToArray();

            list.RemoveChildren();
            foreach (var s in music)
            {
                var song = s;
                if (currentSong == null)
                {
                    currentSong = song;
                }

                var item = ScrollItemWidget.Setup(itemTemplate, () => currentSong == song, () => { currentSong = song; Play(); });
                item.Get <LabelWidget>("TITLE").GetText  = () => song.Title;
                item.Get <LabelWidget>("LENGTH").GetText = () => SongLengthLabel(song);
                list.AddChild(item);
            }
        }
コード例 #19
0
        public PlayerProfileBadgesLogic(Widget widget, PlayerProfile profile, Func <int, int> negotiateWidth)
        {
            var showBadges = profile.Badges.Any();

            widget.IsVisible = () => showBadges;

            var badgeTemplate = widget.Get("BADGE_TEMPLATE");

            widget.RemoveChild(badgeTemplate);

            var width       = 0;
            var badgeOffset = badgeTemplate.Bounds.Y;

            foreach (var badge in profile.Badges)
            {
                var b    = badgeTemplate.Clone();
                var icon = b.Get <SpriteWidget>("ICON");
                icon.GetSprite = () => badge.Icon24;

                var label     = b.Get <LabelWidget>("LABEL");
                var labelFont = Game.Renderer.Fonts[label.Font];

                var labelText = WidgetUtils.TruncateText(badge.Label, label.Bounds.Width, labelFont);
                label.GetText = () => labelText;

                width = Math.Max(width, label.Bounds.Left + labelFont.Measure(labelText).X + icon.Bounds.X);

                b.Bounds.Y = badgeOffset;
                widget.AddChild(b);

                badgeOffset += badgeTemplate.Bounds.Height;
            }

            if (badgeOffset > badgeTemplate.Bounds.Y)
            {
                badgeOffset += 5;
            }

            widget.Bounds.Width  = negotiateWidth(width);
            widget.Bounds.Height = badgeOffset;
        }
コード例 #20
0
ファイル: SettingsLogic.cs プロジェクト: wenzeslaus/OpenRA
        static void BindHotkeyPref(KeyValuePair <string, string> kv, KeySettings ks, Widget template, Widget parent)
        {
            var key = template.Clone() as Widget;

            key.Id        = kv.Key;
            key.IsVisible = () => true;

            var field = ks.GetType().GetField(kv.Key);

            if (field == null)
            {
                throw new InvalidOperationException("Game.Settings.Keys does not contain {1}".F(kv.Key));
            }

            key.Get <LabelWidget>("FUNCTION").GetText = () => kv.Value + ":";

            var textBox = key.Get <HotkeyEntryWidget>("HOTKEY");

            textBox.Key         = (Hotkey)field.GetValue(ks);
            textBox.OnLoseFocus = () => field.SetValue(ks, textBox.Key);
            parent.AddChild(key);
        }
コード例 #21
0
        public void UpdateObjectives(bool notify)
        {
            if (notify)
            {
                objectivesButton.Highlighted = true;
            }

            primaryPanel.RemoveChildren();
            secondaryPanel.RemoveChildren();

            foreach (var o in objectives.Objectives.Where(o => o.Status != ObjectiveStatus.Inactive))
            {
                var objective = o;

                Widget      widget;
                LabelWidget objectiveText;
                LabelWidget objectiveStatus;

                if (objective.Type == ObjectiveType.Primary)
                {
                    widget          = primaryTemplate.Clone();
                    objectiveText   = widget.Get <LabelWidget>("PRIMARY_OBJECTIVE");
                    objectiveStatus = widget.Get <LabelWidget>("PRIMARY_STATUS");
                    SetupWidget(widget, objectiveText, objectiveStatus, objective);
                    primaryPanel.AddChild(widget);
                }
                else
                {
                    widget          = secondaryTemplate.Clone();
                    objectiveText   = widget.Get <LabelWidget>("SECONDARY_OBJECTIVE");
                    objectiveStatus = widget.Get <LabelWidget>("SECONDARY_STATUS");
                    SetupWidget(widget, objectiveText, objectiveStatus, objective);
                    secondaryPanel.AddChild(widget);
                }
            }
        }
コード例 #22
0
ファイル: TradePanel.cs プロジェクト: polytronicgr/dwarfcorp
        public void SetTradeItems(List <ResourceAmount> leftResources, List <ResourceAmount> rightResources, DwarfBux leftMoney, DwarfBux rightMoney)
        {
            Update();
            LeftItems.Clear();
            RightItems.Clear();

            var left      = GetTopResources(leftResources).ToList();
            int leftCount = left.Count + (leftMoney > 0.0m ? 1 : 0);

            int k = 0;

            foreach (var resource in left)
            {
                var resourceType = ResourceLibrary.GetResourceByName(resource.ResourceType);
                LeftItems.AddChild(new ResourceIcon()
                {
                    Layers      = resourceType.GuiLayers,
                    MinimumSize = new Point(32, 32),
                    MaximumSize = new Point(32, 32),
                    Rect        = new Rectangle(LeftWidget.Rect.X + 16 + k * 4 - leftCount * 2, LeftWidget.Rect.Y + 5, 32, 32)
                });
                k++;
            }

            if (leftMoney > 0.0m)
            {
                LeftItems.AddChild(new Widget()
                {
                    Background  = new TileReference("coins", 1),
                    MinimumSize = new Point(32, 32),
                    MaximumSize = new Point(32, 32),
                    Rect        = new Rectangle(LeftWidget.Rect.X + 16 + k * 4 - leftCount * 2, LeftWidget.Rect.Y + 5, 32, 32)
                });
            }

            var right      = GetTopResources(rightResources).ToList();
            int rightCount = right.Count + (rightMoney > 0.0m ? 1 : 0);

            k = 0;
            foreach (var resource in GetTopResources(rightResources))
            {
                var resourceType = ResourceLibrary.GetResourceByName(resource.ResourceType);
                RightItems.AddChild(new ResourceIcon()
                {
                    Layers      = resourceType.GuiLayers,
                    MinimumSize = new Point(32, 32),
                    MaximumSize = new Point(32, 32),
                    Rect        = new Rectangle(RightWidget.Rect.X + 16 + k * 4 - rightCount * 2, RightWidget.Rect.Y + 5, 32, 32)
                });
                k++;
            }

            if (rightMoney > 0.0m)
            {
                RightItems.AddChild(new Widget()
                {
                    Background  = new TileReference("coins", 1),
                    MinimumSize = new Point(32, 32),
                    MaximumSize = new Point(32, 32),
                    Rect        = new Rectangle(RightWidget.Rect.X + 16 + k * 4 - rightCount * 2, RightWidget.Rect.Y + 5, 32, 32)
                });
            }
            LeftItems.Invalidate();
            RightItems.Invalidate();
        }
コード例 #23
0
ファイル: DiplomacyDelegate.cs プロジェクト: geckosoft/OpenRA
        void LayoutDialog(Widget bg)
        {
            bg.Children.RemoveAll(w => controls.Contains(w));
            controls.Clear();

            var y = 50;
            var margin = 20;
            var labelWidth = (bg.Bounds.Width - 3 * margin) / 3;

            var ts = new LabelWidget
            {
                Bold = true,
                Bounds = new Rectangle(margin + labelWidth + 10, y, labelWidth, 25),
                Text = "Their Stance",
                Align = LabelWidget.TextAlign.Left,
            };

            bg.AddChild(ts);
            controls.Add(ts);

            var ms = new LabelWidget
            {
                Bold = true,
                Bounds = new Rectangle(margin + 2 * labelWidth + 20, y, labelWidth, 25),
                Text = "My Stance",
                Align = LabelWidget.TextAlign.Left,
            };

            bg.AddChild(ms);
            controls.Add(ms);

            y += 35;

            foreach (var p in world.players.Values.Where(a => a != world.LocalPlayer && !a.NonCombatant))
            {
                var pp = p;
                var label = new LabelWidget
                {
                    Bounds = new Rectangle(margin, y, labelWidth, 25),
                    Id = "DIPLOMACY_PLAYER_LABEL_{0}".F(p.Index),
                    Text = p.PlayerName,
                    Align = LabelWidget.TextAlign.Left,
                    Bold = true,
                };

                bg.AddChild(label);
                controls.Add(label);

                var theirStance = new LabelWidget
                {
                    Bounds = new Rectangle( margin + labelWidth + 10, y, labelWidth, 25),
                    Id = "DIPLOMACY_PLAYER_LABEL_THEIR_{0}".F(p.Index),
                    Text = p.PlayerName,
                    Align = LabelWidget.TextAlign.Left,
                    Bold = false,

                    GetText = () => pp.Stances[ world.LocalPlayer ].ToString(),
                };

                bg.AddChild(theirStance);
                controls.Add(theirStance);

                var myStance = new ButtonWidget
                {
                    Bounds = new Rectangle( margin + 2 * labelWidth + 20,  y, labelWidth, 25),
                    Id = "DIPLOMACY_PLAYER_LABEL_MY_{0}".F(p.Index),
                    Text = world.LocalPlayer.Stances[ pp ].ToString(),
                };

                myStance.OnMouseUp = mi => { CycleStance(pp, myStance); return true; };

                bg.AddChild(myStance);
                controls.Add(myStance);

                y += 35;
            }
        }
コード例 #24
0
        public override void Construct()
        {
            Border         = "";
            Font           = "font10";
            TextColor      = new Vector4(0, 0, 0, 1);
            InteriorMargin = new Margin(16, 16, 16, 16);

            var titleBar = AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 34),
            });

            for (var i = 0; i < Data.Craft_Ingredients.Count; ++i)
            {
                var resource = Library.EnumerateResourceTypesWithTag(Data.Craft_Ingredients[i].Tag).FirstOrDefault();
                if (resource != null)
                {
                    titleBar.AddChild(new Play.ResourceGuiGraphicIcon
                    {
                        Resource            = resource.Gui_Graphic,
                        MinimumSize         = new Point(32, 32),
                        MaximumSize         = new Point(32, 32),
                        AutoLayout          = AutoLayout.DockLeft,
                        Text                = Data.Craft_Ingredients[i].Count.ToString(),
                        TextHorizontalAlign = HorizontalAlign.Right,
                        TextVerticalAlign   = VerticalAlign.Bottom,
                        Font                = "font10-outline-numsonly",
                        TextColor           = Color.White.ToVector4(),
                        Tooltip             = Data.Craft_Ingredients[i].Tag
                    });
                }

                if (i < Data.Craft_Ingredients.Count - 1)
                {
                    titleBar.AddChild(new Widget
                    {
                        MinimumSize         = new Point(16, 32),
                        MaximumSize         = new Point(16, 32),
                        AutoLayout          = AutoLayout.DockLeft,
                        Text                = "+",
                        TextHorizontalAlign = HorizontalAlign.Center,
                        TextVerticalAlign   = VerticalAlign.Bottom,
                        Font                = "font10"
                    });
                }
                else
                {
                    titleBar.AddChild(new Widget
                    {
                        MinimumSize         = new Point(16, 32),
                        MaximumSize         = new Point(16, 32),
                        AutoLayout          = AutoLayout.DockLeft,
                        Text                = ">>",
                        TextHorizontalAlign = HorizontalAlign.Center,
                        TextVerticalAlign   = VerticalAlign.Bottom,
                        Font                = "font10"
                    });
                }
            }

            titleBar.AddChild(new Play.ResourceIcon
            {
                Resource            = new Resource(Data),
                MinimumSize         = new Point(32, 32),
                AutoLayout          = AutoLayout.DockLeft,
                Text                = Data.Craft_ResultsCount.ToString(),
                Font                = "font10-outline-numsonly",
                TextHorizontalAlign = HorizontalAlign.Right,
                TextVerticalAlign   = VerticalAlign.Bottom,
                TextColor           = Color.White.ToVector4()
            });

            titleBar.AddChild(new Widget
            {
                Text              = " " + Data.DisplayName,
                Font              = "font16",
                AutoLayout        = AutoLayout.DockLeft,
                TextVerticalAlign = VerticalAlign.Center,
                MinimumSize       = new Point(0, 34),
                Padding           = new Margin(0, 0, 16, 0)
            });

            AddChild(new Widget
            {
                Text                   = Data.Description + "\n",
                AutoLayout             = AutoLayout.DockTop,
                AutoResizeToTextHeight = true
            });

            foreach (var resourceAmount in Data.Craft_Ingredients)
            {
                var child = AddChild(new Widget()
                {
                    AutoLayout  = AutoLayout.DockTop,
                    MinimumSize = new Point(200, 18)
                });

                child.AddChild(new Widget()
                {
                    Font       = "font8",
                    Text       = String.Format("{0} {1}: ", resourceAmount.Count, resourceAmount.Tag),
                    AutoLayout = AutoLayout.DockLeft
                });

                child.Layout();

                var resourceSelector = child.AddChild(new ComboBox
                {
                    Font  = "font8",
                    Items = new List <string> {
                        "<Not enough!>"
                    },
                    AutoLayout  = AutoLayout.DockLeft,
                    MinimumSize = new Point(200, 18),
                    Tooltip     = String.Format("Type of {0} to use.", resourceAmount.Tag)
                }) as ComboBox;

                var resourceCountIndicator = child.AddChild(new Widget
                {
                    Font       = "font8",
                    AutoLayout = AutoLayout.DockFill
                });

                ResourceCombos.Add(new ResourceCombo
                {
                    Resource = resourceAmount,
                    Combo    = resourceSelector,
                    Count    = resourceCountIndicator
                });
            }

            var child2 = AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(100, 18)
            });

            child2.AddChild(new Widget()
            {
                Font       = "font8",
                Text       = "Repeat ",
                AutoLayout = AutoLayout.DockLeft
            });

            NumCombo = child2.AddChild(new ComboBox
            {
                Font  = "font8",
                Items = new List <string>()
                {
                    "1x",
                    "5x",
                    "10x",
                    "100x"
                },
                AutoLayout  = AutoLayout.DockLeft,
                MinimumSize = new Point(64, 18),
                MaximumSize = new Point(64, 18),
                Tooltip     = "Craft this many objects."
            }) as ComboBox;

            NumCombo.SelectedIndex = 0;

            BottomBar = AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(256, 32),
                TextColor   = new Vector4(1, 0, 0, 1)
            });

            Button = BottomBar.AddChild(new Button()
            {
                Text    = Library.GetString("craft-new", Data.Craft_Verb.Base),
                Tooltip = Library.GetString("craft-new-tooltip", Data.Craft_Verb.PresentTense, Data.DisplayName),
                OnClick = (widget, args) =>
                {
                    if (Button.Hidden)
                    {
                        return;
                    }
                    BuildAction(this, args);
                },
                AutoLayout  = AutoLayout.DockLeftCentered,
                MinimumSize = new Point(64, 28),
            });

            PlaceButton = BottomBar.AddChild(new Button()
            {
                Text   = "Place",
                Hidden = true
            });

            OnUpdate += (sender, time) =>
            {
                if (Hidden)
                {
                    return;
                }

                var notEnoughResources = false;
                var availableResources = World.ListApparentResources();

                foreach (var combo in ResourceCombos)
                {
                    var currentSelection = combo.Combo.SelectedItem;

                    // Todo: Aggregate by display name instead. And then - ??
                    combo.Combo.Items = ResourceSet.GroupByApparentType(
                        World.GetResourcesWithTag(combo.Resource.Tag)).Where(r => r.Count >= combo.Resource.Count).Select(r => r.ApparentType).OrderBy(p => p).ToList();

                    if (combo.Combo.Items.Count == 0)
                    {
                        combo.Combo.Items.Add("<Not enough!>");
                        notEnoughResources = true;
                    }

                    if (combo.Combo.Items.Contains(currentSelection))
                    {
                        combo.Combo.SelectedIndex = combo.Combo.Items.IndexOf(currentSelection);
                    }
                    else
                    {
                        combo.Combo.SelectedIndex = 0;
                    }

                    if (combo.Combo.SelectedItem == "<Not enough!>")
                    {
                        combo.Count.Text = "";
                    }
                    else
                    {
                        if (availableResources.ContainsKey(combo.Combo.SelectedItem))
                        {
                            combo.Count.Text = String.Format("Available: {0}", availableResources[combo.Combo.SelectedItem].Count);
                        }
                        else
                        {
                            combo.Count.Text = "Available: None!";
                        }
                    }

                    combo.Combo.Invalidate();
                    combo.Count.Invalidate();
                }

                Button.Hidden = true;

                if (notEnoughResources)
                {
                    BottomBar.Text = "You don't have enough resources.";
                }
                else
                {
                    if (!World.PlayerFaction.Minions.Any(m => m.Stats.IsTaskAllowed(Data.Craft_TaskCategory)))
                    {
                        BottomBar.Text = String.Format("You need a minion capable of {0} tasks to {1} this.", Data.Craft_TaskCategory, Data.Craft_Verb.PresentTense);
                    }
                    else
                    {
                        var nearestBuildLocation = World.PlayerFaction.FindNearestItemWithTags(Data.Craft_Location, Vector3.Zero, false, null);
                        if (!String.IsNullOrEmpty(Data.Craft_Location) && nearestBuildLocation == null)
                        {
                            BottomBar.Text = String.Format("Needs {0} to {1}!", Data.Craft_Location, Data.Craft_Verb.Base);
                        }
                        else
                        {
                            Button.Hidden  = false;
                            BottomBar.Text = "";
                        }
                    }
                }

                PlaceButton.Hidden = true;

                if (CanPlace != null && CanPlace())
                {
                    PlaceButton.Hidden = false;
                }
            };

            Root.RegisterForUpdate(this);
            Layout();
        }
コード例 #25
0
        public override void OnEnter()
        {
            if (SuppressEnter)
            {
                SuppressEnter = false;
                return;
            }

            DwarfGame.GumInputMapper.GetInputQueue();

            #region Setup GUI
            GuiRoot = new Gui.Root(DwarfGame.GuiSkin);
            GuiRoot.MousePointer = new MousePointer("mouse", 15.0f, 16, 17, 18, 19, 20, 21, 22, 23);

            MainPanel = GuiRoot.RootItem.AddChild(new Gui.Widget
            {
                Rect           = GuiRoot.RenderData.VirtualScreen,
                Border         = "border-fancy",
                Text           = Settings.Name,
                Font           = "font16",
                TextColor      = new Vector4(0, 0, 0, 1),
                Padding        = new Margin(4, 4, 4, 4),
                InteriorMargin = new Margin(24, 0, 0, 0)
            });

            var rightPanel = MainPanel.AddChild(new Widget
            {
                MinimumSize = new Point(256, 0),
                Padding     = new Margin(2, 2, 2, 2),
                AutoLayout  = AutoLayout.DockRight
            });

            rightPanel.AddChild(new Gui.Widget
            {
                Text               = "Back",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.DockTop,
                OnClick            = (sender, args) =>
                {
                    GameStateManager.PopState();
                }
            });

            rightPanel.AddChild(new Widget
            {
                Text               = "Factions",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = AutoLayout.DockTop,
                OnClick            = (sender, args) =>
                {
                    SuppressEnter = true;
                    GameStateManager.PushState(new FactionViewState(GameState.Game, Settings));
                }
            });

            switch (PanelState)
            {
            case PanelStates.Generate:
                RightPanel = rightPanel.AddChild(new GenerationPanel(Game, Settings)
                {
                    RestartGeneration = () => RestartGeneration(),
                    GetGenerator      = () => Generator,
                    OnVerified        = () =>
                    {
                        SwitchToLaunchPanel();
                    },
                    AutoLayout = Gui.AutoLayout.DockFill,
                });
                break;

            case PanelStates.Launch:
                RightPanel = rightPanel.AddChild(new LaunchPanel(Game, Generator, Settings, this)
                {
                    AutoLayout = AutoLayout.DockFill,
                });

                break;
            }

            GenerationProgress = MainPanel.AddChild(new Gui.Widgets.ProgressBar
            {
                AutoLayout          = Gui.AutoLayout.DockBottom,
                TextHorizontalAlign = Gui.HorizontalAlign.Center,
                TextVerticalAlign   = Gui.VerticalAlign.Center,
                Font      = "font10",
                TextColor = new Vector4(1, 1, 1, 1)
            }) as Gui.Widgets.ProgressBar;

            PoliticsToggle = MainPanel.AddChild(new Gui.Widgets.CheckBox
            {
                Text     = "Show Political Boundaries",
                Hidden   = true,
                OnLayout = (sender) =>
                {
                    sender.Rect = GenerationProgress.Rect;
                },
                OnCheckStateChange = (sender) =>
                {
                    Preview.ShowPolitics = (sender as Gui.Widgets.CheckBox).CheckState;
                }
            }) as Gui.Widgets.CheckBox;

            Preview = MainPanel.AddChild(new WorldGeneratorPreview(Game.GraphicsDevice)
            {
                Border     = "border-thin",
                AutoLayout = Gui.AutoLayout.DockFill,
                Overworld  = Settings,
                Hidden     = true,
                OnLayout   = (sender) =>
                {
                    //sender.Rect = new Rectangle(sender.Rect.X, sender.Rect.Y, sender.Rect.Width, GenerationProgress.Rect.Bottom - sender.Rect.Y);
                },
                OnCellSelectionMade = () =>
                {
                    if (RightPanel is LaunchPanel launch)
                    {
                        launch.UpdateCellInfo();
                    }
                }
            }) as WorldGeneratorPreview;
コード例 #26
0
        public SettingsLogic(Widget widget, Action onExit, WorldRenderer worldRenderer, Dictionary <string, MiniYaml> logicArgs)
        {
            panelContainer = widget.Get("PANEL_CONTAINER");
            var panelTemplate = panelContainer.Get <ContainerWidget>("PANEL_TEMPLATE");

            panelContainer.RemoveChild(panelTemplate);

            tabContainer = widget.Get("SETTINGS_TAB_CONTAINER");
            tabTemplate  = tabContainer.Get <ButtonWidget>("BUTTON_TEMPLATE");
            tabContainer.RemoveChild(tabTemplate);

            if (logicArgs.TryGetValue("ButtonStride", out var buttonStrideNode))
            {
                buttonStride = FieldLoader.GetValue <int2>("ButtonStride", buttonStrideNode.Value);
            }

            if (logicArgs.TryGetValue("Panels", out var settingsPanels))
            {
                panels = settingsPanels.ToDictionary(kv => kv.Value);

                foreach (var panel in panels)
                {
                    var container = panelTemplate.Clone() as ContainerWidget;
                    container.Id = panel.Key;
                    panelContainer.AddChild(container);

                    Game.LoadWidget(worldRenderer.World, panel.Key, container, new WidgetArgs()
                    {
                        { "registerPanel", (Action <string, string, Func <Widget, Func <bool> >, Func <Widget, Action> >)RegisterSettingsPanel },
                        { "panelID", panel.Key },
                        { "label", panel.Value }
                    });
                }
            }

            widget.Get <ButtonWidget>("BACK_BUTTON").OnClick = () =>
            {
                needsRestart |= leavePanelActions[activePanel]();
                var current = Game.Settings;
                current.Save();

                Action closeAndExit = () => { Ui.CloseWindow(); onExit(); };
                if (needsRestart)
                {
                    Action noRestart = () => ConfirmationDialogs.ButtonPrompt(
                        title: "Restart Required",
                        text: "Some changes will not be applied until\nthe game is restarted.",
                        onCancel: closeAndExit,
                        cancelText: "Continue");

                    if (!Game.ExternalMods.TryGetValue(ExternalMod.MakeKey(Game.ModData.Manifest), out var external))
                    {
                        noRestart();
                        return;
                    }

                    ConfirmationDialogs.ButtonPrompt(
                        title: "Restart Now?",
                        text: "Some changes will not be applied until\nthe game is restarted. Restart now?",
                        onConfirm: () => Game.SwitchToExternalMod(external, null, noRestart),
                        onCancel: closeAndExit,
                        confirmText: "Restart Now",
                        cancelText: "Restart Later");
                }
                else
                {
                    closeAndExit();
                }
            };

            widget.Get <ButtonWidget>("RESET_BUTTON").OnClick = () =>
            {
                Action reset = () =>
                {
                    resetPanelActions[activePanel]();
                    Game.Settings.Save();
                };

                ConfirmationDialogs.ButtonPrompt(
                    title: $"Reset \"{panels[activePanel]}\"",
                    text: "Are you sure you want to reset\nall settings in this panel?",
                    onConfirm: reset,
                    onCancel: () => { },
                    confirmText: "Reset",
                    cancelText: "Cancel");
            };
        }
コード例 #27
0
        public void UpdateCellInfo()
        {
            if (Settings.InstanceSettings.Origin.X < 0 || Settings.InstanceSettings.Origin.X >= Settings.Width ||
                Settings.InstanceSettings.Origin.Y < 0 || Settings.InstanceSettings.Origin.Y >= Settings.Height)
            {
                StartButton.Hidden = true;
                CellInfo.Text      = "\nSelect a spawn cell to continue";
                SaveName           = "";
            }
            else
            {
                SaveName = DwarfGame.GetWorldDirectory() + Path.DirectorySeparatorChar + Settings.Name + Path.DirectorySeparatorChar + String.Format("{0}-{1}", (int)Settings.InstanceSettings.Origin.X, (int)Settings.InstanceSettings.Origin.Y);
                var saveGame = SaveGame.LoadMetaFromDirectory(SaveName);

                if (saveGame != null)
                {
                    StartButton.Text = "Load";
                    CellInfo.Clear();
                    CellInfo.Text      = "\n" + saveGame.Metadata.DescriptionString;
                    StartButton.Hidden = false;
                    CellInfo.Layout();
                }
                else
                {
                    StartButton.Hidden = false;
                    StartButton.Text   = "Create";
                    CellInfo.Clear();
                    CellInfo.Text = "";

                    var cellInfoText = Root.ConstructWidget(new Widget
                    {
                        AutoLayout = AutoLayout.DockFill
                    });

                    CellInfo.AddChild(new Gui.Widget
                    {
                        Text               = "Edit Embarkment",
                        Border             = "border-button",
                        ChangeColorOnHover = true,
                        TextColor          = new Vector4(0, 0, 0, 1),
                        Font               = "font16",
                        AutoLayout         = Gui.AutoLayout.DockTop,
                        MinimumSize        = new Point(0, 32),
                        OnClick            = (sender, args) =>
                        {
                            DwarfGame.LogSentryBreadcrumb("Game Launcher", "User is modifying embarkment.");
                            var embarkmentEditor = Root.ConstructWidget(new EmbarkmentEditor(Settings)
                            {
                                OnClose = (s) =>
                                {
                                    SetCreateCellInfoText(cellInfoText);
                                }
                            });

                            Root.ShowModalPopup(embarkmentEditor);
                        }
                    });

                    CellInfo.AddChild(cellInfoText);
                    SetCreateCellInfoText(cellInfoText);

                    CellInfo.Layout();
                }
            }
        }
コード例 #28
0
        public override void Construct()
        {
            Text = "You have no employees.";
            Font = "font16";

            InteriorPanel = AddChild(new Widget
            {
                AutoLayout = AutoLayout.DockFill,
                Hidden     = true,
                Background = new TileReference("basic", 0),
                Font       = "font8",
            });

            var top = InteriorPanel.AddChild(new Gui.Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 96)
            });

            Icon = top.AddChild(new DwarfCorp.Gui.Widgets.EmployeePortrait
            {
                AutoLayout  = AutoLayout.DockLeft,
                MinimumSize = new Point(48, 40),
            }) as EmployeePortrait;

            NameLabel = top.AddChild(new Gui.Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 48),
                Font        = "font16"
            });

            var levelHolder = top.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(256, 24)
            });

            TitleEditor = levelHolder.AddChild(new Gui.Widgets.EditableTextField()
            {
                AutoLayout   = AutoLayout.DockLeft,
                MinimumSize  = new Point(128, 24),
                OnTextChange = (sender) =>
                {
                    Employee.Stats.Title = sender.Text;
                },
                Tooltip = "Employee title. You can customize this."
            });

            LevelLabel = levelHolder.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockLeft,
                MinimumSize = new Point(128, 24)
            });

            var columns = InteriorPanel.AddChild(new Gui.Widgets.Columns
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 100),
                ColumnCount = 3
            });

            var left          = columns.AddChild(new Gui.Widget());
            var right         = columns.AddChild(new Gui.Widget());
            var evenMoreRight = columns.AddChild(new Gui.Widget());

            #region Stats
            var statParent = left.AddChild(new Gui.Widgets.Columns
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 60)
            });

            var statsLeft  = statParent.AddChild(new Widget());
            var statsRight = statParent.AddChild(new Widget());

            StatDexterity = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Dexterity (affects dwarf speed)"
            });

            StatStrength = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Strength (affects dwarf attack power)"
            });

            StatWisdom = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Wisdom (affects temprement and spell resistance)"
            });

            StatCharisma = statsLeft.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Charisma (affects ability to make friends)"
            });

            StatConstitution = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Constitution (affects dwarf health and damage resistance)"
            });

            StatIntelligence = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Intelligence (affects crafting/farming)"
            });

            StatSize = statsRight.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 16),
                Tooltip     = "Size"
            });
            #endregion

            #region status bars
            Hunger    = CreateStatusBar(right, "Hunger", "Starving", "Hungry", "Peckish", "Okay");
            Energy    = CreateStatusBar(right, "Energy", "Exhausted", "Tired", "Okay", "Energetic");
            Happiness = CreateStatusBar(right, "Happiness", "Miserable", "Unhappy", "So So", "Happy", "Euphoric");
            Health    = CreateStatusBar(evenMoreRight, "Health", "Near Death", "Critical", "Hurt", "Uncomfortable", "Fine", "Perfect");
            Boredom   = CreateStatusBar(evenMoreRight, "Boredom", "Desperate", "Overworked", "Bored", "Meh", "Fine", "Excited");
            #endregion

            PayLabel = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            AgeLabel = InteriorPanel.AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            Bio = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            var task = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(1, 24)
            });

            var inventory = task.AddChild(new Button
            {
                AutoLayout = AutoLayout.DockRight,
                Text       = "Backpack...",
                OnClick    = (sender, args) =>
                {
                    var employeeInfo = sender.Parent.Parent.Parent as EmployeeInfo;
                    if (employeeInfo != null && employeeInfo.Employee != null)
                    {
                        StringBuilder stringBuilder = new StringBuilder();
                        stringBuilder.Append("Backpack contains:\n");
                        Dictionary <string, ResourceAmount> aggregateResources = employeeInfo.Employee.Creature.Inventory.Aggregate();
                        foreach (var resource in aggregateResources)
                        {
                            stringBuilder.Append(String.Format("{0}x {1}\n", resource.Value.NumResources, resource.Key));
                        }
                        if (aggregateResources.Count == 0)
                        {
                            stringBuilder.Append("Nothing.");
                        }

                        Confirm popup = new Confirm()
                        {
                            CancelText = "",
                            Text       = stringBuilder.ToString()
                        };


                        sender.Root.ShowMinorPopup(popup);

                        if (aggregateResources.Count > 0)
                        {
                            popup.AddChild(new Button()
                            {
                                Text       = "Empty",
                                Tooltip    = "Click to order this dwarf to empty their backpack.",
                                AutoLayout = AutoLayout.FloatBottomLeft,
                                OnClick    = (currSender, currArgs) =>
                                {
                                    if (employeeInfo != null && employeeInfo.Employee != null &&
                                        employeeInfo.Employee.Creature != null)
                                    {
                                        employeeInfo.Employee.Creature.RestockAllImmediately(true);
                                    }
                                }
                            });
                            popup.Layout();
                        }
                    }
                }
            });

            CancelTask = task.AddChild(new Button
            {
                AutoLayout         = AutoLayout.DockRight,
                Text               = "Cancel Task",
                ChangeColorOnHover = true
            });

            TaskLabel = task.AddChild(new Widget
            {
                AutoLayout          = AutoLayout.DockRight,
                MinimumSize         = new Point(256, 24),
                TextVerticalAlign   = VerticalAlign.Center,
                TextHorizontalAlign = HorizontalAlign.Right
            });

            Thoughts = InteriorPanel.AddChild(new Widget
            {
                AutoLayout  = AutoLayout.DockTop,
                MinimumSize = new Point(0, 24)
            });

            var bottomBar = InteriorPanel.AddChild(new Widget
            {
                Transparent = true,
                AutoLayout  = AutoLayout.DockBottom,
                MinimumSize = new Point(0, 32)
            });

            bottomBar.AddChild(new Button()
            {
                Text       = "Fire",
                Border     = "border-button",
                AutoLayout = AutoLayout.DockRight,
                OnClick    = (sender, args) =>
                {
                    Root.SafeCall(OnFireClicked, this);
                }
            });

            /*
             * if (EnablePosession)
             * {
             *  bottomBar.AddChild(new Button()
             *  {
             *      Text = "Follow",
             *      Tooltip = "Click to directly control this dwarf and have the camera follow.",
             *      AutoLayout = AutoLayout.DockRight,
             *      OnClick = (sender, args) =>
             *      {
             *          (sender.Parent.Parent.Parent as EmployeeInfo).Employee.World.Tutorial("dwarf follow");
             *          (sender.Parent.Parent.Parent as EmployeeInfo).Employee.IsPosessed = true;
             *      }
             *  });
             * }
             */

            bottomBar.AddChild(new Button()
            {
                Text       = "Tasks...",
                Tooltip    = "Open allowed tasks filter.",
                AutoLayout = AutoLayout.DockRight,
                OnClick    = (sender, args) =>
                {
                    var screen = sender.Root.RenderData.VirtualScreen;
                    sender.Root.ShowModalPopup(new AllowedTaskFilter
                    {
                        Employee    = Employee,
                        Tag         = "selected-employee-allowable-tasks",
                        AutoLayout  = AutoLayout.DockFill,
                        MinimumSize = new Point(256, 256),
                        Border      = "border-fancy",
                        Rect        = new Rectangle(screen.Center.X - 128, screen.Center.Y - 128, 256, 256)
                    });
                }
            });

#if ENABLE_CHAT
            if (Employee != null && Employee.GetRoot().GetComponent <DwarfThoughts>() != null)
            {
                bottomBar.AddChild(new Button()
                {
                    Text       = "Chat...",
                    Tooltip    = "Have a talk with your employee.",
                    AutoLayout = AutoLayout.DockRight,
                    OnClick    = (sender, args) =>
                    {
                        Employee.Chat();
                    }
                });
            }
#endif


            LevelButton = bottomBar.AddChild(new Button()
            {
                Text       = "Promote!",
                Border     = "border-button",
                AutoLayout = AutoLayout.DockRight,
                Tooltip    = "Click to promote this dwarf.\nPromoting Dwarves raises their pay and makes them\nmore effective workers.",
                OnClick    = (sender, args) =>
                {
                    var prevLevel = Employee.Stats.CurrentLevel;
                    Employee.Stats.LevelUp();
                    if (Employee.Stats.CurrentLevel.HealingPower > prevLevel.HealingPower)
                    {
                        Employee.World.MakeAnnouncement(String.Format("{0}'s healing power increased to {1}!", Employee.Stats.FullName, Employee.Stats.CurrentLevel.HealingPower));
                    }

                    if (Employee.Stats.CurrentLevel.ExtraAttacks.Count > prevLevel.ExtraAttacks.Count)
                    {
                        Employee.World.MakeAnnouncement(String.Format("{0} learned to cast {1}!", Employee.Stats.FullName, Employee.Stats.CurrentLevel.ExtraAttacks.Last().Name));
                    }
                    SoundManager.PlaySound(ContentPaths.Audio.change, 0.5f);
                    Invalidate();
                    Employee.Creature.AddThought(Thought.ThoughtType.GotPromoted);
                }
            });


            var topbuttons = top.AddChild(new Widget()
            {
                AutoLayout  = AutoLayout.FloatTopRight,
                MinimumSize = new Point(32, 24)
            });
            topbuttons.AddChild(new Widget()
            {
                Text               = "<",
                Font               = "font10",
                Tooltip            = "Previous employee.",
                AutoLayout         = AutoLayout.DockLeft,
                ChangeColorOnHover = true,
                MinimumSize        = new Point(16, 24),
                OnClick            = (sender, args) =>
                {
                    if (Employee == null)
                    {
                        return;
                    }
                    int idx = Employee.Faction.Minions.IndexOf(Employee);
                    if (idx < 0)
                    {
                        return;
                    }
                    idx--;
                    Employee = Employee.Faction.Minions[Math.Abs(idx) % Employee.Faction.Minions.Count];
                    Employee.World.Master.SelectedMinions = new List <CreatureAI>()
                    {
                        Employee
                    };
                }
            });
            topbuttons.AddChild(new Widget()
            {
                Text               = ">",
                Font               = "font10",
                Tooltip            = "Next employee.",
                AutoLayout         = AutoLayout.DockRight,
                ChangeColorOnHover = true,
                MinimumSize        = new Point(16, 24),
                OnClick            = (sender, args) =>
                {
                    if (Employee == null)
                    {
                        return;
                    }
                    int idx = Employee.Faction.Minions.IndexOf(Employee);
                    if (idx < 0)
                    {
                        return;
                    }
                    idx++;
                    Employee = Employee.Faction.Minions[idx % Employee.Faction.Minions.Count];
                    Employee.World.Master.SelectedMinions = new List <CreatureAI>()
                    {
                        Employee
                    };
                }
            });

            base.Construct();
        }
コード例 #29
0
        public override void Construct()
        {
            Text = "Choose a single employee to assign their allowed tasks.";
            Font = "font10";

            AddChild(new Button()
            {
                Text        = "Ok",
                AutoLayout  = AutoLayout.DockBottom,
                OnClick     = (sender, args) => sender.Parent.Close(),
                MinimumSize = new Point(64, 32)
            });

            InteriorPanel = AddChild(new Widget
            {
                AutoLayout = AutoLayout.DockFill,
                Hidden     = true,
                Background = new TileReference("basic", 0),
                Font       = "font8",
            });

            EmployeeName = InteriorPanel.AddChild(new Gui.Widget
            {
                Text = String.Format("Allowed Tasks"),
                TextHorizontalAlign = HorizontalAlign.Center,
                AutoLayout          = AutoLayout.DockTop,
                MinimumSize         = new Point(0, 36),
                Font = "font10"
            });

            var columns = InteriorPanel.AddChild(new Gui.Widgets.Columns
            {
                AutoLayout  = AutoLayout.DockFill,
                MinimumSize = new Point(0, 120),
                ColumnCount = ColumnCount
            });

            for (var i = 0; i < ColumnCount; ++i)
            {
                columns.AddChild(new Widget
                {
                    Padding = new Margin(2, 2, 2, 2),
                });
            }

            var column = 0;

            foreach (var type in Enum.GetValues(typeof(Task.TaskCategory)))
            {
                if (type.ToString().StartsWith("_"))
                {
                    continue;
                }
                if ((Task.TaskCategory)type == Task.TaskCategory.None)
                {
                    continue;
                }
                if (Employee != null && (Employee.Stats.CurrentClass.Actions & (Task.TaskCategory)type) != (Task.TaskCategory)type)
                {
                    continue;
                }
                var box = columns.GetChild(column).AddChild(new CheckBox
                {
                    Text       = type.ToString(),
                    Tag        = type,
                    AutoLayout = AutoLayout.DockTop,
                }) as CheckBox;

                TaskCategories.Add(box);
                box.OnCheckStateChange += (sender) => CheckChanged();

                column = (column + 1) % ColumnCount;
            }


            base.Construct();
        }
コード例 #30
0
ファイル: EmbarkmentEditor.cs プロジェクト: hhy5277/dwarfcorp
        public override void Construct()
        {
            PopupDestructionType = PopupDestructionType.Keep;
            Padding = new Margin(2, 2, 2, 2);
            //Set size and center on screen.
            Rect = Root.RenderData.VirtualScreen;

            Border = "border-fancy";

            ValidationLabel = AddChild(new Widget
            {
                MinimumSize = new Point(0, 48),
                AutoLayout  = AutoLayout.DockBottom,
                Font        = "font16"
            });

            ValidationLabel.AddChild(new Gui.Widget
            {
                Text               = "Okay",
                Border             = "border-button",
                ChangeColorOnHover = true,
                TextColor          = new Vector4(0, 0, 0, 1),
                Font               = "font16",
                AutoLayout         = Gui.AutoLayout.FloatBottomRight,
                OnClick            = (sender, args) =>
                {
                    foreach (var resource in ResourceColumns.SelectedResources)
                    {
                        Settings.InstanceSettings.InitalEmbarkment.Resources.Add(resource);
                    }

                    var message = "";
                    var valid   = Embarkment.ValidateEmbarkment(Settings, out message);
                    if (valid == InstanceSettings.ValidationResult.Pass)
                    {
                        this.Close();
                    }
                    else if (valid == InstanceSettings.ValidationResult.Query)
                    {
                        var popup = new Gui.Widgets.Confirm()
                        {
                            Text    = message,
                            OnClose = (_sender) =>
                            {
                                if ((_sender as Gui.Widgets.Confirm).DialogResult == Gui.Widgets.Confirm.Result.OKAY)
                                {
                                    this.Close();
                                }
                            }
                        };
                        Root.ShowModalPopup(popup);
                    }
                    else if (valid == InstanceSettings.ValidationResult.Reject)
                    {
                        var popup = new Gui.Widgets.Confirm()
                        {
                            Text       = message,
                            CancelText = ""
                        };
                        Root.ShowModalPopup(popup);
                    }
                }
            });

            var columns = AddChild(new Gui.Widgets.Columns
            {
                ColumnCount = 2,
                AutoLayout  = AutoLayout.DockFill
            });

            var employeeStack = columns.AddChild(new Widget
            {
                MinimumSize = new Point(256, 0)
            });

            employeeStack.AddChild(new Widget
            {
                Text       = "Employees",
                Font       = "font16",
                AutoLayout = AutoLayout.DockTop
            });

            employeeStack.AddChild(new Widget
            {
                Text = "+ new employee",
                Font = "font16",
                ChangeColorOnHover = true,
                AutoLayout         = AutoLayout.DockTop,
                OnClick            = (sender, args) =>
                {
                    var dialog = Root.ConstructWidget(
                        new ChooseEmployeeTypeDialog()
                    {
                        Settings = Settings,
                        OnClose  = (_s) =>
                        {
                            RebuildEmployeeList();
                            UpdateCost();
                        }
                    });
                    Root.ShowModalPopup(dialog);
                }
            });

            var costPanel = employeeStack.AddChild(new Widget
            {
                MinimumSize = new Point(0, 128),
                AutoLayout  = AutoLayout.DockBottom
            });

            var availableFunds = costPanel.AddChild(CreateBar("Funds Available:"));

            availableFunds.AddChild(new Widget
            {
                AutoLayout          = AutoLayout.DockRight,
                Text                = FundsAvailable.ToString(),
                MinimumSize         = new Point(128, 0),
                TextHorizontalAlign = HorizontalAlign.Right
            });

            var moneyBar = costPanel.AddChild(CreateBar("Ready Cash:"));

            Cash = moneyBar.AddChild(new Gui.Widgets.MoneyEditor
            {
                MaximumValue   = (int)FundsAvailable,
                MinimumSize    = new Point(128, 33),
                AutoLayout     = AutoLayout.DockRight,
                OnValueChanged = (sender) =>
                {
                    Settings.InstanceSettings.InitalEmbarkment.Funds = (sender as Gui.Widgets.MoneyEditor).CurrentValue;
                    UpdateCost();
                },
                Tooltip             = "Money to take.",
                TextHorizontalAlign = HorizontalAlign.Right
            }) as Gui.Widgets.MoneyEditor;

            var employeeCostBar = costPanel.AddChild(CreateBar("Signing Bonuses:"));

            EmployeeCost = employeeCostBar.AddChild(new Widget
            {
                AutoLayout          = AutoLayout.DockRight,
                Text                = "$0",
                MinimumSize         = new Point(128, 0),
                TextHorizontalAlign = HorizontalAlign.Right
            });

            var totalBar = costPanel.AddChild(CreateBar("Total Cost:"));

            TotalCost = totalBar.AddChild(new Widget
            {
                AutoLayout          = AutoLayout.DockRight,
                Text                = "$0",
                MinimumSize         = new Point(128, 0),
                TextHorizontalAlign = HorizontalAlign.Right
            });

            EmployeeList = employeeStack.AddChild(new Gui.Widgets.WidgetListView
            {
                AutoLayout = Gui.AutoLayout.DockFill,
                SelectedItemForegroundColor = new Vector4(0, 0, 0, 1)
            }) as Gui.Widgets.WidgetListView;

            RebuildEmployeeList();

            ResourceColumns = columns.AddChild(new EmbarkmentResourceColumns
            {
                ComputeValue = (resourceType) =>
                {
                    var r = Library.GetResourceType(resourceType);
                    return(r.MoneyValue);
                },
                SourceResources   = Settings.PlayerCorporationResources.Enumerate().ToList(),
                SelectedResources = Settings.InstanceSettings.InitalEmbarkment.Resources.Enumerate().ToList(),
                LeftHeader        = "Available",
                RightHeader       = "Taking"
            }) as EmbarkmentResourceColumns;

            Layout();
            UpdateCost();
            base.Construct();
        }
コード例 #31
0
        public override void Tick()
        {
            if (actorIDStatus != nextActorIDStatus)
            {
                if ((actorIDStatus & nextActorIDStatus) == 0)
                {
                    var offset = actorIDErrorLabel.Bounds.Height;
                    if (nextActorIDStatus == ActorIDStatus.Normal)
                    {
                        offset *= -1;
                    }

                    actorEditPanel.Bounds.Height += offset;
                    initContainer.Bounds.Y       += offset;
                    buttonContainer.Bounds.Y     += offset;
                }

                actorIDStatus = nextActorIDStatus;
            }

            var actor = editor.DefaultBrush.SelectedActor;

            if (actor != null)
            {
                var origin = worldRenderer.Viewport.WorldToViewPx(new int2(actor.Bounds.Right, actor.Bounds.Top));

                // If we scrolled, hide the edit box for a moment
                if (lastScrollPosition.X != origin.X || lastScrollPosition.Y != origin.Y)
                {
                    lastScrollTime     = Game.RunTime;
                    lastScrollPosition = origin;
                }

                // If we changed actor, move widgets
                if (CurrentActor != actor)
                {
                    lastScrollTime = 0;                     // Ensure visible
                    CurrentActor   = actor;

                    editActorPreview = new EditActorPreview(CurrentActor);

                    initialActorID = actorIDField.Text = actor.ID;

                    var font          = Game.Renderer.Fonts[typeLabel.Font];
                    var truncatedType = WidgetUtils.TruncateText(actor.DescriptiveName, typeLabel.Bounds.Width, font);
                    typeLabel.Text = truncatedType;

                    actorIDField.CursorPosition = actor.ID.Length;
                    nextActorIDStatus           = ActorIDStatus.Normal;

                    // Remove old widgets
                    var oldInitHeight = initContainer.Bounds.Height;
                    initContainer.Bounds.Height = 0;
                    initContainer.RemoveChildren();

                    // Add owner dropdown
                    var ownerContainer = dropdownOptionTemplate.Clone();
                    ownerContainer.Get <LabelWidget>("LABEL").GetText = () => "Owner";
                    var ownerDropdown = ownerContainer.Get <DropDownButtonWidget>("OPTION");
                    var selectedOwner = actor.Owner;

                    Action <EditorActorPreview, PlayerReference> updateOwner = (preview, reference) =>
                    {
                        preview.Owner = reference;
                        preview.ReplaceInit(new OwnerInit(reference.Name));
                    };

                    var ownerHandler = new EditorActorOptionActionHandle <PlayerReference>(updateOwner, actor.Owner);
                    editActorPreview.Add(ownerHandler);

                    Func <PlayerReference, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
                    {
                        var item = ScrollItemWidget.Setup(template, () => selectedOwner == option, () =>
                        {
                            selectedOwner = option;
                            updateOwner(CurrentActor, selectedOwner);
                            ownerHandler.OnChange(option);
                        });

                        item.Get <LabelWidget>("LABEL").GetText = () => option.Name;
                        item.GetColor = () => option.Color;
                        return(item);
                    };

                    ownerDropdown.GetText  = () => selectedOwner.Name;
                    ownerDropdown.GetColor = () => selectedOwner.Color;
                    ownerDropdown.OnClick  = () =>
                    {
                        var owners = editorActorLayer.Players.Players.Values.OrderBy(p => p.Name);
                        ownerDropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 270, owners, setupItem);
                    };

                    initContainer.Bounds.Height += ownerContainer.Bounds.Height;
                    initContainer.AddChild(ownerContainer);

                    // Add new children for inits
                    var options = actor.Info.TraitInfos <IEditorActorOptions>()
                                  .SelectMany(t => t.ActorOptions(actor.Info, worldRenderer.World))
                                  .OrderBy(o => o.DisplayOrder);

                    foreach (var o in options)
                    {
                        if (o is EditorActorCheckbox)
                        {
                            var co = (EditorActorCheckbox)o;
                            var checkboxContainer = checkboxOptionTemplate.Clone();
                            checkboxContainer.Bounds.Y   = initContainer.Bounds.Height;
                            initContainer.Bounds.Height += checkboxContainer.Bounds.Height;

                            var checkbox = checkboxContainer.Get <CheckboxWidget>("OPTION");
                            checkbox.GetText = () => co.Name;

                            var editorActionHandle = new EditorActorOptionActionHandle <bool>(co.OnChange, co.GetValue(actor));
                            editActorPreview.Add(editorActionHandle);

                            checkbox.IsChecked = () => co.GetValue(actor);
                            checkbox.OnClick   = () =>
                            {
                                var newValue = co.GetValue(actor) ^ true;
                                co.OnChange(actor, newValue);
                                editorActionHandle.OnChange(newValue);
                            };

                            initContainer.AddChild(checkboxContainer);
                        }
                        else if (o is EditorActorSlider)
                        {
                            var so = (EditorActorSlider)o;
                            var sliderContainer = sliderOptionTemplate.Clone();
                            sliderContainer.Bounds.Y     = initContainer.Bounds.Height;
                            initContainer.Bounds.Height += sliderContainer.Bounds.Height;
                            sliderContainer.Get <LabelWidget>("LABEL").GetText = () => so.Name;

                            var slider = sliderContainer.Get <SliderWidget>("OPTION");
                            slider.MinimumValue = so.MinValue;
                            slider.MaximumValue = so.MaxValue;
                            slider.Ticks        = so.Ticks;

                            var editorActionHandle = new EditorActorOptionActionHandle <float>(so.OnChange, so.GetValue(actor));
                            editActorPreview.Add(editorActionHandle);

                            slider.GetValue  = () => so.GetValue(actor);
                            slider.OnChange += value => so.OnChange(actor, value);
                            slider.OnChange += value => editorActionHandle.OnChange(value);

                            initContainer.AddChild(sliderContainer);
                        }
                        else if (o is EditorActorDropdown)
                        {
                            var ddo = (EditorActorDropdown)o;
                            var dropdownContainer = dropdownOptionTemplate.Clone();
                            dropdownContainer.Bounds.Y   = initContainer.Bounds.Height;
                            initContainer.Bounds.Height += dropdownContainer.Bounds.Height;
                            dropdownContainer.Get <LabelWidget>("LABEL").GetText = () => ddo.Name;

                            var editorActionHandle = new EditorActorOptionActionHandle <string>(ddo.OnChange, ddo.GetValue(actor));
                            editActorPreview.Add(editorActionHandle);

                            var dropdown = dropdownContainer.Get <DropDownButtonWidget>("OPTION");
                            Func <KeyValuePair <string, string>, ScrollItemWidget, ScrollItemWidget> dropdownSetup = (option, template) =>
                            {
                                var item = ScrollItemWidget.Setup(template,
                                                                  () => ddo.GetValue(actor) == option.Key,
                                                                  () =>
                                {
                                    ddo.OnChange(actor, option.Key);
                                    editorActionHandle.OnChange(option.Key);
                                });

                                item.Get <LabelWidget>("LABEL").GetText = () => option.Value;
                                return(item);
                            };

                            dropdown.GetText = () => ddo.Labels[ddo.GetValue(actor)];
                            dropdown.OnClick = () => dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 270, ddo.Labels, dropdownSetup);

                            initContainer.AddChild(dropdownContainer);
                        }
                    }

                    actorEditPanel.Bounds.Height += initContainer.Bounds.Height - oldInitHeight;
                    buttonContainer.Bounds.Y     += initContainer.Bounds.Height - oldInitHeight;
                }

                // Set the edit panel to the right of the selection border.
                actorEditPanel.Bounds.X = origin.X + editPanelPadding;
                actorEditPanel.Bounds.Y = origin.Y;
            }
            else
            {
                // Selected actor is null, hide the border and edit panel.
                actorIDField.YieldKeyboardFocus();
                CurrentActor = null;
            }
        }