/** * <summary>Draws the element using OnGUI.</summary> * <param name = "_style">The GUIStyle to draw with</param> * <param name = "_slot">Ignored by this subclass</param> * <param name = "zoom">The zoom factor</param> * <param name = "isActive">If True, then the element will be drawn as though highlighted</param> */ public override void Display(GUIStyle _style, int _slot, float zoom, bool isActive) { base.Display(_style, _slot, zoom, isActive); string fullText = label; if (Application.isPlaying && (isSelected || isActive)) { if (Options.GetLanguageName() == "Arabic" || Options.GetLanguageName() == "Hebrew") { fullText = "|" + fullText; } else { fullText += "|"; } } _style.wordWrap = true; _style.alignment = anchor; if (zoom < 1f) { _style.fontSize = (int)((float)_style.fontSize * zoom); } if (textEffects != TextEffects.None) { AdvGame.DrawTextEffect(ZoomRect(relativeRect, zoom), fullText, _style, Color.black, _style.normal.textColor, outlineSize, textEffects); } else { GUI.Label(ZoomRect(relativeRect, zoom), fullText, _style); } }
private void SetVariable(GVar var, VariableLocation location, bool doSkip) { if (var == null) { return; } if (location == VariableLocation.Global) { var.Download(); } if (var.type == VariableType.Integer) { int _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { if (setVarMethod == SetVarMethod.Formula) { _value = (int)AdvGame.CalculateFormula(AdvGame.ConvertTokens(formula)); } else { _value = intValue; } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && parameterName != "") { _value = animator.GetInteger(parameterName); setVarMethod = SetVarMethod.SetValue; } } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } } if (var.type == VariableType.Float) { float _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { if (setVarMethod == SetVarMethod.Formula) { _value = (float)AdvGame.CalculateFormula(AdvGame.ConvertTokens(formula)); } else { _value = floatValue; } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && parameterName != "") { _value = animator.GetFloat(parameterName); setVarMethod = SetVarMethod.SetValue; } } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } } else if (var.type == VariableType.Boolean) { int _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { _value = (int)boolValue; } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && parameterName != "") { if (animator.GetBool(parameterName)) { _value = 1; } } } var.SetValue(_value, SetVarMethod.SetValue); } else if (var.type == VariableType.PopUp) { var.SetValue(intValue); } else if (var.type == VariableType.String) { string _value = ""; if (setVarMethodString == SetVarMethodString.EnteredHere) { _value = AdvGame.ConvertTokens(stringValue); } else if (setVarMethodString == SetVarMethodString.SetAsMenuElementText) { MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName); if (menuElement != null) { if (menuElement is MenuInput) { MenuInput menuInput = (MenuInput)menuElement; _value = menuInput.GetContents(); if ((Options.GetLanguageName() == "Arabic" || Options.GetLanguageName() == "Hebrew") && _value.Length > 0) { // Invert char[] charArray = _value.ToCharArray(); _value = ""; for (int i = charArray.Length - 1; i >= 0; i--) { _value += charArray[i]; } } } else { PlayerMenus.GetMenuWithName(menuName).Recalculate(); menuElement.PreDisplay(slotNumber, Options.GetLanguage(), false); _value = menuElement.GetLabel(slotNumber, Options.GetLanguage()); } } else { Debug.LogWarning("Could not find MenuInput '" + elementName + "' in Menu '" + menuName + "'"); } } var.SetValue(_value); } if (location == VariableLocation.Global) { var.Upload(); } KickStarter.actionListManager.VariableChanged(); }
/** * Processes input entered by the player, and applies it to the text box (OnGUI-based Menus only). */ public void CheckForInput(string input, bool shift, string menuName) { if (uiInput != null) { return; } bool rightToLeft = false; if (Options.GetLanguageName() == "Arabic" || Options.GetLanguageName() == "Hebrew") { rightToLeft = true; } isSelected = true; if (input == "Backspace") { if (label.Length > 1) { if (rightToLeft) { label = label.Substring(1, label.Length - 1); } else { label = label.Substring(0, label.Length - 1); } } else if (label.Length == 1) { label = ""; } } else if (input == "KeypadEnter" || input == "Return" || input == "Enter") { if (linkedButton != "" && menuName != "") { PlayerMenus.SimulateClick(menuName, PlayerMenus.GetElementWithName(menuName, linkedButton), 1); } } else if ((inputType == AC_InputType.AlphaNumeric && (input.Length == 1 || input.Contains("Alpha"))) || (inputType == AC_InputType.NumbericOnly && input.Contains("Alpha")) || (inputType == AC_InputType.AlphaNumeric && allowSpaces && input == "Space")) { input = input.Replace("Alpha", ""); input = input.Replace("Space", " "); if (shift) { input = input.ToUpper(); } else { input = input.ToLower(); } if (characterLimit == 1) { label = input; } else if (label.Length < characterLimit) { if (rightToLeft) { label = input + label; } else { label += input; } } } }
/** * <summary>Gets the AudioClip associated with a speech line</summary> * <param name = "lineID">The ID number of the speech line, as generated by the Speech Manager</param> * <param name = "_speaker">The character speaking the line</param> * <returns>Gets the AudioClip associated with a speech line</returns> */ public AudioClip GetSpeechAudioClip(int lineID, Char _speaker) { AudioClip clipObj = null; int language = Options.GetLanguage(); string languageName = (language > 0) ? Options.GetLanguageName() : string.Empty; if (KickStarter.speechManager.autoNameSpeechFiles) { string fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, languageName, false); if (currentAudioAssetBundle != null) { // Asset bundles if (isLoadingBundle) { ACDebug.LogWarning("Cannot load audio file from AssetBundle as the AssetBundle is still being loaded."); return(null); } else { int indexOfLastSlash = fullName.LastIndexOf("/") + 1; if (indexOfLastSlash > 0) { fullName = fullName.Substring(indexOfLastSlash); } clipObj = currentAudioAssetBundle.LoadAsset <AudioClip> (fullName); if (clipObj == null && !string.IsNullOrEmpty(fullName)) { ACDebug.LogWarning("Audio file '" + fullName + "' not found in Asset Bundle '" + currentAudioAssetBundle.name + "'."); } } } else { // Resources clipObj = Resources.Load(fullName) as AudioClip; if (clipObj == null && KickStarter.speechManager.fallbackAudio && language > 0) { fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, string.Empty, false); clipObj = Resources.Load(fullName) as AudioClip; } if (clipObj == null && !string.IsNullOrEmpty(fullName)) { ACDebug.LogWarning("Audio file 'Resources/" + fullName + "' not found in Resources folder."); } } } else { clipObj = GetLineCustomAudioClip(lineID, language); if (clipObj == null && KickStarter.speechManager.fallbackAudio && language > 0) { clipObj = GetLineCustomAudioClip(lineID, 0); } } return(clipObj); }
/** * <summary>Gets the lipsync file associated with a speech line</summary> * <param name = "lineID">The ID number of the speech line, as generated by the Speech Manager</param> * <param name = "_speaker">The character speaking the line</param> * <returns>Gets the lipsync file associated with a speech line</returns> */ public T GetSpeechLipsyncFile <T> (int lineID, Char _speaker) where T : Object { T lipsyncFile = null; int language = Options.GetLanguage(); string languageName = (language > 0) ? Options.GetLanguageName() : string.Empty; if (KickStarter.speechManager.autoNameSpeechFiles) { string fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, languageName, true); if (currentLipsyncAssetBundle != null) { // Asset bundles if (isLoadingBundle) { ACDebug.LogWarning("Cannot load lipsync file from AssetBundle as the AssetBundle is still being loaded."); return(null); } int indexOfLastSlash = fullName.LastIndexOf("/") + 1; if (indexOfLastSlash > 0) { fullName = fullName.Substring(indexOfLastSlash); } lipsyncFile = currentLipsyncAssetBundle.LoadAsset <T> (fullName); if (lipsyncFile == null && !string.IsNullOrEmpty(fullName)) { ACDebug.LogWarning("Lipsync file '" + fullName + "' (" + typeof(T) + ") not found in Asset Bundle '" + currentLipsyncAssetBundle.name + "'."); } } else { // Resources lipsyncFile = Resources.Load(fullName) as T; if (lipsyncFile == null && KickStarter.speechManager.fallbackAudio && language > 0) { fullName = KickStarter.speechManager.GetAutoAssetPathAndName(lineID, _speaker, string.Empty, true); lipsyncFile = Resources.Load(fullName) as T; } if (lipsyncFile == null) { ACDebug.LogWarning("Lipsync file 'Resources/" + fullName + "' (" + typeof(T) + ") not found in Resources folder."); } } } else { UnityEngine.Object _object = KickStarter.runtimeLanguages.GetLineCustomLipsyncFile(lineID, language); if (_object == null && KickStarter.speechManager.fallbackAudio && language > 0) { _object = KickStarter.runtimeLanguages.GetLineCustomLipsyncFile(lineID, 0); } if (_object is T) { lipsyncFile = (T)KickStarter.runtimeLanguages.GetLineCustomLipsyncFile(lineID, language); } } return(lipsyncFile); }