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
|
#include "StdAfx.h"
#include "GlobalFunc.h"
#include "T2Balloon.h"
#include "T2BitImage.h"
#include "T2ImageObj.h"
#include "T2Sprite.h"
#include "../T2TowerDoc.h"
#include "../T2TowerMainView.h"
#include "T2WorldDef.h"
#include "UT2Coordinate.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
T2Balloon::T2Balloon() {
mImage = NULL;
mImageObj = NULL;
mDoPause = false;
}
/*virtual*/ T2Balloon::~T2Balloon() {
if (mDoPause)
GetCurrentT2TowerDoc()->towerDoc_vf290(true);
T2Sprite *theSprite = &GetCurrentT2TowerDoc()->mSprite;
theSprite->ShowSprite(mSpriteID, false);
theSprite->DeleteSprite(mSpriteID);
if (mImage)
delete mImage;
if (mImageObj)
delete mImageObj;
}
#pragma var_order(rect4, rect8, rect5, brush3, rect6, font, theSprite, bits, rect1, save, rect7, dc, rgn, rgn4, rect2, var, brush1, dib, thePalette, topLeft, rect3, brush2)
void T2Balloon::Show(int inX, int inY, const CString& inText, BOOL inDoPause) {
CFont font;
CRect rect1;
CRect rect2;
CRgn rgn;
CRect rect3(0, 0, 0, 0);
mDoPause = inDoPause;
font.CreateFontA(-12, 0, 0, 0, FW_NORMAL, false, false, false, SHIFTJIS_CHARSET, OUT_TT_PRECIS, CLIP_TT_ALWAYS, DRAFT_QUALITY, DEFAULT_PITCH, "\x82\x6C\x82\x72 \x82\x6F\x83\x53\x83\x56\x83\x62\x83\x4E");
CDC dc;
dc.CreateCompatibleDC(NULL);
int save = dc.SaveDC();
dc.SelectObject(font);
rect1.SetRectEmpty();
// 123456789012345
dc.DrawText("\x82\x50\x82\x51\x82\x52\x82\x53\x82\x54\x82\x55\x82\x56\x82\x57\x82\x58\x82\x4F\x82\x50\x82\x51\x82\x52\x82\x53\x82\x54", &rect1, DT_SINGLELINE | DT_CALCRECT);
dc.DrawText(inText, &rect1, DT_WORDBREAK | DT_CALCRECT | DT_NOPREFIX);
rect1.NormalizeRect();
rect1.OffsetRect(-rect1.left, -rect1.top);
rect2.SetRect(10, 10, 10, 10);
rect1.OffsetRect(rect2.left, rect2.top);
CRect rect4;
GetCurrentT2TowerDoc()->GetMainView()->GetVisibleUnitRect(rect4);
UT2Coordinate::UnitToQD(rect4, 0);
CRect rect5;
rect5 = rect1;
rect5 += rect2;
rect5.InflateRect(0, 0, 0, 16);
rect5.NormalizeRect();
rect5.OffsetRect(-rect5.left, -rect5.top);
rect5.OffsetRect(inX, inY - rect5.Height());
int var = 1;
CRect rect6;
if (rect6.SubtractRect(rect5, rect4)) {
rect5 = rect1;
rect5 += rect2;
rect5.InflateRect(0, 0, 0, 16);
rect5.NormalizeRect();
rect5.OffsetRect(-rect5.left, -rect5.top);
rect5.OffsetRect(inX - rect5.Width(), inY - rect5.Height());
var = 0;
if (rect6.SubtractRect(rect5, rect4)) {
rect5 = rect1;
rect5 += rect2;
rect5.InflateRect(0, 0, 0, 16);
rect5.NormalizeRect();
rect5.OffsetRect(-rect5.left, -rect5.top);
rect5.OffsetRect(inX, inY);
var = 3;
if (rect6.SubtractRect(rect5, rect4)) {
rect5 = rect1;
rect5 += rect2;
rect5.InflateRect(0, 0, 0, 16);
rect5.NormalizeRect();
rect5.OffsetRect(-rect5.left, -rect5.top);
rect5.OffsetRect(inX - rect5.Width(), inY);
var = 2;
}
}
}
rect5 += rect3;
POINT topLeft = rect5.TopLeft();
rect5 -= rect3;
rect5.OffsetRect(-rect5.left, -rect5.top);
CRect rect7(1, 1, 1, 1);
rect5 -= rect7;
if (var == 1) {
rgn.CreateRectRgn(0, 0, 1, 1);
CRgn baseRegion;
baseRegion.CreateRoundRectRgn(rect5.left, rect5.top, rect5.right, rect5.bottom - 16, 20, 20);
CRgn arrowRegion;
POINT arrowPoints[3];
arrowPoints[0].x = rect5.left + 10;
arrowPoints[0].y = rect5.bottom - 18;
arrowPoints[1].x = rect5.left;
arrowPoints[1].y = rect5.bottom;
arrowPoints[2].x = rect5.left + 21;
arrowPoints[2].y = rect5.bottom - 18;
arrowRegion.CreatePolygonRgn(arrowPoints, 3, ALTERNATE);
rgn.CombineRgn(&baseRegion, &arrowRegion, RGN_OR);
} else if (var == 0) {
rgn.CreateRectRgn(0, 0, 1, 1);
CRgn baseRegion;
baseRegion.CreateRoundRectRgn(rect5.left, rect5.top, rect5.right, rect5.bottom - 16, 20, 20);
CRgn arrowRegion;
POINT arrowPoints[3];
arrowPoints[0].x = rect5.right - 10;
arrowPoints[0].y = rect5.bottom - 18;
arrowPoints[1].x = rect5.right;
arrowPoints[1].y = rect5.bottom;
arrowPoints[2].x = rect5.right - 21;
arrowPoints[2].y = rect5.bottom - 18;
arrowRegion.CreatePolygonRgn(arrowPoints, 3, ALTERNATE);
rgn.CombineRgn(&baseRegion, &arrowRegion, RGN_OR);
} else if (var == 3) {
rect1.OffsetRect(0, 16);
rgn.CreateRectRgn(0, 0, 1, 1);
CRgn baseRegion;
baseRegion.CreateRoundRectRgn(rect5.left, rect5.top + 16, rect5.right, rect5.bottom, 20, 20);
CRgn arrowRegion;
POINT arrowPoints[3];
arrowPoints[0].x = rect5.left + 10;
arrowPoints[0].y = rect5.top + 18;
arrowPoints[1].x = rect5.left;
arrowPoints[1].y = rect5.top;
arrowPoints[2].x = rect5.left + 21;
arrowPoints[2].y = rect5.top + 18;
arrowRegion.CreatePolygonRgn(arrowPoints, 3, ALTERNATE);
rgn.CombineRgn(&baseRegion, &arrowRegion, RGN_OR);
} else if (var == 2) {
rect1.OffsetRect(0, 16);
rgn.CreateRectRgn(0, 0, 1, 1);
CRgn baseRegion;
baseRegion.CreateRoundRectRgn(rect5.left, rect5.top + 16, rect5.right, rect5.bottom, 20, 20);
CRgn arrowRegion;
POINT arrowPoints[3];
arrowPoints[0].x = rect5.right - 10;
arrowPoints[0].y = rect5.top + 18;
arrowPoints[1].x = rect5.right;
arrowPoints[1].y = rect5.top;
arrowPoints[2].x = rect5.right - 21;
arrowPoints[2].y = rect5.top + 18;
arrowRegion.CreatePolygonRgn(arrowPoints, 3, ALTERNATE);
rgn.CombineRgn(&baseRegion, &arrowRegion, RGN_OR);
} else {
rgn.CreateRoundRectRgn(rect5.left, rect5.top, rect5.right, rect5.bottom, 20, 20);
}
CRgn rgn4;
rgn4.CreateRectRgn(0, 0, 1, 1);
rgn4.CopyRgn(&rgn);
rgn4.OffsetRgn(rect3.left, rect3.top);
CRect rect8;
rect8.top = 0;
rect8.left = 0;
rect8.bottom = ((rect5.Height() + 3) / 4) * 4;
rect8.right = ((rect5.Width() + 3) / 4) * 4;
#line 201
mImage = new T2BitImage(rect8);
mImage->Clear(0);
CPalette *thePalette = GetCurrentT2TowerDoc()->GetWorldDef()->GetPalette();
dc.SelectPalette(thePalette, false);
dc.RealizePalette();
mImage->mBitmap.header.biHeight = -mImage->mBitmap.header.biHeight;
void *bits;
HBITMAP dib = CreateDIBSection(dc.m_hDC, (BITMAPINFO *) &mImage->mBitmap.header, DIB_PAL_COLORS, &bits, NULL, 0);
mImage->mBitmap.header.biHeight = -mImage->mBitmap.header.biHeight;
dc.SelectObject(dib);
CBrush brush1;
CBrush brush2;
CBrush brush3;
brush3.CreateSolidBrush(PALETTEINDEX(0));
brush1.CreateSolidBrush(PALETTEINDEX(255));
brush2.CreateSolidBrush(PALETTEINDEX(1));
dc.FillRect(rect8, &brush3);
dc.FillRgn(&rgn, &brush2);
dc.FrameRgn(&rgn, &brush1, 2, 2);
dc.SetBkMode(TRANSPARENT);
dc.SetTextColor(PALETTEINDEX(255));
dc.SelectObject(font);
dc.DrawText(inText, &rect1, DT_WORDBREAK | DT_NOPREFIX);
dc.RestoreDC(save);
memcpy(mImage->mData, bits, mImage->mBitmap.header.biSizeImage);
DeleteObject(dib);
#line 233
mImageObj = new T2ImageObj;
mImageObj->AddObject("BAL", 0, *mImage, rect8, true, false);
T2Sprite *theSprite = &GetCurrentT2TowerDoc()->mSprite;
mSpriteID = theSprite->NewSprite(*mImageObj, "BAL", T2Sprite::ELayer_6);
theSprite->MoveSprite(mSpriteID, POINT(topLeft));
theSprite->ShowSprite(mSpriteID, true);
if (mDoPause)
GetCurrentT2TowerDoc()->towerDoc_vf290(true);
mEndTime = GetTickCount() + 1500;
}
|