@@ -77,6 +77,12 @@ pub(crate) fn impl_mode(tokens: &mut proc_macro2::TokenStream, state: &State, mo
77
77
let mode_blocks = mode. blocks ( ) ;
78
78
let game_blocks = state. receiver . blocks ( ) ;
79
79
80
+ let game_labels = state. receiver . labels ( ) ;
81
+ let game_labels = game_labels
82
+ . iter ( )
83
+ . filter ( |l| l. tr ( ) != "level" )
84
+ . collect :: < Vec < _ > > ( ) ;
85
+
80
86
let diff_log = game_blocks
81
87
. iter ( )
82
88
. chain ( mode_blocks. iter ( ) )
@@ -119,7 +125,7 @@ pub(crate) fn impl_mode(tokens: &mut proc_macro2::TokenStream, state: &State, mo
119
125
quote ! {
120
126
#extra
121
127
122
- field. push_str( #translate:: tr! ( ctx, Self :: tr( ) ) . as_ref( ) ) ;
128
+ field. push_str( #translate:: tr( ctx, Self :: tr( ) ) . as_ref( ) ) ;
123
129
field. push_str( ": **" ) ;
124
130
field. push_str( #v. as_ref( ) ) ;
125
131
field. push_str( "**\n " ) ;
@@ -139,6 +145,20 @@ pub(crate) fn impl_mode(tokens: &mut proc_macro2::TokenStream, state: &State, mo
139
145
f64 :: from( #value)
140
146
} )
141
147
} , b. tr ( ) , b. var_id ( ) ) ) )
148
+ . chain (
149
+ game_labels
150
+ . iter ( )
151
+ . filter_map ( |l| Some ( ( {
152
+ let value = l. value ( Side :: None , Access :: ModeDiff ( mode) ) ?;
153
+
154
+ quote ! ( {
155
+ let stats = & data. stats. #path_to_game. #id;
156
+ let game = & data. stats. #path_to_game;
157
+
158
+ f64 :: from( #value)
159
+ } )
160
+ } , l. tr ( ) , l. var_id ( ) ) ) )
161
+ )
142
162
. chain ( std:: iter:: once ( (
143
163
quote ! ( {
144
164
let stats = & data. stats. #path_to_game. #id;
@@ -181,7 +201,7 @@ pub(crate) fn impl_mode(tokens: &mut proc_macro2::TokenStream, state: &State, mo
181
201
let mut buffer = #api:: canvas:: project:: f64 :: create(
182
202
ctx,
183
203
:: std:: vec![ (
184
- #translate:: tr! ( ctx, #tr) ,
204
+ #translate:: tr( ctx, #tr) ,
185
205
snapshots
186
206
. iter( )
187
207
. map( |( time, data) | ( * time, #value) )
@@ -190,13 +210,7 @@ pub(crate) fn impl_mode(tokens: &mut proc_macro2::TokenStream, state: &State, mo
190
210
predict_y,
191
211
) ] ,
192
212
first. 0 ..predict_x. map_or( last. 0 , |x| x. max( last. 0 ) ) ,
193
- ( {
194
- let data = & first. 1 ;
195
- #value
196
- } * ( 7. / 8. ) ) ..( predict_y. max( {
197
- let data = & last. 1 ;
198
- #value
199
- } ) * ( 8. / 7. ) ) ,
213
+ ( low * ( 7. / 8. ) ) ..( predict_y. max( high) * ( 8. / 7. ) ) ,
200
214
None ,
201
215
background,
202
216
) ?;
@@ -211,7 +225,7 @@ pub(crate) fn impl_mode(tokens: &mut proc_macro2::TokenStream, state: &State, mo
211
225
#api:: canvas:: project:: apply_bubbles(
212
226
& mut surface,
213
227
ctx,
214
- #translate:: tr! ( ctx, #tr) . as_ref( ) ,
228
+ #translate:: tr( ctx, #tr) . as_ref( ) ,
215
229
& predict_y,
216
230
& r,
217
231
& x,
@@ -221,10 +235,10 @@ pub(crate) fn impl_mode(tokens: &mut proc_macro2::TokenStream, state: &State, mo
221
235
#api:: canvas:: project:: apply_bubbles(
222
236
& mut surface,
223
237
ctx,
224
- #translate:: tr! ( ctx, #tr) . as_ref( ) ,
238
+ #translate:: tr( ctx, #tr) . as_ref( ) ,
225
239
& predict_y,
226
240
& r,
227
- & #translate:: tr! ( ctx, "never" ) . as_ref( ) ,
241
+ & #translate:: tr( ctx, "never" ) . as_ref( ) ,
228
242
background,
229
243
) ;
230
244
}
@@ -283,7 +297,7 @@ pub(crate) fn impl_mode(tokens: &mut proc_macro2::TokenStream, state: &State, mo
283
297
284
298
title. push_str( PLAIN ) ;
285
299
title. push( ' ' ) ;
286
- title. push_str( #translate:: tr! ( ctx, Self :: tr( ) ) . as_ref( ) ) ;
300
+ title. push_str( #translate:: tr( ctx, Self :: tr( ) ) . as_ref( ) ) ;
287
301
288
302
embed. fields. push( #poise:: serenity_prelude:: EmbedField :: new( title, log, true ) ) ;
289
303
embed
@@ -311,7 +325,7 @@ pub(crate) fn impl_mode(tokens: &mut proc_macro2::TokenStream, state: &State, mo
311
325
312
326
#( #embed) *
313
327
314
- embed. field( #translate:: tr! ( ctx, Self :: tr( ) ) , field, true )
328
+ embed. field( #translate:: tr( ctx, Self :: tr( ) ) , field, true )
315
329
}
316
330
317
331
pub fn embed_diff(
@@ -328,7 +342,7 @@ pub(crate) fn impl_mode(tokens: &mut proc_macro2::TokenStream, state: &State, mo
328
342
329
343
#( #embed_diff) *
330
344
331
- embed. field( #translate:: tr! ( ctx, Self :: tr( ) ) , field, true )
345
+ embed. field( #translate:: tr( ctx, Self :: tr( ) ) , field, true )
332
346
}
333
347
334
348
pub fn project(
@@ -355,11 +369,17 @@ pub(crate) fn impl_mode(tokens: &mut proc_macro2::TokenStream, state: &State, mo
355
369
let first = snapshots. first( ) . unwrap( ) ;
356
370
let last = snapshots. last( ) . unwrap( ) ;
357
371
358
- let lower = Self :: min_fields( & first. 1 . stats. #path_to_game. #id, & first. 1 ) ;
359
- let upper = :: std:: cmp:: max( Self :: max_fields( & last. 1 . stats. #path_to_game. #id, & last. 1 ) , 100 ) ;
372
+ let mut lower = Self :: min_fields( & first. 1 . stats. #path_to_game. #id, & first. 1 ) ;
373
+ let mut upper = :: std:: cmp:: max( Self :: max_fields( & first. 1 . stats. #path_to_game. #id, & first. 1 ) , 100 ) ;
374
+
375
+ for ( _, data) in snapshots. iter( ) . skip( 1 ) {
376
+ let stats = & data. stats. #path_to_game. #id;
377
+
378
+ lower = lower. min( Self :: min_fields( stats, data) ) ;
379
+ upper = upper. max( Self :: max_fields( stats, data) ) ;
380
+ }
360
381
361
382
let x_range = first. 0 . clone( ) ..last. 0 . clone( ) ;
362
- let last_data = last. 1 . clone( ) ;
363
383
364
384
let v = :: std:: vec![
365
385
#( #chart, ) *
@@ -376,7 +396,7 @@ pub(crate) fn impl_mode(tokens: &mut proc_macro2::TokenStream, state: &State, mo
376
396
377
397
let mut surface = #api:: canvas:: chart:: canvas( & mut buffer) ?;
378
398
379
- #api:: canvas:: chart:: apply_title( ctx, & mut surface, & last_data , & LABEL , background) ;
399
+ #api:: canvas:: chart:: apply_title( ctx, & mut surface, & last . 1 , & LABEL , background) ;
380
400
#api:: canvas:: chart:: round_corners( & mut surface) ;
381
401
382
402
Ok ( #api:: canvas:: to_png( & mut surface) )
0 commit comments