1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:47:26 +08:00

Merge pull request #157 from SirCmpwn/string-options

Add TextBoxOption and wire it up
This commit is contained in:
Dean Herbert 2016-11-12 16:11:09 +09:00 committed by GitHub
commit 8d56a881d0
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

@ -234,6 +234,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">