Exemple #1
0
        private void _joinGame(MsgTickerJoinGame message)
        {
            if (_tickerState == TickerState.InGame)
            {
                return;
            }

            _tickerState = TickerState.InGame;

            if (_lobby != null)
            {
                _lobby.Dispose();
                _lobby = null;
            }

            _inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
                                          InputCmdHandler.FromDelegate(session =>
            {
                _gameChat.Input.IgnoreNext = true;
                _gameChat.Input.GrabKeyboardFocus();
            }));

            _gameChat = new ChatBox();
            _userInterfaceManager.StateRoot.AddChild(_gameChat);
            _chatManager.SetChatBox(_gameChat);
            _tutorialButton = new TutorialButton();
            _userInterfaceManager.StateRoot.AddChild(_tutorialButton);
            _tutorialButton.SetAnchorAndMarginPreset(Control.LayoutPreset.BottomLeft, Control.LayoutPresetMode.MinSize, 50);
            _gameChat.DefaultChatFormat = "say \"{0}\"";
        }
Exemple #2
0
        protected string CyclicBroadcastStartString(TickerState state, CyclicBroadcastType broadcastType, string location)
        {
            if (!ConfigurationManager.Instance.Settings.CyclicBriefingsAllowed || broadcastType == CyclicBroadcastType.None)
            {
                return(null);
            }

            // For the briefing, context doesn't matter much. It gets weird if you try to make these in the context of only day or only night.
            switch (state)
            {
            case TickerState.Enabled:
                return($"It is day time {location}.");

            case TickerState.Disabled:
                return($"It is night time {location}.");

            case TickerState.Disabling:
                return($"It will be night time {location} soon.");

            case TickerState.Enabling:
                return($"It will be day time {location} soon.");

            default:
                return(null);
            }
        }
Exemple #3
0
        private void _joinGame(MsgTickerJoinGame message)
        {
            if (_tickerState == TickerState.InGame)
            {
                return;
            }

            _tickerState = TickerState.InGame;

            if (_lobby != null)
            {
                _lobby.Chat.TextSubmitted -= _chatConsole.ParseChatMessage;
                _chatConsole.AddString    -= _lobby.Chat.AddLine;
                _lobby.Dispose();
                _lobby = null;
            }

            _inputManager.SetInputCommand(EngineKeyFunctions.FocusChat,
                                          InputCmdHandler.FromDelegate(session => { _gameChat.Input.GrabKeyboardFocus(); }));

            _gameChat = new Chatbox();
            _userInterfaceManager.StateRoot.AddChild(_gameChat);
            _gameChat.TextSubmitted    += _chatConsole.ParseChatMessage;
            _chatConsole.AddString     += _gameChat.AddLine;
            _gameChat.DefaultChatFormat = "say \"{0}\"";
        }
Exemple #4
0
        private void _joinGame(MsgTickerJoinGame message)
        {
            if (_tickerState == TickerState.InGame)
            {
                return;
            }

            _tickerState = TickerState.InGame;

            if (_lobby != null)
            {
                _lobby.Dispose();
                _lobby = null;
            }

            _inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
                                          InputCmdHandler.FromDelegate(session =>
            {
                _gameChat.Input.IgnoreNext = true;
                _gameChat.Input.GrabKeyboardFocus();
            }));

            _gameChat = new ChatBox();
            _userInterfaceManager.StateRoot.AddChild(_gameChat);
            _chatManager.SetChatBox(_gameChat);
            _gameChat.DefaultChatFormat = "say \"{0}\"";
        }
Exemple #5
0
        protected void AbsoluteResetBroadcast(Ticker ticker, TickerState oldState, TickerState newState, string tickerDescription, CheckState tickerChecked)
        {
            if (tickerChecked == CheckState.Unchecked)
            {
                return;
            }

            string notification = null;

            if (oldState == TickerState.Uninitialized)
            {
                if (ConfigurationManager.Instance.Settings.ResetBriefingsAllowed)
                {
                    string remainingTime = newState == TickerState.Disabling ? "soon" : $"in {Utilities.ReadableTimeSpan(ticker.TimeLeft, false)}";
                    notification = $"{tickerDescription} will be resetting {remainingTime}.";
                }
            }
            else
            {
                if (newState == TickerState.Disabled)
                {
                    notification = $"{tickerDescription} have reset for the day.";
                    OnLogMessage?.Invoke("Reset", notification);
                }
                else if (newState == TickerState.Disabling)
                {
                    notification = $"{tickerDescription} will be resetting soon.";
                }
            }

            if (!string.IsNullOrEmpty(notification))
            {
                Broadcast(notification);
            }
        }
        private void _joinGame(MsgTickerJoinGame message)
        {
            if (_tickerState == TickerState.InGame)
            {
                return;
            }

            _tickerState = TickerState.InGame;

            if (_lobby != null)
            {
                _lobby.Dispose();
                _lobby = null;
            }

            _gameChat = new ChatBox();
            _userInterfaceManager.StateRoot.AddChild(_gameChat);
            _userInterfaceManager.StateRoot.AddChild(_gameHud.RootControl);
            _chatManager.SetChatBox(_gameChat);
            _gameChat.DefaultChatFormat = "say \"{0}\"";
            _gameChat.Input.PlaceHolder = _localization.GetString("Say something! [ for OOC");

            _inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
                                          InputCmdHandler.FromDelegate(s => _focusChat(_gameChat)));
        }
