mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-06 09:03:52 +00:00
chore(lua): refactor addon Lua engine API + progress docs
- Refactor Lua addon integration: - Update CMakeLists.txt for addon build paths - Enhance addons API headers and Lua engine interface - Add new Lua API addon modules (`lua_api_helpers`, `lua_api_registrations`, `lua_services`, `lua_action_api`, `lua_inventory_api`, `lua_quest_api`, `lua_social_api`, `lua_spell_api`, `lua_system_api`, `lua_unit_api`) - Update implementation in addon_manager.cpp, lua_engine.cpp, application.cpp, game_handler.cpp
This commit is contained in:
parent
6e02b4451c
commit
a916270a13
21 changed files with 6183 additions and 6700 deletions
|
|
@ -53,23 +53,6 @@ namespace {
|
|||
return s.substr(first, last - first + 1);
|
||||
}
|
||||
|
||||
// Format a duration in seconds as compact text: "2h", "3:05", "42"
|
||||
void fmtDurationCompact(char* buf, size_t sz, int secs) {
|
||||
if (secs >= 3600) snprintf(buf, sz, "%dh", secs / 3600);
|
||||
else if (secs >= 60) snprintf(buf, sz, "%d:%02d", secs / 60, secs % 60);
|
||||
else snprintf(buf, sz, "%d", secs);
|
||||
}
|
||||
|
||||
// Render "Remaining: Xs" or "Remaining: Xm Ys" in a tooltip (light gray)
|
||||
void renderAuraRemaining(int remainMs) {
|
||||
if (remainMs <= 0) return;
|
||||
int s = remainMs / 1000;
|
||||
char buf[32];
|
||||
if (s < 60) snprintf(buf, sizeof(buf), "Remaining: %ds", s);
|
||||
else snprintf(buf, sizeof(buf), "Remaining: %dm %ds", s / 60, s % 60);
|
||||
ImGui::TextColored(kLightGray, "%s", buf);
|
||||
}
|
||||
|
||||
std::string toLower(std::string s) {
|
||||
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
|
|
@ -187,12 +170,10 @@ bool ChatPanel::shouldShowMessage(const game::MessageChatData& msg, int tabIndex
|
|||
|
||||
|
||||
// Forward declaration — defined below
|
||||
static std::string firstMacroCommand(const std::string& macroText);
|
||||
static std::vector<std::string> allMacroCommands(const std::string& macroText);
|
||||
static std::string evaluateMacroConditionals(const std::string& rawArg,
|
||||
game::GameHandler& gameHandler,
|
||||
uint64_t& targetOverride);
|
||||
static std::string getMacroShowtooltipArg(const std::string& macroText);
|
||||
|
||||
void ChatPanel::render(game::GameHandler& gameHandler,
|
||||
InventoryScreen& inventoryScreen,
|
||||
|
|
@ -1708,22 +1689,6 @@ void ChatPanel::render(game::GameHandler& gameHandler,
|
|||
}
|
||||
|
||||
|
||||
static std::string firstMacroCommand(const std::string& macroText) {
|
||||
size_t pos = 0;
|
||||
while (pos <= macroText.size()) {
|
||||
size_t nl = macroText.find('\n', pos);
|
||||
std::string line = (nl != std::string::npos) ? macroText.substr(pos, nl - pos) : macroText.substr(pos);
|
||||
if (!line.empty() && line.back() == '\r') line.pop_back();
|
||||
size_t start = line.find_first_not_of(" \t");
|
||||
if (start != std::string::npos) line = line.substr(start);
|
||||
if (!line.empty() && line.front() != '#')
|
||||
return line;
|
||||
if (nl == std::string::npos) break;
|
||||
pos = nl + 1;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
// Collect all non-comment, non-empty lines from a macro body.
|
||||
static std::vector<std::string> allMacroCommands(const std::string& macroText) {
|
||||
std::vector<std::string> cmds;
|
||||
|
|
@ -1742,36 +1707,6 @@ static std::vector<std::string> allMacroCommands(const std::string& macroText) {
|
|||
return cmds;
|
||||
}
|
||||
|
||||
// Returns the #showtooltip argument from a macro body:
|
||||
// "#showtooltip Spell" → "Spell"
|
||||
// "#showtooltip" → "__auto__" (derive from first /cast)
|
||||
// (none) → ""
|
||||
static std::string getMacroShowtooltipArg(const std::string& macroText) {
|
||||
size_t pos = 0;
|
||||
while (pos <= macroText.size()) {
|
||||
size_t nl = macroText.find('\n', pos);
|
||||
std::string line = (nl != std::string::npos) ? macroText.substr(pos, nl - pos) : macroText.substr(pos);
|
||||
if (!line.empty() && line.back() == '\r') line.pop_back();
|
||||
size_t fs = line.find_first_not_of(" \t");
|
||||
if (fs != std::string::npos) line = line.substr(fs);
|
||||
if (line.rfind("#showtooltip", 0) == 0 || line.rfind("#show", 0) == 0) {
|
||||
size_t sp = line.find(' ');
|
||||
if (sp != std::string::npos) {
|
||||
std::string arg = line.substr(sp + 1);
|
||||
size_t as = arg.find_first_not_of(" \t");
|
||||
if (as != std::string::npos) arg = arg.substr(as);
|
||||
size_t ae = arg.find_last_not_of(" \t");
|
||||
if (ae != std::string::npos) arg.resize(ae + 1);
|
||||
if (!arg.empty()) return arg;
|
||||
}
|
||||
return "__auto__";
|
||||
}
|
||||
if (nl == std::string::npos) break;
|
||||
pos = nl + 1;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// WoW macro conditional evaluator
|
||||
// Parses: [cond1,cond2] Spell1; [cond3] Spell2; DefaultSpell
|
||||
|
|
|
|||
|
|
@ -32,13 +32,6 @@ namespace {
|
|||
constexpr auto& kColorBrightGreen = kBrightGreen;
|
||||
constexpr auto& kColorYellow = kYellow;
|
||||
|
||||
// Format a duration in seconds as compact text: "2h", "3:05", "42"
|
||||
void fmtDurationCompact(char* buf, size_t sz, int secs) {
|
||||
if (secs >= 3600) snprintf(buf, sz, "%dh", secs / 3600);
|
||||
else if (secs >= 60) snprintf(buf, sz, "%d:%02d", secs / 60, secs % 60);
|
||||
else snprintf(buf, sz, "%d", secs);
|
||||
}
|
||||
|
||||
// Render "Remaining: Xs" or "Remaining: Xm Ys" in a tooltip (light gray)
|
||||
void renderAuraRemaining(int remainMs) {
|
||||
if (remainMs <= 0) return;
|
||||
|
|
@ -269,7 +262,6 @@ void CombatUI::renderRaidWarningOverlay(game::GameHandler& gameHandler) {
|
|||
// Walk only the new messages (deque — iterate from back by skipping old ones)
|
||||
size_t toScan = newCount - raidWarnChatSeenCount_;
|
||||
size_t startIdx = newCount > toScan ? newCount - toScan : 0;
|
||||
auto* renderer = services_.renderer;
|
||||
for (size_t i = startIdx; i < newCount; ++i) {
|
||||
const auto& msg = chatHistory[i];
|
||||
if (msg.type == game::ChatType::RAID_WARNING ||
|
||||
|
|
|
|||
|
|
@ -76,24 +76,6 @@ namespace {
|
|||
// Common ImGui window flags for popup dialogs
|
||||
const ImGuiWindowFlags kDialogFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize;
|
||||
|
||||
// Build a WoW-format item link string for chat insertion.
|
||||
// Format: |cff<qualHex>|Hitem:<itemId>:0:0:0:0:0:0:0:0|h[<name>]|h|r
|
||||
std::string buildItemChatLink(uint32_t itemId, uint8_t quality, const std::string& name) {
|
||||
static constexpr const char* kQualHex[] = {"9d9d9d","ffffff","1eff00","0070dd","a335ee","ff8000","e6cc80","e6cc80"};
|
||||
uint8_t qi = quality < 8 ? quality : 1;
|
||||
char buf[512];
|
||||
snprintf(buf, sizeof(buf), "|cff%s|Hitem:%u:0:0:0:0:0:0:0:0|h[%s]|h|r",
|
||||
kQualHex[qi], itemId, name.c_str());
|
||||
return buf;
|
||||
}
|
||||
|
||||
std::string trim(const std::string& s) {
|
||||
size_t first = s.find_first_not_of(" \t\r\n");
|
||||
if (first == std::string::npos) return "";
|
||||
size_t last = s.find_last_not_of(" \t\r\n");
|
||||
return s.substr(first, last - first + 1);
|
||||
}
|
||||
|
||||
// Format a duration in seconds as compact text: "2h", "3:05", "42"
|
||||
void fmtDurationCompact(char* buf, size_t sz, int secs) {
|
||||
if (secs >= 3600) snprintf(buf, sz, "%dh", secs / 3600);
|
||||
|
|
@ -111,13 +93,6 @@ namespace {
|
|||
ImGui::TextColored(kLightGray, "%s", buf);
|
||||
}
|
||||
|
||||
std::string toLower(std::string s) {
|
||||
std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) {
|
||||
return static_cast<char>(std::tolower(c));
|
||||
});
|
||||
return s;
|
||||
}
|
||||
|
||||
// Render gold/silver/copper amounts in WoW-canonical colors on the current ImGui line.
|
||||
// Skips zero-value denominations (except copper, which is always shown when gold=silver=0).
|
||||
// Aliases for shared class color helpers (wowee::ui namespace)
|
||||
|
|
@ -138,40 +113,6 @@ namespace {
|
|||
return wowee::game::getClassName(static_cast<wowee::game::Class>(classId));
|
||||
}
|
||||
|
||||
bool isPortBotTarget(const std::string& target) {
|
||||
std::string t = toLower(trim(target));
|
||||
return t == "portbot" || t == "gmbot" || t == "telebot";
|
||||
}
|
||||
|
||||
std::string buildPortBotCommand(const std::string& rawInput) {
|
||||
std::string input = trim(rawInput);
|
||||
if (input.empty()) return "";
|
||||
|
||||
std::string lower = toLower(input);
|
||||
if (lower == "help" || lower == "?") {
|
||||
return "__help__";
|
||||
}
|
||||
|
||||
if (lower.rfind(".tele ", 0) == 0 || lower.rfind(".go ", 0) == 0) {
|
||||
return input;
|
||||
}
|
||||
|
||||
if (lower.rfind("xyz ", 0) == 0) {
|
||||
return ".go " + input;
|
||||
}
|
||||
|
||||
if (lower == "sw" || lower == "stormwind") return ".tele stormwind";
|
||||
if (lower == "if" || lower == "ironforge") return ".tele ironforge";
|
||||
if (lower == "darn" || lower == "darnassus") return ".tele darnassus";
|
||||
if (lower == "org" || lower == "orgrimmar") return ".tele orgrimmar";
|
||||
if (lower == "tb" || lower == "thunderbluff") return ".tele thunderbluff";
|
||||
if (lower == "uc" || lower == "undercity") return ".tele undercity";
|
||||
if (lower == "shatt" || lower == "shattrath") return ".tele shattrath";
|
||||
if (lower == "dal" || lower == "dalaran") return ".tele dalaran";
|
||||
|
||||
return ".tele " + input;
|
||||
}
|
||||
|
||||
bool raySphereIntersect(const wowee::rendering::Ray& ray, const glm::vec3& center, float radius, float& tOut) {
|
||||
glm::vec3 oc = ray.origin - center;
|
||||
float b = glm::dot(oc, ray.direction);
|
||||
|
|
@ -198,51 +139,6 @@ namespace {
|
|||
}
|
||||
return "Unknown";
|
||||
}
|
||||
|
||||
// Collect all non-comment, non-empty lines from a macro body.
|
||||
std::vector<std::string> allMacroCommands(const std::string& macroText) {
|
||||
std::vector<std::string> cmds;
|
||||
size_t pos = 0;
|
||||
while (pos <= macroText.size()) {
|
||||
size_t nl = macroText.find('\n', pos);
|
||||
std::string line = (nl != std::string::npos) ? macroText.substr(pos, nl - pos) : macroText.substr(pos);
|
||||
if (!line.empty() && line.back() == '\r') line.pop_back();
|
||||
size_t start = line.find_first_not_of(" \t");
|
||||
if (start != std::string::npos) line = line.substr(start);
|
||||
if (!line.empty() && line.front() != '#')
|
||||
cmds.push_back(std::move(line));
|
||||
if (nl == std::string::npos) break;
|
||||
pos = nl + 1;
|
||||
}
|
||||
return cmds;
|
||||
}
|
||||
|
||||
// Returns the #showtooltip argument from a macro body.
|
||||
std::string getMacroShowtooltipArg(const std::string& macroText) {
|
||||
size_t pos = 0;
|
||||
while (pos <= macroText.size()) {
|
||||
size_t nl = macroText.find('\n', pos);
|
||||
std::string line = (nl != std::string::npos) ? macroText.substr(pos, nl - pos) : macroText.substr(pos);
|
||||
if (!line.empty() && line.back() == '\r') line.pop_back();
|
||||
size_t fs = line.find_first_not_of(" \t");
|
||||
if (fs != std::string::npos) line = line.substr(fs);
|
||||
if (line.rfind("#showtooltip", 0) == 0 || line.rfind("#show", 0) == 0) {
|
||||
size_t sp = line.find(' ');
|
||||
if (sp != std::string::npos) {
|
||||
std::string arg = line.substr(sp + 1);
|
||||
size_t as = arg.find_first_not_of(" \t");
|
||||
if (as != std::string::npos) arg = arg.substr(as);
|
||||
size_t ae = arg.find_last_not_of(" \t");
|
||||
if (ae != std::string::npos) arg.resize(ae + 1);
|
||||
if (!arg.empty()) return arg;
|
||||
}
|
||||
return "__auto__";
|
||||
}
|
||||
if (nl == std::string::npos) break;
|
||||
pos = nl + 1;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
namespace wowee { namespace ui {
|
||||
|
|
|
|||
|
|
@ -43,25 +43,6 @@ namespace {
|
|||
constexpr auto& kColorGray = kGray;
|
||||
constexpr auto& kColorDarkGray = kDarkGray;
|
||||
|
||||
// Render gold/silver/copper amounts in WoW-canonical colors
|
||||
void renderGoldText(uint32_t totalCopper) {
|
||||
uint32_t gold = totalCopper / 10000;
|
||||
uint32_t silver = (totalCopper / 100) % 100;
|
||||
uint32_t copper = totalCopper % 100;
|
||||
bool shown = false;
|
||||
if (gold > 0) {
|
||||
ImGui::TextColored(ImVec4(1.0f, 0.84f, 0.0f, 1.0f), "%ug", gold);
|
||||
shown = true;
|
||||
}
|
||||
if (silver > 0 || shown) {
|
||||
if (shown) { ImGui::SameLine(0, 2); }
|
||||
ImGui::TextColored(ImVec4(0.75f, 0.75f, 0.75f, 1.0f), "%us", silver);
|
||||
shown = true;
|
||||
}
|
||||
if (shown) { ImGui::SameLine(0, 2); }
|
||||
ImGui::TextColored(ImVec4(0.72f, 0.45f, 0.2f, 1.0f), "%uc", copper);
|
||||
}
|
||||
|
||||
// Common ImGui window flags for popup dialogs
|
||||
const ImGuiWindowFlags kDialogFlags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue