From 837e40a98513765a8e3d0fb32393951e7319ff0f Mon Sep 17 00:00:00 2001 From: zaCade Date: Mon, 15 Apr 2019 15:46:49 +0200 Subject: [PATCH] entWatch4: 'Paged' interface. --- _entWatch4/scripting/entWatch-interface.sp | 121 +++++++++++---------- 1 file changed, 61 insertions(+), 60 deletions(-) diff --git a/_entWatch4/scripting/entWatch-interface.sp b/_entWatch4/scripting/entWatch-interface.sp index e9d04889..031b98e1 100644 --- a/_entWatch4/scripting/entWatch-interface.sp +++ b/_entWatch4/scripting/entWatch-interface.sp @@ -35,31 +35,8 @@ public void OnMapStart() //---------------------------------------------------------------------------------------------------- public Action OnDisplayHUD(Handle timer) { - int iZombiesCount; - int iZombies[MAXPLAYERS+1]; - - int iHumansCount; - int iHumans[MAXPLAYERS+1]; - - int iSpecsCount; - int iSpecs[MAXPLAYERS+1]; - - for (int client = 1; client <= MaxClients; client++) - { - if (!IsClientInGame(client) || IsFakeClient(client)) - continue; - - switch(GetClientTeam(client)) - { - case(2): iZombies[iZombiesCount++] = client; - case(3): iHumans[iHumansCount++] = client; - default: iSpecs[iSpecsCount++] = client; - } - } - - char sZombieHUD[255]; - char sHumanHUD[255]; - char sSpecHUD[255]; + int iHUDPages[3]; + char sHUDPanels[3][8][255] for (int index; index < EW_GetItemCount(); index++) { @@ -67,32 +44,32 @@ public Action OnDisplayHUD(Handle timer) if (item.bClient && item.dConfig.bDisplayInterface) { - char sLine[64]; char sShort[32]; item.dConfig.GetShort(sShort, sizeof(sShort)); + char sLine[96]; switch(item.dConfig.iMode) { case MODE_COOLDOWN: { if (item.iTimeReady > RoundToCeil(GetEngineTime())) { - Format(sLine, sizeof(sLine), "%s [%d]: %N\n", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient); + Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient); } else { - Format(sLine, sizeof(sLine), "%s [%s]: %N\n", sShort, "R", item.iClient); + Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "R", item.iClient); } } case MODE_MAXUSES: { if (item.iTimesUsed < item.dConfig.iMaxUses) { - Format(sLine, sizeof(sLine), "%s [%d/%d]: %N\n", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); + Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); } else { - Format(sLine, sizeof(sLine), "%s [%s]: %N\n", sShort, "D", item.iClient); + Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "D", item.iClient); } } case MODE_COOLDOWNMAXUSES: @@ -101,32 +78,32 @@ public Action OnDisplayHUD(Handle timer) { if (item.iTimeReady > RoundToCeil(GetEngineTime())) { - Format(sLine, sizeof(sLine), "%s [%d]: %N\n", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient); + Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient); } else { - Format(sLine, sizeof(sLine), "%s [%d/%d]: %N\n", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); + Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); } } else { - Format(sLine, sizeof(sLine), "%s [%s]: %N\n", sShort, "D", item.iClient); + Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "D", item.iClient); } } case MODE_COOLDOWNCHARGES: { if (item.iTimeReady > RoundToCeil(GetEngineTime())) { - Format(sLine, sizeof(sLine), "%s [%d]: %N\n", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient); + Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient); } else { - Format(sLine, sizeof(sLine), "%s [%d/%d]: %N\n", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); + Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); } } default: { - Format(sLine, sizeof(sLine), "%s [%s]: %N\n", sShort, "N/A", item.iClient); + Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "N/A", item.iClient); } } @@ -134,39 +111,63 @@ public Action OnDisplayHUD(Handle timer) { case(2): { - if (strlen(sZombieHUD) + strlen(sLine) < sizeof(sZombieHUD)) - { - StrCat(sZombieHUD, sizeof(sZombieHUD), sLine); - } + if (strlen(sHUDPanels[1][iHUDPages[1]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[1]++; + + StrCat(sHUDPanels[1][iHUDPages[1]], sizeof(sHUDPanels[][]), sLine); + StrCat(sHUDPanels[1][iHUDPages[1]], sizeof(sHUDPanels[][]), "\n"); } case(3): { - if (strlen(sHumanHUD) + strlen(sLine) < sizeof(sHumanHUD)) - { - StrCat(sHumanHUD, sizeof(sHumanHUD), sLine); - } + if (strlen(sHUDPanels[2][iHUDPages[2]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[2]++; + + StrCat(sHUDPanels[2][iHUDPages[2]], sizeof(sHUDPanels[][]), sLine); + StrCat(sHUDPanels[2][iHUDPages[2]], sizeof(sHUDPanels[][]), "\n"); } } - if (strlen(sSpecHUD) + strlen(sLine) < sizeof(sSpecHUD)) - { - StrCat(sSpecHUD, sizeof(sSpecHUD), sLine); - } + if (strlen(sHUDPanels[0][iHUDPages[0]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[0]++; + + StrCat(sHUDPanels[0][iHUDPages[0]], sizeof(sHUDPanels[][]), sLine); + StrCat(sHUDPanels[0][iHUDPages[0]], sizeof(sHUDPanels[][]), "\n"); } } - Handle hZombieMessage = StartMessage("KeyHintText", iZombies, iZombiesCount); - BfWriteByte(hZombieMessage, 1); - BfWriteString(hZombieMessage, sZombieHUD); - EndMessage(); + static int iPageUpdate; + static int iPageCurrent[3]; - Handle hHumanMessage = StartMessage("KeyHintText", iHumans, iHumansCount); - BfWriteByte(hHumanMessage, 1); - BfWriteString(hHumanMessage, sHumanHUD); - EndMessage(); + if (iPageUpdate >= 5) + { + for (int iPageID; iPageID < 3; iPageID++) + { + if (iPageCurrent[iPageID] >= iHUDPages[iPageID]) + iPageCurrent[iPageID] = 0; + else + iPageCurrent[iPageID]++; + } - Handle hSpecMessage = StartMessage("KeyHintText", iSpecs, iSpecsCount); - BfWriteByte(hSpecMessage, 1); - BfWriteString(hSpecMessage, sSpecHUD); - EndMessage(); + iPageUpdate = 0; + } + else + iPageUpdate++; + + for (int client = 1; client <= MaxClients; client++) + { + if (!IsClientInGame(client) || IsFakeClient(client)) + continue; + + int iPanelID; + switch(GetClientTeam(client)) + { + case(2): iPanelID = 1; + case(3): iPanelID = 2; + } + + if (sHUDPanels[iPanelID][iPageCurrent[iPanelID]][0]) + { + Handle hMessage = StartMessageOne("KeyHintText", client); + BfWriteByte(hMessage, 1); + BfWriteString(hMessage, sHUDPanels[iPanelID][iPageCurrent[iPanelID]]); + EndMessage(); + } + } } \ No newline at end of file