|
| 1 | +using CinematicUnityExplorer.NightRunners.Utils; |
| 2 | +using UnityExplorer.UI; |
| 3 | +using UnityExplorer.UI.Panels; |
| 4 | +using UniverseLib.UI; |
| 5 | + |
| 6 | +namespace CinematicUnityExplorer.UI.Panels |
| 7 | +{ |
| 8 | + public class RecordPanel : UEPanel |
| 9 | + { |
| 10 | + public override UIManager.Panels PanelType => UIManager.Panels.Record; |
| 11 | + public override string Name => "Record"; |
| 12 | + public override int MinWidth => 325; |
| 13 | + public override int MinHeight => 200; |
| 14 | + public override Vector2 DefaultAnchorMin => new(0.4f, 0.4f); |
| 15 | + public override Vector2 DefaultAnchorMax => new(0.6f, 0.6f); |
| 16 | + |
| 17 | + public RecordPanel(UIBase owner) : base(owner) |
| 18 | + { |
| 19 | + } |
| 20 | + |
| 21 | + protected override void ConstructPanelContent() |
| 22 | + { |
| 23 | + UIFactory.SetLayoutElement( |
| 24 | + UIFactory.CreateLabel(ContentRoot, "Warning", "Experimental, only player's car will be recorded", TextAnchor.MiddleCenter).gameObject, |
| 25 | + minWidth: 150, minHeight: 25, flexibleWidth: 9999 |
| 26 | + ); |
| 27 | + |
| 28 | + var recordButton = UIFactory.CreateButton(ContentRoot, "ToggleRecordButton", "Record"); |
| 29 | + UIFactory.SetLayoutElement(recordButton.GameObject, minWidth: 150, minHeight: 25, flexibleWidth: 9999); |
| 30 | + recordButton.OnClick += () => |
| 31 | + { |
| 32 | + RecordUtils.StartRecord(); |
| 33 | + var mode = RecordUtils.GetMode(); |
| 34 | + recordButton.ButtonText.text = $"{(mode == RCC_Recorder.Mode.Neutral ? "Start" : "Stop")} Record"; |
| 35 | + }; |
| 36 | + |
| 37 | + var replayButton = UIFactory.CreateButton(ContentRoot, "ToggleReplayButton", "Replay"); |
| 38 | + UIFactory.SetLayoutElement(replayButton.GameObject, minWidth: 150, minHeight: 25, flexibleWidth: 9999); |
| 39 | + replayButton.OnClick += () => |
| 40 | + { |
| 41 | + var mode = RecordUtils.GetMode(); |
| 42 | + if (mode == RCC_Recorder.Mode.Play) |
| 43 | + { |
| 44 | + RecordUtils.StopReplay(); |
| 45 | + } |
| 46 | + else |
| 47 | + { |
| 48 | + RecordUtils.StartReplay(); |
| 49 | + } |
| 50 | + }; |
| 51 | + } |
| 52 | + } |
| 53 | +} |
0 commit comments