Commit 44433d61 authored by NY00123's avatar NY00123 Committed by Richard Gobeille

source/duke3d/src/m32common.cpp: Remove LUNATIC/MENU_HAVE_DESCRIPTION code

parent 3a699907
......@@ -1429,12 +1429,6 @@ too_many_errors:
#define MENU_BG_COLOR editorcolors[0]
#define MENU_BG_COLOR_SEL editorcolors[1]
#ifdef LUNATIC
# define MENU_HAVE_DESCRIPTION 1
#else
# define MENU_HAVE_DESCRIPTION 0
#endif
typedef struct StatusBarMenu_ {
const char *const menuname;
const int32_t custom_start_index;
......@@ -1452,31 +1446,6 @@ typedef struct StatusBarMenu_ {
#define MENU_INITIALIZER(MenuName, CustomStartIndex, ProcessFunc, ...) \
{ MenuName, CustomStartIndex, CustomStartIndex, ProcessFunc, {}, {}, ## __VA_ARGS__ }
#ifdef LUNATIC
static void M_Clear(StatusBarMenu *m)
{
int32_t i;
m->numentries = 0;
Bmemset(m->auxdata, 0, sizeof(m->auxdata));
Bmemset(m->name, 0, sizeof(m->name));
for (i=0; i<MENU_MAX_ENTRIES; i++)
DO_FREE_AND_NULL(m->description[i]);
}
static int32_t M_HaveDescription(StatusBarMenu *m)
{
int32_t i;
for (i=0; i<MENU_MAX_ENTRIES; i++)
if (m->description[i] != NULL)
return 1;
return 0;
}
#endif
// NOTE: Does not handle description strings! (Only the Lua menu uses them.)
static void M_UnregisterFunction(StatusBarMenu *m, intptr_t auxdata)
{
......@@ -1526,13 +1495,7 @@ static void M_RegisterFunction(StatusBarMenu *m, const char *name, intptr_t auxd
Bstrncpyz(m->name[m->numentries], name, MENU_ENTRY_SIZE);
m->auxdata[m->numentries] = auxdata;
#if MENU_HAVE_DESCRIPTION
// NOTE: description only handled here (not above).
if (description)
m->description[m->numentries] = Xstrdup(description);
#else
UNREFERENCED_PARAMETER(description);
#endif
m->numentries++;
}
......@@ -1640,19 +1603,6 @@ static void M_EnterMainLoop(StatusBarMenu *m)
break;
}
#if MENU_HAVE_DESCRIPTION
if (M_HaveDescription(m))
{
const int32_t maxrows = 20;
int32_t r;
for (r=0; r<maxrows+1; r++)
printext16(16-4, 16-4 + r*8, 0, MENU_BG_COLOR, // 71 blanks:
" ", 0);
if (m->description[col*8 + row] != NULL)
printext16(16, 16, MENU_FG_COLOR, MENU_BG_COLOR, m->description[col*8 + row], 0);
}
#endif
printext16(xpos, ypos+row*MENU_Y_SPACING, MENU_FG_COLOR, MENU_BG_COLOR_SEL, disptext, 0);
videoShowFrame(1);
}
......@@ -1985,63 +1935,3 @@ void m32_showmouse()
}
#endif
}
#ifdef LUNATIC
typedef const char *(*luamenufunc_t)(void);
#ifdef __cplusplus
extern "C" {
#endif
extern void LM_Register(const char *name, luamenufunc_t funcptr, const char *description);
extern void LM_Clear(void);
#ifdef __cplusplus
}
#endif
static int32_t g_numLuaFuncs = 0;
static luamenufunc_t g_LuaFuncPtrs[MENU_MAX_ENTRIES];
static void LuaFuncMenu_Process(const StatusBarMenu *m, int32_t col, int32_t row)
{
luamenufunc_t func = g_LuaFuncPtrs[col*8 + row];
const char *errmsg;
Bassert(func != NULL);
errmsg = func();
if (errmsg == NULL)
{
printmessage16("Lua function executed successfully");
}
else
{
printmessage16("There were errors executing the Lua function, see OSD");
OSD_Printf("Errors executing Lua function \"%s\": %s\n", m->name[col*8 + row], errmsg);
}
}
static StatusBarMenu g_LuaFuncMenu = MENU_INITIALIZER_EMPTY("Lua functions", LuaFuncMenu_Process);
void LuaFuncMenu(void)
{
M_EnterMainLoop(&g_LuaFuncMenu);
}
LUNATIC_EXTERN void LM_Register(const char *name, luamenufunc_t funcptr, const char *description)
{
if (name == NULL || g_numLuaFuncs == MENU_MAX_ENTRIES)
return;
g_LuaFuncPtrs[g_numLuaFuncs] = funcptr;
M_RegisterFunction(&g_LuaFuncMenu, name, g_numLuaFuncs, description);
g_numLuaFuncs++;
}
LUNATIC_EXTERN void LM_Clear(void)
{
M_Clear(&g_LuaFuncMenu);
g_numLuaFuncs = 0;
Bmemset(g_LuaFuncPtrs, 0, sizeof(g_LuaFuncPtrs));
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment