Ejemplo n.º 1
0
void CommandProcessorBase::OnLabelledStatesMenuItem(wxCommandEvent& event)
{
    if (GetOpenCommand()) {
        ProcessOpenCommand();
    }

    int index = event.GetId() - FIRST_MENU_ID;  // NB index will be -1 if the selection is the initial-command's label. This will always mean *un*dos (or nothing)
    wxCHECK_RET(index < (int)GetCommands().size(), "An ID that overruns the command-list");

    if (index < GetCurrentCommand()) {
        const int count = GetCurrentCommand() - index;
        for (int n=0; n < count; ++n) {
            if (DoUndo()) {
                DecrementCurrentCommand();
            }
        }
    } else {
        const int count = index - GetCurrentCommand();
        for (int n=0; n < count; ++n) {
            if (DoRedo()) {
                IncrementCurrentCommand();
            }
        }
    }
}
Ejemplo n.º 2
0
void AGameObject::CheckNextCommand()
{
  // If explicitly asked to DoNextCommand.
  if( IsReadyToRunNextCommand )
  {
    // When a command completes, remove the flag for it (if any) and pop it from the queue
    if( commands.size() )
    {
      // If there are still commands left, execute the next one.
      exec( GetCurrentCommand() );
      IsReadyToRunNextCommand = 0;
    }
  }

  if( Idling() )
  {
    // Once we are idling, we can pop the current command and try to exec the next one
    if( commands.size() )
    {
      Game->ClearFlag( GetCurrentCommand().CommandID );
      commands.pop_front(); // pop out the front item in the queue
    }
    IsReadyToRunNextCommand = 1;
  }

}
Ejemplo n.º 3
0
CLCommand::Ptr_t CommandProcessorBase::GetActiveCommand() const
{
    CLCommand::Ptr_t command(NULL);

    if (GetCurrentCommand() == -1) {
        command = GetInitialCommand();
        
    } else if (GetCommands().size() > 0) {
        command = GetCommands().at(GetCurrentCommand());
        
    }

    return command;
}
Ejemplo n.º 4
0
enum Command CFileZillaEnginePrivate::GetCurrentCommandId() const
{
	if (!m_pCurrentCommand)
		return cmd_none;

	else
		return GetCurrentCommand()->GetId();
}
void SlavedLauncherPID::SendSD() {
	SmartDashboard::PutNumber(GetName() + "speed", ReturnPIDInput());
	SmartDashboard::PutNumber(GetName() + "power", pidMotor.Get());
	SmartDashboard::PutNumber(GetName() + "power2", pidMotor2.Get());
	Command* comm = GetCurrentCommand();
	if(comm)
	{
		SmartDashboard::PutString(GetName() + "command" , comm->GetName());
	}
}
Ejemplo n.º 6
0
bool wxCommandProcessor::Undo()
{
    wxCommand *command = GetCurrentCommand();
    if ( command && command->CanUndo() )
    {
        if ( UndoCommand(*command) )
        {
            m_currentCommand = m_currentCommand->GetPrevious();
            SetMenuStrings();
            return true;
        }
    }

    return false;
}
Ejemplo n.º 7
0
void CommandProcessorBase::DoPopulateUnRedoMenu(wxMenu& menu, bool undoing)
{
    wxString prefix(undoing ? _("Undo ") : _("Redo "));
    int id = FIRST_MENU_ID;
    int count = 0;

    if (undoing) {
        if (GetCommands().size() > 0) {
            for (CLCommand::Vec_t::const_reverse_iterator iter = GetCommands().rbegin() + GetNextUndoCommand(); iter != GetCommands().rend(); ++iter) {
                CLCommand::Ptr_t command = *iter;
                if (command) {
                    wxString label;
                    if (!command->GetUserLabel().empty()) {
                        if (command->GetName().Contains(":")) {
                            label = command->GetName().BeforeFirst(':') + ": ";
                        }
                        label << command->GetUserLabel();
                    } else {
                        if (command == GetOpenCommand()) {
                            label = GetBestLabel(command); // If the command's still open, there won't otherwise be a name string
                        } else {
                            label = command->GetName();
                        }
                    }
                    menu.Append(id++, wxString::Format("%i ", ++count) + prefix + label);
                }
            }
        }
    } else {
        for (CLCommand::Vec_t::const_iterator iter = GetCommands().begin() + GetCurrentCommand() + 1; iter != GetCommands().end(); ++iter) {
            CLCommand::Ptr_t command = *iter;
            if (command) {
                wxString label;
                if (!command->GetUserLabel().empty()) {
                    if (command->GetName().Contains(":")) {
                        label = command->GetName().BeforeFirst(':') + ": ";
                    }
                    label << command->GetUserLabel();
                } else {
                    label = command->GetName();
                }
                menu.Append(id++, wxString::Format("%i ", ++count) + prefix + label);
            }
        }
    }
}
Ejemplo n.º 8
0
bool wxCommandProcessor::CanUndo() const
{
    wxCommand *command = GetCurrentCommand();

    return command && command->CanUndo();
}