Skip to content

Commit

Permalink
Add Delimit Speed Checkbox when in Advanced Window
Browse files Browse the repository at this point in the history
Closes #77
  • Loading branch information
Minmoose committed Aug 24, 2024
1 parent 62dfcd5 commit eface48
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions Brio/UI/Controls/Editors/ActionTimelineEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ internal class ActionTimelineEditor(CutsceneManager cutsceneManager, GPoseServic
private readonly ConfigurationService _configService = configService;
private readonly EntityManager _entityManager = entityManager;

private static readonly ActionTimelineSelector _globalTimelineSelector = new("global_timeline_selector");
private static float MaxItemWidth => ImGui.GetContentRegionAvail().X - ImGui.CalcTextSize("XXXXXXXXXXXXXXXXXX").X;
private static float LabelStart => MaxItemWidth + ImGui.GetCursorPosX() + (ImGui.GetStyle().FramePadding.X * 2f);

public bool _startAnimationOnSelect = true;
private static readonly float _hederButtonSize = ImGui.CalcTextSize("#########").X + 28;
private static readonly ActionTimelineSelector _globalTimelineSelector = new("global_timeline_selector");

public string cameraPath = string.Empty;
private string _cameraPath = string.Empty;
private ActionTimelineCapability _capability = null!;
public float hederButtonSize = ImGui.CalcTextSize("#########").X + 28;
private bool _startAnimationOnSelect = true;
private bool _delimitSpeed = false;

public void Draw(bool drawAdvanced, ActionTimelineCapability capability)
{
Expand All @@ -51,7 +52,7 @@ public void Draw(bool drawAdvanced, ActionTimelineCapability capability)

DrawBaseOverride();
DrawBlend();
DrawOverallSpeed();
DrawOverallSpeed(drawAdvanced);

if(drawAdvanced)
{
Expand Down Expand Up @@ -83,7 +84,7 @@ private void DrawHeder()

ImGui.SameLine();

ImBrio.RightAlign(hederButtonSize, 1);
ImBrio.RightAlign(_hederButtonSize, 1);

if(ImGui.Button("Actors "))
{
Expand All @@ -107,7 +108,7 @@ private void DrawHeder()
_capability.Reset();
_cutsceneManager.StopPlayback();
_cutsceneManager.CameraPath = null;
cameraPath = string.Empty;
_cameraPath = string.Empty;
}

using var popup = ImRaii.Popup("animation_control");
Expand Down Expand Up @@ -441,18 +442,29 @@ private void DrawSlot(ActionTimelineSlots slot)
}
}

private void DrawOverallSpeed()
private void DrawOverallSpeed(bool drawAdvanced)
{
float existingSpeed = _capability.SpeedMultiplier;
float newSpeed = existingSpeed;

const string speedLabel = "Speed";
ImGui.SetNextItemWidth(MaxItemWidth);
if(ImGui.SliderFloat($"###speed_slider", ref newSpeed, 0f, 5f))
ImGui.SetNextItemWidth(drawAdvanced ? MaxItemWidth - ImGui.CalcTextSize("XXXX").X : MaxItemWidth);
if(ImGui.SliderFloat($"###speed_slider", ref newSpeed, _delimitSpeed ? -5f : 0f, _delimitSpeed ? 10f : 5f))
_capability.SetOverallSpeedOverride(newSpeed);

if(drawAdvanced)
{
ImGui.SameLine();
if(ImGui.Checkbox("###delimit_speed", ref _delimitSpeed))
if(_delimitSpeed == false)
{
_capability.ResetOverallSpeedOverride();
}
if(ImGui.IsItemHovered())
ImGui.SetTooltip("Delimit Speed");
}

ImGui.SameLine();

ImGui.SetCursorPosX(LabelStart);
ImGui.Text(speedLabel);

Expand All @@ -463,7 +475,7 @@ private void DrawOverallSpeed()

ImGui.SameLine();

if(ImBrio.FontIconButtonRight("speed_pause", FontAwesomeIcon.PauseCircle, 2, _capability.SpeedMultiplier > 0 ? "Un-Pause" : "Paused", _capability.SpeedMultiplier > 0f))
if(ImBrio.FontIconButtonRight("speed_pause", FontAwesomeIcon.PauseCircle, 2, "Pause", _capability.SpeedMultiplier != 0f))
{
_capability.SetOverallSpeedOverride(0f);
}
Expand All @@ -475,7 +487,7 @@ private void DrawCutscene()

ImGui.SameLine();

ImGui.InputText(string.Empty, ref cameraPath, 260, ImGuiInputTextFlags.ReadOnly);
ImGui.InputText(string.Empty, ref _cameraPath, 260, ImGuiInputTextFlags.ReadOnly);

ImGui.SameLine();

Expand All @@ -486,28 +498,28 @@ private void DrawCutscene()
{
if(success)
{
cameraPath = path[0];
_cameraPath = path[0];

string? folderPath = Path.GetDirectoryName(cameraPath);
string? folderPath = Path.GetDirectoryName(_cameraPath);
if(folderPath is not null)
{
_configService.Configuration.LastXATPath = folderPath;
_configService.Save();

_cutsceneManager.CameraPath = new XATCameraPathFile(new BinaryReader(File.OpenRead(cameraPath)));
_cutsceneManager.CameraPath = new XATCameraPathFile(new BinaryReader(File.OpenRead(_cameraPath)));
}
}
else
{
cameraPath = string.Empty;
_cameraPath = string.Empty;
_cutsceneManager.CameraPath = null;
}
}, 1, _configService.Configuration.LastXATPath, false);
}

ImGui.Separator();

using(ImRaii.Disabled(string.IsNullOrEmpty(cameraPath)))
using(ImRaii.Disabled(string.IsNullOrEmpty(_cameraPath)))
{
ImGui.Checkbox("Enable FOV", ref _cutsceneManager.CameraSettings.EnableFOV);

Expand Down

0 comments on commit eface48

Please sign in to comment.