Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed Captioning system for SFX #498

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
Add captioning to the Language menu in settings.
codeedward committed Sep 4, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 0ffcdb3dea929e28d2b4c717ee79edce02aa39e9
Original file line number Diff line number Diff line change
@@ -267,6 +267,18 @@ MonoBehaviour:
m_Key: Language
m_Metadata:
m_Items: []
- m_Id: 39863313582776320
m_Key: Captioning
m_Metadata:
m_Items: []
- m_Id: 39863497532366848
m_Key: Captioning_On
m_Metadata:
m_Items: []
- m_Id: 39863525374156800
m_Key: Captioning_Off
m_Metadata:
m_Items: []
m_Metadata:
m_Items: []
m_KeyGenerator:
Original file line number Diff line number Diff line change
@@ -273,5 +273,17 @@ MonoBehaviour:
m_Localized: Music Volume
m_Metadata:
m_Items: []
- m_Id: 39863313582776320
m_Localized: Captioning
m_Metadata:
m_Items: []
- m_Id: 39863497532366848
m_Localized: On
m_Metadata:
m_Items: []
- m_Id: 39863525374156800
m_Localized: Off
m_Metadata:
m_Items: []
references:
version: 1
Original file line number Diff line number Diff line change
@@ -239,5 +239,13 @@ MonoBehaviour:
m_Localized: Volume de la musique
m_Metadata:
m_Items: []
- m_Id: 39863497532366848
m_Localized: "Activ\xE9"
m_Metadata:
m_Items: []
- m_Id: 39863525374156800
m_Localized: "Desactiv\xE9"
m_Metadata:
m_Items: []
references:
version: 1
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ Mesh:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: pb_Mesh-82296
m_Name: pb_Mesh-81552
serializedVersion: 10
m_SubMeshes:
- serializedVersion: 2
244 changes: 208 additions & 36 deletions UOP1_Project/Assets/Scenes/Managers/Gameplay.unity

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ MonoBehaviour:
audioClips:
- {fileID: 8300000, guid: e0e1785c8995b62439473ff886ea115d, type: 3}
Caption:
Visualise: 0
Visualise: 1
SoundText:
m_TableReference:
m_TableCollectionName: GUID:d299736136010ec4f926836ea5b14a66
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ MonoBehaviour:
- {fileID: 8300000, guid: c9e9f3c13ca8a2449b95437d67506110, type: 3}
- {fileID: 8300000, guid: 9b8b36841533b9f46875b542d77513b8, type: 3}
Caption:
Visualise: 0
Visualise: 1
SoundText:
m_TableReference:
m_TableCollectionName: GUID:d299736136010ec4f926836ea5b14a66
@@ -29,4 +29,4 @@ MonoBehaviour:
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 1
Duration: 1
Duration: 0.5
2 changes: 2 additions & 0 deletions UOP1_Project/Assets/Scripts/SaveSystem/Save.cs
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ public class Save
public float _shadowDistance = default;
public bool _isFullscreen = default;
public Locale _currentLocale = default;
public bool _isCaptioningEnabled = default;

public void SaveSettings(SettingsSO settings)
{
@@ -37,6 +38,7 @@ public void SaveSettings(SettingsSO settings)
_shadowDistance = settings.ShadowDistance;
_isFullscreen = settings.IsFullscreen;
_currentLocale = settings.CurrentLocale;
_isCaptioningEnabled = settings.IsCaptioningEnabled;
}
public string ToJson()
{
8 changes: 6 additions & 2 deletions UOP1_Project/Assets/Scripts/Systems/Settings/SettingsSO.cs
Original file line number Diff line number Diff line change
@@ -12,14 +12,16 @@ public class SettingsSO : ScriptableObject
[SerializeField] float _shadowDistance = default;
[SerializeField] bool _isFullscreen = default;
[SerializeField] Locale _currentLocale = default;
[SerializeField] bool _isCaptioningEnabled = default;
public float MasterVolume => _masterVolume;
public float MusicVolume => _musicVolume;
public float SfxVolume => _sfxVolume;
public int ResolutionsIndex => _resolutionsIndex;
public int AntiAliasingIndex => _antiAliasingIndex;
public float ShadowDistance => _shadowDistance;
public bool IsFullscreen => _isFullscreen;
public bool IsFullscreen => _isFullscreen;
public Locale CurrentLocale => _currentLocale;
public bool IsCaptioningEnabled => _isCaptioningEnabled;
public void SaveAudioSettings(float newMusicVolume, float newSfxVolume, float newMasterVolume)
{
_masterVolume = newMasterVolume;
@@ -33,9 +35,10 @@ public void SaveGraphicsSettings(int newResolutionsIndex, int newAntiAliasingInd
_shadowDistance = newShadowDistance;
_isFullscreen = fullscreenState;
}
public void SaveLanguageSettings(Locale local)
public void SaveLanguageSettings(Locale local, bool isCaptioningEnabled)
{
_currentLocale = local;
_isCaptioningEnabled = isCaptioningEnabled;
}
public SettingsSO() { }
public void LoadSavedSettings(Save savedFile)
@@ -48,5 +51,6 @@ public void LoadSavedSettings(Save savedFile)
_shadowDistance = savedFile._shadowDistance;
_isFullscreen = savedFile._isFullscreen;
_currentLocale = savedFile._currentLocale;
_isCaptioningEnabled = savedFile._isCaptioningEnabled;
}
}
Original file line number Diff line number Diff line change
@@ -211,7 +211,6 @@ void SetFullscreen()
{
_fullscreenField.FillSettingField_Localized(2, 0, "Off");
}

}
bool GetCurrentFullscreenState()
{
Original file line number Diff line number Diff line change
@@ -17,13 +17,18 @@ public class UISettingsLanguageComponent : MonoBehaviour
AsyncOperationHandle m_InitializeOperation;
List<string> languageList = new List<string>();

public event UnityAction<Locale> _save = delegate { };
public event UnityAction<Locale, bool> _save = delegate { };
private int _currentSelectedOption = 0;
private int _savedSelectedOption = default;

[SerializeField] private UISettingItemFiller _captioningField = default;
private bool _isCaptioningEnabled = default;
private bool _savedIsCaptioningEnabled = default;

[SerializeField] private UIGenericButton _saveButton;
[SerializeField] private UIGenericButton _resetButton;


void OnEnable()
{
m_InitializeOperation = LocalizationSettings.SelectedLocaleAsync;
@@ -37,8 +42,12 @@ void OnEnable()
}
_saveButton.Clicked += SaveSettings;
_resetButton.Clicked += ResetSettings;

_languageField._nextOption += NextOption;
_languageField._previousOption += PreviousOption;

_captioningField._nextOption += NextIsCaptioningEnabledState;
_captioningField._previousOption += PreviousIsCaptioningEnabledState;
}
private void OnDisable()
{
@@ -51,6 +60,14 @@ private void OnDisable()
LocalizationSettings.SelectedLocaleChanged -= LocalizationSettings_SelectedLocaleChanged;
}

