Nuclide
Software Development Kit for id Technology
api_func.h
1/*
2 * Copyright (c) 2016-2024 Vera Visions LLC.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
18typedef enum
19{
25
28typedef enumflags
29{
30 AF_LEFT,
31 AF_TOP,
32 AF_RIGHT,
33 AF_BOTTOM
34} alignflags_t;
35#define AF_NONE 0
36
38typedef struct
39{
40 int iID;
41 int iScaleX;
42 int iScaleY;
43 vector vecColor;
44 float flAlpha;
45 int iFlags;
46 string hexColor;
47} font_s;
48
58/* Font library */
59typedef struct
60{
61 float GetID(font_s);
62 void Load(string,font_s &);
63 string RGBtoHex(vector);
65 float StringWidth(string,bool,font_s);
66} fontAPI_t;
68
69
70/* Surface library */
71typedef struct
72{
73 vector Mins(void);
74 vector Size(void);
75 float Width(void);
76 float Height(void);
77 vector HUDMins(void);
78 vector HUDSize(void);
81
82/* Surface library */
83typedef struct
84{
85 void Rect(vector, vector, vector, float);
86 void RectOutline(vector, vector, float, vector, float);
87 void RoundedBox(vector, vector, vector, float);
88 void Line(float, vector, vector, vector, float);
89 void Pic(vector, string, vector, vector, float);
90 void Text(vector,string,font_s);
91 void Text_A(vector,string,float,font_s);
92 void Text_RGB(vector,string,vector,font_s);
93 void Text_RGBA(vector,string,vector,float,font_s);
94 void RText(vector,string,font_s);
95 void RText_A(vector,string,float,font_s);
96 void RText_RGB(vector,string,vector,font_s);
97 void RText_RGBA(vector,string,vector,float,font_s);
98 void TextField(vector,vector,string,font_s,alignflags_t);
99 void TextFieldAtHeight(vector,vector,int,string,font_s,alignflags_t);
100} drawAPI_t;
102
103/* Player library */
104typedef struct
105{
106 vector GetCameraPosition(void);
107 vector GetCameraAngles(void);
108 float GetArmor(void);
109 float GetHealth(void);
110 float GetStamina(void);
111 int GetTeam(void);
112 bool IsStanding(void);
113 bool IsLeaning(void);
114 bool IsSprinting(void);
115 bool IsCrouched(void);
116 bool IsProne(void);
117 bool HasItem(string);
120
121/* Weapon library */
122typedef struct
123{
124 bool IsValid(entity);
125 string GetTitle(entity);
126 int GetSlot(entity);
127 int GetSlotPos(entity);
128 string GetIcon(entity);
129 string GetSelectedIcon(entity);
130 int GetAmmo1(void);
131 int GetAmmo2(void);
132 int GetClip(void);
133 int GetClipSize(void);
135 bool AmmoRequired(void);
136
137 entity GetActiveWeapon(void);
140
143
144 void SelectWeapon(entity);
147
148 // end of hudC
150
151/* To be implemented by HUD */
152void HUD_Init(void);
153
154__variant
155linkToClientProgs(string funcName)
156{
157 static void empty(void)
158 {
159 print("Called unimplemented client-side API call.\n");
160 breakpoint();
161 }
162
163 void *func = externvalue(0, funcName);
164
165 if (func) {
166 return ((__variant)func);
167 } else {
168 return (empty);
169 }
170}
171
172void
173_client_main(void)
174{
175 font.GetHeight = linkToClientProgs("Font_GetHeight");
176 font.GetID = linkToClientProgs("Font_GetID");
177 font.Load = linkToClientProgs("Font_Load");
178 font.RGBtoHex = linkToClientProgs("Font_RGBtoHex");
179 font.StringWidth = linkToClientProgs("Font_StringWidth");
180
181 screen.Width = linkToClientProgs("Surface_ScreenHeight");
182 screen.Height = linkToClientProgs("Surface_ScreenHeight");
183 screen.Size = linkToClientProgs("Surface_ScreenSize");
184 screen.Mins = linkToClientProgs("Surface_ScreenMins");
185 screen.HUDMins = linkToClientProgs("Surface_HUDMins");
186 screen.HUDSize = linkToClientProgs("Surface_HUDSize");
187
188 player.GetCameraPosition = linkToClientProgs("Player_GetCameraPosition");
189 player.GetCameraAngles = linkToClientProgs("Player_GetCameraAngles");
190 player.GetHealth = linkToClientProgs("Player_GetHealth");
191 player.GetArmor = linkToClientProgs("Player_GetArmor");
192 player.GetStamina = linkToClientProgs("Player_GetStamina");
193 player.GetTeam = linkToClientProgs("Player_GetTeam");
194 player.HasItem = linkToClientProgs("Player_HasItem");
195 player.IsStanding = linkToClientProgs("Player_IsStanding");
196 player.IsLeaning = linkToClientProgs("Player_IsLeaning");
197 player.IsSprinting = linkToClientProgs("Player_IsSprinting");
198 player.IsCrouched = linkToClientProgs("Player_IsCrouched");
199 player.IsProne = linkToClientProgs("Player_IsProne");
200
201 weapon.IsValid = linkToClientProgs("Weapon_IsValid");
202 weapon.GetTitle = linkToClientProgs("Weapon_GetTitle");
203 weapon.GetIcon = linkToClientProgs("Weapon_GetIcon");
204 weapon.GetSelectedIcon = linkToClientProgs("Weapon_GetSelectedIcon");
205 weapon.GetSlot = linkToClientProgs("Weapon_GetSlot");
206 weapon.GetSlotPos = linkToClientProgs("Weapon_GetSlotPos");
207 weapon.GetAmmo1 = linkToClientProgs("Weapon_GetAmmo1");
208 weapon.GetAmmo2 = linkToClientProgs("Weapon_GetAmmo2");
209 weapon.GetClip = linkToClientProgs("Weapon_GetClip");
210 weapon.GetClipSize = linkToClientProgs("Weapon_GetClipSize");
211 weapon.UsesSecondaryAmmo = linkToClientProgs("Weapon_UsesSecondaryAmmo");
212 weapon.AmmoRequired = linkToClientProgs("Weapon_AmmoRequired");
213 weapon.GetActiveWeapon = linkToClientProgs("Weapon_GetActiveWeapon");
214 weapon.GetFirstWeaponInInventory = linkToClientProgs("Weapon_GetFirstWeaponInInventory");
215 weapon.GetLastWeaponInInventory = linkToClientProgs("Weapon_GetLastWeaponInInventory");
216 weapon.GetNextWeaponRelativeTo = linkToClientProgs("Weapon_GetNextWeaponRelativeTo");
217 weapon.GetPreviousWeaponRelativeTo = linkToClientProgs("Weapon_GetPreviousWeaponRelativeTo");
218 weapon.SelectWeapon = linkToClientProgs("Weapon_SelectWeapon");
219
220 draw.Rect = linkToClientProgs("Draw_Rect");
221 draw.RectOutline = linkToClientProgs("Draw_RectOutline");
222 draw.RoundedBox = linkToClientProgs("Draw_RoundedBox");
223 draw.Line = linkToClientProgs("Draw_Line");
224 draw.Pic = linkToClientProgs("Draw_Pic");
225 draw.TextField = linkToClientProgs("Font_DrawField");
226 draw.TextFieldAtHeight = linkToClientProgs("Font_DrawFieldAtHeight");
227 draw.RText = linkToClientProgs("Font_DrawRText");
228 draw.RText_A = linkToClientProgs("Font_DrawRText_A");
229 draw.RText_RGB = linkToClientProgs("Font_DrawRText_RGB");
230 draw.RText_RGBA = linkToClientProgs("Font_DrawRText_RGBA");
231 draw.Text = linkToClientProgs("Font_DrawText");
232 draw.Text_A= linkToClientProgs("Font_DrawText_A");
233 draw.Text_RGB= linkToClientProgs("Font_DrawText_RGB");
234 draw.Text_RGBA = linkToClientProgs("Font_DrawText_RGBA");
235}
drawflag_t
Flags for 2D drawing operations.
Definition: font.h:27
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37
@ DRAWFLAG_ADDITIVE
Render with an additive blend mode.
Definition: api_func.h:21
@ DRAWFLAG_MODULATE
Not implemented in FTEQW.
Definition: api_func.h:22
@ DRAWFLAG_2XMODULATE
Not implemented in FTEQW.
Definition: api_func.h:23
@ DRAWFLAG_NORMAL
The default.
Definition: api_func.h:20
var surfaceAPI_t screen
Definition: api_func.h:80
var fontAPI_t font
Definition: api_func.h:67
var weaponAPI_t weapon
Definition: api_func.h:146
var drawAPI_t draw
Definition: api_func.h:101
var playerAPI_t player
Definition: api_func.h:119
Definition: api_func.h:84
void RText_RGB(vector, string, vector, font_s)
void RText_A(vector, string, float, font_s)
void Rect(vector, vector, vector, float)
void Line(float, vector, vector, vector, float)
void TextField(vector, vector, string, font_s, alignflags_t)
void Text_A(vector, string, float, font_s)
void RText(vector, string, font_s)
void TextFieldAtHeight(vector, vector, int, string, font_s, alignflags_t)
void RText_RGBA(vector, string, vector, float, font_s)
void Text_RGBA(vector, string, vector, float, font_s)
void Pic(vector, string, vector, vector, float)
void Text(vector, string, font_s)
void RoundedBox(vector, vector, vector, float)
void Text_RGB(vector, string, vector, font_s)
void RectOutline(vector, vector, float, vector, float)
Definition: api_func.h:60
string RGBtoHex(vector)
float GetID(font_s)
int GetHeight(font_s)
float StringWidth(string, bool, font_s)
void Load(string, font_s &)
Representation of a font.
Definition: api_func.h:39
int iFlags
Rendering flags that the font posesses.
Definition: api_func.h:45
int iScaleX
Suggested maximum width of a character in the font.
Definition: api_func.h:41
int iScaleY
Maximum height of a chracter in the font.
Definition: api_func.h:42
vector vecColor
Suggested default color of the font.
Definition: api_func.h:43
float flAlpha
Suggested default alpha of the font.
Definition: api_func.h:44
int iID
Internal ID, will be passed to 'drawfont' before rendering text.
Definition: api_func.h:40
string hexColor
Definition: api_func.h:46
Definition: api_func.h:105
int GetTeam(void)
float GetHealth(void)
float GetArmor(void)
bool IsLeaning(void)
bool IsProne(void)
bool IsCrouched(void)
vector GetCameraAngles(void)
bool IsStanding(void)
float GetStamina(void)
bool HasItem(string)
bool IsSprinting(void)
vector GetCameraPosition(void)
Definition: api_func.h:72
vector HUDSize(void)
float Height(void)
float Width(void)
vector HUDMins(void)
vector Size(void)
vector Mins(void)
Definition: api_func.h:123
int GetSlot(entity)
entity GetPreviousWeaponRelativeTo(entity)
entity GetNextWeaponRelativeTo(entity)
bool IsValid(entity)
string GetSelectedIcon(entity)
entity GetActiveWeapon(void)
entity GetLastWeaponInInventory(void)
bool UsesSecondaryAmmo(void)
string GetTitle(entity)
string GetIcon(entity)
bool AmmoRequired(void)
int GetClip(void)
int GetSlotPos(entity)
entity GetFirstWeaponInInventory(void)
int GetAmmo2(void)
int GetClipSize(void)
int GetAmmo1(void)
void SelectWeapon(entity)