mirror of
https://github.com/EQEmu/Server.git
synced 2026-04-07 09:02:26 +00:00
[Commands] Cleanup #timers Command. (#1965)
- Cleanup message and logic. - Utilize popup instead of chat messages. - Utilize ConvertSecondsToTime() helper method.
This commit is contained in:
parent
f9eb4603a3
commit
1ea8888607
@ -2,21 +2,45 @@
|
|||||||
|
|
||||||
void command_timers(Client *c, const Seperator *sep)
|
void command_timers(Client *c, const Seperator *sep)
|
||||||
{
|
{
|
||||||
if (!c->GetTarget() || !c->GetTarget()->IsClient()) {
|
auto target = c;
|
||||||
c->Message(Chat::White, "Need a player target for timers.");
|
if (c->GetTarget() && c->GetTarget()->IsClient()) {
|
||||||
return;
|
target = c->GetTarget()->CastToClient();
|
||||||
}
|
}
|
||||||
Client *them = c->GetTarget()->CastToClient();
|
|
||||||
|
|
||||||
std::vector<std::pair<pTimerType, PersistentTimer *> > res;
|
std::vector<std::pair<pTimerType, PersistentTimer *>> timers;
|
||||||
them->GetPTimers().ToVector(res);
|
target->GetPTimers().ToVector(timers);
|
||||||
|
|
||||||
c->Message(Chat::White, "Timers for target:");
|
std::string popup_title = fmt::format(
|
||||||
|
"Recast Timers for {}",
|
||||||
|
c == target ?
|
||||||
|
"Yourself" :
|
||||||
|
fmt::format(
|
||||||
|
"{} ({})",
|
||||||
|
target->GetCleanName(),
|
||||||
|
target->GetID()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
int r;
|
std::string popup_text = "<table>";
|
||||||
int l = res.size();
|
|
||||||
for (r = 0; r < l; r++) {
|
popup_text += "<tr><td>Timer ID</td><td>Remaining</td></tr>";
|
||||||
c->Message(Chat::White, "Timer %d: %d seconds remain.", res[r].first, res[r].second->GetRemainingTime());
|
|
||||||
|
for (const auto& timer : timers) {
|
||||||
|
auto remaining_time = timer.second->GetRemainingTime();
|
||||||
|
if (remaining_time) {
|
||||||
|
popup_text += fmt::format(
|
||||||
|
"<tr><td>{}</td><td>{}</td></tr>",
|
||||||
|
timer.first,
|
||||||
|
ConvertSecondsToTime(remaining_time)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
popup_text += "</table>";
|
||||||
|
|
||||||
|
c->SendPopupToClient(
|
||||||
|
popup_title.c_str(),
|
||||||
|
popup_text.c_str()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user