Inheritance: FSO.Client.UI.Framework.UIContainer
Beispiel #1
0
        public override void Update(UpdateState state)
        {
            if (!VM.UseWorld)
            {
                return;
            }

            var botRect = InvalidAreas[3];

            botRect.Y = GlobalSettings.Default.GraphicsHeight - ((Owner.PanelActive) ? 135 : 20);

            InvalidAreas[3] = botRect;
            if (HistoryDialog.Visible)
            {
                TextBox.Visible = false;
            }
            else
            {
                var lastFocus = state.InputManager.GetFocus();
                if (state.NewKeys.Contains(Keys.Enter) && (Owner.EODs.ActiveEOD == null ||
                                                           lastFocus == null || lastFocus == TextBox ||
                                                           lastFocus == HistoryDialog.ChatEntryTextEdit
                                                           ))
                {
                    if (!TextBox.Visible)
                    {
                        TextBox.Clear();
                    }
                    else
                    {
                        SendMessageElem(TextBox);
                    }
                    TextBox.Visible = !TextBox.Visible;

                    if (TextBox.Visible)
                    {
                        state.InputManager.SetFocus(TextBox);
                    }
                }
            }

            if (state.NewKeys.Contains(Keys.H) && state.CtrlDown)
            {
                state.InputManager.SetFocus(null);
                HistoryDialog.Visible = !HistoryDialog.Visible;
            }

            if (state.NewKeys.Contains(Keys.P) && state.CtrlDown)
            {
                PropertyLog.Visible = !PropertyLog.Visible;
            }

            var avatars = vm.Entities.Where(x => (x is VMAvatar)).ToList();

            while (avatars.Count < Labels.Count)
            {
                Remove(Labels[Labels.Count - 1]);
                Labels[Labels.Count - 1].Dispose();
                Labels.RemoveAt(Labels.Count - 1);
            }
            while (avatars.Count > Labels.Count)
            {
                var balloon = new UIChatBalloon(this);
                balloon.Color = Colours[Labels.Count % Colours.Length];
                AddAt(Children.Count - 2, balloon); //behind chat dialog and text box
                Labels.Add(balloon);
            }

            var myAvatar   = vm.GetAvatarByPersist(vm.MyUID);
            var myIgnoring = ((VMTSOAvatarState)myAvatar?.TSOState)?.IgnoredAvatars ?? new HashSet <uint>();

            for (int i = 0; i < Labels.Count; i++)
            {
                var label  = Labels[i];
                var avatar = (VMAvatar)avatars[i];

                if (label.Message != avatar.Message)
                {
                    label.SetNameMessage(avatar.Name, avatar.Message, avatar.GetPersonData(SimAntics.Model.VMPersonDataVariable.Gender) > 0);
                }
                if (myIgnoring.Contains(avatar.PersistID))
                {
                    label.Alpha = 0;
                }
                else
                {
                    if (avatar.MessageTimeout < 30)
                    {
                        label.FadeTime = avatar.MessageTimeout / 3;
                        label.Alpha    = avatar.MessageTimeout / 30f;
                    }
                    else
                    {
                        if (label.FadeTime < 10)
                        {
                            label.FadeTime++;
                        }
                        label.Alpha = label.FadeTime / 10f;
                    }
                }

                var world = vm.Context.World.State;
                var off2  = new Vector2(world.WorldSpace.WorldPxWidth, world.WorldSpace.WorldPxHeight);
                off2 = (off2 / world.PreciseZoom - off2) / 2;

                label.TargetPt = ((avatar.WorldUI.GetScreenPos(vm.Context.World.State) + new Vector2(0, -45) / (1 << (3 - (int)vm.Context.World.State.Zoom)))
                                  + off2) * world.PreciseZoom;
            }
            base.Update(state);
        }
