33using System . Linq ;
44using static UnityEditor . EditorGUILayout ;
55using static Activ . Prolog . LogWindowModel ;
6- using static Activ . Prolog . Config ;
6+ // using static Activ.Prolog.PCfg ;
77using Ed = UnityEditor . EditorApplication ;
88using GL = UnityEngine . GUILayout ;
99using EGL = UnityEditor . EditorGUILayout ;
10+ //
11+ using PrologLogger = Activ . Prolog . Logger ;
12+ using PrologConfigManager = Activ . Prolog . PrologConfigManager ;
13+ using PrologFrame = Activ . Prolog . Frame ;
14+ using PrologMessage = Activ . Prolog . Message ;
15+ using PrologWindowModel = Activ . Prolog . LogWindowModel ;
16+ using PrologHistoryGUI = Activ . Prolog . HistoryGUI ;
17+ using PCfg = Activ . Prolog . PrologConfig ;
1018
11- namespace Activ . Prolog {
19+ namespace Activ . Loggr . UI {
1220public class LogWindow : EditorWindow {
1321
1422 const int FontSize = 13 ;
@@ -17,34 +25,37 @@ public class LogWindow : EditorWindow{
1725 //
1826 static Font normalButtonFont ;
1927 static Font _font ;
20- LogWindowModel model = LogWindowModel . instance ;
21- Frame selectedFrame ; // Last selected frame object
22- Vector2 scroll ;
23- string currentLog ;
24- int frame = - 1 ; // Last frame while playing (store this?)
28+ PrologWindowModel model = PrologWindowModel . instance ;
29+ PrologFrame selectedFrame ; // Last selected frame object
30+ Vector2 scroll ;
31+ string currentLog ;
32+ int frame = - 1 ; // Last frame while playing (store this?)
33+ // approx msg count (helps tracking memory overheads)
34+ public static int cumulatedMessageCount ;
2535
2636 LogWindow ( ) {
2737 Ed . pauseStateChanged +=
2838 ( PauseState s ) => { if ( s == PauseState . Paused ) Repaint ( ) ; } ;
29- Activ . Loggr . Logger < string , object > . messageReceived += OnMessage ;
39+ Activ . Loggr . Logger < string , object > . messageReceived += OnGenericMessage ;
3040 }
3141
3242 // From DebugChan
33- public void OnMessage ( string message , object sender ) {
43+ public void OnGenericMessage ( string message , object sender , int messageCount ) {
44+ cumulatedMessageCount = messageCount ;
3445 if ( isPlaying && instance ) {
3546 instance . DoUpdate ( null ) ;
3647 }
3748 }
3849
3950 // From Prolog
40- public static void OnMessage ( object sender , Message message ) {
51+ public static void OnMessage ( object sender , PrologMessage message ) {
4152 if ( isPlaying && instance ) {
4253 instance . model . current = Selection . activeGameObject ;
4354 instance . DoUpdate ( message ) ;
4455 }
4556 }
4657
47- void DoUpdate ( Message msg )
58+ void DoUpdate ( PrologMessage msg )
4859 { if ( frame != Time . frameCount ) { frame = Time . frameCount ; Repaint ( ) ; } }
4960
5061 void OnFocus ( ) {
@@ -54,7 +65,7 @@ void OnFocus(){
5465
5566 void OnGUI ( ) {
5667 if ( PrologConfigManager . current == null ) {
57- if ( GL . Button ( "Create Prolog config" ) ) {
68+ if ( GL . Button ( "Create Debug-Chan config" ) ) {
5869 PrologConfigManager . Create ( ) ;
5970 }
6071 return ;
@@ -70,7 +81,7 @@ void OnGUI_Content(){
7081 DrawScrubber ( ) ;
7182 if ( Config . enableInjection ) DrawDebuggerTextView ( ) ;
7283 DrawLoggerTextView ( ) ;
73- DrawToggles ( ) ;
84+ DrawFooter ( ) ;
7485 //DrawTrailsConfig();
7586 }
7687
@@ -80,7 +91,7 @@ void DrawLoggerTextView(){
8091 DrawTextView ( "Not running" ) ;
8192 return ;
8293 }
83- if ( ! useSelection || model . selection == null ) {
94+ if ( ! Config . useSelection || model . selection == null ) {
8495 DrawTextView ( "No selection" ) ;
8596 return ;
8697 }
@@ -122,7 +133,7 @@ void ConfigTextAreaStyle(){
122133 style . focused . textColor = Color . white ;
123134 }
124135
125- void DrawToggles ( ) {
136+ void DrawFooter ( ) {
126137 BeginHorizontal ( ) ;
127138 Config . useSelection = ToggleLeft ( "Use Selection" , Config . useSelection ,
128139 GL . MaxWidth ( 100f ) ) ;
@@ -132,7 +143,8 @@ void DrawToggles(){
132143 = ToggleLeft ( "Log to console" , Config . logToConsole ,
133144 GL . MaxWidth ( 120 ) ) ;
134145 //
135- GL . FlexibleSpace ( ) ;
146+ EndHorizontal ( ) ;
147+ BeginHorizontal ( ) ;
136148 //
137149 GL . Label ( "Trails - offset: " , GL . MaxWidth ( 88f ) ) ;
138150 Config . trailOffset = FloatField ( Config . trailOffset ,
@@ -144,8 +156,19 @@ void DrawToggles(){
144156 // TODO for Prolog update
145157 //if(model.selection){
146158 // GL.Label("→", GL.MaxWidth(25f));
147- // Config .rtypeIndex = Popup(Config .rtypeIndex, rtypeOptions);
159+ // PCfg .rtypeIndex = Popup(PCfg .rtypeIndex, rtypeOptions);
148160 //}
161+ //EndHorizontal();
162+ //BeginHorizontal();
163+ GL . FlexibleSpace ( ) ;
164+ if ( isPlaying ) {
165+ EGL . LabelField ( $ "#{ cumulatedMessageCount : 0,000,000} ", GL . MaxWidth ( 92f ) ) ;
166+ } else {
167+ EditorGUIUtility . labelWidth = 60 ;
168+ Config . maxMessages = EGL . IntField ( "Max msgs" , Config . maxMessages ) ;
169+ EditorGUIUtility . labelWidth = 0 ;
170+ //if(ScrubberButton($"Clear")) Clear();
171+ }
149172 EndHorizontal ( ) ;
150173 if ( ! Config . useSelection ) model . current = null ;
151174 }
@@ -165,9 +188,13 @@ void DrawScrubber(){
165188 if ( ScrubberButton ( ">" ) ) SelectNext ( ) ;
166189 style . font = normalButtonFont ;
167190 GL . FlexibleSpace ( ) ;
168- if ( ! isPlaying && ScrubberButton ( $ "Clear") ) Clear ( ) ;
191+ if ( isPlaying ) {
192+ //EGL.LabelField($"N#{cumulatedMessageCount:0,000,000}", GL.MaxWidth(92f));
193+ } else {
194+ if ( ScrubberButton ( $ "Clear") ) Clear ( ) ;
195+ }
169196 // TODO reenable
170- //Config .step = ToggleLeft("Step", Config .step, GL.MaxWidth(48f));
197+ //PCfg .step = ToggleLeft("Step", PCfg .step, GL.MaxWidth(48f));
171198 EndHorizontal ( ) ;
172199 }
173200
@@ -176,25 +203,25 @@ bool ScrubberButton(string arg)
176203
177204 // TODO re-enable but move elsewhere
178205 //void DrawPauseModeConfig(){
179- // Config .enableInjection = ToggleLeft(
206+ // PCfg .enableInjection = ToggleLeft(
180207 // $"Instrument ({Logger.injectionTimeMs}ms)",
181- // Config .enableInjection, GL.ExpandWidth(true));
208+ // PCfg .enableInjection, GL.ExpandWidth(true));
182209 //}
183210
184211 void ToggleAdvanced ( ) { }
185212
186213 void DrawConfigManager ( ) {
187214 var selected = EGL . ObjectField (
188215 PrologConfigManager . current ,
189- typeof ( PrologConfig ) ,
216+ typeof ( PCfg ) ,
190217 allowSceneObjects : false ) ;
191- PrologConfigManager . current = selected as PrologConfig ;
218+ PrologConfigManager . current = ( PCfg ) selected ;
192219 }
193220
194221 // Ref https://tinyurl.com/yyo8c35g which also demonstrates starting a 2D
195222 // GUI at handles location
196223 void OnSceneGUI ( SceneView sceneView ) {
197- var sel = HistoryGUI . Draw ( model . filtered , selectedFrame ) ;
224+ var sel = PrologHistoryGUI . Draw ( model . filtered , selectedFrame ) ;
198225 if ( Ed . isPaused || ! isPlaying ) {
199226 selectedFrame = sel ?? selectedFrame ;
200227 Repaint ( ) ;
@@ -207,7 +234,7 @@ void OnSelectionChange()
207234 { if ( Ed . isPaused || ! isPlaying ) Repaint ( ) ; }
208235
209236 void Clear ( ) {
210- Logger . Clear ( ) ;
237+ PrologLogger . Clear ( ) ;
211238 model . Clear ( ) ;
212239 selectedFrame = null ;
213240 SceneView . RepaintAll ( ) ;
@@ -226,10 +253,10 @@ void SelectNext(){
226253 SceneView . RepaintAll ( ) ;
227254 }
228255
229- [ MenuItem ( "Window/Activ/Prolog " ) ]
256+ [ MenuItem ( "Window/Activ/Debug-Chan " ) ]
230257 static void Init ( ) {
231258 instance = ( LogWindow ) EditorWindow
232- . GetWindow < LogWindow > ( title : "Prolog " ) ;
259+ . GetWindow < LogWindow > ( title : "Debug-Chan " ) ;
233260 instance . Show ( ) ;
234261 }
235262
0 commit comments