Skip to content

Commit d087a90

Browse files
committed
feat: add experimantal record feature
1 parent 3475d39 commit d087a90

File tree

3 files changed

+95
-1
lines changed

3 files changed

+95
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace CinematicUnityExplorer.NightRunners.Utils
8+
{
9+
public static class RecordUtils
10+
{
11+
public static RCC_Recorder.Mode GetMode()
12+
{
13+
return RCC_SceneManager.instance.recorder.mode;
14+
}
15+
16+
public static void StartRecord()
17+
{
18+
RCC.StartStopRecord();
19+
}
20+
21+
public static void StopRecord()
22+
{
23+
RCC.StartStopRecord();
24+
}
25+
26+
public static void StartReplay()
27+
{
28+
RCC_SceneManager.instance.recorder.carController.externalControllerAI = new RCC_AICarController();
29+
RCC.StartStopReplay();
30+
}
31+
32+
public static void StopReplay()
33+
{
34+
RCC_SceneManager.instance.recorder.carController.externalControllerAI = null;
35+
RCC.StartStopReplay();
36+
}
37+
}
38+
}

src/UI/Panels/RecordPanel.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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+
}

src/UI/UIManager.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using UnityExplorer.Config;
1+
using CinematicUnityExplorer.UI.Panels;
2+
using UnityExplorer.Config;
23
using UnityExplorer.CSConsole;
34
using UnityExplorer.Inspectors;
45
using UnityExplorer.UI.Panels;
@@ -28,6 +29,7 @@ public enum Panels
2829
PostProcessingPanel,
2930
AnimatorPanel,
3031
Misc,
32+
Record
3133
}
3234

3335
public enum VerticalAnchor
@@ -102,6 +104,7 @@ internal static void InitUI()
102104
UIPanels.Add(Panels.PostProcessingPanel, new PostProcessingPanel(UiBase));
103105
UIPanels.Add(Panels.AnimatorPanel, new AnimatorPanel(UiBase));
104106
UIPanels.Add(Panels.Misc, new UnityExplorer.UI.Panels.Misc(UiBase));
107+
UIPanels.Add(Panels.Record, new RecordPanel(UiBase));
105108
UIPanels.Add(Panels.Options, new OptionsPanel(UiBase));
106109
UIPanels.Add(Panels.UIInspectorResults, new MouseInspectorResultsPanel(UiBase));
107110

0 commit comments

Comments
 (0)