updated to use the multi-lingual system | better code style

This commit is contained in:
Felix Geyer
2004-08-05 11:09:16 +00:00
parent 9276dbb086
commit 89b4ef92b5
8 changed files with 609 additions and 639 deletions

View File

@ -39,25 +39,25 @@
#define MAX_CMDS_LAYERS 3
new g_cmdMenuName[ MAX_CMDS_LAYERS ][ ] = {
"Commands Menu",
"Configs Menu",
"Speech Menu"
new g_cmdMenuName[ MAX_CMDS_LAYERS ][] = {
"CMD_MENU",
"CONF_MENU",
"SPE_MENU"
}
new g_cmdMenuCmd[ MAX_CMDS_LAYERS ][ ] = {
new g_cmdMenuCmd[ MAX_CMDS_LAYERS ][] = {
"amx_cmdmenu",
"amx_cfgmenu",
"amx_speechmenu"
}
new g_cmdMenuCfg[ MAX_CMDS_LAYERS ][ ] = {
new g_cmdMenuCfg[ MAX_CMDS_LAYERS ][] = {
"cmds.ini",
"configs.ini",
"speech.ini"
}
new g_cmdMenuHelp[ MAX_CMDS_LAYERS ][ ] = {
new g_cmdMenuHelp[ MAX_CMDS_LAYERS ][] = {
"- displays commands menu",
"- displays configs menu",
"- displays speech menu"
@ -86,15 +86,17 @@ new g_menuLayer[33]
new g_coloredMenus
public plugin_init()
{
public plugin_init() {
register_plugin("Commands Menu",AMXX_VERSION_STR,"AMXX Dev Team")
register_dictionary("cmdmenu.txt")
register_dictionary("common.txt")
new configsDir[64];
get_configsdir(configsDir, 63);
new config[64]
for(new a = 0; a < MAX_CMDS_LAYERS; ++a) {
register_menucmd(register_menuid( g_cmdMenuName[ a ] ),1023,"actionCmdMenu")
new configsDir[64],config[64]
get_configsdir(configsDir, 63)
for (new a = 0; a < MAX_CMDS_LAYERS; ++a) {
new MenuName[64]
format(MenuName,63,"%L","en",g_cmdMenuName[a])
register_menucmd(register_menuid( MenuName ),1023,"actionCmdMenu")
register_clcmd( g_cmdMenuCmd[ a ] ,"cmdCmdMenu",ADMIN_MENU, g_cmdMenuHelp[ a ] )
format(config,63,"%s/%s",configsDir,g_cmdMenuCfg[a])
loadCmdSettings(config,a)
@ -112,12 +114,11 @@ public plugin_init()
/* Commands menu */
public actionCmdMenu(id,key)
{
switch(key){
case 8: displayCmdMenu(id,++g_menuPosition[id])
case 9: displayCmdMenu(id,--g_menuPosition[id])
default:{
public actionCmdMenu(id,key) {
switch (key) {
case 8: displayCmdMenu(id,++g_menuPosition[id])
case 9: displayCmdMenu(id,--g_menuPosition[id])
default:{
new option = g_menuSelect[ id ][ g_menuPosition[id] * 8 + key ]
new flags = g_cmdMisc[ option ][ 1 ]
if ( flags & 1)
@ -133,8 +134,7 @@ public actionCmdMenu(id,key)
}
displayCmdMenu(id,pos){
displayCmdMenu(id,pos) {
if (pos < 0) return
new menuBody[512]
@ -145,7 +145,7 @@ displayCmdMenu(id,pos){
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511,g_coloredMenus ?
"\y%s\R%d/%d^n\w^n" : "%s %d/%d^n^n" , g_cmdMenuName[ g_menuLayer[id] ],
"\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n" , id, g_cmdMenuName[ g_menuLayer[id] ],
pos+1,( g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0 )) )
new end = start + 8
@ -154,33 +154,31 @@ displayCmdMenu(id,pos){
if (end > g_menuSelectNum[id])
end = g_menuSelectNum[id]
for(new a = start; a < end; ++a)
{
if ( g_cmdCmd[ g_menuSelect[id][ a ] ][0] == '-' )
{
for(new a = start; a < end; ++a) {
if ( g_cmdCmd[ g_menuSelect[id][ a ] ][0] == '-' ) {
if ( g_coloredMenus )
len += format(menuBody[len],511-len,"\d%s^n\w",g_cmdName[ g_menuSelect[id][ a ] ] )
else
len += format(menuBody[len],511-len,"%s^n",g_cmdName[ g_menuSelect[id][ a ] ] )
++b
}
else
{
else {
keys |= (1<<b)
len += format(menuBody[len],511-len,"%d. %s^n",++b, g_cmdName[ g_menuSelect[id][ a ] ] )
}
}
if (end != g_menuSelectNum[id]) {
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
format(menuBody[len],511-len,"^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT" )
keys |= MENU_KEY_9
}
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit" )
show_menu(id,keys,menuBody)
else format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT" )
new MenuName[64]
format(MenuName,63,"%L","en",g_cmdMenuName[g_menuLayer[id]])
show_menu(id,keys,menuBody,-1,MenuName)
}
public cmdCmdMenu(id,level,cid)
{
public cmdCmdMenu(id,level,cid) {
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
new szCmd[32]
@ -188,8 +186,7 @@ public cmdCmdMenu(id,level,cid)
new lvl = 0
while( lvl < MAX_CMDS_LAYERS )
{
while( lvl < MAX_CMDS_LAYERS ) {
if ( equal( g_cmdMenuCmd[ lvl ], szCmd ) )
break
@ -205,12 +202,10 @@ public cmdCmdMenu(id,level,cid)
new a = lvl * MAX_CMDS
new d , c = 0
while( c < g_cmdNum[ lvl ] )
{
while( c < g_cmdNum[ lvl ] ) {
d = a + c
if ( g_cmdMisc[ d ][0] & flags )
{
if ( g_cmdMisc[ d ][0] & flags ) {
g_menuSelect[id][ g_menuSelectNum[id]++ ] = d
}
@ -223,23 +218,20 @@ public cmdCmdMenu(id,level,cid)
}
loadCmdSettings( szFilename[], level )
{
loadCmdSettings( szFilename[], level ) {
if ( !file_exists ( szFilename ) )
return 0
new text[256], szFlags[32], szAccess[32]
new a, pos = 0, c, d = level * MAX_CMDS
while ( g_cmdNum[ level ] < MAX_CMDS && read_file (szFilename,pos++,text,255,a) )
{
while ( g_cmdNum[ level ] < MAX_CMDS && read_file (szFilename,pos++,text,255,a) ) {
if ( text[0] == ';' ) continue
c = d + g_cmdNum[ level ]
if ( parse( text , g_cmdName[ c ] , 31 ,
g_cmdCmd[ c ] ,63,szFlags,31,szAccess,31 ) > 3 )
{
g_cmdCmd[ c ] ,63,szFlags,31,szAccess,31 ) > 3 ) {
while ( replace( g_cmdCmd[ c ] ,63,"\'","^"") ) {
// do nothing
}
@ -256,13 +248,11 @@ loadCmdSettings( szFilename[], level )
/* Cvars menu */
public actionCvarMenu(id,key)
{
switch(key){
case 8: displayCvarMenu(id,++g_menuPosition[id])
case 9: displayCvarMenu(id,--g_menuPosition[id])
default:{
public actionCvarMenu(id,key) {
switch (key){
case 8: displayCvarMenu(id,++g_menuPosition[id])
case 9: displayCvarMenu(id,--g_menuPosition[id])
default: {
new option = g_menuSelect[ id ][ g_menuPosition[id] * 8 + key ]
new szValue[32]
@ -271,10 +261,8 @@ public actionCvarMenu(id,key)
new end = g_cvarMisc[ option ][ 2 ]
new start = g_cvarMisc[ option ][ 1 ]
for(new i = start ; ; ++i )
{
if ( i < end )
{
for (new i = start ; ; ++i ) {
if ( i < end ) {
if ( equal( szValue , g_cvarCmd[ i ] ) )
{
if (++i >= end)
@ -285,8 +273,7 @@ public actionCvarMenu(id,key)
break
}
}
else
{
else {
set_cvar_string( g_cvarNames[ option ], g_cvarCmd[ start ] )
break
}
@ -299,30 +286,28 @@ public actionCvarMenu(id,key)
}
displayCvarMenu(id,pos){
displayCvarMenu(id,pos) {
if (pos < 0) return
new menuBody[512]
new b = 0
new start = pos * 8
if (start >= g_menuSelectNum[id])
start = pos = g_menuPosition[id] = 0
new len = format(menuBody,511, g_coloredMenus ?
"\yCvars Menu\R%d/%d^n\w^n" : "Cvars Menu %d/%d^n^n",
pos+1,( g_menuSelectNum[id] / 8 + ((g_menuSelectNum[id] % 8) ? 1 : 0 )) )
new end = start + 8
new keys = MENU_KEY_0
new szValue[64]
if (end > g_menuSelectNum[id])
end = g_menuSelectNum[id]
for(new a = start; a < end; ++a)
{
for(new a = start; a < end; ++a) {
get_cvar_string( g_cvarNames[ g_menuSelect[id][ a ] ],szValue,31)
keys |= (1<<b)
++b
@ -331,17 +316,16 @@ displayCvarMenu(id,pos){
else
len += format(menuBody[len],511-len,"%d. %s %s^n", b, g_cvarNames[ g_menuSelect[id][ a ] ], szValue )
}
if (end != g_menuSelectNum[id]) {
format(menuBody[len],511-len,"^n9. More...^n0. %s", pos ? "Back" : "Exit")
format(menuBody[len],511-len,"^n9. %L...^n0. %L",id,"MORE",id,pos ? "BACK" : "EXIT")
keys |= MENU_KEY_9
}
else format(menuBody[len],511-len,"^n0. %s", pos ? "Back" : "Exit")
else format(menuBody[len],511-len,"^n0. %L", id, pos ? "BACK" : "EXIT")
show_menu(id,keys,menuBody)
}
public cmdCvarMenu(id,level,cid)
{
public cmdCvarMenu(id,level,cid) {
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
new flags = get_user_flags(id)
@ -357,8 +341,7 @@ public cmdCvarMenu(id,level,cid)
return PLUGIN_HANDLED
}
loadCvarSettings( szFilename[] )
{
loadCvarSettings( szFilename[] ) {
if ( !file_exists ( szFilename ) )
return 0
@ -366,8 +349,7 @@ loadCvarSettings( szFilename[] )
new inum , a, pos = 0
new cvar_values = MAX_CVARS * 5
// a b c d
while ( g_cvarNum < MAX_CVARS && read_file (szFilename,pos++,text,255,a) )
{
while ( g_cvarNum < MAX_CVARS && read_file (szFilename,pos++,text,255,a) ) {
if ( text[0] == ';' ) continue
inum = parse( text , g_cvarNames[ g_cvarNum ] , 31 ,
@ -382,8 +364,7 @@ loadCvarSettings( szFilename[] )
g_cvarMisc[ g_cvarNum ][1] = g_cvarCmdNum
for( a = 0 ; a < inum && g_cvarCmdNum < cvar_values ; ++a )
{
for ( a = 0 ; a < inum && g_cvarCmdNum < cvar_values ; ++a ) {
while ( replace( szValues[ a ] ,31 , "\'" , "^"" ) ) {
// do nothing
}