public void show(DebugConsoleBinding binding) { destroy(); onShow?.Invoke(this); onShow = null; var view = binding.clone(); Object.DontDestroyOnLoad(view); var currentGroupButtons = ImmutableList <ButtonBinding> .Empty; setupList(view.commands, () => currentGroupButtons); var commandGroups = commands.Select(commandGroup => { var button = addButton(view.buttonPrefab, view.commandGroups.holder.transform); button.text.text = commandGroup.Key; button.button.onClick.AddListener(() => currentGroupButtons = showGroup(view, commandGroup.Key, commandGroup.Value) ); return(button); }).ToImmutableList(); setupList(view.commandGroups, () => commandGroups); Application.logMessageReceivedThreaded += onLogMessageReceived; view.closeButton.onClick.AddListener(destroy); current = new Instance(view).some(); }
public static IObservable <Unit> registerDebugSequence( IDisposableTracker tracker, DebugSequenceMouseData mouseData = null, Option <DebugSequenceDirectionData> directionDataOpt = default, DebugConsoleBinding binding = null, [CallerMemberName] string callerMemberName = "", [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = 0 ) { Option.ensureValue(ref directionDataOpt); binding = binding ? binding : Resources.Load <DebugConsoleBinding>("Debug Console Prefab"); mouseData = mouseData ?? DEFAULT_MOUSE_DATA; var mouseObs = new RegionClickObservable(mouseData.width, mouseData.height) .sequenceWithinTimeframe( tracker, mouseData.sequence, 3, // ReSharper disable ExplicitCallerInfoArgument callerMemberName: callerMemberName, callerFilePath: callerFilePath, callerLineNumber: callerLineNumber // ReSharper restore ExplicitCallerInfoArgument ); var directionObs = directionDataOpt.fold( Observable <Unit> .empty, directionData => { var directions = Observable.everyFrame.collect(_ => { var horizontal = Input.GetAxisRaw(directionData.horizonalAxisName); var vertical = Input.GetAxisRaw(directionData.verticalAxisName); // Both are equal, can't decide. if (Math.Abs(horizontal - vertical) < 0.001f) { return(Option <Direction> .None); } return (Math.Abs(horizontal) > Math.Abs(vertical) ? F.some(horizontal > 0 ? Direction.Right : Direction.Left) : F.some(vertical > 0 ? Direction.Up : Direction.Down)); }).changedValues(); return (directions .withinTimeframe(directionData.sequence.Count, directionData.timeframe) .filter(l => l.Select(t => t._1).SequenceEqual(directionData.sequence)) .discardValue()); } ); var editorShortcut = instance.editorShortcutObs.filter(_ => instance.current.isNone); var obs = mouseObs.join(directionObs).join(editorShortcut); obs.subscribe(tracker, _ => instance.show(binding)); return(obs); }
public void show(DebugConsoleBinding binding) { destroy(); onShow?.Invoke(this); onShow = null; var view = binding.clone(); Object.DontDestroyOnLoad(view); var currentGroupButtons = ImmutableList <ButtonBinding> .Empty; setupList(view.commands, () => currentGroupButtons); var commandGroups = commands.OrderBy(_ => _.Key).Select(commandGroup => { var button = addButton(view.buttonPrefab, view.commandGroups.holder.transform); button.text.text = commandGroup.Key; button.button.onClick.AddListener(() => currentGroupButtons = showGroup(view, commandGroup.Key, commandGroup.Value) ); return(button); }).ToImmutableList(); setupList(view.commandGroups, () => commandGroups); var logEntryPool = GameObjectPool.a(GameObjectPool.Init <VerticalLayoutLogEntry> .noReparenting( nameof(DConsole) + " log entry pool", () => view.logEntry.prefab.clone() )); var cache = new List <string>(); var layout = new DynamicVerticalLayout.Init( view.dynamicLayout, // ReSharper disable once InconsistentlySynchronizedField logEntries .SelectMany(e => createEntries(e, logEntryPool, cache, view.lineWidth)) .Select(_ => _.upcast(default(DynamicVerticalLayout.IElementData))), renderLatestItemsFirst: true ); var logCallback = onLogMessageReceived(logEntryPool, cache); Application.logMessageReceivedThreaded += logCallback; view.closeButton.onClick.AddListener(destroy); var editorShortcut = instance.editorShortcutObs.filter(_ => instance.current.isSome); view.minimizeButton.onClick.join(editorShortcut).subscribe(view.gameObject, _ => view.minimizableObjectsContainer.SetActive( !view.minimizableObjectsContainer.activeSelf ) ); current = new Instance(view, layout, logCallback, logEntryPool).some(); }
static void showGroup(DebugConsoleBinding view, string groupName, IEnumerable <Command> commands) { view.commandGroupLabel.text = groupName; foreach (var t in view.commandsHolder.transform.children()) { Object.Destroy(t.gameObject); } foreach (var command in commands) { var button = addButton(view.buttonPrefab, view.commandsHolder.transform); button.text.text = command.name; button.button.onClick.AddListener(() => command.run()); } }
public static IObservable <Unit> registerDebugSequence( DebugSequenceMouseData mouseData = null, Option <DebugSequenceDirectionData> directionDataOpt = default(Option <DebugSequenceDirectionData>), DebugConsoleBinding binding = null ) { Option.ensureValue(ref directionDataOpt); binding = binding ?? Resources.Load <DebugConsoleBinding>("Debug Console Prefab"); mouseData = mouseData ?? DEFAULT_MOUSE_DATA; var mouseObs = new RegionClickObservable(mouseData.width, mouseData.height) .sequenceWithinTimeframe(mouseData.sequence, 3); var directionObs = directionDataOpt.fold( Observable <Unit> .empty, directionData => { var directions = Observable.everyFrame.collect(_ => { var horizontal = Input.GetAxisRaw(directionData.horizonalAxisName); var vertical = Input.GetAxisRaw(directionData.verticalAxisName); // Both are equal, can't decide. if (Math.Abs(horizontal - vertical) < 0.001f) { return(Option <Direction> .None); } return (Math.Abs(horizontal) > Math.Abs(vertical) ? F.some(horizontal > 0 ? Direction.Right : Direction.Left) : F.some(vertical > 0 ? Direction.Up : Direction.Down)); }).changedValues(); return (directions .withinTimeframe(directionData.sequence.Count, directionData.timeframe) .filter(l => l.Select(t => t._1).SequenceEqual(directionData.sequence)) .discardValue()); } ); var obs = mouseObs.join(directionObs); obs.subscribe(_ => instance.show(binding)); return(obs); }
static ImmutableList <ButtonBinding> showGroup( DebugConsoleBinding view, string groupName, IEnumerable <Command> commands ) { view.commandGroupLabel.text = groupName; var commandsHolder = view.commands.holder; foreach (var t in commandsHolder.transform.children()) { Object.Destroy(t.gameObject); } return(commands.Select(command => { var button = addButton(view.buttonPrefab, commandsHolder.transform); button.text.text = command.name; button.button.onClick.AddListener(() => command.run()); return button; }).ToImmutableList()); }
public void show(DebugConsoleBinding binding) { destroy(); var view = binding.clone(); Object.DontDestroyOnLoad(view); foreach (var commandGroup in commands) { var button = addButton(view.buttonPrefab, view.commandGroupsHolder.transform); button.text.text = commandGroup.Key; button.button.onClick.AddListener(() => showGroup(view, commandGroup.Key, commandGroup.Value)); } Application.logMessageReceived += onLogMessageReceived; view.closeButton.onClick.AddListener(destroy); current = new Instance(view).some(); }
public static RegionClickObservable registerDebugSequence( DebugConsoleBinding binding = null, int[] sequence = null ) { binding = binding ?? Resources.Load <DebugConsoleBinding>("Debug Console Prefab"); sequence = sequence ?? DEFAULT_SEQUENCE; var go = new GameObject { name = "Debug Console initiator" }; Object.DontDestroyOnLoad(go); var obs = go.AddComponent <RegionClickObservable>(); obs.init(2, 2).sequenceWithinTimeframe(sequence, 3) .subscribe(_ => { instance.show(binding); }); return(obs); }
public Instance(DebugConsoleBinding view) { this.view = view; }