예제 #1
0
        private void ChannelSelect(VMTSOChatChannel chan)
        {
            if (EditMode)
            {
                var dialog = new UIChatCategoryDialog(chan.Clone(), false);
                UIScreen.GlobalShowDialog(dialog, true);

                dialog.OKButton.OnButtonClick += (btn) =>
                {
                    Dialog.Owner.vm.SendCommand(new VMNetChatEditChanCmd()
                    {
                        Channel = dialog.Channel
                    });
                };

                dialog.OnDelete += () =>
                {
                    Dialog.Owner.vm.SendCommand(new VMNetChatEditChanCmd()
                    {
                        Channel = dialog.Channel
                    });
                };
            }
            else
            {
                var active = Dialog.Owner.ChatPanel.ActiveChannel;
                if (chan.ID == active)
                {
                    //they're toggling this chat to invisible
                    Dialog.ShowChannels &= (byte)(~(1 << chan.ID));
                    if (Dialog.ShowChannels != 0)
                    {
                        for (int i = 0; i < 5; i++)
                        {
                            if ((Dialog.ShowChannels & (1 << i)) > 0)
                            {
                                Dialog.Owner.ChatPanel.ActiveChannel = i;
                                break;
                            }
                        }
                    }
                    else
                    {
                        Dialog.Owner.ChatPanel.ActiveChannel = 0;
                    }
                }
                else
                {
                    //setting this chat as default, and showing it.
                    Dialog.ShowChannels |= (byte)(1 << chan.ID);
                    Dialog.Owner.ChatPanel.ActiveChannel = chan.ID;
                }
                if (Dialog.ShowChannels == 0)
                {
                    Dialog.ShowChannels = 1;
                }
                Dialog.RenderEvents();
                Populate();
            }
        }
예제 #2
0
        private void NewButton(UIElement button)
        {
            //make a new chat channel with a free id
            var channels = Dialog.Owner.vm.TSOState.ChatChannels;

            if (channels.Count >= 4)
            {
                return;
            }
            int freeID = 0;
            int i      = 0;

            foreach (var chan in channels.OrderBy(x => x.ID))
            {
                if (freeID + 1 + (i++) < chan.ID)
                {
                    freeID = chan.ID;
                    break;
                }
            }
            if (freeID == 0)
            {
                freeID = channels.Count + 1;
            }

            var dialog = new UIChatCategoryDialog(new VMTSOChatChannel {
                ID          = (byte)freeID,
                Name        = GameFacade.Strings.GetString("f113", "41"),
                Description = GameFacade.Strings.GetString("f113", "42")
            }, true);

            UIScreen.GlobalShowDialog(dialog, true);
            dialog.OKButton.OnButtonClick += (btn) =>
            {
                Dialog.Owner.vm.SendCommand(new VMNetChatEditChanCmd()
                {
                    Channel = dialog.Channel
                });
            };
        }