Make it possible to translate arguments in help text of module commands

Ref #1354
This commit is contained in:
Alexey Sokolov
2016-12-25 21:10:40 +00:00
parent b5fde609c4
commit d9c1da8a68
6 changed files with 51 additions and 29 deletions

View File

@@ -517,10 +517,10 @@ bool CModule::AddCommand(const CString& sCmd, CModCommand::ModCmdFunc func,
return AddCommand(cmd);
}
bool CModule::AddCommand(const CString& sCmd, const CString& sArgs,
bool CModule::AddCommand(const CString& sCmd, const COptionalTranslation& Args,
const COptionalTranslation& Desc,
std::function<void(const CString& sLine)> func) {
CModCommand cmd(sCmd, std::move(func), sArgs, Desc);
CModCommand cmd(sCmd, std::move(func), Args, Desc);
return AddCommand(std::move(cmd));
}
@@ -1958,18 +1958,19 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath,
}
CModCommand::CModCommand()
: m_sCmd(), m_pFunc(nullptr), m_sArgs(), m_Desc("") {}
: m_sCmd(), m_pFunc(nullptr), m_Args(""), m_Desc("") {}
CModCommand::CModCommand(const CString& sCmd, CModule* pMod, ModCmdFunc func,
const CString& sArgs, const CString& sDesc)
: m_sCmd(sCmd),
m_pFunc([pMod, func](const CString& sLine) { (pMod->*func)(sLine); }),
m_sArgs(sArgs),
m_Args(sArgs),
m_Desc(sDesc) {}
CModCommand::CModCommand(const CString& sCmd, CmdFunc func,
const CString& sArgs, const COptionalTranslation& Desc)
: m_sCmd(sCmd), m_pFunc(std::move(func)), m_sArgs(sArgs), m_Desc(Desc) {}
const COptionalTranslation& Args,
const COptionalTranslation& Desc)
: m_sCmd(sCmd), m_pFunc(std::move(func)), m_Args(Args), m_Desc(Desc) {}
void CModCommand::InitHelp(CTable& Table) {
Table.AddColumn("Command");