@@ -8,6 +8,8 @@ pub struct LeagueApp {
88 pub histories : Arc < RwLock < Vec < GameHistoryQuery > > > ,
99 pub filtered_histories : Arc < RwLock < Vec < GameHistoryQuery > > > ,
1010 pub is_classic_mode : bool ,
11+ pub max_game_count : u32 ,
12+ pub display_size : u32 ,
1113}
1214
1315/// functional implement block
@@ -19,6 +21,8 @@ impl LeagueApp {
1921 histories : Arc :: new ( RwLock :: new ( vec ! [ ] ) ) ,
2022 filtered_histories : Arc :: new ( RwLock :: new ( vec ! [ ] ) ) ,
2123 is_classic_mode : false ,
24+ max_game_count : 20 ,
25+ display_size : 5 ,
2226 }
2327 }
2428
@@ -28,11 +32,12 @@ impl LeagueApp {
2832 let histories_task = self . histories . clone ( ) ;
2933 let filtered_histories_task = self . filtered_histories . clone ( ) ;
3034 let lcu_task = self . lcu_client . clone ( ) ;
35+ let game_count = self . max_game_count ;
3136 rt. block_on ( async move {
3237 let mut histories = histories_task. write ( ) ;
3338 let mut filtered_history = filtered_histories_task. write ( ) ;
3439
35- let expect_history = lcu_task. read ( ) . get_summoner_match_histories ( ) . await . unwrap ( ) ;
40+ let expect_history = lcu_task. read ( ) . get_summoner_match_histories ( game_count ) . await . unwrap ( ) ;
3641
3742 if expect_history. is_empty ( ) {
3843 log:: debug!( "No match history found currently" ) ;
@@ -70,8 +75,9 @@ impl eframe::App for LeagueApp {
7075 egui_extras:: install_image_loaders ( ctx) ;
7176 CentralPanel :: default ( ) . show ( ctx, |ui| {
7277 self . render_header_options ( ui) ;
73- self . render_match_history ( ui) ;
74-
78+ egui:: ScrollArea :: vertical ( ) . show ( ui, |ui| {
79+ self . render_match_history ( ui) ;
80+ } ) ;
7581 } ) ;
7682
7783 }
@@ -81,24 +87,26 @@ impl eframe::App for LeagueApp {
8187impl LeagueApp {
8288 pub fn render_header_options ( & mut self , ui : & mut egui:: Ui ) {
8389 ui. horizontal ( |ui| {
84- if ui. button ( "Refresh Match History " ) . highlight ( ) . clicked ( ) {
90+ if ui. button ( "Refresh" ) . highlight ( ) . clicked ( ) {
8591 self . fetch_match_history ( ) . unwrap ( ) ;
8692
8793 self . filter_by_mode ( ) ;
8894 }
8995
90- ui. checkbox ( & mut self . is_classic_mode , "Filter Classic Mode" ) ;
96+ ui. checkbox ( & mut self . is_classic_mode , "Classic Mode" ) ;
9197 ui. separator ( ) ;
98+
99+ ui. add ( egui:: Slider :: new ( & mut self . display_size , 1 ..=self . max_game_count ) . text ( "Display Count" ) ) ;
92100 } ) ;
93101 }
94102
95103 pub fn render_match_history ( & self , ui : & mut egui:: Ui ) {
96104 ui. horizontal ( |ui| {
97105 if self . is_classic_mode {
98- Self :: render_game_history ( ui, & self . filtered_histories ) ;
106+ self . render_game_history ( ui, & self . filtered_histories ) ;
99107 return ;
100108 }
101- Self :: render_game_history ( ui, & self . histories ) ;
109+ self . render_game_history ( ui, & self . histories ) ;
102110 } ) ;
103111
104112 }
@@ -168,6 +176,7 @@ impl LeagueApp {
168176 ui. add ( Image :: new ( spell2_url) . fit_to_exact_size ( Vec2 :: new ( 15. , 15. ) ) ) ;
169177 } ) ;
170178 } ) ;
179+ ui. label ( egui:: RichText :: new ( game. get_date ( ) ) ) ;
171180 ui. label ( egui:: RichText :: new ( game. get_kda_result ( ) ) . color ( egui:: Color32 :: DARK_BLUE ) ) ;
172181 if game. get_win_status ( ) {
173182 ui. label ( egui:: RichText :: new ( "Win" ) . color ( egui:: Color32 :: GREEN ) ) ;
@@ -177,7 +186,7 @@ impl LeagueApp {
177186 } ) ;
178187 }
179188
180- fn render_game_history ( ui : & mut egui:: Ui , histories : & Arc < RwLock < Vec < GameHistoryQuery > > > ) {
189+ fn render_game_history ( & self , ui : & mut egui:: Ui , histories : & Arc < RwLock < Vec < GameHistoryQuery > > > ) {
181190 ui. horizontal ( |ui| {
182191 static PADDING : f32 = 4. ;
183192 for ( slot, history) in histories. read ( ) . iter ( ) . enumerate ( ) {
@@ -192,7 +201,7 @@ impl LeagueApp {
192201 ui. add_space ( PADDING ) ;
193202
194203 for ( index, game) in games. iter ( ) . enumerate ( ) {
195- if index == 5 {
204+ if index == self . display_size as usize {
196205 break ;
197206 }
198207 Self :: render_game ( ui, game) ;
0 commit comments