diff --git a/Intersect.Client.Framework/Database/GameDatabase.cs b/Intersect.Client.Framework/Database/GameDatabase.cs index 6ea618d836..012cf8cbfd 100644 --- a/Intersect.Client.Framework/Database/GameDatabase.cs +++ b/Intersect.Client.Framework/Database/GameDatabase.cs @@ -12,6 +12,8 @@ public abstract partial class GameDatabase public bool HideOthersOnWindowOpen { get; set; } + public bool AutoToggleChatLog { get; set; } + public bool TargetAccountDirection { get; set; } public int MusicVolume { get; set; } @@ -106,6 +108,7 @@ public virtual void LoadPreferences() FullScreen = LoadPreference(nameof(FullScreen), false); EnableLighting = LoadPreference(nameof(EnableLighting), true); HideOthersOnWindowOpen = LoadPreference(nameof(HideOthersOnWindowOpen), true); + AutoToggleChatLog = LoadPreference(nameof(AutoToggleChatLog), false); TargetAccountDirection = LoadPreference(nameof(TargetAccountDirection), false); StickyTarget = LoadPreference(nameof(StickyTarget), false); AutoTurnToTarget = LoadPreference(nameof(AutoTurnToTarget), false); @@ -139,6 +142,7 @@ public virtual void SavePreferences() SavePreference(nameof(FullScreen), FullScreen); SavePreference(nameof(EnableLighting), EnableLighting); SavePreference(nameof(HideOthersOnWindowOpen), HideOthersOnWindowOpen); + SavePreference(nameof(AutoToggleChatLog), AutoToggleChatLog); SavePreference(nameof(TargetAccountDirection), TargetAccountDirection); SavePreference(nameof(StickyTarget), StickyTarget); SavePreference(nameof(AutoTurnToTarget), AutoTurnToTarget); diff --git a/Intersect.Client/Interface/Game/Chat/Chatbox.cs b/Intersect.Client/Interface/Game/Chat/Chatbox.cs index b2cfc60043..87478eff27 100644 --- a/Intersect.Client/Interface/Game/Chat/Chatbox.cs +++ b/Intersect.Client/Interface/Game/Chat/Chatbox.cs @@ -37,6 +37,12 @@ public partial class Chatbox private Button mChatboxSendButton; + private Button _chatboxToggleLogButton; + + private Button _chatboxClearLogButton; + + private readonly GameTexture _chatboxTexture; + private Label mChatboxText; private Label mChatboxTitle; @@ -117,9 +123,9 @@ public Chatbox(Canvas gameCanvas, GameInterface gameUi) mChatbar.IsHidden = true; mChatboxInput = new TextBox(mChatboxWindow, "ChatboxInputField"); - mChatboxInput.SubmitPressed += ChatBoxInput_SubmitPressed; + mChatboxInput.SubmitPressed += ChatboxInput_SubmitPressed; mChatboxInput.Text = GetDefaultInputText(); - mChatboxInput.Clicked += ChatBoxInput_Clicked; + mChatboxInput.Clicked += ChatboxInput_Clicked; mChatboxInput.IsTabable = false; mChatboxInput.SetMaxLength(Options.MaxChatLength); Interface.FocusElements.Add(mChatboxInput); @@ -150,10 +156,19 @@ public Chatbox(Canvas gameCanvas, GameInterface gameUi) mChatboxSendButton = new Button(mChatboxWindow, "ChatboxSendButton"); mChatboxSendButton.Text = Strings.Chatbox.send; - mChatboxSendButton.Clicked += ChatBoxSendBtn_Clicked; + mChatboxSendButton.Clicked += ChatboxSendBtn_Clicked; + + _chatboxToggleLogButton = new Button(mChatboxWindow, "ChatboxToggleLogButton"); + _chatboxToggleLogButton.SetToolTipText(Strings.Chatbox.ToggleLogButtonToolTip); + _chatboxToggleLogButton.Clicked += ChatboxToggleLogBtn_Clicked; + + _chatboxClearLogButton = new Button(mChatboxWindow, "ChatboxClearLogButton"); + _chatboxClearLogButton.SetToolTipText(Strings.Chatbox.ClearLogButtonToolTip); + _chatboxClearLogButton.Clicked += ChatboxClearLogBtn_Clicked; mChatboxWindow.LoadJsonUi(GameContentManager.UI.InGame, Graphics.Renderer.GetResolutionString()); + _chatboxTexture = mChatboxWindow.Texture; // store chatbox texture here so we can re-use it later. mChatboxText.IsHidden = true; // Disable this to start, since this is the default tab we open the client on. @@ -346,7 +361,6 @@ public void Update() mChatboxMessages.GetHorizontalScrollBar().SetScrollAmount(0); mMessageIndex = 0; mReceivedMessage = true; - mLastTab = mCurrentTab; } @@ -443,6 +457,10 @@ public void Focus() { mChatboxInput.Text = string.Empty; mChatboxInput.Focus(); + if (Globals.Database.AutoToggleChatLog) + { + ShowChatLog(); + } } } @@ -455,12 +473,16 @@ public void UnFocus() { mChatboxInput.Text = GetDefaultInputText(); mChatboxMessages.Focus(); + if (Globals.Database.AutoToggleChatLog) + { + HideChatLog(); + } } } //Input Handlers //Chatbox Window - void ChatBoxInput_Clicked(Base sender, ClickedEventArgs arguments) + void ChatboxInput_Clicked(Base sender, ClickedEventArgs arguments) { if (mChatboxInput.Text == GetDefaultInputText()) { @@ -468,16 +490,62 @@ void ChatBoxInput_Clicked(Base sender, ClickedEventArgs arguments) } } - void ChatBoxInput_SubmitPressed(Base sender, EventArgs arguments) + void ChatboxInput_SubmitPressed(Base sender, EventArgs arguments) { TrySendMessage(); } - void ChatBoxSendBtn_Clicked(Base sender, ClickedEventArgs arguments) + void ChatboxSendBtn_Clicked(Base sender, ClickedEventArgs arguments) { TrySendMessage(); } + void ChatboxClearLogBtn_Clicked(Base sender, ClickedEventArgs arguments) + { + ChatboxMsg.ClearMessages(); + mChatboxMessages.Clear(); + mChatboxMessages.GetHorizontalScrollBar().SetScrollAmount(0); + mMessageIndex = 0; + mReceivedMessage = true; + mLastTab = mCurrentTab; + } + + void ChatboxToggleLogBtn_Clicked(Base sender, ClickedEventArgs arguments) + { + if (mChatboxWindow.Texture != null) + { + HideChatLog(); + } + else + { + ShowChatLog(); + } + } + + private void ShowChatLog() + { + mTabButtons[ChatboxTab.All].Show(); + mTabButtons[ChatboxTab.Local].Show(); + mTabButtons[ChatboxTab.Party].Show(); + mTabButtons[ChatboxTab.Guild].Show(); + mTabButtons[ChatboxTab.Global].Show(); + mTabButtons[ChatboxTab.System].Show(); + mChatboxMessages.Show(); + mChatboxWindow.Texture = _chatboxTexture; + } + + private void HideChatLog() + { + mTabButtons[ChatboxTab.All].Hide(); + mTabButtons[ChatboxTab.Local].Hide(); + mTabButtons[ChatboxTab.Party].Hide(); + mTabButtons[ChatboxTab.Guild].Hide(); + mTabButtons[ChatboxTab.Global].Hide(); + mTabButtons[ChatboxTab.System].Hide(); + mChatboxMessages.Hide(); + mChatboxWindow.Texture = null; + } + void TrySendMessage() { var msg = mChatboxInput.Text.Trim(); @@ -515,15 +583,17 @@ string GetDefaultInputText() Strings.Keys.keydict[Enum.GetName(typeof(Keys), key2.Key).ToLower()] ); } - else if (key1.Key != Keys.None && key2.Key == Keys.None) + + if (key1.Key != Keys.None && key2.Key == Keys.None) { return Strings.Chatbox.enterchat1.ToString( Strings.Keys.keydict[Enum.GetName(typeof(Keys), key1.Key).ToLower()] ); } - else if (key1.Key != Keys.None && key2.Key != Keys.None) + + if (key1.Key != Keys.None && key2.Key != Keys.None) { - return Strings.Chatbox.enterchat1.ToString( + return Strings.Chatbox.enterchat2.ToString( Strings.Keys.keydict[Enum.GetName(typeof(Keys), key1.Key).ToLower()], Strings.Keys.keydict[Enum.GetName(typeof(Keys), key2.Key).ToLower()] ); diff --git a/Intersect.Client/Interface/Shared/SettingsWindow.cs b/Intersect.Client/Interface/Shared/SettingsWindow.cs index a5fffb1220..d4bdbd909f 100644 --- a/Intersect.Client/Interface/Shared/SettingsWindow.cs +++ b/Intersect.Client/Interface/Shared/SettingsWindow.cs @@ -56,6 +56,8 @@ public partial class SettingsWindow private readonly LabeledCheckBox mAutoCloseWindowsCheckbox; + private readonly LabeledCheckBox mAutoToggleChatLogCheckbox; + private readonly LabeledCheckBox mShowExperienceAsPercentageCheckbox; private readonly LabeledCheckBox mShowHealthAsPercentageCheckbox; @@ -195,6 +197,10 @@ public SettingsWindow(Base parent, MainMenu mainMenu, EscapeMenu escapeMenu) mAutoCloseWindowsCheckbox = new LabeledCheckBox(mInterfaceSettings, "AutoCloseWindowsCheckbox"); mAutoCloseWindowsCheckbox.Text = Strings.Settings.AutoCloseWindows; + // Game Settings - Interface: Auto-toggle chat log visibility. + mAutoToggleChatLogCheckbox = new LabeledCheckBox(mInterfaceSettings, "AutoToggleChatLogCheckbox"); + mAutoToggleChatLogCheckbox.Text = Strings.Settings.AutoToggleChatLog; + // Game Settings - Interface: Show EXP/HP/MP as Percentage. mShowExperienceAsPercentageCheckbox = new LabeledCheckBox(mInterfaceSettings, "ShowExperienceAsPercentageCheckbox"); @@ -671,6 +677,7 @@ public void Show(bool returnToMenu = false) // Game Settings. mAutoCloseWindowsCheckbox.IsChecked = Globals.Database.HideOthersOnWindowOpen; + mAutoToggleChatLogCheckbox.IsChecked = Globals.Database.AutoToggleChatLog; mShowHealthAsPercentageCheckbox.IsChecked = Globals.Database.ShowHealthAsPercentage; mShowManaAsPercentageCheckbox.IsChecked = Globals.Database.ShowManaAsPercentage; mShowExperienceAsPercentageCheckbox.IsChecked = Globals.Database.ShowExperienceAsPercentage; @@ -851,6 +858,7 @@ private void SettingsApplyBtn_Clicked(Base sender, ClickedEventArgs arguments) // Game Settings. Globals.Database.HideOthersOnWindowOpen = mAutoCloseWindowsCheckbox.IsChecked; + Globals.Database.AutoToggleChatLog = mAutoToggleChatLogCheckbox.IsChecked; Globals.Database.ShowExperienceAsPercentage = mShowExperienceAsPercentageCheckbox.IsChecked; Globals.Database.ShowHealthAsPercentage = mShowHealthAsPercentageCheckbox.IsChecked; Globals.Database.ShowManaAsPercentage = mShowManaAsPercentageCheckbox.IsChecked; diff --git a/Intersect.Client/Localization/Strings.cs b/Intersect.Client/Localization/Strings.cs index 41497b3d86..c1b68a9c4d 100644 --- a/Intersect.Client/Localization/Strings.cs +++ b/Intersect.Client/Localization/Strings.cs @@ -605,6 +605,10 @@ public partial struct Chatbox public static LocalizedString toofast = @"You are chatting too fast!"; + public static LocalizedString ToggleLogButtonToolTip = @"Toggle chat log visibility"; + + public static LocalizedString ClearLogButtonToolTip = @"Clear chat log messages"; + public static Dictionary ChatTabButtons = new Dictionary() { { ChatboxTab.All, @"All" }, { ChatboxTab.Local, @"Local" }, @@ -1706,6 +1710,9 @@ public partial struct Settings [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public static LocalizedString AutoCloseWindows = @"Auto-close Windows"; + + [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] + public static LocalizedString AutoToggleChatLog = @"Auto-toggle chat log visibility"; [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] public static LocalizedString Cancel = @"Cancel";