mirror of
https://github.com/originalnicodr/CinematicUnityExplorer.git
synced 2026-10-11 01:48:07 +08:00
Refactored the TimeWidget lock button into an Override toggle to make things clearer, and minor UI tweaks on the Cam Path panel.
This commit is contained in:
1 parent
56e438948b
commit
fd18d1b56d
4 files changed
+25
-39
No files matched your search
@@ -174,11 +174,11 @@ namespace UnityExplorer.UI.Panels
|
||||
|
||||
|
||||
// CatmullRom alpha value
|
||||
GameObject thridRow = AddInputField("alphaCatmullRom", "Alpha:", "0.5", out alphaCatmullRomInput, AlphaCatmullRom_OnEndEdit, 100);
|
||||
GameObject thridRow = AddInputField("alphaCatmullRom", "Alpha:", "0.5", out alphaCatmullRomInput, AlphaCatmullRom_OnEndEdit, 50);
|
||||
alphaCatmullRomInput.Text = alphaCatmullRomValue.ToString();
|
||||
|
||||
GameObject alphaCatmullRomObj = UIFactory.CreateSlider(thridRow, "Alpha CatmullRom Slider", out alphaCatmullRomSlider);
|
||||
UIFactory.SetLayoutElement(alphaCatmullRomObj, minHeight: 25, minWidth: 50, flexibleWidth: 0);
|
||||
UIFactory.SetLayoutElement(alphaCatmullRomObj, minHeight: 25, minWidth: 100, flexibleWidth: 0);
|
||||
alphaCatmullRomSlider.m_FillImage.color = Color.clear;
|
||||
alphaCatmullRomSlider.minValue = 0;
|
||||
alphaCatmullRomSlider.maxValue = 1;
|
||||
@@ -191,11 +191,11 @@ namespace UnityExplorer.UI.Panels
|
||||
});
|
||||
|
||||
// CatmullRom tension value
|
||||
AddInputField("tensionCatmullRomO", "Tension:", "0", out tensionCatmullRomInput, TensionCatmullRom_OnEndEdit, 100, thridRow);
|
||||
AddInputField("tensionCatmullRomO", "Tension:", "0", out tensionCatmullRomInput, TensionCatmullRom_OnEndEdit, 50, thridRow);
|
||||
tensionCatmullRomInput.Text = tensionCatmullRomValue.ToString();
|
||||
|
||||
GameObject tensionCatmullRomObj = UIFactory.CreateSlider(thridRow, "Tension CatmullRom Slider", out tensionCatmullRomSlider);
|
||||
UIFactory.SetLayoutElement(tensionCatmullRomObj, minHeight: 25, minWidth: 50, flexibleWidth: 0);
|
||||
UIFactory.SetLayoutElement(tensionCatmullRomObj, minHeight: 25, minWidth: 100, flexibleWidth: 0);
|
||||
tensionCatmullRomSlider.m_FillImage.color = Color.clear;
|
||||
tensionCatmullRomSlider.minValue = 0;
|
||||
tensionCatmullRomSlider.maxValue = 1;
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ namespace UnityExplorer.UI
|
||||
|
||||
public static RectTransform NavBarRect;
|
||||
public static GameObject NavbarTabButtonHolder;
|
||||
private static readonly Vector2 NAVBAR_DIMENSIONS = new(1600f, 35f);
|
||||
private static readonly Vector2 NAVBAR_DIMENSIONS = new(1610f, 35f);
|
||||
|
||||
private static ButtonRef closeBtn;
|
||||
private static TimeScaleWidget timeScaleWidget;
|
||||
|
||||
@@ -23,22 +23,21 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
static TimeScaleWidget Instance;
|
||||
|
||||
ButtonRef lockBtn;
|
||||
bool locked;
|
||||
Toggle overrideTimeScaleToggle;
|
||||
InputFieldRef timeInput;
|
||||
float desiredTime = 1;
|
||||
bool settingTimeScale;
|
||||
bool pause;
|
||||
Slider slider;
|
||||
|
||||
bool shouldSliderUnpauseOnValueChange = true;
|
||||
bool pressedPauseHotkey = false;
|
||||
float previousDesiredTime;
|
||||
bool previousLocked;
|
||||
bool previousOverride;
|
||||
|
||||
public void Update()
|
||||
{
|
||||
// Force the timescale in case the game tries force it for us
|
||||
if (locked)
|
||||
if (overrideTimeScaleToggle.isOn)
|
||||
SetTimeScale(desiredTime);
|
||||
|
||||
//if (!timeInput.Component.isFocused)
|
||||
@@ -47,19 +46,15 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
public void PauseToggle(){
|
||||
// If not paused but moved the slider to 0, consider that as it being paused
|
||||
if (desiredTime == 0 && locked && !pause) pause = true;
|
||||
if (desiredTime == 0 && overrideTimeScaleToggle.isOn && !pause) pause = true;
|
||||
|
||||
pause = !pause;
|
||||
|
||||
locked = pause ? true : previousLocked;
|
||||
UpdateLockedButton();
|
||||
desiredTime = pause ? 0f : previousDesiredTime;
|
||||
// We assume the vanilla game speed was 1f before editing it
|
||||
SetTimeScale(locked ? desiredTime : 1f);
|
||||
|
||||
shouldSliderUnpauseOnValueChange = false;
|
||||
pressedPauseHotkey = true;
|
||||
overrideTimeScaleToggle.isOn = pause ? true : previousOverride;
|
||||
slider.value = desiredTime;
|
||||
shouldSliderUnpauseOnValueChange = true;
|
||||
pressedPauseHotkey = false;
|
||||
}
|
||||
|
||||
public bool IsPaused(){
|
||||
@@ -89,16 +84,14 @@ namespace UnityExplorer.UI.Widgets
|
||||
}
|
||||
}
|
||||
|
||||
void OnLockedButtonClicked()
|
||||
void OnOverrideValueChanged(bool value)
|
||||
{
|
||||
locked = !locked;
|
||||
UpdateLockedButton();
|
||||
previousLocked = locked;
|
||||
if (!pressedPauseHotkey) previousOverride = overrideTimeScaleToggle.isOn;
|
||||
|
||||
// If the game was paused we consider this an unpause
|
||||
if (pause) pause = false;
|
||||
|
||||
if (locked){
|
||||
if (value){
|
||||
SetTimeScale(desiredTime);
|
||||
}
|
||||
else {
|
||||
@@ -107,13 +100,6 @@ namespace UnityExplorer.UI.Widgets
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateLockedButton()
|
||||
{
|
||||
Color color = locked ? new Color(0.3f, 0.3f, 0.2f) : new Color(0.2f, 0.2f, 0.2f);
|
||||
RuntimeHelper.SetColorBlock(lockBtn.Component, color, color * 1.2f, color * 0.7f);
|
||||
lockBtn.ButtonText.text = locked ? "Unlock" : "Lock";
|
||||
}
|
||||
|
||||
// UI Construction
|
||||
|
||||
void ConstructUI(GameObject parent)
|
||||
@@ -134,24 +120,24 @@ namespace UnityExplorer.UI.Widgets
|
||||
desiredTime = newTimeScale;
|
||||
timeInput.Text = desiredTime.ToString("0.00");
|
||||
|
||||
if (shouldSliderUnpauseOnValueChange){
|
||||
if (!pressedPauseHotkey){
|
||||
pause = false;
|
||||
// Don't save 0 as a previous desired time, it might not do anything when unpausing
|
||||
if (desiredTime != 0) previousDesiredTime = desiredTime;
|
||||
previousLocked = locked;
|
||||
}
|
||||
});
|
||||
slider.m_FillImage.color = Color.clear;
|
||||
slider.value = 1;
|
||||
slider.minValue = 0f;
|
||||
slider.maxValue = 2f;
|
||||
|
||||
lockBtn = UIFactory.CreateButton(parent, "PauseButton", "Lock", new Color(0.2f, 0.2f, 0.2f));
|
||||
UIFactory.SetLayoutElement(lockBtn.Component.gameObject, minHeight: 25, minWidth: 50);
|
||||
lockBtn.OnClick += OnLockedButtonClicked;
|
||||
}
|
||||
GameObject overrideTimeScaleObj = UIFactory.CreateToggle(parent, "Override TimeScale", out overrideTimeScaleToggle, out Text overrideTimeScaleText);
|
||||
UIFactory.SetLayoutElement(overrideTimeScaleObj, minHeight: 25, flexibleWidth: 0);
|
||||
overrideTimeScaleToggle.isOn = false;
|
||||
overrideTimeScaleToggle.onValueChanged.AddListener(OnOverrideValueChanged);
|
||||
overrideTimeScaleText.text = "Override";
|
||||
|
||||
// Only allow Time.timeScale to be set if the user hasn't "locked" it or if we are setting the value internally.
|
||||
slider.value = 1;
|
||||
}
|
||||
|
||||
static void InitPatch()
|
||||
{
|
||||
@@ -171,7 +157,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
static bool Prefix_Time_set_timeScale()
|
||||
{
|
||||
return !Instance.locked || Instance.settingTimeScale;
|
||||
return !Instance.overrideTimeScaleToggle.isOn || Instance.settingTimeScale;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user