mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
WIP OSD refactor, committing now before it stops applying cleanly to current svn. This shouldn't break anything in an obvious or major way.
git-svn-id: https://svn.eduke32.com/eduke32@4536 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
d7a3f8e78a
commit
06072db493
5 changed files with 595 additions and 517 deletions
|
@ -9,6 +9,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "mutex.h"
|
||||
|
||||
typedef struct {
|
||||
int32_t numparms;
|
||||
const char *name;
|
||||
|
@ -18,6 +20,16 @@ typedef struct {
|
|||
|
||||
const char *OSD_StripColors(char *out, const char *in);
|
||||
|
||||
#define OSDDEFAULTMAXLINES 128
|
||||
#define OSDEDITLENGTH 512
|
||||
#define OSDMINHISTORYDEPTH 32
|
||||
#define OSDMAXHISTORYDEPTH 256
|
||||
#define OSDBUFFERSIZE 32768
|
||||
#define OSDDEFAULTROWS 20
|
||||
#define OSDDEFAULTCOLS 60
|
||||
#define OSDLOGCUTOFF 131072
|
||||
#define OSDMAXSYMBOLS 512
|
||||
|
||||
enum cvartype_t
|
||||
{
|
||||
CVAR_FLOAT = 0x00000001,
|
||||
|
@ -35,6 +47,15 @@ enum cvartype_t
|
|||
CVAR_INVALIDATEART = 0x00001000,
|
||||
};
|
||||
|
||||
typedef struct _symbol
|
||||
{
|
||||
const char *name;
|
||||
struct _symbol *next;
|
||||
|
||||
const char *help;
|
||||
int32_t(*func)(const osdfuncparm_t *);
|
||||
} symbol_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char *name;
|
||||
|
@ -59,9 +80,97 @@ typedef struct
|
|||
} dval;
|
||||
} osdcvar_t;
|
||||
|
||||
// version string
|
||||
typedef struct
|
||||
{
|
||||
char *buf;
|
||||
|
||||
uint8_t len;
|
||||
uint8_t shade;
|
||||
uint8_t pal;
|
||||
} osdstr_t;
|
||||
|
||||
// command prompt editing
|
||||
typedef struct
|
||||
{
|
||||
char *buf;// [OSDEDITLENGTH+1]; // editing buffer
|
||||
char *tmp;// [OSDEDITLENGTH+1]; // editing buffer temporary workspace
|
||||
|
||||
int16_t len, pos; // length of characters and position of cursor in buffer
|
||||
int16_t start, end;
|
||||
} osdedit_t;
|
||||
|
||||
// main text buffer
|
||||
typedef struct
|
||||
{
|
||||
// each character in the buffer also has a format byte containing shade and color
|
||||
char *buf;
|
||||
char *fmt;
|
||||
|
||||
int32_t pos; // position next character will be written at
|
||||
int32_t lines; // total number of lines in buffer
|
||||
int32_t maxlines; // max lines in buffer
|
||||
} osdtext_t;
|
||||
|
||||
// history display
|
||||
typedef struct
|
||||
{
|
||||
char *buf[OSDMAXHISTORYDEPTH];
|
||||
|
||||
int32_t maxlines; // max entries in buffer, ranges from OSDMINHISTORYDEPTH to OSDMAXHISTORYDEPTH
|
||||
int32_t pos; // current buffer position
|
||||
int32_t lines; // entries currently in buffer
|
||||
int32_t total; // total number of entries
|
||||
int32_t exec; // number of lines from the head of the history buffer to execute
|
||||
} osdhist_t;
|
||||
|
||||
// active display parameters
|
||||
typedef struct
|
||||
{
|
||||
int32_t promptshade, promptpal;
|
||||
int32_t editshade, editpal;
|
||||
int32_t textshade, textpal;
|
||||
int32_t mode;
|
||||
|
||||
int32_t rows; // # lines of the buffer that are visible
|
||||
int32_t cols; // width of onscreen display in text columns
|
||||
int32_t head; // topmost visible line number
|
||||
} osddraw_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BFILE *fp;
|
||||
int32_t cutoff;
|
||||
int32_t errors;
|
||||
int32_t lines;
|
||||
} osdlog_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
osdtext_t text;
|
||||
osdedit_t editor;
|
||||
osdhist_t history;
|
||||
osddraw_t draw;
|
||||
osdstr_t verstr;
|
||||
|
||||
uint32_t flags; // controls initialization, etc
|
||||
osdcvar_t *cvars;
|
||||
uint32_t numcvars;
|
||||
|
||||
symbol_t *symbptrs[OSDMAXSYMBOLS];
|
||||
int32_t numsymbols;
|
||||
int32_t execdepth; // keeps track of nested execution
|
||||
mutex_t mutex;
|
||||
int32_t keycode;
|
||||
|
||||
osdlog_t log;
|
||||
} osdmain_t;
|
||||
|
||||
extern osdmain_t *osd;
|
||||
|
||||
enum osdflags_t
|
||||
{
|
||||
OSD_INITIALIZED = 0x00000001,
|
||||
// OSD_INITIALIZED = 0x00000001,
|
||||
OSD_DRAW = 0x00000002,
|
||||
OSD_CAPTURE = 0x00000004,
|
||||
OSD_OVERTYPE = 0x00000008,
|
||||
|
@ -94,6 +203,9 @@ int32_t OSD_GetRowsCur(void);
|
|||
// initializes things
|
||||
void OSD_Init(void);
|
||||
|
||||
// cleans things up. these comments are retarded.
|
||||
void OSD_Cleanup(void);
|
||||
|
||||
// sets the file to echo output to
|
||||
void OSD_SetLogFile(const char *fn);
|
||||
|
||||
|
@ -177,14 +289,7 @@ void OSD_WriteCvars(FILE *fp);
|
|||
#define OSDTEXT_BRIGHT "^S0"
|
||||
|
||||
#define OSD_ERROR OSDTEXT_DARKRED OSDTEXT_BRIGHT
|
||||
#define TEXTSIZE 32768
|
||||
|
||||
#define OSD_EDITLENGTH 511
|
||||
#define OSD_HISTORYDEPTH 32
|
||||
|
||||
extern char osdhistorybuf[OSD_HISTORYDEPTH][OSD_EDITLENGTH+1]; // history strings
|
||||
extern int32_t osdhistorysize; // number of entries in history
|
||||
extern int32_t osdhistorytotal; // number of total history entries
|
||||
|
||||
extern int32_t osdcmd_restartvid(const osdfuncparm_t *parm);
|
||||
|
||||
|
|
|
@ -260,12 +260,14 @@ int32_t loadsetup(const char *fn)
|
|||
scripthistend = i;
|
||||
|
||||
// copy script history into OSD history
|
||||
for (i=0; i<min(scripthistend, OSD_HISTORYDEPTH); i++)
|
||||
for (i=0; i<min(scripthistend, osd->history.maxlines); i++)
|
||||
{
|
||||
Bstrncpyz(osdhistorybuf[i], scripthist[scripthistend-1-i], OSD_EDITLENGTH+1);
|
||||
// Bstrncpyz(osd->history.buf[i], scripthist[scripthistend-1-i], OSDEDITLENGTH+1);
|
||||
DO_FREE_AND_NULL(osd->history.buf[i]);
|
||||
osd->history.buf[i] = Bstrdup(scripthist[scripthistend-1-i]);
|
||||
|
||||
osdhistorysize++;
|
||||
osdhistorytotal++;
|
||||
osd->history.lines++;
|
||||
osd->history.total++;
|
||||
}
|
||||
|
||||
scripthistend %= SCRIPTHISTSIZ;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -10645,6 +10645,7 @@ void G_Shutdown(void)
|
|||
uninitengine();
|
||||
G_Cleanup();
|
||||
FreeGroups();
|
||||
OSD_Cleanup();
|
||||
Bfflush(NULL);
|
||||
}
|
||||
|
||||
|
@ -10821,7 +10822,7 @@ void G_PostCreateGameState(void)
|
|||
static void G_HandleMemErr(int32_t line, const char *file, const char *func)
|
||||
{
|
||||
static char msg[128];
|
||||
snprintf(msg, sizeof(msg), "Out of memory in %s:%d (%s)\n", file, line, func);
|
||||
Bsnprintf(msg, sizeof(msg), "Out of memory in %s:%d (%s)\n", file, line, func);
|
||||
G_GameExit(msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,6 @@ LUNATIC_CB void (*A_ResetVars)(int32_t iActor);
|
|||
#else
|
||||
# include "gamestructures.c"
|
||||
|
||||
extern int32_t OSD_errors;
|
||||
|
||||
static void Gv_Free(void) /* called from Gv_ReadSave() and Gv_ResetVars() */
|
||||
{
|
||||
// call this function as many times as needed.
|
||||
|
@ -368,7 +366,8 @@ void Gv_ResetVars(void) /* this is called during a new game and nowhere else */
|
|||
int32_t i;
|
||||
|
||||
Gv_Free();
|
||||
OSD_errors=0;
|
||||
|
||||
osd->log.errors = 0;
|
||||
|
||||
for (i=0; i<MAXGAMEVARS; i++)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue