feat(desktop): add jank channel chooser
This commit is contained in:
parent
3b896fe889
commit
789fd20209
|
@ -65,6 +65,13 @@ namespace XIVChat_Desktop {
|
|||
this.outgoingMessages.Writer.TryWrite(msg.Encode());
|
||||
}
|
||||
|
||||
public void ChangeChannel(InputChannel channel) {
|
||||
var msg = new ClientChannel {
|
||||
Channel = channel,
|
||||
};
|
||||
this.outgoingMessages.Writer.TryWrite(msg.Encode());
|
||||
}
|
||||
|
||||
public void Disconnect() {
|
||||
this.cancel.Cancel();
|
||||
for (var i = 0; i < 2; i++) {
|
||||
|
@ -257,11 +264,12 @@ namespace XIVChat_Desktop {
|
|||
Close:
|
||||
try {
|
||||
this.client.Close();
|
||||
} catch (ObjectDisposedException) { }
|
||||
} catch (ObjectDisposedException) {
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleIncoming(byte[] rawMessage) {
|
||||
var type = (ServerOperation)rawMessage[0];
|
||||
var type = (ServerOperation) rawMessage[0];
|
||||
var payload = new byte[rawMessage.Length - 1];
|
||||
Array.Copy(rawMessage, 1, payload, 0, payload.Length);
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
xmlns:cc="clr-namespace:XIVChat_Desktop.Controls"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
xmlns:server="clr-namespace:XIVChatCommon.Message.Server;assembly=XIVChatCommon"
|
||||
xmlns:message="clr-namespace:XIVChatCommon.Message;assembly=XIVChatCommon"
|
||||
ui:WindowHelper.UseModernWindowStyle="True"
|
||||
ui:TitleBar.ExtendViewIntoTitleBar="{Binding App.Config.CompactMode}"
|
||||
mc:Ignorable="d"
|
||||
|
@ -180,7 +181,95 @@
|
|||
|
||||
<TextBlock Margin="8,4,0,0"
|
||||
Grid.Row="1"
|
||||
Text="{Binding App.Connection.CurrentChannel, ElementName=Main, UpdateSourceTrigger=PropertyChanged}" />
|
||||
MouseDown="Channel_MouseDown"
|
||||
Text="{Binding App.Connection.CurrentChannel, ElementName=Main, UpdateSourceTrigger=PropertyChanged}">
|
||||
<TextBlock.CommandBindings>
|
||||
<CommandBinding Command="local:MainWindow.ChangeChannel"
|
||||
CanExecute="ChangeChannel_CanExecute"
|
||||
Executed="ChangeChannel_Execute" />
|
||||
</TextBlock.CommandBindings>
|
||||
|
||||
<TextBlock.ContextMenu>
|
||||
<ContextMenu
|
||||
DataContext="{Binding PlacementTarget.DataContext, RelativeSource={RelativeSource Self}}">
|
||||
<MenuItem Header="Tell"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Tell}" />
|
||||
<MenuItem Header="Say"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Say}" />
|
||||
<MenuItem Header="Party"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Party}" />
|
||||
<MenuItem Header="Alliance"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Alliance}" />
|
||||
<MenuItem Header="Yell"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Yell}" />
|
||||
<MenuItem Header="Shout"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Shout}" />
|
||||
<MenuItem Header="Free Company"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.FreeCompany}" />
|
||||
<MenuItem Header="PvP Team"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.PvpTeam}" />
|
||||
<MenuItem Header="Novice Network"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.NoviceNetwork}" />
|
||||
<MenuItem Header="Cross-world Linkshell [1]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.CrossLinkshell1}" />
|
||||
<MenuItem Header="Cross-world Linkshell [2]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.CrossLinkshell2}" />
|
||||
<MenuItem Header="Cross-world Linkshell [3]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.CrossLinkshell3}" />
|
||||
<MenuItem Header="Cross-world Linkshell [4]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.CrossLinkshell4}" />
|
||||
<MenuItem Header="Cross-world Linkshell [5]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.CrossLinkshell5}" />
|
||||
<MenuItem Header="Cross-world Linkshell [6]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.CrossLinkshell6}" />
|
||||
<MenuItem Header="Cross-world Linkshell [7]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.CrossLinkshell7}" />
|
||||
<MenuItem Header="Cross-world Linkshell [8]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.CrossLinkshell8}" />
|
||||
<MenuItem Header="Linkshell [1]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Linkshell1}" />
|
||||
<MenuItem Header="Linkshell [2]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Linkshell2}" />
|
||||
<MenuItem Header="Linkshell [3]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Linkshell3}" />
|
||||
<MenuItem Header="Linkshell [4]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Linkshell4}" />
|
||||
<MenuItem Header="Linkshell [5]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Linkshell5}" />
|
||||
<MenuItem Header="Linkshell [6]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Linkshell6}" />
|
||||
<MenuItem Header="Linkshell [7]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Linkshell7}" />
|
||||
<MenuItem Header="Linkshell [8]"
|
||||
Command="local:MainWindow.ChangeChannel"
|
||||
CommandParameter="{x:Static message:InputChannel.Linkshell8}" />
|
||||
</ContextMenu>
|
||||
</TextBlock.ContextMenu>
|
||||
</TextBlock>
|
||||
|
||||
<TextBox x:Name="InputBox"
|
||||
ui:ControlHelper.PlaceholderText="{Binding InputPlaceholder, ElementName=Main, UpdateSourceTrigger=PropertyChanged}"
|
||||
|
|
|
@ -103,9 +103,28 @@ namespace XIVChat_Desktop {
|
|||
this.InsertTellCommand(sender.Name, worldName);
|
||||
}
|
||||
|
||||
public static readonly RoutedUICommand ChangeChannel = new RoutedUICommand(
|
||||
"ChangeChannel",
|
||||
"ChangeChannel",
|
||||
typeof(MainWindow)
|
||||
);
|
||||
|
||||
private void ChangeChannel_CanExecute(object sender, CanExecuteRoutedEventArgs e) {
|
||||
e.CanExecute = this.App.Connected;
|
||||
}
|
||||
|
||||
private void ChangeChannel_Execute(object sender, ExecutedRoutedEventArgs e) {
|
||||
if (!(e.Parameter is InputChannel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var param = (InputChannel) e.Parameter;
|
||||
this.App.Connection?.ChangeChannel(param);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public App App => (App)Application.Current;
|
||||
public App App => (App) Application.Current;
|
||||
|
||||
public List<ServerMessage> Messages { get; } = new List<ServerMessage>();
|
||||
public ObservableCollection<Player> FriendList { get; } = new ObservableCollection<Player>();
|
||||
|
@ -202,7 +221,7 @@ namespace XIVChat_Desktop {
|
|||
|
||||
var diff = this.Messages.Count - this.App.Config.LocalBacklogMessages;
|
||||
if (diff > 0) {
|
||||
this.Messages.RemoveRange(0, (int)diff);
|
||||
this.Messages.RemoveRange(0, (int) diff);
|
||||
}
|
||||
|
||||
// scroll to the bottom if previously at the bottom
|
||||
|
@ -230,7 +249,7 @@ namespace XIVChat_Desktop {
|
|||
|
||||
var diff = this.Messages.Count - this.App.Config.LocalBacklogMessages;
|
||||
if (diff > 0) {
|
||||
this.Messages.RemoveRange(0, (int)diff);
|
||||
this.Messages.RemoveRange(0, (int) diff);
|
||||
}
|
||||
|
||||
// scroll to the bottom if previously at the bottom
|
||||
|
@ -372,5 +391,17 @@ namespace XIVChat_Desktop {
|
|||
private void FriendList_Click(object sender, RoutedEventArgs e) {
|
||||
new FriendList(this).Show();
|
||||
}
|
||||
|
||||
private void Channel_MouseDown(object sender, MouseButtonEventArgs e) {
|
||||
e.Handled = true;
|
||||
|
||||
if (e.ChangedButton != MouseButton.Left) {
|
||||
return;
|
||||
}
|
||||
|
||||
var channel = (TextBlock) sender;
|
||||
channel.ContextMenu!.PlacementTarget = channel;
|
||||
channel.ContextMenu!.IsOpen = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user