Beispiel #2
0
        public override void Update(UpdateState state)
        {
            Inputs = state.InputManager;
            if (!VM.UseWorld || vm.FSOVAsyncLoading)
            {
                return;
            }

            var botRect = InvalidAreas[3];

            botRect.Y = GlobalSettings.Default.GraphicsHeight - ((Owner.PanelActive) ? 135 : 20);

            InvalidAreas[3] = botRect;

            var avatars = vm.Entities.Where(x => (x is VMAvatar)).ToList();

            while (avatars.Count < Labels.Count)
            {
                Remove(Labels[Labels.Count - 1]);
                Labels[Labels.Count - 1].Dispose();
                Labels.RemoveAt(Labels.Count - 1);
            }
            while (avatars.Count > Labels.Count)
            {
                var balloon = new UIChatBalloon(this);
                AddAt(Children.Count - 2, balloon); //behind chat dialog and text box
                Labels.Add(balloon);
            }

            var myAvatar   = vm.GetAvatarByPersist(vm.MyUID);
            var myIgnoring = ((VMTSOAvatarState)myAvatar?.TSOState)?.IgnoredAvatars ?? new HashSet <uint>();

            for (int i = 0; i < Labels.Count; i++)
            {
                var label  = Labels[i];
                var avatar = (VMAvatar)avatars[i];
                var tstate = ((VMTSOAvatarState)avatar.TSOState);

                if (label.Message != avatar.Message)
                {
                    label.SetNameMessage(avatar);
                }
                if (label.Color != tstate.ChatColor)
                {
                    label.Color = tstate.ChatColor;
                }
                if (myIgnoring.Contains(avatar.PersistID))
                {
                    label.Alpha = 0;
                }
                else
                {
                    if (avatar.MessageTimeout < 30)
                    {
                        label.FadeTime = avatar.MessageTimeout / 3;
                        label.Alpha    = avatar.MessageTimeout / 30f;
                    }
                    else
                    {
                        if (label.FadeTime < 10)
                        {
                            label.FadeTime++;
                        }
                        label.Alpha = label.FadeTime / 10f;
                    }
                }

                var world = vm.Context.World.State;
                var off2  = new Vector2(world.WorldSpace.WorldPxWidth, world.WorldSpace.WorldPxHeight);
                off2 = (off2 / world.PreciseZoom - off2) / 2;

                label.TargetPt = ((avatar.WorldUI.GetScreenPos(vm.Context.World.State) + new Vector2(0, -45) / (1 << (3 - (int)vm.Context.World.State.Zoom)))
                                  + off2) * world.PreciseZoom / FSOEnvironment.DPIScaleFactor;
            }
            base.Update(state);

            var lastFocus = state.InputManager.GetFocus();

            if (HistoryDialog.Visible)
            {
                TextBox.Visible = false;
            }
            else
            {
                if (state.NewKeys.Contains(Keys.Enter) && (
                        lastFocus == null || lastFocus == TextBox ||
                        lastFocus == HistoryDialog.ChatEntryTextEdit
                        ))
                {
                    if (!TextBox.Visible && !JustHidTextbox)
                    {
                        TextBox.Clear();
                        TextBox.Visible = !TextBox.Visible;

                        if (TextBox.Visible)
                        {
                            state.InputManager.SetFocus(TextBox);
                        }
                        else if (lastFocus == TextBox)
                        {
                            state.InputManager.SetFocus(null);
                        }
                    }
                }
            }
            JustHidTextbox = false;
            if (state.NewKeys.Contains(Keys.Escape))
            {
                if (TextBox.Visible)
                {
                    TextBox.Clear();
                    TextBox.Visible = !TextBox.Visible;
                }
                if (HistoryDialog.Visible)
                {
                    if (HistoryDialog.ChatEntryTextEdit.CurrentText.Length > 0)
                    {
                        HistoryDialog.ChatEntryTextEdit.CurrentText = "";
                        HistoryDialog.OKButton.Disabled             = true;
                    }
                    else if (lastFocus == HistoryDialog.ChatEntryTextEdit)
                    {
                        state.InputManager.SetFocus(null);
                    }
                }
            }
            if (state.NewKeys.Contains(Keys.Enter) && HistoryDialog.Visible)
            {
                if (lastFocus == null)
                {
                    state.InputManager.SetFocus(HistoryDialog.ChatEntryTextEdit);
                }

                /*
                 * if (HistoryDialog.ChatEntryTextEdit.CurrentText.Length < 1)
                 * if (lastFocus == HistoryDialog.ChatEntryTextEdit)
                 * state.InputManager.SetFocus(null);
                 * else if (lastFocus == null)
                 * state.InputManager.SetFocus(HistoryDialog.ChatEntryTextEdit);
                 */
            }
            if (state.NewKeys.Contains(Keys.H) && state.CtrlDown)
            {
                HistoryDialog.Visible = !HistoryDialog.Visible;
                if (HistoryDialog.Visible)
                {
                    state.InputManager.SetFocus(HistoryDialog.ChatEntryTextEdit);
                }
                else
                {
                    state.InputManager.SetFocus(null);
                }
            }

            if (state.NewKeys.Contains(Keys.OemPlus) && state.CtrlDown && HistoryDialog.Visible)
            {
                HistoryDialog.ResizeChatDialogByDelta(1);
            }

            if (state.NewKeys.Contains(Keys.OemMinus) && state.CtrlDown && HistoryDialog.Visible)
            {
                HistoryDialog.ResizeChatDialogByDelta(-1);
            }

            if (state.NewKeys.Contains(Keys.P) && state.CtrlDown)
            {
                PropertyLog.Visible = !PropertyLog.Visible;
            }
        }
Beispiel #3
0
        public override void Update(UpdateState state)
        {
            if (!VM.UseWorld)
            {
                return;
            }

            var botRect = InvalidAreas[3];

            botRect.Y = GlobalSettings.Default.GraphicsHeight - ((Owner.PanelActive) ? 135 : 20);

            InvalidAreas[3] = botRect;
            if (HistoryDialog.Visible)
            {
                TextBox.Visible = false;
            }
            else
            {
                var lastFocus = state.InputManager.GetFocus();
                if (state.NewKeys.Contains(Keys.Enter) && (Owner.EODs.ActiveEOD == null ||
                                                           lastFocus == null || lastFocus == TextBox ||
                                                           lastFocus == HistoryDialog.ChatEntryTextEdit
                                                           ))
                {
                    if (!TextBox.Visible)
                    {
                        TextBox.Clear();
                    }
                    TextBox.Visible = !TextBox.Visible;

                    if (TextBox.Visible)
                    {
                        state.InputManager.SetFocus(TextBox);
                    }
                }
            }

            if (state.NewKeys.Contains(Keys.H) && state.KeyboardState.IsKeyDown(Keys.LeftControl))
            {
                state.InputManager.SetFocus(null);
                HistoryDialog.Visible = !HistoryDialog.Visible;
            }

            if (state.NewKeys.Contains(Keys.P) && state.KeyboardState.IsKeyDown(Keys.LeftControl))
            {
                PropertyLog.Visible = !PropertyLog.Visible;
            }

            var avatars = vm.Entities.Where(x => (x is VMAvatar)).ToList();

            while (avatars.Count < Labels.Count)
            {
                Remove(Labels[Labels.Count - 1]);
                Labels.RemoveAt(Labels.Count - 1);
            }
            while (avatars.Count > Labels.Count)
            {
                var balloon = new UIChatBalloon(this);
                balloon.Color = Colours[Labels.Count % Colours.Length];
                AddAt(Children.Count - 2, balloon); //behind chat dialog and text box
                Labels.Add(balloon);
            }

            for (int i = 0; i < Labels.Count; i++)
            {
                var label  = Labels[i];
                var avatar = (VMAvatar)avatars[i];

                if (label.Message != avatar.Message)
                {
                    label.SetNameMessage(avatar.Name, avatar.Message);
                }

                if (avatar.MessageTimeout < 30)
                {
                    label.FadeTime = avatar.MessageTimeout / 3;
                    label.Alpha    = avatar.MessageTimeout / 30f;
                }
                else
                {
                    if (label.FadeTime < 10)
                    {
                        label.FadeTime++;
                    }
                    label.Alpha = label.FadeTime / 10f;
                }

                label.TargetPt = avatar.WorldUI.GetScreenPos(vm.Context.World.State) + new Vector2(0, -45) / (1 << (3 - (int)vm.Context.World.State.Zoom));
            }
            base.Update(state);
        }
Beispiel #4
0
        public override void Update(UpdateState state)
        {
            if (!VM.UseWorld) return;

            var botRect = InvalidAreas[3];
            botRect.Y = GlobalSettings.Default.GraphicsHeight - ((Owner.PanelActive) ? 135 : 20);

            InvalidAreas[3] = botRect;
            if (HistoryDialog.Visible) TextBox.Visible = false;
            else
            {
                var lastFocus = state.InputManager.GetFocus();
                if (state.NewKeys.Contains(Keys.Enter) && (Owner.EODs.ActiveEOD == null ||
                        lastFocus == null || lastFocus == TextBox ||
                        lastFocus == HistoryDialog.ChatEntryTextEdit
                        ))
                {
                    if (!TextBox.Visible) TextBox.Clear();
                    TextBox.Visible = !TextBox.Visible;

                    if (TextBox.Visible) state.InputManager.SetFocus(TextBox);
                }
            }

            if (state.NewKeys.Contains(Keys.H) && state.KeyboardState.IsKeyDown(Keys.LeftControl))
            {
                state.InputManager.SetFocus(null);
                HistoryDialog.Visible = !HistoryDialog.Visible;
            }

            if (state.NewKeys.Contains(Keys.P) && state.KeyboardState.IsKeyDown(Keys.LeftControl))
            {
                PropertyLog.Visible = !PropertyLog.Visible;
            }

            var avatars = vm.Entities.Where(x => (x is VMAvatar)).ToList();
            while (avatars.Count < Labels.Count)
            {
                Remove(Labels[Labels.Count - 1]);
                Labels.RemoveAt(Labels.Count - 1);
            }
            while (avatars.Count > Labels.Count)
            {
                var balloon = new UIChatBalloon(this);
                balloon.Color = Colours[Labels.Count % Colours.Length];
                AddAt(Children.Count - 2, balloon); //behind chat dialog and text box
                Labels.Add(balloon);
            }

            for (int i=0; i<Labels.Count; i++)
            {
                var label = Labels[i];
                var avatar = (VMAvatar)avatars[i];

                if (label.Message != avatar.Message)
                    label.SetNameMessage(avatar.Name, avatar.Message);

                if (avatar.MessageTimeout < 30)
                {
                    label.FadeTime = avatar.MessageTimeout / 3;
                    label.Alpha = avatar.MessageTimeout / 30f;
                }
                else
                {
                    if (label.FadeTime < 10) label.FadeTime++;
                    label.Alpha = label.FadeTime / 10f;
                }

                label.TargetPt = avatar.WorldUI.GetScreenPos(vm.Context.World.State) + new Vector2(0, -45) / (1 << (3 - (int)vm.Context.World.State.Zoom));

            }
            base.Update(state);
        }