public void Setup(bool isCaptioningEnabled)
{
_isCaptioningEnabled = isCaptioningEnabled;
_savedIsCaptioningEnabled = _isCaptioningEnabled;

SetCaptioning();
}

void InitializeCompleted(AsyncOperationHandle obj)
{
m_InitializeOperation.Completed -= InitializeCompleted;
@@ -109,12 +126,44 @@ public void SaveSettings()
{
Locale _currentLocale = LocalizationSettings.AvailableLocales.Locales[_currentSelectedOption];
_savedSelectedOption = _currentSelectedOption;
_save.Invoke(_currentLocale);
_savedIsCaptioningEnabled = _isCaptioningEnabled;
_save.Invoke(_currentLocale, _isCaptioningEnabled);
}
public void ResetSettings()
{
_currentSelectedOption = _savedSelectedOption;
OnSelectionChanged();

_isCaptioningEnabled = _savedIsCaptioningEnabled;
OnCaptioningChange();
}

#region IsCaptioningEnabled
void NextIsCaptioningEnabledState()
{
_isCaptioningEnabled = true;
OnCaptioningChange();
}
void PreviousIsCaptioningEnabledState()
{
_isCaptioningEnabled = false;
OnCaptioningChange();
}
void OnCaptioningChange()
{
SetCaptioning();
}

private void SetCaptioning()
{
if (_isCaptioningEnabled)
{
_captioningField.FillSettingField_Localized(2, 1, "On");
}
else
{
_captioningField.FillSettingField_Localized(2, 0, "Off");
}
}
#endregion
}
Original file line number Diff line number Diff line change
@@ -54,6 +54,9 @@ public void SetField(SettingField field, UISettingItemFiller uiField)
else
selectedOption = "Off";
break;
case SettingFieldType.Captioning:
paginationCount = 2;
break;
case SettingFieldType.ShadowDistance:

break;
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ public enum SettingFieldType
AntiAliasing,
ShadowQuality,
Volume_Master,
Captioning

}
[System.Serializable]
@@ -89,7 +90,8 @@ void OpenSetting(SettingsType settingType)
switch (settingType)
{
case SettingsType.Language:
_currentSettings.SaveLanguageSettings(_currentSettings.CurrentLocale);
_currentSettings.SaveLanguageSettings(_currentSettings.CurrentLocale, _currentSettings.IsCaptioningEnabled);
_languageComponent.Setup(_currentSettings.IsCaptioningEnabled);
break;
case SettingsType.Graphics:
_graphicsComponent.Setup();
@@ -109,7 +111,6 @@ void OpenSetting(SettingsType settingType)
}
void SwitchTab(float orientation)
{

if (orientation != 0)
{
bool isLeft = orientation < 0;
@@ -131,9 +132,9 @@ void SwitchTab(float orientation)
OpenSetting(_settingTabsList[initialIndex]);
}
}
public void SaveLaguageSettings(Locale local)
public void SaveLaguageSettings(Locale local, bool isCaptioningEnabled)
{
_currentSettings.SaveLanguageSettings(local);
_currentSettings.SaveLanguageSettings(local, isCaptioningEnabled);
SaveSettingsEvent.RaiseEvent();
}
public void SaveGraphicsSettings(int newResolutionsIndex, int newAntiAliasingIndex, float newShadowDistance, bool fullscreenState)