示例#1
0
        public static void SetupChatLine(ContainerWidget template, DateTime time, string name, Color nameColor, string text, Color textColor)
        {
            var nameLabel = template.Get <LabelWidget>("NAME");
            var timeLabel = template.Get <LabelWidget>("TIME");
            var textLabel = template.Get <LabelWidget>("TEXT");

            var nameText = name + ":";
            var font     = Game.Renderer.Fonts[nameLabel.Font];
            var nameSize = font.Measure(nameText);

            timeLabel.GetText = () => "{0:D2}:{1:D2}".F(time.Hour, time.Minute);

            nameLabel.GetColor     = () => nameColor;
            nameLabel.GetText      = () => nameText;
            nameLabel.Bounds.Width = nameSize.X;

            textLabel.GetColor      = () => textColor;
            textLabel.Bounds.X     += nameSize.X;
            textLabel.Bounds.Width -= nameSize.X;

            // Hack around our hacky wordwrap behavior: need to resize the widget to fit the text
            text = WidgetUtils.WrapText(text, textLabel.Bounds.Width, font);
            textLabel.GetText = () => text;
            var dh = font.Measure(text).Y - textLabel.Bounds.Height;

            if (dh > 0)
            {
                textLabel.Bounds.Height += dh;
                template.Bounds.Height  += dh;
            }
        }
示例#2
0
        public QuaternionPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ContainerWidget.AddNode(new Widget {
                Layout = new HBoxLayout {
                    CellDefaults = new LayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorX = editorParams.NumericEditBoxFactory()),
                    (editorY = editorParams.NumericEditBoxFactory()),
                    (editorZ = editorParams.NumericEditBoxFactory())
                }
            });
            var current = CoalescedPropertyValue();

            editorX.Submitted += text => SetComponent(editorParams, 0, editorX, current.GetValue());
            editorY.Submitted += text => SetComponent(editorParams, 1, editorY, current.GetValue());
            editorZ.Submitted += text => SetComponent(editorParams, 2, editorZ, current.GetValue());
            editorX.AddChangeWatcher(current, v => {
                var ea       = v.ToEulerAngles() * Mathf.RadToDeg;
                editorX.Text = RoundAngle(ea.X).ToString();
                editorY.Text = RoundAngle(ea.Y).ToString();
                editorZ.Text = RoundAngle(ea.Z).ToString();
            });
        }
示例#3
0
 protected FilePropertyEditor(IPropertyEditorParams editorParams, string[] allowedFileTypes) : base(editorParams)
 {
     ContainerWidget.AddNode(new Widget {
         Layout = new HBoxLayout(),
         Nodes  =
         {
             (editor         = editorParams.EditBoxFactory()),
             new HSpacer(4),
             (button         = new ThemedButton {
                 Text        = "...",
                 MinMaxWidth =                             20,
                 LayoutCell  = new LayoutCell(Alignment.Center)
             })
         }
     });
     editor.LayoutCell = new LayoutCell(Alignment.Center);
     editor.Submitted += text => AssignAsset(AssetPath.CorrectSlashes(text));
     button.Clicked   += () => {
         var dlg = new FileDialog {
             AllowedFileTypes = allowedFileTypes,
             Mode             = FileDialogMode.Open,
             InitialDirectory = Directory.Exists(LastOpenedDirectory) ? LastOpenedDirectory : Project.Current.GetSystemDirectory(Document.Current.Path),
         };
         if (dlg.RunModal())
         {
             SetFilePath(dlg.FileName);
             LastOpenedDirectory = Project.Current.GetSystemDirectory(dlg.FileName);
         }
     };
 }
        public GameInfoObjectivesLogic(Widget widget, World world)
        {
            var lp = world.LocalPlayer;

            var missionStatus = widget.Get <LabelWidget>("MISSION_STATUS");

            missionStatus.GetText = () => lp.WinState == WinState.Undefined ? "In progress" :
                                    lp.WinState == WinState.Won ? "Accomplished" : "Failed";
            missionStatus.GetColor = () => lp.WinState == WinState.Undefined ? Color.White :
                                     lp.WinState == WinState.Won ? Color.LimeGreen : Color.Red;

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

            if (mo == null)
            {
                return;
            }

            var objectivesPanel = widget.Get <ScrollPanelWidget>("OBJECTIVES_PANEL");

            template = objectivesPanel.Get <ContainerWidget>("OBJECTIVE_TEMPLATE");

            PopulateObjectivesList(mo, objectivesPanel, template);

            Action <Player, bool> redrawObjectives = (player, _) =>
            {
                if (player == lp)
                {
                    PopulateObjectivesList(mo, objectivesPanel, template);
                }
            };

            mo.ObjectiveAdded += redrawObjectives;
        }
        private async Task SetData(IEnumerable <Row> rows, NicheShackContext context, QueryParams queryParams)
        {
            foreach (Row row in rows)
            {
                if (row.Background != null && row.Background.Image != null)
                {
                    await row.Background.Image.SetData(context);
                }

                foreach (Column column in row.Columns)
                {
                    if (column.Background != null && column.Background.Image != null)
                    {
                        await column.Background.Image.SetData(context);
                    }


                    // Create the widget
                    Widget widget = page.GetWidget(column.WidgetData.WidgetType, column.WidgetData);


                    await widget.SetData(context, queryParams);

                    if (column.WidgetData.WidgetType == WidgetType.Container)
                    {
                        ContainerWidget container = (ContainerWidget)column.WidgetData;

                        if (container.Rows != null && container.Rows.Count() > 0)
                        {
                            await SetData(container.Rows, context, queryParams);
                        }
                    }
                }
            }
        }
        public GlobalChatLogic(Widget widget)
        {
            historyPanel     = widget.Get <ScrollPanelWidget>("HISTORY_PANEL");
            chatTemplate     = historyPanel.Get <ContainerWidget>("CHAT_TEMPLATE");
            nicknamePanel    = widget.Get <ScrollPanelWidget>("NICKNAME_PANEL");
            nicknameTemplate = nicknamePanel.Get("NICKNAME_TEMPLATE");

            var textColor = ChromeMetrics.Get <Color>("GlobalChatTextColor");
            var textLabel = chatTemplate.Get <LabelWidget>("TEXT");

            textLabel.GetColor = () => textColor;

            historyPanel.Bind(Game.GlobalChat.History, MakeHistoryWidget, HistoryWidgetEquals, true);
            nicknamePanel.Bind(Game.GlobalChat.Users, MakeUserWidget, UserWidgetEquals, false);

            inputBox            = widget.Get <TextFieldWidget>("CHAT_TEXTFIELD");
            inputBox.IsDisabled = () => Game.GlobalChat.ConnectionStatus != ChatConnectionStatus.Joined;
            inputBox.OnEnterKey = EnterPressed;

            // IRC protocol limits messages to 510 characters + CRLF
            inputBox.MaxLength = 510;

            var nickName    = Game.GlobalChat.SanitizedName(Game.Settings.Player.Name);
            var nicknameBox = widget.Get <TextFieldWidget>("NICKNAME_TEXTFIELD");

            nicknameBox.Text         = nickName;
            nicknameBox.OnTextEdited = () =>
            {
                nicknameBox.Text = Game.GlobalChat.SanitizedName(nicknameBox.Text);
            };

            var connectPanel = widget.Get("GLOBALCHAT_CONNECT_PANEL");

            connectPanel.IsVisible = () => Game.GlobalChat.ConnectionStatus == ChatConnectionStatus.Disconnected;

            var disconnectButton = widget.Get <ButtonWidget>("DISCONNECT_BUTTON");

            disconnectButton.OnClick = Game.GlobalChat.Disconnect;

            var connectAutomaticallyCheckBox = connectPanel.Get <CheckboxWidget>("CONNECT_AUTOMATICALLY_CHECKBOX");

            connectAutomaticallyCheckBox.IsChecked = () => Game.Settings.Chat.ConnectAutomatically;
            connectAutomaticallyCheckBox.OnClick   = () => { Game.Settings.Chat.ConnectAutomatically ^= true; Game.Settings.Save(); };

            var connectButton = connectPanel.Get <ButtonWidget>("CONNECT_BUTTON");

            connectButton.IsDisabled = () => !Game.GlobalChat.IsValidNickname(nicknameBox.Text);
            connectButton.OnClick    = () => Game.GlobalChat.Connect(nicknameBox.Text);

            var mainPanel = widget.Get("GLOBALCHAT_MAIN_PANEL");

            mainPanel.IsVisible = () => Game.GlobalChat.ConnectionStatus != ChatConnectionStatus.Disconnected;

            mainPanel.Get <LabelWidget>("CHANNEL_TOPIC").GetText = () => Game.GlobalChat.Topic;

            if (Game.Settings.Chat.ConnectAutomatically)
            {
                Game.GlobalChat.Connect(nickName);
            }
        }
