public override ActionEnd End(List <Action> actions) { switch (saveCheck) { case SaveCheck.NumberOfSaveGames: return(ProcessResult(CheckCondition(KickStarter.saveSystem.GetNumSaves(includeAutoSaves)), actions)); case SaveCheck.NumberOfProfiles: return(ProcessResult(CheckCondition(KickStarter.options.GetNumProfiles()), actions)); case SaveCheck.IsSlotEmpty: return(ProcessResult(!SaveSystem.DoesSaveExist(intValue, intValue, !checkByElementIndex), actions)); case SaveCheck.DoesProfileExist: if (checkByElementIndex) { int i = Mathf.Max(0, intValue); bool includeActive = true; if (menuName != "" && elementName != "") { MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName); if (menuElement != null && menuElement is MenuProfilesList) { MenuProfilesList menuProfilesList = (MenuProfilesList)menuElement; if (menuProfilesList.fixedOption) { LogWarning("Cannot refer to ProfilesList " + elementName + " in Menu " + menuName + ", as it lists a fixed profile ID only!"); return(ProcessResult(false, actions)); } i += menuProfilesList.GetOffset(); includeActive = menuProfilesList.showActive; } else { LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'."); } } else { LogWarning("No ProfilesList element referenced when trying to delete profile slot " + i.ToString()); } return(ProcessResult(KickStarter.options.DoesProfileExist(i, includeActive), actions)); } else { // intValue is the profile ID return(ProcessResult(Options.DoesProfileIDExist(intValue), actions)); } case SaveCheck.DoesProfileNameExist: bool result = false; GVar gVar = GlobalVariables.GetVariable(profileVarID); if (gVar != null) { string profileName = gVar.TextValue; result = KickStarter.options.DoesProfileExist(profileName); } else { LogWarning("Could not check for profile name - no variable found."); } return(ProcessResult(result, actions)); case SaveCheck.IsSavingPossible: return(ProcessResult(!PlayerMenus.IsSavingLocked(this), actions)); default: break; } return(GenerateStopActionEnd()); }
/** * 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; } } } }
public override float Run() { string newSaveLabel = ""; if (manageSaveType == ManageSaveType.RenameSave) { GVar gVar = GlobalVariables.GetVariable(varID); if (gVar != null) { newSaveLabel = gVar.textVal; } else { LogWarning("Could not " + manageSaveType.ToString() + " - no variable found."); return(0f); } } int i = Mathf.Max(0, saveIndex); if (selectSaveType == SelectSaveType.SlotIndexFromVariable) { GVar gVar = GlobalVariables.GetVariable(slotVarID); if (gVar != null) { i = gVar.val; } else { LogWarning("Could not rename save - no variable found."); return(0f); } } else if (selectSaveType == SelectSaveType.Autosave) { if (manageSaveType == ManageSaveType.DeleteSave) { SaveSystem.DeleteSave(0); } else if (manageSaveType == ManageSaveType.RenameSave) { return(0f); } } if (menuName != "" && elementName != "") { MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName); if (menuElement != null && menuElement is MenuSavesList) { MenuSavesList menuSavesList = (MenuSavesList)menuElement; i += menuSavesList.GetOffset(); } else { LogWarning("Cannot find SavesList element '" + elementName + "' in Menu '" + menuName + "'."); } } else { LogWarning("No SavesList element referenced when trying to find save slot " + i.ToString()); } if (manageSaveType == ManageSaveType.DeleteSave) { KickStarter.saveSystem.DeleteSave(i, -1, false); } else if (manageSaveType == ManageSaveType.RenameSave) { KickStarter.saveSystem.RenameSave(newSaveLabel, i); } return(0f); }
private void RunInstant(AC.Menu _menu) { if (changeType == MenuChangeType.HideMenuElement || changeType == MenuChangeType.ShowMenuElement) { MenuElement _element = PlayerMenus.GetElementWithName(menuToChange, elementToChange); if (_element != null) { if (changeType == MenuChangeType.HideMenuElement) { _element.isVisible = false; } else { _element.isVisible = true; } _menu.ResetVisibleElements(); _menu.Recalculate(); KickStarter.playerMenus.FindFirstSelectedElement(); } else { ACDebug.LogWarning("Could not find element of name '" + elementToChange + "' on menu '" + menuToChange + "'"); } } else if (changeType == MenuChangeType.UnlockMenu) { _menu.isLocked = false; } else if (changeType == MenuChangeType.AddJournalPage) { MenuElement _element = PlayerMenus.GetElementWithName(menuToChange, elementToChange); if (_element != null) { if (journalText != "") { if (_element is MenuJournal) { MenuJournal journal = (MenuJournal)_element; JournalPage newPage = new JournalPage(lineID, journalText); journal.AddPage(newPage, onlyAddNewJournal, journalPageIndex); if (lineID == -1) { ACDebug.LogWarning("The new Journal page has no ID number, and will not be included in save game files - this can be corrected by clicking 'Gather text' in the Speech Manager"); } } else { ACDebug.LogWarning(_element.title + " is not a journal!"); } } else { ACDebug.LogWarning("No journal text to add!"); } } else { ACDebug.LogWarning("Could not find menu element of name '" + elementToChange + "' inside '" + menuToChange + "'"); } _menu.Recalculate(); } else if (changeType == MenuChangeType.RemoveJournalPage) { MenuElement _element = PlayerMenus.GetElementWithName(menuToChange, elementToChange); if (_element != null) { if (_element is MenuJournal) { MenuJournal journal = (MenuJournal)_element; journal.RemovePage(journalPageIndex); } else { ACDebug.LogWarning(_element.title + " is not a journal!"); } } else { ACDebug.LogWarning("Could not find menu element of name '" + elementToChange + "' inside '" + menuToChange + "'"); } _menu.Recalculate(); } }
protected void SetVariable(GVar var, VariableLocation location, bool doSkip) { if (var == null) { return; } switch (var.type) { case VariableType.Integer: { int _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { if (setVarMethod == SetVarMethod.Formula) { _value = (int)AdvGame.CalculateFormula(AdvGame.ConvertTokens(formula, Options.GetLanguage(), localVariables)); } else { _value = intValue; } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && !string.IsNullOrEmpty(parameterName)) { _value = animator.GetInteger(parameterName); setVarMethod = SetVarMethod.SetValue; } } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } break; } case VariableType.Float: { float _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { if (setVarMethod == SetVarMethod.Formula) { _value = (float)AdvGame.CalculateFormula(AdvGame.ConvertTokens(formula, Options.GetLanguage(), localVariables)); } else { _value = floatValue; } } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && !string.IsNullOrEmpty(parameterName)) { _value = animator.GetFloat(parameterName); setVarMethod = SetVarMethod.SetValue; } } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetFloatValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } break; } case VariableType.Boolean: { int _value = 0; if (setVarMethodIntBool == SetVarMethodIntBool.EnteredHere) { _value = (int)boolValue; } else if (setVarMethodIntBool == SetVarMethodIntBool.SetAsMecanimParameter) { if (animator && !string.IsNullOrEmpty(parameterName)) { if (animator.GetBool(parameterName)) { _value = 1; } } } var.SetValue(_value, SetVarMethod.SetValue); break; } case VariableType.Vector3: { Vector3 newValue = vector3Value; if (setVarMethodVector == SetVarMethodVector.IncreaseByValue) { newValue += var.vector3Val; } var.SetVector3Value(newValue); break; } case VariableType.PopUp: { int _value = 0; if (setVarMethod == SetVarMethod.Formula) { _value = (int)AdvGame.CalculateFormula(AdvGame.ConvertTokens(formula, Options.GetLanguage(), localVariables)); } else if (setVarMethod == SetVarMethod.SetAsRandom) { _value = var.GetNumPopUpValues(); } else { _value = Mathf.Clamp(intValue, 0, var.GetNumPopUpValues() - 1); } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } break; } case VariableType.String: { string _value = string.Empty; if (setVarMethodString == SetVarMethodString.EnteredHere) { _value = AdvGame.ConvertTokens(stringValue, Options.GetLanguage(), localVariables); } 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 (KickStarter.runtimeLanguages.LanguageReadsRightToLeft(Options.GetLanguage()) && _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 { LogWarning("Could not find MenuInput '" + elementName + "' in Menu '" + menuName + "'"); } } var.SetStringValue(_value, lineID); break; } default: break; } var.Upload(location, runtimeVariables); KickStarter.actionListManager.VariableChanged(); }
protected void PerformSaveOrLoad() { ClearAllEvents(); if (saveHandling == SaveHandling.ContinueFromLastSave || saveHandling == SaveHandling.LoadGame) { EventManager.OnFinishLoading += OnFinishLoading; EventManager.OnFailLoading += OnFail; } else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame) { EventManager.OnFinishSaving += OnFinishSaving; EventManager.OnFailSaving += OnFail; } if ((saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.ContinueFromLastSave) && doSelectiveLoad) { KickStarter.saveSystem.SetSelectiveLoadOptions(selectiveLoad); } string newSaveLabel = ""; if (customLabel && ((updateLabel && saveHandling == SaveHandling.OverwriteExistingSave) || saveHandling == AC.SaveHandling.SaveNewGame)) { if (selectSaveType != SelectSaveType.Autosave) { GVar gVar = GlobalVariables.GetVariable(varID); if (gVar != null) { newSaveLabel = gVar.GetValue(Options.GetLanguage()); } else { LogWarning("Could not " + saveHandling.ToString() + " - no variable found."); return; } } } int i = Mathf.Max(0, saveIndex); if (saveHandling == SaveHandling.ContinueFromLastSave) { SaveSystem.ContinueGame(); return; } if (saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.OverwriteExistingSave) { if (selectSaveType == SelectSaveType.Autosave) { if (saveHandling == SaveHandling.LoadGame) { SaveSystem.LoadAutoSave(); return; } else { if (PlayerMenus.IsSavingLocked(this, true)) { OnComplete(); } else { SaveSystem.SaveAutoSave(); } return; } } else if (selectSaveType == SelectSaveType.SlotIndexFromVariable) { GVar gVar = GlobalVariables.GetVariable(slotVarID); if (gVar != null) { i = gVar.val; } else { LogWarning("Could not get save slot index - no variable found."); return; } } } if (!string.IsNullOrEmpty(menuName) && !string.IsNullOrEmpty(elementName)) { MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName); if (menuElement != null && menuElement is MenuSavesList) { MenuSavesList menuSavesList = (MenuSavesList)menuElement; i += menuSavesList.GetOffset(); } else { LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'."); } } else { LogWarning("No SavesList element referenced when trying to find slot slot " + i.ToString()); } if (saveHandling == SaveHandling.LoadGame) { SaveSystem.LoadGame(i, -1, false); } else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame) { if (PlayerMenus.IsSavingLocked(this, true)) { OnComplete(); } else { if (saveHandling == SaveHandling.OverwriteExistingSave) { SaveSystem.SaveGame(i, -1, false, updateLabel, newSaveLabel); } else if (saveHandling == SaveHandling.SaveNewGame) { SaveSystem.SaveNewGame(updateLabel, newSaveLabel); } } } }
/** * <summary>Performs what should happen when the element is clicked on.</summary> * <param name = "_menu">The element's parent Menu</param> * <param name = "_slot">Ignored by this subclass</param> * <param name = "_mouseState">The state of the mouse button</param> */ public override void ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (!_menu.IsClickable()) { return; } base.ProcessClick(_menu, _slot, _mouseState); ShowClick(); if (buttonClickType == AC_ButtonClickType.TurnOffMenu) { _menu.TurnOff(doFade); } else if (buttonClickType == AC_ButtonClickType.Crossfade) { AC.Menu menuToSwitchTo = PlayerMenus.GetMenuWithName(switchMenuTitle); if (menuToSwitchTo != null) { KickStarter.playerMenus.CrossFade(menuToSwitchTo); } else { ACDebug.LogWarning("Cannot find any menu of name '" + switchMenuTitle + "'"); } } else if (buttonClickType == AC_ButtonClickType.OffsetElementSlot) { if (elementToShift != null) { elementToShift.Shift(shiftInventory, shiftAmount); elementToShift.RecalculateSize(_menu.menuSource); _menu.Recalculate(); } else { ACDebug.LogWarning("Cannot find '" + inventoryBoxTitle + "' inside '" + _menu.title + "'"); } } else if (buttonClickType == AC_ButtonClickType.OffsetJournal) { MenuJournal journalToShift = (MenuJournal)PlayerMenus.GetElementWithName(_menu.title, inventoryBoxTitle); if (journalToShift != null) { journalToShift.Shift(shiftInventory, loopJournal, shiftAmount); journalToShift.RecalculateSize(_menu.menuSource); _menu.Recalculate(); } else { ACDebug.LogWarning("Cannot find '" + inventoryBoxTitle + "' inside '" + _menu.title + "'"); } } else if (buttonClickType == AC_ButtonClickType.RunActionList) { if (actionList) { AdvGame.RunActionListAsset(actionList, parameterID, parameterValue); } } else if (buttonClickType == AC_ButtonClickType.CustomScript) { MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState); } else if (buttonClickType == AC_ButtonClickType.SimulateInput) { KickStarter.playerInput.SimulateInput(simulateInput, inputAxis, simulateValue); } }
public override bool ProcessClick(AC.Menu _menu, int _slot, MouseState _mouseState) { if (!_menu.IsClickable() || _mouseState != MouseState.SingleClick) { return(false); } ShowClick(); switch (buttonClickType) { case AC_ButtonClickType.TurnOffMenu: _menu.TurnOff(doFade); break; case AC_ButtonClickType.Crossfade: Menu menuToSwitchTo = PlayerMenus.GetMenuWithName(switchMenuTitle); if (menuToSwitchTo != null) { KickStarter.playerMenus.CrossFade(menuToSwitchTo); } else { ACDebug.LogWarning("Cannot find any menu of name '" + switchMenuTitle + "'"); } break; case AC_ButtonClickType.OffsetElementSlot: if (elementToShift != null) { elementToShift.Shift(shiftInventory, shiftAmount); elementToShift.RecalculateSize(_menu.menuSource); _menu.Recalculate(); } else { ACDebug.LogWarning("Cannot find '" + inventoryBoxTitle + "' inside '" + _menu.title + "'"); } break; case AC_ButtonClickType.OffsetJournal: MenuJournal journalToShift = (MenuJournal)PlayerMenus.GetElementWithName(_menu.title, inventoryBoxTitle); if (journalToShift != null) { journalToShift.Shift(shiftInventory, loopJournal, shiftAmount); journalToShift.RecalculateSize(_menu.menuSource); _menu.Recalculate(); } else { ACDebug.LogWarning("Cannot find '" + inventoryBoxTitle + "' inside '" + _menu.title + "'"); } break; case AC_ButtonClickType.RunActionList: if (actionList) { if (!actionList.canRunMultipleInstances) { KickStarter.actionListAssetManager.EndAssetList(actionList); } AdvGame.RunActionListAsset(actionList, parameterID, parameterValue); } break; case AC_ButtonClickType.CustomScript: MenuSystem.OnElementClick(_menu, this, _slot, (int)_mouseState); break; case AC_ButtonClickType.SimulateInput: KickStarter.playerInput.SimulateInput(simulateInput, inputAxis, simulateValue); break; default: break; } return(base.ProcessClick(_menu, _slot, _mouseState)); }
override public float Run() { if (!KickStarter.settingsManager.useProfiles) { ACDebug.LogWarning("Save game profiles are not enabled - please set in Settings Manager to use this Action."); return(0f); } string newProfileLabel = ""; if ((manageProfileType == ManageProfileType.CreateProfile && useCustomLabel) || manageProfileType == ManageProfileType.RenameProfile) { GVar gVar = GlobalVariables.GetVariable(varID); if (gVar != null) { newProfileLabel = gVar.textVal; } else { ACDebug.LogWarning("Could not " + manageProfileType.ToString() + " - no variable found."); return(0f); } } if (manageProfileType == ManageProfileType.CreateProfile) { KickStarter.options.CreateProfile(newProfileLabel); } else if (manageProfileType == ManageProfileType.DeleteProfile || manageProfileType == ManageProfileType.RenameProfile || manageProfileType == ManageProfileType.SwitchActiveProfile) { if (deleteProfileType == DeleteProfileType.ActiveProfile) { if (manageProfileType == ManageProfileType.DeleteProfile) { KickStarter.saveSystem.DeleteProfile(); } else if (manageProfileType == ManageProfileType.RenameProfile) { KickStarter.options.RenameProfile(newProfileLabel); } return(0f); } else if (deleteProfileType == DeleteProfileType.SetProfileID) { int profileID = Mathf.Max(0, profileIndex); if (manageProfileType == ManageProfileType.DeleteProfile) { KickStarter.saveSystem.DeleteProfileID(profileID); } else if (manageProfileType == ManageProfileType.RenameProfile) { KickStarter.options.RenameProfileID(newProfileLabel, profileID); } else if (manageProfileType == ManageProfileType.SwitchActiveProfile) { Options.SwitchProfileID(profileID); } } else if (deleteProfileType == DeleteProfileType.SetSlotIndex || deleteProfileType == DeleteProfileType.SlotIndexFromVariable) { int i = Mathf.Max(0, profileIndex); if (deleteProfileType == DeleteProfileType.SlotIndexFromVariable) { GVar gVar = GlobalVariables.GetVariable(slotVarID); if (gVar != null) { i = gVar.val; } else { ACDebug.LogWarning("Could not " + manageProfileType.ToString() + " - no variable found."); return(0f); } } bool includeActive = true; if (menuName != "" && elementName != "") { MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName); if (menuElement != null && menuElement is MenuProfilesList) { MenuProfilesList menuProfilesList = (MenuProfilesList)menuElement; if (menuProfilesList.fixedOption) { ACDebug.LogWarning("Cannot refer to ProfilesLst " + elementName + " in Menu " + menuName + ", as it lists a fixed profile ID only!"); return(0f); } i += menuProfilesList.GetOffset(); includeActive = menuProfilesList.showActive; } else { ACDebug.LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'."); } } else { ACDebug.LogWarning("No ProfilesList element referenced when trying to delete profile slot " + i.ToString()); } if (manageProfileType == ManageProfileType.DeleteProfile) { KickStarter.saveSystem.DeleteProfile(i, includeActive); } else if (manageProfileType == ManageProfileType.RenameProfile) { KickStarter.options.RenameProfile(newProfileLabel, i, includeActive); } else if (manageProfileType == ManageProfileType.SwitchActiveProfile) { KickStarter.options.SwitchProfile(i, includeActive); } } } return(0f); }
override public float Run() { if (!isRunning) { isRunning = true; AC.Menu _menu = PlayerMenus.GetMenuWithName(menuToChange); if (_menu != null) { if (changeType == MenuChangeType.TurnOnMenu) { if (_menu.IsManualControlled()) { if (!_menu.TurnOn(doFade)) { // Menu is already on isRunning = false; return(0f); } if (doFade && willWait) { return(_menu.fadeSpeed); } } else { ACDebug.LogWarning("Can only turn on Menus with an Appear Type of Manual, OnInputKey or OnContainer - did you mean 'Unlock Menu'?"); } } else if (changeType == MenuChangeType.TurnOffMenu) { if (_menu.IsManualControlled()) { if (!_menu.TurnOff(doFade)) { // Menu is already off isRunning = false; return(0f); } if (doFade && willWait) { return(_menu.fadeSpeed); } } else { ACDebug.LogWarning("Can only turn off Menus with an Appear Type of Manual, OnInputKey or OnContainer - did you mean 'Lock Menu'?"); } } else if (changeType == MenuChangeType.HideMenuElement || changeType == MenuChangeType.ShowMenuElement) { MenuElement _element = PlayerMenus.GetElementWithName(menuToChange, elementToChange); if (_element != null) { if (changeType == MenuChangeType.HideMenuElement) { _element.isVisible = false; } else { _element.isVisible = true; } _menu.ResetVisibleElements(); _menu.Recalculate(); KickStarter.playerMenus.FindFirstSelectedElement(); } else { ACDebug.LogWarning("Could not find element of name '" + elementToChange + "' on menu '" + menuToChange + "'"); } } else if (changeType == MenuChangeType.LockMenu) { if (doFade) { _menu.TurnOff(true); } else { _menu.ForceOff(); } _menu.isLocked = true; if (doFade && willWait) { return(_menu.fadeSpeed); } } else if (changeType == MenuChangeType.UnlockMenu) { _menu.isLocked = false; } else if (changeType == MenuChangeType.AddJournalPage) { MenuElement _element = PlayerMenus.GetElementWithName(menuToChange, elementToChange); if (_element != null) { if (journalText != "") { if (_element is MenuJournal) { MenuJournal journal = (MenuJournal)_element; JournalPage newPage = new JournalPage(lineID, journalText); journal.AddPage(newPage, onlyAddNewJournal); } else { ACDebug.LogWarning(_element.title + " is not a journal!"); } } else { ACDebug.LogWarning("No journal text to add!"); } } else { ACDebug.LogWarning("Could not find menu element of name '" + elementToChange + "' inside '" + menuToChange + "'"); } } } else if (menuToChange != "") { ACDebug.LogWarning("Could not find menu of name '" + menuToChange + "'"); } } else { isRunning = false; return(0f); } return(0f); }
override public void Skip() { AC.Menu _menu = PlayerMenus.GetMenuWithName(menuToChange); if (_menu != null) { if (changeType == MenuChangeType.TurnOnMenu) { if (_menu.appearType == AppearType.Manual || _menu.appearType == AppearType.OnInputKey) { _menu.TurnOn(false); } } else if (changeType == MenuChangeType.TurnOffMenu) { if (_menu.appearType == AppearType.Manual || _menu.appearType == AppearType.OnInputKey || _menu.appearType == AppearType.OnContainer) { _menu.ForceOff(); } } else if (changeType == MenuChangeType.HideMenuElement || changeType == MenuChangeType.ShowMenuElement) { MenuElement _element = PlayerMenus.GetElementWithName(menuToChange, elementToChange); if (_element != null) { if (changeType == MenuChangeType.HideMenuElement) { _element.isVisible = false; } else { _element.isVisible = true; } _menu.ResetVisibleElements(); _menu.Recalculate(); } } else if (changeType == MenuChangeType.LockMenu) { _menu.isLocked = true; _menu.ForceOff(); } else if (changeType == MenuChangeType.UnlockMenu) { _menu.isLocked = false; } else if (changeType == MenuChangeType.AddJournalPage) { MenuElement _element = PlayerMenus.GetElementWithName(menuToChange, elementToChange); if (_element != null) { if (journalText != "") { if (_element is MenuJournal) { MenuJournal journal = (MenuJournal)_element; JournalPage newPage = new JournalPage(lineID, journalText); journal.AddPage(newPage, onlyAddNewJournal); } } } } } }
override public float Run() { if ((saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.ContinueFromLastSave) && doSelectiveLoad) { KickStarter.saveSystem.SetSelectiveLoadOptions(selectiveLoad); } string newSaveLabel = ""; if (customLabel && ((updateLabel && saveHandling == SaveHandling.OverwriteExistingSave) || saveHandling == AC.SaveHandling.SaveNewGame)) { if (selectSaveType != SelectSaveType.Autosave) { GVar gVar = GlobalVariables.GetVariable(varID); if (gVar != null) { //newSaveLabel = gVar.textVal; newSaveLabel = gVar.GetValue(Options.GetLanguage()); } else { ACDebug.LogWarning("Could not " + saveHandling.ToString() + " - no variable found."); return(0f); } } } int i = Mathf.Max(0, saveIndex); if (saveHandling == SaveHandling.ContinueFromLastSave) { SaveSystem.ContinueGame(); return(0f); } if (saveHandling == SaveHandling.LoadGame || saveHandling == SaveHandling.OverwriteExistingSave) { if (selectSaveType == SelectSaveType.Autosave) { if (saveHandling == SaveHandling.LoadGame) { SaveSystem.LoadAutoSave(); return(0f); } else { if (!PlayerMenus.IsSavingLocked(this)) { SaveSystem.SaveAutoSave(); } else { ACDebug.LogWarning("Cannot save at this time - either blocking ActionLists, a Converation is active, or saving has been manually locked."); } return(0f); } } else if (selectSaveType == SelectSaveType.SlotIndexFromVariable) { GVar gVar = GlobalVariables.GetVariable(slotVarID); if (gVar != null) { i = gVar.val; } else { ACDebug.LogWarning("Could not get save slot index - no variable found."); return(0f); } } } if (menuName != "" && elementName != "") { MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName); if (menuElement != null && menuElement is MenuSavesList) { MenuSavesList menuSavesList = (MenuSavesList)menuElement; i += menuSavesList.GetOffset(); } else { ACDebug.LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'."); } } else { ACDebug.LogWarning("No SavesList element referenced when trying to find slot slot " + i.ToString()); } if (saveHandling == SaveHandling.LoadGame) { SaveSystem.LoadGame(i, -1, false); } else if (saveHandling == SaveHandling.OverwriteExistingSave || saveHandling == SaveHandling.SaveNewGame) { if (!PlayerMenus.IsSavingLocked(this)) { if (saveHandling == SaveHandling.OverwriteExistingSave) { SaveSystem.SaveGame(i, -1, false, updateLabel, newSaveLabel); } else if (saveHandling == SaveHandling.SaveNewGame) { SaveSystem.SaveNewGame(updateLabel, newSaveLabel); } } else { ACDebug.LogWarning("Cannot save at this time - either blocking ActionLists, a Converation is active, or saving has been manually locked."); } } return(0f); }
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, Options.GetLanguage(), localVariables)); } 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, Options.GetLanguage(), localVariables)); } 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.SetFloatValue(_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); int _value = 0; if (setVarMethod == SetVarMethod.Formula) { _value = (int)AdvGame.CalculateFormula(AdvGame.ConvertTokens(formula, Options.GetLanguage(), localVariables)); } else if (setVarMethod == SetVarMethod.SetAsRandom) { if (var.popUps != null) { _value = var.popUps.Length; } } else { _value = intValue; } if (setVarMethod == SetVarMethod.IncreaseByValue && doSkip) { var.RestoreBackupValue(); } var.SetValue(_value, setVarMethod); if (doSkip) { var.BackupValue(); } } else if (var.type == VariableType.String) { string _value = ""; if (setVarMethodString == SetVarMethodString.EnteredHere) { _value = AdvGame.ConvertTokens(stringValue, Options.GetLanguage(), localVariables); } 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 { ACDebug.LogWarning("Could not find MenuInput '" + elementName + "' in Menu '" + menuName + "'"); } } var.SetStringValue(_value); } if (location == VariableLocation.Global) { var.Upload(); } KickStarter.actionListManager.VariableChanged(); }
override public ActionEnd End(List <AC.Action> actions) { int actualNumber = 0; if (saveCheck == SaveCheck.NumberOfSaveGames) { actualNumber = KickStarter.saveSystem.GetNumSaves(includeAutoSaves); } else if (saveCheck == SaveCheck.NumberOfProfiles) { actualNumber = KickStarter.options.GetNumProfiles(); } else if (saveCheck == SaveCheck.IsSlotEmpty) { return(ProcessResult(!SaveSystem.DoesSaveExist(intValue, intValue, !checkByElementIndex), actions)); } else if (saveCheck == SaveCheck.DoesProfileExist) { if (checkByElementIndex) { int i = Mathf.Max(0, intValue); bool includeActive = true; if (menuName != "" && elementName != "") { MenuElement menuElement = PlayerMenus.GetElementWithName(menuName, elementName); if (menuElement != null && menuElement is MenuProfilesList) { MenuProfilesList menuProfilesList = (MenuProfilesList)menuElement; if (menuProfilesList.fixedOption) { ACDebug.LogWarning("Cannot refer to ProfilesLst " + elementName + " in Menu " + menuName + ", as it lists a fixed profile ID only!"); return(ProcessResult(false, actions)); } i += menuProfilesList.GetOffset(); includeActive = menuProfilesList.showActive; } else { ACDebug.LogWarning("Cannot find ProfilesList element '" + elementName + "' in Menu '" + menuName + "'."); } } else { ACDebug.LogWarning("No ProfilesList element referenced when trying to delete profile slot " + i.ToString()); } bool result = KickStarter.options.DoesProfileExist(i, includeActive); return(ProcessResult(result, actions)); } else { // intValue is the profile ID bool result = Options.DoesProfileIDExist(intValue); return(ProcessResult(result, actions)); } } else if (saveCheck == SaveCheck.IsSavingPossible) { return(ProcessResult(!PlayerMenus.IsSavingLocked(this), actions)); } return(ProcessResult(CheckCondition(actualNumber), actions)); }