File: D3Splash.cpp

package info (click to toggle)
descent3 1.5.0%2Bds-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 35,256 kB
  • sloc: cpp: 416,147; ansic: 3,233; sh: 10; makefile: 8
file content (156 lines) | stat: -rw-r--r-- 3,941 bytes parent folder | download | duplicates (3)
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
/*
 * Descent 3
 * Copyright (C) 2024 Parallax Software
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// D3Splash.cpp : implementation file
//

#include "stdafx.h"
#include "editor.h"
#include "D3Splash.h"

#include <stdarg.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

const int SPLASHTEXT_LEFT = 10;
const int SPLASHTEXT_TOP = 180;
const int SPLASHTEXT_RIGHT = 310;
const int SPLASHTEXT_BOTTOM = 230;

CD3Splash *D3_splash_screen;

/////////////////////////////////////////////////////////////////////////////
// CD3Splash dialog

CD3Splash::CD3Splash(CWnd *pParent /*=NULL*/) : CDialog(CD3Splash::IDD, pParent) {
  //{{AFX_DATA_INIT(CD3Splash)
  // NOTE: the ClassWizard will add member initialization here
  //}}AFX_DATA_INIT

  m_ParentWnd = pParent;
}

void CD3Splash::DoDataExchange(CDataExchange *pDX) {
  CDialog::DoDataExchange(pDX);
  //{{AFX_DATA_MAP(CD3Splash)
  // NOTE: the ClassWizard will add DDX and DDV calls here
  //}}AFX_DATA_MAP
}

BOOL CD3Splash::Create() {
  m_TextLines[0][0] = 0;
  m_TextLines[1][0] = 0;
  m_TextLines[2][0] = 0;
  m_CurLine = 0;

  D3_splash_screen = this;

  m_SplashBmp.LoadBitmap(IDB_D3SPLASH);

  return CDialog::Create(CD3Splash::IDD, m_ParentWnd);
}

void CD3Splash::PutText(char *buf) {
  RECT rect;

  if (m_CurLine == 3) {
    for (int i = 0; i < 2; i++)
      lstrcpy(&m_TextLines[i][0], &m_TextLines[i + 1][0]);
  } else
    m_CurLine++;

  lstrcpy(&m_TextLines[m_CurLine - 1][0], buf);

  //	mprintf(1, "%d:%s",m_CurLine-1, m_TextLines[m_CurLine-1]);

  SetRect(&rect, SPLASHTEXT_LEFT, SPLASHTEXT_TOP, SPLASHTEXT_RIGHT, SPLASHTEXT_BOTTOM);
  InvalidateRect(&rect, FALSE);
  UpdateWindow();
}

BEGIN_MESSAGE_MAP(CD3Splash, CDialog)
//{{AFX_MSG_MAP(CD3Splash)
ON_WM_PAINT()
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CD3Splash message handlers

void CD3Splash::OnCancel() {
  //	Absolutely nothing
}

void CD3Splash::OnOK() {
  //	Absolutely nothing
}

void CD3Splash::PostNcDestroy() {
  //	needed for modeless dialogs
  delete this;
}

void CD3Splash::OnPaint() {
  CPaintDC dc(this); // device context for painting
  CDC sdc;           // source dc
  CBitmap *bmp;
  CFont *fnt;
  CSize textdim;
  BITMAP bm;
  RECT uprect;
  int x, y;

  GetClientRect(&uprect);

  m_SplashBmp.GetObject(sizeof(bm), &bm);

  sdc.CreateCompatibleDC(NULL);
  bmp = sdc.SelectObject(&m_SplashBmp);
  dc.StretchBlt(uprect.left + 1, uprect.top + 1, uprect.right - uprect.left - 2, uprect.bottom - uprect.top - 2, &sdc,
                0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
  sdc.SelectObject(bmp);

  fnt = dc.SelectObject(GetFont());
  dc.SetBkMode(TRANSPARENT);
  dc.SetTextColor(RGB(255, 255, 255));

  textdim = dc.GetTextExtent(&m_TextLines[0][0], lstrlen(m_TextLines[0]));

  y = uprect.bottom - (4 * (textdim.cy + 2));

  for (int r = 0; r < 3; r++) {
    if (lstrlen(m_TextLines[r])) {
      textdim = dc.GetTextExtent(&m_TextLines[r][0], lstrlen(m_TextLines[r]));
      x = ((uprect.right - uprect.left) - textdim.cx) / 2;
      dc.TextOut(x, y, &m_TextLines[r][0], lstrlen(m_TextLines[r]));
      y += textdim.cy + 2;
    }
  }
  dc.SelectObject(fnt);
}

void CD3Splash::OnDestroy() {
  CDialog::OnDestroy();

  D3_splash_screen = NULL;
}