TRAIN BAR
authorhgn <hgodden00@gmail.com>
Wed, 14 Jul 2021 16:35:25 +0000 (17:35 +0100)
committerhgn <hgodden00@gmail.com>
Wed, 14 Jul 2021 16:35:25 +0000 (17:35 +0100)
csRadar.c
csrLog.h

index e68237c5f46edf4d3220f2c8dac68506c01c2852..5347d751021634e7b31c04ac7eb90d1fd4c00022 100644 (file)
--- a/csRadar.c
+++ b/csRadar.c
@@ -6,6 +6,9 @@
 #include <time.h>
 #include <stdarg.h>
 
+
+#include <unistd.h>
+
 // CSR lib
 #include "csrLog.h"
 #include "csrOpt.h"
@@ -39,9 +42,7 @@ int main( int argc, char *argv[] )
        
        float padding = 128.f;
        u32 resolution = 1024;
-       int standard_layers = 0;
        int write_txt = 1;
-       int multi_sample = 1;
        char output_path[ 512 ];                // Full path eg. /home/harry/my_map.vmf
        char vmf_name[ 128 ];                   // Just the base name eg. my_map
        int output_set = 0;
@@ -213,6 +214,23 @@ int main( int argc, char *argv[] )
                                        csr_auto_fit( &target, padding );
                                        vmf_load_models( map );
                                }
+                               else
+                               {
+                                       float prog = 0.f;
+                                       csr_prog_begin( "Rendering" );
+                                       for(;;)
+                                       {
+                                               if( prog > 1.f )
+                                                       break;
+                                               
+                                               csr_prog_update( prog );
+                                               usleep( 20000 );
+
+                                               prog += 0.01f;
+                                       }
+
+                                       csr_prog_end();
+                               }
                        }
                        
                        if( write_txt )
index f0735ad84e356a2a29eafe3cd7c025285a4191c7..42b16722aab0ec86279b85119647711c69c2e079 100644 (file)
--- a/csrLog.h
+++ b/csrLog.h
@@ -55,3 +55,37 @@ void csr_log_out( FILE *f, int type, const char* prefix, const char* fmt, ... )
 
 #define log_init log_alloc
 #define log_dealloc log_free
+
+const char *csr_prog_msg;
+void csr_prog_begin( const char *msg )
+{
+       csr_prog_msg = msg;
+}
+
+void csr_prog_update( float const percent )
+{
+       int const k_track_length = 40;
+
+       printf( "\r %s %d%% |", csr_prog_msg, (int)(percent*100.f) );
+       
+       // Calculate how many steps travelled
+       int cur_pos = ((float)k_track_length * (1.f-percent));
+       
+       for( int i = 0; i < cur_pos; i ++ )
+               printf( " " );
+               
+       printf( "🚂🚃🚃🚃🚃" );
+       
+       for( int i = 0; i < k_track_length-cur_pos; i ++ )
+               printf( " " );
+               
+       printf( "|" );
+       
+       fflush( stdout );
+}
+
+void csr_prog_end(void)
+{
+       csr_prog_update( 1.f );
+       printf( "\n" );
+}