-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCredits.cpp
More file actions
439 lines (369 loc) · 11.2 KB
/
Copy pathCredits.cpp
File metadata and controls
439 lines (369 loc) · 11.2 KB
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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
//**************************************************************************
// credits.cpp : implementation file
//**************************************************************************
#include "stdafx.h"
#include "resource.h"
#include "resrc1.h"
#include "credits.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
#define SCROLLAMOUNT -1
#define DISPLAY_SLOW 70
#define DISPLAY_MEDIUM 40
#define DISPLAY_FAST 10
#define DISPLAY_SPEED DISPLAY_MEDIUM
#define RED RGB(255,0,0)
#define GREEN RGB(0,255,0)
#define BLUE RGB(0,0,255)
#define WHITE RGB(255,255,255)
#define YELLOW RGB(255,255,0)
#define TURQUOISE RGB(0,255,255)
#define PURPLE RGB(255,0,255)
#define BLACK RGB(0,0,0)
#define BACKGROUND_COLOR BLACK
#define TOP_LEVEL_TITLE_COLOR RED
#define TOP_LEVEL_GROUP_COLOR YELLOW
#define GROUP_TITLE_COLOR TURQUOISE
#define NORMAL_TEXT_COLOR WHITE
// You can set font heights here to suit your taste
#define TOP_LEVEL_TITLE_HEIGHT 21
#define TOP_LEVEL_GROUP_HEIGHT 19
#define GROUP_TITLE_HEIGHT 17
#define NORMAL_TEXT_HEIGHT 15
// these define the escape sequences to suffix each array line with. They
// are listed in order of descending font size.
#define TOP_LEVEL_TITLE '\n'
#define TOP_LEVEL_GROUP '\r'
#define GROUP_TITLE '\t'
#define NORMAL_TEXT '\f'
#define DISPLAY_BITMAP '\b'
// Enter the text and bitmap resource string identifiers which are to
// appear in the scrolling list. Append each non-empty string entry with
// an escape character corresponding to the desired font effect. Empty
// strings do not get a font assignment.
// (see #defines above)
//
// Array count. Make sure this keeps up with how many lines there are
// in the array!
#define ARRAYCOUNT 93
char *pArrCredit[] = { "PAINT 2000\n",
"",
"Copyright (c) 2000\f",
"MB Software\f",
"All Rights Reserved\f",
"",
"Beta Testing\t",
"",
"Rodito D. Buan\t",
"Thanks Dad!\f",
"",
"Project Lead\t",
"",
"Rodito M. Buan II\f",
"",
"Technical Lead\t",
"",
"Rodito M. Buan II\f",
"",
"Engineering Lead\t",
"",
"Rodito M. Buan II\f",
"",
"QA \t",
"",
"Rodito M. Buan II\f",
"",
"",
"Documentation \t",
"",
"Rodito M. Buan II\f",
"",
"",
"Systems Support \t",
"",
"Rodito M. Buan II\f",
"",
"",
"Administrative Support \t",
"",
"Rodito M. Buan II\f",
"",
"",
"* * * * * * * * * \t",
"",
"",
"Project Manager \t",
"",
"Rodito M. Buan II\f",
"",
"",
"Engineering \t",
"",
"Rodito M. Buan II\f",
"",
"",
"Quality Assurance \t",
"",
"Rodito M. Buan II\f",
"",
"",
};
/////////////////////////////////////////////////////////////////////////////
// CCredits dialog
CCredits::CCredits(CWnd* pParent) : CDialog(IDD_DISPLAY, pParent)
{
}
void CCredits::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CCredits, CDialog)
ON_WM_PAINT()
ON_WM_TIMER()
ON_WM_DESTROY()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCredits message handlers
void CCredits::OnOK()
{
KillTimer(DISPLAY_TIMER_ID);
CDialog::OnOK();
}
//************************************************************************
// InitDialog
//
// Setup the display rect and start the timer.
//************************************************************************
BOOL CCredits::OnInitDialog()
{
CDialog::OnInitDialog();
BOOL bRet;
UINT nRet;
nCurrentFontHeight = NORMAL_TEXT_HEIGHT;
CClientDC dc(this);
bRet = m_dcMem.CreateCompatibleDC(&dc);
m_bProcessingBitmap=FALSE;
nArrIndex=0;
nCounter=1;
nClip=0;
m_bFirstTime=TRUE;
m_bDrawText=FALSE;
m_hBmpOld = 0;
m_pDisplayFrame=(CWnd*)GetDlgItem(IDC_DISPLAY_STATIC);
// If you assert here, you did not assign your static display control
// the IDC_ value that was used in the GetDlgItem(...). This is the
// control that will display the credits.
_ASSERTE(m_pDisplayFrame);
m_pDisplayFrame->GetClientRect(&m_ScrollRect);
nRet = SetTimer(DISPLAY_TIMER_ID,DISPLAY_SPEED,NULL);
_ASSERTE(nRet != 0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//************************************************************************
// OnTimer
//
// On each of the display timers, scroll the window 1 unit. Each 20
// units, fetch the next array element and load into work string. Call
// Invalidate and UpdateWindow to invoke the OnPaint which will paint
// the contents of the newly updated work string.
//************************************************************************
void CCredits::OnTimer(UINT nIDEvent)
{
if (nIDEvent != DISPLAY_TIMER_ID)
{
CDialog::OnTimer(nIDEvent);
return;
}
if (!m_bProcessingBitmap)
if (nCounter++ % nCurrentFontHeight == 0) // every x timer events, show new line
{
nCounter=1;
m_szWork = pArrCredit[nArrIndex++];
if (nArrIndex > ARRAYCOUNT-1)
nArrIndex=0;
nClip = 0;
m_bDrawText=TRUE;
}
m_pDisplayFrame->ScrollWindow(0,SCROLLAMOUNT,&m_ScrollRect,&m_ScrollRect);
nClip = nClip + abs(SCROLLAMOUNT);
CRect r;
CWnd* pWnd = GetDlgItem(IDC_DISPLAY_STATIC);
ASSERT_VALID(pWnd);
pWnd->GetClientRect(&r);
pWnd->ClientToScreen(r);
ScreenToClient(&r);
InvalidateRect(r,FALSE); // FALSE does not erase background
CDialog::OnTimer(nIDEvent);
}
//************************************************************************
// OnPaint
//
// Send the newly updated work string to the display rect.
//************************************************************************
void CCredits::OnPaint()
{
CPaintDC dc(this); // device context for painting
PAINTSTRUCT ps;
CDC* pDc = m_pDisplayFrame->BeginPaint(&ps);
pDc->SetBkMode(TRANSPARENT);
//*********************************************************************
// FONT SELECTION
CFont m_fntArial;
CFont* pOldFont;
BOOL bSuccess;
BOOL bUnderline;
BOOL bItalic;
if (!m_szWork.IsEmpty())
switch (m_szWork[m_szWork.GetLength()-1] )
{
case NORMAL_TEXT:
default:
bItalic = FALSE;
bUnderline = FALSE;
nCurrentFontHeight = NORMAL_TEXT_HEIGHT;
bSuccess = m_fntArial.CreateFont(NORMAL_TEXT_HEIGHT, 0, 0, 0,
FW_THIN, bItalic, bUnderline, 0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
VARIABLE_PITCH | 0x04 | FF_DONTCARE,
(LPSTR)"Arial");
pDc->SetTextColor(NORMAL_TEXT_COLOR);
pOldFont = pDc->SelectObject(&m_fntArial);
break;
case TOP_LEVEL_GROUP:
bItalic = FALSE;
bUnderline = FALSE;
nCurrentFontHeight = TOP_LEVEL_GROUP_HEIGHT;
bSuccess = m_fntArial.CreateFont(TOP_LEVEL_GROUP_HEIGHT, 0, 0, 0,
FW_BOLD, bItalic, bUnderline, 0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
VARIABLE_PITCH | 0x04 | FF_DONTCARE,
(LPSTR)"Arial");
pDc->SetTextColor(TOP_LEVEL_GROUP_COLOR);
pOldFont = pDc->SelectObject(&m_fntArial);
break;
case GROUP_TITLE:
bItalic = FALSE;
bUnderline = FALSE;
nCurrentFontHeight = GROUP_TITLE_HEIGHT;
bSuccess = m_fntArial.CreateFont(GROUP_TITLE_HEIGHT, 0, 0, 0,
FW_BOLD, bItalic, bUnderline, 0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
VARIABLE_PITCH | 0x04 | FF_DONTCARE,
(LPSTR)"Arial");
pDc->SetTextColor(GROUP_TITLE_COLOR);
pOldFont = pDc->SelectObject(&m_fntArial);
break;
case TOP_LEVEL_TITLE:
bItalic = FALSE;
bUnderline = TRUE;
nCurrentFontHeight = TOP_LEVEL_TITLE_HEIGHT;
bSuccess = m_fntArial.CreateFont(TOP_LEVEL_TITLE_HEIGHT, 0, 0, 0,
FW_BOLD, bItalic, bUnderline, 0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
PROOF_QUALITY,
VARIABLE_PITCH | 0x04 | FF_DONTCARE,
(LPSTR)"Arial");
pDc->SetTextColor(TOP_LEVEL_TITLE_COLOR);
pOldFont = pDc->SelectObject(&m_fntArial);
break;
case DISPLAY_BITMAP:
if (!m_bProcessingBitmap)
{
CString szBitmap = m_szWork.Left(m_szWork.GetLength()-1);
if (!m_bmpWork.LoadBitmap((const char *)szBitmap))
{
CString str;
str.Format("Could not find bitmap resource \"%s\". "
"Be sure to assign the bitmap a QUOTED resource name", szBitmap);
KillTimer(DISPLAY_TIMER_ID);
MessageBox(str);
return;
}
m_bmpCurrent = &m_bmpWork;
m_bmpCurrent->GetObject(sizeof(BITMAP), &m_bmpInfo);
m_size.cx = m_bmpInfo.bmWidth; // width of dest rect
RECT workRect;
m_pDisplayFrame->GetClientRect(&workRect);
m_pDisplayFrame->ClientToScreen(&workRect);
ScreenToClient(&workRect);
// upper left point of dest
m_pt.x = (workRect.right -
((workRect.right-workRect.left)/2) - (m_bmpInfo.bmWidth/2));
m_pt.y = workRect.bottom;
pBmpOld = m_dcMem.SelectObject(m_bmpCurrent);
if (m_hBmpOld == 0)
m_hBmpOld = (HBITMAP) pBmpOld->GetSafeHandle();
m_bProcessingBitmap = TRUE;
}
break;
}
CBrush bBrush(BLACK);
CBrush* pOldBrush;
pOldBrush = pDc->SelectObject(&bBrush);
// Only fill rect comprised of gap left by bottom of scrolling window
r=m_ScrollRect;
r.top = r.bottom-abs(SCROLLAMOUNT);
pDc->DPtoLP(&r);
if (m_bFirstTime)
{
m_bFirstTime=FALSE;
pDc->FillRect(&m_ScrollRect,&bBrush);
}
else
pDc->FillRect(&r,&bBrush);
r=m_ScrollRect;
r.top = r.bottom-nClip;
if (!m_bProcessingBitmap)
{
int x = pDc->DrawText((const char *)m_szWork,m_szWork.GetLength()-1,&r,DT_TOP|DT_CENTER|
DT_NOPREFIX | DT_SINGLELINE);
m_bDrawText=FALSE;
}
else
{
dc.StretchBlt( m_pt.x, m_pt.y-nClip, m_size.cx, nClip,
&m_dcMem, 0, 0, m_bmpInfo.bmWidth-1, nClip,
SRCCOPY );
if (nClip > m_bmpInfo.bmHeight)
{
m_bmpWork.DeleteObject();
m_bProcessingBitmap = FALSE;
nClip=0;
m_szWork.Empty();
nCounter=1;
}
pDc->SelectObject(pOldBrush);
bBrush.DeleteObject();
m_pDisplayFrame->EndPaint(&ps);
return;
}
pDc->SelectObject(pOldBrush);
bBrush.DeleteObject();
if (!m_szWork.IsEmpty())
{
pDc->SelectObject(pOldFont);
m_fntArial.DeleteObject();
}
m_pDisplayFrame->EndPaint(&ps);
// Do not call CDialog::OnPaint() for painting messages
}
void CCredits::OnDestroy()
{
CDialog::OnDestroy();
m_dcMem.SelectObject(CBitmap::FromHandle(m_hBmpOld));
m_bmpWork.DeleteObject();
}