private void addCommand(int list, int index)
{
//list: 3: recent, 2: commands, 1: creatures, 0: items
int eIndex = -1;
switch (list)
{
case 3:
eIndex = recentList[index];
list = recentKindList[index];
break;
case 2:
eIndex = commandList[index];
break;
case 1:
eIndex = creatureList[index];
break;
case 0:
eIndex = itemList[index];
break;
default:
break;
}
if (eIndex >= 0)
{
string command = createCommand(list, eIndex);
if (command.Length > 0)
{
string name = this.entities[eIndex].name;
this.textBoxCommand.Text += (this.textBoxCommand.Text.Length > 0 ? "|" : "") + command;
int pos = this.listBoxRecent.Items.IndexOf(name);
if (pos == -1)
{
this.recentList.Insert(0, eIndex);
this.recentKindList.Insert(0, list);
this.listBoxRecent.Items.Insert(0, name);
updateRecentlyList();
}
else if (pos > 0)
{
this.recentList.RemoveAt(pos);
this.recentKindList.RemoveAt(pos);
this.listBoxRecent.Items.RemoveAt(pos);
this.recentList.Insert(0, eIndex);
this.recentKindList.Insert(0, list);
this.listBoxRecent.Items.Insert(0, name);
updateRecentlyList();
}
}
}
}