<Collapsible Orientation="Vertical" HorizontalExpand="True">
<CollapsibleHeading Title="{Loc 'guidebook-reagent-recipes-header'}"/>
<CollapsibleBody>
- <BoxContainer Name="RecipesDescriptionContainer"
+ <GridContainer Name="RecipesDescriptionContainer"
Margin="10 0 10 0"
- Orientation="Horizontal"
+ Columns="1"
+ HSeparationOverride="5"
HorizontalAlignment="Stretch"
- HorizontalExpand="True">
- <BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalAlignment="Center">
- <RichTextLabel Name="ReactantsLabel"
- HorizontalAlignment="Center"
- VerticalAlignment="Center"/>
- </BoxContainer>
- <BoxContainer Orientation="Vertical" VerticalAlignment="Center">
- <TextureRect TexturePath="/Textures/Interface/Misc/beakerlarge.png"
- HorizontalAlignment="Center"/>
- <Label Name="MixLabel"
- Text="{Loc 'guidebook-reagent-recipes-mix'}"
- HorizontalAlignment="Center"/>
- </BoxContainer>
- <BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalAlignment="Center">
- <RichTextLabel Name="ProductsLabel"
- HorizontalAlignment="Center"
- VerticalAlignment="Center"/>
- </BoxContainer>
- </BoxContainer>
+ HorizontalExpand="True"/>
</CollapsibleBody>
</Collapsible>
</BoxContainer>
BackgroundColor = reagent.SubstanceColor
};
- var textColor = Color.ToHsl(reagent.SubstanceColor).Z > 0.45
+ var r = reagent.SubstanceColor.R;
+ var g = reagent.SubstanceColor.G;
+ var b = reagent.SubstanceColor.B;
+
+ var textColor = 0.2126f * r + 0.7152f * g + 0.0722f * b > 0.5
? Color.Black
: Color.White;
("color", textColor), ("name", reagent.LocalizedName)));
#region Recipe
- // by default, we assume that the reaction has the same ID as the reagent.
- // if this isn't true, we'll loop through reactions.
- if (!_prototype.TryIndex<ReactionPrototype>(reagent.ID, out var reactionPrototype))
- {
- reactionPrototype = _prototype.EnumeratePrototypes<ReactionPrototype>()
- .FirstOrDefault(p => p.Products.ContainsKey(reagent.ID));
- }
+ var reactions = _prototype.EnumeratePrototypes<ReactionPrototype>()
+ .Where(p => p.Products.ContainsKey(reagent.ID))
+ .OrderBy(p => p.Priority)
+ .ThenBy(p => p.Products.Count)
+ .ToList();
- if (reactionPrototype != null)
+ if (reactions.Any())
{
- var reactantMsg = new FormattedMessage();
- var reactantsCount = reactionPrototype.Reactants.Count;
- var i = 0;
- foreach (var (product, reactant) in reactionPrototype.Reactants)
- {
- reactantMsg.AddMarkup(Loc.GetString("guidebook-reagent-recipes-reagent-display",
- ("reagent", _prototype.Index<ReagentPrototype>(product).LocalizedName), ("ratio", reactant.Amount)));
- i++;
- if (i < reactantsCount)
- reactantMsg.PushNewline();
- }
- reactantMsg.Pop();
- ReactantsLabel.SetMessage(reactantMsg);
-
- if (reactionPrototype.MinimumTemperature > 0.0f)
+ foreach (var reactionPrototype in reactions)
{
- MixLabel.Text = Loc.GetString("guidebook-reagent-recipes-mix-and-heat",
- ("temperature", reactionPrototype.MinimumTemperature));
+ var ctrl = GetRecipeGuide(reactionPrototype);
+ RecipesDescriptionContainer.AddChild(ctrl);
}
-
- var productMsg = new FormattedMessage();
- var productCount = reactionPrototype.Products.Count;
- var u = 0;
- foreach (var (product, ratio) in reactionPrototype.Products)
- {
- productMsg.AddMarkup(Loc.GetString("guidebook-reagent-recipes-reagent-display",
- ("reagent", _prototype.Index<ReagentPrototype>(product).LocalizedName), ("ratio", ratio)));
- u++;
- if (u < productCount)
- productMsg.PushNewline();
- }
- productMsg.Pop();
- ProductsLabel.SetMessage(productMsg);
}
else
{
FormattedMessage description = new();
description.AddText(reagent.LocalizedDescription);
description.PushNewline();
- description.AddText(Loc.GetString("guidebook-reagent-physical-description",
+ description.AddMarkup(Loc.GetString("guidebook-reagent-physical-description",
("description", reagent.LocalizedPhysicalDescription)));
ReagentDescription.SetMessage(description);
}
+
+ private GuideReagentReaction GetRecipeGuide(ReactionPrototype reactionPrototype)
+ {
+ var control = new GuideReagentReaction();
+
+ var reactantMsg = new FormattedMessage();
+ var reactantsCount = reactionPrototype.Reactants.Count;
+ var i = 0;
+ foreach (var (product, reactant) in reactionPrototype.Reactants)
+ {
+ reactantMsg.AddMarkup(Loc.GetString("guidebook-reagent-recipes-reagent-display",
+ ("reagent", _prototype.Index<ReagentPrototype>(product).LocalizedName), ("ratio", reactant.Amount)));
+ i++;
+ if (i < reactantsCount)
+ reactantMsg.PushNewline();
+ }
+ reactantMsg.Pop();
+ control.ReactantsLabel.SetMessage(reactantMsg);
+
+ if (reactionPrototype.MinimumTemperature > 0.0f)
+ {
+ control.MixLabel.Text = Loc.GetString("guidebook-reagent-recipes-mix-and-heat",
+ ("temperature", reactionPrototype.MinimumTemperature));
+ }
+
+ var productMsg = new FormattedMessage();
+ var productCount = reactionPrototype.Products.Count;
+ var u = 0;
+ foreach (var (product, ratio) in reactionPrototype.Products)
+ {
+ productMsg.AddMarkup(Loc.GetString("guidebook-reagent-recipes-reagent-display",
+ ("reagent", _prototype.Index<ReagentPrototype>(product).LocalizedName), ("ratio", ratio)));
+ u++;
+ if (u < productCount)
+ productMsg.PushNewline();
+ }
+ productMsg.Pop();
+ control.ProductsLabel.SetMessage(productMsg);
+ return control;
+ }
}
--- /dev/null
+<BoxContainer xmlns="https://spacestation14.io"
+ Orientation="Horizontal"
+ HorizontalAlignment="Stretch"
+ HorizontalExpand="True">
+ <BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalAlignment="Center">
+ <RichTextLabel Name="ReactantsLabel"
+ HorizontalAlignment="Center"
+ VerticalAlignment="Center"
+ Access="Public"/>
+ </BoxContainer>
+ <BoxContainer Orientation="Vertical" VerticalAlignment="Center">
+ <TextureRect TexturePath="/Textures/Interface/Misc/beakerlarge.png"
+ HorizontalAlignment="Center"/>
+ <Label Name="MixLabel"
+ Text="{Loc 'guidebook-reagent-recipes-mix'}"
+ HorizontalAlignment="Center"
+ Access="Public"/>
+ </BoxContainer>
+ <BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalAlignment="Center">
+ <RichTextLabel Name="ProductsLabel"
+ HorizontalAlignment="Center"
+ VerticalAlignment="Center"
+ Access="Public"/>
+ </BoxContainer>
+</BoxContainer>