Пример #1
0
        public static void LanGameOptionsMenuInit(Window window, Game game)
        {
            GameOptions = new GameOptionsUtil(window, game, "Lan");

            // Clear chat field
            var textChat = (TextBox)window.Controls.FindControl(TextEntryChatPrefix);

            textChat.Text = string.Empty;
        }
Пример #2
0
        public static void LanGameOptionsMenuInit(Window window, Game game)
        {
            GameOptions = new GameOptionsUtil(window, game, "Lan");

            GameOptions.OnSlotIndexChange += (index, name, value) =>
            {
                if (game?.SkirmishManager?.SkirmishGame == null)
                {
                    return;
                }

                var slot = game.SkirmishManager.SkirmishGame.Slots[index];

                switch (name)
                {
                case GameOptionsUtil.ComboBoxColorPrefix:
                    logger.Info($"Changed the color box to {value}");
                    slot.ColorIndex = (byte)value;
                    break;

                case GameOptionsUtil.ComboBoxPlayerPrefix:
                    logger.Info($"Changed the player type box to {value}");

                    break;

                case GameOptionsUtil.ComboBoxPlayerTemplatePrefix:
                    logger.Info($"Changed the faction box to {value}");
                    slot.FactionIndex = (byte)value;
                    break;

                case GameOptionsUtil.ComboBoxTeamPrefix:
                    logger.Info($"Changed the team box to {value}");
                    slot.Team = (byte)value;
                    break;
                }
            };

            // Clear chat field
            var textChat = (TextBox)window.Controls.FindControl(TextEntryChatPrefix);

            textChat.Text = string.Empty;


            var buttonStart = (Button)window.Controls.FindControl($"LanGameOptionsMenu.wnd:ButtonStart");

            //TODO: Use the right language strings
            buttonStart.Text = game.SkirmishManager.IsHosting ? "Play Game" : "Accept";

            //game.SkirmishManager.OnStop += () =>
            //{
            //    //TODO: somehow make this work
            //    game.Scene2D.WndWindowManager.SetWindow(@"Menus\LanLobbyMenu.wnd");
            //};
        }
        public static async void LanGameOptionsMenuInit(Window window, Game game)
        {
            GameOptions = new GameOptionsUtil(window, game, "Lan");

            if (game.SkirmishManager.IsHosting)
            {
                game.SkirmishManager.Settings.MapName = GameOptions.CurrentMap.Name;
            }

            // Clear chat field
            var textChat = (TextBox)window.Controls.FindControl(TextEntryChatPrefix);

            textChat.Text = string.Empty;


            var buttonStart = (Button)window.Controls.FindControl($"LanGameOptionsMenu.wnd:ButtonStart");

            //TODO: Use the right language strings
            buttonStart.Text = game.SkirmishManager.IsHosting ? "Play Game" : "Accept";

            //game.SkirmishManager.OnStop += () =>
            //{
            //    //TODO: somehow make this work
            //    game.Scene2D.WndWindowManager.SetWindow(@"Menus\LanLobbyMenu.wnd");
            //};

            if (window.Tag == NetworkUtils.OnlineTag && game.SkirmishManager.IsHosting)
            {
                var listBoxChat = (ListBox)window.Controls.FindControl(ListboxChatWindowLanGamePrefix);
                var listBoxItem = new ListBoxDataItem(null, new string[] { "Checking UPnP status..." }, ColorRgbaF.White);
                listBoxChat.Items = new[] { listBoxItem };

                if (UPnP.Status == UPnPStatus.Enabled)
                {
                    if (await UPnP.ForwardPortsAsync())
                    {
                        listBoxItem.ColumnData[0] = $"Ports forwarded via UPnP. Your external IP is {UPnP.ExternalIP?.ToString() ?? "unknown."}";
                    }
                    else
                    {
                        listBoxItem.ColumnData[0] = $"Failed to forward ports via UPnP. Your external IP is {UPnP.ExternalIP?.ToString() ?? "unknown."}";
                    }
                }
                else
                {
                    listBoxItem.ColumnData[0] = "UPnP is disabled.";
                }
            }
        }
