git-svn-id: https://svn.eduke32.com/eduke32@821 1a8010ca-5511-0410-912e-c29ae57300e0

This commit is contained in:
terminx 2008-06-30 07:30:48 +00:00
parent 5d2b147658
commit 1783253ccd
11 changed files with 228 additions and 150 deletions

View file

@ -22,7 +22,8 @@ typedef struct _symbol
int (*func)(const osdfuncparm_t *);
} symbol_t;
extern symbol_t *symbols;
symbol_t *symbols;
const char *stripcolorcodes(const char *t);
#define OSD_ALIAS 1337
#define OSD_UNALIASED 1338
@ -30,6 +31,10 @@ extern symbol_t *symbols;
#define OSDCMD_OK 0
#define OSDCMD_SHOWHELP 1
int osdexecscript;
int OSD_Exec(const char *szScript);
// initializes things
void OSD_Init(void);

View file

@ -6,6 +6,7 @@
#include "osd.h"
#include "compat.h"
#include "baselayer.h"
#include "cache1d.h"
symbol_t *symbols = NULL;
static symbol_t *addnewsymbol(const char *name);
@ -82,6 +83,7 @@ static int osdexeccount=0; // number of lines from the head of the history buf
// maximal log line count
int logcutoff=120000;
int linecnt;
int osdexecscript=0;
// presentation parameters
static int osdpromptshade=0;
@ -103,6 +105,61 @@ static void (*clearbackground)(int,int) = _internal_clearbackground;
static int (*gettime)(void) = _internal_gettime;
static void (*onshowosd)(int) = _internal_onshowosd;
const char *stripcolorcodes(const char *t)
{
int i = 0;
static char colstrip[1024];
while (*t)
{
if (*t == '^' && isdigit(*(t+1)))
{
t += 2;
if (isdigit(*t))
t++;
continue;
}
colstrip[i] = *t;
i++,t++;
}
colstrip[i] = '\0';
return(colstrip);
}
int OSD_Exec(const char *szScript)
{
FILE* fp = fopenfrompath(szScript, "r");
if (fp != NULL)
{
char line[255];
OSD_Printf("Executing \"%s\"\n", szScript);
osdexecscript++;
while (fgets(line ,sizeof(line)-1, fp) != NULL)
OSD_Dispatch(strtok(line,"\r\n"));
osdexecscript--;
fclose(fp);
return 0;
}
return 1;
}
static int _internal_osdfunc_exec(const osdfuncparm_t *parm)
{
char fn[BMAX_PATH];
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
Bstrcpy(fn,parm->parms[0]);
if (OSD_Exec(fn))
{
OSD_Printf("exec: file \"%s\" not found.\n", fn);
return OSDCMD_OK;
}
return OSDCMD_OK;
}
static void _internal_drawosdchar(int x, int y, char ch, int shade, int pal)
{
int i,j,k;
@ -213,7 +270,7 @@ static int _internal_osdfunc_alias(const osdfuncparm_t *parm)
OSD_Printf("Alias listing:\n");
for (i=symbols; i!=NULL; i=i->next)
if (i->func == (void *)OSD_ALIAS)
OSD_Printf(" %s\n", i->name);
OSD_Printf(" %s \"%s\"\n", i->name, i->help);
return OSDCMD_OK;
}
@ -237,7 +294,8 @@ static int _internal_osdfunc_alias(const osdfuncparm_t *parm)
}
OSD_RegisterFunction(Bstrdup(parm->parms[0]),Bstrdup(parm->parms[1]),(void *)OSD_ALIAS);
OSD_Printf("%s\n",parm->raw);
if (!osdexecscript)
OSD_Printf("%s\n",parm->raw);
return OSDCMD_OK;
}
@ -256,7 +314,7 @@ static int _internal_osdfunc_unalias(const osdfuncparm_t *parm)
{
if (i->func == (void *)OSD_ALIAS)
{
OSD_Printf("Removed alias %s \(\"%s\"\)\n", i->name, i->help);
OSD_Printf("Removed alias %s (\"%s\")\n", i->name, i->help);
i->func = (void *)OSD_UNALIASED;
}
else OSD_Printf("Invalid alias %s\n",i->name);
@ -300,13 +358,35 @@ static int _internal_osdfunc_vars(const osdfuncparm_t *parm)
static int _internal_osdfunc_listsymbols(const osdfuncparm_t *parm)
{
symbol_t *i;
int maxwidth = 0;
UNREFERENCED_PARAMETER(parm);
OSD_Printf("Symbol listing:\n");
for (i=symbols; i!=NULL; i=i->next)
if (i->func != (void *)OSD_UNALIASED)
OSD_Printf(" %s\n", i->name);
maxwidth = max((unsigned)maxwidth,Bstrlen(i->name));
if (maxwidth > 0)
{
int x = 0;
maxwidth += 3;
OSD_Printf("Symbol listing:\n");
for (i=symbols; i!=NULL; i=i->next)
{
if (i->func != (void *)OSD_UNALIASED)
{
OSD_Printf("%-*s",maxwidth,i->name);
x += maxwidth;
}
if (x > osdcols - maxwidth)
{
x = 0;
OSD_Printf("\n");
}
}
if (x)
OSD_Printf("\n");
}
return OSDCMD_OK;
}
@ -377,6 +457,7 @@ void OSD_Init(void)
OSD_RegisterFunction("clear","clear: clears the console text buffer",_internal_osdfunc_clear);
OSD_RegisterFunction("alias","alias: creates an alias for calling multiple commands",_internal_osdfunc_alias);
OSD_RegisterFunction("unalias","unalias: removes an alias created with \"alias\"",_internal_osdfunc_unalias);
OSD_RegisterFunction("exec","exec <scriptfile>: executes a script", _internal_osdfunc_exec);
atexit(OSD_Cleanup);
}
@ -548,14 +629,33 @@ int OSD_HandleKey(int sc, int press)
if (findsymbol(osdedittmp, tabc->next))
{
symbol_t *symb=tabc;
int maxwidth = 0, x = 0;
OSD_Printf("Matching symbols:\n");
OSD_Printf("Completions for '%s':\n",osdedittmp);
while (symb && symb != lastmatch)
{
OSD_Printf(" %s\n", symb->name);
maxwidth = max((unsigned)maxwidth,Bstrlen(symb->name));
lastmatch = symb;
symb=findsymbol(osdedittmp, lastmatch->next);
}
maxwidth += 3;
symb = tabc;
OSD_Printf(" ");
while (symb && symb != lastmatch)
{
OSD_Printf("%-*s",maxwidth,symb->name);
x += maxwidth;
lastmatch = symb;
symb=findsymbol(osdedittmp, lastmatch->next);
if (x > osdcols - maxwidth)
{
x = 0;
OSD_Printf("\n");
OSD_Printf(" ");
}
}
if (x)
OSD_Printf("\n");
}
}
}