示例#7
0
        public static void SetupChatLine(ContainerWidget template, DateTime time, TextNotification chatLine)
        {
            var nameLabel = template.Get <LabelWidget>("NAME");
            var timeLabel = template.Get <LabelWidget>("TIME");
            var textLabel = template.Get <LabelWidget>("TEXT");

            var nameText = chatLine.Prefix + ":";
            var font     = Game.Renderer.Fonts[nameLabel.Font];
            var nameSize = font.Measure(nameText);

            timeLabel.GetText = () => $"{time.Hour:D2}:{time.Minute:D2}";

            nameLabel.GetColor     = () => chatLine.PrefixColor;
            nameLabel.GetText      = () => nameText;
            nameLabel.Bounds.Width = nameSize.X;

            textLabel.GetColor      = () => chatLine.TextColor;
            textLabel.Bounds.X     += nameSize.X;
            textLabel.Bounds.Width -= nameSize.X;

            // Hack around our hacky wordwrap behavior: need to resize the widget to fit the text
            var text = WidgetUtils.WrapText(chatLine.Text, textLabel.Bounds.Width, font);

            textLabel.GetText = () => text;
            var dh = font.Measure(text).Y - textLabel.Bounds.Height;

            if (dh > 0)
            {
                textLabel.Bounds.Height += dh;
                template.Bounds.Height  += dh;
            }
        }
