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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
// LogSelectProps.cpp : implementation file
//
#include "stdafx.h"
#include "UI.h"
#include "LogSelectProps.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CLogSelectProps dialog
CLogSelectProps::CLogSelectProps(CWnd* pParent /*=NULL*/)
: CPropertyPage(CLogSelectProps::IDD),
m_persistLastDirectory(string("LastInputDirectory"))
{
//{{AFX_DATA_INIT(CLogSelectProps)
//}}AFX_DATA_INIT
m_psp.dwFlags &= ~PSP_HASHELP;
alreadyAcknowledged=false;
}
void CLogSelectProps::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CLogSelectProps)
DDX_Control(pDX, IDC_SELECT, m_SelectButton);
DDX_Control(pDX, IDC_REMOVELOG, m_RemoveButton);
DDX_Control(pDX, IDC_LOGS2DO, m_Logs2Do);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CLogSelectProps, CDialog)
//{{AFX_MSG_MAP(CLogSelectProps)
ON_LBN_SELCHANGE(IDC_LOGS2DO, OnSelchangeLogs2do)
ON_BN_CLICKED(IDC_REMOVELOG, OnRemovelog)
ON_BN_CLICKED(IDC_SELECT, OnSelect)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CLogSelectProps message handlers
void CLogSelectProps::OnSelect()
{
char* fileNameBuf= new char[10000];
memset(fileNameBuf,0,10000);
CFileDialog cfd(TRUE,".log",NULL,0,"Log Files (*.log)|*.log|Text Files (*.txt)|*.txt|All Files (*.*)|*.*||");
cfd.m_ofn.Flags|=OFN_ALLOWMULTISELECT;
cfd.m_ofn.lpstrFile=fileNameBuf;
cfd.m_ofn.nMaxFile=10000;
if (m_persistLastDirectory.toString()!="")
cfd.m_ofn.lpstrInitialDir=m_persistLastDirectory.toString().c_str();
if (cfd.DoModal()==IDOK)
{
POSITION pos=cfd.GetStartPosition();
while(pos)
{
CUIApp::CTFStatsExec* pc=new CUIApp::CTFStatsExec;
CString wow=cfd.GetNextPathName(pos);
//void _splitpath( const char *path, char *drive, char *dir, char *fname, char *ext );
pc->fullpath=wow;
char drvbuf[5];
char dirbuf[10000];
char namebuf[10000];
char extbuf[10000];
char fname[10000];
char inpdir[10000];
_splitpath(pc->fullpath.c_str(),drvbuf,dirbuf,namebuf,extbuf);
sprintf(inpdir,"%s%s",drvbuf,dirbuf);
sprintf(fname,"%s%s",namebuf,extbuf);
pc->outputsubdir=namebuf;
pc->inputfile=fname;
pc->logdirectory=inpdir;
m_persistLastDirectory=inpdir;
int idx=m_Logs2Do.AddString(pc->fullpath.c_str());
m_Logs2Do.SetItemDataPtr(idx,pc);
}
}
delete [] fileNameBuf;
}
list<CUIApp::CTFStatsExec>* CLogSelectProps::getList()
{
list<CUIApp::CTFStatsExec>* pRetList=new list<CUIApp::CTFStatsExec>;
int numItems=m_Logs2Do.GetCount();
for (int i=0;i<numItems;i++)
{
CUIApp::CTFStatsExec * pExec=(CUIApp::CTFStatsExec *)m_Logs2Do.GetItemDataPtr(i);
pRetList->push_back(*pExec);
}
return pRetList;
}
void CLogSelectProps::OnSelchangeLogs2do()
{
if (m_Logs2Do.GetSelCount() > 0)
m_RemoveButton.EnableWindow(TRUE);
else
m_RemoveButton.EnableWindow(FALSE);
}
void CLogSelectProps::OnRemovelog()
{
int* selitems=new int[500];
int numselected=m_Logs2Do.GetSelItems(500,selitems);
//have to do it backwards to account for indices being changed by the actual deletions
for (int i=numselected-1;i>=0;i--)
{
//delete m_Logs2Do.GetItemDataPtr(selitems[i]);
//m_Logs2Do.SetItemData(selitems[i],0);
CString wow;
m_Logs2Do.GetText(selitems[i],wow);
m_Logs2Do.DeleteString(selitems[i]);
}
delete [] selitems;
m_Logs2Do.SetSel(-1,FALSE);
}
#include "propsht.h"
BOOL CLogSelectProps::OnSetActive()
{
//call superclass
BOOL bRes=this->CPropertyPage::OnSetActive();
if (theApp.FirstEverTimeRun && !alreadyAcknowledged)
{
alreadyAcknowledged=true;
CPersistentString cps("InstallPath","Software\\Valve\\Half-Life");
string basedir=addSlash(cps.toString());
basedir+="tfc\\logs";
m_persistLastDirectory=basedir;
}
return bRes;
}
BOOL CLogSelectProps::OnKillActive()
{
//call superclass
BOOL bRes=this->CPropertyPage::OnKillActive();
UpdateAppList();
return bRes;
}
void CLogSelectProps::UpdateAppList()
{
if (theApp.m_pLogs != NULL)
delete(theApp.m_pLogs);
theApp.m_pLogs=getList();
}
|