OMG FINALLY FIXED OVERLAYZ. I almost killed myself over this one.

This commit is contained in:
Greyscale 2009-06-21 14:59:18 -07:00
parent 38b256419d
commit ff7528f09f
4 changed files with 28 additions and 71 deletions

View File

@ -210,7 +210,7 @@ OverlaysClientUpdateOverlay(client, OverlaysChannel:channel = OVERLAYS_CHANNEL_N
} }
// Display overlay to client. // Display overlay to client.
ClientCommand(client, "r_screenoverlay %s", g_strOverlayPath[client][channel]); ClientCommand(client, "r_screenoverlay \"%s\"", g_strOverlayPath[client][channel]);
} }
OverlaysChannel:OverlaysClientFindChannel(client) OverlaysChannel:OverlaysClientFindChannel(client)
@ -239,7 +239,7 @@ OverlaysChannel:OverlaysClientFindChannel(client)
* @param update (Optional) Update the overlay when this function is called. * @param update (Optional) Update the overlay when this function is called.
* @param toggle (Optional) Set to true to toggle state, false to use value param. * @param toggle (Optional) Set to true to toggle state, false to use value param.
* @param value (Optional) New value of the state, only used if toggle is false. * @param value (Optional) New value of the state, only used if toggle is false.
* @param reset (Optional) Clears the overlay from client's screen. * @param reset (Optional) Resets the channel path.
* @return The overlay's new state. * @return The overlay's new state.
*/ */
bool:OverlaysClientSetChannelState(client, OverlaysChannel:channel, bool:update = false, bool:toggle = true, bool:value = false, bool:reset = false) bool:OverlaysClientSetChannelState(client, OverlaysChannel:channel, bool:update = false, bool:toggle = true, bool:value = false, bool:reset = false)
@ -303,6 +303,12 @@ public Action:OverlaysTimer(Handle:timer)
continue; continue;
} }
// If no overlay is on the client's screen, then stop.
if (OverlaysClientFindChannel(x) == OVERLAYS_CHANNEL_NONE)
{
continue;
}
// Update client's overlay. // Update client's overlay.
OverlaysClientUpdateOverlay(x); OverlaysClientUpdateOverlay(x);
} }

View File

@ -133,9 +133,6 @@ ClassOnClientSpawn(client)
ClassReloadPlayerCache(client, ClassGetActiveIndex(client)); ClassReloadPlayerCache(client, ClassGetActiveIndex(client));
ClassApplyAttributes(client); ClassApplyAttributes(client);
} }
// Forward event to sub-modules.
ClassOverlayOnClientSpawn(client);
} }
/** /**
@ -173,7 +170,4 @@ ClassOnClientInfected(client, bool:motherzombie = false)
// Apply the new attributes. // Apply the new attributes.
ClassApplyAttributes(client, motherzombie); ClassApplyAttributes(client, motherzombie);
// Forward event to sub-modules.
ClassOverlayOnClientInfected(client);
} }

View File

@ -105,31 +105,6 @@ ClassOverlayClientInit(client)
} }
} }
/**
* Client is spawning into the game.
*
* @param client The client index.
*/
ClassOverlayOnClientSpawn(client)
{
// If overlay toggle is enabled and class has an overlay, then send center text.
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
decl String:overlaypath[PLATFORM_MAX_PATH];
ClassGetOverlayPath(client, overlaypath, sizeof(overlaypath));
if (overlaytoggle && overlaypath[0])
{
decl String:togglecmds[CLASSOVERLAY_TOGGLE_MAX_CMDS * CLASSOVERLAY_TOGGLE_MAX_LENGTH];
GetConVarString(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS], togglecmds, sizeof(togglecmds));
TranslationPrintHUDText(client, "Classes overlay toggle", togglecmds);
}
// Update class overlay.
OverlaysClientUpdateOverlay(client, OVERLAYS_CHANNEL_CLASSES);
}
/** /**
* Client has been killed. * Client has been killed.
* *
@ -141,28 +116,6 @@ ClassOverlayOnClientDeath(client)
OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, false, true); OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, false, true);
} }
/**
* Client has been infected.
*
* @param client The client index.
*/
ClassOverlayOnClientInfected(client)
{
// If overlay toggle is enabled and class has an overlay, then send center text.
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
decl String:overlaypath[PLATFORM_MAX_PATH];
ClassGetOverlayPath(client, overlaypath, sizeof(overlaypath));
if (overlaytoggle && overlaypath[0])
{
decl String:togglecmds[CLASSOVERLAY_TOGGLE_MAX_CMDS * CLASSOVERLAY_TOGGLE_MAX_LENGTH];
GetConVarString(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS], togglecmds, sizeof(togglecmds));
TranslationPrintCenterText(client, "Classes overlay toggle", togglecmds);
}
}
ClassOverlayInitialize(client, const String:overlay[]) ClassOverlayInitialize(client, const String:overlay[])
{ {
if (IsFakeClient(client)) if (IsFakeClient(client))
@ -177,6 +130,20 @@ ClassOverlayInitialize(client, const String:overlay[])
return; return;
} }
// If overlay toggle is enabled and class has an overlay, then send center text.
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
decl String:overlaypath[PLATFORM_MAX_PATH];
ClassGetOverlayPath(client, overlaypath, sizeof(overlaypath));
if (overlaytoggle && overlaypath[0])
{
decl String:togglecmds[CLASSOVERLAY_TOGGLE_MAX_CMDS * CLASSOVERLAY_TOGGLE_MAX_LENGTH];
GetConVarString(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS], togglecmds, sizeof(togglecmds));
TranslationPrintHUDText(client, "Classes overlay toggle", togglecmds);
}
// Display class overlays. // Display class overlays.
OverlaysClientSetChannelPath(client, OVERLAYS_CHANNEL_CLASSES, overlay); OverlaysClientSetChannelPath(client, OVERLAYS_CHANNEL_CLASSES, overlay);
OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, CookiesGetClientCookieBool(client, g_hOverlayEnabledCookie)); OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, false, CookiesGetClientCookieBool(client, g_hOverlayEnabledCookie));

