Skip to content

Commit

Permalink
Fixes and improvements for 2440851
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklul committed Jun 1, 2024
1 parent 1ebccfe commit c33c2f2
Show file tree
Hide file tree
Showing 11 changed files with 3,719 additions and 2,124 deletions.
275 changes: 102 additions & 173 deletions Assets/USharpVideoSubtitles/Development/DevScene.unity

Large diffs are not rendered by default.

2,721 changes: 1,361 additions & 1,360 deletions Assets/USharpVideoSubtitles/Development/Testing.prefab

Large diffs are not rendered by default.

106 changes: 80 additions & 26 deletions Assets/USharpVideoSubtitles/Fonts/OpenSans SDF.asset

Large diffs are not rendered by default.

1,002 changes: 950 additions & 52 deletions Assets/USharpVideoSubtitles/Scenes/ExampleScene.unity

Large diffs are not rendered by default.

550 changes: 330 additions & 220 deletions Assets/USharpVideoSubtitles/Scripts/SubtitleControlHandler.asset

Large diffs are not rendered by default.

46 changes: 37 additions & 9 deletions Assets/USharpVideoSubtitles/Scripts/SubtitleControlHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ public class SubtitleControlHandler : UdonSharpBehaviour
[SerializeField]
private GameObject inputMenu;

[SerializeField]
private Graphic inputLoadButtonBackground;
[SerializeField]
private Graphic inputLoadButtonIcon;

[SerializeField]
private Graphic inputMenuButtonBackground;
[SerializeField]
Expand Down Expand Up @@ -440,19 +445,17 @@ public override void OnOwnershipTransferred(VRCPlayerApi player)

public void UpdateOwner()
{
#if !UNITY_EDITOR
if (ownerField)
{
if (manager.IsLocal())
ownerField.text = Networking.LocalPlayer.displayName + " " + INDICATOR_LOCAL;
else
ownerField.text = Networking.GetOwner(manager.gameObject).displayName;
}
#endif

if (reloadButton)
{
if (manager.CanSynchronizeSubtitles() || manager.IsLocal())
if (manager.CanSynchronizeSubtitles() || manager.IsLocal() || manager.IsSyncedURL())
{
if (reloadGraphic) reloadGraphic.color = whiteGraphicColor;
}
Expand All @@ -471,6 +474,7 @@ public void UpdateLockState()

if (lockGraphic) lockGraphic.color = whiteGraphicColor;
if (inputClearButtonIcon) inputClearButtonIcon.color = whiteGraphicColor;
if (inputLoadButtonIcon) inputLoadButtonIcon.color = whiteGraphicColor;

if (inputField) inputField.readOnly = false;
if (urlInputField) urlInputField.readOnly = false;
Expand All @@ -492,6 +496,7 @@ public void UpdateLockState()
{
if (lockGraphic) lockGraphic.color = whiteGraphicColor;
if (inputClearButtonIcon) inputClearButtonIcon.color = whiteGraphicColor;
if (inputLoadButtonIcon) inputLoadButtonIcon.color = whiteGraphicColor;

if (inputField) inputField.readOnly = false;
if (urlInputField) urlInputField.readOnly = false;
Expand All @@ -503,18 +508,18 @@ public void UpdateLockState()
{
if (lockGraphic) lockGraphic.color = redGraphicColor;
if (inputClearButtonIcon) inputClearButtonIcon.color = redGraphicColor;
if (inputLoadButtonIcon) inputLoadButtonIcon.color = redGraphicColor;

if (inputField) inputField.readOnly = true;
if (urlInputField) urlInputField.readOnly = true;
#if !UNITY_EDITOR

string onlyMaster = string.Format(
@MESSAGE_ONLY_MASTER_CAN_ADD,
(manager.IsUsingUSharpVideo() ? manager.GetUSharpVideoOwner() : Networking.GetOwner(manager.gameObject)).displayName
);

if (inputPlaceholderText) inputPlaceholderText.text = onlyMaster;
if (urlInputPlaceholderText) urlInputPlaceholderText.text = onlyMaster;
#endif
}
}
else
Expand All @@ -524,15 +529,28 @@ public void UpdateLockState()

if (lockGraphic) lockGraphic.color = whiteGraphicColor;
if (inputClearButtonIcon) inputClearButtonIcon.color = whiteGraphicColor;
if (inputLoadButtonIcon) inputLoadButtonIcon.color = whiteGraphicColor;

if (inputField) inputField.readOnly = false;
if (urlInputField) urlInputField.readOnly = true;
if (urlInputField) urlInputField.readOnly = false;

if (inputPlaceholderText) inputPlaceholderText.text = MESSAGE_PASTE + " " + INDICATOR_ANYONE;
if (urlInputPlaceholderText) urlInputPlaceholderText.text = MESSAGE_LOAD_URL + " " + INDICATOR_ANYONE;
}
}

public void LoadInput()
{
if (inputField && inputField.text.Length > 0) {
OnSubtitleInput();
} else if (urlInputField && urlInputField.GetUrl().ToString().Length > 0) {
OnSubtitleUrlInput();
}

inputField.text = string.Empty;
urlInputField.SetUrl(VRCUrl.Empty);
}

public void OnSubtitleInput()
{
if (!inputField)
Expand Down Expand Up @@ -729,22 +747,32 @@ public void OnReloadButton()
return;
}
}
else if (manager.IsSyncedURL())
{
AnimateReloadButton();
manager.ReloadSyncedURL();
return;
}
else
{
SetStickyStatusText(string.Format(MESSAGE_ONLY_OWNER_CAN_SYNC, Networking.GetOwner(manager.gameObject).displayName), 3.0f);
return;
}
}

AnimateReloadButton();
manager.SynchronizeSubtitles();
}

private void AnimateReloadButton()
{
if (reloadButton)
{
Animator animator = reloadButton.GetComponent<Animator>();

if (animator)
animator.SetTrigger("Rotate");
}

manager.SynchronizeSubtitles();
}

public void OnLockButton()
Expand Down Expand Up @@ -1026,7 +1054,7 @@ private void ImportSettingsFromStringInternal(string settings, int mode)
if (alignmentToggle)
alignmentToggle.isOn = tmpInt == 1;

// Not exposed to Udon yet (VerticalAlignmentOptions)
// @TODO Not exposed to Udon yet (VerticalAlignmentOptions)
/*if (tmpInt == 1)
overlayHandler.SetAlignment(VerticalAlignmentOptions.Top);
else
Expand Down
Loading

0 comments on commit c33c2f2

Please sign in to comment.