quake2ts 0.0.187 → 0.0.189

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.
Files changed (67) hide show
  1. package/package.json +1 -1
  2. package/packages/cgame/dist/index.cjs +256 -0
  3. package/packages/cgame/dist/index.cjs.map +1 -0
  4. package/packages/cgame/dist/index.d.cts +101 -0
  5. package/packages/cgame/dist/index.d.ts +99 -1
  6. package/packages/cgame/dist/index.js +250 -28
  7. package/packages/cgame/dist/index.js.map +1 -0
  8. package/packages/client/dist/browser/index.global.js +5 -5
  9. package/packages/client/dist/browser/index.global.js.map +1 -1
  10. package/packages/client/dist/cjs/index.cjs +34 -0
  11. package/packages/client/dist/cjs/index.cjs.map +1 -1
  12. package/packages/client/dist/esm/index.js +48 -14
  13. package/packages/client/dist/esm/index.js.map +1 -1
  14. package/packages/client/dist/tsconfig.tsbuildinfo +1 -1
  15. package/packages/engine/dist/browser/index.global.js +9 -9
  16. package/packages/engine/dist/browser/index.global.js.map +1 -1
  17. package/packages/engine/dist/cjs/index.cjs +17 -0
  18. package/packages/engine/dist/cjs/index.cjs.map +1 -1
  19. package/packages/engine/dist/esm/index.js +17 -0
  20. package/packages/engine/dist/esm/index.js.map +1 -1
  21. package/packages/engine/dist/tsconfig.tsbuildinfo +1 -1
  22. package/packages/game/dist/browser/index.global.js +2 -2
  23. package/packages/game/dist/browser/index.global.js.map +1 -1
  24. package/packages/game/dist/cjs/index.cjs +202 -161
  25. package/packages/game/dist/cjs/index.cjs.map +1 -1
  26. package/packages/game/dist/esm/index.js +202 -161
  27. package/packages/game/dist/esm/index.js.map +1 -1
  28. package/packages/game/dist/tsconfig.tsbuildinfo +1 -1
  29. package/packages/game/dist/types/entities/pool.d.ts +1 -0
  30. package/packages/game/dist/types/entities/pool.d.ts.map +1 -1
  31. package/packages/game/dist/types/entities/system.d.ts +2 -1
  32. package/packages/game/dist/types/entities/system.d.ts.map +1 -1
  33. package/packages/game/dist/types/imports.d.ts +1 -0
  34. package/packages/game/dist/types/imports.d.ts.map +1 -1
  35. package/packages/game/dist/types/index.d.ts +1 -1
  36. package/packages/game/dist/types/index.d.ts.map +1 -1
  37. package/packages/game/dist/types/inventory/ammo.d.ts +2 -24
  38. package/packages/game/dist/types/inventory/ammo.d.ts.map +1 -1
  39. package/packages/game/dist/types/inventory/playerInventory.d.ts +2 -47
  40. package/packages/game/dist/types/inventory/playerInventory.d.ts.map +1 -1
  41. package/packages/game/dist/types/physics/collision.d.ts.map +1 -1
  42. package/packages/server/dist/index.cjs +19 -1
  43. package/packages/server/dist/index.d.cts +1 -0
  44. package/packages/server/dist/index.d.ts +1 -0
  45. package/packages/server/dist/index.js +20 -2
  46. package/packages/shared/dist/browser/index.global.js +1 -1
  47. package/packages/shared/dist/browser/index.global.js.map +1 -1
  48. package/packages/shared/dist/cjs/index.cjs +153 -0
  49. package/packages/shared/dist/cjs/index.cjs.map +1 -1
  50. package/packages/shared/dist/esm/index.js +142 -0
  51. package/packages/shared/dist/esm/index.js.map +1 -1
  52. package/packages/shared/dist/tsconfig.tsbuildinfo +1 -1
  53. package/packages/shared/dist/types/index.d.ts +1 -0
  54. package/packages/shared/dist/types/index.d.ts.map +1 -1
  55. package/packages/shared/dist/types/items/ammo.d.ts +33 -0
  56. package/packages/shared/dist/types/items/ammo.d.ts.map +1 -0
  57. package/packages/shared/dist/types/items/index.d.ts +7 -0
  58. package/packages/shared/dist/types/items/index.d.ts.map +1 -0
  59. package/packages/shared/dist/types/items/powerups.d.ts +31 -0
  60. package/packages/shared/dist/types/items/powerups.d.ts.map +1 -0
  61. package/packages/shared/dist/types/items/weapons.d.ts +25 -0
  62. package/packages/shared/dist/types/items/weapons.d.ts.map +1 -0
  63. package/packages/shared/dist/types/protocol/index.d.ts +2 -0
  64. package/packages/shared/dist/types/protocol/index.d.ts.map +1 -1
  65. package/packages/tools/dist/tsconfig.tsbuildinfo +1 -1
  66. package/packages/cgame/dist/index.d.mts +0 -3
  67. package/packages/cgame/dist/index.mjs +0 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "quake2ts",
3
- "version": "0.0.187",
3
+ "version": "0.0.189",
4
4
  "description": "Quake II re-release port to TypeScript with WebGL renderer - A complete game engine with physics, networking, and BSP rendering",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@8.15.7",