Exemple #7
0
        protected void OnDailyState(TickerState oldState, TickerState newState)
        {
            AbsoluteResetBroadcast(DailyTicker, oldState, newState, "Daily rewards and faction standing limits", ConfigurationManager.Instance.Settings.DailyResets);

            if (newState == TickerState.Disabled)
            {
                DailyTicker.ResetToTimeSpecific(dailyResetTime);
            }
        }
        private void _joinLobby(MsgTickerJoinLobby message)
        {
            if (_tickerState == TickerState.InLobby)
            {
                return;
            }

            if (_gameChat != null)
            {
                _gameChat.Dispose();
                _gameChat = null;
            }

            _gameHud.RootControl.Orphan();

            _tickerState = TickerState.InLobby;

            _lobby = new LobbyGui(_localization, _resourceCache);
            _userInterfaceManager.StateRoot.AddChild(_lobby);

            _lobby.SetAnchorAndMarginPreset(Control.LayoutPreset.Wide, margin: 20);

            _chatManager.SetChatBox(_lobby.Chat);
            _lobby.Chat.DefaultChatFormat = "ooc \"{0}\"";

            _lobby.ServerName.Text = _baseClient.GameInfo.ServerName;

            _inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
                                          InputCmdHandler.FromDelegate(s => _focusChat(_lobby.Chat)));

            _updateLobbyUi();

            _lobby.ObserveButton.OnPressed += args => _console.ProcessCommand("observe");
            _lobby.ReadyButton.OnPressed   += args =>
            {
                if (!_gameStarted)
                {
                    return;
                }

                _console.ProcessCommand("joingame");
            };

            _lobby.ReadyButton.OnToggled += args =>
            {
                if (_gameStarted)
                {
                    return;
                }

                _console.ProcessCommand($"toggleready {args.Pressed}");
            };

            _lobby.LeaveButton.OnPressed += args => _console.ProcessCommand("disconnect");

            _updatePlayerList();
        }
Exemple #9
0
        protected void OnMissionState(TickerState oldState, TickerState newState)
        {
            AbsoluteResetBroadcast(MissionTicker, oldState, newState, "Sorties and syndicate missions", ConfigurationManager.Instance.Settings.MissionResets);

            if (newState == TickerState.Disabled)
            {
                MissionTicker.ResetToTimeSpecific(missionResetTime);
            }
        }
Exemple #10
0
        protected void OnWeeklyState(TickerState oldState, TickerState newState)
        {
            AbsoluteResetBroadcast(WeeklyTicker, oldState, newState, "Weekly rewards", ConfigurationManager.Instance.Settings.WeeklyResets);

            if (newState == TickerState.Disabled)
            {
                WeeklyTicker.ResetToDay(weeklyResetDay);
            }
        }
Exemple #11
0
        private void _joinLobby(MsgTickerJoinLobby message)
        {
            if (_tickerState == TickerState.InLobby)
            {
                return;
            }

            if (_gameChat != null)
            {
                _gameChat.Dispose();
                _gameChat = null;
            }

            _tickerState = TickerState.InLobby;

            _lobby = new LobbyGui();
            _userInterfaceManager.StateRoot.AddChild(_lobby);

            _chatManager.SetChatBox(_lobby.Chat);
            _lobby.Chat.DefaultChatFormat = "ooc \"{0}\"";

            _lobby.ServerName.Text = _baseClient.GameInfo.ServerName;

            _inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
                                          InputCmdHandler.FromDelegate(session =>
            {
                _lobby.Chat.Input.IgnoreNext = true;
                _lobby.Chat.Input.GrabKeyboardFocus();
            }));

            _updateLobbyUi();

            _lobby.ObserveButton.OnPressed += args => _console.ProcessCommand("observe");
            _lobby.ReadyButton.OnPressed   += args =>
            {
                if (!_gameStarted)
                {
                    return;
                }

                _console.ProcessCommand("joingame");
            };

            _lobby.ReadyButton.OnToggled += args =>
            {
                if (_gameStarted)
                {
                    return;
                }

                _console.ProcessCommand($"toggleready {args.Pressed}");
            };

            _lobby.LeaveButton.OnPressed += args => _console.ProcessCommand("disconnect");
        }