Пример #4
0
        public static void LanGameOptionsMenuInit(Window window, Game game)
        {
            GameOptions = new GameOptionsUtil(window, game, "Lan");

            // Clear chat field
            var textChat = (TextBox)window.Controls.FindControl(TextEntryChatPrefix);

            textChat.Text = string.Empty;

            //game.SkirmishManager.OnStop += () =>
            //{
            //    //TODO: somehow make this work
            //    game.Scene2D.WndWindowManager.SetWindow(@"Menus\LanLobbyMenu.wnd");
            //};
        }
Пример #5
0
 public static void LanGameOptionsMenuInit(Window window, Game game)
 {
     GameOptions = new GameOptionsUtil(window, game, "Lan");
 }
Пример #6
0
        public static async void LanGameOptionsMenuInit(Window window, Game game)
        {
            GameOptions = new GameOptionsUtil(window, game, "Lan");

            if (game.SkirmishManager.IsHosting)
            {
                game.SkirmishManager.SkirmishGame.MapName = GameOptions.CurrentMap.Name;
            }

            GameOptions.OnSlotIndexChange += (index, name, value) =>
            {
                if (game?.SkirmishManager?.SkirmishGame == null)
                {
                    return;
                }

                var slot = game.SkirmishManager.SkirmishGame.Slots[index];

                switch (name)
                {
                case GameOptionsUtil.ComboBoxColorPrefix:
                    Logger.Trace($"Changed the color box to {value}");
                    slot.ColorIndex = (byte)value;
                    break;

                case GameOptionsUtil.ComboBoxPlayerPrefix:
                    Logger.Trace($"Changed the player type box to {value}");

                    break;

                case GameOptionsUtil.ComboBoxPlayerTemplatePrefix:
                    Logger.Trace($"Changed the faction box to {value}");
                    slot.FactionIndex = (byte)value;
                    break;

                case GameOptionsUtil.ComboBoxTeamPrefix:
                    Logger.Trace($"Changed the team box to {value}");
                    slot.Team = (byte)value;
                    break;
                }
            };

            // Clear chat field
            var textChat = (TextBox)window.Controls.FindControl(TextEntryChatPrefix);

            textChat.Text = string.Empty;


            var buttonStart = (Button)window.Controls.FindControl($"LanGameOptionsMenu.wnd:ButtonStart");

            //TODO: Use the right language strings
            buttonStart.Text = game.SkirmishManager.IsHosting ? "Play Game" : "Accept";

            //game.SkirmishManager.OnStop += () =>
            //{
            //    //TODO: somehow make this work
            //    game.Scene2D.WndWindowManager.SetWindow(@"Menus\LanLobbyMenu.wnd");
            //};

            if (window.Tag == NetworkUtils.OnlineTag && game.SkirmishManager.IsHosting)
            {
                var listBoxChat = (ListBox)window.Controls.FindControl(ListboxChatWindowLanGamePrefix);
                var listBoxItem = new ListBoxDataItem(null, new string[] { "Checking UPnP status..." }, ColorRgbaF.White);
                listBoxChat.Items = new[] { listBoxItem };

                if (UPnP.Status == UPnPStatus.Enabled)
                {
                    if (await UPnP.ForwardPortsAsync())
                    {
                        listBoxItem.ColumnData[0] = $"Ports forwarded via UPnP. Your external IP is {UPnP.ExternalIP?.ToString() ?? "unknown."}";
                    }
                    else
                    {
                        listBoxItem.ColumnData[0] = $"Failed to forward ports via UPnP. Your external IP is {UPnP.ExternalIP?.ToString() ?? "unknown."}";
                    }
                }
                else
                {
                    listBoxItem.ColumnData[0] = "UPnP is disabled.";
                }
            }
        }
Пример #7
0
 public static void SkirmishGameOptionsMenuInit(Window window, Game game)
 {
     GameOptions = new GameOptionsUtil(window, game, "Skirmish");
 }