2626using osu . Game . Rulesets . Difficulty ;
2727using osu . Game . Rulesets . Scoring ;
2828using osu . Game . Rulesets . UI ;
29- using osu . Game . Utils ;
3029using osu . Game . Users . Drawables ;
30+ using osu . Game . Utils ;
3131using osuTK ;
3232using osuTK . Graphics ;
3333using PerformanceCalculatorGUI . Components . TextBoxes ;
@@ -372,39 +372,7 @@ private void load(GameHost host, RulesetStore rulesets)
372372 Shear = new Vector2 ( performance_background_shear , 0 ) ,
373373 EdgeSmoothness = new Vector2 ( 2 , 0 ) ,
374374 } ,
375- new FillFlowContainer
376- {
377- AutoSizeAxes = Axes . Both ,
378- Padding = new MarginPadding
379- {
380- Vertical = 5 ,
381- Left = 30 ,
382- Right = 20
383- } ,
384- Anchor = Anchor . Centre ,
385- Origin = Anchor . Centre ,
386- Direction = FillDirection . Vertical ,
387- Children = new Drawable [ ]
388- {
389- new ExtendedOsuSpriteText
390- {
391- Font = OsuFont . GetFont ( weight : FontWeight . Bold ) ,
392- Text = $ "{ Score . PerformanceAttributes ? . Total : 0} pp",
393- Colour = colourProvider . Highlight1 ,
394- Anchor = Anchor . TopCentre ,
395- Origin = Anchor . TopCentre ,
396- TooltipContent = $ "{ AttributeConversion . ToReadableString ( Score . PerformanceAttributes ) } "
397- } ,
398- new OsuSpriteText
399- {
400- Font = OsuFont . GetFont ( size : small_text_font_size ) ,
401- Text = $ "{ Score . PerformanceAttributes ? . Total - Score . LivePP : +0.0;-0.0;-} ",
402- Colour = getPpDifferenceColor ( ) ,
403- Anchor = Anchor . TopCentre ,
404- Origin = Anchor . TopCentre
405- }
406- }
407- }
375+ new ScorePerformanceContainer ( Score )
408376 }
409377 }
410378 }
@@ -413,19 +381,6 @@ private void load(GameHost host, RulesetStore rulesets)
413381 Score . PositionChange . BindValueChanged ( v => { positionChangeText . Text = $ "{ v . NewValue : +0;-0;-} "; } ) ;
414382 }
415383
416- private Color4 getPpDifferenceColor ( )
417- {
418- double difference = Score . PerformanceAttributes ? . Total - Score . LivePP ?? 0 ;
419- var baseColor = colourProvider . Light1 ;
420-
421- return difference switch
422- {
423- < 0 => Interpolation . ValueAt ( difference , baseColor , Color4 . OrangeRed , 0 , - 200 ) ,
424- > 0 => Interpolation . ValueAt ( difference , baseColor , Color4 . Lime , 0 , 200 ) ,
425- _ => baseColor
426- } ;
427- }
428-
429384 private OsuSpriteText formatCombo ( )
430385 {
431386 bool isFullCombo = Score . SoloScore . MaxCombo == Score . DifficultyAttributes . MaxCombo ;
@@ -513,5 +468,75 @@ private void load(GameHost host)
513468 } ;
514469 }
515470 }
471+
472+ private partial class ScorePerformanceContainer : OsuHoverContainer
473+ {
474+ private readonly ExtendedScore score ;
475+
476+ [ Resolved ]
477+ private OverlayColourProvider colourProvider { get ; set ; } = null ! ;
478+
479+ public ScorePerformanceContainer ( ExtendedScore score )
480+ {
481+ this . score = score ;
482+ RelativeSizeAxes = Axes . Both ;
483+ Padding = new MarginPadding
484+ {
485+ Vertical = 5 ,
486+ Left = 30 ,
487+ Right = 20
488+ } ;
489+ }
490+
491+ [ BackgroundDependencyLoader ( true ) ]
492+ private void load ( PerformanceCalculatorSceneManager sceneManager )
493+ {
494+ Action = ( ) =>
495+ {
496+ sceneManager . SwitchToSimulate ( score . SoloScore . BeatmapID , score . SoloScore . ID ) ;
497+ } ;
498+
499+ Child = new FillFlowContainer
500+ {
501+ AutoSizeAxes = Axes . Both ,
502+ Anchor = Anchor . Centre ,
503+ Origin = Anchor . Centre ,
504+ Direction = FillDirection . Vertical ,
505+ Children = new Drawable [ ]
506+ {
507+ new ExtendedOsuSpriteText
508+ {
509+ Font = OsuFont . GetFont ( weight : FontWeight . Bold ) ,
510+ Text = $ "{ score . PerformanceAttributes ? . Total : 0} pp",
511+ Colour = colourProvider . Highlight1 ,
512+ Anchor = Anchor . TopCentre ,
513+ Origin = Anchor . TopCentre ,
514+ TooltipContent = $ "{ AttributeConversion . ToReadableString ( score . PerformanceAttributes ) } "
515+ } ,
516+ new OsuSpriteText
517+ {
518+ Font = OsuFont . GetFont ( size : small_text_font_size ) ,
519+ Text = $ "{ score . PerformanceAttributes ? . Total - score . LivePP : +0.0;-0.0;-} ",
520+ Colour = getPpDifferenceColor ( ) ,
521+ Anchor = Anchor . TopCentre ,
522+ Origin = Anchor . TopCentre
523+ }
524+ }
525+ } ;
526+ }
527+
528+ private Color4 getPpDifferenceColor ( )
529+ {
530+ double difference = score . PerformanceAttributes ? . Total - score . LivePP ?? 0 ;
531+ var baseColor = colourProvider . Light1 ;
532+
533+ return difference switch
534+ {
535+ < 0 => Interpolation . ValueAt ( difference , baseColor , Color4 . OrangeRed , 0 , - 200 ) ,
536+ > 0 => Interpolation . ValueAt ( difference , baseColor , Color4 . Lime , 0 , 200 ) ,
537+ _ => baseColor
538+ } ;
539+ }
540+ }
516541 }
517542}
0 commit comments