@@ -0,0 +1,256 @@
1
+ 'use strict';
2
+
3
+ // src/hud/messages.ts
4
+ var CENTER_PRINT_DURATION = 3e3;
5
+ var NOTIFY_DURATION = 5e3;
6
+ var MAX_NOTIFY_MESSAGES = 4;
7
+ var MessageSystem = class {
8
+ constructor() {
9
+ this.centerPrintMsg = null;
10
+ this.notifyMessages = [];
11
+ }
12
+ addCenterPrint(text, now) {
13
+ this.centerPrintMsg = {
14
+ text,
15
+ startTime: now,
16
+ duration: CENTER_PRINT_DURATION
17
+ };
18
+ }
19
+ addNotify(text, now) {
20
+ this.notifyMessages.push({
21
+ text,
22
+ startTime: now,
23
+ duration: NOTIFY_DURATION
24
+ });
25
+ if (this.notifyMessages.length > MAX_NOTIFY_MESSAGES) {
26
+ this.notifyMessages.shift();
27
+ }
28
+ }
29
+ // Additional methods for cgame API
30
+ setCenterPrint(text, now) {
31
+ this.centerPrintMsg = {
32
+ text,
33
+ startTime: now,
34
+ duration: CENTER_PRINT_DURATION
35
+ };
36
+ }
37
+ addNotification(text, is_chat, now) {
38
+ this.notifyMessages.push({
39
+ text,
40
+ startTime: now,
41
+ duration: NOTIFY_DURATION
42
+ });
43
+ if (this.notifyMessages.length > MAX_NOTIFY_MESSAGES) {
44
+ this.notifyMessages.shift();
45
+ }
46
+ }
47
+ clearNotifications() {
48
+ this.notifyMessages = [];
49
+ }
50
+ clearCenterPrint() {
51
+ this.centerPrintMsg = null;
52
+ }
53
+ drawCenterPrint(renderer, now, layout) {
54
+ if (!this.centerPrintMsg) return;
55
+ if (now > this.centerPrintMsg.startTime + this.centerPrintMsg.duration) {
56
+ this.centerPrintMsg = null;
57
+ return;
58
+ }
59
+ this.centerPrintMsg.text.length * 8;
60
+ const y = layout.CENTER_PRINT_Y;
61
+ renderer.drawCenterString(y, this.centerPrintMsg.text);
62
+ }
63
+ drawNotifications(renderer, now) {
64
+ while (this.notifyMessages.length > 0 && now > this.notifyMessages[0].startTime + this.notifyMessages[0].duration) {
65
+ this.notifyMessages.shift();
66
+ }
67
+ let y = 10;
68
+ for (const msg of this.notifyMessages) {
69
+ renderer.drawString(10, y, msg.text);
70
+ y += 10;
71
+ }
72
+ }
73
+ };
74
+
75
+ // src/hud/layout.ts
76
+ var REFERENCE_WIDTH = 640;
77
+ var REFERENCE_HEIGHT = 480;
78
+ var getHudLayout = (width, height) => {
79
+ const scaleX = width / REFERENCE_WIDTH;
80
+ const scaleY = height / REFERENCE_HEIGHT;
81
+ const scale = Math.min(scaleX, scaleY);
82
+ return {
83
+ // Status bar numbers - Anchored Bottom-Left / Center / Right
84
+ HEALTH_X: 100 * scale,
85
+ HEALTH_Y: height - (REFERENCE_HEIGHT - 450) * scale,
86
+ ARMOR_X: 200 * scale,
87
+ ARMOR_Y: height - (REFERENCE_HEIGHT - 450) * scale,
88
+ AMMO_X: width - (REFERENCE_WIDTH - 540) * scale,
89
+ // Anchor right? 540 is near right (640)
90
+ AMMO_Y: height - (REFERENCE_HEIGHT - 450) * scale,
91
+ // Center print messages - Center
92
+ CENTER_PRINT_X: width / 2,
93
+ CENTER_PRINT_Y: 100 * scale,
94
+ // Top anchor
95
+ // Weapon and powerup icons
96
+ WEAPON_ICON_X: 10 * scale,
97
+ WEAPON_ICON_Y: height - (REFERENCE_HEIGHT - 450) * scale,
98
+ POWERUP_X: width - (REFERENCE_WIDTH - 610) * scale,
99
+ POWERUP_Y: height - (REFERENCE_HEIGHT - 450) * scale,
100
+ scale
101
+ };
102
+ };
103
+
104
+ // src/screen.ts
105
+ var cgi = null;
106
+ var hudNumberPics = [];
107
+ var numberWidth = 0;
108
+ var messageSystem = new MessageSystem();
109
+ function CG_InitScreen(imports) {
110
+ cgi = imports;
111
+ }
112
+ function CG_TouchPics() {
113
+ if (!cgi) return;
114
+ hudNumberPics.length = 0;
115
+ for (let i = 0; i < 10; i++) {
116
+ try {
117
+ const pic = cgi.Draw_RegisterPic(`pics/hud/num_${i}.pcx`);
118
+ hudNumberPics.push(pic);
119
+ if (i === 0) {
120
+ const size = cgi.Draw_GetPicSize(pic);
121
+ numberWidth = size.width;
122
+ }
123
+ } catch (e) {
124
+ cgi.Com_Print(`Warning: Failed to load HUD image: pics/hud/num_${i}.pcx
125
+ `);
126
+ }
127
+ }
128
+ }
129
+ function CG_DrawHUD(isplit, data, hud_vrect, hud_safe, scale, playernum, ps) {
130
+ if (!cgi) {
131
+ console.error("CG_DrawHUD: cgame imports not initialized");
132
+ return;
133
+ }
134
+ cgi.CL_ClientTime();
135
+ getHudLayout(hud_vrect.width, hud_vrect.height);
136
+ if (ps.centerPrint) {
137
+ cgi.SCR_DrawFontString(
138
+ hud_vrect.width / 2,
139
+ hud_vrect.height / 2 - 20,
140
+ ps.centerPrint
141
+ );
142
+ }
143
+ if (ps.notify) {
144
+ cgi.SCR_DrawFontString(8, 8, ps.notify);
145
+ }
146
+ }
147
+ function CG_GetMessageSystem() {
148
+ return messageSystem;
149
+ }
150
+
151
+ // src/index.ts
152
+ var cgi2 = null;
153
+ function Init() {
154
+ if (!cgi2) {
155
+ console.error("CGame Init: cgame imports not set");
156
+ return;
157
+ }
158
+ cgi2.Com_Print("===== CGame Initialization =====\n");
159
+ CG_InitScreen(cgi2);
160
+ cgi2.Com_Print("CGame initialized\n");
161
+ }
162
+ function Shutdown() {
163
+ if (cgi2) {
164
+ cgi2.Com_Print("CGame shutdown\n");
165
+ }
166
+ cgi2 = null;
167
+ }
168
+ function DrawHUD(isplit, data, hud_vrect, hud_safe, scale, playernum, ps) {
169
+ CG_DrawHUD(isplit, data, hud_vrect, hud_safe, scale, playernum, ps);
170
+ }
171
+ function TouchPics() {
172
+ CG_TouchPics();
173
+ }
174
+ function GetLayoutFlags(ps) {
175
+ return 0;
176
+ }
177
+ function GetActiveWeaponWheelWeapon(ps) {
178
+ return 0;
179
+ }
180
+ function GetOwnedWeaponWheelWeapons(ps) {
181
+ return [];
182
+ }
183
+ function GetWeaponWheelAmmoCount(ps, weapon) {
184
+ return 0;
185
+ }
186
+ function GetPowerupWheelCount(ps) {
187
+ return 0;
188
+ }
189
+ function GetHitMarkerDamage(ps) {
190
+ return 0;
191
+ }
192
+ function Pmove(pmove) {
193
+ }
194
+ function ParseConfigString(i, s) {
195
+ }
196
+ function ParseCenterPrint(str, isplit, instant) {
197
+ if (!cgi2) return;
198
+ const messageSystem2 = CG_GetMessageSystem();
199
+ messageSystem2.setCenterPrint(str, cgi2.CL_ClientTime());
200
+ }
201
+ function NotifyMessage(isplit, msg, is_chat) {
202
+ if (!cgi2) return;
203
+ const messageSystem2 = CG_GetMessageSystem();
204
+ messageSystem2.addNotification(msg, is_chat, cgi2.CL_ClientTime());
205
+ }
206
+ function ClearNotify(isplit) {
207
+ const messageSystem2 = CG_GetMessageSystem();
208
+ messageSystem2.clearNotifications();
209
+ }
210
+ function ClearCenterprint(isplit) {
211
+ const messageSystem2 = CG_GetMessageSystem();
212
+ messageSystem2.clearCenterPrint();
213
+ }
214
+ function GetMonsterFlashOffset(id) {
215
+ return { x: 0, y: 0, z: 0 };
216
+ }
217
+ function GetExtension(name) {
218
+ return null;
219
+ }
220
+ function GetCGameAPI(imports) {
221
+ cgi2 = imports;
222
+ return {
223
+ // Lifecycle
224
+ Init,
225
+ Shutdown,
226
+ // Rendering
227
+ DrawHUD,
228
+ TouchPics,
229
+ // Layout
230
+ LayoutFlags: GetLayoutFlags,
231
+ // Weapon wheel
232
+ GetActiveWeaponWheelWeapon,
233
+ GetOwnedWeaponWheelWeapons,
234
+ GetWeaponWheelAmmoCount,
235
+ GetPowerupWheelCount,
236
+ // Hit markers
237
+ GetHitMarkerDamage,
238
+ // Prediction
239
+ Pmove,
240
+ // Parsing
241
+ ParseConfigString,
242
+ ParseCenterPrint,
243
+ NotifyMessage,
244
+ // State management
245
+ ClearNotify,
246
+ ClearCenterprint,
247
+ // Effects
248
+ GetMonsterFlashOffset,
249
+ // Extension
250
+ GetExtension
251
+ };
252
+ }
253
+
254
+ exports.GetCGameAPI = GetCGameAPI;
255
+ //# sourceMappingURL=index.cjs.map
256
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hud/messages.ts","../src/hud/layout.ts","../src/screen.ts","../src/index.ts"],"names":["cgi","messageSystem"],"mappings":";;;AASA,IAAM,qBAAA,GAAwB,GAAA;AAC9B,IAAM,eAAA,GAAkB,GAAA;AACxB,IAAM,mBAAA,GAAsB,CAAA;AAErB,IAAM,gBAAN,MAAoB;AAAA,EAApB,WAAA,GAAA;AACL,IAAA,IAAA,CAAQ,cAAA,GAAiC,IAAA;AACzC,IAAA,IAAA,CAAQ,iBAA4B,EAAC;AAAA,EAAA;AAAA,EAErC,cAAA,CAAe,MAAc,GAAA,EAAa;AACxC,IAAA,IAAA,CAAK,cAAA,GAAiB;AAAA,MACpB,IAAA;AAAA,MACA,SAAA,EAAW,GAAA;AAAA,MACX,QAAA,EAAU;AAAA,KACZ;AAAA,EACF;AAAA,EAEA,SAAA,CAAU,MAAc,GAAA,EAAa;AACnC,IAAA,IAAA,CAAK,eAAe,IAAA,CAAK;AAAA,MACvB,IAAA;AAAA,MACA,SAAA,EAAW,GAAA;AAAA,MACX,QAAA,EAAU;AAAA,KACX,CAAA;AAED,IAAA,IAAI,IAAA,CAAK,cAAA,CAAe,MAAA,GAAS,mBAAA,EAAqB;AACpD,MAAA,IAAA,CAAK,eAAe,KAAA,EAAM;AAAA,IAC5B;AAAA,EACF;AAAA;AAAA,EAGA,cAAA,CAAe,MAAc,GAAA,EAAa;AACxC,IAAA,IAAA,CAAK,cAAA,GAAiB;AAAA,MACpB,IAAA;AAAA,MACA,SAAA,EAAW,GAAA;AAAA,MACX,QAAA,EAAU;AAAA,KAC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AACX;AASO,SAAS,YAAY,OAAA,EAAmC;AAC3D,EAAAD,IAAAA,GAAM,OAAA;AAEN,EAAA,OAAO;AAAA;AAAA,IAEH,IAAA;AAAA,IACA,QAAA;AAAA;AAAA,IAGA,OAAA;AAAA,IACA,SAAA;AAAA;AAAA,IAGA,WAAA,EAAa,cAAA;AAAA;AAAA,IAGb,0BAAA;AAAA,IACA,0BAAA;AAAA,IACA,uBAAA;AAAA,IACA,oBAAA;AAAA;AAAA,IAGA,kBAAA;AAAA;AAAA,IAGA,KAAA;AAAA;AAAA,IAGA,iBAAA;AAAA,IACA,gBAAA;AAAA,IACA,aAAA;AAAA;AAAA,IAGA,WAAA;AAAA,IACA,gBAAA;AAAA;AAAA,IAGA,qBAAA;AAAA;AAAA,IAGA;AAAA,GACJ;AACJ","file":"index.cjs","sourcesContent":["import { Renderer } from '@quake2ts/engine';\nimport { getHudLayout } from './layout.js';\n\ninterface Message {\n text: string;\n startTime: number;\n duration: number;\n}\n\nconst CENTER_PRINT_DURATION = 3000;\nconst NOTIFY_DURATION = 5000;\nconst MAX_NOTIFY_MESSAGES = 4;\n\nexport class MessageSystem {\n private centerPrintMsg: Message | null = null;\n private notifyMessages: Message[] = [];\n\n addCenterPrint(text: string, now: number) {\n this.centerPrintMsg = {\n text,\n startTime: now,\n duration: CENTER_PRINT_DURATION,\n };\n }\n\n addNotify(text: string, now: number) {\n this.notifyMessages.push({\n text,\n startTime: now,\n duration: NOTIFY_DURATION,\n });\n\n if (this.notifyMessages.length > MAX_NOTIFY_MESSAGES) {\n this.notifyMessages.shift();\n }\n }\n\n // Additional methods for cgame API\n setCenterPrint(text: string, now: number) {\n this.centerPrintMsg = {\n text,\n startTime: now,\n duration: CENTER_PRINT_DURATION,\n };\n }\n\n addNotification(text: string, is_chat: boolean, now: number) {\n this.notifyMessages.push({\n text,\n startTime: now,\n duration: NOTIFY_DURATION,\n });\n\n if (this.notifyMessages.length > MAX_NOTIFY_MESSAGES) {\n this.notifyMessages.shift();\n }\n }\n\n clearNotifications() {\n this.notifyMessages = [];\n }\n\n clearCenterPrint() {\n this.centerPrintMsg = null;\n }\n\n drawCenterPrint(renderer: Renderer, now: number, layout: ReturnType<typeof getHudLayout>) {\n if (!this.centerPrintMsg) return;\n\n if (now > this.centerPrintMsg.startTime + this.centerPrintMsg.duration) {\n this.centerPrintMsg = null;\n return;\n }\n\n // Draw centered text\n const width = this.centerPrintMsg.text.length * 8;\n // We ignore layout.CENTER_PRINT_X because drawCenterString calculates X automatically\n const y = layout.CENTER_PRINT_Y;\n\n renderer.drawCenterString(y, this.centerPrintMsg.text);\n }\n\n drawNotifications(renderer: Renderer, now: number) {\n // Remove expired messages\n while (this.notifyMessages.length > 0 && now > this.notifyMessages[0].startTime + this.notifyMessages[0].duration) {\n this.notifyMessages.shift();\n }\n\n let y = 10; // Start near top-left\n for (const msg of this.notifyMessages) {\n renderer.drawString(10, y, msg.text);\n y += 10; // Line height\n }\n }\n}\n","// Dynamic Layout Scaling\nconst REFERENCE_WIDTH = 640;\nconst REFERENCE_HEIGHT = 480;\n\nexport const getHudLayout = (width: number, height: number) => {\n // Determine scale factor - usually based on height to preserve aspect ratio logic or just scale uniform\n // Quake 2 typically scales 2D elements.\n const scaleX = width / REFERENCE_WIDTH;\n const scaleY = height / REFERENCE_HEIGHT;\n const scale = Math.min(scaleX, scaleY); // Uniform scaling\n\n // Or we can just center the 640x480 rect?\n // Modern approach: Scale UI to fit, or anchor to edges.\n // Let's implement edge anchoring logic relative to 640x480 coordinates.\n\n // Original constants (approximate):\n // HEALTH_X: 100, HEALTH_Y: 450\n // ARMOR_X: 200, ARMOR_Y: 450\n // AMMO_X: 540, AMMO_Y: 450\n // CENTER_PRINT: Center screen\n // WEAPON_ICON: Bottom left\n // POWERUP: Bottom right?\n\n // We'll return scaled coordinates.\n // For bottom elements, we should anchor to bottom.\n\n return {\n // Status bar numbers - Anchored Bottom-Left / Center / Right\n HEALTH_X: 100 * scale,\n HEALTH_Y: height - (REFERENCE_HEIGHT - 450) * scale,\n\n ARMOR_X: 200 * scale,\n ARMOR_Y: height - (REFERENCE_HEIGHT - 450) * scale,\n\n AMMO_X: width - (REFERENCE_WIDTH - 540) * scale, // Anchor right? 540 is near right (640)\n AMMO_Y: height - (REFERENCE_HEIGHT - 450) * scale,\n\n // Center print messages - Center\n CENTER_PRINT_X: width / 2,\n CENTER_PRINT_Y: 100 * scale, // Top anchor\n\n // Weapon and powerup icons\n WEAPON_ICON_X: 10 * scale,\n WEAPON_ICON_Y: height - (REFERENCE_HEIGHT - 450) * scale,\n\n POWERUP_X: width - (REFERENCE_WIDTH - 610) * scale,\n POWERUP_Y: height - (REFERENCE_HEIGHT - 450) * scale,\n\n scale: scale\n };\n};\n\n// Backward compatibility (deprecated, but useful for initial refactor)\nexport const HUD_LAYOUT = {\n HEALTH_X: 100,\n HEALTH_Y: 450,\n ARMOR_X: 200,\n ARMOR_Y: 450,\n AMMO_X: 540,\n AMMO_Y: 450,\n CENTER_PRINT_X: 320,\n CENTER_PRINT_Y: 100,\n WEAPON_ICON_X: 10,\n WEAPON_ICON_Y: 450,\n POWERUP_X: 610,\n POWERUP_Y: 450,\n};\n","/**\n * CGame HUD Screen Drawing\n * Reference: rerelease/cg_screen.cpp\n *\n * This module handles all HUD rendering for the cgame package, including:\n * - Status bar (health, armor, ammo)\n * - Crosshair\n * - Damage indicators\n * - Pickup notifications\n * - Messages and center print\n * - Subtitles\n */\n\nimport type { PlayerState } from '@quake2ts/shared';\nimport type { CGameImport } from './types.js';\n\n// HUD component imports\nimport { Draw_Crosshair, Init_Crosshair } from './hud/crosshair.js';\nimport { Init_Icons } from './hud/icons.js';\nimport { Draw_Damage, Init_Damage } from './hud/damage.js';\nimport { Draw_Diagnostics } from './hud/diagnostics.js';\nimport { MessageSystem } from './hud/messages.js';\nimport { SubtitleSystem } from './hud/subtitles.js';\nimport { Draw_Blends } from './hud/blends.js';\nimport { Draw_Pickup } from './hud/pickup.js';\nimport { Draw_StatusBar } from './hud/statusbar.js';\nimport { getHudLayout } from './hud/layout.js';\n\n// Module-level state\nlet cgi: CGameImport | null = null;\nconst hudNumberPics: unknown[] = []; // Will hold pic handles from cgi.Draw_RegisterPic()\nlet numberWidth = 0;\n\n// Message and subtitle systems\nconst messageSystem = new MessageSystem();\nconst subtitleSystem = new SubtitleSystem();\n\n/**\n * Initialize the CGame screen module with import functions.\n * Reference: rerelease/cg_screen.cpp InitCGame()\n */\nexport function CG_InitScreen(imports: CGameImport): void {\n cgi = imports;\n}\n\n/**\n * Precache all HUD images.\n * Reference: rerelease/cg_screen.cpp:1689 (TouchPics)\n *\n * This is called during level load to register all required HUD assets.\n */\nexport function CG_TouchPics(): void {\n if (!cgi) return;\n\n // Load HUD number pics\n hudNumberPics.length = 0;\n for (let i = 0; i < 10; i++) {\n try {\n const pic = cgi.Draw_RegisterPic(`pics/hud/num_${i}.pcx`);\n hudNumberPics.push(pic);\n if (i === 0) {\n const size = cgi.Draw_GetPicSize(pic);\n numberWidth = size.width;\n }\n } catch (e) {\n cgi.Com_Print(`Warning: Failed to load HUD image: pics/hud/num_${i}.pcx\\n`);\n }\n }\n\n // TODO: Call Init functions for other HUD components\n // These will need to be adapted to use cgi.Draw_RegisterPic()\n // instead of direct asset manager access\n}\n\n/**\n * Main HUD drawing function.\n * Reference: rerelease/cg_screen.cpp CG_DrawHUD()\n *\n * Called each frame by the client to render the HUD overlay.\n *\n * @param isplit - Split-screen index (0 for single player)\n * @param data - Additional HUD data (unused in initial implementation)\n * @param hud_vrect - Virtual HUD rectangle (screen coordinates)\n * @param hud_safe - Safe area rectangle (for overscan)\n * @param scale - HUD scale factor\n * @param playernum - Player number\n * @param ps - Current player state\n */\nexport function CG_DrawHUD(\n isplit: number,\n data: unknown,\n hud_vrect: { x: number; y: number; width: number; height: number },\n hud_safe: { x: number; y: number; width: number; height: number },\n scale: number,\n playernum: number,\n ps: PlayerState\n): void {\n if (!cgi) {\n console.error('CG_DrawHUD: cgame imports not initialized');\n return;\n }\n\n // TODO: Implement full HUD rendering using cgi drawing functions\n // For now, this is a placeholder structure\n\n // The full implementation will need to:\n // 1. Read stats from ps.stats[] array using STAT_* constants\n // 2. Use cgi.SCR_DrawPic(), cgi.SCR_DrawChar(), etc. for rendering\n // 3. Calculate layout based on hud_vrect and hud_safe\n // 4. Draw all HUD components in correct order:\n // - Screen blends (damage, powerups)\n // - Status bar\n // - Pickup messages\n // - Damage indicators\n // - Center print\n // - Notifications\n // - Subtitles\n // - Crosshair\n\n const timeMs = cgi.CL_ClientTime();\n const layout = getHudLayout(hud_vrect.width, hud_vrect.height);\n\n // Basic placeholder rendering\n // TODO: Adapt each Draw_* function to use cgi instead of renderer\n\n if (ps.centerPrint) {\n cgi.SCR_DrawFontString(\n hud_vrect.width / 2,\n hud_vrect.height / 2 - 20,\n ps.centerPrint\n );\n }\n\n if (ps.notify) {\n cgi.SCR_DrawFontString(8, 8, ps.notify);\n }\n}\n\n/**\n * Get message system instance.\n * Used by parsing functions to add messages.\n */\nexport function CG_GetMessageSystem(): MessageSystem {\n return messageSystem;\n}\n\n/**\n * Get subtitle system instance.\n * Used by audio system to display subtitles.\n */\nexport function CG_GetSubtitleSystem(): SubtitleSystem {\n return subtitleSystem;\n}\n","/**\n * CGame Module Entry Point\n * Reference: rerelease/cg_main.cpp\n *\n * This module provides the GetCGameAPI() function that returns the cgame_export_t\n * interface to the client engine.\n */\n\nimport type { CGameImport, CGameExport } from './types.js';\nimport type { PlayerState, Vec3 } from '@quake2ts/shared';\nimport { LayoutFlags } from '@quake2ts/shared';\nimport { CG_InitScreen, CG_TouchPics, CG_DrawHUD, CG_GetMessageSystem, CG_GetSubtitleSystem } from './screen.js';\n\n// Module-level state\nlet cgi: CGameImport | null = null;\n\n/**\n * Initialize the CGame module.\n * Reference: rerelease/cg_main.cpp InitCGame()\n */\nfunction Init(): void {\n if (!cgi) {\n console.error('CGame Init: cgame imports not set');\n return;\n }\n\n cgi.Com_Print('===== CGame Initialization =====\\n');\n\n // Initialize screen/HUD module\n CG_InitScreen(cgi);\n\n cgi.Com_Print('CGame initialized\\n');\n}\n\n/**\n * Shutdown the CGame module.\n * Reference: rerelease/cg_main.cpp ShutdownCGame()\n */\nfunction Shutdown(): void {\n if (cgi) {\n cgi.Com_Print('CGame shutdown\\n');\n }\n cgi = null;\n}\n\n/**\n * Main HUD drawing function (wrapper for CG_DrawHUD).\n * Reference: rerelease/cg_screen.cpp CG_DrawHUD()\n */\nfunction DrawHUD(\n isplit: number,\n data: unknown,\n hud_vrect: { x: number; y: number; width: number; height: number },\n hud_safe: { x: number; y: number; width: number; height: number },\n scale: number,\n playernum: number,\n ps: PlayerState\n): void {\n CG_DrawHUD(isplit, data, hud_vrect, hud_safe, scale, playernum, ps);\n}\n\n/**\n * Precache all HUD images.\n * Reference: rerelease/cg_screen.cpp TouchPics()\n */\nfunction TouchPics(): void {\n CG_TouchPics();\n}\n\n/**\n * Get layout flags for current player state.\n * Reference: rerelease/cg_screen.cpp\n */\nfunction GetLayoutFlags(ps: PlayerState): LayoutFlags {\n // TODO: Implement proper layout flag calculation\n // Based on inventory state, help state, intermission, etc.\n return 0 as LayoutFlags; // No flags set by default\n}\n\n/**\n * Placeholder stubs for remaining CGameExport functions.\n * These will be implemented as needed.\n */\n\nfunction GetActiveWeaponWheelWeapon(ps: PlayerState): number {\n return 0;\n}\n\nfunction GetOwnedWeaponWheelWeapons(ps: PlayerState): number[] {\n return [];\n}\n\nfunction GetWeaponWheelAmmoCount(ps: PlayerState, weapon: number): number {\n return 0;\n}\n\nfunction GetPowerupWheelCount(ps: PlayerState): number {\n return 0;\n}\n\nfunction GetHitMarkerDamage(ps: PlayerState): number {\n return 0;\n}\n\nfunction Pmove(pmove: unknown): void {\n // TODO: Implement client-side movement prediction\n // Should call shared Pmove() function\n}\n\nfunction ParseConfigString(i: number, s: string): void {\n // TODO: Implement config string parsing\n // Handle CONFIG_N64_PHYSICS, CS_AIRACCEL, etc.\n}\n\nfunction ParseCenterPrint(str: string, isplit: number, instant: boolean): void {\n if (!cgi) return;\n const messageSystem = CG_GetMessageSystem();\n // TODO: Parse layout strings and handle key bindings\n messageSystem.setCenterPrint(str, cgi.CL_ClientTime());\n}\n\nfunction NotifyMessage(isplit: number, msg: string, is_chat: boolean): void {\n if (!cgi) return;\n const messageSystem = CG_GetMessageSystem();\n messageSystem.addNotification(msg, is_chat, cgi.CL_ClientTime());\n}\n\nfunction ClearNotify(isplit: number): void {\n const messageSystem = CG_GetMessageSystem();\n messageSystem.clearNotifications();\n}\n\nfunction ClearCenterprint(isplit: number): void {\n const messageSystem = CG_GetMessageSystem();\n messageSystem.clearCenterPrint();\n}\n\nfunction GetMonsterFlashOffset(id: number): Vec3 {\n return { x: 0, y: 0, z: 0 };\n}\n\nfunction GetExtension(name: string): unknown {\n return null;\n}\n\n/**\n * Main entry point for CGame module.\n * Reference: rerelease/cg_main.cpp GetCGameAPI()\n *\n * @param imports - Functions provided by the client engine\n * @returns CGame export interface\n */\nexport function GetCGameAPI(imports: CGameImport): CGameExport {\n cgi = imports;\n\n return {\n // Lifecycle\n Init,\n Shutdown,\n\n // Rendering\n DrawHUD,\n TouchPics,\n\n // Layout\n LayoutFlags: GetLayoutFlags,\n\n // Weapon wheel\n GetActiveWeaponWheelWeapon,\n GetOwnedWeaponWheelWeapons,\n GetWeaponWheelAmmoCount,\n GetPowerupWheelCount,\n\n // Hit markers\n GetHitMarkerDamage,\n\n // Prediction\n Pmove,\n\n // Parsing\n ParseConfigString,\n ParseCenterPrint,\n NotifyMessage,\n\n // State management\n ClearNotify,\n ClearCenterprint,\n\n // Effects\n GetMonsterFlashOffset,\n\n // Extension\n GetExtension,\n };\n}\n"]}
@@ -0,0 +1,101 @@
1
+ import { Vec3, PmoveTraceResult, PlayerState, LayoutFlags } from '@quake2ts/shared';
2
+
3
+ /**
4
+ * Interface provided by the Engine to the CGame module.
5
+ * Mirrors `cgame_import_t` from `rerelease/game.h`.
6
+ */
7
+ interface CGameImport {
8
+ tick_rate: number;
9
+ frame_time_s: number;
10
+ frame_time_ms: number;
11
+ Com_Print(msg: string): void;
12
+ Com_Error(msg: string): void;
13
+ get_configstring(num: number): string;
14
+ TagMalloc(size: number, tag: number): unknown;
15
+ TagFree(ptr: unknown): void;
16
+ FreeTags(tag: number): void;
17
+ cvar(name: string, value: string, flags: number): unknown;
18
+ cvar_set(name: string, value: string): void;
19
+ cvar_forceset(name: string, value: string): void;
20
+ CL_FrameValid(): boolean;
21
+ CL_FrameTime(): number;
22
+ CL_ClientTime(): number;
23
+ CL_ServerFrame(): number;
24
+ CL_ServerProtocol(): number;
25
+ CL_GetClientName(playerNum: number): string;
26
+ CL_GetClientPic(playerNum: number): string;
27
+ CL_GetClientDogtag(playerNum: number): string;
28
+ CL_GetKeyBinding(key: string): string;
29
+ Draw_RegisterPic(name: string): unknown;
30
+ Draw_GetPicSize(pic: unknown): {
31
+ width: number;
32
+ height: number;
33
+ };
34
+ SCR_DrawChar(x: number, y: number, char: number): void;
35
+ SCR_DrawPic(x: number, y: number, pic: unknown): void;
36
+ SCR_DrawColorPic(x: number, y: number, pic: unknown, color: Vec3, alpha: number): void;
37
+ SCR_DrawFontString(x: number, y: number, str: string): void;
38
+ SCR_MeasureFontString(str: string): number;
39
+ SCR_FontLineHeight(): number;
40
+ SCR_SetAltTypeface(alt: boolean): void;
41
+ SCR_DrawBind(x: number, y: number, command: string): void;
42
+ Localize(key: string): string;
43
+ CL_GetTextInput(): string;
44
+ CL_GetWarnAmmoCount(): number;
45
+ CL_InAutoDemoLoop(): boolean;
46
+ PM_Trace(start: Vec3, end: Vec3, mins: Vec3, maxs: Vec3): PmoveTraceResult;
47
+ }
48
+ /**
49
+ * Interface exported by the CGame module to the Engine.
50
+ * Mirrors `cgame_export_t` from `rerelease/game.h`.
51
+ */
52
+ interface CGameExport {
53
+ Init(): void;
54
+ Shutdown(): void;
55
+ DrawHUD(isplit: number, data: unknown, // Placeholder, likely specific HUD data structure
56
+ hud_vrect: {
57
+ x: number;
58
+ y: number;
59
+ width: number;
60
+ height: number;
61
+ }, hud_safe: {
62
+ x: number;
63
+ y: number;
64
+ width: number;
65
+ height: number;
66
+ }, scale: number, playernum: number, ps: PlayerState): void;
67
+ TouchPics(): void;
68
+ LayoutFlags(ps: PlayerState): LayoutFlags;
69
+ GetActiveWeaponWheelWeapon(ps: PlayerState): number;
70
+ GetOwnedWeaponWheelWeapons(ps: PlayerState): number[];
71
+ GetWeaponWheelAmmoCount(ps: PlayerState, weapon: number): number;
72
+ GetPowerupWheelCount(ps: PlayerState): number;
73
+ GetHitMarkerDamage(ps: PlayerState): number;
74
+ Pmove(pmove: unknown): void;
75
+ ParseConfigString(i: number, s: string): void;
76
+ ParseCenterPrint(str: string, isplit: number, instant: boolean): void;
77
+ NotifyMessage(isplit: number, msg: string, is_chat: boolean): void;
78
+ ClearNotify(isplit: number): void;
79
+ ClearCenterprint(isplit: number): void;
80
+ GetMonsterFlashOffset(id: number): Vec3;
81
+ GetExtension(name: string): unknown;
82
+ }
83
+
84
+ /**
85
+ * CGame Module Entry Point
86
+ * Reference: rerelease/cg_main.cpp
87
+ *
88
+ * This module provides the GetCGameAPI() function that returns the cgame_export_t
89
+ * interface to the client engine.
90
+ */
91
+
92
+ /**
93
+ * Main entry point for CGame module.
94
+ * Reference: rerelease/cg_main.cpp GetCGameAPI()
95
+ *
96
+ * @param imports - Functions provided by the client engine
97
+ * @returns CGame export interface
98
+ */
99
+ declare function GetCGameAPI(imports: CGameImport): CGameExport;
100
+
101
+ export { GetCGameAPI };
@@ -1,3 +1,101 @@
1
- declare function GetCGameAPI(): {};
1
+ import { Vec3, PmoveTraceResult, PlayerState, LayoutFlags } from '@quake2ts/shared';
2
+
3
+ /**
4
+ * Interface provided by the Engine to the CGame module.
5
+ * Mirrors `cgame_import_t` from `rerelease/game.h`.
6
+ */
7
+ interface CGameImport {
8
+ tick_rate: number;
9
+ frame_time_s: number;
10
+ frame_time_ms: number;
11
+ Com_Print(msg: string): void;
12
+ Com_Error(msg: string): void;
13
+ get_configstring(num: number): string;
14
+ TagMalloc(size: number, tag: number): unknown;
15
+ TagFree(ptr: unknown): void;
16
+ FreeTags(tag: number): void;
17
+ cvar(name: string, value: string, flags: number): unknown;
18
+ cvar_set(name: string, value: string): void;
19
+ cvar_forceset(name: string, value: string): void;
20
+ CL_FrameValid(): boolean;
21
+ CL_FrameTime(): number;
22
+ CL_ClientTime(): number;
23
+ CL_ServerFrame(): number;
24
+ CL_ServerProtocol(): number;
25
+ CL_GetClientName(playerNum: number): string;
26
+ CL_GetClientPic(playerNum: number): string;
27
+ CL_GetClientDogtag(playerNum: number): string;
28
+ CL_GetKeyBinding(key: string): string;
29
+ Draw_RegisterPic(name: string): unknown;
30
+ Draw_GetPicSize(pic: unknown): {
31
+ width: number;
32
+ height: number;
33
+ };
34
+ SCR_DrawChar(x: number, y: number, char: number): void;
35
+ SCR_DrawPic(x: number, y: number, pic: unknown): void;
36
+ SCR_DrawColorPic(x: number, y: number, pic: unknown, color: Vec3, alpha: number): void;
37
+ SCR_DrawFontString(x: number, y: number, str: string): void;
38
+ SCR_MeasureFontString(str: string): number;
39
+ SCR_FontLineHeight(): number;
40
+ SCR_SetAltTypeface(alt: boolean): void;
41
+ SCR_DrawBind(x: number, y: number, command: string): void;
42
+ Localize(key: string): string;
43
+ CL_GetTextInput(): string;
44
+ CL_GetWarnAmmoCount(): number;
45
+ CL_InAutoDemoLoop(): boolean;
46
+ PM_Trace(start: Vec3, end: Vec3, mins: Vec3, maxs: Vec3): PmoveTraceResult;
47
+ }
48
+ /**
49
+ * Interface exported by the CGame module to the Engine.
50
+ * Mirrors `cgame_export_t` from `rerelease/game.h`.
51
+ */
52
+ interface CGameExport {
53
+ Init(): void;
54
+ Shutdown(): void;
55
+ DrawHUD(isplit: number, data: unknown, // Placeholder, likely specific HUD data structure
56
+ hud_vrect: {
57
+ x: number;
58
+ y: number;
59
+ width: number;
60
+ height: number;
61
+ }, hud_safe: {
62
+ x: number;
63
+ y: number;
64
+ width: number;
65
+ height: number;
66
+ }, scale: number, playernum: number, ps: PlayerState): void;
67
+ TouchPics(): void;
68
+ LayoutFlags(ps: PlayerState): LayoutFlags;
69
+ GetActiveWeaponWheelWeapon(ps: PlayerState): number;
70
+ GetOwnedWeaponWheelWeapons(ps: PlayerState): number[];
71
+ GetWeaponWheelAmmoCount(ps: PlayerState, weapon: number): number;
72
+ GetPowerupWheelCount(ps: PlayerState): number;
73
+ GetHitMarkerDamage(ps: PlayerState): number;
74
+ Pmove(pmove: unknown): void;
75
+ ParseConfigString(i: number, s: string): void;
76
+ ParseCenterPrint(str: string, isplit: number, instant: boolean): void;
77
+ NotifyMessage(isplit: number, msg: string, is_chat: boolean): void;
78
+ ClearNotify(isplit: number): void;
79
+ ClearCenterprint(isplit: number): void;
80
+ GetMonsterFlashOffset(id: number): Vec3;
81
+ GetExtension(name: string): unknown;
82
+ }
83
+
84
+ /**
85
+ * CGame Module Entry Point
86
+ * Reference: rerelease/cg_main.cpp
87
+ *
88
+ * This module provides the GetCGameAPI() function that returns the cgame_export_t
89
+ * interface to the client engine.
90
+ */
91
+
92
+ /**
93
+ * Main entry point for CGame module.
94
+ * Reference: rerelease/cg_main.cpp GetCGameAPI()
95
+ *
96
+ * @param imports - Functions provided by the client engine
97
+ * @returns CGame export interface
98
+ */
99
+ declare function GetCGameAPI(imports: CGameImport): CGameExport;
2
100
 
3
101
  export { GetCGameAPI };