mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
HUD tracking: polish bubble trap button prompt
This commit is contained in:
parent
4d93503dee
commit
083ebbbff9
1 changed files with 32 additions and 8 deletions
|
|
@ -1,9 +1,12 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <functional>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "core/static_vec.hpp"
|
#include "core/static_vec.hpp"
|
||||||
|
#include "cxxutil.hpp"
|
||||||
#include "v_draw.hpp"
|
#include "v_draw.hpp"
|
||||||
|
|
||||||
#include "g_game.h"
|
#include "g_game.h"
|
||||||
|
|
@ -66,7 +69,8 @@ struct TargetTracking
|
||||||
|
|
||||||
struct Tooltip
|
struct Tooltip
|
||||||
{
|
{
|
||||||
Tooltip(srb2::Draw::TextElement&& text_) : text(text_) {}
|
Tooltip(srb2::Draw::TextElement&& text_) : var(text_) {}
|
||||||
|
Tooltip(std::function<void(const srb2::Draw&)>&& fn) : var(fn) {}
|
||||||
|
|
||||||
Tooltip& offset3d(fixed_t x, fixed_t y, fixed_t z)
|
Tooltip& offset3d(fixed_t x, fixed_t y, fixed_t z)
|
||||||
{
|
{
|
||||||
|
|
@ -76,7 +80,7 @@ struct TargetTracking
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
srb2::Draw::TextElement text;
|
std::variant<srb2::Draw::TextElement, std::function<void(const srb2::Draw&)>> var;
|
||||||
vector3_t ofs = {};
|
vector3_t ofs = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -403,7 +407,18 @@ std::optional<TargetTracking::Tooltip> object_tooltip(const mobj_t* mobj)
|
||||||
case MT_BUBBLESHIELDTRAP:
|
case MT_BUBBLESHIELDTRAP:
|
||||||
return conditional(
|
return conditional(
|
||||||
mobj->tracer == stplyr->mo,
|
mobj->tracer == stplyr->mo,
|
||||||
[&] { return TextElement(((leveltime / 3) % 2) ? "\xB3 " : " \xB2").font(Draw::Font::kMenu); }
|
[&]
|
||||||
|
{
|
||||||
|
return [](const Draw& box)
|
||||||
|
{
|
||||||
|
bool left = (leveltime / 3) % 2;
|
||||||
|
box
|
||||||
|
.x(12 * (left ? -1 : 1))
|
||||||
|
.font(Draw::Font::kMenu)
|
||||||
|
.align(left ? Draw::Align::kRight : Draw::Align::kLeft)
|
||||||
|
.text(left ? "\xB3" : "\xB2");
|
||||||
|
};
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
case MT_GARDENTOP:
|
case MT_GARDENTOP:
|
||||||
|
|
@ -461,9 +476,14 @@ void K_DrawTargetTracking(const TargetTracking& target)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
srb2::Draw(FixedToFloat(result.x), FixedToFloat(result.y))
|
using srb2::Draw;
|
||||||
.align(srb2::Draw::Align::kCenter)
|
Draw box = Draw(FixedToFloat(result.x), FixedToFloat(result.y)).align(Draw::Align::kCenter);
|
||||||
.text(target.tooltip->text);
|
auto visitor = srb2::Overload {
|
||||||
|
[&](const srb2::Draw::TextElement& text) { box.text(text); },
|
||||||
|
[&](const std::function<void(const srb2::Draw&)>& fn) { fn(box); },
|
||||||
|
};
|
||||||
|
std::visit(visitor, target.tooltip->var);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -818,15 +838,19 @@ void K_drawTargetHUD(const vector3_t* origin, player_t* player)
|
||||||
|
|
||||||
if (tooltip)
|
if (tooltip)
|
||||||
{
|
{
|
||||||
tooltip->text.flags(tooltip->text.flags().value_or(0) | V_SPLITSCREEN);
|
if (auto* text = std::get_if<srb2::Draw::TextElement>(&tooltip->var))
|
||||||
tr.tooltip = tooltip;
|
{
|
||||||
|
text->flags(text->flags().value_or(0) | V_SPLITSCREEN);
|
||||||
|
}
|
||||||
|
|
||||||
const vector3_t copy = pos;
|
const vector3_t copy = pos;
|
||||||
FV3_Add(&pos, &tooltip->ofs);
|
FV3_Add(&pos, &tooltip->ofs);
|
||||||
K_ObjectTracking(&tr.result, &pos, false);
|
K_ObjectTracking(&tr.result, &pos, false);
|
||||||
pos = copy;
|
pos = copy;
|
||||||
|
|
||||||
|
tr.tooltip = tooltip;
|
||||||
targetList.push_back(tr);
|
targetList.push_back(tr);
|
||||||
|
tr.tooltip = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mobj->player)
|
if (!mobj->player)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue