quake2ts 0.0.211 → 0.0.212

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -190,6 +190,32 @@ var MessageSystem = class {
190
190
  }
191
191
  };
192
192
 
193
+ // src/hud/subtitles.ts
194
+ var SUBTITLE_DURATION = 3e3;
195
+ var SubtitleSystem = class {
196
+ constructor() {
197
+ this.subtitle = null;
198
+ }
199
+ addSubtitle(text, now) {
200
+ this.subtitle = {
201
+ text,
202
+ startTime: now,
203
+ duration: SUBTITLE_DURATION
204
+ };
205
+ }
206
+ drawSubtitles(cgi3, now) {
207
+ if (!this.subtitle) {
208
+ return;
209
+ }
210
+ if (now > this.subtitle.startTime + this.subtitle.duration) {
211
+ this.subtitle = null;
212
+ return;
213
+ }
214
+ const y = 200;
215
+ cgi3.SCR_DrawCenterString(y, this.subtitle.text);
216
+ }
217
+ };
218
+
193
219
  // src/hud/blends.ts
194
220
  var Draw_Blends = (cgi3, ps, width, height) => {
195
221
  if (!ps.blend) return;
@@ -301,6 +327,7 @@ var cgi = null;
301
327
  var hudNumberPics = [];
302
328
  var numberWidth = 0;
303
329
  var messageSystem = new MessageSystem();
330
+ var subtitleSystem = new SubtitleSystem();
304
331
  function CG_InitScreen(imports) {
305
332
  cgi = imports;
306
333
  }
@@ -345,11 +372,15 @@ function CG_DrawHUD(isplit, data, hud_vrect, hud_safe, scale2, playernum, ps) {
345
372
  }
346
373
  messageSystem.drawCenterPrint(cgi, timeMs, layout);
347
374
  messageSystem.drawNotifications(cgi, timeMs);
375
+ subtitleSystem.drawSubtitles(cgi, timeMs);
348
376
  Draw_Crosshair(cgi, hud_vrect.width, hud_vrect.height);
349
377
  }
350
378
  function CG_GetMessageSystem() {
351
379
  return messageSystem;
352
380
  }
381
+ function CG_GetSubtitleSystem() {
382
+ return subtitleSystem;
383
+ }
353
384
  function CG_ParseConfigString(cgi3, i, s) {
354
385
  if (i >= ConfigStringIndex.Models && i < ConfigStringIndex.Models + MAX_MODELS) {
355
386
  cgi3.RegisterModel(s);
@@ -1144,6 +1175,11 @@ function ClearCenterprint(isplit) {
1144
1175
  const messageSystem2 = CG_GetMessageSystem();
1145
1176
  messageSystem2.clearCenterPrint();
1146
1177
  }
1178
+ function ShowSubtitle(text, soundName) {
1179
+ if (!cgi2) return;
1180
+ const subtitleSystem2 = CG_GetSubtitleSystem();
1181
+ subtitleSystem2.addSubtitle(text, cgi2.CL_ClientTime());
1182
+ }
1147
1183
  function GetMonsterFlashOffset(id) {
1148
1184
  return { x: 0, y: 0, z: 0 };
1149
1185
  }
@@ -1174,6 +1210,7 @@ function GetCGameAPI(imports) {
1174
1210
  ParseConfigString,
1175
1211
  ParseCenterPrint,
1176
1212
  NotifyMessage,
1213
+ ShowSubtitle,
1177
1214
  // State management
1178
1215
  ClearNotify,
1179
1216
  ClearCenterprint,