mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
feat: implement client-side macro text storage and execution
Macros in WoW are client-side — the server sends only a macro index via SMSG_ACTION_BUTTONS, never the text. This commit adds local storage and a UI so macro slots are actually usable. - GameHandler: getMacroText/setMacroText accessors backed by macros_ map; text is persisted to the character .cfg file as macro_N_text= entries - Action bar left-click: MACRO slot executes first line of macro text as a chat/slash command (same path as /cast, /use, etc.) - Context menu: "Execute" and "Edit" items for MACRO slots; "Edit" opens a multiline modal editor (320×80 px, up to 255 chars) with Save/Cancel - Tooltip: shows macro text body below the index; hints "right-click to Edit" when no text is set yet
This commit is contained in:
parent
1588c1029a
commit
2c86fb4fa6
4 changed files with 96 additions and 0 deletions
|
|
@ -23468,6 +23468,21 @@ std::string GameHandler::getCharacterConfigDir() {
|
|||
return dir;
|
||||
}
|
||||
|
||||
static const std::string EMPTY_MACRO_TEXT;
|
||||
|
||||
const std::string& GameHandler::getMacroText(uint32_t macroId) const {
|
||||
auto it = macros_.find(macroId);
|
||||
return (it != macros_.end()) ? it->second : EMPTY_MACRO_TEXT;
|
||||
}
|
||||
|
||||
void GameHandler::setMacroText(uint32_t macroId, const std::string& text) {
|
||||
if (text.empty())
|
||||
macros_.erase(macroId);
|
||||
else
|
||||
macros_[macroId] = text;
|
||||
saveCharacterConfig();
|
||||
}
|
||||
|
||||
void GameHandler::saveCharacterConfig() {
|
||||
const Character* ch = getActiveCharacter();
|
||||
if (!ch || ch->name.empty()) return;
|
||||
|
|
@ -23494,6 +23509,12 @@ void GameHandler::saveCharacterConfig() {
|
|||
out << "action_bar_" << i << "_id=" << actionBar[i].id << "\n";
|
||||
}
|
||||
|
||||
// Save client-side macro text
|
||||
for (const auto& [id, text] : macros_) {
|
||||
if (!text.empty())
|
||||
out << "macro_" << id << "_text=" << text << "\n";
|
||||
}
|
||||
|
||||
// Save quest log
|
||||
out << "quest_log_count=" << questLog_.size() << "\n";
|
||||
for (size_t i = 0; i < questLog_.size(); i++) {
|
||||
|
|
@ -23534,6 +23555,15 @@ void GameHandler::loadCharacterConfig() {
|
|||
try { savedGender = std::stoi(val); } catch (...) {}
|
||||
} else if (key == "use_female_model") {
|
||||
try { savedUseFemaleModel = std::stoi(val); } catch (...) {}
|
||||
} else if (key.rfind("macro_", 0) == 0) {
|
||||
// Parse macro_N_text
|
||||
size_t firstUnder = 6; // length of "macro_"
|
||||
size_t secondUnder = key.find('_', firstUnder);
|
||||
if (secondUnder == std::string::npos) continue;
|
||||
uint32_t macroId = 0;
|
||||
try { macroId = static_cast<uint32_t>(std::stoul(key.substr(firstUnder, secondUnder - firstUnder))); } catch (...) { continue; }
|
||||
if (key.substr(secondUnder + 1) == "text" && !val.empty())
|
||||
macros_[macroId] = val;
|
||||
} else if (key.rfind("action_bar_", 0) == 0) {
|
||||
// Parse action_bar_N_type or action_bar_N_id
|
||||
size_t firstUnderscore = 11; // length of "action_bar_"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue