Nuclide
Software Development Kit for id Technology (BETA)
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
62/* Font library */
63typedef struct
64{
65 float GetID(font_s);
66 void Load(string,font_s &);
67 string RGBtoHex(vector);
69 float StringWidth(string,bool,font_s);
70} fontAPI_t;
72
73
74/* Surface library */
75typedef struct
76{
77 vector Mins(void);
78 vector Size(void);
79 float Width(void);
80 float Height(void);
81 vector HUDMins(void);
82 vector HUDSize(void);
85
86/* Surface library */
87typedef struct
88{
89 void Rect(vector, vector, vector, float);
90 void RectOutline(vector, vector, float, vector, float);
91 void RoundedBox(vector, vector, vector, float);
92 void Line(float, vector, vector, vector, float);
93 void Pic(vector, string, vector, vector, float);
94 void Text(vector,string,font_s);
95 void Text_A(vector,string,float,font_s);
96 void Text_RGB(vector,string,vector,font_s);
97 void Text_RGBA(vector,string,vector,float,font_s);
98 void RText(vector,string,font_s);
99 void RText_A(vector,string,float,font_s);
100 void RText_RGB(vector,string,vector,font_s);
101 void RText_RGBA(vector,string,vector,float,font_s);
102 void TextField(vector,vector,string,font_s,alignflags_t);
103 void TextFieldAtHeight(vector,vector,int,string,font_s,alignflags_t);
104} drawAPI_t;
106
107/* Player library */
108typedef struct
109{
110 vector GetCameraPosition(void);
111 vector GetCameraAngles(void);
112 float GetArmor(void);
113 float GetHealth(void);
114 float GetStamina(void);
115 int GetTeam(void);
116 bool IsStanding(void);
117 bool IsLeaning(void);
118 bool IsSprinting(void);
119 bool IsCrouched(void);
120 bool IsProne(void);
121 bool HasItem(string);
124
125/* Weapon library */
126typedef struct
127{
128 bool IsValid(entity);
129 string GetTitle(entity);
130 int GetSlot(entity);
131 int GetSlotPos(entity);
132 string GetIcon(entity);
133 string GetSelectedIcon(entity);
134 int GetAmmo1(void);
135 int GetAmmo2(void);
136 int GetClip(void);
137 int GetClipSize(void);
139 bool AmmoRequired(void);
140
141 entity GetActiveWeapon(void);
144
147
148 void SelectWeapon(entity);
151
152 // end of hudC
154
155/* To be implemented by HUD */
156void HUD_Init(void);
157
158__variant
159linkToClientProgs(string funcName)
160{
161 static void empty(void)
162 {
163 print("Called unimplemented client-side API call.\n");
164 breakpoint();
165 }
166
167 void *func = externvalue(0, funcName);
168
169 if (func) {
170 return ((__variant)func);
171 } else {
172 return (empty);
173 }
174}
175
176void
177_client_main(void)
178{
179 font.GetHeight = linkToClientProgs("Font_GetHeight");
180 font.GetID = linkToClientProgs("Font_GetID");
181 font.Load = linkToClientProgs("Font_Load");
182 font.RGBtoHex = linkToClientProgs("Font_RGBtoHex");
183 font.StringWidth = linkToClientProgs("Font_StringWidth");
184
185 screen.Width = linkToClientProgs("Surface_ScreenHeight");
186 screen.Height = linkToClientProgs("Surface_ScreenHeight");
187 screen.Size = linkToClientProgs("Surface_ScreenSize");
188 screen.Mins = linkToClientProgs("Surface_ScreenMins");
189 screen.HUDMins = linkToClientProgs("Surface_HUDMins");
190 screen.HUDSize = linkToClientProgs("Surface_HUDSize");
191
192 player.GetCameraPosition = linkToClientProgs("Player_GetCameraPosition");
193 player.GetCameraAngles = linkToClientProgs("Player_GetCameraAngles");
194 player.GetHealth = linkToClientProgs("Player_GetHealth");
195 player.GetArmor = linkToClientProgs("Player_GetArmor");
196 player.GetStamina = linkToClientProgs("Player_GetStamina");
197 player.GetTeam = linkToClientProgs("Player_GetTeam");
198 player.HasItem = linkToClientProgs("Player_HasItem");
199 player.IsStanding = linkToClientProgs("Player_IsStanding");
200 player.IsLeaning = linkToClientProgs("Player_IsLeaning");
201 player.IsSprinting = linkToClientProgs("Player_IsSprinting");
202 player.IsCrouched = linkToClientProgs("Player_IsCrouched");
203 player.IsProne = linkToClientProgs("Player_IsProne");
204
205 weapon.IsValid = linkToClientProgs("Weapon_IsValid");
206 weapon.GetTitle = linkToClientProgs("Weapon_GetTitle");
207 weapon.GetIcon = linkToClientProgs("Weapon_GetIcon");
208 weapon.GetSelectedIcon = linkToClientProgs("Weapon_GetSelectedIcon");
209 weapon.GetSlot = linkToClientProgs("Weapon_GetSlot");
210 weapon.GetSlotPos = linkToClientProgs("Weapon_GetSlotPos");
211 weapon.GetAmmo1 = linkToClientProgs("Weapon_GetAmmo1");
212 weapon.GetAmmo2 = linkToClientProgs("Weapon_GetAmmo2");
213 weapon.GetClip = linkToClientProgs("Weapon_GetClip");
214 weapon.GetClipSize = linkToClientProgs("Weapon_GetClipSize");
215 weapon.UsesSecondaryAmmo = linkToClientProgs("Weapon_UsesSecondaryAmmo");
216 weapon.AmmoRequired = linkToClientProgs("Weapon_AmmoRequired");
217 weapon.GetActiveWeapon = linkToClientProgs("Weapon_GetActiveWeapon");
218 weapon.GetFirstWeaponInInventory = linkToClientProgs("Weapon_GetFirstWeaponInInventory");
219 weapon.GetLastWeaponInInventory = linkToClientProgs("Weapon_GetLastWeaponInInventory");
220 weapon.GetNextWeaponRelativeTo = linkToClientProgs("Weapon_GetNextWeaponRelativeTo");
221 weapon.GetPreviousWeaponRelativeTo = linkToClientProgs("Weapon_GetPreviousWeaponRelativeTo");
222 weapon.SelectWeapon = linkToClientProgs("Weapon_SelectWeapon");
223
224 draw.Rect = linkToClientProgs("Draw_Rect");
225 draw.RectOutline = linkToClientProgs("Draw_RectOutline");
226 draw.RoundedBox = linkToClientProgs("Draw_RoundedBox");
227 draw.Line = linkToClientProgs("Draw_Line");
228 draw.Pic = linkToClientProgs("Draw_Pic");
229 draw.TextField = linkToClientProgs("Font_DrawField");
230 draw.TextFieldAtHeight = linkToClientProgs("Font_DrawFieldAtHeight");
231 draw.RText = linkToClientProgs("Font_DrawRText");
232 draw.RText_A = linkToClientProgs("Font_DrawRText_A");
233 draw.RText_RGB = linkToClientProgs("Font_DrawRText_RGB");
234 draw.RText_RGBA = linkToClientProgs("Font_DrawRText_RGBA");
235 draw.Text = linkToClientProgs("Font_DrawText");
236 draw.Text_A= linkToClientProgs("Font_DrawText_A");
237 draw.Text_RGB= linkToClientProgs("Font_DrawText_RGB");
238 draw.Text_RGBA = linkToClientProgs("Font_DrawText_RGBA");
239}
var surfaceAPI_t screen
Definition: api_func.h:84
var fontAPI_t font
Definition: api_func.h:71
var weaponAPI_t weapon
Definition: api_func.h:150
var drawAPI_t draw
Definition: api_func.h:105
var playerAPI_t player
Definition: api_func.h:123
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
Definition: api_func.h:88
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:64
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:109
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:76
vector HUDSize(void)
float Height(void)
float Width(void)
vector HUDMins(void)
vector Size(void)
vector Mins(void)
Definition: api_func.h:127
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)