Species info in Guidebook and at chargen (#25844)

* guidebook pages defined

* species info button in character profile editor

* if current species has no guidebook page then open the parent page

* skrek

* destroying evidence of secret vox plot

* icon size adjustment, no icon if guidebook page for species does not exist

* finished pages

* additional info

* weh
This commit is contained in:
Errant
2024-03-11 04:01:32 +01:00
committed by GitHub
parent 8de4b4196e
commit 84a07315dd
16 changed files with 279 additions and 17 deletions

View File

@@ -58,6 +58,7 @@
<BoxContainer HorizontalExpand="True">
<Label Text="{Loc 'humanoid-profile-editor-species-label'}" />
<Control HorizontalExpand="True"/>
<TextureButton Name="SpeciesInfoButton" Scale="0.3 0.3" VerticalAlignment="Center"></TextureButton>
<OptionButton Name="CSpeciesButton" HorizontalAlignment="Right" />
</BoxContainer>
<!-- Age -->

View File

@@ -1,11 +1,13 @@
using System.Linq;
using System.Numerics;
using Content.Client.Guidebook;
using Content.Client.Humanoid;
using Content.Client.Lobby.UI;
using Content.Client.Message;
using Content.Client.Players.PlayTimeTracking;
using Content.Client.Stylesheets;
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Systems.Guidebook;
using Content.Shared.CCVar;
using Content.Shared.GameTicking;
using Content.Shared.Humanoid;
@@ -116,6 +118,8 @@ namespace Content.Client.Preferences.UI
_configurationManager = configurationManager;
_markingManager = IoCManager.Resolve<MarkingManager>();
SpeciesInfoButton.ToolTip = Loc.GetString("humanoid-profile-editor-guidebook-button-tooltip");
#region Left
#region Randomize
@@ -523,10 +527,30 @@ namespace Content.Client.Preferences.UI
preferencesManager.OnServerDataLoaded += LoadServerData;
SpeciesInfoButton.OnPressed += OnSpeciesInfoButtonPressed;
UpdateSpeciesGuidebookIcon();
IsDirty = false;
}
private void OnSpeciesInfoButtonPressed(BaseButton.ButtonEventArgs args)
{
var guidebookController = UserInterfaceManager.GetUIController<GuidebookUIController>();
var species = Profile?.Species ?? SharedHumanoidAppearanceSystem.DefaultSpecies;
var page = "Species";
if (_prototypeManager.HasIndex<GuideEntryPrototype>(species))
page = species;
if (_prototypeManager.TryIndex<GuideEntryPrototype>("Species", out var guideRoot))
{
var dict = new Dictionary<string, GuideEntry>();
dict.Add("Species", guideRoot);
//TODO: Don't close the guidebook if its already open, just go to the correct page
guidebookController.ToggleGuidebook(dict, includeChildren:true, selected: page);
}
}
private void ToggleClothes(BaseButton.ButtonEventArgs obj)
{
RebuildSpriteView();
@@ -790,6 +814,7 @@ namespace Content.Client.Preferences.UI
CMarkings.SetSpecies(newSpecies); // Repopulate the markings tab as well.
UpdateSexControls(); // update sex for new species
RebuildSpriteView(); // they might have different inv so we need a new dummy
UpdateSpeciesGuidebookIcon();
IsDirty = true;
_needUpdatePreview = true;
}
@@ -941,6 +966,25 @@ namespace Content.Client.Preferences.UI
}
public void UpdateSpeciesGuidebookIcon()
{
SpeciesInfoButton.StyleClasses.Clear();
var species = Profile?.Species;
if (species is null)
return;
if (!_prototypeManager.TryIndex<SpeciesPrototype>(species, out var speciesProto))
return;
// Don't display the info button if no guide entry is found
if (!_prototypeManager.HasIndex<GuideEntryPrototype>(species))
return;
var style = speciesProto.GuideBookIcon;
SpeciesInfoButton.StyleClasses.Add(style);
}
private void UpdateMarkings()
{
if (Profile == null)

View File

@@ -1392,6 +1392,14 @@ namespace Content.Client.Stylesheets
.Prop(Control.StylePropertyModulateSelf, Color.FromHex("#753131")),
// ---
// Profile Editor
Element<TextureButton>().Class("SpeciesInfoDefault")
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/Interface/VerbIcons/information.svg.192dpi.png")),
Element<TextureButton>().Class("SpeciesInfoWarning")
.Prop(TextureButton.StylePropertyTexture, resCache.GetTexture("/Textures/Interface/info.svg.192dpi.png"))
.Prop(Control.StylePropertyModulateSelf, Color.FromHex("#eeee11")),
// The default look of paper in UIs. Pages can have components which override this
Element<PanelContainer>().Class("PaperDefaultBorder")
.Prop(PanelContainer.StylePropertyPanel, paperBackground),