21 const protocol::Duel& duel) {
22 if (duel.state() != state_) {
24 if (duel.state() == protocol::DUEL_FIGHTING) {
25 started_ = ImGui::GetTime();
27 state_ = duel.state();
30 const ImVec2 screen = ImGui::GetIO().DisplaySize;
31 const auto shout = [&screen](
const std::string& words,
float alpha) {
33 const float size =
Ui(110.0f);
35 title->CalcTextSizeA(size, FLT_MAX, 0.0f, words.c_str());
37 {(screen.x - extent.x) / 2.0f, screen.y * 0.22f},
41 const double fighting = ImGui::GetTime() - started_;
42 if (duel.state() == protocol::DUEL_COUNTDOWN) {
44 }
else if (duel.state() == protocol::DUEL_FIGHTING && fighting <
kFight) {
45 shout(
Tr(
"Fight!"),
static_cast<float>(1.0 - fighting /
kFight));
47 if (duel.state() != protocol::DUEL_ASKED ||
51 ImGui::SetNextWindowPos({screen.x / 2.0f, screen.y * 0.3f}, ImGuiCond_Always,
54 std::optional<protocol::DuelAction> action;
56 ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove |
57 ImGuiWindowFlags_NoSavedSettings);
58 ImGui::TextUnformatted(
59 absl::Substitute(
Tr(
"$0 asks you to duel."), duel.opponent()).c_str());
62 action.emplace().set_accept(
true);
66 if (
GameButton(
"Not now", {
Ui(150.0f), 0.0f}) || !open) {
67 action.emplace().set_decline(
true);
71 answered_ = ImGui::GetTime();
void DrawGradientText(ImDrawList *draw, ImFont *font, float size, ImVec2 at, ImU32 top, ImU32 bottom, const char *text)