示例#8
0
        public override void Update()
        {
            try
            {
                this.blockIconWidget.Value = int.Parse(blockID.Text);
            }
            catch
            {
                this.blockIconWidget.Value = 0;
            }



            if (this.cancelButton.IsClicked)
            {
                DialogsManager.HideDialog(this);
            }
            if (this.SelectBlockButton.IsClicked)
            {
                int[] items = new int[] { 0, 2, 8, 7, 3, 67, 66, 4, 5, 26, 73, 21, 46, 47, 15, 62, 68, 126, 71, 1, 92, 18 };
                DialogsManager.ShowDialog(null, new ListSelectionDialog("Select Block", items, 72f, delegate(object index)
                {
                    XElement node = ContentManager.Get <XElement>("Widgets/SelectBlockItem");
                    ContainerWidget containerWidget = (ContainerWidget)WidgetsManager.LoadWidget(null, node, null);
                    containerWidget.Children.Find <BlockIconWidget>("SelectBlockItem.Block", true).Contents = (int)index;
                    containerWidget.Children.Find <LabelWidget>("SelectBlockItem.Text", true).Text          = BlocksManager.Blocks[(int)index].GetDisplayName(null, Terrain.MakeBlockValue((int)index));
                    return(containerWidget);
                }, delegate(object index)
                {
                    this.blockID.Text = ((int)index).ToString();
                }));
            }
        }
        public GameInfoObjectivesLogic(Widget widget, World world)
        {
            var lp = world.LocalPlayer;

            var missionStatus = widget.Get<LabelWidget>("MISSION_STATUS");
            missionStatus.GetText = () => lp.WinState == WinState.Undefined ? "In progress" :
                lp.WinState == WinState.Won ? "Accomplished" : "Failed";
            missionStatus.GetColor = () => lp.WinState == WinState.Undefined ? Color.White :
                lp.WinState == WinState.Won ? Color.LimeGreen : Color.Red;

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

            var objectivesPanel = widget.Get<ScrollPanelWidget>("OBJECTIVES_PANEL");
            template = objectivesPanel.Get<ContainerWidget>("OBJECTIVE_TEMPLATE");

            PopulateObjectivesList(mo, objectivesPanel, template);

            Action<Player> redrawObjectives = player =>
            {
                if (player == lp)
                    PopulateObjectivesList(mo, objectivesPanel, template);
            };
            mo.ObjectiveAdded += redrawObjectives;
        }
        public DictionaryPropertyEditor(IPropertyEditorParams editorParams, Func <Type, PropertyEditorParams, Widget, object, IEnumerable <IPropertyEditor> > populateEditors) : base(editorParams)
        {
            if (EditorParams.Objects.Skip(1).Any())
            {
                EditorContainer.AddNode(new Widget()
                {
                    Layout = new HBoxLayout(),
                    Nodes  = { new ThemedSimpleText {
                                   Text = "Edit of dictionary properties isn't supported for multiple selection.", ForceUncutText = false
                               } },
                    Presenter = new WidgetFlatFillPresenter(Theme.Colors.WarningBackground)
                });
                return;
            }
            this.populateEditors = populateEditors;
            dictionary           = PropertyValue(EditorParams.Objects.First()).GetValue();
            var addButton = new ThemedAddButton {
                Clicked = () => {
                    if (dictionary == null)
                    {
                        var pi = EditorParams.PropertyInfo;
                        var o  = EditorParams.Objects.First();
                        pi.SetValue(o, dictionary = Activator.CreateInstance <TDictionary>());
                    }
                    if (dictionary.ContainsKey(keyValueToAdd.Key))
                    {
                        AddWarning($"Key \"{keyValueToAdd.Key}\" already exists.", ValidationResult.Warning);
                        return;
                    }
                    using (Document.Current.History.BeginTransaction()) {
                        InsertIntoDictionary <TDictionary, string, TValue> .Perform(dictionary, keyValueToAdd.Key,
                                                                                    keyValueToAdd.Value);

                        ExpandableContent.Nodes.Add(CreateDefaultKeyValueEditor(keyValueToAdd.Key,
                                                                                keyValueToAdd.Value));
                        Document.Current.History.CommitTransaction();
                    }
                    keyValueToAdd.Value = DefaultValue;
                    keyValueToAdd.Key   = string.Empty;
                },
                LayoutCell = new LayoutCell(Alignment.LeftCenter),
            };
            var keyEditorContainer = CreateKeyEditor(editorParams, keyValueToAdd, s => keyValueToAdd.Key = s, addButton);

            ExpandableContent.Nodes.Add(keyEditorContainer);
            ExpandableContent.Nodes.Add(CreateValueEditor(editorParams, keyValueToAdd, populateEditors));
            Rebuild();
            EditorContainer.Tasks.AddLoop(() => {
                if (dictionary != null && ((ICollection)dictionary).Count != pairs.Count)
                {
                    Rebuild();
                }
            });
            var current = PropertyValue(EditorParams.Objects.First());

            ContainerWidget.AddChangeWatcher(() => current.GetValue(), d => {
                dictionary = d;
                Rebuild();
            });
        }
 public SkinningWeightsPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     editorParams.DefaultValueGetter = () => new SkinningWeights();
     indexEditors   = new NumericEditBox[4];
     weightsSliders = new ThemedAreaSlider[4];
     foreach (var o in editorParams.Objects)
     {
         var prop = new Property <SkinningWeights>(o, editorParams.PropertyName).Value;
     }
     for (var i = 0; i <= 3; i++)
     {
         indexEditors[i]      = editorParams.NumericEditBoxFactory();
         indexEditors[i].Step = 1;
         weightsSliders[i]    = new ThemedAreaSlider(range: new Vector2(0, 1), labelFormat: "0.00000");
         var wrapper = new Widget {
             Layout     = new HBoxLayout(),
             LayoutCell = new LayoutCell {
                 StretchY = 0
             }
         };
         var propertyLabel = new ThemedSimpleText {
             Text       = $"Bone { char.ConvertFromUtf32(65 + i) }",
             VAlignment = VAlignment.Center,
             Padding    = new Thickness {
                 Left = 20
             },
             LayoutCell = new LayoutCell {
                 StretchX = 1.0f
             },
             ForceUncutText = false,
             OverflowMode   = TextOverflowMode.Minify,
             HitTestTarget  = false
         };
         wrapper.AddNode(propertyLabel);
         wrapper.AddNode(new Widget {
             Layout = new HBoxLayout {
                 Spacing = 4
             },
             LayoutCell = new LayoutCell {
                 StretchX = 2.0f
             },
             Nodes =
             {
                 indexEditors[i],
                 weightsSliders[i]
             }
         });
         ExpandableContent.AddNode(wrapper);
         customWarningsContainer = new Widget {
             Layout = new VBoxLayout()
         };
         ContainerWidget.AddNode(customWarningsContainer);
         var j = i;
         SetLink(i, CoalescedPropertyComponentValue(sw => sw[j].Index), CoalescedPropertyComponentValue(sw => sw[j].Weight));
     }
     CheckWarnings();
 }
示例#12
0
        public IngameChatLogic(Widget widget, OrderManager orderManager, World world)
        {
            World = world;
            var chatPanel = (ContainerWidget) widget;

            ChatOverlay = chatPanel.Get<ContainerWidget>("CHAT_OVERLAY");
            ChatOverlayDisplay = ChatOverlay.Get<ChatDisplayWidget>("CHAT_DISPLAY");
            ChatOverlay.Visible = false;

            ChatChrome = chatPanel.Get<ContainerWidget>("CHAT_CHROME");
            ChatChrome.Visible = true;

            var chatMode = ChatChrome.Get<ButtonWidget>("CHAT_MODE");
            chatMode.GetText = () => TeamChat ? "Team" : "All";
            chatMode.OnClick = () => TeamChat = !TeamChat;

            ChatText = ChatChrome.Get<TextFieldWidget>("CHAT_TEXTFIELD");
            ChatText.OnTabKey = () => { TeamChat = !TeamChat; return true; };
            ChatText.OnEnterKey = () =>
            {
                ChatText.Text = ChatText.Text.Trim();
                if (ChatText.Text != "")
                    orderManager.IssueOrder(Order.Chat(TeamChat, ChatText.Text));
                CloseChat();
                return true;
            };
            ChatText.OnEscKey = () => {CloseChat(); return true; };

            var chatClose = ChatChrome.Get<ButtonWidget>("CHAT_CLOSE");
            chatClose.OnClick += () => CloseChat();

            chatPanel.OnKeyPress = (e) =>
            {
                if (e.Event == KeyInputEvent.Up) return false;
                if (!IsOpen && (e.KeyName == "enter" || e.KeyName == "return") )
                {

                    var shift = e.Modifiers.HasModifier(Modifiers.Shift);
                    var toggle = Game.Settings.Game.TeamChatToggle ;
                    TeamChat = (!toggle && shift) || ( toggle &&  (TeamChat ^ shift) );
                    OpenChat();
                    return true;
                }

                return false;
            };

            ChatScrollPanel = ChatChrome.Get<ScrollPanelWidget>("CHAT_SCROLLPANEL");
            ChatTemplate = ChatScrollPanel.Get<ContainerWidget>("CHAT_TEMPLATE");

            Game.AddChatLine += AddChatLine;
            Game.BeforeGameStart += UnregisterEvents;

            CloseChat();
            ChatOverlayDisplay.AddLine(Color.White, null, "Use RETURN key to open chat window...");
        }
