void DebugMenu::Add(const String& path, IAction* action) { if (StringContains(path, "/")) { std::vector<String> paths = SplitString(path, "/"); action->name = paths.back(); paths.pop_back(); PathAction* pathAction = s_Instance->CreateOrFindPaths(paths); SP_ASSERT(pathAction); if (!pathAction->ContainsAction(action->name)) pathAction->actionList.push_back(action); else spdel action; } else { s_Instance->m_ActionList.push_back(action); } s_Instance->Refresh(); }
void DebugMenu::Remove(const String& path) { if (StringContains(path, "/")) { std::vector<String> paths = SplitString(path, "/"); String name = paths.back(); paths.pop_back(); PathAction* pathAction = s_Instance->CreateOrFindPaths(paths); SP_ASSERT(pathAction); if (pathAction->ContainsAction(name)) { if (pathAction->actionList.size() == 1) { PathAction* parent = pathAction->parent; if (parent) { parent->DeleteChild(pathAction); } else { for (uint i = 0; i < s_Instance->m_ActionList.size(); i++) { if (s_Instance->m_ActionList[i] == pathAction) { spdel s_Instance->m_ActionList[i]; s_Instance->m_ActionList.erase(s_Instance->m_ActionList.begin() + i); break; } } } while (parent) { spdel pathAction; pathAction = pathAction->parent; } } else { ActionList& actionList = pathAction->actionList; for (uint i = 0; i < actionList.size(); i++) { if (actionList[i]->name == name) { actionList.erase(actionList.begin() + i); break; } } } } } else { ActionList& actions = s_Instance->m_ActionList; for (uint i = 0; i < actions.size(); i++) { if (actions[i]->name == path) { spdel actions[i]; actions.erase(actions.begin() + i); break; } } } s_Instance->Refresh(); }