Add TextBoxOption and wire it up

This commit is contained in:
Drew DeVault 2016-11-10 18:15:30 -05:00
parent d6dafd6b70
commit a81f099d40
3 changed files with 56 additions and 3 deletions

View File

@ -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<bool>(OsuConfig.ChatRemoveForeign);
logPMs.Bindable = osuGame.Config.GetBindable<bool>(OsuConfig.LogPrivateMessages);
blockPMs.Bindable = osuGame.Config.GetBindable<bool>(OsuConfig.BlockNonFriendPM);
chatIgnoreList.Bindable = osuGame.Config.GetBindable<string>(OsuConfig.IgnoreList);
chatHighlightWords.Bindable = osuGame.Config.GetBindable<string>(OsuConfig.HighlightWords);
}
}
}

View File

@ -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<string> bindable;
public Bindable<string> 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);
}
}
}

View File

@ -232,6 +232,7 @@
<Compile Include="Overlays\Options\Online\PrivacyOptions.cs" />
<Compile Include="Overlays\Options\Online\NotificationsOptions.cs" />
<Compile Include="Overlays\Options\CheckBoxOption.cs" />
<Compile Include="Overlays\Options\TextBoxOption.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">