当前位置: 首页>>代码示例>>C#>>正文


C# Widget.RemoveChild方法代码示例

本文整理汇总了C#中OpenRA.Widgets.Widget.RemoveChild方法的典型用法代码示例。如果您正苦于以下问题:C# Widget.RemoveChild方法的具体用法?C# Widget.RemoveChild怎么用?C# Widget.RemoveChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OpenRA.Widgets.Widget的用法示例。


在下文中一共展示了Widget.RemoveChild方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MapChooserLogic

        internal MapChooserLogic(Widget widget, string initialMap, MapClassification initialTab, Action onExit, Action<string> onSelect, MapVisibility filter)
        {
            this.widget = widget;
            this.onSelect = onSelect;

            var approving = new Action(() => { Ui.CloseWindow(); onSelect(selectedUid); });
            var canceling = new Action(() => { Ui.CloseWindow(); onExit(); });

            var okButton = widget.Get<ButtonWidget>("BUTTON_OK");
            okButton.Disabled = this.onSelect == null;
            okButton.OnClick = approving;
            widget.Get<ButtonWidget>("BUTTON_CANCEL").OnClick = canceling;

            gameModeDropdown = widget.GetOrNull<DropDownButtonWidget>("GAMEMODE_FILTER");

            var itemTemplate = widget.Get<ScrollItemWidget>("MAP_TEMPLATE");
            widget.RemoveChild(itemTemplate);

            var mapFilterInput = widget.GetOrNull<TextFieldWidget>("MAPFILTER_INPUT");
            if (mapFilterInput != null)
            {
                mapFilterInput.TakeKeyboardFocus();
                mapFilterInput.OnEscKey = () =>
                {
                    if (mapFilterInput.Text.Length == 0)
                        canceling();
                    else
                    {
                        mapFilter = mapFilterInput.Text = null;
                        EnumerateMaps(currentTab, itemTemplate);
                    }

                    return true;
                };
                mapFilterInput.OnEnterKey = () => { approving(); return true; };
                mapFilterInput.OnTextEdited = () =>
                {
                    mapFilter = mapFilterInput.Text;
                    EnumerateMaps(currentTab, itemTemplate);
                };
            }

            var randomMapButton = widget.GetOrNull<ButtonWidget>("RANDOMMAP_BUTTON");
            if (randomMapButton != null)
            {
                randomMapButton.OnClick = () =>
                {
                    var uid = visibleMaps.Random(Game.CosmeticRandom);
                    selectedUid = uid;
                    scrollpanels[currentTab].ScrollToItem(uid, smooth: true);
                };
                randomMapButton.IsDisabled = () => visibleMaps == null || visibleMaps.Length == 0;
            }

            var deleteMapButton = widget.Get<ButtonWidget>("DELETE_MAP_BUTTON");
            deleteMapButton.IsDisabled = () => Game.ModData.MapCache[selectedUid].Class != MapClassification.User;
            deleteMapButton.IsVisible = () => currentTab == MapClassification.User;
            deleteMapButton.OnClick = () =>
            {
                DeleteOneMap(selectedUid, (string newUid) =>
                {
                    RefreshMaps(currentTab, filter);
                    EnumerateMaps(currentTab, itemTemplate);
                    if (!tabMaps[currentTab].Any())
                        SwitchTab(Game.ModData.MapCache[newUid].Class, itemTemplate);
                });
            };

            var deleteAllMapsButton = widget.Get<ButtonWidget>("DELETE_ALL_MAPS_BUTTON");
            deleteAllMapsButton.IsVisible = () => currentTab == MapClassification.User;
            deleteAllMapsButton.OnClick = () =>
            {
                DeleteAllMaps(visibleMaps, (string newUid) =>
                {
                    RefreshMaps(currentTab, filter);
                    EnumerateMaps(currentTab, itemTemplate);
                    SwitchTab(Game.ModData.MapCache[newUid].Class, itemTemplate);
                });
            };

            SetupMapTab(MapClassification.User, filter, "USER_MAPS_TAB_BUTTON", "USER_MAPS_TAB", itemTemplate);
            SetupMapTab(MapClassification.System, filter, "SYSTEM_MAPS_TAB_BUTTON", "SYSTEM_MAPS_TAB", itemTemplate);

            if (initialMap == null && tabMaps.Keys.Contains(initialTab) && tabMaps[initialTab].Any())
            {
                selectedUid = WidgetUtils.ChooseInitialMap(tabMaps[initialTab].Select(mp => mp.Uid).First());
                currentTab = initialTab;
            }
            else
            {
                selectedUid = WidgetUtils.ChooseInitialMap(initialMap);
                currentTab = tabMaps.Keys.FirstOrDefault(k => tabMaps[k].Select(mp => mp.Uid).Contains(selectedUid));
            }

            SwitchTab(currentTab, itemTemplate);
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:96,代码来源:MapChooserLogic.cs

示例2: LayoutDialog

        // This is shit
        void LayoutDialog(Widget bg)
        {
            foreach (var c in controls)
                bg.RemoveChild(c);
            controls.Clear();

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

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

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

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

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

            y += 35;

            foreach (var p in world.Players.Where(a => a != world.LocalPlayer && !a.NonCombatant))
            {
                var pp = p;
                var label = new LabelWidget
                {
                    Bounds = new Rectangle(margin, y, labelWidth, 25),
                    Text = p.PlayerName,
                    Align = TextAlign.Left,
                    Font = "Bold",
                    Color = p.Color.RGB,
                };

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

                var theirStance = new LabelWidget
                {
                    Bounds = new Rectangle( margin + labelWidth + 10, y, labelWidth, 25),
                    Text = p.PlayerName,
                    Align = TextAlign.Left,

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

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

                var myStance = new DropDownButtonWidget
                {
                    Bounds = new Rectangle( margin + 2 * labelWidth + 20,  y, labelWidth, 25),
                    GetText = () => world.LocalPlayer.Stances[ pp ].ToString(),
                };

                if (!p.World.LobbyInfo.GlobalSettings.FragileAlliances)
                    myStance.Disabled = true;

                myStance.OnMouseDown = mi => ShowDropDown(pp, myStance);

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

                y += 35;
            }
        }
开发者ID:Tsher,项目名称:OpenRA,代码行数:79,代码来源:DiplomacyLogic.cs

示例3: MenuButtonsChromeLogic

        public MenuButtonsChromeLogic(Widget widget, World world)
        {
            this.world = world;

            worldRoot = Ui.Root.Get("WORLD_ROOT");
            menuRoot = Ui.Root.Get("MENU_ROOT");

            Action removeCurrentWidget = () => menuRoot.RemoveChild(currentWidget);
            world.GameOver += removeCurrentWidget;

            // System buttons
            var options = widget.GetOrNull<MenuButtonWidget>("OPTIONS_BUTTON");
            if (options != null)
            {
                var blinking = false;
                var lp = world.LocalPlayer;
                options.IsDisabled = () => disableSystemButtons;
                options.OnClick = () =>
                {
                    blinking = false;
                    OpenMenuPanel(options, new WidgetArgs()
                    {
                        { "activePanel", IngameInfoPanel.AutoSelect }
                    });
                };
                options.IsHighlighted = () => blinking && Game.LocalTick % 50 < 25;

                if (lp != null)
                {
                    Action<Player, bool> startBlinking = (player, inhibitAnnouncement) =>
                    {
                        if (!inhibitAnnouncement && player == world.LocalPlayer)
                            blinking = true;
                    };

                    var mo = lp.PlayerActor.TraitOrDefault<MissionObjectives>();

                    if (mo != null)
                        mo.ObjectiveAdded += startBlinking;
                }
            }

            var diplomacy = widget.GetOrNull<MenuButtonWidget>("DIPLOMACY_BUTTON");
            if (diplomacy != null)
            {
                diplomacy.Visible = !world.Map.Visibility.HasFlag(MapVisibility.MissionSelector) && world.Players.Any(a => a != world.LocalPlayer && !a.NonCombatant);
                diplomacy.IsDisabled = () => disableSystemButtons;
                diplomacy.OnClick = () => OpenMenuPanel(diplomacy);
            }

            var debug = widget.GetOrNull<MenuButtonWidget>("DEBUG_BUTTON");
            if (debug != null)
            {
                debug.IsVisible = () => world.LobbyInfo.GlobalSettings.AllowCheats;
                debug.IsDisabled = () => disableSystemButtons;
                debug.OnClick = () => OpenMenuPanel(debug, new WidgetArgs()
                {
                    { "activePanel", IngameInfoPanel.Debug }
                });
            }

            var stats = widget.GetOrNull<MenuButtonWidget>("OBSERVER_STATS_BUTTON");
            if (stats != null)
            {
                stats.IsDisabled = () => disableSystemButtons;
                stats.OnClick = () => OpenMenuPanel(stats);
            }
        }
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:68,代码来源:MenuButtonsChromeLogic.cs


注:本文中的OpenRA.Widgets.Widget.RemoveChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。