1+ use chat:: format_chat_messages;
12use coldmaps:: * ;
23
4+ mod chat;
35mod demo_player;
46mod demostf;
57mod gui_filters;
@@ -25,16 +27,20 @@ const ICONS: Font = Font::External {
2527 bytes : include_bytes ! ( "../fonts/icons.ttf" ) ,
2628} ;
2729
28- fn icon ( unicode : char ) -> Text {
30+ fn icon ( unicode : char , color : [ f32 ; 3 ] ) -> Text {
2931 Text :: new ( & unicode. to_string ( ) )
3032 . font ( ICONS )
31- . color ( [ 1.0 , 0.0 , 0.0 ] )
33+ . color ( color )
3234 . horizontal_alignment ( alignment:: Horizontal :: Center )
3335 . size ( 20 )
3436}
3537
3638fn delete_icon ( ) -> Text {
37- icon ( '\u{F1F8}' )
39+ icon ( '\u{F1F8}' , [ 1.0 , 0.0 , 0.0 ] )
40+ }
41+
42+ fn chat_preview_icon ( ) -> Text {
43+ icon ( '\u{E802}' , [ 1.0 , 1.0 , 1.0 ] )
3844}
3945
4046pub fn main ( ) -> Result < ( ) , iced:: Error > {
@@ -79,6 +85,7 @@ struct DemoFile {
7985 _path : PathBuf ,
8086 file_name : String ,
8187 delete_button : button:: State ,
88+ chat_preview_button : button:: State ,
8289 heatmap_analysis : HeatmapAnalysis ,
8390}
8491
@@ -87,6 +94,7 @@ enum Message {
8794 WindowEventOccurred ( iced_native:: Event ) ,
8895 PaneResized ( pane_grid:: ResizeEvent ) ,
8996 DemoRemoved ( usize ) ,
97+ ChatPreview ( usize ) ,
9098 ThemeChanged ( style:: Theme ) ,
9199 CoordsTypeChanged ( CoordsType ) ,
92100 HeatmapTypeChanged ( HeatmapType ) ,
@@ -172,7 +180,14 @@ impl DemoList {
172180 . enumerate ( )
173181 . fold ( Column :: new ( ) . spacing ( 10 ) , |column, ( index, demo) | {
174182 let delete_button = Button :: new ( & mut demo. delete_button , delete_icon ( ) ) . style ( theme) . on_press ( Message :: DemoRemoved ( index) ) ;
175- let row = Row :: new ( ) . push ( delete_button) . push ( Text :: new ( & demo. file_name ) . size ( 20 ) ) ;
183+ let chat_preview_button = Button :: new ( & mut demo. chat_preview_button , chat_preview_icon ( ) )
184+ . style ( theme)
185+ . on_press ( Message :: ChatPreview ( index) ) ;
186+ let row = Row :: new ( )
187+ . spacing ( 2 )
188+ . push ( delete_button)
189+ . push ( chat_preview_button)
190+ . push ( Text :: new ( & demo. file_name ) . size ( 20 ) ) ;
176191 column. push ( row)
177192 } )
178193 . into ( ) ,
@@ -408,6 +423,7 @@ impl LogPane {
408423 }
409424
410425 fn log ( & mut self , message : & str ) {
426+ println ! ( "{}" , message) ;
411427 self . log . push_str ( message) ;
412428 self . log . push ( '\n' ) ;
413429 // TODO replace this by a cleaner way to scroll down once possible
@@ -546,6 +562,19 @@ impl Application for App {
546562 self . show_stats ( ) ;
547563 self . try_generate_heatmap ( ) ;
548564 }
565+ Message :: ChatPreview ( index) => {
566+ let demo_list = self . get_demo_list_pane_mut ( ) ;
567+ let demo = & demo_list. demo_files [ index] ;
568+ let messages = format_chat_messages ( & demo. heatmap_analysis ) ;
569+ let header_message = format ! ( "Chat log of {}:" , demo. file_name) ;
570+ self . log ( "" ) ;
571+ self . log ( & header_message) ;
572+ self . log ( "======================" ) ;
573+ for message in messages {
574+ self . log ( & message) ;
575+ }
576+ self . log ( "======================" ) ;
577+ }
549578 Message :: ThemeChanged ( theme) => {
550579 self . theme = theme;
551580 self . get_demo_list_pane_mut ( ) . theme = theme;
@@ -634,6 +663,7 @@ impl Application for App {
634663 file_name,
635664 heatmap_analysis,
636665 delete_button : Default :: default ( ) ,
666+ chat_preview_button : Default :: default ( ) ,
637667 } ;
638668 demo_list. demo_files . push ( demo_file) ;
639669 }
0 commit comments