示例#13
0
        protected FilePropertyEditor(IPropertyEditorParams editorParams, string[] allowedFileTypes) : base(editorParams)
        {
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout(),
                Nodes  =
                {
                    (editor         = editorParams.EditBoxFactory()),
                    Spacer.HSpacer(4),
                    (button         = new ThemedButton {
                        Text        = "...",
                        MinMaxWidth =                             20,
                        LayoutCell  = new LayoutCell(Alignment.Center)
                    })
                }
            });
            editor.LayoutCell = new LayoutCell(Alignment.Center);
            editor.Submitted += text => SetComponent(text);
            bool textValid = true;

            editor.AddChangeWatcher(() => editor.Text, text => textValid = IsValid(text));
            editor.CompoundPostPresenter.Add(new SyncDelegatePresenter <EditBox>(editBox => {
                if (!textValid)
                {
                    editBox.PrepareRendererState();
                    Renderer.DrawRect(Vector2.Zero, editBox.Size, Color4.Red.Transparentify(0.8f));
                }
            }));
            button.Clicked += () => {
                var dlg = new FileDialog {
                    AllowedFileTypes = allowedFileTypes,
                    Mode             = FileDialogMode.Open,
                    InitialDirectory = Directory.Exists(LastOpenedDirectory) ? LastOpenedDirectory : Project.Current.GetSystemDirectory(Document.Current.Path),
                };
                if (dlg.RunModal())
                {
                    SetFilePath(dlg.FileName);
                    LastOpenedDirectory = Project.Current.GetSystemDirectory(dlg.FileName);
                }
            };
            ExpandableContent.Padding = new Thickness(24, 10, 2, 2);
            var prefixEditor = new StringPropertyEditor(new PropertyEditorParams(ExpandableContent, prefix, nameof(PrefixData.Prefix))
            {
                LabelWidth = 180
            });

            prefix.Prefix = GetLongestCommonPrefix(GetPaths());
            ContainerWidget.AddChangeWatcher(() => prefix.Prefix, v => {
                string oldPrefix = GetLongestCommonPrefix(GetPaths());
                if (oldPrefix == v)
                {
                    return;
                }
                SetPathPrefix(oldPrefix, v);
                prefix.Prefix = v.Trim('/');
            });
        }
示例#14
0
 public StringPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams)
 {
     editor            = editorParams.EditBoxFactory();
     editor.LayoutCell = new LayoutCell(Alignment.Center);
     editor.Editor.EditorParams.MaxLines = multiline ? maxLines : 1;
     editor.MinHeight += multiline ? editor.TextWidget.FontHeight * (maxLines - 1) : 0;
     ContainerWidget.AddNode(editor);
     editor.Submitted += SetProperty;
     editor.AddChangeWatcher(CoalescedPropertyValue(), v => editor.Text = v);
 }
示例#15
0
        void AdjustHeader(ContainerWidget headerTemplate)
        {
            var offset = playerStatsPanel.ScrollbarWidth;

            headerTemplate.Get <ColorBlockWidget>("HEADER_COLOR").Bounds.Width        += offset;
            headerTemplate.Get <GradientColorBlockWidget>("HEADER_GRADIENT").Bounds.X += offset;

            foreach (var headerLabel in headerTemplate.Children.OfType <LabelWidget>())
            {
                headerLabel.Bounds.X += offset;
            }
        }
示例#16
0
        protected override void Execute()
        {
            ContainerWidget container = FindParent <ProfilingPage>().FindChild <ContainerWidget>();
            T widget = container.FindChild <T>();

            if (widget == null)
            {
                widget = new T();
                container.AttachChild(widget);
            }
            container.CurrentChild = widget;
        }
示例#17
0
 public RenderTexturePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     editor            = editorParams.EditBoxFactory();
     editor.IsReadOnly = true;
     editor.LayoutCell = new LayoutCell(Alignment.Center);
     ContainerWidget.AddNode(editor);
     editor.AddChangeWatcher(CoalescedPropertyValue(), v =>
                             editor.Text = v == null ?
                                           "RenderTexture (null)" :
                                           $"RenderTexture ({v.ImageSize.Width}x{v.ImageSize.Height})"
                             );
 }
示例#18
0
 public BooleanPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     checkBox = new ThemedCheckBox {
         LayoutCell = new LayoutCell(Alignment.LeftCenter)
     };
     ContainerWidget.AddNode(checkBox);
     checkBox.Changed += args => {
         if (args.ChangedByUser)
         {
             SetProperty(args.Value);
         }
     };
     checkBox.AddChangeWatcher(CoalescedPropertyValue(), v => checkBox.Checked = v);
 }
示例#19
0
 public AnchorsPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
 {
     group = new Widget {
         Layout = new HBoxLayout {
             CellDefaults = new LayoutCell(Alignment.Center), Spacing = 4
         }
     };
     ContainerWidget.AddNode(group);
     firstButton = AddButton(Anchors.Left, "Anchor to the left");
     AddButton(Anchors.Right, "Anchor to the right");
     AddButton(Anchors.Top, "Anchor to the top");
     AddButton(Anchors.Bottom, "Anchor to the bottom");
     AddButton(Anchors.CenterH, "Anchor to the center horizontally");
     AddButton(Anchors.CenterV, "Anchor to the center vertically");
 }
        void AdjustStatisticsPanel(ContainerWidget headerTemplate, Widget itemTemplate)
        {
            var height = playerStatsPanel.Bounds.Height;

            if (players.Count() > 8)
            {
                playerStatsPanel.ScrollbarWidth = 24;
            }
            playerStatsPanel.Bounds.Width  = itemTemplate.Bounds.Width + playerStatsPanel.ScrollbarWidth;
            playerStatsPanel.Bounds.Height = Math.Min(players.Count(), 8) * (itemTemplate.Bounds.Height + playerStatsPanel.ItemSpacing) + playerStatsPanel.TopBottomSpacing * 2;
            if (playerStatsPanel.Bounds.Height < height)
            {
                playerStatsPanel.ScrollToTop();
            }
            headerTemplate.Parent.Bounds.Width = playerStatsPanel.Bounds.Width;
        }