Exemple #12
0
        protected void OnEarthState(TickerState oldState, TickerState newState)
        {
            string location          = "on Earth";
            CyclicBroadcastType type = GetCyclicBroadcastType(ConfigurationManager.Instance.Settings.EarthDayNotifications, ConfigurationManager.Instance.Settings.EarthNightNotifications);
            string broadcast         = oldState == TickerState.Uninitialized ? CyclicBroadcastStartString(newState, type, location) : CyclicBroadcastChangeString(newState, type, location);

            if (!string.IsNullOrEmpty(broadcast))
            {
                Broadcast(broadcast);
            }
        }
Exemple #13
0
        protected void SetState(TickerState newState)
        {
            if (State == newState)
            {
                return;
            }

            TickerState oldState = State;

            State = newState;
            OnStateChanged?.Invoke(oldState, newState);
        }
Exemple #14
0
        private void BaseClientOnRunLevelChanged(object sender, RunLevelChangedEventArgs e)
        {
            if (e.NewLevel != ClientRunLevel.Initialize)
            {
                return;
            }

            _tickerState = TickerState.Unset;
            _lobby?.Dispose();
            _lobby = null;
            _gameChat?.Dispose();
            _gameChat = null;
        }
        private void BaseClientOnRunLevelChanged(object sender, RunLevelChangedEventArgs e)
        {
            if (e.NewLevel != ClientRunLevel.Initialize)
            {
                _inputManager.SetInputCommand(ContentKeyFunctions.FocusChat, null);
                return;
            }

            _tickerState = TickerState.Unset;
            _lobby?.Dispose();
            _lobby = null;
            _gameChat?.Dispose();
            _gameChat = null;
            _gameHud.RootControl.Orphan();
        }
Exemple #16
0
        protected void OnTickerState(TickerState oldState, TickerState newState)
        {
            switch (newState)
            {
            case TickerState.Disabling:
                OnExtractorNotification?.Invoke($"{Name} extractors will complete their resource harvesting soon.");
                break;

            case TickerState.Disabled:
                OnExtractorNotification?.Invoke($"{Name} extractors have completed their resource harvesting.");
                IsActive = false;
                OnExtractorFinished?.Invoke();
                break;
            }
        }
Exemple #17
0
        public void StartListening()
        {
            lock (_tickerStateLock)
            {
                if (TickerState != TickerState.Open)
                {
                    _timer = new Timer(TryEmitRecords, null, _updateInterval, _updateInterval);
                    //TryEmitRecords(null);

                    TickerState = TickerState.Open;

                    // Broadcast
                    BroadcastTickerStateChange(TickerState.Open);
                }
            }
        }
Exemple #18
0
        private void TryEmitRecords(object state)
        {
            lock (_tickerRecordLock)
            {
                if (!_emittingRecords)
                {
                    _emittingRecords = true;

                    using (var context = new LogDbContext())
                    {
                        var records = context.LogRecords
                                      .OrderBy(x => x.TimestampUTC)
                                      .GroupBy(x => new
                        {
                            x.TimestampUTC.Year,
                            x.TimestampUTC.Month,
                            x.TimestampUTC.Day,
                            x.TimestampUTC.Hour,
                            //x.TimestampUTC.Minute
                        })
                                      .Select(x => new { x.Key, Count = x.Count() })
                                      .ToList()
                                      .GroupBy(x => (new DateTime(x.Key.Year, x.Key.Month, x.Key.Day, x.Key.Hour, 0, 0)).RoundToNearest(TimeSpan.FromHours(6)))
                                      .Select(x => new { Date = x.Key, Count = x.Sum(v => v.Count) });

                        var rEnum = records.GetEnumerator();

                        while (rEnum.MoveNext() && TickerState == TickerState.Open)
                        {
                            var record = rEnum.Current;

                            BroadcastRecord(new Tuple <DateTime, int>(record.Date, record.Count));

                            Task.Delay(500).Wait();
                        }
                    }

                    if (TickerState == TickerState.Open)
                    {
                        TickerState = TickerState.Finished;
                        BroadcastTickerStateChange(TickerState.Finished);
                    }

                    _emittingRecords = false;
                }
            }
        }
