[Quest API] Add Popup methods to Perl/Lua. (#2533)

* [Quest API] Add Popup methods to Perl/Lua.

# Perl
- Add `quest::popupcentermessage(message)` to Perl.
- Add `quest::popupcolormessage(color, message)` to Perl.
- Add `quest::popupindent()` to Perl.
- Add `quest::popuplink(link)` to Perl.
- Add `quest::popuplink(link, message)` to Perl.

# Lua
- Add `eq.popup(title, message)` to Lua.
- Add `eq.popup(title, message, popup_id)` to Lua.
- Add `eq.popup(title, message, popup_id, buttons)` to Lua.
- Add `eq.popup_center_message(message)` to Lua.
- Add `eq.popup_color_message(color, message)` to Lua.
- Add `eq.popup_indent()` to Lua.
- Add `eq.popup_link(link)` to Lua.
- Add `eq.popup_link(link, message)` to Lua.

# Notes
- Adds the Perl plugins like PWAutoCenter, PWIndent, and PWHyperlink.
- Parses out HTML `<>` tags automatically in `popupautocenter` to properly center stuff like colored messages. (Doesn't work with links)
- This lets Lua users have similar functionality to Perl users.

* Add tables and break.

* Add indent_count to indent method.

* Move to Dialogue Window.
This commit is contained in:
Kinglykrab
2022-11-14 14:05:24 -05:00
committed by GitHub
parent 31e5622dad
commit 9c967c24b8
4 changed files with 272 additions and 1 deletions
+77 -1
View File
@@ -27,6 +27,7 @@
#include "lua_encounter.h"
#include "data_bucket.h"
#include "expedition.h"
#include "dialogue_window.h"
struct Events { };
struct Factions { };
@@ -772,6 +773,18 @@ void lua_end_dz_task(bool send_fail) {
quest_manager.EndCurrentDzTask(send_fail);
}
void lua_popup(const char *title, const char *text) {
quest_manager.popup(title, text, 0, 0, 0);
}
void lua_popup(const char *title, const char *text, uint32 id) {
quest_manager.popup(title, text, id, 0, 0);
}
void lua_popup(const char *title, const char *text, uint32 id, uint32 buttons) {
quest_manager.popup(title, text, id, buttons, 0);
}
void lua_popup(const char *title, const char *text, uint32 id, uint32 buttons, uint32 duration) {
quest_manager.popup(title, text, id, buttons, duration);
}
@@ -3464,6 +3477,54 @@ std::string lua_get_aa_name(int aa_id) {
return zone->GetAAName(aa_id);
}
std::string lua_popup_break() {
return DialogueWindow::Break();
}
std::string lua_popup_break(uint32 break_count) {
return DialogueWindow::Break(break_count);
}
std::string lua_popup_center_message(std::string message) {
return DialogueWindow::CenterMessage(message);
}
std::string lua_popup_color_message(std::string color, std::string message) {
return DialogueWindow::ColorMessage(color, message);
}
std::string lua_popup_indent() {
return DialogueWindow::Indent();
}
std::string lua_popup_indent(uint32 indent_count) {
return DialogueWindow::Indent(indent_count);
}
std::string lua_popup_link(std::string link) {
return DialogueWindow::Link(link);
}
std::string lua_popup_link(std::string link, std::string message) {
return DialogueWindow::Link(link, message);
}
std::string lua_popup_table(std::string message) {
return DialogueWindow::Table(message);
}
std::string lua_popup_table_cell() {
return DialogueWindow::TableCell();
}
std::string lua_popup_table_cell(std::string message) {
return DialogueWindow::TableCell(message);
}
std::string lua_popup_table_row(std::string message) {
return DialogueWindow::TableRow(message);
}
#define LuaCreateNPCParse(name, c_type, default_value) do { \
cur = table[#name]; \
if(luabind::type(cur) != LUA_TNIL) { \
@@ -3774,7 +3835,6 @@ luabind::scope lua_register_general() {
luabind::def("get_dz_task_id", &lua_get_dz_task_id),
luabind::def("end_dz_task", (void(*)())&lua_end_dz_task),
luabind::def("end_dz_task", (void(*)(bool))&lua_end_dz_task),
luabind::def("popup", &lua_popup),
luabind::def("clear_spawn_timers", &lua_clear_spawn_timers),
luabind::def("zone_emote", &lua_zone_emote),
luabind::def("world_emote", &lua_world_emote),
@@ -3934,6 +3994,22 @@ luabind::scope lua_register_general() {
luabind::def("is_raining", &lua_is_raining),
luabind::def("is_snowing", &lua_is_snowing),
luabind::def("get_aa_name", &lua_get_aa_name),
luabind::def("popup", (void(*)(const char*,const char*))&lua_popup),
luabind::def("popup", (void(*)(const char*,const char*,uint32))&lua_popup),
luabind::def("popup", (void(*)(const char*,const char*,uint32,uint32))&lua_popup),
luabind::def("popup", (void(*)(const char*,const char*,uint32,uint32,uint32))&lua_popup),
luabind::def("popup_break", (std::string(*)(void))&lua_popup_break),
luabind::def("popup_break", (std::string(*)(uint32))&lua_popup_break),
luabind::def("popup_center_message", &lua_popup_center_message),
luabind::def("popup_color_message", &lua_popup_color_message),
luabind::def("popup_indent", (std::string(*)(void))&lua_popup_indent),
luabind::def("popup_indent", (std::string(*)(uint32))&lua_popup_indent),
luabind::def("popup_link", (std::string(*)(std::string))&lua_popup_link),
luabind::def("popup_link", (std::string(*)(std::string,std::string))&lua_popup_link),
luabind::def("popup_table", &lua_popup_table),
luabind::def("popup_table_cell", (std::string(*)(void))&lua_popup_table_cell),
luabind::def("popup_table_cell", (std::string(*)(std::string))&lua_popup_table_cell),
luabind::def("popup_table_row", &lua_popup_table_row),
/*
Cross Zone