View File

@ -109,6 +109,9 @@ RoundEndOnClientInfected()
*/ */
RoundEndOnRoundStart() RoundEndOnRoundStart()
{ {
// Stop all overlays.
RoundEndOverlayStop();
// If round end timer is running, then kill it. // If round end timer is running, then kill it.
if (tRoundEnd != INVALID_HANDLE) if (tRoundEnd != INVALID_HANDLE)
{ {
@ -160,7 +163,7 @@ RoundEndOnRoundEnd(reason)
new RoundEndOutcome:outcome = RoundEndReasonToOutcome(reason); new RoundEndOutcome:outcome = RoundEndReasonToOutcome(reason);
// Display the overlay to all clients. // Display the overlay to all clients.
RoundEndOverlayStart(ROUNDEND_DELAY, outcome); RoundEndOverlayStart(outcome);
// Balance teams. // Balance teams.
RoundEndBalanceTeams(); RoundEndBalanceTeams();
@ -355,7 +358,7 @@ RoundEndBalanceTeams()
* @param time Time to display overlays. * @param time Time to display overlays.
* @param outcome The outcome of the round. * @param outcome The outcome of the round.
*/ */
RoundEndOverlayStart(Float:time, RoundEndOutcome:outcome) RoundEndOverlayStart(RoundEndOutcome:outcome)
{ {
// If round end overlays are disabled, then stop. // If round end overlays are disabled, then stop.
new bool:overlay = GetConVarBool(g_hCvarsList[CVAR_ROUNDEND_OVERLAY]); new bool:overlay = GetConVarBool(g_hCvarsList[CVAR_ROUNDEND_OVERLAY]);
@ -403,8 +406,6 @@ RoundEndOverlayStart(Float:time, RoundEndOutcome:outcome)
OverlaysClientSetChannelPath(x, OVERLAYS_CHANNEL_ROUNDEND, overlaypath); OverlaysClientSetChannelPath(x, OVERLAYS_CHANNEL_ROUNDEND, overlaypath);
OverlaysClientSetChannelState(x, OVERLAYS_CHANNEL_ROUNDEND, true, false, true); OverlaysClientSetChannelState(x, OVERLAYS_CHANNEL_ROUNDEND, true, false, true);
} }
CreateTimer(time, RoundEndOverlayTimer, _, TIMER_FLAG_NO_MAPCHANGE);
} }
RoundEndOverlayStop() RoundEndOverlayStop()
@ -427,15 +428,4 @@ RoundEndOverlayStop()
// Disable roundend overlay channel. // Disable roundend overlay channel.
OverlaysClientSetChannelState(x, OVERLAYS_CHANNEL_ROUNDEND, true, false, false, true); OverlaysClientSetChannelState(x, OVERLAYS_CHANNEL_ROUNDEND, true, false, false, true);
} }
} }
/**
* Timer callback, stops overlays on all clients.
*
* @param timer The timer handle.
*/
public Action:RoundEndOverlayTimer(Handle:timer)
{
// Stop all overlays.
RoundEndOverlayStop();
}