using UnityEngine; using UnityEngine.UI; using System.Collections; using Games.Item; using System.Collections.Generic; using GCGame.Table; using Games.GlobeDefine; public class CommunityHotPageLogic : UIControllerBase { void OnEnable () { SetInstance(this); InitGlobalBlog(); } void OnDisable() { SetInstance(null); } public void CloseWindow() { gameObject.SetActive(false); } #region public UIButtonTime _ServerBlogBtn; public UIButtonTime _GlobalBlogBtn; public UIContainerBase _BlogContainer; private int _LoadBlogType; public void OnBtnServer() { InitServerBlog(); _ServerBlogBtn.SetBtnDisableTime(3); } public void InitServerBlog() { _LoadedBlogs.Clear(); _BlogContainer.InitContentItem(null); _LastIdx = -1; LoadMoreServerBlog(); _LoadBlogType = 0; } public void InitCityBlog() { _LoadedBlogs.Clear(); _BlogContainer.InitContentItem(null); _LastIdx = -1; _LoadBlogType = 1; } public void OnBtnGlobal() { InitGlobalBlog(); _GlobalBlogBtn.SetBtnDisableTime(3); } public void InitGlobalBlog() { _LoadedBlogs.Clear(); _BlogContainer.InitContentItem(null); _LastIdx = -1; LoadMoreClobalBlog(); _LoadBlogType = 2; } #endregion #region private List _LoadedBlogs = new List(); private int _LastIdx = -1; public void LoadMoreBlog() { switch (_LoadBlogType) { case 0: LoadMoreServerBlog(); break; case 2: LoadMoreClobalBlog(); break; } } public void LoadMoreServerBlog() { CG_REQ_VIEW_NATIVE_HOT_BLOG_LIST packet = (CG_REQ_VIEW_NATIVE_HOT_BLOG_LIST)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_VIEW_NATIVE_HOT_BLOG_LIST); packet.Curhothandle = _LastIdx; packet.Loadedsize = _LoadedBlogs.Count; packet.Count = 10; packet.SendPacket(); } public void RetLoadServerBlog(GC_RET_VIEW_NATIVE_HOT_BLOG_LIST packet) { for (int i = 0; i < packet.blogguidCount; ++i) { CommunityBlogInfo newBlog = new CommunityBlogInfo(); _LoadedBlogs.Add(newBlog); newBlog.GUID = packet.GetBlogguid(i); newBlog.Contex = packet.GetContext(i); newBlog.HeadIconUrl = packet.GetHeadpic(i); newBlog.Profession = packet.GetJoblist(i); newBlog.Level = packet.GetRolelevel(i); newBlog.RoleGuid = packet.GetRoleguid(i); newBlog.Name = packet.GetRolename(i); newBlog.ForwardingCnt = packet.GetReprinttimes(i); newBlog.LikeCnt = packet.GetLiketimes(i); newBlog.LikeRoles = new List(); for (int j = 0; j < packet.GetLikedrolelist(i).infolistCount; ++j) { newBlog.LikeRoles.Add(packet.GetLikedrolelist(i).GetInfolist(j)); } newBlog.Comments = new List(); for (int j = 0; j < packet.GetCommentlist(i).commentlistCount; ++j) { newBlog.Comments.Add(packet.GetCommentlist(i).GetCommentlist(j)); } newBlog.Time = packet.GetRecordtime(i); if (GlobeVar.IsGUIDValid(packet.GetReprintroleguid(i))) { newBlog.ForwardingBlog = new CommunityBlogInfo(); newBlog.ForwardingBlog.RoleGuid = packet.GetReprintroleguid(i); newBlog.ForwardingBlog.Name = packet.GetReprintrolename(i); newBlog.ForwardingBlog.HeadIconUrl = packet.GetReprintroleheadpic(i); newBlog.ForwardingBlog.Level = packet.GetReprintrolelevel(i); newBlog.ForwardingBlog.Profession = packet.GetReprintrolejob(i); newBlog.Contex = packet.GetReprintcomment(i); newBlog.ForwardingBlog.Contex = packet.GetContext(i); newBlog.ForwardingBlog.ContexImageUrls = new List(); for (int j = 0; j < packet.GetPicnamelist(i).vallistCount; ++j) { newBlog.ForwardingBlog.ContexImageUrls.Add(packet.GetPicnamelist(i).GetVallist(j)); } } else { newBlog.ContexImageUrls = new List(); for (int j = 0; j < packet.GetPicnamelist(i).vallistCount; ++j) { newBlog.ContexImageUrls.Add(packet.GetPicnamelist(i).GetVallist(j)); } } } _LastIdx = packet.Rankhandle; if (packet.blogguidCount > 0) { CommunityLogic.Instance()._EmptyTip.text = ""; } else { CommunityLogic.Instance()._EmptyTip.text = StrDictionary.GetClientDictionaryString("#{41310}"); } Hashtable hash = new Hashtable(); hash.Add("IsShowPlayerInfo", true); hash.Add("IsFixedCommentHeight", false); _BlogContainer.InitContentItem(_LoadedBlogs, null, hash); } public void LoadMoreClobalBlog() { CG_REQ_VIEW_CROSS_SERVER_HOT_BLOG_LIST packet = (CG_REQ_VIEW_CROSS_SERVER_HOT_BLOG_LIST)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_VIEW_CROSS_SERVER_HOT_BLOG_LIST); packet.Curhothandle = _LastIdx; packet.Loadedsize = _LoadedBlogs.Count; packet.Count = 10; packet.SendPacket(); } public void RetLoadGlobalBlog(GC_RET_VIEW_CROSS_SERVER_HOT_BLOG_LIST packet) { for (int i = 0; i < packet.blogguidCount; ++i) { CommunityBlogInfo newBlog = new CommunityBlogInfo(); _LoadedBlogs.Add(newBlog); newBlog.GUID = packet.GetBlogguid(i); newBlog.Contex = packet.GetContext(i); newBlog.HeadIconUrl = packet.GetHeadpic(i); newBlog.Profession = packet.GetJoblist(i); newBlog.Profession = packet.GetJoblist(i); newBlog.Level = packet.GetRolelevel(i); newBlog.RoleGuid = packet.GetRoleguid(i); newBlog.Name = packet.GetRolename(i); newBlog.ForwardingCnt = packet.GetReprinttimes(i); newBlog.LikeCnt = packet.GetLiketimes(i); newBlog.LikeRoles = new List(); for (int j = 0; j < packet.GetLikedrolelist(i).infolistCount; ++j) { newBlog.LikeRoles.Add(packet.GetLikedrolelist(i).GetInfolist(j)); } newBlog.Comments = new List(); for (int j = 0; j < packet.GetCommentlist(i).commentlistCount; ++j) { newBlog.Comments.Add(packet.GetCommentlist(i).GetCommentlist(j)); } newBlog.Time = packet.GetRecordtime(i); if (GlobeVar.IsGUIDValid(packet.GetReprintroleguid(i)) && !string.IsNullOrEmpty(packet.GetReprintrolename(i))) { newBlog.ForwardingBlog = new CommunityBlogInfo(); newBlog.ForwardingBlog.RoleGuid = packet.GetReprintroleguid(i); newBlog.ForwardingBlog.Name = packet.GetReprintrolename(i); newBlog.ForwardingBlog.HeadIconUrl = packet.GetReprintroleheadpic(i); newBlog.ForwardingBlog.Profession = packet.GetReprintrolejob(i); newBlog.ForwardingBlog.Level = packet.GetReprintrolelevel(i); newBlog.Contex = packet.GetReprintcomment(i); newBlog.ForwardingBlog.Contex = packet.GetContext(i); newBlog.ForwardingBlog.ContexImageUrls = new List(); for (int j = 0; j < packet.GetPicnamelist(i).vallistCount; ++j) { newBlog.ForwardingBlog.ContexImageUrls.Add(packet.GetPicnamelist(i).GetVallist(j)); } } else { newBlog.ContexImageUrls = new List(); for (int j = 0; j < packet.GetPicnamelist(i).vallistCount; ++j) { newBlog.ContexImageUrls.Add(packet.GetPicnamelist(i).GetVallist(j)); } } } _LastIdx = packet.Rankhandle; if (packet.blogguidCount > 0) { CommunityLogic.Instance()._EmptyTip.text = ""; } else { CommunityLogic.Instance()._EmptyTip.text = StrDictionary.GetClientDictionaryString("#{41310}"); } Hashtable hash = new Hashtable(); hash.Add("IsShowPlayerInfo", true); hash.Add("IsFixedCommentHeight", false); _BlogContainer.InitContentItem(_LoadedBlogs, null, hash); } #endregion }