Updated basetriggers to use more translation friendly phrases (bug 3330, r=dvander).

Basetriggers now counts rounds remaining for mp_maxrounds output.
This commit is contained in:
Matt Woodrow 2008-10-16 10:54:23 +13:00
parent 4a1c565b62
commit 07cbe39552
2 changed files with 134 additions and 18 deletions

View File

@ -64,6 +64,8 @@ new Handle:g_Cvar_MaxRounds = INVALID_HANDLE;
new bool:mapchooser; new bool:mapchooser;
new g_TotalRounds;
public OnPluginStart() public OnPluginStart()
{ {
LoadTranslations("common.phrases"); LoadTranslations("common.phrases");
@ -81,6 +83,11 @@ public OnPluginStart()
HookConVarChange(g_Cvar_TimeleftInterval, ConVarChange_TimeleftInterval); HookConVarChange(g_Cvar_TimeleftInterval, ConVarChange_TimeleftInterval);
HookEvent("round_end", Event_RoundEnd);
HookEvent("game_start", Event_GameStart);
HookEventEx("teamplay_win_panel", Event_TeamPlayWinPanel);
HookEventEx("teamplay_restart_round", Event_TFRestartRound);
HookEventEx("arena_win_panel", Event_TeamPlayWinPanel);
g_Cvar_WinLimit = FindConVar("mp_winlimit"); g_Cvar_WinLimit = FindConVar("mp_winlimit");
g_Cvar_FragLimit = FindConVar("mp_fraglimit"); g_Cvar_FragLimit = FindConVar("mp_fraglimit");
@ -89,6 +96,37 @@ public OnPluginStart()
mapchooser = LibraryExists("mapchooser"); mapchooser = LibraryExists("mapchooser");
} }
public OnMapStart()
{
g_TotalRounds = 0;
}
/* Round count tracking */
public Event_TFRestartRound(Handle:event, const String:name[], bool:dontBroadcast)
{
/* Game got restarted - reset our round count tracking */
g_TotalRounds = 0;
}
public Event_GameStart(Handle:event, const String:name[], bool:dontBroadcast)
{
/* Game got restarted - reset our round count tracking */
g_TotalRounds = 0;
}
public Event_TeamPlayWinPanel(Handle:event, const String:name[], bool:dontBroadcast)
{
if(GetEventInt(event, "round_complete") == 1 || StrEqual(name, "arena_win_panel"))
{
g_TotalRounds++;
}
}
/* You ask, why don't you just use team_score event? And I answer... Because CSS doesn't. */
public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
g_TotalRounds++;
}
public OnLibraryRemoved(const String:name[]) public OnLibraryRemoved(const String:name[])
{ {
if (StrEqual(name, "mapchooser")) if (StrEqual(name, "mapchooser"))
@ -330,12 +368,27 @@ ShowTimeLeft(client, who)
new len = strlen(finalOutput); new len = strlen(finalOutput);
if (len < sizeof(finalOutput)) if (len < sizeof(finalOutput))
{ {
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "WinLimitAppend" ,client, winlimit, (winlimit == 1)? "":"s"); if (winlimit > 1)
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "WinLimitAppendPlural" ,client, winlimit);
}
else
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "WinLimitAppend" ,client);
}
} }
} }
else else
{ {
FormatEx(finalOutput, sizeof(finalOutput), "%T", "WinLimit", client, winlimit, (winlimit == 1)? "":"s"); if (winlimit > 1)
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "WinLimitPlural", client, winlimit);
}
else
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "WinLimit", client);
}
written = true; written = true;
} }
} }
@ -352,12 +405,27 @@ ShowTimeLeft(client, who)
new len = strlen(finalOutput); new len = strlen(finalOutput);
if (len < sizeof(finalOutput)) if (len < sizeof(finalOutput))
{ {
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "FragLimitAppend", client, fraglimit, (fraglimit == 1)? "":"s"); if (fraglimit > 1)
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "FragLimitAppendPlural", client, fraglimit);
}
else
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "FragLimitAppend", client);
}
} }
} }
else else
{ {
FormatEx(finalOutput, sizeof(finalOutput), "%T", "FragLimit", client, fraglimit, (fraglimit == 1)? "":"s"); if (fraglimit > 1)
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "FragLimitPlural", client, fraglimit);
}
else
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "FragLimit", client);
}
written = true; written = true;
} }
} }
@ -369,17 +437,34 @@ ShowTimeLeft(client, who)
if (maxrounds > 0) if (maxrounds > 0)
{ {
new remaining = maxrounds - g_TotalRounds;
if (written) if (written)
{ {
new len = strlen(finalOutput); new len = strlen(finalOutput);
if (len < sizeof(finalOutput)) if (len < sizeof(finalOutput))
{ {
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "MaxRoundsAppend", client, maxrounds, (maxrounds == 1)? "":"s"); if (remaining > 1)
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "MaxRoundsAppendPlural", client, remaining);
}
else
{
FormatEx(finalOutput[len], sizeof(finalOutput)-len, "%T", "MaxRoundsAppend", client);
}
} }
} }
else else
{ {
FormatEx(finalOutput, sizeof(finalOutput), "%T", "MaxRounds", client, maxrounds, (maxrounds == 1)? "":"s"); if (remaining > 1)
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "MaxRoundsPlural", client, remaining);
}
else
{
FormatEx(finalOutput, sizeof(finalOutput), "%T", "MaxRounds", client);
}
written = true; written = true;
} }
} }

View File

@ -29,37 +29,68 @@
"WinLimitAppend" "WinLimitAppend"
{ {
"#format" "{1:i},{2:s}" "en" ", or change map after a team wins one round"
"en" ", or change map after a team wins {1} round{2}"
} }
"WinLimit" "WinLimit"
{ {
"#format" "{1:i},{2:s}" "en" "Map will change after a team wins one round"
"en" "Map will change after a team wins {1} round{2}"
} }
"MaxRoundsAppend" "MaxRoundsAppend"
{ {
"#format" "{1:i},{2:s}" "en" ", or change map after one more round"
"en" ", or change map after {1} round{2}"
} }
"MaxRounds" "MaxRounds"
{ {
"#format" "{1:i},{2:s}" "en" "Map will change after one more round"
"en" "Map will change after {1} round{2}"
} }
"FragLimitAppend" "FragLimitAppend"
{ {
"#format" "{1:i},{2:s}" "en" ", or change map after player reaches one frag"
"en" ", or change map after player reaches {1} frag{2}"
} }
"FragLimit" "FragLimit"
{ {
"#format" "{1:i},{2:s}" "en" "Map will change after a player reaches one frag"
"en" "Map will change after a player reaches {1} frag{2}" }
"WinLimitAppendPlural"
{
"#format" "{1:i}"
"en" ", or change map after a team wins {1} rounds"
}
"WinLimitPlural"
{
"#format" "{1:i}"
"en" "Map will change after a team wins {1} rounds"
}
"MaxRoundsAppendPlural"
{
"#format" "{1:i}"
"en" ", or change map after {1} more rounds"
}
"MaxRoundsPlural"
{
"#format" "{1:i}"
"en" "Map will change after {1} more rounds"
}
"FragLimitAppendPlural"
{
"#format" "{1:i}"
"en" ", or change map after player reaches {1} frags"
}
"FragLimitPlural"
{
"#format" "{1:i}"
"en" "Map will change after a player reaches {1} frags"
} }
"LastRound" "LastRound"