Convert MCoreCommandManager uint32 -> size_t
Signed-off-by: Chris Burel <burelc@amazon.com>
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
|
||||
namespace MCore
|
||||
{
|
||||
CommandManager::CommandHistoryEntry::CommandHistoryEntry(CommandGroup* group, Command* command, const CommandLine& parameters, AZ::u32 historyItemNr)
|
||||
CommandManager::CommandHistoryEntry::CommandHistoryEntry(CommandGroup* group, Command* command, const CommandLine& parameters, size_t historyItemNr)
|
||||
{
|
||||
mCommandGroup = group;
|
||||
mExecutedCommand = command;
|
||||
@@ -28,15 +28,15 @@ namespace MCore
|
||||
// remark: the mCommand and mCommandGroup are automatically deleted after popping from the history
|
||||
}
|
||||
|
||||
AZStd::string CommandManager::CommandHistoryEntry::ToString(CommandGroup* group, Command* command, AZ::u32 historyItemNr)
|
||||
AZStd::string CommandManager::CommandHistoryEntry::ToString(CommandGroup* group, Command* command, size_t historyItemNr)
|
||||
{
|
||||
if (group)
|
||||
{
|
||||
return AZStd::string::format("%.3d - %s", historyItemNr, group->GetGroupName());
|
||||
return AZStd::string::format("%.3zu - %s", historyItemNr, group->GetGroupName());
|
||||
}
|
||||
else if (command)
|
||||
{
|
||||
return AZStd::string::format("%.3d - %s", historyItemNr, command->GetHistoryName());
|
||||
return AZStd::string::format("%.3zu - %s", historyItemNr, command->GetHistoryName());
|
||||
}
|
||||
|
||||
return "";
|
||||
@@ -88,7 +88,7 @@ namespace MCore
|
||||
if (mCommandHistory.size() >= mMaxHistoryEntries)
|
||||
{
|
||||
PopCommandHistory();
|
||||
mHistoryIndex = static_cast<int32>(mCommandHistory.size()) - 1;
|
||||
mHistoryIndex = static_cast<ptrdiff_t>(mCommandHistory.size()) - 1;
|
||||
}
|
||||
|
||||
if (!mCommandHistory.empty())
|
||||
@@ -137,7 +137,7 @@ namespace MCore
|
||||
if (mCommandHistory.size() >= mMaxHistoryEntries)
|
||||
{
|
||||
PopCommandHistory();
|
||||
mHistoryIndex = static_cast<int32>(mCommandHistory.size()) - 1;
|
||||
mHistoryIndex = static_cast<ptrdiff_t>(mCommandHistory.size()) - 1;
|
||||
}
|
||||
|
||||
// remove unneeded commands
|
||||
@@ -540,7 +540,7 @@ namespace MCore
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (static_cast<int32>(i) < relativeIndex)
|
||||
if (static_cast<ptrdiff_t>(i) < relativeIndex)
|
||||
{
|
||||
MCore::LogError("Execution of command '%s' failed, command trying to access results from %d commands back, but there are only %d", commandString.c_str(), relativeIndex, i - 1);
|
||||
hadError = true;
|
||||
@@ -689,11 +689,11 @@ namespace MCore
|
||||
void CommandManager::ExecuteUndoCallbacks(Command* command, const CommandLine& parameters, bool preUndo)
|
||||
{
|
||||
Command* orgCommand = command->GetOriginalCommand();
|
||||
uint32 numFailed = 0;
|
||||
size_t numFailed = 0;
|
||||
|
||||
// get the number of callbacks and iterate through them
|
||||
const uint32 numCommandCallbacks = orgCommand->GetNumCallbacks();
|
||||
for (uint32 i = 0; i < numCommandCallbacks; ++i)
|
||||
const size_t numCommandCallbacks = orgCommand->GetNumCallbacks();
|
||||
for (size_t i = 0; i < numCommandCallbacks; ++i)
|
||||
{
|
||||
// get the current callback
|
||||
Command::Callback* callback = orgCommand->GetCallback(i);
|
||||
@@ -734,11 +734,11 @@ namespace MCore
|
||||
void CommandManager::ExecuteCommandCallbacks(Command* command, const CommandLine& parameters, bool preCommand)
|
||||
{
|
||||
Command* orgCommand = command->GetOriginalCommand();
|
||||
uint32 numFailed = 0;
|
||||
size_t numFailed = 0;
|
||||
|
||||
// get the number of callbacks and iterate through them
|
||||
const uint32 numCommandCallbacks = orgCommand->GetNumCallbacks();
|
||||
for (uint32 i = 0; i < numCommandCallbacks; ++i)
|
||||
const size_t numCommandCallbacks = orgCommand->GetNumCallbacks();
|
||||
for (size_t i = 0; i < numCommandCallbacks; ++i)
|
||||
{
|
||||
// get the current callback
|
||||
Command::Callback* callback = orgCommand->GetCallback(i);
|
||||
@@ -799,8 +799,8 @@ namespace MCore
|
||||
managerCallback->OnPreExecuteCommandGroup(group, true);
|
||||
}
|
||||
|
||||
const int32 numCommands = static_cast<int32>(group->GetNumCommands() - 1);
|
||||
for (int32 g = numCommands; g >= 0; --g)
|
||||
const ptrdiff_t numCommands = static_cast<ptrdiff_t>(group->GetNumCommands()) - 1;
|
||||
for (ptrdiff_t g = numCommands; g >= 0; --g)
|
||||
{
|
||||
Command* groupCommand = group->GetCommand(g);
|
||||
if (groupCommand == nullptr)
|
||||
@@ -1130,8 +1130,8 @@ namespace MCore
|
||||
// print the command history entries
|
||||
for (size_t i = 0; i < numHistoryEntries; ++i)
|
||||
{
|
||||
AZStd::string text = AZStd::string::format("%.3zu: name='%s', num parameters=%u", i, mCommandHistory[i].mExecutedCommand->GetName(), mCommandHistory[i].mParameters.GetNumParameters());
|
||||
if (i == (uint32)mHistoryIndex)
|
||||
AZStd::string text = AZStd::string::format("%.3zu: name='%s', num parameters=%zu", i, mCommandHistory[i].mExecutedCommand->GetName(), mCommandHistory[i].mParameters.GetNumParameters());
|
||||
if (i == mHistoryIndex)
|
||||
{
|
||||
LogDetailedInfo("-> %s", text.c_str());
|
||||
}
|
||||
@@ -1180,15 +1180,15 @@ namespace MCore
|
||||
}
|
||||
|
||||
// set the max num history items
|
||||
void CommandManager::SetMaxHistoryItems(uint32 maxItems)
|
||||
void CommandManager::SetMaxHistoryItems(size_t maxItems)
|
||||
{
|
||||
maxItems = AZStd::max(1u, maxItems);
|
||||
maxItems = AZStd::max(size_t{1}, maxItems);
|
||||
mMaxHistoryEntries = maxItems;
|
||||
|
||||
while (mCommandHistory.size() > mMaxHistoryEntries)
|
||||
{
|
||||
PopCommandHistory();
|
||||
mHistoryIndex = static_cast<int32>(mCommandHistory.size()) - 1;
|
||||
mHistoryIndex = static_cast<ptrdiff_t>(mCommandHistory.size()) - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1197,7 +1197,7 @@ namespace MCore
|
||||
return mMaxHistoryEntries;
|
||||
}
|
||||
|
||||
int32 CommandManager::GetHistoryIndex() const
|
||||
ptrdiff_t CommandManager::GetHistoryIndex() const
|
||||
{
|
||||
return mHistoryIndex;
|
||||
}
|
||||
@@ -1229,7 +1229,7 @@ namespace MCore
|
||||
mHistoryIndex = -1;
|
||||
}
|
||||
|
||||
const CommandLine& CommandManager::GetHistoryCommandLine(uint32 historyIndex) const
|
||||
const CommandLine& CommandManager::GetHistoryCommandLine(size_t historyIndex) const
|
||||
{
|
||||
return mCommandHistory[historyIndex].mParameters;
|
||||
}
|
||||
|
||||
@@ -48,17 +48,17 @@ namespace MCore
|
||||
* @param command The command instance that has been created at execution time. When set to nullptr it will assume it is a group, and it will use the group you specified.
|
||||
* @param parameters The command arguments.
|
||||
*/
|
||||
CommandHistoryEntry(CommandGroup* group, Command* command, const CommandLine& parameters, AZ::u32 historyItemNr);
|
||||
CommandHistoryEntry(CommandGroup* group, Command* command, const CommandLine& parameters, size_t historyItemNr);
|
||||
|
||||
~CommandHistoryEntry();
|
||||
|
||||
static AZStd::string ToString(CommandGroup* group, Command* command, AZ::u32 historyItemNr);
|
||||
static AZStd::string ToString(CommandGroup* group, Command* command, size_t historyItemNr);
|
||||
AZStd::string ToString() const;
|
||||
|
||||
CommandGroup* mCommandGroup; /**< A pointer to the command group, or nullptr when no group is used (in that case it uses a single command). */
|
||||
Command* mExecutedCommand; /**< A pointer to the command object, or nullptr when no command is used (in that case it uses a group). */
|
||||
CommandLine mParameters; /**< The used command arguments, unused in case no command is used (in that case it uses a group). */
|
||||
AZ::u32 m_historyItemNr; /**< The global history item number. This number will neither change depending on the size of the history queue nor with undo/redo. */
|
||||
size_t m_historyItemNr; /**< The global history item number. This number will neither change depending on the size of the history queue nor with undo/redo. */
|
||||
};
|
||||
|
||||
|
||||
@@ -183,7 +183,7 @@ namespace MCore
|
||||
* On default this value is 100. This means it will remember the last 100 executed commands, which can then be undo-ed and redo-ed.
|
||||
* @param maxItems The maximum number of items to remember.
|
||||
*/
|
||||
void SetMaxHistoryItems(uint32 maxItems);
|
||||
void SetMaxHistoryItems(size_t maxItems);
|
||||
|
||||
/**
|
||||
* Get the maximum number of history items that the manager will remember.
|
||||
@@ -197,7 +197,7 @@ namespace MCore
|
||||
* This value will be in range of [0..GetMaxHistoryItems()-1].
|
||||
* @result The current history index.
|
||||
*/
|
||||
int32 GetHistoryIndex() const;
|
||||
ptrdiff_t GetHistoryIndex() const;
|
||||
|
||||
/**
|
||||
* Get the number of history items stored.
|
||||
@@ -225,7 +225,7 @@ namespace MCore
|
||||
* @param historyIndex The history index number, which must be in range of [0..GetNumHistoryItems()-1].
|
||||
* @result A reference to the command line that was used when executing this command.
|
||||
*/
|
||||
const CommandLine& GetHistoryCommandLine(uint32 historyIndex) const;
|
||||
const CommandLine& GetHistoryCommandLine(size_t historyIndex) const;
|
||||
|
||||
/**
|
||||
* Get the total number of registered commands.
|
||||
@@ -302,8 +302,8 @@ namespace MCore
|
||||
AZStd::vector<AZStd::string> mErrors; /**< List of errors that happened during command execution. */
|
||||
AZStd::vector<Command*> mCommands; /**< A flat array of registered commands, for easy traversal. */
|
||||
size_t mMaxHistoryEntries; /**< The maximum remembered commands in the command history. */
|
||||
int32 mHistoryIndex; /**< The command history iterator. The current position in the undo/redo history. */
|
||||
AZ::u32 m_totalNumHistoryItems; /**< The number of history items since the application start. This number will neither change depending on the size of the history queue nor with undo/redo. */
|
||||
ptrdiff_t mHistoryIndex; /**< The command history iterator. The current position in the undo/redo history. */
|
||||
size_t m_totalNumHistoryItems; /**< The number of history items since the application start. This number will neither change depending on the size of the history queue nor with undo/redo. */
|
||||
int m_commandsInExecution; /**< The number of commands currently in execution. */
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user