-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTCharRankInfoDlg.cpp
352 lines (290 loc) · 9.62 KB
/
TCharRankInfoDlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
#include "Stdafx.h"
#include "TFameRank.h"
#include "TCharRankInfoDlg.h"
#include "TClientGame.h"
BYTE CTCharRankInfoDlg::m_bTabIndex = CTCharRankInfoDlg::TRANKINFO_TAB_TOTAL;
CTCharRankInfoDlg::CTCharRankInfoDlg( TComponent *pParent, LP_FRAMEDESC pDesc )
: CTClientUIBase(pParent, pDesc)
{
CPoint ptRankOffset, ptGuildOffset, ptNameOffset, ptCountryOffset, ptMonthfameOffset, ptButtonOffset;
{
static DWORD dwBASE_NEW[ MAX_SLOT_COUNT ] =
{
ID_CTRLINST_SLOT1, //ID_CTRLINST_SLOT01
ID_CTRLINST_SLOT2, //ID_CTRLINST_SLOT02
ID_CTRLINST_SLOT3, //ID_CTRLINST_SLOT03
ID_CTRLINST_SLOT4, //ID_CTRLINST_SLOT04
ID_CTRLINST_SLOT5, //ID_CTRLINST_SLOT05
ID_CTRLINST_SLOT6, //ID_CTRLINST_SLOT06
ID_CTRLINST_SLOT7, //ID_CTRLINST_SLOT07
ID_CTRLINST_SLOT8, //ID_CTRLINST_SLOT08
ID_CTRLINST_SLOT9, //ID_CTRLINST_SLOT09
ID_CTRLINST_SLOT10, //ID_CTRLINST_SLOT10
ID_CTRLINST_SLOT11, //ID_CTRLINST_SLOT11
ID_CTRLINST_SLOT12, //ID_CTRLINST_SLOT12
ID_CTRLINST_SLOT13, //ID_CTRLINST_SLOT13
ID_CTRLINST_SLOT14, //ID_CTRLINST_SLOT14
ID_CTRLINST_SLOT15, //ID_CTRLINST_SLOT15
ID_CTRLINST_SLOT16, //ID_CTRLINST_SLOT16
};
CPoint ptBase, ptRank, ptGuild, ptName, ptCountry, ptMonthfame, ptButton;
m_pSLOT[0] = FindKid( ID_CTRLINST_SLOT1 );
m_pRANK[0] = FindKid( ID_CTRLINST_RANK );
m_pGUILD[0] = FindKid( ID_CTRLINST_GUILD );
m_pNAME[0] = FindKid( ID_CTRLINST_NAME);
m_pCOUNTRY[0] = FindKid( ID_CTRLINST_COUNTRY );
m_pMONTHFAME[0] = FindKid( ID_CTRLINST_MONTH_FAME );
m_pBUTTON[0] = (TButton*) FindKid( ID_CTRLINST_BTN_LIST );
m_pSLOT[0]->GetComponentPos( &ptBase );
m_pRANK[0]->GetComponentPos( &ptRank );
m_pGUILD[0]->GetComponentPos( &ptGuild );
m_pNAME[0]->GetComponentPos( &ptName );
m_pCOUNTRY[0]->GetComponentPos( &ptCountry );
m_pMONTHFAME[0]->GetComponentPos( &ptMonthfame );
m_pBUTTON[0]->GetComponentPos( &ptButton );
ptRankOffset = ptRank - ptBase;
ptGuildOffset = ptGuild - ptBase;
ptNameOffset = ptName - ptBase;
ptCountryOffset = ptCountry - ptBase;
ptMonthfameOffset = ptMonthfame - ptBase;
ptButtonOffset = ptButton - ptBase;
for( INT i = 1; i < MAX_SLOT_COUNT; ++i )
{
m_pSLOT[i] = FindKid( dwBASE_NEW[i] );
m_pBUTTON[i] = new TButton( this, m_pBUTTON[0]->m_pDESC);
m_pRANK[i] = new TComponent( this, m_pRANK[0]->m_pDESC);
m_pGUILD[i] = new TComponent( this, m_pGUILD[0]->m_pDESC);
m_pNAME[i] = new TComponent( this, m_pNAME[0]->m_pDESC);
m_pCOUNTRY[i] = new TComponent( this, m_pCOUNTRY[0]->m_pDESC);
m_pMONTHFAME[i] = new TComponent( this, m_pMONTHFAME[0]->m_pDESC);
m_pBUTTON[i]->m_id = GetUniqueID();
m_pRANK[i]->m_id = GetUniqueID();
m_pGUILD[i]->m_id = GetUniqueID();
m_pNAME[i]->m_id = GetUniqueID();
m_pCOUNTRY[i]->m_id = GetUniqueID();
m_pMONTHFAME[i]->m_id = GetUniqueID();
AddKid( m_pBUTTON[i] );
AddKid( m_pRANK[i] );
AddKid( m_pGUILD[i] );
AddKid( m_pNAME[i] );
AddKid( m_pCOUNTRY[i] );
AddKid( m_pMONTHFAME[i] );
m_pSLOT[i]->GetComponentPos( &ptBase );
m_pBUTTON[i]->MoveComponent( ptBase + ptButtonOffset );
m_pRANK[i]->MoveComponent( ptBase + ptRankOffset );
m_pGUILD[i]->MoveComponent( ptBase + ptGuildOffset );
m_pNAME[i]->MoveComponent( ptBase + ptNameOffset );
m_pCOUNTRY[i]->MoveComponent( ptBase + ptCountryOffset );
m_pMONTHFAME[i]->MoveComponent( ptBase + ptMonthfameOffset );
}
}
m_bFirstCount = 0;
}
CTCharRankInfoDlg::~CTCharRankInfoDlg(void)
{
ReleaseData();
}
void CTCharRankInfoDlg::ReleaseData()
{
TMAPFAMERANK::iterator itFRAMERANK;
VTFAMERANK::iterator itVTFRAMERANK;
for ( int i = 0; i < TCONTRY_COUNT; ++i )
{
for ( itFRAMERANK = m_mapMONTHFAMERANK[i].begin(); itFRAMERANK != m_mapMONTHFAMERANK[i].end(); itFRAMERANK++ )
delete (*itFRAMERANK).second;
m_mapMONTHFAMERANK[i].clear();
}
for ( itVTFRAMERANK = m_vtFIRSTGRADEGROUP.begin(); itVTFRAMERANK != m_vtFIRSTGRADEGROUP.end(); itVTFRAMERANK++ )
delete (*itVTFRAMERANK);
m_vtFIRSTGRADEGROUP.clear();
m_vtFAMERANK.clear();
}
void CTCharRankInfoDlg::ResetData( BYTE bTopTabIndex, BYTE bBottonTabIndex )
{
TMAPFAMERANK::iterator itFRAMERANK;
m_vtFAMERANK.clear();
if ( bTopTabIndex == TRANKINFO_TAB_TOTAL )
{
for( int i = 0; i < TCONTRY_COUNT; ++i )
{
for ( int j = 1; j < m_mapMONTHFAMERANK[i].size(); ++j )
{
if ( m_mapMONTHFAMERANK[i][j]->dwMonthPoint > 0 )
m_vtFAMERANK.push_back( m_mapMONTHFAMERANK[i][j] );
}
}
sort( m_vtFAMERANK.begin(), m_vtFAMERANK.end(), SortRank );
}
else if ( bTopTabIndex == TRANKINFO_TAB_COUNTRY )
{
BYTE bCountry = CTClientGame::GetInstance()->GetMainChar()->m_bContryID;
for ( int i = 1; i < m_mapMONTHFAMERANK[bCountry].size(); ++i )
{
if ( m_mapMONTHFAMERANK[bCountry][i]->dwMonthPoint > 0 )
m_vtFAMERANK.push_back( m_mapMONTHFAMERANK[bCountry][i] );
}
}
else if ( bTopTabIndex == TRANKINFO_TAB_TOURNAMENT )
{
for ( int i = 0; i < m_vtFIRSTGRADEGROUP.size(); ++i )
{
m_vtFAMERANK.push_back( m_vtFIRSTGRADEGROUP[i] );
}
}
for ( INT i = 0; i < MAX_SLOT_COUNT; ++i )
{
if ( m_vtFAMERANK.size() > i )
{
m_pRANK[i]->m_strText.Format("%d", i+1);
m_pNAME[i]->m_strText = m_vtFAMERANK[i]->strName;
m_pCOUNTRY[i]->m_strText = CTChart::LoadString( (TSTRING) CTClientGame::m_vTCOUNTRYSTR[m_vtFAMERANK[i]->bCountry] );
m_pGUILD[i]->m_strText = m_vtFAMERANK[i]->strGuild;
m_pMONTHFAME[i]->m_strText.Format("%d", m_vtFAMERANK[i]->dwMonthPoint );
m_pBUTTON[i]->EnableComponent( FALSE );
}
else
{
m_pRANK[i]->m_strText = CString("");
m_pNAME[i]->m_strText = CString("");
m_pCOUNTRY[i]->m_strText = CString("");
m_pGUILD[i]->m_strText = CString("");
m_pMONTHFAME[i]->m_strText = CString("");
m_pBUTTON[i]->EnableComponent( FALSE );
}
if ( ( bTopTabIndex == TRANKINFO_TAB_TOTAL && i < MAX_COLOR_SLOT_COUNT ) ||
( bTopTabIndex == TRANKINFO_TAB_COUNTRY && i < (m_bFirstCount - 1) ) ||
bTopTabIndex == TRANKINFO_TAB_TOURNAMENT )
{
CGDIFont *pGDIFont = FindFont( ID_FONT_LOGIN_BROWN );
if( m_pRANK[i]->GetFont() != pGDIFont )
m_pRANK[i]->SetFont( pGDIFont, NULL);
if( m_pNAME[i]->GetFont() != pGDIFont )
m_pNAME[i]->SetFont( pGDIFont, NULL);
if( m_pCOUNTRY[i]->GetFont() != pGDIFont )
m_pCOUNTRY[i]->SetFont( pGDIFont, NULL);
if( m_pGUILD[i]->GetFont() != pGDIFont )
m_pGUILD[i]->SetFont( pGDIFont, NULL);
if( m_pMONTHFAME[i]->GetFont() != pGDIFont )
m_pMONTHFAME[i]->SetFont( pGDIFont, NULL);
}
else
{
CGDIFont *pGDIFont = FindFont( ID_FONT_FAME_LIST );
if( m_pRANK[i]->GetFont() != pGDIFont )
m_pRANK[i]->SetFont( pGDIFont, NULL);
if( m_pNAME[i]->GetFont() != pGDIFont )
m_pNAME[i]->SetFont( pGDIFont, NULL);
if( m_pCOUNTRY[i]->GetFont() != pGDIFont )
m_pCOUNTRY[i]->SetFont( pGDIFont, NULL);
if( m_pGUILD[i]->GetFont() != pGDIFont )
m_pGUILD[i]->SetFont( pGDIFont, NULL);
if( m_pMONTHFAME[i]->GetFont() != pGDIFont )
m_pMONTHFAME[i]->SetFont( pGDIFont, NULL);
}
}
TButton *pTopTAB[TRANKINFO_TAB_COUNT] = {
(TButton *) FindKid(ID_CTRLINST_TAB_1),
(TButton *) FindKid(ID_CTRLINST_TAB_2),
(TButton *) FindKid(ID_CTRLINST_TAB_3),
};
for ( BYTE i = 0; i < TRANKINFO_TAB_COUNT; ++i )
{
pTopTAB[i]->Select( i == bTopTabIndex ? TRUE : FALSE );
CGDIFont *pGDIFont = FindFont(pTopTAB[i]->IsStateDown() ? ID_FONT_LOGIN : ID_FONT_DISABLE);
if( pTopTAB[i]->GetFont() != pGDIFont )
pTopTAB[i]->SetFont( pGDIFont, NULL);
}
}
BOOL CTCharRankInfoDlg::SortRank( CTFameRank* pLeft, CTFameRank* pRight )
{
if ( pLeft->dwMonthPoint > pRight->dwMonthPoint )
{
return TRUE;
}
else if ( pLeft->dwMonthPoint == pRight->dwMonthPoint )
{
if ( pLeft->wWin > pRight->wWin )
{
return TRUE;
}
else if ( pLeft->wWin == pRight->wWin )
{
if( (pLeft->wWin+pLeft->wLose) > (pRight->wWin+pRight->wLose) )
{
return TRUE;
}
else if ( (pLeft->wWin+pLeft->wLose) == (pRight->wWin+pRight->wLose) )
{
return ( pLeft->strName < pRight->strName );
}
else
{
return FALSE;
}
}
else
{
return FALSE;
}
}
else
{
return FALSE;
}
}
void CTCharRankInfoDlg::OnLButtonUp(UINT nFlags, CPoint pt)
{
GetComponentPos( &CTCharInfoDlg::m_ptPOS);
CTClientUIBase::OnLButtonUp( nFlags, pt );
}
void CTCharRankInfoDlg::ShowComponent( BOOL bVisible )
{
MoveComponent( CTCharInfoDlg::m_ptPOS );
if( bVisible )
{
CTClientUIBase* pDLG = CTClientGame::GetInstance()->GetFrame( TFRAME_CHAR_INFO );
pDLG->ShowComponent( FALSE );
pDLG = CTClientGame::GetInstance()->GetFrame( TFRAME_CHAR_PVP_INFO );
pDLG->ShowComponent( FALSE );
}
CTClientUIBase::ShowComponent( bVisible );
}
ITDetailInfoPtr CTCharRankInfoDlg::GetTInfoKey( const CPoint& point )
{
ITDetailInfoPtr pInfo;
for ( INT i = 0; i < MAX_SLOT_COUNT ; ++i )
{
if ( m_pBUTTON[i]->HitTest( point ) && m_vtFAMERANK.size() > i )
{
CRect rc;
GetComponentRect(&rc);
return CTDetailInfoManager::NewFameInst(
m_vtFAMERANK[i]->strName,
m_vtFAMERANK[i]->dwTotalPoint,
m_vtFAMERANK[i]->dwMonthPoint,
m_vtFAMERANK[i]->wWin,
m_vtFAMERANK[i]->wLose,
m_vtFAMERANK[i]->bLevel,
m_vtFAMERANK[i]->bClass,
rc );
}
}
return pInfo;
}
void CTCharRankInfoDlg::ResetTabIndex( BYTE bTabIndex )
{
TButton *pBottonTAB[TINFO_COUNT] = {
(TButton *) FindKid(ID_CTRLINST_BASIC),
(TButton *) FindKid(ID_CTRLINST_MORE),
(TButton *) FindKid(ID_CTRLINST_WAR),
(TButton *) FindKid(ID_CTRLINST_PVP),
(TButton *) FindKid(ID_CTRLINST_BTN_RANK),
};
for( BYTE i = 0; i < TINFO_COUNT; ++i )
{
pBottonTAB[i]->Select( i == bTabIndex ? TRUE : FALSE);
/*CGDIFont *pGDIFont = FindFont(pBottonTAB[i]->IsStateDown() ? ID_FONT_LOGIN : ID_FONT_DISABLE);
if( pBottonTAB[i]->GetFont() != pGDIFont )
pBottonTAB[i]->SetFont( pGDIFont, NULL);*/
}
}