diff options
| author | leviathan <leviathan@lindenlab.com> | 2026-05-07 22:52:05 -0700 |
|---|---|---|
| committer | leviathan <leviathan@lindenlab.com> | 2026-10-16 13:14:36 -0700 |
| commit | 5f9fc17e90f3d5a219c52dc3cecf449275174ffc (patch) | |
| tree | 7ae3505efd8b1010a56d9ff921ed1d84122b69cd /indra/llui/llurlentry.cpp | |
| parent | fa75a7bd0f909c8b19d6217c5c15b4431d439c8b (diff) | |
overhaul game-control config and UI
Diffstat (limited to 'indra/llui/llurlentry.cpp')
| -rw-r--r-- | indra/llui/llurlentry.cpp | 148 |
1 files changed, 142 insertions, 6 deletions
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index 06dac54cf9..fb6d90f86f 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -34,6 +34,7 @@ #include "llavatarnamecache.h" #include "llcachename.h" +#include "llgamecontrol.h" #include "llkeyboard.h" #include "llregex.h" #include "llscrolllistctrl.h" // for LLUrlEntryKeybinding file parsing @@ -403,9 +404,9 @@ bool LLUrlEntryInvalidSLURL::isSLURLvalid(const std::string &url) const if (path_parts == actual_parts) { // handle slurl with (X,Y,Z) coordinates - LLStringUtil::convertToS32(path_array[path_parts-3],x); - LLStringUtil::convertToS32(path_array[path_parts-2],y); - LLStringUtil::convertToS32(path_array[path_parts-1],z); + LLStringUtil::convertToS32(path_array[path_parts - 3].asStringRef(), x); + LLStringUtil::convertToS32(path_array[path_parts - 2].asStringRef(), y); + LLStringUtil::convertToS32(path_array[path_parts - 1].asStringRef(), z); if((x>= 0 && x<= 256) && (y>= 0 && y<= 256) && (z>= 0)) { @@ -416,8 +417,8 @@ bool LLUrlEntryInvalidSLURL::isSLURLvalid(const std::string &url) const { // handle slurl with (X,Y) coordinates - LLStringUtil::convertToS32(path_array[path_parts-2],x); - LLStringUtil::convertToS32(path_array[path_parts-1],y); + LLStringUtil::convertToS32(path_array[path_parts - 2].asStringRef(), x); + LLStringUtil::convertToS32(path_array[path_parts - 1].asStringRef(), y); ; if((x>= 0 && x<= 256) && (y>= 0 && y<= 256)) { @@ -427,7 +428,7 @@ bool LLUrlEntryInvalidSLURL::isSLURLvalid(const std::string &url) const else if (path_parts == (actual_parts-2)) { // handle slurl with (X) coordinate - LLStringUtil::convertToS32(path_array[path_parts-1],x); + LLStringUtil::convertToS32(path_array[path_parts - 1].asStringRef(), x); if(x>= 0 && x<= 256) { return true; @@ -1785,3 +1786,138 @@ void LLUrlEntryKeybinding::initLocalizationFromFile(const std::string& filename) } } } + + +// +// LLUrlEntryGameController Displays currently assigned game control binding +// +LLUrlEntryGameController::LLUrlEntryGameController() + : LLUrlEntryBase() + , pKeyHandler(NULL) + , pControllerHandler(NULL) +{ + mPattern = boost::regex(APP_HEADER_REGEX "/gamecontroller/[\\w+-]+(\\?mode=\\w+)?$", + boost::regex::perl | boost::regex::icase); + mMenuName = "menu_url_experience.xml"; + + initLocalization(); +} + +std::string LLUrlEntryGameController::getLabel(const std::string& url, const LLUrlLabelCallback& cb) +{ + std::string control = getControlName(url); + + std::string keybind = ""; + if (pControllerHandler && pControllerHandler->hasHandlingDevice()) + { + keybind = pControllerHandler->getBindingAsString(control); + LL_WARNS() << "Game Control Translate:" << control << " = " << keybind << LL_ENDL; + if(!keybind.empty()) + { + std::map<std::string, LLLocalizationData>::iterator iter = mLocalizations.find(keybind); + if(iter != mLocalizations.end()) { + keybind = iter->second.mLocalization; + } + // Debug text change for testing + keybind = keybind + " (Game Control)"; + return keybind; + } + } + // Fallback to key binding if game control binding is not found + if (pKeyHandler && keybind.empty()) + { + LLStringUtil::toLower(control); + keybind = pKeyHandler->getKeyBindingAsString(getMode(url), "game_control_" + control); + LL_WARNS() << "Key Binding Translate:" << control << " = " << keybind << LL_ENDL; + if(!keybind.empty()) + { + // Debug text change for testing + keybind = keybind + " (Key Binding)"; + return keybind; + } + } + + return "Unbound Control: " + control; +} + +std::string LLUrlEntryGameController::getTooltip(const std::string& url) const +{ + std::string control = getControlName(url); + + std::map<std::string, LLLocalizationData>::const_iterator iter = mLocalizations.find(control); + if (iter != mLocalizations.end()) + { + return iter->second.mTooltip; + } + return url; +} + +std::string LLUrlEntryGameController::getControlName(const std::string& url) const +{ + std::string search = "/gamecontroller/"; + size_t pos_start = url.find(search); + if (pos_start == std::string::npos) + { + return std::string(); + } + pos_start += search.size(); + + size_t pos_end = url.find("?mode="); + if (pos_end == std::string::npos) + { + pos_end = url.size(); + } + return url.substr(pos_start, pos_end - pos_start); +} + +std::string LLUrlEntryGameController::getMode(const std::string& url) const +{ + std::string search = "?mode="; + size_t pos_start = url.find(search); + if (pos_start == std::string::npos) + { + return std::string(); + } + pos_start += search.size(); + return url.substr(pos_start, url.size() - pos_start); +} + +void LLUrlEntryGameController::initLocalization() +{ + initLocalizationFromFile("control_table_contents_game_control.xml"); + // TODO : Need to add localization for other game control bindings specifically axes +} + +void LLUrlEntryGameController::initLocalizationFromFile(const std::string& filename) +{ + LLXMLNodePtr xmlNode; + LLScrollListCtrl::Contents contents; + if (!LLUICtrlFactory::getLayeredXMLNode(filename, xmlNode)) + { + LL_WARNS() << "Failed to load " << filename << LL_ENDL; + return; + } + LLXUIParser parser; + parser.readXUI(xmlNode, contents, filename); + + if (!contents.validateBlock()) + { + LL_WARNS() << "Failed to validate " << filename << LL_ENDL; + return; + } + + for (LLInitParam::ParamIterator<LLScrollListItem::Params>::const_iterator row_it = contents.rows.begin(); + row_it != contents.rows.end(); + ++row_it) + { + std::string control = row_it->value.getValue().asString(); + if (!control.empty() && control != "menu_separator") + { + mLocalizations[control] = + LLLocalizationData( + row_it->columns.begin()->value.getValue().asString(), + row_it->columns.begin()->tool_tip.getValue() + ); + } + } +} |
