quake2ts 0.0.211 → 0.0.213

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.
@@ -3895,9 +3895,18 @@ function createCGameImport(imports, state) {
3895
3895
  },
3896
3896
  // Cvars
3897
3897
  cvar: (name, value, flags) => {
3898
- const existing = imports.host?.cvars?.get(name);
3899
- if (existing) return existing;
3900
- return null;
3898
+ if (!imports.host || !imports.host.cvars) {
3899
+ return null;
3900
+ }
3901
+ const existing = imports.host.cvars.get(name);
3902
+ if (existing) {
3903
+ return existing;
3904
+ }
3905
+ return imports.host.cvars.register({
3906
+ name,
3907
+ defaultValue: value,
3908
+ flags
3909
+ });
3901
3910
  },
3902
3911
  cvar_set: (name, value) => {
3903
3912
  imports.host?.cvars?.setValue(name, value);
@@ -4177,32 +4186,6 @@ var Init_Hud = async (renderer, assets) => {
4177
4186
  await Init_Damage(renderer, assets);
4178
4187
  };
4179
4188
 
4180
- // src/hud/subtitles.ts
4181
- var SUBTITLE_DURATION = 3e3;
4182
- var SubtitleSystem = class {
4183
- constructor() {
4184
- this.subtitle = null;
4185
- }
4186
- addSubtitle(text, now) {
4187
- this.subtitle = {
4188
- text,
4189
- startTime: now,
4190
- duration: SUBTITLE_DURATION
4191
- };
4192
- }
4193
- drawSubtitles(renderer, now) {
4194
- if (!this.subtitle) {
4195
- return;
4196
- }
4197
- if (now > this.subtitle.startTime + this.subtitle.duration) {
4198
- this.subtitle = null;
4199
- return;
4200
- }
4201
- const y = renderer.height - 40;
4202
- renderer.drawCenterString(y, this.subtitle.text);
4203
- }
4204
- };
4205
-
4206
4189
  // src/demo/handler.ts
4207
4190
  var import_cgame = require("@quake2ts/cgame");
4208
4191
 
@@ -6043,7 +6026,6 @@ function buildRenderableEntities(latestEntities, previousEntities, alpha, config
6043
6026
  function createClient(imports) {
6044
6027
  const prediction = new import_cgame2.ClientPrediction(imports.engine.trace);
6045
6028
  const view = new import_cgame3.ViewEffects();
6046
- const subtitleSystem = new SubtitleSystem();
6047
6029
  const demoPlayback = new DemoPlaybackController();
6048
6030
  const demoHandler = new ClientNetworkHandler(imports);
6049
6031
  const menuSystem = new MenuSystem();
@@ -6394,7 +6376,6 @@ function createClient(imports) {
6394
6376
  // playernum
6395
6377
  playerState
6396
6378
  );
6397
- subtitleSystem.drawSubtitles(renderer, timeMs);
6398
6379
  renderer.end2D();
6399
6380
  }
6400
6381
  if (menuSystem.isActive()) {
@@ -6445,8 +6426,7 @@ function createClient(imports) {
6445
6426
  cg.NotifyMessage(0, msg, false);
6446
6427
  },
6447
6428
  showSubtitle(text, soundName) {
6448
- const timeMs = latestFrame?.timeMs ?? 0;
6449
- subtitleSystem.addSubtitle(text, timeMs);
6429
+ cg.ShowSubtitle(text, soundName);
6450
6430
  },
6451
6431
  ParseConfigString(index, value) {
6452
6432
  configStrings.set(index, value);