add Nametag Directives
This commit is contained in:
parent
0135629301
commit
e64aabfcf1
@ -1,4 +1,9 @@
|
|||||||
{
|
{
|
||||||
|
"nametag" : {
|
||||||
|
"showMasterNames" : true,
|
||||||
|
"fontDirectives" : "?border=2;444;4440",
|
||||||
|
"inspectOpacityRate" : 0.15
|
||||||
|
},
|
||||||
"font" : {
|
"font" : {
|
||||||
"defaultDirectives" : "",
|
"defaultDirectives" : "",
|
||||||
"defaultFont" : ""
|
"defaultFont" : ""
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"config" : {
|
"config" : {
|
||||||
"font" : {
|
"font" : {
|
||||||
"directives" : "?border=1;000;0000",
|
"directives" : "?border=1;333a;3330",
|
||||||
"padding" : [1, 1] // Padding to prevent border clipping at the edges of the log canvas while keeping compat with mods that patch the canvas size
|
"padding" : [1, 1] // Padding to prevent border clipping at the edges of the log canvas while keeping compat with mods that patch the canvas size
|
||||||
},
|
},
|
||||||
"colors" : {
|
"colors" : {
|
||||||
|
@ -659,7 +659,7 @@ uint64_t Json::queryUInt(String const& query, uint64_t def) const {
|
|||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
String Json::queryString(String const& query, String def) const {
|
String Json::queryString(String const& query, String const& def) const {
|
||||||
auto json = JsonPath::pathFind(*this, JsonPath::parseQueryPath, query);
|
auto json = JsonPath::pathFind(*this, JsonPath::parseQueryPath, query);
|
||||||
if (json && *json)
|
if (json && *json)
|
||||||
return json->toString();
|
return json->toString();
|
||||||
|
@ -201,7 +201,7 @@ public:
|
|||||||
bool queryBool(String const& path, bool def) const;
|
bool queryBool(String const& path, bool def) const;
|
||||||
int64_t queryInt(String const& path, int64_t def) const;
|
int64_t queryInt(String const& path, int64_t def) const;
|
||||||
uint64_t queryUInt(String const& path, uint64_t def) const;
|
uint64_t queryUInt(String const& path, uint64_t def) const;
|
||||||
String queryString(String const& path, String def) const;
|
String queryString(String const& path, String const& def) const;
|
||||||
JsonArray queryArray(String const& path, JsonArray def) const;
|
JsonArray queryArray(String const& path, JsonArray def) const;
|
||||||
JsonObject queryObject(String const& path, JsonObject def) const;
|
JsonObject queryObject(String const& path, JsonObject def) const;
|
||||||
|
|
||||||
|
@ -139,13 +139,11 @@ void BubbleSeparator<T>::forEach(function<void(Bubble&, T&)> func) {
|
|||||||
RectF boundBox = bubble.boundBox.translated(positionDelta);
|
RectF boundBox = bubble.boundBox.translated(positionDelta);
|
||||||
RectF separated = separateBubble(m_sortedLeftEdges, m_sortedRightEdges, boundBox);
|
RectF separated = separateBubble(m_sortedLeftEdges, m_sortedRightEdges, boundBox);
|
||||||
anyMoved = true;
|
anyMoved = true;
|
||||||
bubble = Bubble{bubble.contents,
|
bubble.currentDestination = bubble.idealDestination;
|
||||||
bubble.idealDestination,
|
bubble.boundBox = boundBox;
|
||||||
bubble.idealDestination,
|
bubble.separatedPosition = bubble.idealDestination + separated.min() - boundBox.min();
|
||||||
boundBox,
|
bubble.separatedBox = separated;
|
||||||
bubble.idealDestination + separated.min() - boundBox.min(),
|
bubble.currentPosition += positionDelta;
|
||||||
separated,
|
|
||||||
bubble.currentPosition + positionDelta};
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (anyMoved)
|
if (anyMoved)
|
||||||
|
@ -754,6 +754,7 @@ void MainInterface::update() {
|
|||||||
m_nameplatePainter->update(m_client->worldClient(), m_worldPainter->camera(), m_client->worldClient()->interactiveHighlightMode());
|
m_nameplatePainter->update(m_client->worldClient(), m_worldPainter->camera(), m_client->worldClient()->interactiveHighlightMode());
|
||||||
m_questIndicatorPainter->update(m_client->worldClient(), m_worldPainter->camera());
|
m_questIndicatorPainter->update(m_client->worldClient(), m_worldPainter->camera());
|
||||||
|
|
||||||
|
m_chatBubbleManager->setCamera(m_worldPainter->camera());
|
||||||
if (auto worldClient = m_client->worldClient()) {
|
if (auto worldClient = m_client->worldClient()) {
|
||||||
auto chatActions = worldClient->pullPendingChatActions();
|
auto chatActions = worldClient->pullPendingChatActions();
|
||||||
auto portraitActions = chatActions.filtered([](ChatAction action) { return action.is<PortraitChatAction>(); });
|
auto portraitActions = chatActions.filtered([](ChatAction action) { return action.is<PortraitChatAction>(); });
|
||||||
@ -778,7 +779,6 @@ void MainInterface::update() {
|
|||||||
m_chatBubbleManager->addChatActions(chatActions);
|
m_chatBubbleManager->addChatActions(chatActions);
|
||||||
m_chatBubbleManager->update(worldClient);
|
m_chatBubbleManager->update(worldClient);
|
||||||
}
|
}
|
||||||
m_chatBubbleManager->setCamera(m_worldPainter->camera());
|
|
||||||
|
|
||||||
if (auto container = m_client->worldClient()->get<ContainerEntity>(m_containerInteractor->openContainerId())) {
|
if (auto container = m_client->worldClient()->get<ContainerEntity>(m_containerInteractor->openContainerId())) {
|
||||||
if (!m_client->worldClient()->playerCanReachEntity(container->entityId())
|
if (!m_client->worldClient()->playerCanReachEntity(container->entityId())
|
||||||
|
@ -11,12 +11,16 @@ NameplatePainter::NameplatePainter() {
|
|||||||
auto assets = Root::singleton().assets();
|
auto assets = Root::singleton().assets();
|
||||||
|
|
||||||
Json nametagConfig = assets->json("/interface.config:nametag");
|
Json nametagConfig = assets->json("/interface.config:nametag");
|
||||||
|
m_showMasterNames = nametagConfig.getBool("showMasterNames");
|
||||||
m_opacityRate = nametagConfig.getFloat("opacityRate");
|
m_opacityRate = nametagConfig.getFloat("opacityRate");
|
||||||
|
m_inspectOpacityRate = nametagConfig.queryFloat("inspectOpacityRate", m_opacityRate);
|
||||||
m_offset = jsonToVec2F(nametagConfig.get("offset"));
|
m_offset = jsonToVec2F(nametagConfig.get("offset"));
|
||||||
m_font = nametagConfig.optString("font").value("");
|
m_font = nametagConfig.queryString("font", "");
|
||||||
m_statusFont = nametagConfig.optString("font").value(m_font);
|
m_fontDirectives = nametagConfig.queryString("fontDirectives", "");
|
||||||
m_fontSize = nametagConfig.getFloat("fontSize");
|
m_fontSize = nametagConfig.getFloat("fontSize");
|
||||||
m_statusFontSize = nametagConfig.getFloat("statusFontSize");
|
m_statusFont = nametagConfig.queryString("font", m_font);
|
||||||
|
m_statusFontDirectives = nametagConfig.queryString("fontDirectives", m_fontDirectives);
|
||||||
|
m_statusFontSize = nametagConfig.queryFloat("statusFontSize", m_fontSize);
|
||||||
m_statusOffset = jsonToVec2F(nametagConfig.get("statusOffset"));
|
m_statusOffset = jsonToVec2F(nametagConfig.get("statusOffset"));
|
||||||
m_statusColor = jsonToColor(nametagConfig.get("statusColor"));
|
m_statusColor = jsonToColor(nametagConfig.get("statusColor"));
|
||||||
m_opacityBoost = nametagConfig.getFloat("opacityBoost");
|
m_opacityBoost = nametagConfig.getFloat("opacityBoost");
|
||||||
@ -29,7 +33,7 @@ void NameplatePainter::update(WorldClientPtr const& world, WorldCamera const& ca
|
|||||||
|
|
||||||
Set<EntityId> foundEntities;
|
Set<EntityId> foundEntities;
|
||||||
for (auto const& entity : world->query<NametagEntity>(camera.worldScreenRect())) {
|
for (auto const& entity : world->query<NametagEntity>(camera.worldScreenRect())) {
|
||||||
if (entity->isMaster() || !entity->displayNametag())
|
if ((entity->isMaster() && !m_showMasterNames) || !entity->displayNametag())
|
||||||
continue;
|
continue;
|
||||||
if (auto player = as<Player>(entity)) {
|
if (auto player = as<Player>(entity)) {
|
||||||
if (player->isTeleporting())
|
if (player->isTeleporting())
|
||||||
@ -57,7 +61,7 @@ void NameplatePainter::update(WorldClientPtr const& world, WorldCamera const& ca
|
|||||||
nametag.color = entity->nametagColor();
|
nametag.color = entity->nametagColor();
|
||||||
bool fullyOnScreen = world->geometry().rectContains(camera.worldScreenRect(), entity->position());
|
bool fullyOnScreen = world->geometry().rectContains(camera.worldScreenRect(), entity->position());
|
||||||
if (inspectionMode)
|
if (inspectionMode)
|
||||||
nametag.opacity = 1.0f;
|
nametag.opacity = approach(1.0f, nametag.opacity, m_inspectOpacityRate);
|
||||||
else if (fullyOnScreen)
|
else if (fullyOnScreen)
|
||||||
nametag.opacity = approach(0.0f, nametag.opacity, m_opacityRate);
|
nametag.opacity = approach(0.0f, nametag.opacity, m_opacityRate);
|
||||||
else
|
else
|
||||||
@ -77,21 +81,25 @@ void NameplatePainter::render() {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
context.setFont(m_font);
|
context.setFont(m_font);
|
||||||
|
context.setFontProcessingDirectives(m_fontDirectives);
|
||||||
context.setFontSize(m_fontSize);
|
context.setFontSize(m_fontSize);
|
||||||
|
|
||||||
auto color = Color::rgb(nametag.color);
|
auto color = Color::rgb(nametag.color);
|
||||||
color.setAlphaF(nametag.opacity);
|
color.setAlphaF(nametag.opacity);
|
||||||
auto statusColor = m_statusColor;
|
|
||||||
statusColor.setAlphaF(nametag.opacity);
|
|
||||||
context.setFontColor(color.toRgba());
|
context.setFontColor(color.toRgba());
|
||||||
context.setFontMode(FontMode::Shadow);
|
context.setFontMode(FontMode::Shadow);
|
||||||
|
|
||||||
context.renderText(nametag.name, namePosition(bubble.currentPosition));
|
context.renderText(nametag.name, namePosition(bubble.currentPosition));
|
||||||
|
|
||||||
if (nametag.statusText) {
|
if (nametag.statusText) {
|
||||||
context.setFontSize(m_statusFontSize);
|
auto statusColor = m_statusColor;
|
||||||
context.setFont(m_statusFont);
|
statusColor.setAlphaF(nametag.opacity);
|
||||||
context.setFontColor(statusColor.toRgba());
|
context.setFontColor(statusColor.toRgba());
|
||||||
|
|
||||||
|
context.setFontSize(m_statusFontSize);
|
||||||
|
context.setFontProcessingDirectives(m_statusFontDirectives);
|
||||||
|
context.setFont(m_statusFont);
|
||||||
|
|
||||||
context.renderText(*nametag.statusText, statusPosition(bubble.currentPosition));
|
context.renderText(*nametag.statusText, statusPosition(bubble.currentPosition));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -111,10 +119,12 @@ TextPositioning NameplatePainter::statusPosition(Vec2F bubblePosition) const {
|
|||||||
RectF NameplatePainter::determineBoundBox(Vec2F bubblePosition, Nametag const& nametag) const {
|
RectF NameplatePainter::determineBoundBox(Vec2F bubblePosition, Nametag const& nametag) const {
|
||||||
auto& context = GuiContext::singleton();
|
auto& context = GuiContext::singleton();
|
||||||
context.setFontSize(m_fontSize);
|
context.setFontSize(m_fontSize);
|
||||||
|
context.setFontProcessingDirectives(m_fontDirectives);
|
||||||
context.setFont(m_font);
|
context.setFont(m_font);
|
||||||
RectF nametagBox = context.determineTextSize(nametag.name, namePosition(bubblePosition));
|
RectF nametagBox = context.determineTextSize(nametag.name, namePosition(bubblePosition));
|
||||||
if (nametag.statusText) {
|
if (nametag.statusText) {
|
||||||
context.setFontSize(m_statusFontSize);
|
context.setFontSize(m_statusFontSize);
|
||||||
|
context.setFontProcessingDirectives(m_statusFontDirectives);
|
||||||
context.setFont(m_statusFont);
|
context.setFont(m_statusFont);
|
||||||
nametagBox.combine(context.determineTextSize(*nametag.statusText, statusPosition(bubblePosition)));
|
nametagBox.combine(context.determineTextSize(*nametag.statusText, statusPosition(bubblePosition)));
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,14 @@ private:
|
|||||||
TextPositioning statusPosition(Vec2F bubblePosition) const;
|
TextPositioning statusPosition(Vec2F bubblePosition) const;
|
||||||
RectF determineBoundBox(Vec2F bubblePosition, Nametag const& nametag) const;
|
RectF determineBoundBox(Vec2F bubblePosition, Nametag const& nametag) const;
|
||||||
|
|
||||||
|
bool m_showMasterNames;
|
||||||
float m_opacityRate;
|
float m_opacityRate;
|
||||||
|
float m_inspectOpacityRate;
|
||||||
Vec2F m_offset;
|
Vec2F m_offset;
|
||||||
String m_font;
|
String m_font;
|
||||||
String m_statusFont;
|
String m_statusFont;
|
||||||
|
String m_fontDirectives;
|
||||||
|
String m_statusFontDirectives;
|
||||||
float m_fontSize;
|
float m_fontSize;
|
||||||
float m_statusFontSize;
|
float m_statusFontSize;
|
||||||
Vec2F m_statusOffset;
|
Vec2F m_statusOffset;
|
||||||
|
Loading…
Reference in New Issue
Block a user