Changeset - 95e1ae426eb3
[Not reviewed]
default
0 4 0
Jason Maltzen - 12 months ago 2023-12-07 05:55:08
jason@hiddenachievement.com
Add an info box when a detected clipped reaction could be extrapolated from a white shift.
4 files changed with 21 insertions and 3 deletions:
0 comments (0 inline, 0 general)
Models/ReactionTest.cs
Show inline comments
...
 
@@ -73,24 +73,35 @@ namespace DesertPaintCodex.Models
 
        }
 

	
 
        private ClipType _clipType;
 
        public ClipType Clipped {
 
            get => _clipType;
 
            set
 
            {
 
                _clipType = value;
 
                NotifyPropertyChanged(nameof(Clipped));
 
            }
 
        }
 

	
 
        private bool _whiteShift;
 
        public bool WhiteShift
 
        {
 
            get => _whiteShift;
 
            set
 
            {
 
                _whiteShift = value;
 
                NotifyPropertyChanged(nameof(WhiteShift));
 
            }
 
        }
 

	
 
        public bool IsAllCatalysts { get; }
 

	
 
        private Reaction? _reaction;
 
        public Reaction? Reaction { get => _reaction; set { _reaction = value; NotifyPropertyChanged(nameof(Reaction)); } }
 

	
 
        private Reaction? _badReaction;
 
        public Reaction? BadReaction { get => _badReaction; set { _badReaction = value; NotifyPropertyChanged(nameof(BadReaction)); } }
 

	
 
        private int _scanProgress;
 
        public int ScanProgress { get => _scanProgress; set { _scanProgress = value; NotifyPropertyChanged(nameof(ScanProgress)); } }
 
        
 
        
...
 
@@ -143,31 +154,32 @@ namespace DesertPaintCodex.Models
 

	
 
        private PaintColor? _hypotheticalColor;
 
        public PaintColor? HypotheticalColor { get => _hypotheticalColor; set { _hypotheticalColor = value; NotifyPropertyChanged(nameof(HypotheticalColor)); } }
 

	
 
        private PaintColor? _observedColor;
 
        public PaintColor? ObservedColor { get => _observedColor; set { _observedColor = value; NotifyPropertyChanged(nameof(ObservedColor)); } }
 

	
 
        private readonly PaintRecipe _recipe = new();
 

	
 
        public bool IsStub { get; }
 

	
 

	
 
        public ReactionTest(Reagent reagent1, Reagent reagent2, Reaction? reaction, ClipType clipType, bool isStub = false)
 
        public ReactionTest(Reagent reagent1, Reagent reagent2, Reaction? reaction, ClipType clipType, bool whiteShift, bool isStub = false)
 
        {
 
            Reagent1 = reagent1;
 
            Reagent2 = reagent2;
 
            UseFirstBuffer = true;
 
            IsAllCatalysts = reagent1.IsCatalyst && reagent2.IsCatalyst;
 
            Clipped = clipType;
 
            WhiteShift = whiteShift;
 
            Reaction = reaction;
 
            State = (reaction != null) ? TestState.Saved :
 
                (clipType == ClipType.None) ? TestState.Untested : TestState.ClippedResult;
 
            _recipe.AddReagent(reagent1.Name);
 
            _recipe.AddReagent(reagent2.Name);
 
            IsStub = isStub;
 
            UpdateHypotheticalColor();
 
        }
 

	
 
        
 
        #region Actions
 
        public async Task StartScan()
...
 
@@ -244,24 +256,25 @@ namespace DesertPaintCodex.Models
 
                                if (!extrapolated) extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Green, 0, reaction.Green);
 
                                if (!extrapolated) extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Blue,  0, reaction.Blue);
 
                            }
 
                            else if ((reaction.Red > 0) &&
 
                                (reaction.Green > 0) &&
 
                                (reaction.Blue > 0))
 
                            {
 
                                // White-shift up clip.
 
                                extrapolated                    = ExtrapolateWhiteFromOneChannel(_observedColor.Red,   255, reaction.Red);
 
                                if (!extrapolated) extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Green, 255, reaction.Green);
 
                                if (!extrapolated) extrapolated = ExtrapolateWhiteFromOneChannel(_observedColor.Blue,  255, reaction.Blue);
 
                            }
 
                            WhiteShift = extrapolated;
 
                        }
 

	
 
                        if (!extrapolated)
 
                        {
 
                            State       = TestState.ClippedResult;
 
                            BadReaction = CalculateReaction();
 
                        }
 
                    }
 
                    
 
                    PlayerProfile? profile = ProfileManager.CurrentProfile;
 
                    profile?.SetPairClipStatus(Reagent1, Reagent2, Clipped);
 
                }
Models/ReactionTestService.cs
Show inline comments
...
 
@@ -25,25 +25,25 @@ namespace DesertPaintCodex.Models
 
            
 
            List<string> reagentNames = ReagentService.Names;
 

	
 
            foreach (Reagent reagent1 in reagentNames.Select(ReagentService.GetReagent))
 
            {
 
                foreach (Reagent reagent2 in reagentNames.Select(ReagentService.GetReagent))
 
                {
 
                    if (reagent1 == reagent2) continue;
 

	
 
                    Reaction? reaction = profile.FindReaction(reagent1, reagent2);
 
                    ClipType clipType = profile.PairClipStatus(reagent1, reagent2);
 
                    
 
                    ReactionTest test = new(reagent1, reagent2, reaction, clipType)
 
                    ReactionTest test = new(reagent1, reagent2, reaction, clipType, false)
 
                    {
 
                        Clipped  = clipType,
 
                        Reaction = reaction,
 
                       
 
                    };
 

	
 
                    _allTests.Add(test);
 
                }
 
            }
 
        }
 

	
 
        public static void PopulateRemainingTests(ObservableCollection<ReactionTest> collection)
Util/Constants.cs
Show inline comments
...
 
@@ -12,21 +12,21 @@ namespace DesertPaintCodex.Util
 

	
 
        private static ReactionTest? _stubReactionTest = null;
 

	
 
        public static ReactionTest StubReactionTest
 
        {
 
            get
 
            {
 
                if (_stubReactionTest == null)
 
                {
 
                    _stubReactionTest = new ReactionTest(
 
                        new Reagent("Toad Skin", "ToadSkin", 48, 96, 48, 0), 
 
                        new Reagent("Falcons Bait", "FalconBait", 128, 240, 224, 1), 
 
                        null, ClipType.None, true);
 
                        null, ClipType.None, false, true);
 
                }
 

	
 
                return _stubReactionTest;
 
            }
 
            
 
        }
 
    }
 
}
...
 
\ No newline at end of file
Views/ReactionTestView.axaml
Show inline comments
...
 
@@ -125,24 +125,29 @@
 
                    <TextBlock FontWeight="Bold" FontSize="15">SCREEN SETTINGS</TextBlock>
 
                </Button>
 
            </views:EmbeddedWarningBox>
 
        </StackPanel>
 

	
 
        <StackPanel DockPanel.Dock="Top" Orientation="Vertical" Spacing="5"
 
                    IsVisible="{Binding ReactionTest.HasReaction}">
 
            <TextBlock Classes="BlockHeader">REACTION OBSERVED</TextBlock>
 
            <StackPanel Orientation="Horizontal" Spacing="21" Margin="0 5">
 
                <views:ReactionUnitView Reaction="{Binding ReactionTest.Reaction}"/>
 
            </StackPanel>
 

	
 
          <views:EmbeddedWarningBox Title="🛈 EXTRAPOLATED REACTION"
 
                                    IsVisible="{Binding ReactionTest.WhiteShift}"
 
                                    Message="One component of the reaction clipped, but a value could be extrapolated from the shift in the color components.">
 
          </views:EmbeddedWarningBox>
 

	
 
            <views:EmbeddedWarningBox Title="🛇 REACTION CLIPPED"
 
                                      IsVisible="{Binding !!ReactionTest.Clipped}"
 
                                      Message="Your reaction fell outside of measurable values. We will need to use a buffer pigment to test it.">
 
                <StackPanel Orientation="Vertical" Spacing="10">
 
                    <Button Command="{Binding ShowClipInfo}">LEARN MORE</Button>
 
                </StackPanel>
 
            </views:EmbeddedWarningBox>
 
        </StackPanel>
 
        
 
        <Button IsVisible="{Binding ReactionTest.CanClear}"
 
                Command="{Binding ClearReaction}">Clear Reaction</Button>
 
        <Button IsVisible="{Binding ReactionTest.CanSave}"
0 comments (0 inline, 0 general)