diff --git a/Assets/Prefabs/Panels/ReferencePanel/ReferencePanelIconBackgroundImage.prefab b/Assets/Prefabs/Panels/ReferencePanel/ReferencePanelIconBackgroundImage.prefab index 03cd6dfe2..8ebc10ae2 100644 --- a/Assets/Prefabs/Panels/ReferencePanel/ReferencePanelIconBackgroundImage.prefab +++ b/Assets/Prefabs/Panels/ReferencePanel/ReferencePanelIconBackgroundImage.prefab @@ -144,6 +144,15 @@ MonoBehaviour: m_HoverScale: 1.2 m_HoverBoxColliderGrow: 0.2 m_AddOverlay: 0 + m_ErrorHelpText: + m_TableReference: + m_TableCollectionName: GUID:c84355079ab3f3e4f8f3812258805f86 + m_TableEntryReference: + m_KeyId: 238935604850335744 + m_Key: + m_FallbackState: 0 + m_WaitForCompletion: 0 + m_LocalVariables: [] references: version: 2 RefIds: [] diff --git a/Assets/Scripts/GUI/LoadBackgroundImageButton.cs b/Assets/Scripts/GUI/LoadBackgroundImageButton.cs index e4af884b2..2b246f4ca 100644 --- a/Assets/Scripts/GUI/LoadBackgroundImageButton.cs +++ b/Assets/Scripts/GUI/LoadBackgroundImageButton.cs @@ -13,6 +13,8 @@ // limitations under the License. using UnityEngine; +using UnityEngine.Localization; + namespace TiltBrush { @@ -20,17 +22,30 @@ public class LoadBackgroundImageButton : BaseButton { public ReferenceImage ReferenceImage { get; set; } + [SerializeField] private LocalizedString m_ErrorHelpText; + + // this is commented out and moved into ResetState() because + // for a new image (ie., one that isn't in the cache yet), !ReferenceImage.Valid, even if the size is valid (ie less than the max size) + // TODO: figure out if it's bad to move this into ResetState() public void RefreshDescription() { - if (ReferenceImage != null) - { - SetDescriptionText(ReferenceImage.FileName); - } - } + /* if (ReferenceImage != null) + { + + if (!ReferenceImage.Valid) + { + SetDescriptionText(App.ShortenForDescriptionText(ReferenceImage.FileName), ImageErrorExtraDescription()); + } + else + { + SetDescriptionText(App.ShortenForDescriptionText(ReferenceImage.FileName)); + } + }*/ + } override protected void OnButtonPressed() { - if (ReferenceImage == null) + if (ReferenceImage == null || !ReferenceImage.Valid) { return; } @@ -41,16 +56,18 @@ override public void ResetState() { base.ResetState(); - // Make ourselves unavailable if our image has an error. - bool available = false; - if (ReferenceImage != null) + if (ReferenceImage == null) { - available = ReferenceImage.NotLoaded || ReferenceImage.Valid; + return; } - if (available != IsAvailable()) + if (!ReferenceImage.Valid) + { + SetDescriptionText(App.ShortenForDescriptionText(ReferenceImage.FileName), ImageErrorExtraDescription()); + } + else { - SetButtonAvailable(available); + SetDescriptionText(App.ShortenForDescriptionText(ReferenceImage.FileName)); } } @@ -62,5 +79,11 @@ public void Set360ButtonTexture(Texture2D rTexture, float aspect = -1) m_ButtonRenderer.material.SetFloat("_Stereoscopic", isStereo); } + + public string ImageErrorExtraDescription() + { + return m_ErrorHelpText.GetLocalizedStringAsync().Result; + } + } } // namespace TiltBrush diff --git a/Assets/Scripts/GUI/LoadReferenceImageButton.cs b/Assets/Scripts/GUI/LoadReferenceImageButton.cs index 71e8551b5..2892e31cf 100644 --- a/Assets/Scripts/GUI/LoadReferenceImageButton.cs +++ b/Assets/Scripts/GUI/LoadReferenceImageButton.cs @@ -24,14 +24,14 @@ public class LoadReferenceImageButton : BaseButton [SerializeField] private LocalizedString m_ErrorHelpText; - - public void RefreshDescription() { if (ReferenceImage != null) { - if (!ReferenceImage.Valid) + // Problem: image can have error for other reasons too, not just for being too large + // displays "Image too large to load" under the file name. + if (ReferenceImage.Icon == ReferenceImageCatalog.m_Instance.ErrorImage) { SetDescriptionText(App.ShortenForDescriptionText(ReferenceImage.FileName), ImageErrorExtraDescription()); } @@ -45,7 +45,7 @@ public void RefreshDescription() override protected void OnButtonPressed() { - if (ReferenceImage == null || !ReferenceImage.Valid) + if (ReferenceImage == null) { return; } @@ -72,6 +72,20 @@ override protected void OnButtonPressed() override public void ResetState() { base.ResetState(); + + // Make ourselves unavailable if our image has an error. + bool available = false; + if (ReferenceImage != null) + { + available = ReferenceImage.NotLoaded || ReferenceImage.Valid; + } + + if (available != IsAvailable()) + { + SetButtonAvailable(available); + } + + RefreshDescription(); } public string ImageErrorExtraDescription() diff --git a/Assets/Settings/Localization/Strings/Strings Shared Data.asset b/Assets/Settings/Localization/Strings/Strings Shared Data.asset index c0578650b..c160912a3 100644 --- a/Assets/Settings/Localization/Strings/Strings Shared Data.asset +++ b/Assets/Settings/Localization/Strings/Strings Shared Data.asset @@ -3319,6 +3319,10 @@ MonoBehaviour: m_Key: PANEL_REFERENCE_ICONIMAGE_LOADERRORTEXT m_Metadata: m_Items: [] + - m_Id: 238935604850335744 + m_Key: PANEL_REFERENCE_ICONBACKGROUNDIMAGE_LOADERRORTEXT + m_Metadata: + m_Items: [] m_Metadata: m_Items: [] m_KeyGenerator: diff --git a/Assets/Settings/Localization/Strings/Strings_en.asset b/Assets/Settings/Localization/Strings/Strings_en.asset index 57c5e9874..a6880379f 100644 --- a/Assets/Settings/Localization/Strings/Strings_en.asset +++ b/Assets/Settings/Localization/Strings/Strings_en.asset @@ -3516,6 +3516,10 @@ MonoBehaviour: m_Localized: Image too large to load m_Metadata: m_Items: [] + - m_Id: 238935604850335744 + m_Localized: Image too large to load + m_Metadata: + m_Items: [] references: version: 2 RefIds: []