|
| 1 | +using UnityEngine; |
| 2 | +using GL = UnityEngine.GUILayout; |
| 3 | +using UnityEditor; |
| 4 | +using Ed = UnityEditor.EditorApplication; |
| 5 | +using EGL = UnityEditor.EditorGUILayout; |
| 6 | +using static UnityEditor.EditorGUILayout; |
| 7 | +// |
| 8 | +using PCfg = Activ.Prolog.PrologConfig; |
| 9 | +using PrologConfigManager = Activ.Prolog.PrologConfigManager; |
| 10 | +using PrologFrame = Activ.Prolog.Frame; |
| 11 | +using PrologLogger = Activ.Prolog.Logger; |
| 12 | +using PrologMessage = Activ.Prolog.Message; |
| 13 | +using PrologWindowModel = Activ.Prolog.LogWindowModel; |
| 14 | +using static Activ.Prolog.LogWindowModel; |
| 15 | + |
| 16 | +namespace Activ.Loggr.UI{ |
| 17 | +public partial class LogWindow{ // Prolog |
| 18 | + |
| 19 | + Vector2 p_scroll; |
| 20 | + |
| 21 | + PrologWindowModel model = PrologWindowModel.instance; |
| 22 | + PrologFrame selectedFrame; // Last selected frame object |
| 23 | + |
| 24 | + void DrawPrologView(){ |
| 25 | + DrawPrologHeader(); |
| 26 | + DrawPrologTextView(); |
| 27 | + } |
| 28 | + |
| 29 | + void DrawPrologHeader(){ |
| 30 | + BeginHorizontal(); |
| 31 | + DrawConfigSelector(); |
| 32 | + DrawReturnTypeSelector(); |
| 33 | + // |
| 34 | + // TODO generic option, likely should partake x-logger header |
| 35 | + Config.step = ToggleLeft("Step", Config.step, GL.MaxWidth(48f)); |
| 36 | + // |
| 37 | + EndHorizontal(); |
| 38 | + } |
| 39 | + |
| 40 | + void DrawPrologTextView(){ |
| 41 | + string log = model.Output(useHistory, rtypeOptions[Config.rtypeIndex]); |
| 42 | + if(currentLog != log && Config.step) Ed.isPaused = true; |
| 43 | + currentLog = log; |
| 44 | + DrawTextView(log, ref p_scroll); |
| 45 | + } |
| 46 | + |
| 47 | + void DrawConfigSelector(){ |
| 48 | + var selected = EGL.ObjectField( |
| 49 | + PrologConfigManager.current, |
| 50 | + typeof(PCfg), |
| 51 | + allowSceneObjects: false); |
| 52 | + PrologConfigManager.current = (PCfg)selected; |
| 53 | + } |
| 54 | + |
| 55 | + void DrawReturnTypeSelector(){ |
| 56 | + if(model.selection){ |
| 57 | + GL.Label("→", GL.MaxWidth(25f)); |
| 58 | + Config.rtypeIndex = Popup(Config.rtypeIndex, rtypeOptions); |
| 59 | + } |
| 60 | + } |
| 61 | + |
| 62 | + // ============================================================= |
| 63 | + |
| 64 | + void DoUpdate(PrologMessage msg) |
| 65 | + { if(frame != Time.frameCount){ frame = Time.frameCount; Repaint(); }} |
| 66 | + |
| 67 | + // From Prolog |
| 68 | + public static void OnMessage(object sender, PrologMessage message){ |
| 69 | + if(isPlaying && instance){ |
| 70 | + instance.model.current = Selection.activeGameObject; |
| 71 | + instance.DoUpdate(message); |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | +}} |
0 commit comments