private void PrimGroupChange(object sender, EventArgs e)
{
Button btn = (Button)sender;
foreach (var cbtn in ButtonGroups)
{
var col = ButtonColors[cbtn.Value];
if (cbtn.Key == btn) cbtn.Key.BackColor = Color.FromArgb((col.R * 128) / 255 + 127, (col.G * 128) / 255 + 127, (col.B * 128) / 255 + 127);
else cbtn.Key.BackColor = col;
}
SelectedGroup = ButtonGroups[btn];
//set primitive list to reflect the group
CurrentFullList = new List<InstructionIDNamePair>();
if (SelectedGroup == PrimitiveGroup.Control || SelectedGroup == PrimitiveGroup.All)
{
CurrentFullList.Add(new InstructionIDNamePair("Return True", 254));
CurrentFullList.Add(new InstructionIDNamePair("Return False", 255));
}
if (SelectedGroup == PrimitiveGroup.All)
{
for (ushort id = 0; id < 68; id++)
{
var primName = EditorScope.Behaviour.Get<STR>(139).GetString(id);
CurrentFullList.Add(new InstructionIDNamePair((primName == null) ? "Primitive #" + id : primName, id));
}
}
if (SelectedGroup == PrimitiveGroup.Subroutine || SelectedGroup == PrimitiveGroup.All)
{
if (bhav.ChunkID > 4095)
{
if (bhav.ChunkID < 8192) CurrentFullList.AddRange(Scope.GetAllSubroutines(ScopeSource.Private));
CurrentFullList.AddRange(Scope.GetAllSubroutines(ScopeSource.SemiGlobal));
}
CurrentFullList.AddRange(Scope.GetAllSubroutines(ScopeSource.Global));
}
else
{
var prims = PrimitiveRegistry.PrimitiveGroups[SelectedGroup];
foreach (var id in prims)
{
var primName = EditorScope.Behaviour.Get<STR>(139).GetString(id);
CurrentFullList.Add(new InstructionIDNamePair((primName == null) ? "Primitive #" + id : primName, id));
}
}
SearchBox.Text = "";
UpdatePrimitiveList();
}