1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 04:23:21 +08:00

Save / sync chat text box messages per channel

This commit is contained in:
Joseph Madamba 2022-12-28 15:12:57 -08:00
parent ffd9359f4a
commit c326745f96
4 changed files with 21 additions and 4 deletions

View File

@ -98,6 +98,11 @@ namespace osu.Game.Online.Chat
/// </summary> /// </summary>
public Bindable<Message> HighlightedMessage = new Bindable<Message>(); public Bindable<Message> HighlightedMessage = new Bindable<Message>();
/// <summary>
/// The current text box message while in this <see cref="Channel"/>.
/// </summary>
public Bindable<string> TextBoxMessage = new Bindable<string>(string.Empty);
[JsonConstructor] [JsonConstructor]
public Channel() public Channel()
{ {

View File

@ -87,6 +87,14 @@ namespace osu.Game.Online.Chat
channelManager ??= manager; channelManager ??= manager;
} }
protected override void LoadComplete()
{
base.LoadComplete();
if (channelManager != null)
TextBox?.Current.BindTo(channelManager.CurrentChannel.Value.TextBoxMessage);
}
protected virtual StandAloneDrawableChannel CreateDrawableChannel(Channel channel) => protected virtual StandAloneDrawableChannel CreateDrawableChannel(Channel channel) =>
new StandAloneDrawableChannel(channel); new StandAloneDrawableChannel(channel);

View File

@ -128,9 +128,8 @@ namespace osu.Game.Overlays.Chat
chattingTextContainer.FadeTo(showSearch ? 0 : 1); chattingTextContainer.FadeTo(showSearch ? 0 : 1);
searchIconContainer.FadeTo(showSearch ? 1 : 0); searchIconContainer.FadeTo(showSearch ? 1 : 0);
// Clear search terms if any exist when switching back to chat mode if (showSearch)
if (!showSearch) OnSearchTermsChanged?.Invoke(chatTextBox.Current.Value);
OnSearchTermsChanged?.Invoke(string.Empty);
}, true); }, true);
currentChannel.BindValueChanged(change => currentChannel.BindValueChanged(change =>
@ -151,6 +150,12 @@ namespace osu.Game.Overlays.Chat
chattingText.Text = ChatStrings.TalkingIn(newChannel.Name); chattingText.Text = ChatStrings.TalkingIn(newChannel.Name);
break; break;
} }
if (change.OldValue != null)
chatTextBox.Current.UnbindFrom(change.OldValue.TextBoxMessage);
if (newChannel != null)
chatTextBox.Current.BindTo(newChannel.TextBoxMessage);
}, true); }, true);
} }

View File

@ -24,7 +24,6 @@ namespace osu.Game.Overlays.Chat
bool showSearch = change.NewValue; bool showSearch = change.NewValue;
PlaceholderText = showSearch ? HomeStrings.SearchPlaceholder : ChatStrings.InputPlaceholder; PlaceholderText = showSearch ? HomeStrings.SearchPlaceholder : ChatStrings.InputPlaceholder;
Text = string.Empty;
}, true); }, true);
} }