-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Окно, но не прототип * Рабочий прототип роадмапа * Контрол * Потом доделаю * Пустой Roadmap * Готова --------- Co-authored-by: BL02DL <[email protected]>
- Loading branch information
1 parent
0394782
commit bb53a70
Showing
11 changed files
with
325 additions
and
2 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
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
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
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,96 @@ | ||
using Content.Shared._LostParadise.Roadmap; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface; | ||
using System.Numerics; | ||
|
||
namespace Content.Client._LostParadise.Roadmap | ||
{ | ||
public class RoadmapControl : Control | ||
{ | ||
private readonly RoadmapPrototype _prototype; | ||
private readonly ProgressBar _progressBar; | ||
|
||
public RoadmapControl(RoadmapPrototype prototype) | ||
{ | ||
_prototype = prototype; | ||
_progressBar = new ProgressBar | ||
{ | ||
MinValue = 0, | ||
MaxValue = 100, | ||
Value = _prototype.Progress, | ||
HorizontalExpand = true | ||
}; | ||
|
||
SetupUI(); | ||
} | ||
|
||
private void SetupUI() | ||
{ | ||
Margin = new Thickness(0, 20, 0, 0); | ||
|
||
var vBox = new BoxContainer | ||
{ | ||
Orientation = BoxContainer.LayoutOrientation.Vertical | ||
}; | ||
|
||
var nameButton = new Button | ||
{ | ||
Text = _prototype.Name, | ||
StyleClasses = { "Caution" }, | ||
HorizontalExpand = true | ||
}; | ||
|
||
vBox.AddChild(nameButton); | ||
|
||
var descriptionLabel = new Label { Text = _prototype.Description, FontColorOverride = Color.LightGray }; | ||
var progressLabel = new Label | ||
{ | ||
Text = Loc.GetString("roadmap-progress") + $": {_prototype.Progress}%", | ||
FontColorOverride = Color.White | ||
}; | ||
|
||
var statusBox = new BoxContainer | ||
{ | ||
Orientation = BoxContainer.LayoutOrientation.Horizontal, | ||
HorizontalExpand = true, | ||
SeparationOverride = 5 | ||
}; | ||
|
||
var statusLabel = new Label | ||
{ | ||
Text = Loc.GetString("roadmap-status") + $": {Loc.GetString(_prototype.Status)}", | ||
FontColorOverride = GetStatusColor(), | ||
}; | ||
|
||
statusBox.AddChild(statusLabel); | ||
statusBox.AddChild(new Control { HorizontalExpand = true }); | ||
|
||
vBox.AddChild(descriptionLabel); | ||
vBox.AddChild(progressLabel); | ||
vBox.AddChild(_progressBar); | ||
vBox.AddChild(statusBox); | ||
|
||
var separator = new PanelContainer | ||
{ | ||
Modulate = new Color(0.5f, 0.5f, 0.5f, 1f), | ||
MinSize = new Vector2(0, 2), | ||
HorizontalExpand = true | ||
}; | ||
vBox.AddChild(separator); | ||
|
||
AddChild(vBox); | ||
} | ||
|
||
private Color GetStatusColor() | ||
{ | ||
string status = _prototype.Status; | ||
return status switch | ||
{ | ||
"roadmap-goal-completed" => new Color(0.0f, 1.0f, 0.0f), | ||
"roadmap-goal-progress" => new Color(1.0f, 1.0f, 0.0f), | ||
"roadmap-goal-waiting" => new Color(1.0f, 0.5f, 0.0f), | ||
_ => Color.White | ||
}; | ||
} | ||
} | ||
} |
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,81 @@ | ||
using Content.Shared._LostParadise.Roadmap; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface; | ||
using Robust.Shared.IoC; | ||
using Robust.Shared.Prototypes; | ||
using System.Numerics; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Client.UserInterface.Controllers; | ||
using System.Linq; | ||
|
||
namespace Content.Client._LostParadise.Roadmap | ||
{ | ||
public sealed class RoadmapUI : UIController | ||
{ | ||
private DefaultWindow _roadmapWindow; | ||
|
||
public RoadmapUI() | ||
{ | ||
_roadmapWindow = new DefaultWindow | ||
{ | ||
Title = Loc.GetString("roadmap-plan-LLP"), | ||
SetSize = new Vector2(600, 600), | ||
Resizable = false | ||
}; | ||
|
||
var panelContainer = new PanelContainer | ||
{ | ||
MinSize = new Vector2(580, 580), | ||
ModulateSelfOverride = Color.Transparent, | ||
Margin = new Thickness(10) | ||
}; | ||
|
||
var scrollContainer = new ScrollContainer | ||
{ | ||
HorizontalExpand = true, | ||
VerticalExpand = true, | ||
Margin = new Thickness(0, 20, 0, 0) | ||
}; | ||
|
||
var phaseList = new BoxContainer | ||
{ | ||
Orientation = BoxContainer.LayoutOrientation.Vertical, | ||
SeparationOverride = 10 | ||
}; | ||
|
||
scrollContainer.AddChild(phaseList); | ||
panelContainer.AddChild(scrollContainer); | ||
_roadmapWindow.AddChild(panelContainer); | ||
|
||
RefreshUI(phaseList); | ||
} | ||
|
||
private void RefreshUI(BoxContainer phaseList) | ||
{ | ||
phaseList.RemoveAllChildren(); | ||
|
||
var roadmapSystem = IoCManager.Resolve<IPrototypeManager>(); | ||
|
||
var roadmapPhases = roadmapSystem.EnumeratePrototypes<RoadmapPrototype>() | ||
.OrderBy<RoadmapPrototype, int>(phase => phase.Order); | ||
|
||
foreach (var phase in roadmapPhases) | ||
{ | ||
var phaseControl = new RoadmapControl(phase); | ||
phaseList.AddChild(phaseControl); | ||
} | ||
} | ||
|
||
public void ToggleRoadmap() | ||
{ | ||
if (_roadmapWindow.IsOpen) | ||
{ | ||
_roadmapWindow.Close(); | ||
} | ||
else | ||
{ | ||
_roadmapWindow.OpenCentered(); | ||
} | ||
} | ||
} | ||
} |
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,34 @@ | ||
using Content.Shared.Administration.Logs; | ||
using Content.Shared._LostParadise.Roadmap; | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.IoC; | ||
using Robust.Shared.Log; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server._LostParadise.Roadmap | ||
{ | ||
public class RoadmapSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IPrototypeManager _protoManager = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<RoadmapComponent, RoadmapUpdateEvent>(OnPhaseUpdate); | ||
} | ||
|
||
private void OnPhaseUpdate(EntityUid uid, RoadmapComponent component, RoadmapUpdateEvent args) | ||
{ | ||
if (!_protoManager.TryIndex<RoadmapPrototype>(args.RoadmapId, out var phase)) | ||
{ | ||
Logger.ErrorS("roadmap", $"Roadmap {args.RoadmapId} not found."); | ||
return; | ||
} | ||
|
||
component.CurrentPhase = phase.ID; | ||
component.Progress = args.NewProgress; | ||
|
||
Dirty(uid, component); | ||
} | ||
} | ||
} |
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,18 @@ | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.Serialization.Manager.Attributes; | ||
using Robust.Shared.ViewVariables; | ||
|
||
namespace Content.Shared._LostParadise.Roadmap | ||
{ | ||
[RegisterComponent] | ||
public sealed partial class RoadmapComponent : Component | ||
{ | ||
[ViewVariables(VVAccess.ReadWrite)] | ||
[DataField("roadmap")] | ||
public string CurrentPhase { get; set; } = string.Empty; | ||
|
||
[ViewVariables(VVAccess.ReadWrite)] | ||
[DataField("progress")] | ||
public float Progress { get; set; } = 0.0f; | ||
} | ||
} |
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,26 @@ | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Serialization.Manager.Attributes; | ||
|
||
namespace Content.Shared._LostParadise.Roadmap | ||
{ | ||
[Prototype("roadmap")] | ||
public class RoadmapPrototype : IPrototype | ||
{ | ||
[IdDataField] | ||
public string ID { get; } = default!; | ||
|
||
[DataField("name")] | ||
public string Name { get; } = string.Empty; | ||
|
||
[DataField("description")] | ||
public string Description { get; } = string.Empty; | ||
|
||
[DataField("progress")] | ||
public float Progress { get; set; } = 0.0f; | ||
|
||
[DataField("status")] | ||
public string Status { get; set; } = "roadmap-goal-waiting"; | ||
[DataField("order")] | ||
public int Order { get; set; } | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
Content.Shared/_LostParadise/Roadmap/RoadmapUpdateEvent.cs
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,16 @@ | ||
using Robust.Shared.GameObjects; | ||
|
||
namespace Content.Shared._LostParadise.Roadmap | ||
{ | ||
public sealed class RoadmapUpdateEvent : EntityEventArgs | ||
{ | ||
public string RoadmapId { get; } | ||
public float NewProgress { get; } | ||
|
||
public RoadmapUpdateEvent(string roadmapId, float newProgress) | ||
{ | ||
RoadmapId = roadmapId; | ||
NewProgress = newProgress; | ||
} | ||
} | ||
} |
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,7 @@ | ||
ui-roadmap = План разработки | ||
roadmap-plan-LLP = План разработки Lost Paradise | ||
roadmap-goal-completed = Завершено | ||
roadmap-goal-progress = В процессе | ||
roadmap-goal-waiting = В ожидании | ||
roadmap-progress = Прогресс | ||
roadmap-status = Статус |
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,27 @@ | ||
# Короче, думаю тут всё понятно, однако в status | ||
# пихайте: roadmap-goal-completed, roadmap-goal-progress, roadmap-goal-waiting | ||
# Order нужен, чтоб выставить в правильном порядке, так что вот, пользуйтесь | ||
|
||
- type: roadmap | ||
id: "helloworld" | ||
name: "Версия 2.0 - Дивный новый мир!" | ||
description: "Новая сборка и механики!" | ||
progress: 100 | ||
status: roadmap-goal-completed | ||
order: 0 | ||
|
||
- type: roadmap | ||
id: "centcom" | ||
name: "Обновление 2.1 - Центком важен!" | ||
description: "Обновление Центкома!" | ||
progress: 50 | ||
status: roadmap-goal-progress | ||
order: 1 | ||
|
||
- type: roadmap | ||
id: "blusec" | ||
name: "Обновление 2.2 - BLUSEC!" | ||
description: "Перекрас СБ в новый модный цвет!" | ||
progress: 37 | ||
status: roadmap-goal-progress | ||
order: 2 |