Inspecting now logs to the chat
TODO: make configurable!
This commit is contained in:
parent
f7d2303fe0
commit
39a6e900a4
Before Width: | Height: | Size: 145 B After Width: | Height: | Size: 145 B |
Before Width: | Height: | Size: 178 B After Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 174 B After Width: | Height: | Size: 174 B |
@ -760,23 +760,30 @@ void MainInterface::update(float dt) {
|
||||
m_chatBubbleManager->setCamera(m_worldPainter->camera());
|
||||
if (auto worldClient = m_client->worldClient()) {
|
||||
auto chatActions = worldClient->pullPendingChatActions();
|
||||
auto portraitActions = chatActions.filtered([](ChatAction action) { return action.is<PortraitChatAction>(); });
|
||||
|
||||
for (auto action : portraitActions) {
|
||||
PortraitChatAction portraitAction = action.get<PortraitChatAction>();
|
||||
for (auto& action : chatActions) {
|
||||
if (action.is<PortraitChatAction>()) {
|
||||
PortraitChatAction& portraitAction = action.get<PortraitChatAction>();
|
||||
|
||||
String name;
|
||||
if (auto npc = as<Npc>(worldClient->entity(portraitAction.entity)))
|
||||
name = npc->name();
|
||||
String name;
|
||||
if (auto npc = as<Npc>(worldClient->entity(portraitAction.entity)))
|
||||
name = npc->name();
|
||||
|
||||
ChatReceivedMessage message = {
|
||||
{ MessageContext::World },
|
||||
ServerConnectionId,
|
||||
Text::stripEscapeCodes(name),
|
||||
Text::stripEscapeCodes(portraitAction.text),
|
||||
Text::stripEscapeCodes(portraitAction.portrait.replace("<frame>", "0"))
|
||||
};
|
||||
m_chat->addMessages({message}, false);
|
||||
ChatReceivedMessage message = {
|
||||
{MessageContext::World},
|
||||
ServerConnectionId,
|
||||
Text::stripEscapeCodes(name),
|
||||
Text::stripEscapeCodes(portraitAction.text),
|
||||
Text::stripEscapeCodes(portraitAction.portrait.replace("<frame>", "0"))};
|
||||
m_chat->addMessages({message}, false);
|
||||
} else if (action.is<SayChatAction>()) {
|
||||
SayChatAction& sayAction = action.get<SayChatAction>();
|
||||
|
||||
if (sayAction.config) {
|
||||
if (auto message = sayAction.config.opt("message"))
|
||||
m_chat->addMessages({ChatReceivedMessage(*message)}, sayAction.config.getBool("showPane", false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_chatBubbleManager->addChatActions(chatActions);
|
||||
|
@ -55,7 +55,7 @@ ChatReceivedMessage::ChatReceivedMessage(Json const& json) : ChatReceivedMessage
|
||||
fromConnection = json.getUInt("fromConnection", 0);
|
||||
fromNick = json.getString("fromNick", "");
|
||||
portrait = json.getString("portrait", "");
|
||||
text = json.getString("text");
|
||||
text = json.getString("text", "");
|
||||
}
|
||||
|
||||
Json ChatReceivedMessage::toJson() const {
|
||||
|
@ -976,15 +976,21 @@ void Player::update(float dt, uint64_t) {
|
||||
});
|
||||
}
|
||||
|
||||
for (auto tool : {m_tools->primaryHandItem(), m_tools->altHandItem()}) {
|
||||
for (auto& tool : {m_tools->primaryHandItem(), m_tools->altHandItem()}) {
|
||||
if (auto inspectionTool = as<InspectionTool>(tool)) {
|
||||
for (auto ir : inspectionTool->pullInspectionResults()) {
|
||||
for (auto& ir : inspectionTool->pullInspectionResults()) {
|
||||
if (ir.objectName) {
|
||||
m_questManager->receiveMessage("objectScanned", true, {*ir.objectName, *ir.entityId});
|
||||
m_log->addScannedObject(*ir.objectName);
|
||||
}
|
||||
|
||||
addChatMessage(ir.message);
|
||||
addChatMessage(ir.message, JsonObject{
|
||||
{"message", JsonObject{
|
||||
{"context", JsonObject{{"mode", "RadioMessage"}}},
|
||||
{"fromConnection", world()->connection()},
|
||||
{"text", ir.message}
|
||||
}}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2178,12 +2184,12 @@ void Player::queueItemPickupMessage(ItemPtr const& item) {
|
||||
m_queuedItemPickups.append(item);
|
||||
}
|
||||
|
||||
void Player::addChatMessage(String const& message) {
|
||||
void Player::addChatMessage(String const& message, Json const& config) {
|
||||
starAssert(!isSlave());
|
||||
m_chatMessage = message;
|
||||
m_chatMessageUpdated = true;
|
||||
m_chatMessageChanged = true;
|
||||
m_pendingChatActions.append(SayChatAction{entityId(), message, mouthPosition()});
|
||||
m_pendingChatActions.append(SayChatAction{entityId(), message, mouthPosition(), config});
|
||||
}
|
||||
|
||||
void Player::addEmote(HumanoidEmote const& emote, Maybe<float> emoteCooldown) {
|
||||
|
@ -381,7 +381,7 @@ public:
|
||||
void queueUIMessage(String const& message) override;
|
||||
void queueItemPickupMessage(ItemPtr const& item);
|
||||
|
||||
void addChatMessage(String const& message);
|
||||
void addChatMessage(String const& message, Json const& config = {});
|
||||
void addEmote(HumanoidEmote const& emote, Maybe<float> emoteCooldown = {});
|
||||
pair<HumanoidEmote, float> currentEmote() const;
|
||||
|
||||
|
@ -496,7 +496,7 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) {
|
||||
else { // this is THEIR problem!!
|
||||
Logger::error("WorldClient: Exception caught in {}::render ({}): {}", EntityTypeNames.getRight(entity->entityType()), entity->entityId(), e.what());
|
||||
auto toolUser = as<ToolUserEntity>(entity);
|
||||
String image = toolUser ? strf("/rendering/error_{}.png", DirectionNames.getRight(toolUser->facingDirection())) : "/rendering/error.png";
|
||||
String image = toolUser ? strf("/rendering/sprites/error_{}.png", DirectionNames.getRight(toolUser->facingDirection())) : "/rendering/sprites/error.png";
|
||||
Color color = Color::rgbf(0.8f + (float)sin(m_currentTime * Constants::pi * 2.0) * 0.2f, 0.0f, 0.0f);
|
||||
auto drawable = Drawable::makeImage(image, 1.0f / TilePixels, true, entity->position(), color);
|
||||
drawable.fullbright = true;
|
||||
|
Loading…
Reference in New Issue
Block a user