示例#21
0
        public NodeReferencePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            var propName = editorParams.PropertyName;

            if (propName.EndsWith("Ref"))
            {
                PropertyLabel.Text = propName.Substring(0, propName.Length - 3);
            }
            editor            = editorParams.EditBoxFactory();
            editor.LayoutCell = new LayoutCell(Alignment.Center);
            ContainerWidget.AddNode(editor);
            editor.Submitted += text => {
                SetProperty(new NodeReference <T>(text));
            };
            editor.AddChangeWatcher(CoalescedPropertyValue(), v => editor.Text = v?.Id);
        }
示例#22
0
        public FloatPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor = editorParams.NumericEditBoxFactory();
            ContainerWidget.AddNode(editor);
            var current = CoalescedPropertyValue();

            editor.Submitted += text => {
                float newValue;
                if (float.TryParse(text, out newValue))
                {
                    SetProperty(newValue);
                }

                editor.Text = current.GetValue().ToString();
            };
            editor.AddChangeWatcher(current, v => editor.Text = v.ToString());
        }
示例#23
0
        protected FilePropertyEditor(IPropertyEditorParams editorParams, string[] allowedFileTypes) : base(editorParams)
        {
            ThemedButton button;

            this.allowedFileTypes = allowedFileTypes;
            EditorContainer.AddNode(new Widget {
                Layout = new HBoxLayout(),
                Nodes  =
                {
                    (editor         = editorParams.EditBoxFactory()),
                    Spacer.HSpacer(4),
                    (button         = new ThemedButton {
                        Text        = "...",
                        MinMaxWidth =                             20,
                        LayoutCell  = new LayoutCell(Alignment.Center)
                    })
                }
            });
            editor.LayoutCell         = new LayoutCell(Alignment.Center);
            editor.Submitted         += text => SetComponent(text);
            button.Clicked           += OnSelectClicked;
            ExpandableContent.Padding = new Thickness(24, 10, 2, 2);
            var prefixEditor = new StringPropertyEditor(new PropertyEditorParams(ExpandableContent, prefix, nameof(PrefixData.Prefix))
            {
                LabelWidth = 180
            });

            prefix.Prefix = GetLongestCommonPrefix(GetPaths());
            ContainerWidget.AddChangeWatcher(() => prefix.Prefix, v => {
                string oldPrefix = GetLongestCommonPrefix(GetPaths());
                if (oldPrefix == v)
                {
                    return;
                }
                SetPathPrefix(oldPrefix, v);
                prefix.Prefix = v.Trim('/');
            });
            ContainerWidget.AddChangeWatcher(() => ShowPrefix, show => {
                Expanded             = show && Expanded;
                ExpandButton.Visible = show;
            });
            var current = CoalescedPropertyValue();

            editor.AddChangeLateWatcher(current, v => editor.Text = ValueToStringConverter(v.Value) ?? "");
            ManageManyValuesOnFocusChange(editor, current);
        }
        void PopulateObjectivesList(MissionObjectives mo, ScrollPanelWidget parent, ContainerWidget template)
        {
            parent.RemoveChildren();

            foreach (var objective in mo.Objectives.OrderBy(o => o.Type))
            {
                var widget = template.Clone();
                var label  = widget.Get <LabelWidget>("OBJECTIVE_TYPE");
                label.GetText = () => objective.Type;

                var checkbox = widget.Get <CheckboxWidget>("OBJECTIVE_STATUS");
                checkbox.IsChecked    = () => objective.State != ObjectiveState.Incomplete;
                checkbox.GetCheckType = () => objective.State == ObjectiveState.Completed ? "checked" : "crossed";
                checkbox.GetText      = () => objective.Description;

                parent.AddChild(widget);
            }
        }
示例#25
0
        public ListPropertyEditor(IPropertyEditorParams editorParams, Func <PropertyEditorParams, Widget, IList, IEnumerable <IPropertyEditor> > onAdd) : base(editorParams)
        {
            this.onAdd = onAdd;

            if (EditorParams.Objects.Skip(1).Any())
            {
                // Dont create editor interface if > 1 objects are selected
                EditorContainer.AddNode(new Widget()
                {
                    Layout = new HBoxLayout(),
                    Nodes  = { new ThemedSimpleText {
                                   Text = "Edit of list properties isnt supported for multiple selection.", ForceUncutText = false
                               } },
                    // TODO: move color to theme
                    Presenter = new WidgetFlatFillPresenter(Theme.Colors.WarningBackground)
                });
                return;
            }
            ExpandableContent.Padding = new Thickness(left: 4.0f, right: 0.0f, top: 4.0f, bottom: 4.0f);
            list = (IList)EditorParams.PropertyInfo.GetValue(EditorParams.Objects.First());
            var addButton = new ThemedAddButton()
            {
                Clicked = () => {
                    Expanded = true;
                    if (list == null)
                    {
                        var pi = EditorParams.PropertyInfo;
                        var o  = EditorParams.Objects.First();
                        pi.SetValue(o, list = new TList());
                    }
                    var newElement = typeof(TElement) == typeof(string) ? (TElement)(object)string.Empty : Activator.CreateInstance <TElement>();
                    using (Document.Current.History.BeginTransaction()) {
                        int newIndex = list.Count;
                        InsertIntoList.Perform(list, newIndex, newElement);
                        Document.Current.History.CommitTransaction();
                    }
                }
            };

            EditorContainer.AddNode(addButton);
            ContainerWidget.Updating += _ => removeCallback?.Invoke();
            ContainerWidget.AddChangeWatcher(() => list?.Count ?? 0, Build);
        }
