void OnRightClick(ShowMapMenuEvent e) { if (_npc.Node == null) { return; } var window = Resolve <IWindowManager>(); var camera = Resolve <ICamera>(); var tf = Resolve <ITextFormatter>(); var normPosition = camera.ProjectWorldToNorm(_sprite.Position); var uiPosition = window.NormToUi(normPosition.X, normPosition.Y); // TODO: NPC type check. IText S(TextId textId) => tf.NoWrap().Center().Format(textId); var heading = S(Base.SystemText.MapPopup_Person); var options = new List <ContextMenuOption> { new( S(Base.SystemText.MapPopup_TalkTo), new TriggerChainEvent(_npc.ChainSource, _npc.Chain, _npc.Node, new EventSource(_npc.Id, TextId.None, TriggerTypes.TalkTo)), ContextMenuGroup.Actions), new( S(Base.SystemText.MapPopup_MainMenu), new PushSceneEvent(SceneId.MainMenu), ContextMenuGroup.System ) }; Raise(new ContextMenuEvent(uiPosition, heading, options)); e.Propagating = false; }
void ShowContextMenu(IList <Selection> orderedHits) { Raise(new PopMouseModeEvent()); var clickEvent = new ShowMapMenuEvent(); foreach (var hit in orderedHits) { if (!clickEvent.Propagating) { break; } var component = hit.Target as IComponent; component?.Receive(clickEvent, this); } }