/
menu.zs
361 lines (311 loc) · 14.6 KB
/
menu.zs
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
//-------------------------------------------------------------------------
/*
Copyright (C) 1996, 2003 - 3D Realms Entertainment
Copyright (C) 2020-2021 Christoph Oelckers
This file is part of Raze.
Duke Nukem 3D 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 2
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
aint with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Original Source: 1996 - Todd Replogle
Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms
( not much left of the original code, though... ;) )
*/
//-------------------------------------------------------------------------
class DukeMenuDelegate : RazeMenuDelegate
{
override int DrawCaption(String title, Font fnt, int y, bool drawit)
{
let font = Raze.PickBigFont(); // this ignores the passed font intentionally.
let texid = TexMan.CheckForTexture("MENUBAR");
let texsize = TexMan.GetScaledSize(texid);
let fonth = font.GetGlyphHeight("A");
if (drawit)
{
double scalex = (gameinfo.gameType & GAMEFLAG_RRALL)? 0.4 : 1.;
double width = font.StringWidth(title);
double scaley = scalex;
if (texid.isValid())
{
screen.DrawTexture(texid, false, 160, 19, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_CenterOffsetRel, true, DTA_Color, 0xff808080);
if (texsize.X - 30 < width * scalex) scalex = (texsize.X - 30) / (width); // Squash the text if it doesn't fit.
}
screen.DrawText(font, Font.CR_UNTRANSLATED, 160 - width / 2 * scalex, 19 - fonth / 2 * scaley, title, DTA_ScaleX, scalex, DTA_ScaleY, scaley, DTA_FullscreenScale, FSMode_Fit320x200Top);
}
double fx, fy, fw, fh;
[fx, fy, fw, fh] = Screen.GetFullscreenRect(320, 200, FSMode_ScaleToFit43Top);
int h = texid.isValid() && texsize.Y < 40? texsize.Y : fonth;
return int((y+h) * fh / 200); // This must be the covered height of the header in true pixels.
}
//----------------------------------------------------------------------------
//
//
//
//----------------------------------------------------------------------------
void DrawCursor(double x, double y, double scale, bool right)
{
uint mclock = uint(MSTimeF() * (120. / 1000.));
uint frames = (gameinfo.gametype & GAMEFLAG_RRALL) ? 16 : 7;
String picname;
if (!right) picname= String.Format("SPINNINGNUKEICON%d", ((mclock >> 3) % frames));
else picname = String.Format("SPINNINGNUKEICON%d", frames - 1 - ((frames - 1 + (mclock >> 3)) % frames));
int light = 231 + ((Raze.bsin(mclock<<5) * 3) >> 11);
let pe = color(255, light, light, light);
Screen.DrawTexture(TexMan.CheckForTexture(picname), false, x, y, DTA_FullscreenScale, FSMode_Fit320x200, DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, DTA_CenterOffsetRel, true);
}
override bool DrawSelector(ListMenuDescriptor desc)
{
int cursorOffset = 110;
double cursorScale = (gameinfo.gametype & GAMEFLAG_RRALL) ? 0.2 : 1.0;
double ymid = desc.mItems[desc.mSelectedItem].GetY() + 7; // half height must be hardcoded or layouts will break.
DrawCursor(160 + cursorOffset, ymid, cursorScale, false);
DrawCursor(160 - cursorOffset, ymid, cursorScale, true);
return true;
}
//----------------------------------------------------------------------------
//
// not used for any localized content.
//
//----------------------------------------------------------------------------
static void shadowminitext(int xx, int yy, String t, int p)
{
double x = xx / 65536.;
double y = yy / 65536.;
Screen.DrawText(SmallFont2, Font.CR_UNTRANSLATED, x + 1, y + 1, t, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Color, 0xff000000, DTA_Alpha, 0.5);
Screen.DrawText(SmallFont2, Font.CR_NATIVEPAL, x, y, t, DTA_FullscreenScale, FSMode_Fit320x200, DTA_TranslationIndex, TRANSLATION.MakeID(Translation_Remap, p));
}
static void mgametextcenter(int xx, int yy, String t)
{
double x = xx / 65536. + 160. - SmallFont.StringWidth(t) * 0.5;
double y = yy / 65536.;
Screen.DrawText(SmallFont, Font.CR_UNTRANSLATED, x, y + 2, t, DTA_FullscreenScale, FSMode_Fit320x200);
}
}
//----------------------------------------------------------------------------
//
// Logo
//
//----------------------------------------------------------------------------
class ListMenuItemDukeLogo : ListMenuItem
{
const x = 160;
void Init(ListMenuDescriptor desc)
{
Super.Init(0, 0);
}
override void Draw(bool selected, ListMenuDescriptor desc)
{
if (gameinfo.gametype & GAMEFLAG_RRRA)
{
Screen.DrawTexture(TexMan.CheckForTexture("THREEDEE"), false, x-5, 57, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_ScaleX, 0.253, DTA_ScaleY, 0.253, DTA_CenterOffsetRel, true);
}
else if (gameinfo.gametype & GAMEFLAG_RR)
{
Screen.DrawTexture(TexMan.CheckForTexture("INGAMEDUKETHREEDEE"), false, x+5, 24, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_ScaleX, 0.36, DTA_ScaleY, 0.36, DTA_CenterOffsetRel, true);
}
else
{
Screen.DrawTexture(TexMan.CheckForTexture("INGAMEDUKETHREEDEE"), false, x, 29, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_CenterOffsetRel, true);
if (gameinfo.gametype & GAMEFLAG_PLUTOPAK)
{
let mclock = MSTimeF() * 120 / 1000;
int light = 223 + Raze.bsin(mclock * 16, -9);
let pe = Color(255, light, light, light);
Screen.DrawTexture(TexMan.CheckForTexture("MENUPLUTOPAKSPRITE"), false, x + 100, 36, DTA_FullscreenScale, FSMode_Fit320x200Top, DTA_Color, pe, DTA_CenterOffsetRel, true);
}
}
}
}
//----------------------------------------------------------------------------
//
// text item
//
//----------------------------------------------------------------------------
class ListMenuItemDukeTextItem : ListMenuItemTextItem
{
void Init(ListMenuDescriptor desc, String text, String hotkey, Name child, int param = 0)
{
Super.Init(desc, text, hotkey, child, param);
mColorSelected = 0;
}
void InitDirect(double x, double y, int height, String hotkey, String text, Font font, int color, int color2, Name child, int param = 0)
{
Super.InitDirect(x, y, height, hotkey, text, font, color, color2, child, param);
}
override void Draw(bool selected, ListMenuDescriptor desc)
{
let font = Raze.PickBigFont();
int trans = mColorSelected? Translation.MakeID(Translation_Remap, 1) : 0;
Color pe;
double scale = (gameinfo.gametype & GAMEFLAG_RRALL) ? 0.4 : 1.;
let xpos = 160 - font.StringWidth(mText) * scale * 0.5;
if (selected)
{
let mclock = MSTimeF() * 120 / 1000;
int light = 231 + ((Raze.bsin(mclock * 32) * 3) >> 11);
pe = Color(255, light, light, light);
}
else
{
pe = Color(255, 160, 160, 160);
}
// Palette 0 may not use NATIVEPAL so that substitution remaps work.
Screen.DrawText(font, trans? Font.CR_NATIVEPAL : Font.CR_UNTRANSLATED, xpos, mYpos, mText, DTA_FullscreenScale, FSMode_Fit320x200,
DTA_ScaleX, scale, DTA_ScaleY, scale, DTA_Color, pe, DTA_TranslationIndex, trans);
}
}
//----------------------------------------------------------------------------
//
// Credits for Duke 1.3
//
//----------------------------------------------------------------------------
class ImageScrollerPageDukeCredits1 : ImageScrollerPage
{
void Init(ImageScrollerDescriptor desc)
{
Super.Init();
}
override void Drawer(bool selected)
{
int m, l;
Screen.DrawTexture(TexMan.CheckForTexture("MENUSCREEN"), false, 160, 100, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Color, 0xff808080, DTA_CenterOffset, true);
m = (20 << 16);
l = (33 << 16);
DukeMenuDelegate.shadowminitext(m, l, "Original Concept", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Todd Replogle and Allen H. Blum III", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Produced & Directed By", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Greg Malone", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Executive Producer", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "George Broussard", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "BUILD Engine", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Ken Silverman", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Game Programming", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Todd Replogle", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "3D Engine/Tools/Net", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Ken Silverman", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Network Layer/Setup Program", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Mark Dochtermann", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Map Design", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Allen H. Blum III", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Richard Gray", 12); l += 7 << 16;
m = (180 << 16);
l = (33 << 16);
DukeMenuDelegate.shadowminitext(m, l, "3D Modeling", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Chuck Jones", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Sapphire Corporation", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Artwork", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Dirk Jones, Stephen Hornback", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "James Storey, David Demaret", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Douglas R. Wood", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Sound Engine", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Jim Dose", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Sound & Music Development", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Robert Prince", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Lee Jackson", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Voice Talent", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Lani Minella - Voice Producer", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Jon St. John as \"Duke Nukem\"", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Graphic Design", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Packaging, Manual, Ads", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Robert M. Atkins", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Michael Hadwin", 12); l += 7 << 16;
}
}
class ImageScrollerPageDukeCredits2 : ImageScrollerPage
{
void Init(ImageScrollerDescriptor desc)
{
Super.Init();
}
override void Drawer(bool selected)
{
int m, l;
Screen.DrawTexture(TexMan.CheckForTexture("MENUSCREEN"), false, 160, 100, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Color, 0xff808080, DTA_CenterOffset, true);
m = (20 << 16);
l = (33 << 16);
DukeMenuDelegate.shadowminitext(m, l, "Special Thanks To", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Steven Blackburn, Tom Hall", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Scott Miller, Joe Siegler", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Terry Nagy, Colleen Compton", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "HASH, Inc., FormGen, Inc.", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "The 3D Realms Beta Testers", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Nathan Anderson, Wayne Benner", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Glenn Brensinger, Rob Brown", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Erik Harris, Ken Heckbert", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Terry Herrin, Greg Hively", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Hank Leukart, Eric Baker", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Jeff Rausch, Kelly Rogers", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Mike Duncan, Doug Howell", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Bill Blair", 12); l += 7 << 16;
m = (160 << 16);
l = (33 << 16);
DukeMenuDelegate.shadowminitext(m, l, "Company Product Support", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "The following companies were cool", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "enough to give us lots of stuff", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "during the making of Duke Nukem 3D.", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Altec Lansing Multimedia", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "for tons of speakers and the", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "THX-licensed sound system.", 12); l += 7 << 16;
DukeMenuDelegate.shadowminitext(m, l, "For info call 1-800-548-0620", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Creative Labs, Inc.", 12); l += 7 << 16;
l += 3 << 16;
DukeMenuDelegate.shadowminitext(m, l, "Thanks for the hardware, guys.", 12); l += 7 << 16;
}
}
class ImageScrollerPageDukeCredits3 : ImageScrollerPage
{
void Init(ImageScrollerDescriptor desc)
{
Super.Init();
}
override void Drawer(bool selected)
{
let VOLUMEONE = gameinfo.gametype & GAMEFLAG_SHAREWARE;
int m, l;
Screen.DrawTexture(TexMan.CheckForTexture("MENUSCREEN"), false, 160, 100, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Color, 0xff808080, DTA_CenterOffset, true);
DukeMenuDelegate.mgametextcenter(0, (50 << 16), "Duke Nukem 3D is a trademark of");
DukeMenuDelegate.mgametextcenter(0, (59 << 16), "3D Realms Entertainment");
DukeMenuDelegate.mgametextcenter(0, (77 << 16), "Duke Nukem 3D");
DukeMenuDelegate.mgametextcenter(0, (86 << 16), "(C) 1996 3D Realms Entertainment");
if (VOLUMEONE)
{
DukeMenuDelegate.mgametextcenter(0, (106 << 16), "Please read LICENSE.DOC for shareware");
DukeMenuDelegate.mgametextcenter(0, (115 << 16), "distribution grants and restrictions.");
}
DukeMenuDelegate.mgametextcenter(0, ((VOLUMEONE ? 134 : 115) << 16), "Made in Dallas, Texas USA");
}
}
class PlayerMenu : OptionMenu
{
override void Drawer()
{
// Hack: The team item is #3. This part doesn't work properly yet.
DrawPlayerSprite((mDesc.mSelectedItem == 3));
Super.Drawer();
}
native static void DrawPlayerSprite(int sel);
}