From a81f099d403258f494e7e30fe91ecab948916022 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 10 Nov 2016 18:15:30 -0500 Subject: [PATCH 1/3] Add TextBoxOption and wire it up --- .../Options/Online/InGameChatOptions.cs | 9 ++-- osu.Game/Overlays/Options/TextBoxOption.cs | 49 +++++++++++++++++++ osu.Game/osu.Game.csproj | 1 + 3 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Overlays/Options/TextBoxOption.cs diff --git a/osu.Game/Overlays/Options/Online/InGameChatOptions.cs b/osu.Game/Overlays/Options/Online/InGameChatOptions.cs index 29316b60fc..ac459f2910 100644 --- a/osu.Game/Overlays/Options/Online/InGameChatOptions.cs +++ b/osu.Game/Overlays/Options/Online/InGameChatOptions.cs @@ -10,7 +10,8 @@ namespace osu.Game.Overlays.Options.Online { protected override string Header => "In-game Chat"; - private CheckBoxOption filterWords, filterForeign, logPMs, blockPMs; + private CheckBoxOption filterWords, filterForeign, logPMs, blockPMs; + private TextBoxOption chatIgnoreList, chatHighlightWords; public InGameChatOptions() { @@ -21,9 +22,9 @@ namespace osu.Game.Overlays.Options.Online logPMs = new CheckBoxOption { LabelText = "Log private messages" }, blockPMs = new CheckBoxOption { LabelText = "Block private messages from non-friends" }, new SpriteText { Text = "Chat ignore list (space-seperated list)" }, - new TextBox { Height = 20, RelativeSizeAxes = Axes.X }, + chatIgnoreList = new TextBoxOption { Height = 20, RelativeSizeAxes = Axes.X }, new SpriteText { Text = "Chat highlight words (space-seperated list)" }, - new TextBox { Height = 20, RelativeSizeAxes = Axes.X }, + chatHighlightWords = new TextBoxOption { Height = 20, RelativeSizeAxes = Axes.X }, }; } @@ -37,6 +38,8 @@ namespace osu.Game.Overlays.Options.Online filterForeign.Bindable = osuGame.Config.GetBindable(OsuConfig.ChatRemoveForeign); logPMs.Bindable = osuGame.Config.GetBindable(OsuConfig.LogPrivateMessages); blockPMs.Bindable = osuGame.Config.GetBindable(OsuConfig.BlockNonFriendPM); + chatIgnoreList.Bindable = osuGame.Config.GetBindable(OsuConfig.IgnoreList); + chatHighlightWords.Bindable = osuGame.Config.GetBindable(OsuConfig.HighlightWords); } } } diff --git a/osu.Game/Overlays/Options/TextBoxOption.cs b/osu.Game/Overlays/Options/TextBoxOption.cs new file mode 100644 index 0000000000..91ec251bac --- /dev/null +++ b/osu.Game/Overlays/Options/TextBoxOption.cs @@ -0,0 +1,49 @@ +using System; +using osu.Framework.Configuration; +using osu.Framework.Graphics.UserInterface; + +namespace osu.Game.Overlays.Options +{ + public class TextBoxOption : TextBox + { + private Bindable bindable; + + public Bindable Bindable + { + set + { + if (bindable != null) + bindable.ValueChanged -= bindableValueChanged; + bindable = value; + if (bindable != null) + { + base.Text = bindable.Value; + bindable.ValueChanged += bindableValueChanged; + } + } + } + + protected override string internalText + { + get { return base.internalText; } + set + { + base.internalText = value; + if (bindable != null) + bindable.Value = value; + } + } + + private void bindableValueChanged(object sender, EventArgs e) + { + Text = bindable.Value; + } + + protected override void Dispose(bool isDisposing) + { + if (bindable != null) + bindable.ValueChanged -= bindableValueChanged; + base.Dispose(isDisposing); + } + } +} \ No newline at end of file diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 3b5ea8de73..4a1b903d08 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -232,6 +232,7 @@ + From e2365cfad283b192a77b6cbaa51420945b1ed7ee Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 10 Nov 2016 18:25:20 -0500 Subject: [PATCH 2/3] s/internalText/InternalText/g --- osu.Game/Overlays/Options/TextBoxOption.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game/Overlays/Options/TextBoxOption.cs b/osu.Game/Overlays/Options/TextBoxOption.cs index 91ec251bac..ffd9c86b71 100644 --- a/osu.Game/Overlays/Options/TextBoxOption.cs +++ b/osu.Game/Overlays/Options/TextBoxOption.cs @@ -23,12 +23,12 @@ namespace osu.Game.Overlays.Options } } - protected override string internalText + protected override string InternalText { - get { return base.internalText; } + get { return base.InternalText; } set { - base.internalText = value; + base.InternalText = value; if (bindable != null) bindable.Value = value; } From e535681bb5c5121e31c7c974869784074bda816e Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Fri, 11 Nov 2016 00:21:59 -0500 Subject: [PATCH 3/3] Update framework --- osu-framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu-framework b/osu-framework index 25b8c3c6cf..ef57b64639 160000 --- a/osu-framework +++ b/osu-framework @@ -1 +1 @@ -Subproject commit 25b8c3c6cfead49acf5659a750c7e604289d5b81 +Subproject commit ef57b64639f53326104707d40536de24226dd63f