public BHAVEditor(BHAV bhav, EditorScope scope) { Scope = scope; this.bhav = bhav; InitializeComponent(); Text = scope.GetFilename(scope.GetScopeFromID(bhav.ChunkID))+"::"+bhav.ChunkLabel.Trim('\0'); EditorControl.InitBHAV(bhav, scope); PrimitiveList.Items.AddRange(scope.GetAllSubroutines(ScopeSource.Private).ToArray()); /*PrimitiveList.Items.Add("Generic Sims Online Call"); PrimitiveList.Items.Add("Sleep"); PrimitiveList.Items.Add("Idle for Input"); PrimitiveList.Items.Add("Notify Stack Object out of Idle"); PrimitiveList.Items.Add("Push Interaction"); PrimitiveList.Items.Add("Find Best Object For Function"); PrimitiveList.Items.Add("Run Functional Tree"); PrimitiveList.Items.Add("Run Tree By Name"); PrimitiveList.Items.Add("Add / Change Action String");*/ ButtonGroups = new Dictionary<Button, PrimitiveGroup>() { {SubroutineBtn, PrimitiveGroup.Subroutine}, {ControlBtn, PrimitiveGroup.Control}, {DebugBtn, PrimitiveGroup.Debug}, {MathBtn, PrimitiveGroup.Math}, {SimBtn, PrimitiveGroup.Sim}, {ObjectBtn, PrimitiveGroup.Object}, {LooksBtn, PrimitiveGroup.Looks}, {PositionBtn, PrimitiveGroup.Position}, {TSOBtn, PrimitiveGroup.TSO}, {AllBtn, PrimitiveGroup.All } }; ButtonColors = new Dictionary<PrimitiveGroup, Color>(); foreach (var btn in ButtonGroups) { ButtonColors.Add(btn.Value, btn.Key.BackColor); btn.Key.Click += PrimGroupChange; } PrimGroupChange(AllBtn, null); EditorCont.OnSelectedChanged += SelectionChanged; }
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(); }