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.
@@ -3864,9 +3864,18 @@ function createCGameImport(imports, state) {
3864
3864
  },
3865
3865
  // Cvars
3866
3866
  cvar: (name, value, flags) => {
3867
- const existing = imports.host?.cvars?.get(name);
3868
- if (existing) return existing;
3869
- return null;
3867
+ if (!imports.host || !imports.host.cvars) {
3868
+ return null;
3869
+ }
3870
+ const existing = imports.host.cvars.get(name);
3871
+ if (existing) {
3872
+ return existing;
3873
+ }
3874
+ return imports.host.cvars.register({
3875
+ name,
3876
+ defaultValue: value,
3877
+ flags
3878
+ });
3870
3879
  },
3871
3880
  cvar_set: (name, value) => {
3872
3881
  imports.host?.cvars?.setValue(name, value);
@@ -4146,32 +4155,6 @@ var Init_Hud = async (renderer, assets) => {
4146
4155
  await Init_Damage(renderer, assets);
4147
4156
  };
4148
4157
 
4149
- // src/hud/subtitles.ts
4150
- var SUBTITLE_DURATION = 3e3;
4151
- var SubtitleSystem = class {
4152
- constructor() {
4153
- this.subtitle = null;
4154
- }
4155
- addSubtitle(text, now) {
4156
- this.subtitle = {
4157
- text,
4158
- startTime: now,
4159
- duration: SUBTITLE_DURATION
4160
- };
4161
- }
4162
- drawSubtitles(renderer, now) {
4163
- if (!this.subtitle) {
4164
- return;
4165
- }
4166
- if (now > this.subtitle.startTime + this.subtitle.duration) {
4167
- this.subtitle = null;
4168
- return;
4169
- }
4170
- const y = renderer.height - 40;
4171
- renderer.drawCenterString(y, this.subtitle.text);
4172
- }
4173
- };
4174
-
4175
4158
  // src/demo/handler.ts
4176
4159
  import { defaultPredictionState, interpolatePredictionState } from "@quake2ts/cgame";
4177
4160
 
@@ -6015,7 +5998,6 @@ function buildRenderableEntities(latestEntities, previousEntities, alpha, config
6015
5998
  function createClient(imports) {
6016
5999
  const prediction = new ClientPrediction(imports.engine.trace);
6017
6000
  const view = new ViewEffects();
6018
- const subtitleSystem = new SubtitleSystem();
6019
6001
  const demoPlayback = new DemoPlaybackController();
6020
6002
  const demoHandler = new ClientNetworkHandler(imports);
6021
6003
  const menuSystem = new MenuSystem();
@@ -6366,7 +6348,6 @@ function createClient(imports) {
6366
6348
  // playernum
6367
6349
  playerState
6368
6350
  );
6369
- subtitleSystem.drawSubtitles(renderer, timeMs);
6370
6351
  renderer.end2D();
6371
6352
  }
6372
6353
  if (menuSystem.isActive()) {
@@ -6417,8 +6398,7 @@ function createClient(imports) {
6417
6398
  cg.NotifyMessage(0, msg, false);
6418
6399
  },
6419
6400
  showSubtitle(text, soundName) {
6420
- const timeMs = latestFrame?.timeMs ?? 0;
6421
- subtitleSystem.addSubtitle(text, timeMs);
6401
+ cg.ShowSubtitle(text, soundName);
6422
6402
  },
6423
6403
  ParseConfigString(index, value) {
6424
6404
  configStrings.set(index, value);