Skip to content

Commit af20e35

Browse files
committed
Restore Prolog GUI
1 parent 332e3e9 commit af20e35

File tree

8 files changed

+214
-132
lines changed

8 files changed

+214
-132
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using UnityEngine;
2+
using Ed = UnityEditor.EditorApplication;
3+
4+
namespace Activ.Loggr.UI{
5+
public partial class LogWindow{ // Debug-Chan
6+
7+
Vector2 dc_scroll;
8+
9+
// From DebugChan
10+
public void OnGenericMessage(string message, object sender, int messageCount){
11+
cumulatedMessageCount = messageCount;
12+
if(isPlaying && instance){
13+
instance.DoUpdate(null);
14+
}
15+
}
16+
17+
void DrawLoggerTextView()
18+
=> DrawTextView(EvalTextContent(), ref dc_scroll);
19+
20+
string EvalTextContent(){
21+
var logger = (Activ.Loggr.Logger<string, object>) DebugChan.logger;
22+
if(logger == null){
23+
return "Debug-Chan: not running";
24+
}
25+
if(!Config.useSelection || model.selection == null){
26+
return "Debug-Chan: no selection";
27+
}
28+
if(useHistory && Ed.isPaused){
29+
var text = logger[model.selection]?.Format() ?? "No messages";
30+
return model.selection.name + "\n\n" + text;
31+
}else{
32+
var frame = logger.CurrentFrame(model.selection);
33+
var text = frame?.Format() ?? "Debug-Chan: no messages";
34+
return model.selection.name + "\n\n" + text;
35+
}
36+
}
37+
38+
}}

Editor/Core/UI/LogWindow-DebugChan.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Core/UI/LogWindow-Prolog.cs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
}}

Editor/Core/UI/LogWindow-Prolog.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)