@@ -33,11 +33,11 @@ typedef ConsoleLogData = {
3333
3434class ConsoleUI {
3535
36- static final CONSOLE_BG_COLOR = 0xFF380051 ;
37- static final SEARCH_HIGHLIGHT_COLOR = 0xFF00FF00 ;
38- static final SEARCH_SELECTED_COLOR = 0xFFE2D302 ;
39- static final SEARCH_DESC_COLOR = 0xFF636363 ;
40- static final SEARCH_ARGS_COLOR = 0xFF58804F ;
36+ static final CONSOLE_BG_COLOR = new ImGuiFloat3Ptr ( 0.22 , 0.0 , 0.32 ) ;
37+ static final SEARCH_HIGHLIGHT_COLOR = new ImGuiFloat3Ptr ( 0.0 , 1.0 , 0.0 ) ;
38+ static final SEARCH_SELECTED_COLOR = new ImGuiFloat3Ptr ( 0.888 , 0.83 , 0.008 ) ;
39+ static final SEARCH_DESC_COLOR = new ImGuiFloat3Ptr ( 0.6 , 0.6 , 0.6 ) ;
40+ static final SEARCH_ARGS_COLOR = new ImGuiFloat3Ptr ( 0.35 , 0.5 , 0.31 ) ;
4141
4242 static final CONSOLE_MAX_OUPUT = 100 ;
4343 static final SEARCH_MAX_OUTPUT = 25 ;
@@ -71,6 +71,7 @@ class ConsoleUI {
7171
7272 #if IMGUI_ENABLED
7373 var settingsOpen : ImGuiBoolPtr = new ImGuiBoolPtr (false );
74+ var stylesOpen : ImGuiBoolPtr = new ImGuiBoolPtr (false );
7475
7576 var timeFilter : ImGuiBoolPtr = new ImGuiBoolPtr (true );
7677 var typeFilter : ImGuiBoolPtr = new ImGuiBoolPtr (true );
@@ -210,6 +211,35 @@ class ConsoleUI {
210211 #end
211212 }
212213
214+ private static final CONSOLE_COLOR_ORDER : Array <ConsoleColor > = [
215+ BLACK , DARKBLUE , DARKGREEN , DARKCYAN , DARKRED , DARKMAGENTA , DARKYELLOW , LIGHTGRAY ,
216+ GRAY , BLUE , GREEN , CYAN , RED , MAGENTA , YELLOW , WHITE
217+ ];
218+
219+ public static final consoleColors : Map <ConsoleColor , ImGuiFloat3Ptr > = [
220+ BLACK => new ImGuiFloat3Ptr (0.0 , 0.0 , 0.0 ),
221+ DARKBLUE => new ImGuiFloat3Ptr (0.04 , 0.04 , 0.76 ),
222+ DARKGREEN => new ImGuiFloat3Ptr (0.0 , 0.53 , 0.0 ),
223+ DARKCYAN => new ImGuiFloat3Ptr (0.0 , 0.53 , 0.53 ),
224+ DARKRED => new ImGuiFloat3Ptr (0.53 , 0.0 , 0.0 ),
225+ DARKMAGENTA => new ImGuiFloat3Ptr (0.6 , 0.11 , 0.77 ),
226+ DARKYELLOW => new ImGuiFloat3Ptr (0.74 , 0.74 , 0.0 ),
227+ LIGHTGRAY => new ImGuiFloat3Ptr (0.83 , 0.83 , 0.83 ),
228+ // /////////////////////////////////////////////////////
229+ GRAY => new ImGuiFloat3Ptr (0.64 , 0.64 , 0.64 ),
230+ BLUE => new ImGuiFloat3Ptr (0.16 , 0.29 , 0.92 ),
231+ GREEN => new ImGuiFloat3Ptr (0.0 , 1.0 , 0.0 ),
232+ CYAN => new ImGuiFloat3Ptr (0.0 , 0.54 , 1.0 ),
233+ RED => new ImGuiFloat3Ptr (1.0 , 0.0 , 0.0 ),
234+ MAGENTA => new ImGuiFloat3Ptr (1.0 , 0.0 , 1.0 ),
235+ YELLOW => new ImGuiFloat3Ptr (1.0 , 1.0 , 0.0 ),
236+ WHITE => new ImGuiFloat3Ptr (1.0 , 1.0 , 1.0 ),
237+ ];
238+
239+ public static function consoleColorToImColor (color : ConsoleColor ) {
240+ return (consoleColors .get (color ) ?? consoleColors .get (WHITE )).toImColor ();
241+ }
242+
213243 public function displayUI () {
214244 #if IMGUI_ENABLED
215245 if (! Options .devMode ) {
@@ -219,8 +249,10 @@ class ConsoleUI {
219249 }
220250
221251 var toggled : Bool = false ;
222- for (key in Options .SOLO_DEV_CONSOLE ) {
223- if (ImGui .isKeyPressed (key .toImGuiKey (), false )) toggled = true ;
252+ if (! Options .useNativeConsole ) {
253+ for (key in Options .SOLO_DEV_CONSOLE ) {
254+ if (ImGui .isKeyPressed (key .toImGuiKey (), false )) toggled = true ;
255+ }
224256 }
225257 if (toggled ) toggleUI ();
226258
@@ -237,6 +269,9 @@ class ConsoleUI {
237269 ImGui .setNextWindowPos (ImGuiUtil .getWindowSpaceX () + Lib .application .window .width - 240 , ImGuiUtil .getWindowSpaceY (), ImGuiCond . FirstUseEver );
238270 ImGui .setNextWindowSize (240 , 405 , ImGuiCond . FirstUseEver );
239271 if (ImGui .begin (" Console Settings" , settingsOpen , 0 )) {
272+ if (ImGui .button (" Open Style Editor" )) {
273+ stylesOpen .value = ! stylesOpen .value ;
274+ }
240275 // ImGui.checkbox("Count duplicated output##Console Settings", countDuplicatedOutput); ImGui.setItemTooltip("Toggles if duplicated logs add a counter instead of displaying again");
241276 ImGui .separatorText (" Log Filter:" );
242277 ImGui .checkbox (" Time##Console Settings" , timeFilter ); ImGui .setItemTooltip (" Toggles if timestamp shows in each log" );
@@ -259,6 +294,27 @@ class ConsoleUI {
259294 saveSettings ();
260295 }
261296
297+ if (stylesOpen .value ) {
298+ if (ImGui .begin (" Style Editor" )) {
299+ ImGui .textWrapped (" THIS WILL NOT SAVE !!! (yet)" );
300+ ImGui .textWrapped (" Expect cool stuff to share with people once you're able to save though" );
301+ ImGui .separator ();
302+ ImGui .separatorText (" Console Colors" );
303+ ImGui .colorEdit3 (" Input BG Color##Style Editor" , CONSOLE_BG_COLOR , ImGuiColorEditFlags . NoInputs );
304+ ImGui .colorEdit3 (" Search Highlight##Style Editor" , SEARCH_HIGHLIGHT_COLOR , ImGuiColorEditFlags . NoInputs );
305+ ImGui .colorEdit3 (" Search Selection##Style Editor" , SEARCH_SELECTED_COLOR , ImGuiColorEditFlags . NoInputs );
306+ ImGui .colorEdit3 (" Search Description##Style Editor" , SEARCH_DESC_COLOR , ImGuiColorEditFlags . NoInputs );
307+ ImGui .colorEdit3 (" Search Arguments##Style Editor" , SEARCH_ARGS_COLOR , ImGuiColorEditFlags . NoInputs );
308+ ImGui .separatorText (" Text Colors" );
309+ for (x => i in CONSOLE_COLOR_ORDER ) {
310+ ImGui .colorEdit3 (" Text Color #${x+1}##$x" , consoleColors [i ], ImGuiColorEditFlags . NoInputs | ImGuiColorEditFlags . NoLabel );
311+ if ((x + 1 ) % Std .int (CONSOLE_COLOR_ORDER .length / 2 ) != 0 ) ImGui .sameLine (0 , 2 );
312+ }
313+ ImGui .showStyleEditor ();
314+ }
315+ ImGui .end ();
316+ }
317+
262318 ImGui .setNextWindowPos (ImGuiUtil .getWindowSpaceX (), ImGuiUtil .getWindowSpaceY () + (Lib .application .window .height - 250 ), ImGuiCond . FirstUseEver );
263319 ImGui .setNextWindowSize (Lib .application .window .width , 250 , ImGuiCond . FirstUseEver );
264320 ImGui .setNextWindowDockID (0 , ImGuiCond . FirstUseEver );
@@ -321,18 +377,23 @@ class ConsoleUI {
321377 }
322378 }
323379
380+ // TODO: text wraping
381+ inline function drawText (text : String ) {
382+ ImGui .textUnformatted (text );
383+ }
384+
324385 for (textIndex => t in consoleOutput [i ].log ) {
325386 if (indicesToIgnore .contains (textIndex )) continue ;
326387 if (! timeFilter .value && textIndex == 0 ) { // fix padding
327388 ImGui .sameLine (0 , 0 );
328389 ImGui .pushStyleColor (ImGuiCol . Text , consoleColorToImColor (t .color ));
329- ImGui . textUnformatted (" [" );
390+ drawText (" [" );
330391 ImGui .popStyleColor ();
331392 continue ;
332393 } else if (! typeFilter .value && textIndex == 4 ) {
333394 ImGui .sameLine (0 , 0 );
334395 ImGui .pushStyleColor (ImGuiCol . Text , consoleColorToImColor (t .color ));
335- ImGui . textUnformatted (" ] " );
396+ drawText (" ] " );
336397 ImGui .popStyleColor ();
337398 continue ;
338399 }
@@ -341,14 +402,14 @@ class ConsoleUI {
341402 ImGui .pushStyleColor (ImGuiCol . Text , consoleColorToImColor (t .color ));
342403 var lines = t .text .split (" \n " );
343404 for (i => l in lines ) {
344- ImGui . textUnformatted (l );
405+ drawText (l );
345406 }
346407 ImGui .popStyleColor ();
347408 }
348409
349410 if (countDuplicatedOutput .value && consoleOutput [i ].times > 1 ) {
350411 ImGui .sameLine (0 , 0 );
351- ImGui . textUnformatted (" (" + consoleOutput [i ].times + " x)" );
412+ drawText (" (" + consoleOutput [i ].times + " x)" );
352413 }
353414
354415 ImGui .newLine ();
@@ -402,7 +463,7 @@ class ConsoleUI {
402463 if (end < SEARCH_MAX_OUTPUT ) end = SEARCH_MAX_OUTPUT ;
403464 if (end > commandSearch .length ) end = commandSearch .length ;
404465
405- ImGui .pushStyleColor (ImGuiCol . WindowBg , CONSOLE_BG_COLOR );
466+ ImGui .pushStyleColor (ImGuiCol . WindowBg , CONSOLE_BG_COLOR . toImColor () );
406467 ImGui .setNextWindowPos (inputTextCursorPos .x , inputTextCursorPos .y - (ImGui .getTextLineHeightWithSpacing () * (end - start ))- 12 );
407468 if (ImGui .begin (" Command Search window" , null , ImGuiWindowFlags . NoDecoration | ImGuiWindowFlags . AlwaysAutoResize | ImGuiWindowFlags . NoInputs | ImGuiWindowFlags . NoFocusOnAppearing )) {
408469 ImGui .bringNamedWindowToDisplayFront (" Command Search window" );
@@ -415,16 +476,16 @@ class ConsoleUI {
415476 var after : String = cmdName .substring (cmd .searchIndex + inputName .length , cmdName .length );
416477
417478 if (before != " " ) {
418- if (i == commandSearch .length - 1 ) ImGui .pushStyleColor (ImGuiCol . Text , SEARCH_SELECTED_COLOR );
479+ if (i == commandSearch .length - 1 ) ImGui .pushStyleColor (ImGuiCol . Text , SEARCH_SELECTED_COLOR . toImColor () );
419480 ImGui .textUnformatted (before );
420481 ImGui .sameLine (0 , 0 );
421482 if (i == commandSearch .length - 1 ) ImGui .popStyleColor ();
422483 }
423- ImGui .pushStyleColor (ImGuiCol . Text , SEARCH_HIGHLIGHT_COLOR );
484+ ImGui .pushStyleColor (ImGuiCol . Text , SEARCH_HIGHLIGHT_COLOR . toImColor () );
424485 ImGui .textUnformatted (cmdName .substring (cmd .searchIndex , cmd .searchIndex + inputName .length ));
425486 ImGui .popStyleColor ();
426487 if (after != " " ) {
427- if (i == commandSearch .length - 1 ) ImGui .pushStyleColor (ImGuiCol . Text , SEARCH_SELECTED_COLOR );
488+ if (i == commandSearch .length - 1 ) ImGui .pushStyleColor (ImGuiCol . Text , SEARCH_SELECTED_COLOR . toImColor () );
428489 ImGui .sameLine (0 , 0 );
429490 ImGui .textUnformatted (after );
430491 if (i == commandSearch .length - 1 ) ImGui .popStyleColor ();
@@ -435,20 +496,20 @@ class ConsoleUI {
435496 ImGui .textUnformatted (" (TAB to Autocomplete)" );
436497 }
437498 } else {
438- if (i == cycleIndex ) ImGui .pushStyleColor (ImGuiCol . Text , SEARCH_SELECTED_COLOR );
499+ if (i == cycleIndex ) ImGui .pushStyleColor (ImGuiCol . Text , SEARCH_SELECTED_COLOR . toImColor () );
439500 ImGui .textUnformatted (cmd .name );
440501 if (i == cycleIndex ) ImGui .popStyleColor ();
441502 }
442503
443504 if (cmd .argsDesc != null && cmd .argsDesc != " " ) {
444505 ImGui .sameLine ();
445- ImGui .pushStyleColor (ImGuiCol . Text , SEARCH_ARGS_COLOR );
506+ ImGui .pushStyleColor (ImGuiCol . Text , SEARCH_ARGS_COLOR . toImColor () );
446507 ImGui .textUnformatted (cmd .argsDesc );
447508 ImGui .popStyleColor ();
448509 }
449510 if (cmd .desc != " " ) {
450511 ImGui .sameLine ();
451- ImGui .pushStyleColor (ImGuiCol . Text , SEARCH_DESC_COLOR );
512+ ImGui .pushStyleColor (ImGuiCol . Text , SEARCH_DESC_COLOR . toImColor () );
452513 ImGui .textUnformatted (cmd .desc );
453514 ImGui .popStyleColor ();
454515 }
@@ -676,25 +737,4 @@ class ConsoleUI {
676737 Logs .infos (Std .string (consoleHscript .tryExecute (str )), LIGHTGRAY , " Console" );
677738 }
678739 }
679-
680- public static function consoleColorToImColor (color : ConsoleColor ) {
681- return switch (color ) {
682- case BLACK : 0xFF000000 ;
683- case DARKBLUE : 0xFF0909C3 ;
684- case DARKGREEN : 0xFF008800 ;
685- case DARKCYAN : 0xFF008888 ;
686- case DARKRED : 0xFF880000 ;
687- case DARKMAGENTA : 0xFF9A1CC5 ;
688- case DARKYELLOW : 0xFFBCBC00 ;
689- case LIGHTGRAY : 0xFFD4D4D4 ;
690- case GRAY : 0xFFA4A4A4 ;
691- case BLUE : 0xFF2A4AEA ;
692- case GREEN : 0xFF00FF00 ;
693- case CYAN : 0xFF008CFF ;
694- case RED : 0xFFFF0000 ;
695- case MAGENTA : 0xFFFF00FF ;
696- case YELLOW : 0xFFFFFF00 ;
697- case WHITE | _ : 0xFFFFFFFF ;
698- }
699- }
700740}
0 commit comments