mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Patch from hunter_rus.
Adds: - maximal log line count and OSD variable "logcutoff" - ability to define different models for each palette - "bind" OSD command to bind keys so that they run command batch files git-svn-id: https://svn.eduke32.com/eduke32@591 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
cfa399998a
commit
a8a675634e
5 changed files with 200 additions and 23 deletions
|
@ -201,8 +201,13 @@ static tile2model_t tile2model[MAXTILES+EXTRATILES];
|
|||
int addtileP(int model,int tile,int pallet)
|
||||
{
|
||||
if (curextra==MAXTILES+EXTRATILES-2)return curextra;
|
||||
if (tile2model[tile].modelid==-1)return tile;
|
||||
while (tile2model[tile].next!=-1)tile=tile2model[tile].next;
|
||||
if (tile2model[tile].modelid==-1){tile2model[tile].pal=pallet;return tile;}
|
||||
if (tile2model[tile].pal==pallet)return tile;
|
||||
while(tile2model[tile].next!=-1)
|
||||
{
|
||||
tile=tile2model[tile].next;
|
||||
if(tile2model[tile].pal==pallet)return tile;
|
||||
}
|
||||
tile2model[tile].next=curextra;
|
||||
tile2model[curextra].pal=pallet;
|
||||
return curextra++;
|
||||
|
|
|
@ -88,6 +88,10 @@ static int osdhistorysize=0; // number of entries in history
|
|||
// the execution buffer works from the command history
|
||||
static int osdexeccount=0; // number of lines from the head of the history buffer to execute
|
||||
|
||||
// maximal log line count
|
||||
int logcutoff=120000;
|
||||
int linecnt;
|
||||
|
||||
// presentation parameters
|
||||
static int osdpromptshade=0;
|
||||
static int osdpromptpal=0;
|
||||
|
@ -210,7 +214,14 @@ static int _internal_osdfunc_vars(const osdfuncparm_t *parm)
|
|||
osdrows = atoi(parm->parms[0]);
|
||||
if (osdrows < 1) osdrows = 1;
|
||||
else if (osdrows > osdmaxrows) osdrows = osdmaxrows;
|
||||
osdrowscur = osdrows;
|
||||
if(osdrowscur!=-1)osdrowscur = osdrows;
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
} else
|
||||
if (!Bstrcasecmp(parm->name, "logcutoff")) {
|
||||
if (showval) { OSD_Printf("logcutoff is %d\n", logcutoff); return OSDCMD_OK; }
|
||||
else {
|
||||
logcutoff = atoi(parm->parms[0]);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
}
|
||||
|
@ -289,6 +300,7 @@ void OSD_Init(void)
|
|||
OSD_RegisterFunction("listsymbols","listsymbols: lists all the recognized symbols",_internal_osdfunc_listsymbols);
|
||||
OSD_RegisterFunction("help","help: displays help on the named symbol",_internal_osdfunc_help);
|
||||
OSD_RegisterFunction("osdrows","osdrows: sets the number of visible lines of the OSD",_internal_osdfunc_vars);
|
||||
OSD_RegisterFunction("logcutoff","logcutoff: sets the maximal line count of the log file",_internal_osdfunc_vars);
|
||||
OSD_RegisterFunction("clear","clear: clears the console text buffer",_internal_osdfunc_clear);
|
||||
|
||||
atexit(OSD_Cleanup);
|
||||
|
@ -861,7 +873,7 @@ void OSD_Draw(void)
|
|||
while (j > -1)
|
||||
{
|
||||
osdrowscur++;
|
||||
j -= 10;
|
||||
j -= 200/osdrows;
|
||||
if (osdrowscur > osdrows-1)
|
||||
break;
|
||||
}
|
||||
|
@ -872,7 +884,7 @@ void OSD_Draw(void)
|
|||
while (j > -1)
|
||||
{
|
||||
osdrowscur--;
|
||||
j -= 10;
|
||||
j -= 200/osdrows;
|
||||
if (osdrowscur < 1)
|
||||
break;
|
||||
}
|
||||
|
@ -937,7 +949,17 @@ void OSD_Printf(const char *fmt, ...)
|
|||
Bvsnprintf(tmpstr, 1024, fmt, va);
|
||||
va_end(va);
|
||||
|
||||
if (osdlog) Bfputs(tmpstr, osdlog);
|
||||
if(linecnt<logcutoff)
|
||||
{
|
||||
if (osdlog&&(!logcutoff||linecnt<logcutoff))
|
||||
Bfputs(tmpstr, osdlog);
|
||||
}
|
||||
else if(linecnt==logcutoff)
|
||||
{
|
||||
Bfputs("\nMaximal log size reached. Logging stopped.\nSet the \"logcutoff\" console variable to a higher value if you need a longer log.\n", osdlog);
|
||||
linecnt=logcutoff+1;
|
||||
}
|
||||
|
||||
|
||||
for (chp = tmpstr; *chp; chp++)
|
||||
{
|
||||
|
@ -945,6 +967,7 @@ void OSD_Printf(const char *fmt, ...)
|
|||
else if (*chp == '\n')
|
||||
{
|
||||
osdpos=0;
|
||||
linecnt++;
|
||||
linefeed();
|
||||
}
|
||||
else
|
||||
|
|
|
@ -989,6 +989,24 @@ extern playerspawn_t g_PlayerSpawnPoints[MAXPLAYERS];
|
|||
extern playerdata_t g_player[MAXPLAYERS];
|
||||
#include "funct.h"
|
||||
|
||||
// key bindings stuff
|
||||
#define MAXSCRIPTFILENAMELENGTH 32
|
||||
#define MAXBOUNDKEYS 256
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
int id;
|
||||
} keydef;
|
||||
|
||||
extern keydef keynames[];
|
||||
|
||||
typedef struct binding {
|
||||
char name[MAXSCRIPTFILENAMELENGTH];
|
||||
char *key;
|
||||
} keybind;
|
||||
|
||||
extern keybind boundkeys[MAXBOUNDKEYS];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -147,6 +147,104 @@ static char recbuf[180];
|
|||
|
||||
extern void computergetinput(int snum, input *syn);
|
||||
|
||||
keydef keynames[]=
|
||||
{
|
||||
{"COMMA", sc_Comma},
|
||||
{"PERIOD", sc_Period},
|
||||
{"ENTER", sc_Enter},
|
||||
{"ESCAPE", sc_Escape},
|
||||
{"SPACE", sc_Space},
|
||||
{"BACKSPACE", sc_BackSpace},
|
||||
{"TAB", sc_Tab},
|
||||
{"LEFTALT", sc_LeftAlt},
|
||||
{"LEFTCONTROL", sc_LeftControl},
|
||||
{"CAPSLOCK", sc_CapsLock},
|
||||
{"LEFTSHIFT", sc_LeftShift},
|
||||
{"RIGHTSHIFT", sc_RightShift},
|
||||
{"F1", sc_F1},
|
||||
{"F2", sc_F2},
|
||||
{"F3", sc_F3},
|
||||
{"F4", sc_F4},
|
||||
{"F5", sc_F5},
|
||||
{"F6", sc_F6},
|
||||
{"F7", sc_F7},
|
||||
{"F8", sc_F8},
|
||||
{"F9", sc_F9},
|
||||
{"F10", sc_F10},
|
||||
{"F11", sc_F11},
|
||||
{"F12", sc_F12},
|
||||
{"KPAD_STAR", sc_Kpad_Star},
|
||||
{"PAUSE", sc_Pause},
|
||||
{"SCROLLLOCK", sc_ScrollLock},
|
||||
{"NUMLOCK", sc_NumLock},
|
||||
{"SLASH", sc_Slash},
|
||||
{"SEMICOLON", sc_SemiColon},
|
||||
{"QUOTE", sc_Quote},
|
||||
{"TILDE", sc_Tilde},
|
||||
{"BACKSLASH", sc_BackSlash},
|
||||
|
||||
{"OPENBRACKET", sc_OpenBracket},
|
||||
{"CLOSEBRACKET",sc_CloseBracket},
|
||||
|
||||
{"1", sc_1},
|
||||
{"2", sc_2},
|
||||
{"3", sc_3},
|
||||
{"4", sc_4},
|
||||
{"5", sc_5},
|
||||
{"6", sc_6},
|
||||
{"7", sc_7},
|
||||
{"8", sc_8},
|
||||
{"9", sc_9},
|
||||
{"0", sc_0},
|
||||
{"MINUS", sc_Minus},
|
||||
{"EQUALS", sc_Equals},
|
||||
{"PLUS", sc_Plus},
|
||||
|
||||
{"KPAD_1", sc_kpad_1},
|
||||
{"KPAD_2", sc_kpad_2},
|
||||
{"KPAD_3", sc_kpad_3},
|
||||
{"KPAD_4", sc_kpad_4},
|
||||
{"KPAD_5", sc_kpad_5},
|
||||
{"KPAD_6", sc_kpad_6},
|
||||
{"KPAD_7", sc_kpad_7},
|
||||
{"KPAD_8", sc_kpad_8},
|
||||
{"KPAD_9", sc_kpad_9},
|
||||
{"KPAD_0", sc_kpad_0},
|
||||
{"KPAD_MINUS", sc_kpad_Minus},
|
||||
{"KPAD_PLUS", sc_kpad_Plus},
|
||||
{"KPAD_PERIOD", sc_kpad_Period},
|
||||
|
||||
{"A", sc_A},
|
||||
{"B", sc_B},
|
||||
{"C", sc_C},
|
||||
{"D", sc_D},
|
||||
{"E", sc_E},
|
||||
{"F", sc_F},
|
||||
{"G", sc_G},
|
||||
{"H", sc_H},
|
||||
{"I", sc_I},
|
||||
{"J", sc_J},
|
||||
{"K", sc_K},
|
||||
{"L", sc_L},
|
||||
{"M", sc_M},
|
||||
{"N", sc_N},
|
||||
{"O", sc_O},
|
||||
{"P", sc_P},
|
||||
{"Q", sc_Q},
|
||||
{"R", sc_R},
|
||||
{"S", sc_S},
|
||||
{"T", sc_T},
|
||||
{"U", sc_U},
|
||||
{"V", sc_V},
|
||||
{"W", sc_W},
|
||||
{"X", sc_X},
|
||||
{"Y", sc_Y},
|
||||
{"Z", sc_Z},
|
||||
{0,0}
|
||||
};
|
||||
|
||||
keybind boundkeys[MAXBOUNDKEYS];
|
||||
|
||||
enum
|
||||
{
|
||||
T_EOF = -2,
|
||||
|
@ -7671,11 +7769,34 @@ FOUNDCHEAT:
|
|||
}
|
||||
}
|
||||
|
||||
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 void nonsharedkeys(void)
|
||||
{
|
||||
int i,ch;
|
||||
int j;
|
||||
|
||||
for(i=0;i<256;i++)
|
||||
if (*boundkeys[i].name&&KB_KeyPressed(i))
|
||||
{
|
||||
load_script(boundkeys[i].name);
|
||||
KB_ClearKeyDown(i);
|
||||
}
|
||||
if (ud.recstat == 2)
|
||||
{
|
||||
ControlInfo noshareinfo;
|
||||
|
@ -9823,23 +9944,6 @@ void backtomenu(void)
|
|||
else wm_setapptitle(HEAD);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void app_main(int argc,const char **argv)
|
||||
{
|
||||
int i, j;
|
||||
|
|
|
@ -943,6 +943,32 @@ static int osdcmd_name(const osdfuncparm_t *parm)
|
|||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
static int osdcmd_bind(const osdfuncparm_t *parm)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (parm->numparms==1&&!strcmpi(parm->parms[0],"showkeys"))
|
||||
{
|
||||
for(i=0;keynames[i].name;i++)OSD_Printf("%s\n",keynames[i].name);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
if (parm->numparms==0)
|
||||
{
|
||||
OSD_Printf("Keybindings:\n");
|
||||
for(i=0;i<MAXBOUNDKEYS;i++)if(*boundkeys[i].name)
|
||||
OSD_Printf("%-11s = %s\n",boundkeys[i].key,boundkeys[i].name);
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
if (parm->numparms < 2) return OSDCMD_SHOWHELP;
|
||||
for(i=0;keynames[i].name;i++)if(!strcmpi(parm->parms[0],keynames[i].name))break;
|
||||
if (!keynames[i].name) return OSDCMD_SHOWHELP;
|
||||
|
||||
Bstrncpy(boundkeys[keynames[i].id].name,parm->parms[1], MAXSCRIPTFILENAMELENGTH-1);
|
||||
boundkeys[keynames[i].id].key=keynames[i].name;
|
||||
return OSDCMD_OK;
|
||||
}
|
||||
|
||||
int registerosdcommands(void)
|
||||
{
|
||||
unsigned int i;
|
||||
|
@ -998,6 +1024,7 @@ int registerosdcommands(void)
|
|||
|
||||
OSD_RegisterFunction("vidmode","vidmode [xdim ydim] [bpp] [fullscreen]: immediately change the video mode",osdcmd_vidmode);
|
||||
|
||||
OSD_RegisterFunction("bind","bind <key> <scriptfile>: executes a command script when <key> gets pressed. Type \"bind showkeys\" for a list of keys.", osdcmd_bind);
|
||||
//baselayer_onvideomodechange = onvideomodechange;
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue