Esempio n. 1
0
        public void LoadUserInfo()
        {
            UserItem userItem = IOTool.DeserializeFromString <UserItem>(PlayerPrefs.GetString(GlobalVars.PREF_USER_ITEM));

            _headIndex = userItem.headIndex;
            _userName  = userItem.userName;
        }
Esempio n. 2
0
        private void SaveLogDict()
        {
            foreach (var file in IOTool.GetFiles(GetChatDirPath()))
            {
                file.Delete();
            }

            foreach (var userID in _chatLogDict.Keys)
            {
                string filePath = GetChatDirPath() + "/" + userID;
                IOTool.SerializeToFile <ChatLog>(filePath, _chatLogDict[userID]);
            }
        }
        private void SaveFriendDict()
        {
            foreach (var file in IOTool.GetFiles(GetContactsDirPath()))
            {
                file.Delete();
            }

            foreach (var userID in _friendDict.Keys)
            {
                string filePath = GetContactsDirPath() + "/" + userID;
                IOTool.SerializeToFile <UserItem>(filePath, _friendDict[userID]);
            }
        }
Esempio n. 4
0
        private void SaveGroupDict()
        {
            foreach (var file in IOTool.GetFiles(GetGroupDirPath()))
            {
                file.Delete();
            }

            foreach (var groupID in _groupDict.Keys)
            {
                string filePath = GetGroupDirPath() + "/" + groupID;
                IOTool.SerializeToFile <GroupItem>(filePath, _groupDict[groupID]);
            }
        }
Esempio n. 5
0
 private void LoadLogDict()
 {
     ClearLogDict();
     if (IOTool.IsDirExist(GetChatDirPath()))
     {
         foreach (var file in IOTool.GetFiles(GetChatDirPath()))
         {
             ChatLog chatLog = IOTool.DeserializeFromFile <ChatLog>(file.FullName);
             if (chatLog != null)
             {
                 _chatLogDict[chatLog.chatID] = chatLog;
             }
         }
     }
 }
 private void LoadFriendDict()
 {
     ClearFriendDict();
     if (_friendDict.Count == 0 && IOTool.IsDirExist(GetContactsDirPath()))
     {
         foreach (var file in IOTool.GetFiles(GetContactsDirPath()))
         {
             UserItem userItem = IOTool.DeserializeFromFile <UserItem>(file.FullName);
             if (userItem != null)
             {
                 _friendDict[userItem.userId] = userItem;
             }
         }
     }
 }
Esempio n. 7
0
 private void LoadGroupDict()
 {
     ClearGroupDict();
     if (_groupDict.Count == 0 && IOTool.IsDirExist(GetGroupDirPath()))
     {
         foreach (var file in IOTool.GetFiles(GetGroupDirPath()))
         {
             GroupItem groupItem = IOTool.DeserializeFromFile <GroupItem>(file.FullName);
             if (groupItem != null)
             {
                 _groupDict[groupItem.groupId] = groupItem;
             }
         }
     }
 }
Esempio n. 8
0
        public void CreateDir()
        {
            string[] dirPathList = new string[]
            {
                Application.persistentDataPath + "/" + _userId,
                Application.persistentDataPath + "/" + _userId + "/Chat",
                Application.persistentDataPath + "/" + _userId + "/Contacts",
                Application.persistentDataPath + "/" + _userId + "/Head",
                Application.persistentDataPath + "/" + _userId + "/Image",
                Application.persistentDataPath + "/" + _userId + "/Group",
            };

            foreach (var dirPath in dirPathList)
            {
                IOTool.CreateDir(dirPath);
            }
        }
Esempio n. 9
0
 public void SaveUserInfo()
 {
     PlayerPrefs.SetString(GlobalVars.PREF_USER_ITEM, IOTool.SerializeToString <UserItem>(Self));
 }