-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
904 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<controls:FancyWindow xmlns="https://spacestation14.io" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" | ||
SetSize="800 800" | ||
MinSize="800 128" | ||
Resizable="False"> | ||
<BoxContainer Orientation="Horizontal" VerticalExpand="True"> | ||
<ScrollContainer HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="False" Margin="5"> | ||
<PanelContainer VerticalExpand="True" HorizontalExpand="True"> | ||
<PanelContainer.PanelOverride> | ||
<graphics:StyleBoxFlat BackgroundColor="#1B1B1E" /> | ||
</PanelContainer.PanelOverride> | ||
<BoxContainer Name="SpeciesContainer" VerticalExpand="True" HorizontalExpand="True" Orientation="Vertical"/> | ||
</PanelContainer> | ||
</ScrollContainer> | ||
<BoxContainer Name="InfoContainer" Orientation="Vertical" VerticalExpand="True" Margin="5"> | ||
<BoxContainer Name="Showcase" Orientation="Horizontal" VerticalAlignment="Top"> | ||
<PanelContainer SetSize="200 200" MaxSize="200 200" VerticalAlignment="Top" Margin="5"> | ||
<PanelContainer.PanelOverride> | ||
<graphics:StyleBoxFlat BackgroundColor="#1B1B1E" /> | ||
</PanelContainer.PanelOverride> | ||
<SpriteView Name="Mob" Scale="4 4"/> | ||
</PanelContainer> | ||
<PanelContainer SetSize="200 200" MaxSize="200 200" VerticalAlignment="Top" Margin="5"> | ||
<PanelContainer.PanelOverride> | ||
<graphics:StyleBoxFlat BackgroundColor="#1B1B1E" /> | ||
</PanelContainer.PanelOverride> | ||
<SpriteView Name="JobLoadout" Scale="4 4"/> | ||
</PanelContainer> | ||
</BoxContainer> | ||
<Button Name="Select" Text="{ Loc 'ui-species-select-button' }" SetWidth="410" MinWidth="410"/> | ||
<ScrollContainer HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="False" Margin="5"> | ||
<PanelContainer VerticalExpand="True" HorizontalExpand="True"> | ||
<PanelContainer.PanelOverride> | ||
<graphics:StyleBoxFlat BackgroundColor="#1B1B1E" /> | ||
</PanelContainer.PanelOverride> | ||
<BoxContainer Name="DetailInfoContainer" VerticalExpand="True" MaxWidth="380" Orientation="Vertical"> | ||
|
||
</BoxContainer> | ||
</PanelContainer> | ||
</ScrollContainer> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</controls:FancyWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,273 @@ | ||
using System.Linq; | ||
using Content.Client.Administration.UI.CustomControls; | ||
using Content.Client.Guidebook; | ||
using Content.Client.Lobby; | ||
using Content.Client.Stylesheets; | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared.Humanoid; | ||
using Content.Shared.Humanoid.Prototypes; | ||
using Content.Shared.Preferences; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.ContentPack; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Client.ADT.Lobby.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class SpeciesWindow : FancyWindow | ||
{ | ||
public event Action<ProtoId<SpeciesPrototype>>? ChooseAction; | ||
public ProtoId<SpeciesPrototype> CurrentSpecies; | ||
|
||
public HumanoidCharacterProfile Profile; | ||
private readonly IEntityManager _entityManager; | ||
private readonly IPrototypeManager _proto; | ||
private readonly LobbyUIController _uIController; | ||
private readonly IResourceManager _resMan; | ||
[Dependency] private readonly DocumentParsingManager _parsingMan = default!; | ||
|
||
public SpeciesWindow(HumanoidCharacterProfile profile, | ||
IPrototypeManager proto, | ||
IEntityManager entMan, | ||
LobbyUIController uIController, | ||
IResourceManager resManager, | ||
DocumentParsingManager parsing) | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
|
||
Title = Loc.GetString("species-window-title"); | ||
|
||
Profile = profile; | ||
_entityManager = entMan; | ||
_proto = proto; | ||
_uIController = uIController; | ||
_resMan = resManager; | ||
|
||
var protoList = _proto.EnumeratePrototypes<SpeciesPrototype>().Where(x => x.RoundStart).ToList(); | ||
protoList.Sort((x, y) => Loc.GetString(x.Name)[0].CompareTo(Loc.GetString(y.Name)[0])); | ||
|
||
AddLabel("Классические"); | ||
foreach (var item in protoList.Where(x => x.Category == SpeciesCategory.Classic)) | ||
{ | ||
var button = new SpeciesButton(item) | ||
{ | ||
HorizontalExpand = true, | ||
ToggleMode = true, | ||
Pressed = Profile.Species == item.ID, | ||
Text = Loc.GetString(item.Name), | ||
Margin = new Thickness(5f, 5f), | ||
}; | ||
button.OnToggled += args => SelectSpecies(item.ID); | ||
SpeciesContainer.AddChild(button); | ||
} | ||
|
||
AddLabel("Нестандартные"); | ||
foreach (var item in protoList.Where(x => x.Category == SpeciesCategory.Unusual)) | ||
{ | ||
var button = new SpeciesButton(item) | ||
{ | ||
HorizontalExpand = true, | ||
ToggleMode = true, | ||
Pressed = Profile.Species == item.ID, | ||
Text = Loc.GetString(item.Name), | ||
Margin = new Thickness(5f, 5f), | ||
}; | ||
button.OnToggled += args => SelectSpecies(item.ID); | ||
SpeciesContainer.AddChild(button); | ||
} | ||
|
||
AddLabel("Особые"); | ||
foreach (var item in protoList.Where(x => x.Category == SpeciesCategory.Special)) | ||
{ | ||
var button = new SpeciesButton(item) | ||
{ | ||
HorizontalExpand = true, | ||
ToggleMode = true, | ||
Pressed = Profile.Species == item.ID, | ||
Text = Loc.GetString(item.Name), | ||
Margin = new Thickness(5f, 5f), | ||
}; | ||
button.OnToggled += args => SelectSpecies(item.ID); | ||
SpeciesContainer.AddChild(button); | ||
} | ||
|
||
CurrentSpecies = Profile.Species; | ||
SelectSpecies(Profile.Species); | ||
} | ||
private void AddLabel(string text) | ||
{ | ||
var container = new BoxContainer() | ||
{ | ||
Orientation = BoxContainer.LayoutOrientation.Vertical, | ||
Margin = new Thickness(5f, 5f), | ||
}; | ||
var label = new Label() | ||
{ | ||
Text = text, | ||
StyleClasses = { StyleBase.ClassLowDivider }, | ||
Margin = new(2f, 2f), | ||
}; | ||
var separator = new HSeparator() | ||
{ | ||
Margin = new(2f, 2f, 2f, 4f), | ||
}; | ||
container.AddChild(label); | ||
container.AddChild(separator); | ||
|
||
SpeciesContainer.AddChild(container); | ||
} | ||
|
||
public void SelectSpecies(ProtoId<SpeciesPrototype> protoId) | ||
{ | ||
DetailInfoContainer.DisposeAllChildren(); | ||
|
||
foreach (var item in SpeciesContainer.Children) | ||
{ | ||
if (item is not SpeciesButton button) | ||
continue; | ||
button.Pressed = protoId == button.Proto; | ||
} | ||
|
||
var proto = _proto.Index(protoId); | ||
var job = Profile.JobPriorities.Where(x => x.Value == JobPriority.High).First().Key; | ||
CurrentSpecies = protoId; | ||
|
||
var previewProfile = Profile; | ||
previewProfile = previewProfile.WithSpecies(protoId); | ||
|
||
var skin = proto.SkinColoration; | ||
switch (skin) | ||
{ | ||
case HumanoidSkinColor.HumanToned: | ||
{ | ||
var tone = SkinColor.HumanSkinToneFromColor(Profile.Appearance.SkinColor); | ||
var color = SkinColor.HumanSkinTone((int)tone); | ||
|
||
previewProfile = previewProfile.WithCharacterAppearance(previewProfile.Appearance.WithSkinColor(color));// | ||
break; | ||
} | ||
case HumanoidSkinColor.Hues: | ||
{ | ||
break; | ||
} | ||
case HumanoidSkinColor.TintedHues: | ||
{ | ||
var color = SkinColor.TintedHues(Profile.Appearance.SkinColor); | ||
|
||
previewProfile = previewProfile.WithCharacterAppearance(previewProfile.Appearance.WithSkinColor(color)); | ||
break; | ||
} | ||
case HumanoidSkinColor.VoxFeathers: | ||
{ | ||
var color = SkinColor.ClosestVoxColor(Profile.Appearance.SkinColor); | ||
|
||
previewProfile = previewProfile.WithCharacterAppearance(previewProfile.Appearance.WithSkinColor(color)); | ||
break; | ||
} | ||
} | ||
|
||
var mob = _uIController.LoadProfileEntity(previewProfile, _proto.Index(job), false); // Раздетый моб | ||
Mob.SetEntity(mob); | ||
|
||
var loadoutMob = _uIController.LoadProfileEntity(previewProfile, _proto.Index(job), true); // Моб в одежде должности | ||
JobLoadout.SetEntity(loadoutMob); | ||
|
||
Select.Disabled = Profile.Species == protoId; | ||
Select.OnPressed += args => ChooseAction?.Invoke(protoId); | ||
|
||
// Тут у нас идёт штука для создание контейнера плюсов и минусов. Я не уверен, зачем я впихнул это сюда, но мне уже лень переделывать | ||
var prosConsContainer = new BoxContainer() | ||
{ | ||
Orientation = BoxContainer.LayoutOrientation.Vertical, | ||
Margin = new Thickness(5f, 5f), | ||
MaxWidth = 380f, | ||
}; | ||
var prosConsLabel = new RichTextLabel() | ||
{ | ||
Text = Loc.GetString("ui-species-pros-cons"), | ||
StyleClasses = { StyleBase.ClassLowDivider }, | ||
Margin = new(2f, 2f), | ||
}; | ||
var separator = new HSeparator() | ||
{ | ||
Margin = new(2f, 2f, 2f, 4f), | ||
}; | ||
prosConsContainer.AddChild(prosConsLabel); | ||
prosConsContainer.AddChild(separator); | ||
DetailInfoContainer.AddChild(prosConsContainer); | ||
|
||
if (proto.Pros.Count <= 0 && proto.Special.Count <= 0 && proto.Cons.Count <= 0) | ||
{ | ||
var noProsConsLabel = new RichTextLabel() | ||
{ | ||
Text = Loc.GetString("ui-species-no-pros-cons"), | ||
Margin = new(4f), | ||
}; | ||
DetailInfoContainer.AddChild(noProsConsLabel); | ||
} | ||
else | ||
{ | ||
if (proto.Pros.Count > 0) | ||
{ | ||
foreach (var item in proto.Pros) | ||
{ | ||
var label = new RichTextLabel() | ||
{ | ||
Text = "[color=#13f244]- " + Loc.GetString(item) + "[/color]", | ||
StyleClasses = { StyleBase.ClassLowDivider }, | ||
Margin = new(4f, 2f), | ||
}; | ||
prosConsContainer.AddChild(label); | ||
} | ||
prosConsContainer.AddChild(new Control() { MinHeight = 8f }); | ||
} | ||
|
||
if (proto.Special.Count > 0) | ||
{ | ||
foreach (var item in proto.Special) | ||
{ | ||
var label = new RichTextLabel() | ||
{ | ||
Text = "- " + Loc.GetString(item), | ||
StyleClasses = { StyleBase.ClassLowDivider }, | ||
Margin = new(4f, 2f), | ||
}; | ||
prosConsContainer.AddChild(label); | ||
} | ||
prosConsContainer.AddChild(new Control() { MinHeight = 8f }); | ||
} | ||
|
||
if (proto.Cons.Count > 0) | ||
{ | ||
foreach (var item in proto.Cons) | ||
{ | ||
var label = new RichTextLabel() | ||
{ | ||
Text = "[color=#d63636]- " + Loc.GetString(item) + "[/color]", | ||
StyleClasses = { StyleBase.ClassLowDivider }, | ||
Margin = new(4f, 2f), | ||
}; | ||
prosConsContainer.AddChild(label); | ||
} | ||
prosConsContainer.AddChild(new Control() { MinHeight = 8f }); | ||
} | ||
} | ||
|
||
if (!proto.Description.HasValue) | ||
return; | ||
|
||
// Описания рас берут текст из .xml файлов, поэтому нам нужно найти и использовать контент из указанного файла. | ||
// По сути, всё работает так же, как и в гайдбуке (и да, сюда можно вставлять изображения) | ||
using var file = _resMan.ContentFileReadText(proto.Description.Value); | ||
_parsingMan.TryAddMarkup(DetailInfoContainer, file.ReadToEnd()); | ||
} | ||
|
||
private sealed partial class SpeciesButton(ProtoId<SpeciesPrototype> proto) : Button | ||
{ | ||
public ProtoId<SpeciesPrototype> Proto = proto; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.