少年修仙传客户端代码仓库
client_Wu Xijin
2018-08-11 b2e7b00de77a2135113daee9778bb908e11f31f2
System/SystemSetting/ChatSetting.cs
@@ -1,170 +1,170 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public enum ChatBoolType
{
    ChannelSystem = 0 , //系统频道
    ChannelWorld,//世界频道
    ChannelATeam,//组队频道
    ChannelTeam,//队伍频道
    ChannelBugle,//喇叭频道
    ChannelGrad,//仙盟频道
    ChannelArea,//区域频道
    //ChannelAlliance,//同盟频道
    Voice1,
    Voice2,
    Voice3,
    GradVoiceWifi,  //仙盟语音Wifi
    PrivateChatVoiceWifi,//私聊语音Wifi
    TeamVoiceWifi,//队伍语音Wifi
    WorldVoiceWifi,//世界语音Wifi
    AreaVoiceWifi,//区域语音Wifi
   // AllianceVoiceWifi, //同盟语音Wifi
    GradVoice4G,//仙盟语音4G
    PrivatChatVoice4G,//私聊语音4G
    TeamVoice4G,//队伍语音4G
    WorldVoice4G,//世界语音4G
    AreaVoice4G,//区域语音4G
    //AllianceVoice4G, //同盟语音4G
}
 public class ChatSetting : Singleton<ChatSetting>
{
    const string ChatBoolSet_Key = "ChatBoolSet";
    public event Action<ChatBoolType, bool> RefreshChatSetAct;
    #region 缓存数据
    public Dictionary<ChatBoolType, bool> boolSetDict { get; private set; }
    public void GetLoginBoolSet()
    {
        boolSetDict = new Dictionary<ChatBoolType, bool>();
        for (int i = 0; i < 20; i++)
        {
            if (!boolSetDict.ContainsKey((ChatBoolType)i))
            {
                boolSetDict.Add((ChatBoolType)i, SettingMgr.Instance.GetAccountSetBoolInfo(((ChatBoolType)i).ToString()));
            }
        }
    }
    #endregion
    public void SetBoolSetStr(ChatBoolType type, bool isOpen)
    {
        SettingMgr.Instance.SetAccountSetStr(type.ToString(),isOpen.ToString());
        switch (type) {
            case ChatBoolType.ChannelSystem:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.System, isOpen);
                break;
            case ChatBoolType.ChannelWorld:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.World, isOpen);
                break;
            case ChatBoolType.ChannelATeam:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.Invite, isOpen);
                break;
            case ChatBoolType.ChannelTeam:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.Team, isOpen);
                break;
            case ChatBoolType.ChannelBugle:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.Trumpet, isOpen);
                break;
            case ChatBoolType.ChannelGrad:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.Fairy, isOpen);
                break;
            case ChatBoolType.ChannelArea:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.Area, isOpen);
                break;
        }
        if (boolSetDict != null)
        {
            if (boolSetDict.ContainsKey(type))
            {
                boolSetDict[type] = isOpen;
            }
        }
        if(RefreshChatSetAct != null)
        {
            RefreshChatSetAct(type,isOpen);
        }
    }
    public bool GetBool(ChatBoolType type)
    {
        if (boolSetDict != null)
        {
            bool isOpen = false;
            boolSetDict.TryGetValue(type, out isOpen);
            return isOpen;
        }
        else
        {
            return SettingMgr.Instance.GetAccountSetBoolInfo(type.ToString());
        }
    }
    public bool GetAutoPlayVoice(ChatInfoType type, int netState)
    {
        switch (type)
        {
            case ChatInfoType.World:
                if (netState == 1)
                {
                    return GetBool(ChatBoolType.WorldVoiceWifi);
                }
                else if (netState == 4)
                {
                    return GetBool(ChatBoolType.WorldVoice4G);
                }
                break;
            case ChatInfoType.Area:
                if (netState == 1)
                {
                    return GetBool(ChatBoolType.AreaVoiceWifi);
                }
                else if (netState == 4)
                {
                    return GetBool(ChatBoolType.AreaVoice4G);
                }
                break;
            case ChatInfoType.Team:
                if (netState == 1)
                {
                    return GetBool(ChatBoolType.TeamVoiceWifi);
                }
                else if (netState == 4)
                {
                    return GetBool(ChatBoolType.TeamVoice4G);
                }
                break;
            case ChatInfoType.Fairy:
                if (netState == 1)
                {
                    return GetBool(ChatBoolType.GradVoiceWifi);
                }
                else if (netState == 4)
                {
                    return GetBool(ChatBoolType.GradVoice4G);
                }
                break;
            case ChatInfoType.Friend:
                if (netState == 1)
                {
                    return GetBool(ChatBoolType.PrivateChatVoiceWifi);
                }
                else if (netState == 4)
                {
                    return GetBool(ChatBoolType.PrivatChatVoice4G);
                }
                break;
        }
        return false;
    }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public enum ChatBoolType
{
    ChannelSystem = 0 , //系统频道
    ChannelWorld,//世界频道
    ChannelATeam,//组队频道
    ChannelTeam,//队伍频道
    ChannelBugle,//喇叭频道
    ChannelGrad,//仙盟频道
    ChannelArea,//区域频道
    //ChannelAlliance,//同盟频道
    Voice1,
    Voice2,
    Voice3,
    GradVoiceWifi,  //仙盟语音Wifi
    PrivateChatVoiceWifi,//私聊语音Wifi
    TeamVoiceWifi,//队伍语音Wifi
    WorldVoiceWifi,//世界语音Wifi
    AreaVoiceWifi,//区域语音Wifi
   // AllianceVoiceWifi, //同盟语音Wifi
    GradVoice4G,//仙盟语音4G
    PrivatChatVoice4G,//私聊语音4G
    TeamVoice4G,//队伍语音4G
    WorldVoice4G,//世界语音4G
    AreaVoice4G,//区域语音4G
    //AllianceVoice4G, //同盟语音4G
}
 public class ChatSetting : Singleton<ChatSetting>
{
    const string ChatBoolSet_Key = "ChatBoolSet";
    public event Action<ChatBoolType, bool> RefreshChatSetAct;
    #region 缓存数据
    public Dictionary<ChatBoolType, bool> boolSetDict { get; private set; }
    public void GetLoginBoolSet()
    {
        boolSetDict = new Dictionary<ChatBoolType, bool>();
        for (int i = 0; i < 20; i++)
        {
            if (!boolSetDict.ContainsKey((ChatBoolType)i))
            {
                boolSetDict.Add((ChatBoolType)i, SettingMgr.Instance.GetAccountSetBoolInfo(((ChatBoolType)i).ToString()));
            }
        }
    }
    #endregion
    public void SetBoolSetStr(ChatBoolType type, bool isOpen)
    {
        SettingMgr.Instance.SetAccountSetStr(type.ToString(),isOpen.ToString());
        switch (type) {
            case ChatBoolType.ChannelSystem:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.System, isOpen);
                break;
            case ChatBoolType.ChannelWorld:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.World, isOpen);
                break;
            case ChatBoolType.ChannelATeam:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.Invite, isOpen);
                break;
            case ChatBoolType.ChannelTeam:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.Team, isOpen);
                break;
            case ChatBoolType.ChannelBugle:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.Trumpet, isOpen);
                break;
            case ChatBoolType.ChannelGrad:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.Fairy, isOpen);
                break;
            case ChatBoolType.ChannelArea:
                ChatCtrl.Inst.SetChatChannelShow(ChatInfoType.Area, isOpen);
                break;
        }
        if (boolSetDict != null)
        {
            if (boolSetDict.ContainsKey(type))
            {
                boolSetDict[type] = isOpen;
            }
        }
        if(RefreshChatSetAct != null)
        {
            RefreshChatSetAct(type,isOpen);
        }
    }
    public bool GetBool(ChatBoolType type)
    {
        if (boolSetDict != null)
        {
            bool isOpen = false;
            boolSetDict.TryGetValue(type, out isOpen);
            return isOpen;
        }
        else
        {
            return SettingMgr.Instance.GetAccountSetBoolInfo(type.ToString());
        }
    }
    public bool GetAutoPlayVoice(ChatInfoType type, int netState)
    {
        switch (type)
        {
            case ChatInfoType.World:
                if (netState == 1)
                {
                    return GetBool(ChatBoolType.WorldVoiceWifi);
                }
                else if (netState == 4)
                {
                    return GetBool(ChatBoolType.WorldVoice4G);
                }
                break;
            case ChatInfoType.Area:
                if (netState == 1)
                {
                    return GetBool(ChatBoolType.AreaVoiceWifi);
                }
                else if (netState == 4)
                {
                    return GetBool(ChatBoolType.AreaVoice4G);
                }
                break;
            case ChatInfoType.Team:
                if (netState == 1)
                {
                    return GetBool(ChatBoolType.TeamVoiceWifi);
                }
                else if (netState == 4)
                {
                    return GetBool(ChatBoolType.TeamVoice4G);
                }
                break;
            case ChatInfoType.Fairy:
                if (netState == 1)
                {
                    return GetBool(ChatBoolType.GradVoiceWifi);
                }
                else if (netState == 4)
                {
                    return GetBool(ChatBoolType.GradVoice4G);
                }
                break;
            case ChatInfoType.Friend:
                if (netState == 1)
                {
                    return GetBool(ChatBoolType.PrivateChatVoiceWifi);
                }
                else if (netState == 4)
                {
                    return GetBool(ChatBoolType.PrivatChatVoice4G);
                }
                break;
        }
        return false;
    }
}