2 #include "nlite_include.h"
5 CListenerList nlite::listenerList;
10 //
\83\8a\83X
\83i
\81[
\8c\9f\8dõ
\83I
\83u
\83W
\83F
\83N
\83g
15 ListenerPre(ListenerData &in_user):
19 bool operator()(CListenerList::reference listenerData){
22 return (user.user_id == listenerData.user_id) && (user.community == listenerData.community);
29 //
\83\8a\83X
\83i
\81[
\83f
\81[
\83^
30 /////////////////////////////////////////////////////////////////////////////////////////////////
33 ListenerData::ListenerData():
38 //originBkFlag(FALSE),
42 VOID ListenerData::SetBkColor(COLORREF bkColor_in){
48 CChatData::ViewData::ViewData():
49 sellLineColor(INIT_COLOR),
50 stringColor(INIT_COLOR),
51 backColor(INIT_COLOR),
56 VOID CChatData::SetChat(NicoLiveChat &chat_in,ListenerData &listener){
59 this->anonymity = _ttol(chat_in.anonymity);
60 this->premium = _ttol(chat_in.premium);
61 this->chatBuf = chat_in.chatBuf;
62 this->no = _ttol(chat_in.no);
64 if(_tcscmp(chat_in.locale,TEXT("jp")) == 0){
65 this->locale = cuntry::jp;
67 this->locale = cuntry::unknown;
69 this->mail.reserve(chat_in.mailCount);
70 for(UINT_PTR index = 0;index < chat_in.mailCount ;index++){
72 this->mail.push_back(chat_in.mail[index]);
75 this->name = chat_in.name;
79 this->listenerData = &listenerList.Register(listener,FALSE);
82 this->vpos = _ttol(chat_in.vpos);
83 this->thread = _ttol(chat_in.thread);
84 this->date = _ttol(chat_in.date);
94 //
\83R
\83\81\83\93\83g
\83\8a\83X
\83g
\83N
\83\89\83X
95 //////////////////////////////////////////////////////////////////////////
97 //
\91I
\91ð
\8ds
\8eæ
\93¾
\97p
\83t
\83@
\83\93\83N
\83V
\83\87\83i
\83\8b
98 struct GetCurSelFunc_t{
106 BOOL operator() (const CChatData &target){
108 return target.viewData.selectFlag;
113 //
\91}
\93ü
\88Ê
\92u
\8c\9f\8dõ
\83t
\83@
\83\93\83N
\83V
\83\87\83i
\83\8b
114 struct SeartchSetPos_t{
117 SeartchSetPos_t(time_t in_time):time(in_time){}
119 bool operator()(const CChatData &target){
121 return time > target.date;
125 CCommentList::CCommentList(){}
127 CCommentList::~CCommentList(){}
129 CCommentList::iterator CCommentList::GetCurSel(){
130 auto end = this->end();
131 auto ite = this->begin();
133 for(;ite != end && ite->viewData.selectFlag == FALSE;++ite);
139 INT_PTR CCommentList::GetCurSelNo(){
141 auto end = this->end();
142 auto ite = this->begin();
144 for(;ite != end && ite->viewData.selectFlag == FALSE;++ite,++no);
146 return ite != end ? no : -1;
151 CCommentList::iterator CCommentList::OnChatReceve(NicoLiveChat_P chatData_in,LPCTSTR communityID, UINT_PTR commnetCountSum,CCommentListWindow &listWindow){
154 ListenerData listenerData;
155 listenerData.user_id = chatData_in->user_id;
156 listenerData.time = time(NULL);
157 listenerData.community = communityID;
158 chatData.SetChat(*chatData_in,listenerData);
160 if(empty() == TRUE || back().date <= chatData.date){
161 chatList.push_back(chatData);
162 rslt = (--chatList.end());
165 rslt = chatList.insert(std::find_if(chatList.begin(),chatList.end(),SeartchSetPos_t(chatData.date)),chatData);
168 if(shortcut ==chatList.end())shortcut = chatList.begin();
173 CCommentList::iterator CCommentList::GetCurSelItem(){
174 auto rslt = std::find_if(chatList.begin(),chatList.end(),GetCurSelFunc_t());
180 VOID CCommentList::SetCurSel(CCommentList::iterator cursel){
182 auto end = this->end();
183 if(cursel == end)goto end;
185 auto curselItem = this->GetCurSelItem();
187 if(curselItem != end){
188 curselItem->viewData.selectFlag = FALSE;
192 cursel->viewData.selectFlag = TRUE;
200 CCommentList::reference CCommentList::GetChatAt(UINT_PTR no){
202 iterator data = chatList.begin();
203 std::advance(data,no);
208 UINT_PTR CCommentList::Size(){
210 return chatList.size();
213 BOOL CCommentList::empty(){
215 return chatList.empty();
220 CCommentList::iterator CCommentList::begin(){
222 return chatList.begin();
225 CCommentList::iterator CCommentList::end(){
227 return chatList.end();
231 CCommentList::reverse_iterator CCommentList::rbegein(){
234 return chatList.rbegin();
240 CCommentList::reverse_iterator CCommentList::rend(){
242 return chatList.rend();
245 VOID CCommentList::OnDestroy(){
251 VOID CCommentList::OnConnect(){
253 shortcut = chatList.begin();
256 CCommentList::reference CCommentList::back(){
258 return chatList.back();
262 ///
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\83C
\83e
\83\8c\81[
\83^
\82ð
\8eæ
\93¾
264 CCommentList::iterator CCommentList::GetShortCut(){
270 ///
\83V
\83\87\81[
\83g
\83J
\83b
\83g
\82ð
\90Ý
\92è
272 BOOL CCommentList::SetShortCut(UINT_PTR no){
275 if(static_cast<INT_PTR>(chatList.size()) <= no)return FALSE;
277 shortcut = chatList.begin();
278 std::advance(shortcut,no);
286 VOID CListenerList::BkColorCollect(CListenerColorCollector &target){
288 iterator end = m_listenerList.end();
289 std::for_each(m_listenerList.begin(), end,target);
292 CListenerList::reference CListenerList::Register(ListenerData &listener,BOOL bUpdate){
294 ListenerPre listenerPre(listener);
296 iterator begin = m_listenerList.begin();
297 iterator end = m_listenerList.end();
299 iterator rslt = std::find_if(begin,end,listenerPre);
306 m_listenerList.push_back(listener);
308 return m_listenerList.back();
310 } else if(bUpdate == TRUE){