View file

@ -6941,38 +6941,6 @@ static int osdcmd_gamma(const osdfuncparm_t *parm)
return OSDCMD_OK;
}
static int load_script(const char *szScript)
{
FILE* fp = fopenfrompath(szScript, "r");
if (fp != NULL)
{
char line[255];
OSD_Printf("Executing \"%s\"\n", szScript);
while (fgets(line ,sizeof(line)-1, fp) != NULL)
OSD_Dispatch(strtok(line,"\r\n"));
fclose(fp);
return 0;
}
return 1;
}
static int osdcmd_exec(const osdfuncparm_t *parm)
{
char fn[BMAX_PATH];
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
Bstrcpy(fn,parm->parms[0]);
if (load_script(fn))
{
OSD_Printf("exec: file \"%s\" not found.\n", fn);
return OSDCMD_OK;
}
return OSDCMD_OK;
}
static int osdcmd_noclip(const osdfuncparm_t *parm)
{
UNREFERENCED_PARAMETER(parm);
@ -7035,7 +7003,6 @@ static int registerosdcommands(void)
OSD_RegisterFunction("echo","echo [text]: echoes text to the console", osdcmd_echo);
OSD_RegisterFunction("editorgridextent","editorgridextent: sets the size of the 2D mode editing grid",osdcmd_editorgridextent);
OSD_RegisterFunction("exec","exec <scriptfile>: executes a script", osdcmd_exec);
OSD_RegisterFunction("fileinfo","fileinfo <file>: gets a file's information", osdcmd_fileinfo);

View file

@ -199,7 +199,11 @@ void CONFIG_SetDefaults(void)
ud.config.AutoAim = 1;
ud.config.FXDevice = 0;
ud.config.FXVolume = 220;
#if defined(_WIN32)
ud.config.MixRate = 44100;
#else
ud.config.MixRate = 48000;
#endif
ud.config.MouseBias = 0;
ud.config.MouseFilter = 0;
ud.config.MusicDevice = 0;

View file

@ -238,7 +238,6 @@ extern void sendboardname(void);
extern void sendquit(void);
extern void adduserquote(const char *daquote);
extern const char *stripcolorcodes(const char *t);
extern void mpchangemap(int volume, int level);
extern inline int checkspriteflags(int iActor, int iType);

View file

@ -384,26 +384,6 @@ void setgamepalette(player_struct *player, char *pal, int set)
#define TEXTWRAPLEN (scale(35,ud.config.ScreenWidth,320))
const char *stripcolorcodes(const char *t)
{
int i = 0;
static char colstrip[1024];
while (*t)
{
if (*t == '^' && isdigit(*(t+1)))
{
t += 2;
if (isdigit(*t))
t++;
continue;
}
colstrip[i] = *t;
i++,t++;
}
colstrip[i] = '\0';
return(colstrip);
}
int gametext_(int small, int starttile, int x,int y,const char *t,int s,int p,int orientation,int x1, int y1, int x2, int y2)
{
return gametext_z(small,starttile,x,y,t,s,p,orientation,x1,y1,x2,y2,65536);
@ -2692,6 +2672,7 @@ static void showtwoscreens(void)
}
extern int qsetmode;
extern int doquicksave;
void gameexit(const char *t)
{
@ -7810,31 +7791,13 @@ FOUNDCHEAT:
}
}
int load_script(const char *szScript)
{
FILE* fp = fopenfrompath(szScript, "r");
if (fp != NULL)
{
char line[255];
extern int cmdfromscript;
OSD_Printf("Executing \"%s\"\n", szScript);
cmdfromscript = 1;
while (fgets(line ,sizeof(line)-1, fp) != NULL)
OSD_Dispatch(strtok(line,"\r\n"));
cmdfromscript = 0;
fclose(fp);
return 0;
}
return 1;
}
static void nonsharedkeys(void)
{
int i,ch;
int j;
CONTROL_ProcessBinds();
if (ud.recstat == 2)
{
ControlInfo noshareinfo;
@ -7843,12 +7806,12 @@ static void nonsharedkeys(void)
if (g_player[myconnectindex].gotvote == 0 && voting != -1 && voting != myconnectindex)
{
if (KB_KeyPressed(sc_F1) || KB_KeyPressed(sc_F2) || ud.autovote)
if (KB_UnBoundKeyPressed(sc_F1) || KB_UnBoundKeyPressed(sc_F2) || ud.autovote)
{
tempbuf[0] = 18;
tempbuf[1] = 0;
tempbuf[2] = myconnectindex;
tempbuf[3] = (KB_KeyPressed(sc_F1) || ud.autovote?ud.autovote-1:0);
tempbuf[3] = (KB_UnBoundKeyPressed(sc_F1) || ud.autovote?ud.autovote-1:0);
for (i=connecthead;i >= 0;i=connectpoint2[i])
{
@ -7958,52 +7921,52 @@ static void nonsharedkeys(void)
if (SHIFTS_IS_PRESSED || ALT_IS_PRESSED)
{
i = 0;
if (KB_KeyPressed(sc_F1))
if (KB_UnBoundKeyPressed(sc_F1))
{
KB_ClearKeyDown(sc_F1);
i = 1;
}
if (KB_KeyPressed(sc_F2))
if (KB_UnBoundKeyPressed(sc_F2))
{
KB_ClearKeyDown(sc_F2);
i = 2;
}
if (KB_KeyPressed(sc_F3))
if (KB_UnBoundKeyPressed(sc_F3))
{
KB_ClearKeyDown(sc_F3);
i = 3;
}
if (KB_KeyPressed(sc_F4))
if (KB_UnBoundKeyPressed(sc_F4))
{
KB_ClearKeyDown(sc_F4);
i = 4;
}
if (KB_KeyPressed(sc_F5))
if (KB_UnBoundKeyPressed(sc_F5))
{
KB_ClearKeyDown(sc_F5);
i = 5;
}
if (KB_KeyPressed(sc_F6))
if (KB_UnBoundKeyPressed(sc_F6))
{
KB_ClearKeyDown(sc_F6);
i = 6;
}
if (KB_KeyPressed(sc_F7))
if (KB_UnBoundKeyPressed(sc_F7))
{
KB_ClearKeyDown(sc_F7);
i = 7;
}
if (KB_KeyPressed(sc_F8))
if (KB_UnBoundKeyPressed(sc_F8))
{
KB_ClearKeyDown(sc_F8);
i = 8;
}
if (KB_KeyPressed(sc_F9))
if (KB_UnBoundKeyPressed(sc_F9))
{
KB_ClearKeyDown(sc_F9);
i = 9;
}
if (KB_KeyPressed(sc_F10))
if (KB_UnBoundKeyPressed(sc_F10))
{
KB_ClearKeyDown(sc_F10);
i = 10;
@ -8099,7 +8062,7 @@ static void nonsharedkeys(void)
inputloc = 0;
}
if (KB_KeyPressed(sc_F1) || (ud.show_help && (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || MOUSE_GetButtons()&LEFT_MOUSE)))
if (KB_UnBoundKeyPressed(sc_F1) || (ud.show_help && (KB_KeyPressed(sc_Space) || KB_KeyPressed(sc_Enter) || KB_KeyPressed(sc_kpad_Enter) || MOUSE_GetButtons()&LEFT_MOUSE)))
{
KB_ClearKeyDown(sc_F1);
KB_ClearKeyDown(sc_Space);
@ -8127,7 +8090,7 @@ static void nonsharedkeys(void)
// if(ud.multimode < 2)
{
if (ud.recstat != 2 && KB_KeyPressed(sc_F2))
if (ud.recstat != 2 && KB_UnBoundKeyPressed(sc_F2))
{
KB_ClearKeyDown(sc_F2);
@ -8159,7 +8122,7 @@ FAKE_F2:
}
}
if (KB_KeyPressed(sc_F3))
if (KB_UnBoundKeyPressed(sc_F3))
{
KB_ClearKeyDown(sc_F3);
@ -8181,7 +8144,7 @@ FAKE_F3:
}
}
if (KB_KeyPressed(sc_F4) && ud.config.FXDevice >= 0)
if (KB_UnBoundKeyPressed(sc_F4) && ud.config.FXDevice >= 0)
{
KB_ClearKeyDown(sc_F4);
FX_StopAllSounds();
@ -8197,9 +8160,10 @@ FAKE_F3:
}
if (KB_KeyPressed(sc_F6) && (g_player[myconnectindex].ps->gm&MODE_GAME))
if ((KB_UnBoundKeyPressed(sc_F6) || doquicksave == 1) && (g_player[myconnectindex].ps->gm&MODE_GAME))
{
KB_ClearKeyDown(sc_F6);
doquicksave = 0;
if (movesperpacket == 4 && connecthead != myconnectindex)
return;
@ -8228,7 +8192,7 @@ FAKE_F3:
}
}
if (KB_KeyPressed(sc_F7))
if (KB_UnBoundKeyPressed(sc_F7))
{
KB_ClearKeyDown(sc_F7);
if (g_player[myconnectindex].ps->over_shoulder_on)
@ -8242,7 +8206,7 @@ FAKE_F3:
FTA(109+g_player[myconnectindex].ps->over_shoulder_on,g_player[myconnectindex].ps);
}
if (KB_KeyPressed(sc_F5) && ud.config.MusicDevice >= 0)
if (KB_UnBoundKeyPressed(sc_F5) && ud.config.MusicDevice >= 0)
{
KB_ClearKeyDown(sc_F5);
if (map[(unsigned char)music_select].musicfn1 != NULL)
@ -8256,7 +8220,7 @@ FAKE_F3:
FTA(26,g_player[myconnectindex].ps);
}
if (KB_KeyPressed(sc_F8))
if (KB_UnBoundKeyPressed(sc_F8))
{
KB_ClearKeyDown(sc_F8);
ud.fta_on = !ud.fta_on;
@ -8269,9 +8233,10 @@ FAKE_F3:
}
}
if (KB_KeyPressed(sc_F9) && (g_player[myconnectindex].ps->gm&MODE_GAME))
if ((KB_UnBoundKeyPressed(sc_F9) || doquicksave == 2) && (g_player[myconnectindex].ps->gm&MODE_GAME))
{
KB_ClearKeyDown(sc_F9);
doquicksave = 0;
if (movesperpacket == 4 && myconnectindex != connecthead)
return;
@ -8298,7 +8263,7 @@ FAKE_F3:
}
}
if (KB_KeyPressed(sc_F10))
if (KB_UnBoundKeyPressed(sc_F10))
{
KB_ClearKeyDown(sc_F10);
cmenu(500);
@ -8365,7 +8330,7 @@ FAKE_F3:
vscrn();
}
if (KB_KeyPressed(sc_F11))
if (KB_UnBoundKeyPressed(sc_F11))
{
KB_ClearKeyDown(sc_F11);
ud.brightness+=8;
@ -10657,8 +10622,8 @@ void app_main(int argc,const char **argv)
FX_StopAllSounds();
clearsoundlocks();
load_script("autoexec.cfg");
load_script("binds.cfg");
OSD_Exec("autoexec.cfg");
OSD_Exec("binds.cfg");
if (ud.warp_on > 1 && ud.multimode < 2)
{

View file

@ -179,3 +179,5 @@ char cheatkey[2] = { sc_D, sc_N };
char setupfilename[BMAX_PATH]= "duke3d.cfg";
char datetimestring[] = ""__DATE__" "__TIME__"";
int doquicksave = 0;

View file

@ -55,6 +55,8 @@ static boolean CONTROL_Started = false;
static int32 ticrate;
static int32 CONTROL_DoubleClickSpeed;
int extinput[CONTROL_NUM_FLAGS];
keybind boundkeys[MAXBOUNDKEYS];
void CONTROL_GetMouseDelta(void)
{
@ -844,9 +846,6 @@ void CONTROL_ClearButton(int32 whichbutton)
CONTROL_Flags[whichbutton].cleared = true;
}
int extinput[CONTROL_NUM_FLAGS];
keybind boundkeys[MAXBOUNDKEYS];
void CONTROL_ProcessBinds(void)
{
int i;

View file

@ -199,6 +199,7 @@ extern kb_scancode KB_LastScan;
#define KB_ClearKeyDown( scan ) { keystatus[ ( scan ) ] = FALSE; }
#define KB_UnBoundKeyPressed( scan ) ( keystatus[ ( scan ) ] != 0 && !boundkeys[scan].name[0])
/*
=============================================================================

View file

@ -30,9 +30,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "crc32.h"
#include <ctype.h>
extern int voting;
extern int voting, doquicksave;
struct osdcmd_cheatsinfo osdcmd_cheatsinfo_stat;
int cmdfromscript = 0;
static inline int osdcmd_quit(const osdfuncparm_t *parm)
{
@ -629,22 +628,6 @@ static int osdcmd_cmenu(const osdfuncparm_t *parm)
return OSDCMD_OK;
}
static int osdcmd_exec(const osdfuncparm_t *parm)
{
char fn[BMAX_PATH];
extern int load_script(char *szStartupScript);
if (parm->numparms != 1) return OSDCMD_SHOWHELP;
Bstrcpy(fn,parm->parms[0]);
if (load_script(fn))
{
OSD_Printf("exec: file \"%s\" not found.\n", fn);
return OSDCMD_OK;
}
return OSDCMD_OK;
}
cvarmappings cvar[] =
{
{ "crosshair", "crosshair: enable/disable crosshair", (void*)&ud.crosshair, CVAR_INT, 0, 0, 3 },
@ -982,22 +965,27 @@ static int osdcmd_bind(const osdfuncparm_t *parm)
else boundkeys[keynames[i].id].repeat = 1;
Bstrncpy(boundkeys[keynames[i].id].name,parm->parms[j], MAXBINDSTRINGLENGTH-1);
boundkeys[keynames[i].id].key=keynames[i].name;
if (!cmdfromscript)
if (!osdexecscript)
OSD_Printf("%s\n",parm->raw);
return OSDCMD_OK;
}
static int osdcmd_unbindall(const osdfuncparm_t *parm)
{
int i;
UNREFERENCED_PARAMETER(parm);
for (i=0;i<MAXBOUNDKEYS;i++)if (*boundkeys[i].name)
boundkeys[i].name[0] = 0;
OSD_Printf("unbound all keys\n");
return OSDCMD_OK;
}
static int osdcmd_unbind(const osdfuncparm_t *parm)
{
int i;
if (parm->numparms==1&&!Bstrcasecmp(parm->parms[0],"all"))
{
for (i=0;i<MAXBOUNDKEYS;i++)if (*boundkeys[i].name)
boundkeys[i].name[0] = 0;
OSD_Printf("unbound all keys\n");
return OSDCMD_OK;
}
if (parm->numparms < 1) return OSDCMD_SHOWHELP;
for (i=0;keynames[i].name;i++)
if (!Bstrcasecmp(parm->parms[0],keynames[i].name))
@ -1010,6 +998,24 @@ static int osdcmd_unbind(const osdfuncparm_t *parm)
return OSDCMD_OK;
}
static int osdcmd_quicksave(const osdfuncparm_t *parm)
{
UNREFERENCED_PARAMETER(parm);
if (!(g_player[myconnectindex].ps->gm & MODE_GAME))
OSD_Printf("quicksave: not in a game.\n");
else doquicksave = 1;
return OSDCMD_OK;
}
static int osdcmd_quickload(const osdfuncparm_t *parm)
{
UNREFERENCED_PARAMETER(parm);
if (!(g_player[myconnectindex].ps->gm & MODE_GAME))
OSD_Printf("quickload: not in a game.\n");
else doquicksave = 2;
return OSDCMD_OK;
}
int registerosdcommands(void)
{
unsigned int i;
@ -1031,14 +1037,24 @@ int registerosdcommands(void)
OSD_RegisterFunction("addpath","addpath <path>: adds path to game filesystem", osdcmd_addpath);
OSD_RegisterFunction("bind","bind <key> <string>: associates a keypress with a string of console input. Type \"bind showkeys\" for a list of keys and \"listsymbols\" for a list of valid console commands.", osdcmd_bind);
OSD_RegisterFunction("cl_statusbarscale","cl_statusbarscale: changes the status bar scale", osdcmd_setstatusbarscale);
OSD_RegisterFunction("cmenu","cmenu <#>: jumps to menu", osdcmd_cmenu);
OSD_RegisterFunction("echo","echo [text]: echoes text to the console", osdcmd_echo);
OSD_RegisterFunction("exec","exec <scriptfile>: executes a script", osdcmd_exec);
OSD_RegisterFunction("fileinfo","fileinfo <file>: gets a file's information", osdcmd_fileinfo);
for (i=0;i<NUMGAMEFUNCTIONS;i++)
{
char *t;
Bsprintf(tempbuf,"gamefunc_%s",gamefunctions[i]);
t = Bstrdup(tempbuf);
Bstrcat(tempbuf,": game button");
OSD_RegisterFunction(t,Bstrdup(tempbuf),osdcmd_button);
}
OSD_RegisterFunction("gamma","gamma <value>: changes brightness", osdcmd_gamma);
OSD_RegisterFunction("give","give <all|health|weapons|ammo|armor|keys|inventory>: gives requested item", osdcmd_give);
OSD_RegisterFunction("god","god: toggles god mode", osdcmd_god);
@ -1048,6 +1064,8 @@ int registerosdcommands(void)
OSD_RegisterFunction("name","name: change your multiplayer nickname", osdcmd_name);
OSD_RegisterFunction("noclip","noclip: toggles clipping mode", osdcmd_noclip);
OSD_RegisterFunction("quicksave","quicksave: performs a quick save", osdcmd_quicksave);
OSD_RegisterFunction("quickload","quickload: performs a quick load", osdcmd_quickload);
OSD_RegisterFunction("quit","quit: exits the game immediately", osdcmd_quit);
OSD_RegisterFunction("rate","rate: sets the multiplayer packet send rate, in packets/sec",osdcmd_rate);
@ -1060,21 +1078,14 @@ int registerosdcommands(void)
OSD_RegisterFunction("setactorvar","setactorvar <actorID> <gamevar> <value>: sets the value of a gamevar", osdcmd_setactorvar);
OSD_RegisterFunction("spawn","spawn <picnum> [palnum] [cstat] [ang] [x y z]: spawns a sprite with the given properties",osdcmd_spawn);
OSD_RegisterFunction("unbind","unbind <key>: unbinds a key.", osdcmd_unbind);
OSD_RegisterFunction("unbindall","unbindall: unbinds all keys.", osdcmd_unbindall);
OSD_RegisterFunction("usejoystick","usejoystick: enables input from the joystick if it is present",osdcmd_usemousejoy);
OSD_RegisterFunction("usemouse","usemouse: enables input from the mouse if it is present",osdcmd_usemousejoy);
OSD_RegisterFunction("vidmode","vidmode [xdim ydim] [bpp] [fullscreen]: immediately change the video mode",osdcmd_vidmode);
OSD_RegisterFunction("bind","bind <key> <string>: associates a keypress with a string of console input. Type \"bind showkeys\" for a list of keys and \"listsymbols\" for a list of valid console commands.", osdcmd_bind);
OSD_RegisterFunction("unbind","unbind <key>: unbinds a key. Type \"unbind all\" to unbind all keys.", osdcmd_unbind);
for (i=0;i<NUMGAMEFUNCTIONS;i++)
{
char *t;
Bsprintf(tempbuf,"gamefunc_%s",gamefunctions[i]);
t = Bstrdup(tempbuf);
Bstrcat(tempbuf,": game button");
OSD_RegisterFunction(t,Bstrdup(tempbuf),osdcmd_button);
}
//baselayer_onvideomodechange = onvideomodechange;
return 0;

View file

@ -13,23 +13,48 @@ void GAME_drawosdchar(int x, int y, char ch, int shade, int pal)
rotatesprite(((x<<3)+x)<<16, (y<<3)<<16, 65536l, 0, ac, shade, pal, 8|16, 0, 0, xdim-1, ydim-1);
}
#define OSDCHAR_WIDTH 8
void GAME_drawosdstr(int x, int y, char *ch, int len, int shade, int pal)
{
short ac;
for (x = (x<<3)+x; len>0; len--, ch++, x++)
{
/*
if (*ch == '^' && isdigit(*(ch+1)))
{
char smallbuf[4];
ch++;
if (isdigit(*(ch+1)))
{
smallbuf[0] = *(ch++);
smallbuf[1] = *(ch);
smallbuf[2] = '\0';
pal = atol(smallbuf);
}
else
{
smallbuf[0] = *(ch);
smallbuf[1] = '\0';
pal = atol(smallbuf);
}
continue;
}
*/
if (*ch == 32)
{
x+=5;
// x+=5;
x += OSDCHAR_WIDTH;
continue;
}
ac = *ch-'!'+STARTALPHANUM;
if (ac < STARTALPHANUM || ac > ENDALPHANUM) return;
rotatesprite(x<<16, (y<<3)<<16, 65536l, 0, ac, shade, pal, 8|16, 0, 0, xdim-1, ydim-1);
if (*ch >= '0' && *ch <= '9') x+=8;
else x += tilesizx[ac];
/* if (*ch >= '0' && *ch <= '9') x+=8;
else x += tilesizx[ac]; */
x += OSDCHAR_WIDTH;
}
}