示例#26
0
        public Vector2PropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ContainerWidget.AddNode(new Widget {
                Layout = new HBoxLayout {
                    CellDefaults = new LayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (editorX = editorParams.NumericEditBoxFactory()),
                    (editorY = editorParams.NumericEditBoxFactory())
                }
            });
            var currentX = CoalescedPropertyComponentValue(v => v.X);
            var currentY = CoalescedPropertyComponentValue(v => v.Y);

            editorX.Submitted += text => SetComponent(editorParams, 0, editorX, currentX.GetValue());
            editorY.Submitted += text => SetComponent(editorParams, 1, editorY, currentY.GetValue());
            editorX.AddChangeWatcher(currentX, v => editorX.Text = v.ToString());
            editorY.AddChangeWatcher(currentY, v => editorY.Text = v.ToString());
        }
示例#27
0
        void PopulateObjectivesList(MissionObjectives mo, ScrollPanelWidget parent, ContainerWidget template)
        {
            parent.RemoveChildren();

            foreach (var o in mo.Objectives.OrderBy(o => o.Type))
            {
                var objective = o; // Work around the loop closure issue in older versions of C#
                var widget = template.Clone();

                var label = widget.Get<LabelWidget>("OBJECTIVE_TYPE");
                label.GetText = () => objective.Type == ObjectiveType.Primary ? "Primary" : "Secondary";

                var checkbox = widget.Get<CheckboxWidget>("OBJECTIVE_STATUS");
                checkbox.IsChecked = () => objective.State != ObjectiveState.Incomplete;
                checkbox.GetCheckType = () => objective.State == ObjectiveState.Completed ? "checked" : "crossed";
                checkbox.GetText = () => objective.Description;

                parent.AddChild(widget);
            }
        }
        void PopulateObjectivesList(MissionObjectives mo, ScrollPanelWidget parent, ContainerWidget template)
        {
            parent.RemoveChildren();

            foreach (var o in mo.Objectives.OrderBy(o => o.Type))
            {
                var objective = o;                 // Work around the loop closure issue in older versions of C#
                var widget    = template.Clone();

                var label = widget.Get <LabelWidget>("OBJECTIVE_TYPE");
                label.GetText = () => objective.Type == ObjectiveType.Primary ? "Primary" : "Secondary";

                var checkbox = widget.Get <CheckboxWidget>("OBJECTIVE_STATUS");
                checkbox.IsChecked    = () => objective.State != ObjectiveState.Incomplete;
                checkbox.GetCheckType = () => objective.State == ObjectiveState.Completed ? "checked" : "crossed";
                checkbox.GetText      = () => objective.Description;

                parent.AddChild(widget);
            }
        }
示例#29
0
        public NumericRangePropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            ContainerWidget.AddNode(new Widget {
                Layout = new HBoxLayout {
                    CellDefaults = new LayoutCell(Alignment.Center), Spacing = 4
                },
                Nodes =
                {
                    (medEditor  = editorParams.NumericEditBoxFactory()),
                    (dispEditor = editorParams.NumericEditBoxFactory()),
                }
            });
            var currentMed  = CoalescedPropertyComponentValue(v => v.Median);
            var currentDisp = CoalescedPropertyComponentValue(v => v.Dispersion);

            medEditor.Submitted  += text => SetComponent(editorParams, 0, medEditor, currentMed.GetValue());
            dispEditor.Submitted += text => SetComponent(editorParams, 1, dispEditor, currentDisp.GetValue());
            medEditor.AddChangeWatcher(currentMed, v => medEditor.Text    = v.ToString());
            dispEditor.AddChangeWatcher(currentDisp, v => dispEditor.Text = v.ToString());
        }
示例#30
0
        private static void SetupListNum(ContainerWidget container)
        {
            foreach (var child in container.Children)
            {
                if (child is ListPanel)
                {
                    (child as ListPanel).Sections = section;
                }

                if (child is GridListPanel)
                {
                    (child as GridListPanel).ItemCount = 100;
                    (child as GridListPanel).StartItemRequest();
                }

                if (child is LiveListPanel)
                {
                    (child as LiveListPanel).ItemCount = 100;
                    (child as LiveListPanel).StartItemRequest();
                }

                if (child is ContainerWidget)
                {
                    SetupListNum(child as ContainerWidget);
                }
                else if (child is PagePanel)
                {
                    var pagePanel = (PagePanel)child;
                    for (int i = 0; i < pagePanel.PageCount; i++)
                    {
                        SetupListNum(pagePanel.GetPage(i));
                    }
                }
                else if (child is LiveFlipPanel)
                {
                    var liveFlip = (LiveFlipPanel)child;
                    SetupListNum(liveFlip.FrontPanel);
                    SetupListNum(liveFlip.BackPanel);
                }
            }
        }
示例#31
0
 public TriggerPropertyEditor(IPropertyEditorParams editorParams, bool multiline = false) : base(editorParams)
 {
     comboBox = new ThemedComboBox {
         LayoutCell = new LayoutCell(Alignment.Center)
     };
     ContainerWidget.AddNode(comboBox);
     comboBox.Changed += ComboBox_Changed;
     if (editorParams.Objects.Count == 1)
     {
         var node = (Node)editorParams.Objects[0];
         foreach (var a in node.Animations)
         {
             foreach (var m in a.Markers.Where(i => i.Action != MarkerAction.Jump && !string.IsNullOrEmpty(i.Id)))
             {
                 var id = a.Id != null ? m.Id + '@' + a.Id : m.Id;
                 comboBox.Items.Add(new DropDownList.Item(id));
             }
         }
     }
     comboBox.AddChangeWatcher(CoalescedPropertyValue(), v => comboBox.Text = v);
 }
示例#32
0
        public EnumPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            Selector            = editorParams.DropDownListFactory();
            Selector.LayoutCell = new LayoutCell(Alignment.Center);
            ContainerWidget.AddNode(Selector);
            var propType      = editorParams.PropertyInfo.PropertyType;
            var fields        = propType.GetFields(BindingFlags.Public | BindingFlags.Static);
            var allowedFields = fields.Where(f => !Attribute.IsDefined(f, typeof(TangerineIgnoreAttribute)));

            foreach (var field in allowedFields)
            {
                Selector.Items.Add(new CommonDropDownList.Item(field.Name, field.GetValue(null)));
            }
            Selector.Changed += a => {
                if (a.ChangedByUser)
                {
                    SetProperty((T)Selector.Items[a.Index].Value);
                }
            };
            Selector.AddChangeWatcher(CoalescedPropertyValue(), v => Selector.Value = v);
        }
