Exemple #1
0
        void OpenMenuPanel(MenuButtonWidget button, WidgetArgs widgetArgs = null)
        {
            disableSystemButtons = true;
            var cachedPause = world.PredictedPaused;

            if (button.HideIngameUI)
            {
                worldRoot.IsVisible = () => false;
            }

            if (button.Pause && world.LobbyInfo.IsSinglePlayer)
            {
                world.SetPauseState(true);
            }

            widgetArgs = widgetArgs ?? new WidgetArgs();
            widgetArgs.Add("onExit", () =>
            {
                if (button.HideIngameUI)
                {
                    worldRoot.IsVisible = () => true;
                }

                if (button.Pause && world.LobbyInfo.IsSinglePlayer)
                {
                    world.SetPauseState(cachedPause);
                }

                menuRoot.RemoveChild(currentWidget);
                disableSystemButtons = false;
            });

            currentWidget = Game.LoadWidget(world, button.MenuContainer, menuRoot, widgetArgs);
        }
Exemple #2
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);
        }
Exemple #3
0
        void OpenMenuPanel(MenuButtonWidget button, WidgetArgs widgetArgs = null)
        {
            disableSystemButtons = true;
            var cachedPause = world.PredictedPaused;

            if (button.HideIngameUI)
            {
                // Cancel custom input modes (guard, building placement, etc)
                world.CancelInputMode();

                worldRoot.IsVisible = () => false;
            }

            if (button.Pause && world.LobbyInfo.NonBotClients.Count() == 1)
            {
                world.SetPauseState(true);
            }

            var cachedDisableWorldSounds = Game.Sound.DisableWorldSounds;

            if (button.DisableWorldSounds)
            {
                Game.Sound.DisableWorldSounds = true;
            }

            widgetArgs = widgetArgs ?? new WidgetArgs();
            widgetArgs.Add("onExit", () =>
            {
                if (button.HideIngameUI)
                {
                    worldRoot.IsVisible = () => true;
                }

                if (button.DisableWorldSounds)
                {
                    Game.Sound.DisableWorldSounds = cachedDisableWorldSounds;
                }

                if (button.Pause && world.LobbyInfo.NonBotClients.Count() == 1)
                {
                    world.SetPauseState(cachedPause);
                }

                menuRoot.RemoveChild(currentWidget);
                disableSystemButtons = false;
            });

            currentWidget = Game.LoadWidget(world, button.MenuContainer, menuRoot, widgetArgs);
            Game.RunAfterTick(Ui.ResetTooltips);
        }
		public void StartGame(Arguments args)
		{
			var widgetArgs = new WidgetArgs();

			Ui.LoadWidget("MODCHOOSER_BACKGROUND", Ui.Root, widgetArgs);

			if (args != null && args.Contains("installMusic"))
			{
				widgetArgs.Add("modId", args.GetValue("installMusic", ""));
				Ui.OpenWindow("INSTALL_MUSIC_PANEL", widgetArgs);
			}
			else
				Ui.OpenWindow("MODCHOOSER_DIALOG", widgetArgs);
		}
Exemple #5
0
        void ShowMenu()
        {
            if (sidebar.IngameUi.World.LobbyInfo.NonBotClients.Count() == 1)
            {
                sidebar.IngameUi.World.SetPauseState(true);
            }

            var widgetArgs = new WidgetArgs();

            widgetArgs.Add("activePanel", IngameInfoPanel.AutoSelect);
            widgetArgs.Add("onExit", () =>
            {
                if (sidebar.IngameUi.World.LobbyInfo.NonBotClients.Count() == 1)
                {
                    sidebar.IngameUi.World.SetPauseState(false);
                }

                Ui.Root.Get("MENU_ROOT").RemoveChild(menu);
                Active = false;
                menu   = null;
            });

            menu = Game.LoadWidget(sidebar.IngameUi.World, "INGAME_MENU", Ui.Root.Get("MENU_ROOT"), widgetArgs);
        }
        public void StartGame(Arguments args)
        {
            var widgetArgs = new WidgetArgs();

            Ui.LoadWidget("MODCHOOSER_BACKGROUND", Ui.Root, widgetArgs);

            if (args != null && args.Contains("installMusic"))
            {
                widgetArgs.Add("modId", args.GetValue("installMusic", ""));
                Ui.OpenWindow("INSTALL_MUSIC_PANEL", widgetArgs);
            }
            else
            {
                Ui.OpenWindow("MODCHOOSER_DIALOG", widgetArgs);
            }
        }
        void OpenMenuPanel(MenuButtonWidget button, WidgetArgs widgetArgs = null)
        {
            disableSystemButtons = true;
            var cachedPause = world.PredictedPaused;

            if (button.HideIngameUI)
            {
                // Cancel custom input modes (guard, building placement, etc)
                world.CancelInputMode();

                worldRoot.IsVisible = () => false;
            }

            if (button.Pause && world.LobbyInfo.IsSinglePlayer)
                world.SetPauseState(true);

            widgetArgs = widgetArgs ?? new WidgetArgs();
            widgetArgs.Add("onExit", () =>
            {
                if (button.HideIngameUI)
                    worldRoot.IsVisible = () => true;

                if (button.Pause && world.LobbyInfo.IsSinglePlayer)
                    world.SetPauseState(cachedPause);

                menuRoot.RemoveChild(currentWidget);
                disableSystemButtons = false;
            });

            currentWidget = Game.LoadWidget(world, button.MenuContainer, menuRoot, widgetArgs);
            Game.RunAfterTick(Ui.ResetTooltips);
        }
		void OpenMenuPanel(MenuButtonWidget button, WidgetArgs widgetArgs = null)
		{
			disableSystemButtons = true;
			var cachedPause = world.PredictedPaused;

			if (button.HideIngameUI)
				worldRoot.IsVisible = () => false;

			if (button.Pause && world.LobbyInfo.IsSinglePlayer)
				world.SetPauseState(true);

			widgetArgs = widgetArgs ?? new WidgetArgs();
			widgetArgs.Add("onExit", () =>
			{
				if (button.HideIngameUI)
					worldRoot.IsVisible = () => true;

				if (button.Pause && world.LobbyInfo.IsSinglePlayer)
					world.SetPauseState(cachedPause);

				menuRoot.RemoveChild(currentWidget);
				disableSystemButtons = false;
			});

			currentWidget = Game.LoadWidget(world, button.MenuContainer, menuRoot, widgetArgs);
		}