public void AddInstruction(Instruction instruction) { if (instruction is EventInstruction eventInstruction) { this.expectedEventActions.Add(new EventActionPair(eventInstruction.GetEvent())); } else if (instruction is ActionInstruction actionInstruction) { if (this.LastEventActionPair.Action != null) { throw new Exception($"Last event action already set with operation {this.LastEventActionPair.Action.Operation}"); } this.LastEventActionPair.Action = actionInstruction; } else if (instruction is PlayerStateInstruction playerStateInstruction) { if (this.LastEventActionPair.Action != null) { throw new Exception($"Last event action already set with operation {this.LastEventActionPair.Action.Operation}"); } this.LastEventActionPair.Action = playerStateInstruction.GetAction(); this.expectedEventActions.Add(new EventActionPair(playerStateInstruction.GetEvent())); } else if (instruction is MultipleEventInstruction multipleEventInstruction) { var eventActionPair = new EventActionPair(); foreach (var gameEvent in multipleEventInstruction.Events) { eventActionPair.Add(gameEvent); } this.expectedEventActions.Add(eventActionPair); } }
private static void Edit(this EventActionPair pair) { var editDialog = new EventActionPairEditor(pair); editDialog.ShowDialog(); pair?.Refresh(); }
public static EventActionPair New() { var dialog = new SelectDualItem( EventActionFactory.AvailableEvents, EventActionFactory.AvailableActions, "New Event and Action Pair", "Event:", "Action:"); dialog.ShowDialog(); if (dialog.SelectedItem1 == null || dialog.SelectedItem2 == null) { return(null); } var newPair = new EventActionPair { Event = EventActionFactory.GetNewEventFromName((string)dialog.SelectedItem1), Action = EventActionFactory.GetNewActionFromName((string)dialog.SelectedItem2) }; newPair.Add(); newPair.Edit(); return(newPair); }
private static void Refresh(this EventActionPair pair) { if (pair.Event is HotkeyEvent hotkeyEvent) { hotkeyEvent.Hotkey.Disabled = pair.Disabled; HotkeyStore.RegisterHotkey(hotkeyEvent.Hotkey, pair.Action.Execute); } }
public static void New() { var dialog = new SelectDualItem( EventActionFactory.AvailableEvents, EventActionFactory.AvailableActions, "New Event and Action Pair", "Event:", "Action:"); dialog.ShowDialog(); if (dialog.SelectedItem1 == null || dialog.SelectedItem2 == null) return; var newPair = new EventActionPair { Event = EventActionFactory.GetNewEventFromName((string) dialog.SelectedItem1), Action = EventActionFactory.GetNewActionFromName((string) dialog.SelectedItem2) }; newPair.Add(); newPair.Edit(); }
public EventActionPairEditor(EventActionPair pair) { InitializeComponent(); EventActionPair = pair; DataContext = this; }
private static void Add(this EventActionPair pair) { App.WidgetsSettingsStore.EventActionPairs.Add(pair); }
public EventActionPairEditor(EventActionPair pair) { InitializeComponent(); EventActionPair = pair; DataContext = this; }