示例#33
0
        public IntPropertyEditor(IPropertyEditorParams editorParams) : base(editorParams)
        {
            editor             = editorParams.EditBoxFactory();
            editor.MinMaxWidth = 80;
            editor.LayoutCell  = new LayoutCell(Alignment.Center);
            ContainerWidget.AddNode(editor);
            var current = CoalescedPropertyValue();

            editor.Submitted += text => {
                int newValue;
                if (int.TryParse(text, out newValue))
                {
                    SetProperty(newValue);
                }
                else
                {
                    editor.Text = current.GetValue().ToString();
                }
            };
            editor.AddChangeWatcher(current, v => editor.Text = v.ToString());
        }
示例#34
0
        public IngameChatLogic(Widget widget, OrderManager orderManager, World world, Ruleset modRules)
        {
            this.modRules = modRules;

            chatTraits = world.WorldActor.TraitsImplementing<INotifyChat>().ToList();

            var players = world.Players.Where(p => p != world.LocalPlayer && !p.NonCombatant && !p.IsBot);
            var disableTeamChat = world.LocalPlayer == null || world.LobbyInfo.IsSinglePlayer || !players.Any(p => p.IsAlliedWith(world.LocalPlayer));
            teamChat = !disableTeamChat;

            var chatPanel = (ContainerWidget)widget;
            chatOverlay = chatPanel.Get<ContainerWidget>("CHAT_OVERLAY");
            chatOverlayDisplay = chatOverlay.Get<ChatDisplayWidget>("CHAT_DISPLAY");
            chatOverlay.Visible = false;

            chatChrome = chatPanel.Get<ContainerWidget>("CHAT_CHROME");
            chatChrome.Visible = true;

            var chatMode = chatChrome.Get<ButtonWidget>("CHAT_MODE");
            chatMode.GetText = () => teamChat ? "Team" : "All";
            chatMode.OnClick = () => teamChat ^= true;
            chatMode.IsDisabled = () => disableTeamChat;

            chatText = chatChrome.Get<TextFieldWidget>("CHAT_TEXTFIELD");
            chatText.OnTabKey = () =>
            {
                if (!disableTeamChat)
                    teamChat ^= true;
                return true;
            };
            chatText.OnEnterKey = () =>
            {
                var team = teamChat && !disableTeamChat;
                if (chatText.Text != "")
                    orderManager.IssueOrder(Order.Chat(team, chatText.Text.Trim()));

                CloseChat();
                return true;
            };

            chatText.OnEscKey = () => { CloseChat(); return true; };

            var chatClose = chatChrome.Get<ButtonWidget>("CHAT_CLOSE");
            chatClose.OnClick += () => CloseChat();

            chatPanel.OnKeyPress = (e) =>
            {
                if (e.Event == KeyInputEvent.Up)
                    return false;

                if (!chatChrome.IsVisible() && (e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER))
                {
                    OpenChat();
                    return true;
                }

                return false;
            };

            chatScrollPanel = chatChrome.Get<ScrollPanelWidget>("CHAT_SCROLLPANEL");
            chatTemplate = chatScrollPanel.Get<ContainerWidget>("CHAT_TEMPLATE");
            chatScrollPanel.RemoveChildren();

            Game.AddChatLine += AddChatLine;
            Game.BeforeGameStart += UnregisterEvents;

            CloseChat();
        }
        private static void SetupListNum(ContainerWidget container)
        {
            foreach (var child in container.Children)
            {
                if (child is ListPanel)
                {
                    (child as ListPanel).Sections = section;
                }

                if (child is GridListPanel)
                {
                    (child as GridListPanel).ItemCount = 100;
                    (child as GridListPanel).StartItemRequest();
                }

                if (child is LiveListPanel)
                {
                    (child as LiveListPanel).ItemCount = 100;
                    (child as LiveListPanel).StartItemRequest();
                }

                if (child is ContainerWidget)
                {
                    SetupListNum(child as ContainerWidget);
                }
                else if (child is PagePanel)
                {
                    var pagePanel = (PagePanel)child;
                    for (int i = 0; i < pagePanel.PageCount; i++) {
                        SetupListNum (pagePanel.GetPage (i));
                    }
                }
                else if (child is LiveFlipPanel)
                {
                    var liveFlip = (LiveFlipPanel)child;
                    SetupListNum(liveFlip.FrontPanel);
                    SetupListNum(liveFlip.BackPanel);
                }

            }
        }
