mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-16 01:01:30 +00:00
[Dialogue] Add support for Dialogue Window titles. (#1563)
* [Dialogue] Add support for Dialogue Window titles. - Custom title allows defaults to be overridden where necessary, like a leaderboard or something. - Default target to client in case people want to send Dialogue Windows from current client. * Fix possible issue with markdown. - Example: Using the word "title" or using any identifier and forgetting the colon.
This commit is contained in:
parent
2f5d360e53
commit
bb5c491794
@ -9,10 +9,7 @@ void DialogueWindow::Render(Client *c, std::string markdown)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this is the NPC that the client is interacting with if there is dialogue going on
|
// this is the NPC that the client is interacting with if there is dialogue going on
|
||||||
Mob *target;
|
Mob* target = c->GetTarget() ? c->GetTarget() : c;
|
||||||
if (c->GetTarget()) {
|
|
||||||
target = c->GetTarget();
|
|
||||||
}
|
|
||||||
|
|
||||||
// zero this out
|
// zero this out
|
||||||
c->SetEntityVariable(DIAWIND_RESPONSE_ONE_KEY.c_str(), "");
|
c->SetEntityVariable(DIAWIND_RESPONSE_ONE_KEY.c_str(), "");
|
||||||
@ -126,7 +123,7 @@ void DialogueWindow::Render(Client *c, std::string markdown)
|
|||||||
|
|
||||||
// window type
|
// window type
|
||||||
std::string wintype;
|
std::string wintype;
|
||||||
if (markdown.find("wintype") != std::string::npos) {
|
if (markdown.find("wintype:") != std::string::npos) {
|
||||||
LogDiaWind("Client [{}] Rendering wintype option", c->GetCleanName());
|
LogDiaWind("Client [{}] Rendering wintype option", c->GetCleanName());
|
||||||
|
|
||||||
auto first_split = split_string(output, "wintype:");
|
auto first_split = split_string(output, "wintype:");
|
||||||
@ -157,7 +154,7 @@ void DialogueWindow::Render(Client *c, std::string markdown)
|
|||||||
|
|
||||||
// popupid
|
// popupid
|
||||||
std::string popupid;
|
std::string popupid;
|
||||||
if (markdown.find("popupid") != std::string::npos) {
|
if (markdown.find("popupid:") != std::string::npos) {
|
||||||
LogDiaWind("Client [{}] Rendering popupid option", c->GetCleanName());
|
LogDiaWind("Client [{}] Rendering popupid option", c->GetCleanName());
|
||||||
|
|
||||||
auto first_split = split_string(output, "popupid:");
|
auto first_split = split_string(output, "popupid:");
|
||||||
@ -193,7 +190,7 @@ void DialogueWindow::Render(Client *c, std::string markdown)
|
|||||||
|
|
||||||
// secondresponseid
|
// secondresponseid
|
||||||
std::string secondresponseid;
|
std::string secondresponseid;
|
||||||
if (markdown.find("secondresponseid") != std::string::npos) {
|
if (markdown.find("secondresponseid:") != std::string::npos) {
|
||||||
LogDiaWind("Client [{}] Rendering secondresponseid option", c->GetCleanName());
|
LogDiaWind("Client [{}] Rendering secondresponseid option", c->GetCleanName());
|
||||||
|
|
||||||
auto first_split = split_string(output, "secondresponseid:");
|
auto first_split = split_string(output, "secondresponseid:");
|
||||||
@ -225,8 +222,8 @@ void DialogueWindow::Render(Client *c, std::string markdown)
|
|||||||
std::string button_one;
|
std::string button_one;
|
||||||
std::string button_two;
|
std::string button_two;
|
||||||
if (
|
if (
|
||||||
markdown.find("button_one") != std::string::npos &&
|
markdown.find("button_one:") != std::string::npos &&
|
||||||
markdown.find("button_two") != std::string::npos
|
markdown.find("button_two:") != std::string::npos
|
||||||
) {
|
) {
|
||||||
LogDiaWind("Client [{}] Rendering button_one option.", c->GetCleanName());
|
LogDiaWind("Client [{}] Rendering button_one option.", c->GetCleanName());
|
||||||
|
|
||||||
@ -397,7 +394,39 @@ void DialogueWindow::Render(Client *c, std::string markdown)
|
|||||||
speaking = "A Mysterious Voice says";
|
speaking = "A Mysterious Voice says";
|
||||||
}
|
}
|
||||||
|
|
||||||
title = fmt::format("Dialogue [{}]", speaking);
|
// title
|
||||||
|
std::string popup_title;
|
||||||
|
if (markdown.find("title:") != std::string::npos) {
|
||||||
|
LogDiaWind("Client [{}] Rendering title option", c->GetCleanName());
|
||||||
|
|
||||||
|
auto first_split = split_string(output, "title:");
|
||||||
|
if (!first_split.empty()) {
|
||||||
|
auto second_split = split_string(first_split[1], " ");
|
||||||
|
if (!second_split.empty()) {
|
||||||
|
popup_title = second_split[0];
|
||||||
|
LogDiaWindDetail("Client [{}] Rendering title option title [{}]", c->GetCleanName(), popup_title);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (first_split[1].length() == 1) {
|
||||||
|
popup_title = first_split[1];
|
||||||
|
LogDiaWindDetail(
|
||||||
|
"Client [{}] Rendering title (end) option title [{}]",
|
||||||
|
c->GetCleanName(),
|
||||||
|
popup_title
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
find_replace(output, fmt::format("title:{}", popup_title), "");
|
||||||
|
|
||||||
|
if (!popup_title.empty()) {
|
||||||
|
title = popup_title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (title.empty()) {
|
||||||
|
title = fmt::format("Dialogue [{}]", speaking);
|
||||||
|
}
|
||||||
|
|
||||||
// render quotes
|
// render quotes
|
||||||
std::string quote_string = "'";
|
std::string quote_string = "'";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user