public static int GetChannel(ChatChannel channel) { switch (channel) { case ChatChannel.GobchatInfo: return(0x01FFFF); case ChatChannel.GobchatError: return(0x02FFFF); default: var channelData = GobchatChannelMapping.GetChannel(channel); // loss of data in some cases return((int)(channelData.ClientChannel.Length == 0 ? 0 : channelData.ClientChannel[0])); } }
private static ChatChannel GetChannel(int value) { // special cases, they were removed from FFXIVChatChannel, because they are Gobchat specific if (value == 0x01FFFF) { return(ChatChannel.GobchatInfo); } if (value == 0x02FFFF) { return(ChatChannel.GobchatError); } var ffxivChannel = (FFXIVChatChannel)value; var data = GobchatChannelMapping.GetChannel(ffxivChannel); return(data.ChatChannel); }
private void Browser_OnLoadPage_InjectEnums() { _browserAPIManager.ExecuteGobchatJavascript(builder => { builder.Append("Gobchat.MessageSegmentEnum = "); builder.AppendLine(typeof(MessageSegmentType).EnumToJson(s => s.ToUpperInvariant())); }); _browserAPIManager.ExecuteGobchatJavascript(builder => { builder.Append("Gobchat.ChannelEnum = "); builder.AppendLine(typeof(ChatChannel).EnumToJson(s => s.ToUpperInvariant())); }); _browserAPIManager.ExecuteGobchatJavascript(builder => { var channels = GobchatChannelMapping.GetAllChannels(); var settings = new Newtonsoft.Json.JsonSerializerSettings(); settings.ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver(); builder.AppendLine("Gobchat.Channels = {"); for (var i = 0; i < channels.Count; ++i) { var channel = channels[i]; var name = channel.ChatChannel.ToString().ToUpperInvariant(); var jsonObject = Newtonsoft.Json.JsonConvert.SerializeObject(channel, settings); builder.Append("\"").Append(name).Append("\": ").Append(jsonObject); if (i + 1 < channels.Count) { builder.AppendLine(","); } else { builder.AppendLine(); } } builder.AppendLine("}"); }); }
public string Format(ChatMessage msg) { var data = GobchatChannelMapping.GetChannel(msg.Channel); return(WebUIResources.ResourceManager.GetString(data.TranslationId)); }
public JObject Upgrade(JObject src) { JObject dst = (JObject)src.DeepClone(); JsonUtil.SetIfAvailable(dst, "behaviour.groups.data.group-ff-1.ffgroup", 0); JsonUtil.SetIfAvailable(dst, "behaviour.groups.data.group-ff-2.ffgroup", 1); JsonUtil.SetIfAvailable(dst, "behaviour.groups.data.group-ff-3.ffgroup", 2); JsonUtil.SetIfAvailable(dst, "behaviour.groups.data.group-ff-4.ffgroup", 3); JsonUtil.SetIfAvailable(dst, "behaviour.groups.data.group-ff-5.ffgroup", 4); JsonUtil.SetIfAvailable(dst, "behaviour.groups.data.group-ff-6.ffgroup", 5); JsonUtil.SetIfAvailable(dst, "behaviour.groups.data.group-ff-7.ffgroup", 6); var enumTranslationDictionary = Enum.GetValues(typeof(FFXIVChatChannel)).Cast <FFXIVChatChannel>().ToDictionary( key => key.ToString().ToUpperInvariant(), value => GobchatChannelMapping.GetChannel(value).ChatChannel); JArray ReplaceContent(JArray array) { var result = new JArray(); foreach (var element in array) { var key = element.ToString().ToUpperInvariant(); if (enumTranslationDictionary.TryGetValue(key, out var replacement)) { if (replacement == ChatChannel.None) { continue; } var value = replacement.ToString().ToUpperInvariant(); if (!result.Contains(value)) { result.Add(value); } } } return(result); } JsonUtil.MoveIfAvailable(dst, "style.channel.animated-emote", dst, "style.channel.animatedemote"); JsonUtil.MoveIfAvailable(dst, "style.channel.roll", dst, "style.channel.random"); JsonUtil.MoveIfAvailable(dst, "style.channel.worldlinkshell-1", dst, "style.channel.crossworldlinkshell-1"); JsonUtil.MoveIfAvailable(dst, "style.channel.worldlinkshell-2", dst, "style.channel.crossworldlinkshell-2"); JsonUtil.MoveIfAvailable(dst, "style.channel.worldlinkshell-3", dst, "style.channel.crossworldlinkshell-3"); JsonUtil.MoveIfAvailable(dst, "style.channel.worldlinkshell-4", dst, "style.channel.crossworldlinkshell-4"); JsonUtil.MoveIfAvailable(dst, "style.channel.worldlinkshell-5", dst, "style.channel.crossworldlinkshell-5"); JsonUtil.MoveIfAvailable(dst, "style.channel.worldlinkshell-6", dst, "style.channel.crossworldlinkshell-6"); JsonUtil.MoveIfAvailable(dst, "style.channel.worldlinkshell-7", dst, "style.channel.crossworldlinkshell-7"); JsonUtil.MoveIfAvailable(dst, "style.channel.worldlinkshell-8", dst, "style.channel.crossworldlinkshell-8"); JsonUtil.ReplaceArrayIfAvailable(dst, "behaviour.channel.roleplay", ReplaceContent); JsonUtil.ReplaceArrayIfAvailable(dst, "behaviour.channel.mention", ReplaceContent); JsonUtil.ReplaceArrayIfAvailable(dst, "behaviour.channel.visible", ReplaceContent); JsonUtil.ReplaceArrayIfAvailable(dst, "behaviour.channel.rangefilter", ReplaceContent); JsonUtil.ReplaceArrayIfAvailable(dst, "behaviour.channel.visible", (array) => { array.Add(ChatChannel.GobchatInfo.ToString().ToUpperInvariant()); array.Add(ChatChannel.GobchatError.ToString().ToUpperInvariant()); return(array); }); return(dst); }