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;
bool death_tk;
String death_weapon;
int newmenu;
int page;
Vector lastTrace;
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] = 0;
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;
}
@ -756,6 +756,8 @@ static cell AMX_NATIVE_CALL show_menu(AMX *amx, cell *params) /* 3 param */
if (pPlayer->ingame){
pPlayer->keys = keys;
pPlayer->menu = menuid;
pPlayer->newmenu = -1;
pPlayer->page = 0;
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){
pPlayer->keys = keys;
pPlayer->menu = menuid;
pPlayer->newmenu = -1;
pPlayer->page = 0;
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;
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)
{
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);
#ifdef ENABLEEXEPTIONS
try
{
#endif
if (executeForwards(FF_InconsistentFile, pPlayer->index, filename, disconnect_message) == 1)
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 );
}
@ -638,27 +627,12 @@ void C_ClientCommand( edict_t *pEntity ) {
}
}
#ifdef ENABLEEXEPTIONS
try
{
#endif
if (executeForwards(FF_ClientCommand, pPlayer->index) > 0)
RETURN_META(MRES_SUPERCEDE);
if (executeForwards(FF_ClientCommand, pPlayer->index) > 0)
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 */
#ifdef ENABLEEXEPTIONS
try{
#endif
CmdMngr::iterator aa = g_commands.clcmdprefixbegin( cmd );
if ( !aa ) aa = g_commands.clcmdbegin();
@ -675,12 +649,6 @@ void C_ClientCommand( edict_t *pEntity ) {
++aa;
}
#ifdef ENABLEEXEPTIONS
}catch( ... )
{
AMXXLOG_Log( "[AMXX] fatal error at client commmand execution");
}
#endif
/* check menu commands */
if (!strcmp(cmd,"menuselect"))
@ -694,15 +662,39 @@ void C_ClientCommand( edict_t *pEntity ) {
int menuid = pPlayer->menu;
pPlayer->menu = 0;
MenuMngr::iterator a = g_menucmds.begin();
MenuMngr::iterator a = g_menucmds.begin();
while( a )
{
if ( (*a).matchCommand( menuid , bit_key ) && (*a).getPlugin()->isExecutable( (*a).getFunction() ) )
{
ret = executeForwards((*a).getFunction(), pPlayer->index, pressed_key);
if ( ret & 2 ) result = MRES_SUPERCEDE;
if ( ret & 1 ) RETURN_META(MRES_SUPERCEDE);
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 & 1 ) RETURN_META(MRES_SUPERCEDE);
}
}
++a;

View File

@ -127,6 +127,8 @@ bool Menu::Display(int player, page_t page)
pPlayer->keys = keys;
pPlayer->menu = menuId;
pPlayer->newmenu = thisId;
pPlayer->page = (int)page;
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 *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)
{
LogError(amx, AMX_ERR_NOTFOUND, "Invalid function \"%s\"", handler);
@ -372,4 +374,4 @@ AMX_NATIVE_INFO g_NewMenuNatives[] =
{"menu_item_getinfo", menu_item_getinfo},
{"menu_makecallback", menu_makecallback},
{NULL, NULL},
};
};

View File

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