Exemple #19
0
        public void StopListening()
        {
            lock (_tickerStateLock)
            {
                if (TickerState == TickerState.Open)
                {
                    if (_timer != null)
                    {
                        _timer.Dispose();
                    }

                    TickerState = TickerState.Closed;

                    BroadcastTickerStateChange(TickerState.Closed);
                }
            }
        }
Exemple #20
0
        private void BroadcastTickerStateChange(TickerState state)
        {
            switch (state)
            {
            case TickerState.Closed:
                Clients.All.tickerStopped();
                break;

            case TickerState.Open:
                Clients.All.tickerStarted();
                break;

            case TickerState.Finished:
                Clients.All.tickerFinished();
                break;

            default:
                break;
            }
        }
Exemple #21
0
        protected string CyclicBroadcastChangeString(TickerState state, CyclicBroadcastType broadcastType, string location)
        {
            switch (broadcastType)
            {
            case CyclicBroadcastType.All:
                switch (state)
                {
                case TickerState.Enabled:
                    return($"Day time is starting {location}.");

                case TickerState.Disabled:
                    return($"Night time is starting {location}.");

                case TickerState.Disabling:
                    return($"Night time is starting {location} soon.");

                case TickerState.Enabling:
                    return($"Day time is starting {location} soon.");

                default:
                    return(null);
                }

            case CyclicBroadcastType.OnlyEnabled:
                switch (state)
                {
                case TickerState.Enabled:
                    return($"Day time is starting {location}.");

                case TickerState.Disabled:
                    return($"Day time is ending {location}.");

                case TickerState.Disabling:
                    return($"Day time is ending {location} soon.");

                case TickerState.Enabling:
                    return($"Day time is starting {location} soon.");

                default:
                    return(null);
                }

            case CyclicBroadcastType.OnlyDisabled:
                switch (state)
                {
                case TickerState.Enabled:
                    return($"Night time is ending {location}.");

                case TickerState.Disabled:
                    return($"Night time is starting {location}.");

                case TickerState.Disabling:
                    return($"Night time is starting {location} soon.");

                case TickerState.Enabling:
                    return($"Night time is ending {location} soon.");

                default:
                    return(null);
                }

            default:
                return(null);
            }
        }
        private void _joinLobby(MsgTickerJoinLobby message)
        {
            if (_tickerState == TickerState.InLobby)
            {
                return;
            }

            if (_gameChat != null)
            {
                _gameChat.Dispose();
                _gameChat = null;
            }

            _gameHud.RootControl.Orphan();

            _tickerState = TickerState.InLobby;

            _characterSetup = new CharacterSetupGui(_entityManager, _localization, _resourceCache, _preferencesManager, _prototypeManager);
            LayoutContainer.SetAnchorPreset(_characterSetup, LayoutContainer.LayoutPreset.Wide);
            _characterSetup.CloseButton.OnPressed += args =>
            {
                _characterSetup.Save();
                _lobby.CharacterPreview.UpdateUI();
                _userInterfaceManager.StateRoot.AddChild(_lobby);
                _userInterfaceManager.StateRoot.RemoveChild(_characterSetup);
            };
            _lobby = new LobbyGui(_entityManager, _localization, _resourceCache, _preferencesManager);
            _userInterfaceManager.StateRoot.AddChild(_lobby);

            LayoutContainer.SetAnchorPreset(_lobby, LayoutContainer.LayoutPreset.Wide);

            _chatManager.SetChatBox(_lobby.Chat);
            _lobby.Chat.DefaultChatFormat = "ooc \"{0}\"";

            _lobby.ServerName.Text = _baseClient.GameInfo.ServerName;

            _inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
                                          InputCmdHandler.FromDelegate(s => _focusChat(_lobby.Chat)));

            _updateLobbyUi();

            _lobby.CharacterPreview.CharacterSetupButton.OnPressed += args =>
            {
                SetReady(false);
                _userInterfaceManager.StateRoot.RemoveChild(_lobby);
                _userInterfaceManager.StateRoot.AddChild(_characterSetup);
            };

            _lobby.ObserveButton.OnPressed += args => _console.ProcessCommand("observe");
            _lobby.ReadyButton.OnPressed   += args =>
            {
                if (!_gameStarted)
                {
                    return;
                }

                _console.ProcessCommand("joingame");
            };

            _lobby.ReadyButton.OnToggled += args =>
            {
                SetReady(args.Pressed);
            };

            _lobby.LeaveButton.OnPressed += args => _console.ProcessCommand("disconnect");

            _updatePlayerList();
        }