示例#36
0
		public ObserverStatsLogic(World world, WorldRenderer worldRenderer, Widget widget, Action onExit)
		{
			this.world = world;
			this.worldRenderer = worldRenderer;
			players = world.Players.Where(p => !p.NonCombatant);

			basicStatsHeaders = widget.Get<ContainerWidget>("BASIC_STATS_HEADERS");
			economyStatsHeaders = widget.Get<ContainerWidget>("ECONOMY_STATS_HEADERS");
			productionStatsHeaders = widget.Get<ContainerWidget>("PRODUCTION_STATS_HEADERS");
			combatStatsHeaders = widget.Get<ContainerWidget>("COMBAT_STATS_HEADERS");
			earnedThisMinuteGraphHeaders = widget.Get<ContainerWidget>("EARNED_THIS_MIN_GRAPH_HEADERS");

			playerStatsPanel = widget.Get<ScrollPanelWidget>("PLAYER_STATS_PANEL");
			playerStatsPanel.Layout = new GridLayout(playerStatsPanel);

			basicPlayerTemplate = playerStatsPanel.Get<ScrollItemWidget>("BASIC_PLAYER_TEMPLATE");
			economyPlayerTemplate = playerStatsPanel.Get<ScrollItemWidget>("ECONOMY_PLAYER_TEMPLATE");
			productionPlayerTemplate = playerStatsPanel.Get<ScrollItemWidget>("PRODUCTION_PLAYER_TEMPLATE");
			combatPlayerTemplate = playerStatsPanel.Get<ScrollItemWidget>("COMBAT_PLAYER_TEMPLATE");
			earnedThisMinuteGraphTemplate = playerStatsPanel.Get<ContainerWidget>("EARNED_THIS_MIN_GRAPH_TEMPLATE");

			teamTemplate = playerStatsPanel.Get<ScrollItemWidget>("TEAM_TEMPLATE");

			statsDropDown = widget.Get<DropDownButtonWidget>("STATS_DROPDOWN");
			statsDropDown.GetText = () => "Basic";
			statsDropDown.OnMouseDown = _ =>
			{
				var options = new List<StatsDropDownOption>
				{
					new StatsDropDownOption
					{
						Title = "Basic",
						IsSelected = () => basicStatsHeaders.Visible,
						OnClick = () =>
						{
							ClearStats();
							statsDropDown.GetText = () => "Basic";
							DisplayStats(BasicStats);
						}
					},
					new StatsDropDownOption
					{
						Title = "Economy",
						IsSelected = () => economyStatsHeaders.Visible,
						OnClick = () =>
						{
							ClearStats();
							statsDropDown.GetText = () => "Economy";
							DisplayStats(EconomyStats);
						}
					},
					new StatsDropDownOption
					{
						Title = "Production",
						IsSelected = () => productionStatsHeaders.Visible,
						OnClick = () =>
						{
							ClearStats();
							statsDropDown.GetText = () => "Production";
							DisplayStats(ProductionStats);
						}
					},
					new StatsDropDownOption
					{
						Title = "Combat",
						IsSelected = () => combatStatsHeaders.Visible,
						OnClick = () =>
						{
							ClearStats();
							statsDropDown.GetText = () => "Combat";
							DisplayStats(CombatStats);
						}
					},
					new StatsDropDownOption
					{
						Title = "Earnings (graph)",
						IsSelected = () => earnedThisMinuteGraphHeaders.Visible,
						OnClick = () =>
						{
							ClearStats();
							statsDropDown.GetText = () => "Earnings (graph)";
							EarnedThisMinuteGraph();
						}
					}
				};
				Func<StatsDropDownOption, ScrollItemWidget, ScrollItemWidget> setupItem = (option, template) =>
				{
					var item = ScrollItemWidget.Setup(template, option.IsSelected, option.OnClick);
					item.Get<LabelWidget>("LABEL").GetText = () => option.Title;
					return item;
				};
				statsDropDown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 150, options, setupItem);
			};

			ClearStats();
			DisplayStats(BasicStats);

			var close = widget.GetOrNull<ButtonWidget>("CLOSE");
			if (close != null)
				close.OnClick = () =>
				{
					Ui.CloseWindow();
					Ui.Root.RemoveChild(widget);
					onExit();
				};
		}
示例#37
0
        public IngameChatLogic(Widget widget, OrderManager orderManager, World world, ModData modData)
        {
            this.orderManager = orderManager;
            this.modRules = modData.DefaultRules;

            chatTraits = world.WorldActor.TraitsImplementing<INotifyChat>().ToArray();

            var players = world.Players.Where(p => p != world.LocalPlayer && !p.NonCombatant && !p.IsBot);
            disableTeamChat = world.IsReplay || world.LobbyInfo.IsSinglePlayer || (world.LocalPlayer != null && !players.Any(p => p.IsAlliedWith(world.LocalPlayer)));
            teamChat = !disableTeamChat;

            tabCompletion.Commands = chatTraits.OfType<ChatCommands>().SelectMany(x => x.Commands.Keys).ToList();
            tabCompletion.Names = orderManager.LobbyInfo.Clients.Select(c => c.Name).Distinct().ToList();

            var chatPanel = (ContainerWidget)widget;
            chatOverlay = chatPanel.Get<ContainerWidget>("CHAT_OVERLAY");
            chatOverlayDisplay = chatOverlay.Get<ChatDisplayWidget>("CHAT_DISPLAY");
            chatOverlay.Visible = false;

            chatChrome = chatPanel.Get<ContainerWidget>("CHAT_CHROME");
            chatChrome.Visible = true;

            var chatMode = chatChrome.Get<ButtonWidget>("CHAT_MODE");
            chatMode.GetText = () => teamChat ? "Team" : "All";
            chatMode.OnClick = () => teamChat ^= true;
            chatMode.IsDisabled = () => disableTeamChat;

            chatText = chatChrome.Get<TextFieldWidget>("CHAT_TEXTFIELD");
            chatText.OnEnterKey = () =>
            {
                var team = teamChat && !disableTeamChat;
                if (chatText.Text != "")
                {
                    if (!chatText.Text.StartsWith("/"))
                        orderManager.IssueOrder(Order.Chat(team, chatText.Text.Trim()));
                    else if (chatTraits != null)
                    {
                        var text = chatText.Text.Trim();
                        foreach (var trait in chatTraits)
                            trait.OnChat(orderManager.LocalClient.Name, text);
                    }
                }

                chatText.Text = "";
                CloseChat();
                return true;
            };

            chatText.OnTabKey = () =>
            {
                var previousText = chatText.Text;
                chatText.Text = tabCompletion.Complete(chatText.Text);
                chatText.CursorPosition = chatText.Text.Length;

                if (chatText.Text == previousText)
                    return SwitchTeamChat();
                else
                    return true;
            };

            chatText.OnEscKey = () => { CloseChat(); return true; };

            var chatClose = chatChrome.Get<ButtonWidget>("CHAT_CLOSE");
            chatClose.OnClick += CloseChat;

            chatPanel.OnKeyPress = e =>
            {
                if (e.Event == KeyInputEvent.Up)
                    return false;

                if (!chatChrome.IsVisible() && (e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER))
                {
                    OpenChat();
                    return true;
                }

                return false;
            };

            chatScrollPanel = chatChrome.Get<ScrollPanelWidget>("CHAT_SCROLLPANEL");
            chatTemplate = chatScrollPanel.Get<ContainerWidget>("CHAT_TEMPLATE");
            chatScrollPanel.RemoveChildren();
            chatScrollPanel.ScrollToBottom();

            foreach (var chatLine in orderManager.ChatCache)
                AddChatLine(chatLine.Color, chatLine.Name, chatLine.Text, true);

            orderManager.AddChatLine += AddChatLineWrapper;
            Game.BeforeGameStart += UnregisterEvents;

            CloseChat();
            chatText.IsDisabled = () => world.IsReplay;

            var keyListener = chatChrome.Get<LogicKeyListenerWidget>("KEY_LISTENER");
            keyListener.OnKeyPress = e =>
            {
                if (e.Event == KeyInputEvent.Up || !chatText.IsDisabled())
                    return false;

                if ((e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER || e.Key == Keycode.ESCAPE) && e.Modifiers == Modifiers.None)
                {
                    CloseChat();
                    return true;
                }

                return false;
            };
        }