You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
3.0 KiB
137 lines
3.0 KiB
#include "uniquake.h"
|
|
|
|
#include "../Quake/quakedef.h"
|
|
|
|
typedef struct unity_syscalls_s
|
|
{
|
|
void *target;
|
|
|
|
void(*SysPrint)(void *target, const char *msg);
|
|
void(*SysError)(void *target, const char *msg);
|
|
void(*SysQuit)(void *target);
|
|
double(*SysDoubleTime)(void *target);
|
|
|
|
int(*SysFileOpenRead)(void *target, const char *path, int *hndl);
|
|
int(*SysFileOpenWrite)(void *target, const char *path);
|
|
void(*SysFileClose)(void *target, int handle);
|
|
void(*SysFileSeek)(void *target, int handle, int position);
|
|
int(*SysFileRead)(void *target, int handle, void *dest, int count);
|
|
int(*SysFileWrite)(void *target, int handle, const void *data, int count);
|
|
int(*SysFileTime)(void *target, const char *path);
|
|
qboolean(*SysMkDir)(void *target, const char *path);
|
|
} unity_syscalls_t;
|
|
|
|
const unity_syscalls_t *unity_syscalls;
|
|
|
|
void Sys_Error(const char *error, ...)
|
|
{
|
|
va_list argptr;
|
|
char text[1024];
|
|
|
|
va_start(argptr, error);
|
|
q_vsnprintf(text, sizeof(text), error, argptr);
|
|
va_end(argptr);
|
|
|
|
unity_syscalls->SysError(unity_syscalls->target, text);
|
|
}
|
|
|
|
void Sys_Printf(const char *fmt, ...)
|
|
{
|
|
va_list argptr;
|
|
char text[1024];
|
|
|
|
va_start(argptr, fmt);
|
|
q_vsnprintf(text, sizeof(text), fmt, argptr);
|
|
va_end(argptr);
|
|
|
|
unity_syscalls->SysPrint(unity_syscalls->target, text);
|
|
}
|
|
|
|
void Sys_Quit(void)
|
|
{
|
|
unity_syscalls->SysQuit(unity_syscalls->target);
|
|
}
|
|
|
|
double Sys_DoubleTime(void)
|
|
{
|
|
return unity_syscalls->SysDoubleTime(unity_syscalls->target);
|
|
}
|
|
|
|
int Sys_FileOpenRead(const char *path, int *hndl)
|
|
{
|
|
return unity_syscalls->SysFileOpenRead(unity_syscalls->target, path, hndl);
|
|
}
|
|
|
|
int Sys_FileOpenWrite(const char *path)
|
|
{
|
|
return unity_syscalls->SysFileOpenWrite(unity_syscalls->target, path);
|
|
}
|
|
|
|
void Sys_FileClose(int handle)
|
|
{
|
|
unity_syscalls->SysFileClose(unity_syscalls->target, handle);
|
|
}
|
|
|
|
void Sys_FileSeek(int handle, int position)
|
|
{
|
|
unity_syscalls->SysFileSeek(unity_syscalls->target, handle, position);
|
|
}
|
|
|
|
int Sys_FileRead(int handle, void *dest, int count)
|
|
{
|
|
return unity_syscalls->SysFileRead(unity_syscalls->target, handle, dest, count);
|
|
}
|
|
|
|
int Sys_FileWrite(int handle, const void *data, int count)
|
|
{
|
|
return unity_syscalls->SysFileWrite(unity_syscalls->target, handle, data, count);
|
|
}
|
|
|
|
int Sys_FileTime(const char *path)
|
|
{
|
|
return unity_syscalls->SysFileTime(unity_syscalls->target, path);
|
|
}
|
|
|
|
void Sys_mkdir(const char *path)
|
|
{
|
|
if (!unity_syscalls->SysMkDir(unity_syscalls->target, path))
|
|
Sys_Error("Unable to create directory %s", path);
|
|
}
|
|
|
|
const char *Sys_ConsoleInput(void)
|
|
{
|
|
// Not implemented: we support neither STDIN nor dedicated servers in UniQuake
|
|
return NULL;
|
|
}
|
|
|
|
#ifndef USE_LIBSDL
|
|
|
|
void Sys_Sleep(unsigned long msecs)
|
|
{
|
|
// TODO: implement
|
|
}
|
|
|
|
void Sys_SendKeyEvents(void)
|
|
{
|
|
// TODO: signal Unity to process input & send commands
|
|
}
|
|
|
|
void PL_SetWindowIcon(void)
|
|
{
|
|
}
|
|
|
|
void PL_VID_Shutdown(void)
|
|
{
|
|
}
|
|
|
|
char *PL_GetClipboardData(void)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
void PL_ErrorDialog(const char *text)
|
|
{
|
|
// TODO: could signal this back to Unity and show a platform-specific system dialog
|
|
}
|
|
|
|
#endif // !USE_LIBSDL
|