Finished new menu system (for now)

Fixed bug where client_print did not add newlines properly
This commit is contained in:
David Anderson 2005-07-29 19:13:55 +00:00
parent 5b1d0dd2b9
commit 32a42886dd
5 changed files with 43 additions and 42 deletions

View File

@ -99,6 +99,8 @@ public:
int death_victim; int death_victim;
bool death_tk; bool death_tk;
String death_weapon; String death_weapon;
int newmenu;
int page;
Vector lastTrace; Vector lastTrace;
Vector thisTrace; Vector thisTrace;

View File

@ -223,7 +223,7 @@ static cell AMX_NATIVE_CALL client_print(AMX *amx, cell *params) /* 3 param */
msg[len++] = '\n'; msg[len++] = '\n';
msg[len] = 0; msg[len] = 0;
if (pPlayer->ingame) if (pPlayer->ingame)
UTIL_ClientPrint(pPlayer->pEdict, params[2], format_amxstring(amx, params, 3, len)); UTIL_ClientPrint(pPlayer->pEdict, params[2], msg); //format_amxstring(amx, params, 3, len));
} }
return len; return len;
} }
@ -756,6 +756,8 @@ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
if (pPlayer->ingame){ if (pPlayer->ingame){
pPlayer->keys = keys; pPlayer->keys = keys;
pPlayer->menu = menuid; pPlayer->menu = menuid;
pPlayer->newmenu = -1;
pPlayer->page = 0;
UTIL_ShowMenu(pPlayer->pEdict, keys, time, sMenu, ilen ); UTIL_ShowMenu(pPlayer->pEdict, keys, time, sMenu, ilen );
} }
} }
@ -770,6 +772,8 @@ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
if (pPlayer->ingame){ if (pPlayer->ingame){
pPlayer->keys = keys; pPlayer->keys = keys;
pPlayer->menu = menuid; pPlayer->menu = menuid;
pPlayer->newmenu = -1;
pPlayer->page = 0;
UTIL_ShowMenu(pPlayer->pEdict, keys, time, sMenu, ilen ); UTIL_ShowMenu(pPlayer->pEdict, keys, time, sMenu, ilen );
} }
} }
@ -794,7 +798,7 @@ static cell AMX_NATIVE_CALL register_menucmd(AMX *amx, cell *params) /* 3 param
int ilen, idx; int ilen, idx;
char* sptemp = get_amxstring(amx,params[3],0,ilen); char* sptemp = get_amxstring(amx,params[3],0,ilen);
idx = registerSPForwardByName(amx, sptemp, FP_CELL, FP_CELL, FP_DONE); idx = registerSPForwardByName(amx, sptemp, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
if (idx == -1) if (idx == -1)
{ {
LogError(amx, AMX_ERR_NOTFOUND, "Function \"%s\" was not found", sptemp); LogError(amx, AMX_ERR_NOTFOUND, "Function \"%s\" was not found", sptemp);

View File

@ -175,19 +175,8 @@ int C_InconsistentFile( const edict_t *player, const char *filename, char *disco
{ {
CPlayer *pPlayer = GET_PLAYER_POINTER((edict_t *)player); CPlayer *pPlayer = GET_PLAYER_POINTER((edict_t *)player);
#ifdef ENABLEEXEPTIONS
try
{
#endif
if (executeForwards(FF_InconsistentFile, pPlayer->index, filename, disconnect_message) == 1) if (executeForwards(FF_InconsistentFile, pPlayer->index, filename, disconnect_message) == 1)
RETURN_META_VALUE(MRES_SUPERCEDE, FALSE); RETURN_META_VALUE(MRES_SUPERCEDE, FALSE);
#ifdef ENABLEEXEPTIONS
}
catch( ... )
{
AMXXLOG_Log( "[AMXX] Fatal error at inconsistent file forward execution");
}
#endif
RETURN_META_VALUE(MRES_SUPERCEDE, TRUE ); RETURN_META_VALUE(MRES_SUPERCEDE, TRUE );
} }
@ -638,27 +627,12 @@ void C_ClientCommand( edict_t *pEntity ) {
} }
} }
#ifdef ENABLEEXEPTIONS
try
{
#endif
if (executeForwards(FF_ClientCommand, pPlayer->index) > 0) if (executeForwards(FF_ClientCommand, pPlayer->index) > 0)
RETURN_META(MRES_SUPERCEDE); RETURN_META(MRES_SUPERCEDE);
#ifdef ENABLEEXEPTIONS
}
catch( ... )
{
AMXXLOG_Log( "[AMXX] Fatal error at commmand forward execution");
}
#endif
/* check for command and if needed also for first argument and call proper function */ /* check for command and if needed also for first argument and call proper function */
#ifdef ENABLEEXEPTIONS
try{
#endif
CmdMngr::iterator aa = g_commands.clcmdprefixbegin( cmd ); CmdMngr::iterator aa = g_commands.clcmdprefixbegin( cmd );
if ( !aa ) aa = g_commands.clcmdbegin(); if ( !aa ) aa = g_commands.clcmdbegin();
@ -675,12 +649,6 @@ void C_ClientCommand( edict_t *pEntity ) {
++aa; ++aa;
} }
#ifdef ENABLEEXEPTIONS
}catch( ... )
{
AMXXLOG_Log( "[AMXX] fatal error at client commmand execution");
}
#endif
/* check menu commands */ /* check menu commands */
if (!strcmp(cmd,"menuselect")) if (!strcmp(cmd,"menuselect"))
@ -700,10 +668,34 @@ void C_ClientCommand( edict_t *pEntity ) {
{ {
if ( (*a).matchCommand( menuid , bit_key ) && (*a).getPlugin()->isExecutable( (*a).getFunction() ) ) if ( (*a).matchCommand( menuid , bit_key ) && (*a).getPlugin()->isExecutable( (*a).getFunction() ) )
{ {
ret = executeForwards((*a).getFunction(), pPlayer->index, pressed_key); if (pPlayer->newmenu != -1)
{
int menu = pPlayer->newmenu;
pPlayer->newmenu = -1;
if (menu >= 0 && menu < (int)g_NewMenus.size())
{
Menu *pMenu = g_NewMenus[menu];
int item = pMenu->PagekeyToItem(pPlayer->page, pressed_key);
ret = executeForwards( (*a).getFunction(), pPlayer->index, menu, item );
if ( ret & 2 ) result = MRES_SUPERCEDE;
else if ( ret & 1 ) RETURN_META(MRES_SUPERCEDE);
else {
if (item == MENU_BACK)
{
pMenu->Display(pPlayer->index, pPlayer->page-1);
} else if (item == MENU_MORE) {
pMenu->Display(pPlayer->index, pPlayer->page+1);
} else if (item == MENU_EXIT) {
//nothing
}
}
}
} else {
ret = executeForwards((*a).getFunction(), pPlayer->index, pressed_key, 0);
if ( ret & 2 ) result = MRES_SUPERCEDE; if ( ret & 2 ) result = MRES_SUPERCEDE;
if ( ret & 1 ) RETURN_META(MRES_SUPERCEDE); if ( ret & 1 ) RETURN_META(MRES_SUPERCEDE);
} }
}
++a; ++a;
} }

View File

@ -127,6 +127,8 @@ bool Menu::Display(int player, page_t page)
pPlayer->keys = keys; pPlayer->keys = keys;
pPlayer->menu = menuId; pPlayer->menu = menuId;
pPlayer->newmenu = thisId;
pPlayer->page = (int)page;
UTIL_ShowMenu(pPlayer->pEdict, keys, -1, buffer, len); UTIL_ShowMenu(pPlayer->pEdict, keys, -1, buffer, len);
@ -238,7 +240,7 @@ static cell AMX_NATIVE_CALL menu_create(AMX *amx, cell *params)
char *title = get_amxstring(amx, params[1], 0, len); char *title = get_amxstring(amx, params[1], 0, len);
char *handler = get_amxstring(amx, params[2], 1, len); char *handler = get_amxstring(amx, params[2], 1, len);
int func = registerSPForwardByName(amx, handler, FP_CELL, FP_CELL, FP_DONE); int func = registerSPForwardByName(amx, handler, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
if (func == -1) if (func == -1)
{ {
LogError(amx, AMX_ERR_NOTFOUND, "Invalid function \"%s\"", handler); LogError(amx, AMX_ERR_NOTFOUND, "Invalid function \"%s\"", handler);

View File

@ -62,6 +62,7 @@ const char *GetItemCmd(menu_t menu, item_t item);*/
void ClearMenus(); void ClearMenus();
extern CVector<Menu *> g_NewMenus;
extern AMX_NATIVE_INFO g_NewMenuNatives[]; extern AMX_NATIVE_INFO g_NewMenuNatives[];
#endif //_INCLUDE_NEWMENUS_H #endif //_INCLUDE_NEWMENUS_H