Code/Editor

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
Esteban Papp
2021-08-02 17:56:56 -07:00
parent 3b28267569
commit a14b4e478e
47 changed files with 208 additions and 1219 deletions
+35 -36
View File
@@ -79,9 +79,9 @@ CEditorCommandManager::~CEditorCommandManager()
m_uiCommands.clear();
}
string CEditorCommandManager::GetFullCommandName(const AZStd::string& module, const string& name)
AZStd::string CEditorCommandManager::GetFullCommandName(const AZStd::string& module, const AZStd::string& name)
{
string fullName = module;
AZStd::string fullName = module;
fullName += ".";
fullName += name;
return fullName;
@@ -91,10 +91,10 @@ bool CEditorCommandManager::AddCommand(CCommand* pCommand, TPfnDeleter deleter)
{
assert(pCommand);
string module = pCommand->GetModule();
string name = pCommand->GetName();
AZStd::string module = pCommand->GetModule();
AZStd::string name = pCommand->GetName();
if (IsRegistered(module, name) && m_bWarnDuplicate)
if (IsRegistered(module.c_str(), name.c_str()) && m_bWarnDuplicate)
{
QString errMsg;
@@ -118,7 +118,7 @@ bool CEditorCommandManager::AddCommand(CCommand* pCommand, TPfnDeleter deleter)
bool CEditorCommandManager::UnregisterCommand(const char* module, const char* name)
{
string fullName = GetFullCommandName(module, name);
AZStd::string fullName = GetFullCommandName(module, name);
CommandTable::iterator itr = m_commands.find(fullName);
if (itr != m_commands.end())
@@ -154,7 +154,7 @@ bool CEditorCommandManager::RegisterUICommand(
return false;
}
return AttachUIInfo(GetFullCommandName(module, name), uiInfo);
return AttachUIInfo(GetFullCommandName(module, name).c_str(), uiInfo);
}
bool CEditorCommandManager::AttachUIInfo(const char* fullCmdName, const CCommand0::SUIInfo& uiInfo)
@@ -190,14 +190,14 @@ bool CEditorCommandManager::AttachUIInfo(const char* fullCmdName, const CCommand
return true;
}
bool CEditorCommandManager::GetUIInfo(const string& module, const string& name, CCommand0::SUIInfo& uiInfo) const
bool CEditorCommandManager::GetUIInfo(const AZStd::string& module, const AZStd::string& name, CCommand0::SUIInfo& uiInfo) const
{
string fullName = GetFullCommandName(module, name);
AZStd::string fullName = GetFullCommandName(module, name);
return GetUIInfo(fullName, uiInfo);
}
bool CEditorCommandManager::GetUIInfo(const string& fullCmdName, CCommand0::SUIInfo& uiInfo) const
bool CEditorCommandManager::GetUIInfo(const AZStd::string& fullCmdName, CCommand0::SUIInfo& uiInfo) const
{
CommandTable::const_iterator iter = m_commands.find(fullCmdName);
@@ -223,9 +223,9 @@ int CEditorCommandManager::GenNewCommandId()
return uniqueId++;
}
QString CEditorCommandManager::Execute(const string& module, const string& name, const CCommand::CArgs& args)
QString CEditorCommandManager::Execute(const AZStd::string& module, const AZStd::string& name, const CCommand::CArgs& args)
{
string fullName = GetFullCommandName(module, name);
AZStd::string fullName = GetFullCommandName(module, name);
CommandTable::iterator iter = m_commands.find(fullName);
if (iter != m_commands.end())
@@ -245,18 +245,18 @@ QString CEditorCommandManager::Execute(const string& module, const string& name,
return "";
}
QString CEditorCommandManager::Execute(const string& cmdLine)
QString CEditorCommandManager::Execute(const AZStd::string& cmdLine)
{
string cmdTxt, argsTxt;
AZStd::string cmdTxt, argsTxt;
size_t argStart = cmdLine.find_first_of(' ');
cmdTxt = cmdLine.substr(0, argStart);
argsTxt = "";
if (argStart != string::npos)
if (argStart != AZStd::string::npos)
{
argsTxt = cmdLine.substr(argStart + 1);
argsTxt.Trim();
AZ::StringFunc::TrimWhiteSpace(argsTxt, true, true);
}
CommandTable::iterator itr = m_commands.find(cmdTxt);
@@ -301,7 +301,7 @@ void CEditorCommandManager::Execute(int commandId)
}
}
void CEditorCommandManager::GetCommandList(std::vector<string>& cmds) const
void CEditorCommandManager::GetCommandList(std::vector<AZStd::string>& cmds) const
{
cmds.clear();
cmds.reserve(m_commands.size());
@@ -315,9 +315,9 @@ void CEditorCommandManager::GetCommandList(std::vector<string>& cmds) const
std::sort(cmds.begin(), cmds.end());
}
string CEditorCommandManager::AutoComplete(const string& substr) const
AZStd::string CEditorCommandManager::AutoComplete(const AZStd::string& substr) const
{
std::vector<string> cmds;
std::vector<AZStd::string> cmds;
GetCommandList(cmds);
// If substring is empty return first command.
@@ -358,7 +358,7 @@ string CEditorCommandManager::AutoComplete(const string& substr) const
bool CEditorCommandManager::IsRegistered(const char* module, const char* name) const
{
string fullName = GetFullCommandName(module, name);
AZStd::string fullName = GetFullCommandName(module, name);
CommandTable::const_iterator iter = m_commands.find(fullName);
if (iter != m_commands.end())
@@ -373,7 +373,7 @@ bool CEditorCommandManager::IsRegistered(const char* module, const char* name) c
bool CEditorCommandManager::IsRegistered(const char* cmdLine_) const
{
string cmdTxt, argsTxt, cmdLine(cmdLine_);
AZStd::string cmdTxt, argsTxt, cmdLine(cmdLine_);
size_t argStart = cmdLine.find_first_of(' ');
cmdTxt = cmdLine.substr(0, argStart);
CommandTable::const_iterator iter = m_commands.find(cmdTxt);
@@ -402,9 +402,9 @@ bool CEditorCommandManager::IsRegistered(int commandId) const
return false;
}
void CEditorCommandManager::SetCommandAvailableInScripting(const string& module, const string& name)
void CEditorCommandManager::SetCommandAvailableInScripting(const AZStd::string& module, const AZStd::string& name)
{
string fullName = GetFullCommandName(module, name);
AZStd::string fullName = GetFullCommandName(module, name);
CommandTable::iterator iter = m_commands.find(fullName);
if (iter != m_commands.end())
@@ -413,7 +413,7 @@ void CEditorCommandManager::SetCommandAvailableInScripting(const string& module,
}
}
bool CEditorCommandManager::IsCommandAvailableInScripting(const string& fullCmdName) const
bool CEditorCommandManager::IsCommandAvailableInScripting(const AZStd::string& fullCmdName) const
{
CommandTable::const_iterator iter = m_commands.find(fullCmdName);
@@ -425,16 +425,16 @@ bool CEditorCommandManager::IsCommandAvailableInScripting(const string& fullCmdN
return false;
}
bool CEditorCommandManager::IsCommandAvailableInScripting(const string& module, const string& name) const
bool CEditorCommandManager::IsCommandAvailableInScripting(const AZStd::string& module, const AZStd::string& name) const
{
string fullName = GetFullCommandName(module, name);
AZStd::string fullName = GetFullCommandName(module, name);
return IsCommandAvailableInScripting(fullName);
}
void CEditorCommandManager::LogCommand(const string& fullCmdName, const CCommand::CArgs& args) const
void CEditorCommandManager::LogCommand(const AZStd::string& fullCmdName, const CCommand::CArgs& args) const
{
string cmdLine = fullCmdName;
AZStd::string cmdLine = fullCmdName;
for (int i = 0; i < args.GetArgCount(); ++i)
{
@@ -509,7 +509,7 @@ void CEditorCommandManager::LogCommand(const string& fullCmdName, const CCommand
if (pScriptTermDialog)
{
string text = "> ";
AZStd::string text = "> ";
text += cmdLine;
text += "\r\n";
pScriptTermDialog->AppendText(text.c_str());
@@ -526,14 +526,14 @@ QString CEditorCommandManager::ExecuteAndLogReturn(CCommand* pCommand, const CCo
return result;
}
void CEditorCommandManager::GetArgsFromString(const string& argsTxt, CCommand::CArgs& argList)
void CEditorCommandManager::GetArgsFromString(const AZStd::string& argsTxt, CCommand::CArgs& argList)
{
const char quoteSymbol = '\'';
int curPos = 0;
int prevPos = 0;
string arg = argsTxt.Tokenize(" ", curPos);
while (!arg.empty())
AZStd::vector<AZStd::string> tokens;
AZ::StringFunc::Tokenize(argsTxt, tokens, ' ');
for(AZStd::string& arg : tokens)
{
if (arg[0] == quoteSymbol) // A special consideration for a quoted string
{
@@ -542,11 +542,11 @@ void CEditorCommandManager::GetArgsFromString(const string& argsTxt, CCommand::C
size_t openingQuotePos = argsTxt.find(quoteSymbol, prevPos);
size_t closingQuotePos = argsTxt.find(quoteSymbol, curPos);
if (closingQuotePos != string::npos)
if (closingQuotePos != AZStd::string::npos)
{
arg = argsTxt.substr(openingQuotePos + 1, closingQuotePos - openingQuotePos - 1);
size_t nextArgPos = argsTxt.find(' ', closingQuotePos + 1);
curPos = nextArgPos != string::npos ? nextArgPos + 1 : argsTxt.length();
curPos = nextArgPos != AZStd::string::npos ? nextArgPos + 1 : argsTxt.length();
for (; curPos < argsTxt.length(); ++curPos) // Skip spaces.
{
@@ -565,6 +565,5 @@ void CEditorCommandManager::GetArgsFromString(const string& argsTxt, CCommand::C
argList.Add(arg.c_str());
prevPos = curPos;
arg = argsTxt.Tokenize(" ", curPos);
}
}