Browse Source

Fixed some bugs

release/0.19
Jessica James 9 years ago
parent
commit
1c96f6d889
  1. 16
      Jupiter/GenericCommand.cpp
  2. 1
      Jupiter/GenericCommand.h
  3. BIN
      Release/Jupiter.lib

16
Jupiter/GenericCommand.cpp

@ -31,10 +31,13 @@ Jupiter::GenericCommandNamespace &Jupiter::g_generic_commands = o_generic_comman
Jupiter::GenericCommand::GenericCommand()
{
if (&o_generic_commands != this)
{
Jupiter::GenericCommand::setNamespace(o_generic_commands);
for (size_t index = 0; index != Jupiter::plugins->size(); ++index)
Jupiter::plugins->get(index)->OnGenericCommandAdd(*this);
}
}
Jupiter::GenericCommand::~GenericCommand()
@ -124,7 +127,12 @@ const Jupiter::ReadableString &Jupiter::GenericCommandNamespace::getHelp(const J
static Jupiter::ReferenceString not_found = "Error: Command not found"_jrs;
if (parameters.wordCount(GENERIC_COMMAND_WORD_DELIMITER_CS) == 0) // No parameters; list commands
{
if (Jupiter::GenericCommandNamespace::m_should_update_help)
Jupiter::GenericCommandNamespace::updateHelp();
return Jupiter::GenericCommandNamespace::m_help;
}
Jupiter::ReferenceString input(parameters);
GenericCommand *command;
@ -223,7 +231,7 @@ void Jupiter::GenericCommandNamespace::addCommand(Jupiter::GenericCommand &in_co
else
{
Jupiter::GenericCommandNamespace::m_commands.add(&in_command);
Jupiter::GenericCommandNamespace::updateHelp();
Jupiter::GenericCommandNamespace::m_should_update_help = true;
}
}
@ -233,7 +241,7 @@ void Jupiter::GenericCommandNamespace::removeCommand(Jupiter::GenericCommand &in
if (Jupiter::GenericCommandNamespace::m_commands.get(index) == &in_command)
{
Jupiter::GenericCommandNamespace::m_commands.remove(index);
Jupiter::GenericCommandNamespace::updateHelp();
Jupiter::GenericCommandNamespace::m_should_update_help = true;
return;
}
}
@ -244,13 +252,15 @@ void Jupiter::GenericCommandNamespace::removeCommand(const Jupiter::ReadableStri
if (Jupiter::GenericCommandNamespace::m_commands.get(index)->matches(in_command))
{
Jupiter::GenericCommandNamespace::m_commands.remove(index);
Jupiter::GenericCommandNamespace::updateHelp();
Jupiter::GenericCommandNamespace::m_should_update_help = true;
return;
}
}
void Jupiter::GenericCommandNamespace::updateHelp()
{
Jupiter::GenericCommandNamespace::m_should_update_help = false;
Jupiter::ArrayList<Jupiter::GenericCommand> commands = Jupiter::GenericCommandNamespace::getCommands();
Jupiter::StringL tmp_help(commands.size() * 8);

1
Jupiter/GenericCommand.h

@ -157,6 +157,7 @@ namespace Jupiter
Jupiter::ArrayList<GenericCommand> m_commands;
private:
bool m_should_update_help = true;
Jupiter::StringS m_help;
};

BIN
Release/Jupiter.lib

Binary file not shown.
Loading…
Cancel
Save