1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-05 13:13:22 +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>
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]
public Channel()
{

View File

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

View File

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

View File

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