Ejemplo n.º 1
0
		private void LoadPrefs ()
		{
			if (PlayerPrefs.HasKey (ppKey))
			{
				string optionsBinary = PlayerPrefs.GetString (ppKey);
				optionsData = Serializer.DeserializeObjectBinary <OptionsData> (optionsBinary);
				
				Debug.Log ("PlayerPrefs loaded.");
			}
		}
Ejemplo n.º 2
0
		private void Awake ()
		{
			optionsData = new OptionsData();
			LoadPrefs ();

			if (optionsData.language == 0 && AdvGame.GetReferences () && AdvGame.GetReferences ().speechManager && AdvGame.GetReferences ().speechManager.ignoreOriginalText && AdvGame.GetReferences ().speechManager.languages.Count > 1)
			{
				// Ignore original language
				optionsData.language = 1;
				SavePrefs ();
			}

			OnLevelWasLoaded ();
		}
Ejemplo n.º 3
0
        /**
         * <summary>Gets the options values associated with a specific profile.</summary>
         * <param name = "profileID">A unique identifier for the profile to save to</param>
         * <param name = "showLog">If True, the details of this save will be printed in the Console window</param>
         * <param name = "doSave">If True, and if the profile had no OptionsData to read, then new values will be saved to it</param>
         * <returns>An instance of OptionsData containing the profile's options</returns>
         */
        public static OptionsData LoadPrefsFromID(int profileID, bool showLog = false, bool doSave = true)
        {
            if (DoesProfileIDExist(profileID))
            {
                string optionsSerialized = OptionsFileHandler.LoadOptions(profileID, showLog);

                if (!string.IsNullOrEmpty(optionsSerialized))
                {
                    try
                    {
                        return(Serializer.DeserializeOptionsData(optionsSerialized));
                    }
                    catch (System.Exception e)
                    {
                        ACDebug.LogWarning("Error retrieving OptionsData for profile #" + profileID + " - rebuilding..\nException: " + e);

                        OptionsData fallbackOptionsData = new OptionsData(profileID);
                        if (KickStarter.settingsManager)
                        {
                            fallbackOptionsData = GenerateDefaultOptionsData(profileID);
                        }
                        SavePrefsToID(profileID, fallbackOptionsData);
                        return(fallbackOptionsData);
                    }
                }
            }

            // No data exists, so create new
            if (KickStarter.settingsManager == null)
            {
                return(null);
            }

            OptionsData _optionsData = GenerateDefaultOptionsData(profileID);

            if (doSave)
            {
                optionsData = _optionsData;
                SavePrefs();
            }

            return(_optionsData);
        }
Ejemplo n.º 4
0
        public string GetProfileName(int index = -1, bool includeActive = true)
        {
            if (index == -1 || !KickStarter.settingsManager.useProfiles)
            {
                return(Options.optionsData.label);
            }

            int ID = KickStarter.options.ProfileIndexToID(index, includeActive);

            if (PlayerPrefs.HasKey(GetPrefKeyName(ID)))
            {
                OptionsData tempOptionsData = LoadPrefsFromID(ID, false);
                return(tempOptionsData.label);
            }
            else
            {
                return("");
            }
        }
Ejemplo n.º 5
0
        /**
         * <summary>Gets the name of a specific profile ID.</summary>
         * <param name = "profileID">The profile ID to get the name of</param>
         * <returns>The display name of the profile</returns>
         */
        public string GetProfileIDName(int profileID)
        {
            if (!KickStarter.settingsManager.useProfiles)
            {
                if (Options.optionsData == null)
                {
                    LoadPrefs();
                }
                return(Options.optionsData.label);
            }

            if (DoesProfileIDExist(profileID))
            {
                OptionsData tempOptionsData = LoadPrefsFromID(profileID, false, false);
                return(tempOptionsData.label);
            }
            else
            {
                return("");
            }
        }
Ejemplo n.º 6
0
        /**
         * <summary>Creates a new profile (instance of OptionsData).</summary>
         * <param name = "_label">The name of the new profile.</param>
         */
        public void CreateProfile(string _label = "")
        {
            int newProfileID = FindFirstEmptyProfileID();

            OptionsData newOptionsData = new OptionsData(optionsData, newProfileID);

            if (_label != "")
            {
                newOptionsData.label = _label;
            }
            optionsData = newOptionsData;

            SetActiveProfileID(newProfileID);
            SavePrefs();

            if (Application.isPlaying)
            {
                KickStarter.saveSystem.GatherSaveFiles();
                KickStarter.playerMenus.RecalculateAll();
            }
        }
Ejemplo n.º 7
0
        private void Awake()
        {
            if (KickStarter.settingsManager)
            {
                optionsData = new OptionsData(KickStarter.settingsManager.defaultLanguage, KickStarter.settingsManager.defaultShowSubtitles, KickStarter.settingsManager.defaultSfxVolume, KickStarter.settingsManager.defaultMusicVolume, KickStarter.settingsManager.defaultSpeechVolume);
            }
            else
            {
                optionsData = new OptionsData();
            }
            LoadPrefs();

            if (optionsData.language == 0 && KickStarter.speechManager && KickStarter.speechManager.ignoreOriginalText && KickStarter.speechManager.languages.Count > 1)
            {
                // Ignore original language
                optionsData.language = 1;
                SavePrefs();
            }

            Options.languageNumber = optionsData.language;
            OnLevelWasLoaded();
        }
Ejemplo n.º 8
0
        public static void LoadPrefs()
        {
            if (Application.isPlaying)
            {
                KickStarter.options.CustomLoadOptionsHook();
            }

            optionsData = LoadPrefsFromID(GetActiveProfileID(), Application.isPlaying, true);

            if (optionsData.language == 0 && KickStarter.speechManager && KickStarter.speechManager.ignoreOriginalText && KickStarter.speechManager.languages.Count > 1)
            {
                // Ignore original language
                optionsData.language = 1;
                SavePrefs();
            }

            if (Application.isPlaying)
            {
                KickStarter.saveSystem.GatherSaveFiles();
                PlayerMenus.RecalculateAll();
            }
        }
Ejemplo n.º 9
0
        public static OptionsData LoadPrefsFromID(int ID, bool showLog = false, bool doSave = true)
        {
            if (PlayerPrefs.HasKey(GetPrefKeyName(ID)))
            {
                string optionsSerialized = PlayerPrefs.GetString(GetPrefKeyName(ID));

                if (optionsSerialized != null && optionsSerialized.Length > 0)
                {
                    bool isXML = optionsSerialized.Contains("xml version");
                    if (SaveSystem.GetSaveMethod() == SaveMethod.XML && isXML)
                    {
                        if (showLog)
                        {
                            Debug.Log("PlayerPrefs Key '" + GetPrefKeyName(ID) + "' loaded");
                        }
                        return((OptionsData)Serializer.DeserializeObjectXML <OptionsData> (optionsSerialized));
                    }
                    else if (SaveSystem.GetSaveMethod() == SaveMethod.Binary && !isXML)
                    {
                        if (showLog)
                        {
                            Debug.Log("PlayerPrefs Key '" + GetPrefKeyName(ID) + "' loaded");
                        }
                        return((OptionsData)Serializer.DeserializeObjectBinary <OptionsData> (optionsSerialized));
                    }
                }
            }

            // No data exists, so create new
            OptionsData _optionsData = new OptionsData(KickStarter.settingsManager.defaultLanguage, KickStarter.settingsManager.defaultShowSubtitles, KickStarter.settingsManager.defaultSfxVolume, KickStarter.settingsManager.defaultMusicVolume, KickStarter.settingsManager.defaultSpeechVolume, ID);

            if (doSave)
            {
                optionsData = _optionsData;
                SavePrefs();
            }

            return(_optionsData);
        }
Ejemplo n.º 10
0
        /**
         * Sets the options values to those stored within the active profile.
         */
        public static void LoadPrefs()
        {
            if (Application.isPlaying)
            {
                KickStarter.options.CustomLoadOptionsHook();
            }

            optionsData = LoadPrefsFromID(GetActiveProfileID(), Application.isPlaying, true);
            if (optionsData == null)
            {
                ACDebug.LogWarning("No Options Data found!");
            }
            else
            {
                int numLanguages = (Application.isPlaying) ? KickStarter.runtimeLanguages.Languages.Count : AdvGame.GetReferences().speechManager.languages.Count;
                if (optionsData.language >= numLanguages)
                {
                    if (numLanguages != 0)
                    {
                        ACDebug.LogWarning("Language set to an invalid index - reverting to original language.");
                    }
                    optionsData.language = 0;
                    SavePrefs(false);
                }
                if (optionsData.language == 0 && KickStarter.speechManager && KickStarter.speechManager.ignoreOriginalText && KickStarter.speechManager.languages.Count > 1)
                {
                    // Ignore original language
                    optionsData.language = 1;
                    SavePrefs(false);
                }
            }

            if (Application.isPlaying)
            {
                KickStarter.saveSystem.GatherSaveFiles();
                KickStarter.playerMenus.RecalculateAll();
            }
        }
Ejemplo n.º 11
0
        public static void LoadPrefs()
        {
            if (Application.isPlaying)
            {
                KickStarter.options.CustomLoadOptionsHook ();
            }

            optionsData = LoadPrefsFromID (GetActiveProfileID (), Application.isPlaying, true);

            if (optionsData.language == 0 && KickStarter.speechManager && KickStarter.speechManager.ignoreOriginalText && KickStarter.speechManager.languages.Count > 1)
            {
                // Ignore original language
                optionsData.language = 1;
                SavePrefs ();
            }

            if (Application.isPlaying)
            {
                KickStarter.saveSystem.GatherSaveFiles ();
                PlayerMenus.RecalculateAll ();
            }
        }
Ejemplo n.º 12
0
        public static void SavePrefsToID(int ID, OptionsData _optionsData = null, bool showLog = false)
        {
            if (_optionsData == null)
            {
                _optionsData = Options.optionsData;
            }

            string optionsSerialized = "";
            if (SaveSystem.GetSaveMethod () == SaveMethod.XML)
            {
                optionsSerialized = Serializer.SerializeObjectXML <OptionsData> (_optionsData);
            }
            else
            {
                optionsSerialized = Serializer.SerializeObjectBinary (_optionsData);
            }

            if (optionsSerialized != "")
            {
                PlayerPrefs.SetString (GetPrefKeyName (ID), optionsSerialized);
                if (showLog)
                {
                    Debug.Log ("PlayerPrefs Key '" + GetPrefKeyName (ID) + "' saved");
                }
            }
        }
Ejemplo n.º 13
0
        public void ShowGUI()
        {
            EditorGUILayout.LabelField ("Save game settings", EditorStyles.boldLabel);

            if (saveFileName == "")
            {
                saveFileName = SaveSystem.SetProjectName ();
            }
            maxSaves = EditorGUILayout.IntField ("Max. number of saves:", maxSaves);
            saveFileName = EditorGUILayout.TextField ("Save filename:", saveFileName);
            useProfiles = EditorGUILayout.ToggleLeft ("Enable save game profiles?", useProfiles);
            #if !UNITY_WEBPLAYER && !UNITY_ANDROID && !UNITY_WINRT && !UNITY_WII
            saveTimeDisplay = (SaveTimeDisplay) EditorGUILayout.EnumPopup ("Time display:", saveTimeDisplay);
            takeSaveScreenshots = EditorGUILayout.ToggleLeft ("Take screenshot when saving?", takeSaveScreenshots);
            orderSavesByUpdateTime = EditorGUILayout.ToggleLeft ("Order save lists by update time?", orderSavesByUpdateTime);
            #else
            EditorGUILayout.HelpBox ("Save-game screenshots are disabled for WebPlayer, Windows Store and Android platforms.", MessageType.Info);
            takeSaveScreenshots = false;
            #endif

            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Cutscene settings:", EditorStyles.boldLabel);

            actionListOnStart = ActionListAssetMenu.AssetGUI ("ActionList on start game:", actionListOnStart);
            blackOutWhenSkipping = EditorGUILayout.Toggle ("Black out when skipping?", blackOutWhenSkipping);

            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Character settings:", EditorStyles.boldLabel);

            CreatePlayersGUI ();

            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Interface settings", EditorStyles.boldLabel);

            movementMethod = (MovementMethod) EditorGUILayout.EnumPopup ("Movement method:", movementMethod);
            if (movementMethod == MovementMethod.UltimateFPS && !UltimateFPSIntegration.IsDefinePresent ())
            {
                EditorGUILayout.HelpBox ("The 'UltimateFPSIsPresent' preprocessor define must be declared in the Player Settings.", MessageType.Warning);
            }

            inputMethod = (InputMethod) EditorGUILayout.EnumPopup ("Input method:", inputMethod);
            interactionMethod = (AC_InteractionMethod) EditorGUILayout.EnumPopup ("Interaction method:", interactionMethod);

            if (inputMethod != InputMethod.TouchScreen)
            {
                useOuya = EditorGUILayout.ToggleLeft ("Playing on OUYA platform?", useOuya);
                if (useOuya && !OuyaIntegration.IsDefinePresent ())
                {
                    EditorGUILayout.HelpBox ("The 'OUYAIsPresent' preprocessor define must be declared in the Player Settings.", MessageType.Warning);
                }
                if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction)
                {
                    selectInteractions = (SelectInteractions) EditorGUILayout.EnumPopup ("Select Interactions by:", selectInteractions);
                    if (selectInteractions != SelectInteractions.CyclingCursorAndClickingHotspot)
                    {
                        seeInteractions = (SeeInteractions) EditorGUILayout.EnumPopup ("See Interactions with:", seeInteractions);
                        if (seeInteractions == SeeInteractions.ClickOnHotspot)
                        {
                            stopPlayerOnClickHotspot = EditorGUILayout.ToggleLeft ("Stop player moving when click Hotspot?", stopPlayerOnClickHotspot);
                        }
                    }

                    if (selectInteractions == SelectInteractions.CyclingCursorAndClickingHotspot)
                    {
                        autoCycleWhenInteract = EditorGUILayout.ToggleLeft ("Auto-cycle after an Interaction?", autoCycleWhenInteract);
                    }

                    if (SelectInteractionMethod () == SelectInteractions.ClickingMenu)
                    {
                        clickUpInteractions = EditorGUILayout.ToggleLeft ("Trigger interaction by releasing click?", clickUpInteractions);
                        cancelInteractions = (CancelInteractions) EditorGUILayout.EnumPopup ("Close interactions with:", cancelInteractions);
                    }
                    else
                    {
                        cancelInteractions = CancelInteractions.CursorLeavesMenu;
                    }
                }
            }
            if (interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
            {
                autoCycleWhenInteract = EditorGUILayout.ToggleLeft ("Reset cursor after an Interaction?", autoCycleWhenInteract);
            }

            if (movementMethod == MovementMethod.FirstPerson && inputMethod == InputMethod.TouchScreen)
            {
                // First person dragging only works if cursor is unlocked
                lockCursorOnStart = false;
            }
            else
            {
                lockCursorOnStart = EditorGUILayout.ToggleLeft ("Lock cursor in screen's centre when game begins?", lockCursorOnStart);
                hideLockedCursor = EditorGUILayout.ToggleLeft ("Hide cursor when locked in screen's centre?", hideLockedCursor);
                onlyInteractWhenCursorUnlocked = EditorGUILayout.ToggleLeft ("Disallow Interactions if cursor is locked?", onlyInteractWhenCursorUnlocked);
            }
            if (IsInFirstPerson ())
            {
                disableFreeAimWhenDragging = EditorGUILayout.ToggleLeft ("Disable free-aim when dragging?", disableFreeAimWhenDragging);

                if (movementMethod == MovementMethod.FirstPerson)
                {
                    useFPCamDuringConversations = EditorGUILayout.ToggleLeft ("Run Conversations in first-person?", useFPCamDuringConversations);
                }
            }
            if (inputMethod != InputMethod.TouchScreen)
            {
                runConversationsWithKeys = EditorGUILayout.ToggleLeft ("Dialogue options can be selected with number keys?", runConversationsWithKeys);
            }

            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Inventory settings", EditorStyles.boldLabel);

            if (interactionMethod != AC_InteractionMethod.ContextSensitive)
            {
                inventoryInteractions = (InventoryInteractions) EditorGUILayout.EnumPopup ("Inventory interactions:", inventoryInteractions);

                if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction)
                {
                    if (selectInteractions == SelectInteractions.CyclingCursorAndClickingHotspot)
                    {
                        cycleInventoryCursors = EditorGUILayout.ToggleLeft ("Include Inventory items in Interaction cycles?", cycleInventoryCursors);
                    }
                    else
                    {
                        cycleInventoryCursors = EditorGUILayout.ToggleLeft ("Include Inventory items in Interaction menus?", cycleInventoryCursors);
                    }
                }

                if (inventoryInteractions == InventoryInteractions.Multiple && CanSelectItems (false))
                {
                    selectInvWithUnhandled = EditorGUILayout.ToggleLeft ("Select item if Interaction is unhandled?", selectInvWithUnhandled);
                    if (selectInvWithUnhandled)
                    {
                        CursorManager cursorManager = AdvGame.GetReferences ().cursorManager;
                        if (cursorManager != null && cursorManager.cursorIcons != null && cursorManager.cursorIcons.Count > 0)
                        {
                            selectInvWithIconID = GetIconID ("Select with unhandled:", selectInvWithIconID, cursorManager);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox ("No Interaction cursors defined - please do so in the Cursor Manager.", MessageType.Info);
                        }
                    }

                    giveInvWithUnhandled = EditorGUILayout.ToggleLeft ("Give item if Interaction is unhandled?", giveInvWithUnhandled);
                    if (giveInvWithUnhandled)
                    {
                        CursorManager cursorManager = AdvGame.GetReferences ().cursorManager;
                        if (cursorManager != null && cursorManager.cursorIcons != null && cursorManager.cursorIcons.Count > 0)
                        {
                            giveInvWithIconID = GetIconID ("Give with unhandled:", giveInvWithIconID, cursorManager);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox ("No Interaction cursors defined - please do so in the Cursor Manager.", MessageType.Info);
                        }
                    }
                }
            }

            if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction && selectInteractions != SelectInteractions.ClickingMenu && inventoryInteractions == InventoryInteractions.Multiple)
            {}
            else
            {
                reverseInventoryCombinations = EditorGUILayout.ToggleLeft ("Combine interactions work in reverse?", reverseInventoryCombinations);
            }

            //if (interactionMethod != AC_InteractionMethod.ChooseHotspotThenInteraction || inventoryInteractions == InventoryInteractions.Single)
            if (CanSelectItems (false))
            {
                inventoryDragDrop = EditorGUILayout.ToggleLeft ("Drag and drop Inventory interface?", inventoryDragDrop);
                if (!inventoryDragDrop)
                {
                    if (interactionMethod == AC_InteractionMethod.ContextSensitive || inventoryInteractions == InventoryInteractions.Single)
                    {
                        rightClickInventory = (RightClickInventory) EditorGUILayout.EnumPopup ("Right-click active item:", rightClickInventory);
                    }
                }
                else if (inventoryInteractions == AC.InventoryInteractions.Single)
                {
                    inventoryDropLook = EditorGUILayout.ToggleLeft ("Can drop an Item onto itself to Examine it?", inventoryDropLook);
                }
            }

            if (CanSelectItems (false) && !inventoryDragDrop)
            {
                inventoryDisableLeft = EditorGUILayout.ToggleLeft ("Left-click deselects active item?", inventoryDisableLeft);

                if (movementMethod == MovementMethod.PointAndClick && !inventoryDisableLeft)
                {
                    canMoveWhenActive = EditorGUILayout.ToggleLeft ("Can move player if an Item is active?", canMoveWhenActive);
                }
            }

            inventoryActiveEffect = (InventoryActiveEffect) EditorGUILayout.EnumPopup ("Active cursor FX:", inventoryActiveEffect);
            if (inventoryActiveEffect == InventoryActiveEffect.Pulse)
            {
                inventoryPulseSpeed = EditorGUILayout.Slider ("Active FX pulse speed:", inventoryPulseSpeed, 0.5f, 2f);
            }

            activeWhenUnhandled = EditorGUILayout.ToggleLeft ("Show Active FX when an Interaction is unhandled?", activeWhenUnhandled);
            canReorderItems = EditorGUILayout.ToggleLeft ("Items can be re-ordered in Menu?", canReorderItems);
            hideSelectedFromMenu = EditorGUILayout.ToggleLeft ("Hide currently active Item in Menu?", hideSelectedFromMenu);
            activeWhenHover = EditorGUILayout.ToggleLeft ("Show Active FX when Cursor hovers over Item in Menu?", activeWhenHover);

            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Required inputs:", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox ("The following inputs are available for the chosen interface settings:" + GetInputList (), MessageType.Info);

            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Movement settings", EditorStyles.boldLabel);

            if ((inputMethod == InputMethod.TouchScreen && movementMethod != MovementMethod.PointAndClick) || movementMethod == MovementMethod.Drag)
            {
                dragWalkThreshold = EditorGUILayout.FloatField ("Walk threshold:", dragWalkThreshold);
                dragRunThreshold = EditorGUILayout.FloatField ("Run threshold:", dragRunThreshold);

                if (inputMethod == InputMethod.TouchScreen && movementMethod == MovementMethod.FirstPerson)
                {
                    freeAimTouchSpeed = EditorGUILayout.FloatField ("Freelook speed:", freeAimTouchSpeed);
                }

                drawDragLine = EditorGUILayout.Toggle ("Draw drag line?", drawDragLine);
                if (drawDragLine)
                {
                    dragLineWidth = EditorGUILayout.FloatField ("Drag line width:", dragLineWidth);
                    dragLineColor = EditorGUILayout.ColorField ("Drag line colour:", dragLineColor);
                }
            }
            else if (movementMethod == MovementMethod.Direct)
            {
                magnitudeAffectsDirect = EditorGUILayout.ToggleLeft ("Input magnitude affects speed?", magnitudeAffectsDirect);
                directMovementType = (DirectMovementType) EditorGUILayout.EnumPopup ("Direct-movement type:", directMovementType);
                if (directMovementType == DirectMovementType.RelativeToCamera)
                {
                    limitDirectMovement = (LimitDirectMovement) EditorGUILayout.EnumPopup ("Movement limitation:", limitDirectMovement);
                    if (cameraPerspective == CameraPerspective.ThreeD)
                    {
                        directMovementPerspective = EditorGUILayout.ToggleLeft ("Account for player's position on screen?", directMovementPerspective);
                    }
                }
            }
            else if (movementMethod == MovementMethod.PointAndClick)
            {
                clickPrefab = (Transform) EditorGUILayout.ObjectField ("Click marker:", clickPrefab, typeof (Transform), false);
                walkableClickRange = EditorGUILayout.Slider ("NavMesh search %:", walkableClickRange, 0f, 1f);
                doubleClickMovement = EditorGUILayout.Toggle ("Double-click to move?", doubleClickMovement);
            }
            if (movementMethod == MovementMethod.StraightToCursor)
            {
                dragRunThreshold = EditorGUILayout.FloatField ("Run threshold:", dragRunThreshold);
                singleTapStraight = EditorGUILayout.ToggleLeft ("Single-clicking also moves player?", singleTapStraight);
                if (singleTapStraight)
                {
                    singleTapStraightPathfind = EditorGUILayout.ToggleLeft ("Pathfind when single-clicking?", singleTapStraightPathfind);
                }
            }
            if (movementMethod == MovementMethod.FirstPerson && inputMethod == InputMethod.TouchScreen)
            {
                dragAffects = (DragAffects) EditorGUILayout.EnumPopup ("Touch-drag affects:", dragAffects);
            }
            if ((movementMethod == MovementMethod.Direct || movementMethod == MovementMethod.FirstPerson) && inputMethod != InputMethod.TouchScreen)
            {
                jumpSpeed = EditorGUILayout.Slider ("Jump speed:", jumpSpeed, 1f, 10f);
            }

            destinationAccuracy = EditorGUILayout.Slider ("Destination accuracy:", destinationAccuracy, 0f, 1f);
            if (destinationAccuracy == 1f && movementMethod != MovementMethod.StraightToCursor)
            {
                experimentalAccuracy = EditorGUILayout.ToggleLeft ("Attempt to be super-accurate? (Experimental)", experimentalAccuracy);
            }

            if (inputMethod == InputMethod.TouchScreen)
            {
                EditorGUILayout.Space ();
                EditorGUILayout.LabelField ("Touch Screen settings", EditorStyles.boldLabel);

                if (movementMethod != MovementMethod.FirstPerson)
                {
                    offsetTouchCursor = EditorGUILayout.Toggle ("Drag cursor with touch?", offsetTouchCursor);
                }
                doubleTapHotspots = EditorGUILayout.Toggle ("Double-tap Hotspots?", doubleTapHotspots);
            }

            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Camera settings", EditorStyles.boldLabel);

            cameraPerspective_int = (int) cameraPerspective;
            cameraPerspective_int = EditorGUILayout.Popup ("Camera perspective:", cameraPerspective_int, cameraPerspective_list);
            cameraPerspective = (CameraPerspective) cameraPerspective_int;
            if (movementMethod == MovementMethod.FirstPerson)
            {
                cameraPerspective = CameraPerspective.ThreeD;
            }
            if (cameraPerspective == CameraPerspective.TwoD)
            {
                movingTurning = (MovingTurning) EditorGUILayout.EnumPopup ("Moving and turning:", movingTurning);
                if (movingTurning == MovingTurning.TopDown || movingTurning == MovingTurning.Unity2D)
                {
                    verticalReductionFactor = EditorGUILayout.Slider ("Vertical movement factor:", verticalReductionFactor, 0.1f, 1f);
                }
            }

            forceAspectRatio = EditorGUILayout.Toggle ("Force aspect ratio?", forceAspectRatio);
            if (forceAspectRatio)
            {
                wantedAspectRatio = EditorGUILayout.FloatField ("Aspect ratio:", wantedAspectRatio);
                #if UNITY_IPHONE
                landscapeModeOnly = EditorGUILayout.Toggle ("Landscape-mode only?", landscapeModeOnly);
                #endif
            }

            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Hotpot settings", EditorStyles.boldLabel);

            hotspotDetection = (HotspotDetection) EditorGUILayout.EnumPopup ("Hotspot detection method:", hotspotDetection);
            if (hotspotDetection == HotspotDetection.PlayerVicinity && (movementMethod == MovementMethod.Direct || IsInFirstPerson ()))
            {
                hotspotsInVicinity = (HotspotsInVicinity) EditorGUILayout.EnumPopup ("Hotspots in vicinity:", hotspotsInVicinity);
            }
            else if (hotspotDetection == HotspotDetection.MouseOver)
            {
                scaleHighlightWithMouseProximity = EditorGUILayout.ToggleLeft ("Highlight Hotspots based on cursor proximity?", scaleHighlightWithMouseProximity);
                if (scaleHighlightWithMouseProximity)
                {
                    highlightProximityFactor = EditorGUILayout.FloatField ("Cursor proximity factor:", highlightProximityFactor);
                }
            }

            if (cameraPerspective != CameraPerspective.TwoD)
            {
                playerFacesHotspots = EditorGUILayout.ToggleLeft ("Player turns head to active Hotspot?", playerFacesHotspots);
            }

            hotspotIconDisplay = (HotspotIconDisplay) EditorGUILayout.EnumPopup ("Display Hotspot icon:", hotspotIconDisplay);
            if (hotspotIconDisplay != HotspotIconDisplay.Never)
            {
                if (cameraPerspective != CameraPerspective.TwoD)
                {
                    occludeIcons = EditorGUILayout.ToggleLeft ("Don't show behind Colliders?", occludeIcons);
                }
                hotspotIcon = (HotspotIcon) EditorGUILayout.EnumPopup ("Hotspot icon type:", hotspotIcon);
                if (hotspotIcon == HotspotIcon.Texture)
                {
                    hotspotIconTexture = (Texture2D) EditorGUILayout.ObjectField ("Hotspot icon texture:", hotspotIconTexture, typeof (Texture2D), false);
                }
                hotspotIconSize = EditorGUILayout.FloatField ("Hotspot icon size:", hotspotIconSize);
                if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction &&
                    selectInteractions != SelectInteractions.CyclingCursorAndClickingHotspot &&
                    hotspotIconDisplay != HotspotIconDisplay.OnlyWhenFlashing)
                {
                    hideIconUnderInteractionMenu = EditorGUILayout.ToggleLeft ("Hide when Interaction Menus are visible?", hideIconUnderInteractionMenu);
                }
            }

            #if UNITY_5
            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Audio settings", EditorStyles.boldLabel);
            volumeControl = (VolumeControl) EditorGUILayout.EnumPopup ("Volume controlled by:", volumeControl);
            if (volumeControl == VolumeControl.AudioMixerGroups)
            {
                musicMixerGroup = (AudioMixerGroup) EditorGUILayout.ObjectField ("Music mixer:", musicMixerGroup, typeof (AudioMixerGroup), false);
                sfxMixerGroup = (AudioMixerGroup) EditorGUILayout.ObjectField ("SFX mixer:", sfxMixerGroup, typeof (AudioMixerGroup), false);
                speechMixerGroup = (AudioMixerGroup) EditorGUILayout.ObjectField ("Speech mixer:", speechMixerGroup, typeof (AudioMixerGroup), false);
                musicAttentuationParameter = EditorGUILayout.TextField ("Music atten. parameter:", musicAttentuationParameter);
                sfxAttentuationParameter = EditorGUILayout.TextField ("SFX atten. parameter:", sfxAttentuationParameter);
                speechAttentuationParameter = EditorGUILayout.TextField ("Speech atten. parameter:", speechAttentuationParameter);
            }
            #endif

            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Raycast settings", EditorStyles.boldLabel);
            navMeshRaycastLength = EditorGUILayout.FloatField ("NavMesh ray length:", navMeshRaycastLength);
            hotspotRaycastLength = EditorGUILayout.FloatField ("Hotspot ray length:", hotspotRaycastLength);
            moveableRaycastLength = EditorGUILayout.FloatField ("Moveable ray length:", moveableRaycastLength);

            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Layer names", EditorStyles.boldLabel);

            hotspotLayer = EditorGUILayout.TextField ("Hotspot:", hotspotLayer);
            navMeshLayer = EditorGUILayout.TextField ("Nav mesh:", navMeshLayer);
            if (cameraPerspective == CameraPerspective.TwoPointFiveD)
            {
                backgroundImageLayer = EditorGUILayout.TextField ("Background image:", backgroundImageLayer);
            }
            deactivatedLayer = EditorGUILayout.TextField ("Deactivated:", deactivatedLayer);

            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Loading scene", EditorStyles.boldLabel);
            useLoadingScreen = EditorGUILayout.Toggle ("Use loading screen?", useLoadingScreen);
            if (useLoadingScreen)
            {
                loadingSceneIs = (ChooseSceneBy) EditorGUILayout.EnumPopup ("Choose loading scene by:", loadingSceneIs);
                if (loadingSceneIs == ChooseSceneBy.Name)
                {
                    loadingSceneName = EditorGUILayout.TextField ("Loading scene name:", loadingSceneName);
                }
                else
                {
                    loadingScene = EditorGUILayout.IntField ("Loading screen scene:", loadingScene);
                }
            }

            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Options data", EditorStyles.boldLabel);

            optionsData = Options.LoadPrefsFromID (0, false, true);
            if (optionsData == null)
            {
                Debug.Log ("Saved new prefs");
                Options.SaveDefaultPrefs (optionsData);
            }

            defaultSpeechVolume = optionsData.speechVolume = EditorGUILayout.Slider ("Speech volume:", optionsData.speechVolume, 0f, 1f);
            defaultMusicVolume = optionsData.musicVolume = EditorGUILayout.Slider ("Music volume:", optionsData.musicVolume, 0f, 1f);
            defaultSfxVolume = optionsData.sfxVolume = EditorGUILayout.Slider ("SFX volume:", optionsData.sfxVolume, 0f, 1f);
            defaultShowSubtitles = optionsData.showSubtitles = EditorGUILayout.Toggle ("Show subtitles?", optionsData.showSubtitles);
            defaultLanguage = optionsData.language = EditorGUILayout.IntField ("Language:", optionsData.language);

            Options.SaveDefaultPrefs (optionsData);

            if (GUILayout.Button ("Reset options data"))
            {
                optionsData = new OptionsData ();

                optionsData.language = 0;
                optionsData.speechVolume = 1f;
                optionsData.musicVolume = 0.6f;
                optionsData.sfxVolume = 0.9f;
                optionsData.showSubtitles = false;

                Options.SavePrefsToID (0, optionsData, true);
            }

            EditorGUILayout.Space ();
            EditorGUILayout.LabelField ("Debug settings", EditorStyles.boldLabel);
            showActiveActionLists = EditorGUILayout.ToggleLeft ("List active ActionLists in Game window?", showActiveActionLists);
            showHierarchyIcons = EditorGUILayout.ToggleLeft ("Show icons in Hierarchy window?", showHierarchyIcons);

            if (GUI.changed)
            {
                EditorUtility.SetDirty (this);
            }
        }
Ejemplo n.º 14
0
		public void ShowGUI ()
		{
			EditorGUILayout.LabelField ("Save game settings", EditorStyles.boldLabel);
			
			if (saveFileName == "")
			{
				saveFileName = SaveSystem.SetProjectName ();
			}
			saveFileName = EditorGUILayout.TextField ("Save filename:", saveFileName);
			#if !UNITY_WEBPLAYER && !UNITY_ANDROID
			saveTimeDisplay = (SaveTimeDisplay) EditorGUILayout.EnumPopup ("Time display:", saveTimeDisplay);
			takeSaveScreenshots = EditorGUILayout.ToggleLeft ("Take screenshot when saving?", takeSaveScreenshots);
			#else
			EditorGUILayout.HelpBox ("Save-game screenshots are disabled for WebPlayer and Android platforms.", MessageType.Info);
			takeSaveScreenshots = false;
			#endif
			
			EditorGUILayout.Space ();
			EditorGUILayout.LabelField ("Cutscene settings:", EditorStyles.boldLabel);
			
			actionListOnStart = (ActionListAsset) EditorGUILayout.ObjectField ("ActionList on start game:", actionListOnStart, typeof (ActionListAsset), false);
			blackOutWhenSkipping = EditorGUILayout.Toggle ("Black out when skipping?", blackOutWhenSkipping);
			
			EditorGUILayout.Space ();
			EditorGUILayout.LabelField ("Character settings:", EditorStyles.boldLabel);
			
			CreatePlayersGUI ();
			
			EditorGUILayout.Space ();
			EditorGUILayout.LabelField ("Interface settings", EditorStyles.boldLabel);
			
			movementMethod = (MovementMethod) EditorGUILayout.EnumPopup ("Movement method:", movementMethod);
			if (movementMethod == MovementMethod.UltimateFPS && !UltimateFPSIntegration.IsDefinePresent ())
			{
				EditorGUILayout.HelpBox ("The 'UltimateFPSIsPresent' preprocessor define must be declared in the Player Settings.", MessageType.Warning);
			}

			inputMethod = (InputMethod) EditorGUILayout.EnumPopup ("Input method:", inputMethod);
			interactionMethod = (AC_InteractionMethod) EditorGUILayout.EnumPopup ("Interaction method:", interactionMethod);
			
			if (inputMethod != InputMethod.TouchScreen)
			{
				useOuya = EditorGUILayout.ToggleLeft ("Playing on OUYA platform?", useOuya);
				if (useOuya && !OuyaIntegration.IsDefinePresent ())
				{
					EditorGUILayout.HelpBox ("The 'OUYAIsPresent' preprocessor define must be declared in the Player Settings.", MessageType.Warning);
				}
				if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction)
				{
					selectInteractions = (SelectInteractions) EditorGUILayout.EnumPopup ("Select Interactions by:", selectInteractions);
					if (selectInteractions != SelectInteractions.CyclingCursorAndClickingHotspot)
					{
						seeInteractions = (SeeInteractions) EditorGUILayout.EnumPopup ("See Interactions with:", seeInteractions);
					}
					if (selectInteractions == SelectInteractions.CyclingCursorAndClickingHotspot)
					{
						cycleInventoryCursors = EditorGUILayout.ToggleLeft ("Cycle through Inventory items too?", cycleInventoryCursors);
						autoCycleWhenInteract = EditorGUILayout.ToggleLeft ("Auto-cycle after an Interaction?", autoCycleWhenInteract);
					}
				
					if (SelectInteractionMethod () == SelectInteractions.ClickingMenu)
					{
						cancelInteractions = (CancelInteractions) EditorGUILayout.EnumPopup ("Close interactions with:", cancelInteractions);
					}
					else
					{
						cancelInteractions = CancelInteractions.CursorLeavesMenus;
					}
				}
			}
			if (interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
			{
				autoCycleWhenInteract = EditorGUILayout.ToggleLeft ("Reset cursor after an Interaction?", autoCycleWhenInteract);
			}
			lockCursorOnStart = EditorGUILayout.ToggleLeft ("Lock cursor in screen's centre when game begins?", lockCursorOnStart);
			hideLockedCursor = EditorGUILayout.ToggleLeft ("Hide cursor when locked in screen's centre?", hideLockedCursor);
			if (IsInFirstPerson ())
			{
				disableFreeAimWhenDragging = EditorGUILayout.ToggleLeft ("Disable free-aim when dragging?", disableFreeAimWhenDragging);
			}
			
			EditorGUILayout.Space ();
			EditorGUILayout.LabelField ("Inventory settings", EditorStyles.boldLabel);
			
			reverseInventoryCombinations = EditorGUILayout.ToggleLeft ("Combine interactions work in reverse?", reverseInventoryCombinations);
			if (interactionMethod != AC_InteractionMethod.ContextSensitive)
			{
				inventoryInteractions = (InventoryInteractions) EditorGUILayout.EnumPopup ("Inventory interactions:", inventoryInteractions);
			}
			if (interactionMethod != AC_InteractionMethod.ChooseHotspotThenInteraction || inventoryInteractions == InventoryInteractions.Single)
			{
				inventoryDragDrop = EditorGUILayout.ToggleLeft ("Drag and drop Inventory interface?", inventoryDragDrop);
				if (!inventoryDragDrop)
				{
					inventoryDisableLeft = EditorGUILayout.ToggleLeft ("Left-click deselects active item?", inventoryDisableLeft);
					if (interactionMethod == AC_InteractionMethod.ContextSensitive || inventoryInteractions == InventoryInteractions.Single)
					{
						rightClickInventory = (RightClickInventory) EditorGUILayout.EnumPopup ("Right-click active item:", rightClickInventory);
					}
					
					if (movementMethod == MovementMethod.PointAndClick)
					{
						canMoveWhenActive = EditorGUILayout.ToggleLeft ("Can move player if an Item is active?", canMoveWhenActive);
					}
				}
				else
				{
					inventoryDropLook = EditorGUILayout.ToggleLeft ("Can drop an Item onto itself to Examine it?", inventoryDropLook);
				}
				inventoryActiveEffect = (InventoryActiveEffect) EditorGUILayout.EnumPopup ("Active cursor FX:", inventoryActiveEffect);
				if (inventoryActiveEffect == InventoryActiveEffect.Pulse)
				{
					inventoryPulseSpeed = EditorGUILayout.Slider ("Active FX pulse speed:", inventoryPulseSpeed, 0.5f, 2f);
				}
				activeWhenUnhandled = EditorGUILayout.ToggleLeft ("Show Active FX when an Interaction is unhandled?", activeWhenUnhandled);
				canReorderItems = EditorGUILayout.ToggleLeft ("Items can be re-ordered in Menu?", canReorderItems);
				hideSelectedFromMenu = EditorGUILayout.ToggleLeft ("Hide currently active Item in Menu?", hideSelectedFromMenu);
			}
			activeWhenHover = EditorGUILayout.ToggleLeft ("Show Active FX when Cursor hovers over Item in Menu?", activeWhenHover);
			
			EditorGUILayout.Space ();
			EditorGUILayout.LabelField ("Required inputs:", EditorStyles.boldLabel);
			EditorGUILayout.HelpBox ("The following inputs are available for the chosen interface settings:" + GetInputList (), MessageType.Info);
			
			EditorGUILayout.Space ();
			EditorGUILayout.LabelField ("Movement settings", EditorStyles.boldLabel);
			
			if ((inputMethod == InputMethod.TouchScreen && movementMethod != MovementMethod.PointAndClick) || movementMethod == MovementMethod.Drag)
			{
				dragWalkThreshold = EditorGUILayout.FloatField ("Walk threshold:", dragWalkThreshold);
				dragRunThreshold = EditorGUILayout.FloatField ("Run threshold:", dragRunThreshold);
				
				if (inputMethod == InputMethod.TouchScreen && movementMethod == MovementMethod.FirstPerson)
				{
					freeAimTouchSpeed = EditorGUILayout.FloatField ("Freelook speed:", freeAimTouchSpeed);
				}
				
				drawDragLine = EditorGUILayout.Toggle ("Draw drag line?", drawDragLine);
				if (drawDragLine)
				{
					dragLineWidth = EditorGUILayout.FloatField ("Drag line width:", dragLineWidth);
					dragLineColor = EditorGUILayout.ColorField ("Drag line colour:", dragLineColor);
				}
			}
			else if (movementMethod == MovementMethod.Direct)
			{
				directMovementType = (DirectMovementType) EditorGUILayout.EnumPopup ("Direct-movement type:", directMovementType);
				if (directMovementType == DirectMovementType.RelativeToCamera)
				{
					limitDirectMovement = (LimitDirectMovement) EditorGUILayout.EnumPopup ("Movement limitation:", limitDirectMovement);
				}
			}
			else if (movementMethod == MovementMethod.PointAndClick)
			{
				clickPrefab = (Transform) EditorGUILayout.ObjectField ("Click marker:", clickPrefab, typeof (Transform), false);
				walkableClickRange = EditorGUILayout.Slider ("NavMesh search %:", walkableClickRange, 0f, 1f);
				doubleClickMovement = EditorGUILayout.Toggle ("Double-click to move?", doubleClickMovement);
			}
			if (movementMethod == MovementMethod.StraightToCursor)
			{
				dragRunThreshold = EditorGUILayout.FloatField ("Run threshold:", dragRunThreshold);
				singleTapStraight = EditorGUILayout.Toggle ("Single-click works too?", singleTapStraight);
			}
			if (movementMethod == MovementMethod.FirstPerson && inputMethod == InputMethod.TouchScreen)
			{
				dragAffects = (DragAffects) EditorGUILayout.EnumPopup ("Touch-drag affects:", dragAffects);
			}
			if ((movementMethod == MovementMethod.Direct || movementMethod == MovementMethod.FirstPerson) && inputMethod != InputMethod.TouchScreen)
			{
				jumpSpeed = EditorGUILayout.Slider ("Jump speed:", jumpSpeed, 1f, 10f);
			}
			
			destinationAccuracy = EditorGUILayout.Slider ("Destination accuracy:", destinationAccuracy, 0f, 1f);
			
			if (inputMethod == InputMethod.TouchScreen)
			{
				EditorGUILayout.Space ();
				EditorGUILayout.LabelField ("Touch Screen settings", EditorStyles.boldLabel);
				
				offsetTouchCursor = EditorGUILayout.Toggle ("Drag cursor with touch?", offsetTouchCursor);
				doubleTapHotspots = EditorGUILayout.Toggle ("Double-tap Hotspots?", doubleTapHotspots);
			}
			
			EditorGUILayout.Space ();
			EditorGUILayout.LabelField ("Camera settings", EditorStyles.boldLabel);
			
			cameraPerspective_int = (int) cameraPerspective;
			cameraPerspective_int = EditorGUILayout.Popup ("Camera perspective:", cameraPerspective_int, cameraPerspective_list);
			cameraPerspective = (CameraPerspective) cameraPerspective_int;
			if (movementMethod == MovementMethod.FirstPerson)
			{
				cameraPerspective = CameraPerspective.ThreeD;
			}
			if (cameraPerspective == CameraPerspective.TwoD)
			{
				movingTurning = (MovingTurning) EditorGUILayout.EnumPopup ("Moving and turning:", movingTurning);
				if (movingTurning == MovingTurning.TopDown || movingTurning == MovingTurning.Unity2D)
				{
					verticalReductionFactor = EditorGUILayout.Slider ("Vertical movement factor:", verticalReductionFactor, 0.1f, 1f);
				}
			}
			
			forceAspectRatio = EditorGUILayout.Toggle ("Force aspect ratio?", forceAspectRatio);
			if (forceAspectRatio)
			{
				wantedAspectRatio = EditorGUILayout.FloatField ("Aspect ratio:", wantedAspectRatio);
				#if UNITY_IPHONE
				landscapeModeOnly = EditorGUILayout.Toggle ("Landscape-mode only?", landscapeModeOnly);
				#endif
			}
			
			EditorGUILayout.Space ();
			EditorGUILayout.LabelField ("Hotpot settings", EditorStyles.boldLabel);
			
			hotspotDetection = (HotspotDetection) EditorGUILayout.EnumPopup ("Hotspot detection method:", hotspotDetection);
			
			if (hotspotDetection == HotspotDetection.PlayerVicinity && (movementMethod == MovementMethod.Direct || IsInFirstPerson ()))
			{
				hotspotsInVicinity = (HotspotsInVicinity) EditorGUILayout.EnumPopup ("Hotspots in vicinity:", hotspotsInVicinity);
			}
			
			if (cameraPerspective != CameraPerspective.TwoD)
			{
				playerFacesHotspots = EditorGUILayout.Toggle ("Player turns head to active?", playerFacesHotspots);
			}
			
			hotspotIconDisplay = (HotspotIconDisplay) EditorGUILayout.EnumPopup ("Display Hotspot icon:", hotspotIconDisplay);
			if (hotspotIconDisplay != HotspotIconDisplay.Never)
			{
				hotspotIcon = (HotspotIcon) EditorGUILayout.EnumPopup ("Hotspot icon type:", hotspotIcon);
				if (hotspotIcon == HotspotIcon.Texture)
				{
					hotspotIconTexture = (Texture2D) EditorGUILayout.ObjectField ("Hotspot icon texture:", hotspotIconTexture, typeof (Texture2D), false);
				}
				hotspotIconSize = EditorGUILayout.FloatField ("Hotspot icon size:", hotspotIconSize);
			}
			
			EditorGUILayout.Space ();
			EditorGUILayout.LabelField ("Raycast settings", EditorStyles.boldLabel);
			navMeshRaycastLength = EditorGUILayout.FloatField ("NavMesh ray length:", navMeshRaycastLength);
			hotspotRaycastLength = EditorGUILayout.FloatField ("Hotspot ray length:", hotspotRaycastLength);
			moveableRaycastLength = EditorGUILayout.FloatField ("Moveable ray length:", moveableRaycastLength);
			
			EditorGUILayout.Space ();
			EditorGUILayout.LabelField ("Layer names", EditorStyles.boldLabel);
			
			hotspotLayer = EditorGUILayout.TextField ("Hotspot:", hotspotLayer);
			navMeshLayer = EditorGUILayout.TextField ("Nav mesh:", navMeshLayer);
			if (cameraPerspective == CameraPerspective.TwoPointFiveD)
			{
				backgroundImageLayer = EditorGUILayout.TextField ("Background image:", backgroundImageLayer);
			}
			deactivatedLayer = EditorGUILayout.TextField ("Deactivated:", deactivatedLayer);
			
			EditorGUILayout.Space ();
			EditorGUILayout.LabelField ("Loading scene", EditorStyles.boldLabel);
			useLoadingScreen = EditorGUILayout.Toggle ("Use loading screen?", useLoadingScreen);
			if (useLoadingScreen)
			{
				loadingSceneIs = (ChooseSceneBy) EditorGUILayout.EnumPopup ("Choose loading scene by:", loadingSceneIs);
				if (loadingSceneIs == ChooseSceneBy.Name)
				{
					loadingSceneName = EditorGUILayout.TextField ("Loading scene name:", loadingSceneName);
				}
				else
				{
					loadingScene = EditorGUILayout.IntField ("Loading screen scene:", loadingScene);
				}
			}
			
			EditorGUILayout.Space ();
			EditorGUILayout.LabelField ("Options data", EditorStyles.boldLabel);
			
			if (!PlayerPrefs.HasKey (ppKey))
			{
				optionsData = new OptionsData ();
				optionsBinary = Serializer.SerializeObjectBinary (optionsData);
				PlayerPrefs.SetString (ppKey, optionsBinary);
			}
			
			optionsBinary = PlayerPrefs.GetString (ppKey);
			optionsData = Serializer.DeserializeObjectBinary <OptionsData> (optionsBinary);
			
			optionsData.speechVolume = EditorGUILayout.Slider ("Speech volume:", optionsData.speechVolume, 0f, 1f);
			optionsData.musicVolume = EditorGUILayout.Slider ("Music volume:", optionsData.musicVolume, 0f, 1f);
			optionsData.sfxVolume = EditorGUILayout.Slider ("SFX volume:", optionsData.sfxVolume, 0f, 1f);
			optionsData.showSubtitles = EditorGUILayout.Toggle ("Show subtitles?", optionsData.showSubtitles);
			optionsData.language = EditorGUILayout.IntField ("Language:", optionsData.language);
			
			optionsBinary = Serializer.SerializeObjectBinary (optionsData);
			PlayerPrefs.SetString (ppKey, optionsBinary);
			
			if (GUILayout.Button ("Reset options data"))
			{
				PlayerPrefs.DeleteKey ("Options");
				optionsData = new OptionsData ();
				Debug.Log ("PlayerPrefs cleared");
			}
			
			if (GUI.changed)
			{
				EditorUtility.SetDirty (this);
			}
		}
Ejemplo n.º 15
0
        public static OptionsData LoadPrefsFromID(int ID, bool showLog = false, bool doSave = true)
        {
            if (PlayerPrefs.HasKey (GetPrefKeyName (ID)))
            {
                string optionsSerialized = PlayerPrefs.GetString (GetPrefKeyName (ID));

                if (optionsSerialized != null && optionsSerialized.Length > 0)
                {
                    bool isXML = optionsSerialized.Contains ("xml version");
                    if (SaveSystem.GetSaveMethod () == SaveMethod.XML && isXML)
                    {
                        if (showLog)
                        {
                            Debug.Log ("PlayerPrefs Key '" + GetPrefKeyName (ID) + "' loaded");
                        }
                        return (OptionsData) Serializer.DeserializeObjectXML <OptionsData> (optionsSerialized);
                    }
                    else if (SaveSystem.GetSaveMethod () == SaveMethod.Binary && !isXML)
                    {
                        if (showLog)
                        {
                            Debug.Log ("PlayerPrefs Key '" + GetPrefKeyName (ID) + "' loaded");
                        }
                        return (OptionsData) Serializer.DeserializeObjectBinary <OptionsData> (optionsSerialized);
                    }
                }
            }

            // No data exists, so create new
            OptionsData _optionsData = new OptionsData (KickStarter.settingsManager.defaultLanguage, KickStarter.settingsManager.defaultShowSubtitles, KickStarter.settingsManager.defaultSfxVolume, KickStarter.settingsManager.defaultMusicVolume, KickStarter.settingsManager.defaultSpeechVolume, ID);
            if (doSave)
            {
                optionsData = _optionsData;
                SavePrefs ();
            }

            return _optionsData;
        }
Ejemplo n.º 16
0
 public static void SaveDefaultPrefs(OptionsData defaultOptionsData)
 {
     SavePrefsToID (0, defaultOptionsData, false);
 }
Ejemplo n.º 17
0
        public void ShowGUI()
        {
            EditorGUILayout.LabelField("Save game settings", EditorStyles.boldLabel);

            if (saveFileName == "")
            {
                saveFileName = SaveSystem.SetProjectName();
            }
            saveFileName = EditorGUILayout.TextField("Save filename:", saveFileName);
                        #if !UNITY_WEBPLAYER && !UNITY_ANDROID
            saveTimeDisplay     = (SaveTimeDisplay)EditorGUILayout.EnumPopup("Time display:", saveTimeDisplay);
            takeSaveScreenshots = EditorGUILayout.ToggleLeft("Take screenshot when saving?", takeSaveScreenshots);
                        #else
            EditorGUILayout.HelpBox("Save-game screenshots are disabled for WebPlayer and Android platforms.", MessageType.Info);
            takeSaveScreenshots = false;
                        #endif

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Cutscene settings:", EditorStyles.boldLabel);

            actionListOnStart    = ActionListAssetMenu.AssetGUI("ActionList on start game:", actionListOnStart);
            blackOutWhenSkipping = EditorGUILayout.Toggle("Black out when skipping?", blackOutWhenSkipping);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Character settings:", EditorStyles.boldLabel);

            CreatePlayersGUI();

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Interface settings", EditorStyles.boldLabel);

            movementMethod = (MovementMethod)EditorGUILayout.EnumPopup("Movement method:", movementMethod);
            if (movementMethod == MovementMethod.UltimateFPS && !UltimateFPSIntegration.IsDefinePresent())
            {
                EditorGUILayout.HelpBox("The 'UltimateFPSIsPresent' preprocessor define must be declared in the Player Settings.", MessageType.Warning);
            }

            inputMethod       = (InputMethod)EditorGUILayout.EnumPopup("Input method:", inputMethod);
            interactionMethod = (AC_InteractionMethod)EditorGUILayout.EnumPopup("Interaction method:", interactionMethod);

            if (inputMethod != InputMethod.TouchScreen)
            {
                useOuya = EditorGUILayout.ToggleLeft("Playing on OUYA platform?", useOuya);
                if (useOuya && !OuyaIntegration.IsDefinePresent())
                {
                    EditorGUILayout.HelpBox("The 'OUYAIsPresent' preprocessor define must be declared in the Player Settings.", MessageType.Warning);
                }
                if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction)
                {
                    selectInteractions = (SelectInteractions)EditorGUILayout.EnumPopup("Select Interactions by:", selectInteractions);
                    if (selectInteractions != SelectInteractions.CyclingCursorAndClickingHotspot)
                    {
                        seeInteractions = (SeeInteractions)EditorGUILayout.EnumPopup("See Interactions with:", seeInteractions);
                        if (seeInteractions == SeeInteractions.ClickOnHotspot)
                        {
                            stopPlayerOnClickHotspot = EditorGUILayout.ToggleLeft("Stop player moving when click Hotspot?", stopPlayerOnClickHotspot);
                        }
                    }

                    if (selectInteractions == SelectInteractions.CyclingCursorAndClickingHotspot)
                    {
                        autoCycleWhenInteract = EditorGUILayout.ToggleLeft("Auto-cycle after an Interaction?", autoCycleWhenInteract);
                    }

                    if (SelectInteractionMethod() == SelectInteractions.ClickingMenu)
                    {
                        cancelInteractions = (CancelInteractions)EditorGUILayout.EnumPopup("Close interactions with:", cancelInteractions);
                    }
                    else
                    {
                        cancelInteractions = CancelInteractions.CursorLeavesMenu;
                    }
                }
            }
            if (interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
            {
                autoCycleWhenInteract = EditorGUILayout.ToggleLeft("Reset cursor after an Interaction?", autoCycleWhenInteract);
            }
            lockCursorOnStart = EditorGUILayout.ToggleLeft("Lock cursor in screen's centre when game begins?", lockCursorOnStart);
            hideLockedCursor  = EditorGUILayout.ToggleLeft("Hide cursor when locked in screen's centre?", hideLockedCursor);
            onlyInteractWhenCursorUnlocked = EditorGUILayout.ToggleLeft("Disallow Interactions if cursor is unlocked?", onlyInteractWhenCursorUnlocked);
            if (IsInFirstPerson())
            {
                disableFreeAimWhenDragging = EditorGUILayout.ToggleLeft("Disable free-aim when dragging?", disableFreeAimWhenDragging);
            }
            if (inputMethod != InputMethod.TouchScreen)
            {
                runConversationsWithKeys = EditorGUILayout.ToggleLeft("Dialogue options can be selected with number keys?", runConversationsWithKeys);
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Inventory settings", EditorStyles.boldLabel);

            if (interactionMethod != AC_InteractionMethod.ContextSensitive)
            {
                inventoryInteractions = (InventoryInteractions)EditorGUILayout.EnumPopup("Inventory interactions:", inventoryInteractions);

                if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction)
                {
                    if (selectInteractions == SelectInteractions.CyclingCursorAndClickingHotspot)
                    {
                        cycleInventoryCursors = EditorGUILayout.ToggleLeft("Include Inventory items in Interaction cycles?", cycleInventoryCursors);
                    }
                    else
                    {
                        cycleInventoryCursors = EditorGUILayout.ToggleLeft("Include Inventory items in Interaction menus?", cycleInventoryCursors);
                    }
                }

                if (inventoryInteractions == InventoryInteractions.Multiple && CanSelectItems(false))
                {
                    selectInvWithUnhandled = EditorGUILayout.ToggleLeft("Select item if Interaction is unhandled?", selectInvWithUnhandled);
                    if (selectInvWithUnhandled)
                    {
                        CursorManager cursorManager = AdvGame.GetReferences().cursorManager;
                        if (cursorManager != null && cursorManager.cursorIcons != null && cursorManager.cursorIcons.Count > 0)
                        {
                            selectInvWithIconID = GetIconID("Select with unhandled:", selectInvWithIconID, cursorManager);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("No Interaction cursors defined - please do so in the Cursor Manager.", MessageType.Info);
                        }
                    }

                    giveInvWithUnhandled = EditorGUILayout.ToggleLeft("Give item if Interaction is unhandled?", giveInvWithUnhandled);
                    if (giveInvWithUnhandled)
                    {
                        CursorManager cursorManager = AdvGame.GetReferences().cursorManager;
                        if (cursorManager != null && cursorManager.cursorIcons != null && cursorManager.cursorIcons.Count > 0)
                        {
                            giveInvWithIconID = GetIconID("Give with unhandled:", giveInvWithIconID, cursorManager);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("No Interaction cursors defined - please do so in the Cursor Manager.", MessageType.Info);
                        }
                    }
                }
            }

            if (interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction && selectInteractions != SelectInteractions.ClickingMenu && inventoryInteractions == InventoryInteractions.Multiple)
            {
            }
            else
            {
                reverseInventoryCombinations = EditorGUILayout.ToggleLeft("Combine interactions work in reverse?", reverseInventoryCombinations);
            }

            //if (interactionMethod != AC_InteractionMethod.ChooseHotspotThenInteraction || inventoryInteractions == InventoryInteractions.Single)
            if (CanSelectItems(false))
            {
                inventoryDragDrop = EditorGUILayout.ToggleLeft("Drag and drop Inventory interface?", inventoryDragDrop);
                if (!inventoryDragDrop)
                {
                    if (interactionMethod == AC_InteractionMethod.ContextSensitive || inventoryInteractions == InventoryInteractions.Single)
                    {
                        rightClickInventory = (RightClickInventory)EditorGUILayout.EnumPopup("Right-click active item:", rightClickInventory);
                    }
                }
                else if (inventoryInteractions == AC.InventoryInteractions.Single)
                {
                    inventoryDropLook = EditorGUILayout.ToggleLeft("Can drop an Item onto itself to Examine it?", inventoryDropLook);
                }
            }

            if (CanSelectItems(false) && !inventoryDragDrop)
            {
                inventoryDisableLeft = EditorGUILayout.ToggleLeft("Left-click deselects active item?", inventoryDisableLeft);

                if (movementMethod == MovementMethod.PointAndClick && !inventoryDisableLeft)
                {
                    canMoveWhenActive = EditorGUILayout.ToggleLeft("Can move player if an Item is active?", canMoveWhenActive);
                }
            }

            inventoryActiveEffect = (InventoryActiveEffect)EditorGUILayout.EnumPopup("Active cursor FX:", inventoryActiveEffect);
            if (inventoryActiveEffect == InventoryActiveEffect.Pulse)
            {
                inventoryPulseSpeed = EditorGUILayout.Slider("Active FX pulse speed:", inventoryPulseSpeed, 0.5f, 2f);
            }

            activeWhenUnhandled  = EditorGUILayout.ToggleLeft("Show Active FX when an Interaction is unhandled?", activeWhenUnhandled);
            canReorderItems      = EditorGUILayout.ToggleLeft("Items can be re-ordered in Menu?", canReorderItems);
            hideSelectedFromMenu = EditorGUILayout.ToggleLeft("Hide currently active Item in Menu?", hideSelectedFromMenu);
            activeWhenHover      = EditorGUILayout.ToggleLeft("Show Active FX when Cursor hovers over Item in Menu?", activeWhenHover);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Required inputs:", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox("The following inputs are available for the chosen interface settings:" + GetInputList(), MessageType.Info);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Movement settings", EditorStyles.boldLabel);

            if ((inputMethod == InputMethod.TouchScreen && movementMethod != MovementMethod.PointAndClick) || movementMethod == MovementMethod.Drag)
            {
                dragWalkThreshold = EditorGUILayout.FloatField("Walk threshold:", dragWalkThreshold);
                dragRunThreshold  = EditorGUILayout.FloatField("Run threshold:", dragRunThreshold);

                if (inputMethod == InputMethod.TouchScreen && movementMethod == MovementMethod.FirstPerson)
                {
                    freeAimTouchSpeed = EditorGUILayout.FloatField("Freelook speed:", freeAimTouchSpeed);
                }

                drawDragLine = EditorGUILayout.Toggle("Draw drag line?", drawDragLine);
                if (drawDragLine)
                {
                    dragLineWidth = EditorGUILayout.FloatField("Drag line width:", dragLineWidth);
                    dragLineColor = EditorGUILayout.ColorField("Drag line colour:", dragLineColor);
                }
            }
            else if (movementMethod == MovementMethod.Direct)
            {
                magnitudeAffectsDirect = EditorGUILayout.ToggleLeft("Input magnitude affects speed?", magnitudeAffectsDirect);
                directMovementType     = (DirectMovementType)EditorGUILayout.EnumPopup("Direct-movement type:", directMovementType);
                if (directMovementType == DirectMovementType.RelativeToCamera)
                {
                    limitDirectMovement = (LimitDirectMovement)EditorGUILayout.EnumPopup("Movement limitation:", limitDirectMovement);
                    if (cameraPerspective == CameraPerspective.ThreeD)
                    {
                        directMovementPerspective = EditorGUILayout.ToggleLeft("Account for player's position on screen?", directMovementPerspective);
                    }
                }
            }
            else if (movementMethod == MovementMethod.PointAndClick)
            {
                clickPrefab         = (Transform)EditorGUILayout.ObjectField("Click marker:", clickPrefab, typeof(Transform), false);
                walkableClickRange  = EditorGUILayout.Slider("NavMesh search %:", walkableClickRange, 0f, 1f);
                doubleClickMovement = EditorGUILayout.Toggle("Double-click to move?", doubleClickMovement);
            }
            if (movementMethod == MovementMethod.StraightToCursor)
            {
                dragRunThreshold  = EditorGUILayout.FloatField("Run threshold:", dragRunThreshold);
                singleTapStraight = EditorGUILayout.ToggleLeft("Single-clicking also moves player?", singleTapStraight);
                if (singleTapStraight)
                {
                    singleTapStraightPathfind = EditorGUILayout.ToggleLeft("Pathfind when single-clicking?", singleTapStraightPathfind);
                }
            }
            if (movementMethod == MovementMethod.FirstPerson && inputMethod == InputMethod.TouchScreen)
            {
                dragAffects = (DragAffects)EditorGUILayout.EnumPopup("Touch-drag affects:", dragAffects);
            }
            if ((movementMethod == MovementMethod.Direct || movementMethod == MovementMethod.FirstPerson) && inputMethod != InputMethod.TouchScreen)
            {
                jumpSpeed = EditorGUILayout.Slider("Jump speed:", jumpSpeed, 1f, 10f);
            }

            destinationAccuracy = EditorGUILayout.Slider("Destination accuracy:", destinationAccuracy, 0f, 1f);

            if (inputMethod == InputMethod.TouchScreen)
            {
                EditorGUILayout.Space();
                EditorGUILayout.LabelField("Touch Screen settings", EditorStyles.boldLabel);

                offsetTouchCursor = EditorGUILayout.Toggle("Drag cursor with touch?", offsetTouchCursor);
                doubleTapHotspots = EditorGUILayout.Toggle("Double-tap Hotspots?", doubleTapHotspots);
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Camera settings", EditorStyles.boldLabel);

            cameraPerspective_int = (int)cameraPerspective;
            cameraPerspective_int = EditorGUILayout.Popup("Camera perspective:", cameraPerspective_int, cameraPerspective_list);
            cameraPerspective     = (CameraPerspective)cameraPerspective_int;
            if (movementMethod == MovementMethod.FirstPerson)
            {
                cameraPerspective = CameraPerspective.ThreeD;
            }
            if (cameraPerspective == CameraPerspective.TwoD)
            {
                movingTurning = (MovingTurning)EditorGUILayout.EnumPopup("Moving and turning:", movingTurning);
                if (movingTurning == MovingTurning.TopDown || movingTurning == MovingTurning.Unity2D)
                {
                    verticalReductionFactor = EditorGUILayout.Slider("Vertical movement factor:", verticalReductionFactor, 0.1f, 1f);
                }
            }

            forceAspectRatio = EditorGUILayout.Toggle("Force aspect ratio?", forceAspectRatio);
            if (forceAspectRatio)
            {
                wantedAspectRatio = EditorGUILayout.FloatField("Aspect ratio:", wantedAspectRatio);
                                #if UNITY_IPHONE
                landscapeModeOnly = EditorGUILayout.Toggle("Landscape-mode only?", landscapeModeOnly);
                                #endif
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Hotpot settings", EditorStyles.boldLabel);

            hotspotDetection = (HotspotDetection)EditorGUILayout.EnumPopup("Hotspot detection method:", hotspotDetection);
            if (hotspotDetection == HotspotDetection.PlayerVicinity && (movementMethod == MovementMethod.Direct || IsInFirstPerson()))
            {
                hotspotsInVicinity = (HotspotsInVicinity)EditorGUILayout.EnumPopup("Hotspots in vicinity:", hotspotsInVicinity);
            }
            else if (hotspotDetection == HotspotDetection.MouseOver)
            {
                scaleHighlightWithMouseProximity = EditorGUILayout.ToggleLeft("Highlight Hotspots based on cursor proximity?", scaleHighlightWithMouseProximity);
                if (scaleHighlightWithMouseProximity)
                {
                    highlightProximityFactor = EditorGUILayout.FloatField("Cursor proximity factor:", highlightProximityFactor);
                }
            }

            if (cameraPerspective != CameraPerspective.TwoD)
            {
                playerFacesHotspots = EditorGUILayout.Toggle("Player turns head to active?", playerFacesHotspots);
            }

            hotspotIconDisplay = (HotspotIconDisplay)EditorGUILayout.EnumPopup("Display Hotspot icon:", hotspotIconDisplay);
            if (hotspotIconDisplay != HotspotIconDisplay.Never)
            {
                if (cameraPerspective != CameraPerspective.TwoD)
                {
                    occludeIcons = EditorGUILayout.Toggle("Don't show behind Colliders?", occludeIcons);
                }
                hotspotIcon = (HotspotIcon)EditorGUILayout.EnumPopup("Hotspot icon type:", hotspotIcon);
                if (hotspotIcon == HotspotIcon.Texture)
                {
                    hotspotIconTexture = (Texture2D)EditorGUILayout.ObjectField("Hotspot icon texture:", hotspotIconTexture, typeof(Texture2D), false);
                }
                hotspotIconSize = EditorGUILayout.FloatField("Hotspot icon size:", hotspotIconSize);
            }

                        #if UNITY_5
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Audio settings", EditorStyles.boldLabel);
            volumeControl = (VolumeControl)EditorGUILayout.EnumPopup("Volume controlled by:", volumeControl);
            if (volumeControl == VolumeControl.AudioMixerGroups)
            {
                musicMixerGroup             = (AudioMixerGroup)EditorGUILayout.ObjectField("Music mixer:", musicMixerGroup, typeof(AudioMixerGroup), false);
                sfxMixerGroup               = (AudioMixerGroup)EditorGUILayout.ObjectField("SFX mixer:", sfxMixerGroup, typeof(AudioMixerGroup), false);
                speechMixerGroup            = (AudioMixerGroup)EditorGUILayout.ObjectField("Speech mixer:", speechMixerGroup, typeof(AudioMixerGroup), false);
                musicAttentuationParameter  = EditorGUILayout.TextField("Music atten. parameter:", musicAttentuationParameter);
                sfxAttentuationParameter    = EditorGUILayout.TextField("SFX atten. parameter:", sfxAttentuationParameter);
                speechAttentuationParameter = EditorGUILayout.TextField("Speech atten. parameter:", speechAttentuationParameter);
            }
                        #endif

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Raycast settings", EditorStyles.boldLabel);
            navMeshRaycastLength  = EditorGUILayout.FloatField("NavMesh ray length:", navMeshRaycastLength);
            hotspotRaycastLength  = EditorGUILayout.FloatField("Hotspot ray length:", hotspotRaycastLength);
            moveableRaycastLength = EditorGUILayout.FloatField("Moveable ray length:", moveableRaycastLength);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Layer names", EditorStyles.boldLabel);

            hotspotLayer = EditorGUILayout.TextField("Hotspot:", hotspotLayer);
            navMeshLayer = EditorGUILayout.TextField("Nav mesh:", navMeshLayer);
            if (cameraPerspective == CameraPerspective.TwoPointFiveD)
            {
                backgroundImageLayer = EditorGUILayout.TextField("Background image:", backgroundImageLayer);
            }
            deactivatedLayer = EditorGUILayout.TextField("Deactivated:", deactivatedLayer);

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Loading scene", EditorStyles.boldLabel);
            useLoadingScreen = EditorGUILayout.Toggle("Use loading screen?", useLoadingScreen);
            if (useLoadingScreen)
            {
                loadingSceneIs = (ChooseSceneBy)EditorGUILayout.EnumPopup("Choose loading scene by:", loadingSceneIs);
                if (loadingSceneIs == ChooseSceneBy.Name)
                {
                    loadingSceneName = EditorGUILayout.TextField("Loading scene name:", loadingSceneName);
                }
                else
                {
                    loadingScene = EditorGUILayout.IntField("Loading screen scene:", loadingScene);
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Options data", EditorStyles.boldLabel);

            if (!PlayerPrefs.HasKey(ppKey))
            {
                optionsData   = new OptionsData();
                optionsBinary = Serializer.SerializeObjectBinary(optionsData);
                PlayerPrefs.SetString(ppKey, optionsBinary);
            }

            optionsBinary = PlayerPrefs.GetString(ppKey);
            if (optionsBinary.Length > 0)
            {
                optionsData = Serializer.DeserializeObjectBinary <OptionsData> (optionsBinary);
            }
            else
            {
                optionsData = new OptionsData();
            }

            defaultSpeechVolume  = optionsData.speechVolume = EditorGUILayout.Slider("Speech volume:", optionsData.speechVolume, 0f, 1f);
            defaultMusicVolume   = optionsData.musicVolume = EditorGUILayout.Slider("Music volume:", optionsData.musicVolume, 0f, 1f);
            defaultSfxVolume     = optionsData.sfxVolume = EditorGUILayout.Slider("SFX volume:", optionsData.sfxVolume, 0f, 1f);
            defaultShowSubtitles = optionsData.showSubtitles = EditorGUILayout.Toggle("Show subtitles?", optionsData.showSubtitles);
            defaultLanguage      = optionsData.language = EditorGUILayout.IntField("Language:", optionsData.language);

            optionsBinary = Serializer.SerializeObjectBinary(optionsData);
            PlayerPrefs.SetString(ppKey, optionsBinary);

            if (GUILayout.Button("Reset options data"))
            {
                PlayerPrefs.DeleteKey("Options");
                optionsData = new OptionsData();
                Debug.Log("PlayerPrefs cleared");
            }

            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Debug settings", EditorStyles.boldLabel);
            showActiveActionLists = EditorGUILayout.ToggleLeft("List active ActionLists in Game window?", showActiveActionLists);
            showHierarchyIcons    = EditorGUILayout.ToggleLeft("Show icons in Hierarchy window?", showHierarchyIcons);


            if (GUI.changed)
            {
                EditorUtility.SetDirty(this);
            }
        }
Ejemplo n.º 18
0
        public void CreateProfile(string _label = "")
        {
            int newProfileID = FindFirstEmptyProfileID ();

            OptionsData newOptionsData = new OptionsData (optionsData, newProfileID);
            if (_label != "")
            {
                newOptionsData.label = _label;
            }
            optionsData = newOptionsData;

            SetActiveProfileID (newProfileID);
            SavePrefs ();

            if (Application.isPlaying)
            {
                KickStarter.saveSystem.GatherSaveFiles ();
                PlayerMenus.RecalculateAll ();
            }
        }
Ejemplo n.º 19
0
        /**
         * Sets the options values to those stored within the active profile.
         */
        public static void LoadPrefs()
        {
            if (Application.isPlaying)
            {
                KickStarter.options.CustomLoadOptionsHook ();
            }

            optionsData = LoadPrefsFromID (GetActiveProfileID (), Application.isPlaying, true);
            int numLanguages = (Application.isPlaying) ? KickStarter.runtimeLanguages.Languages.Count : AdvGame.GetReferences ().speechManager.languages.Count;
            if (optionsData.language >= numLanguages)
            {
                if (numLanguages != 0)
                {
                    ACDebug.LogWarning ("Language set to an invalid index - reverting to original language.");
                }
                optionsData.language = 0;
                SavePrefs ();
            }
            if (optionsData.language == 0 && KickStarter.speechManager && KickStarter.speechManager.ignoreOriginalText && KickStarter.speechManager.languages.Count > 1)
            {
                // Ignore original language
                optionsData.language = 1;
                SavePrefs ();
            }

            if (Application.isPlaying)
            {
                KickStarter.saveSystem.GatherSaveFiles ();
                KickStarter.playerMenus.RecalculateAll ();
            }
        }
Ejemplo n.º 20
0
        /**
         * <summary>Gets the options values associated with a specific profile.</summary>
         * <param name = "ID">A unique identifier for the profile to save to</param>
         * <param name = "showLog">If True, the details of this save will be printed in the Console window</param>
         * <param name = "doSave">If True, and if the profile had no OptionsData to read, then new values will be saved to it</param>
         * <returns>An instance of OptionsData containing the profile's options</returns>
         */
        public static OptionsData LoadPrefsFromID(int ID, bool showLog = false, bool doSave = true)
        {
            if (PlayerPrefs.HasKey (GetPrefKeyName (ID)))
            {
                string optionsSerialized = PlayerPrefs.GetString (GetPrefKeyName (ID));
                if (optionsSerialized != null && optionsSerialized.Length > 0)
                {
                    if (showLog)
                    {
                        ACDebug.Log ("PlayerPrefs Key '" + GetPrefKeyName (ID) + "' loaded");
                    }
                    return Serializer.DeserializeOptionsData (optionsSerialized);
                }
            }

            // No data exists, so create new
            OptionsData _optionsData = new OptionsData (KickStarter.settingsManager.defaultLanguage, KickStarter.settingsManager.defaultShowSubtitles, KickStarter.settingsManager.defaultSfxVolume, KickStarter.settingsManager.defaultMusicVolume, KickStarter.settingsManager.defaultSpeechVolume, ID);
            if (doSave)
            {
                optionsData = _optionsData;
                SavePrefs ();
            }

            return _optionsData;
        }
Ejemplo n.º 21
0
 /**
  * <summary>Saves specific options to a specific profile.</summary>
  * <param name = "ID">A unique identifier for the profile to save to</param>
  * <param name = "_optionsData">An instance of OptionsData containing the options to save</param>
  * <param name = "showLog">If True, the details of this save will be printed in the Console window</param>
  */
 public static void SavePrefsToID(int ID, OptionsData _optionsData = null, bool showLog = false)
 {
     if (_optionsData == null)
     {
         _optionsData = Options.optionsData;
     }
     string optionsSerialized = Serializer.SerializeObject <OptionsData> (_optionsData, true);
     if (optionsSerialized != "")
     {
         PlayerPrefs.SetString (GetPrefKeyName (ID), optionsSerialized);
         if (showLog)
         {
             ACDebug.Log ("PlayerPrefs Key '" + GetPrefKeyName (ID) + "' saved");
         }
     }
 }
Ejemplo n.º 22
0
 /**
  * <summary>Saves the default options data (i.e. the values chosen in SettingsManager) to the default profile.</summary>
  * <param name = "defaultOptionsData">An instance of OptionsData that represents default values</param>
  */
 public static void SaveDefaultPrefs(OptionsData defaultOptionsData)
 {
     SavePrefsToID(0, defaultOptionsData, false);
 }
Ejemplo n.º 23
0
        private void SaveFileGUI()
        {
            iSaveFileHandler    saveFileHandler          = SaveSystem.SaveFileHandler;
            iOptionsFileHandler optionsFileHandler       = Options.OptionsFileHandler;
            iFileFormatHandler  fileFormatHandler        = SaveSystem.FileFormatHandler;
            iFileFormatHandler  optionsFileFormatHandler = SaveSystem.OptionsFileFormatHandler;

            if (optionsFileHandler == null)
            {
                EditorGUILayout.HelpBox("No Options File Handler assigned - one must be set in order to locate Profile Data.", MessageType.Warning);
                return;
            }

            if (saveFileHandler == null)
            {
                EditorGUILayout.HelpBox("No Save File Handler assigned - one must be set in order to locate Save Data.", MessageType.Warning);
                return;
            }

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showHandlers = CustomGUILayout.ToggleHeader(showHandlers, "File and format handlers");
            if (showHandlers)
            {
                if (saveFileHandler != null)
                {
                    EditorGUILayout.LabelField("Save file location:", saveFileHandler.GetType().Name);
                }

                if (optionsFileHandler != null)
                {
                    EditorGUILayout.LabelField("Options location:", optionsFileHandler.GetType().Name);
                }

                if (fileFormatHandler != null)
                {
                    EditorGUILayout.LabelField("File format:", fileFormatHandler.GetType().Name);
                }

                if (optionsFileFormatHandler != null && fileFormatHandler == null || (optionsFileFormatHandler.GetType().Name != fileFormatHandler.GetType().Name))
                {
                    EditorGUILayout.LabelField("Options format:", optionsFileFormatHandler.GetType().Name);
                }

                EditorGUILayout.HelpBox("Save format and location handlers can be modified through script - see the Manual's 'Custom save formats and handling' chapter.", MessageType.Info);
            }
            EditorGUILayout.EndVertical();

            if (settingsManager.useProfiles)
            {
                EditorGUILayout.Space();

                EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                showProfiles = CustomGUILayout.ToggleHeader(showProfiles, "Profiles");
                if (showProfiles)
                {
                    bool foundSome = false;

                    for (int profileID = 0; profileID < Options.maxProfiles; profileID++)
                    {
                        if (optionsFileHandler.DoesProfileExist(profileID))
                        {
                            foundSome = true;
                            OptionsData tempOptionsData = Options.LoadPrefsFromID(profileID, false, false);

                            string label = profileID.ToString() + ": " + tempOptionsData.label;
                            if (profileID == Options.GetActiveProfileID())
                            {
                                label += " (ACTIVE)";
                            }

                            if (GUILayout.Toggle(selectedProfileID == profileID, label, "Button"))
                            {
                                if (selectedProfileID != profileID)
                                {
                                    selectedProfileID = profileID;
                                    selectedSaveIndex = -1;
                                    foundSaveFiles.Clear();
                                }
                            }
                        }
                    }

                    if (!foundSome)
                    {
                        selectedProfileID = -1;
                        EditorGUILayout.HelpBox("No save profiles found.", MessageType.Warning);
                    }
                }
                EditorGUILayout.EndVertical();
            }
            else
            {
                selectedProfileID = 0;
            }

            if (selectedProfileID < 0 || !optionsFileHandler.DoesProfileExist(selectedProfileID))
            {
                EditorGUILayout.HelpBox("No save profiles found! Run the game to create a new save profile", MessageType.Warning);
                return;
            }

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showProfile = CustomGUILayout.ToggleHeader(showProfile, "Profile " + selectedProfileID + ": Properties");
            if (showProfile)
            {
                OptionsData prefsData = GetPrefsData(selectedProfileID);
                if (prefsData != null)
                {
                    EditorGUILayout.LabelField("Label:", prefsData.label);
                    EditorGUILayout.LabelField("ID:", prefsData.ID.ToString());
                    EditorGUILayout.LabelField("Language:", prefsData.language.ToString());
                    if (prefsData.language != prefsData.voiceLanguage)
                    {
                        EditorGUILayout.LabelField("Voice language:", prefsData.voiceLanguage.ToString());
                    }
                    EditorGUILayout.LabelField("Show subtitles:", prefsData.showSubtitles.ToString());
                    EditorGUILayout.LabelField("SFX volume:", prefsData.sfxVolume.ToString());
                    EditorGUILayout.LabelField("Music volume:", prefsData.musicVolume.ToString());
                    EditorGUILayout.LabelField("Speech volume:", prefsData.speechVolume.ToString());

                    if (KickStarter.variablesManager != null)
                    {
                        List <GVar> linkedVariables = SaveSystem.UnloadVariablesData(prefsData.linkedVariables, KickStarter.variablesManager.vars, true);
                        foreach (GVar linkedVariable in linkedVariables)
                        {
                            if (linkedVariable.link == VarLink.OptionsData)
                            {
                                EditorGUILayout.LabelField(linkedVariable.label + ":", linkedVariable.GetValue());
                            }
                        }
                    }
                    else
                    {
                        EditorGUILayout.LabelField("Linked Variables:", prefsData.linkedVariables);
                    }

                    EditorGUILayout.BeginHorizontal();
                    if (settingsManager.useProfiles)
                    {
                        GUI.enabled = (selectedProfileID != Options.GetActiveProfileID());
                        if (GUILayout.Button("Make active"))
                        {
                            SwitchActiveProfile(selectedProfileID);
                        }
                        GUI.enabled = true;
                    }
                    if (GUILayout.Button("Delete profile"))
                    {
                        bool canDelete = EditorUtility.DisplayDialog("Delete profile?", "Are you sure you want to delete profile #" + selectedProfileID + "? This operation cannot be undone.", "Yes", "No");
                        if (canDelete)
                        {
                            Options.DeleteProfilePrefs(selectedProfileID);
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            foundSaveFiles = saveFileHandler.GatherSaveFiles(selectedProfileID);

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showSaves = CustomGUILayout.ToggleHeader(showSaves, "Save game files");
            if (showSaves)
            {
                if (foundSaveFiles != null)
                {
                    for (int saveIndex = 0; saveIndex < foundSaveFiles.Count; saveIndex++)
                    {
                        SaveFile saveFile = foundSaveFiles[saveIndex];
                        string   label    = saveFile.saveID.ToString() + ": " + saveFile.label;

                        if (GUILayout.Toggle(selectedSaveIndex == saveIndex, label, "Button"))
                        {
                            selectedSaveIndex = saveIndex;
                        }
                    }
                }

                if (foundSaveFiles == null || foundSaveFiles.Count == 0)
                {
                    selectedSaveIndex = -1;
                    EditorGUILayout.HelpBox("No save game files found.", MessageType.Warning);
                }

                EditorGUILayout.Space();
                EditorGUILayout.BeginHorizontal();
                GUI.enabled = Application.isPlaying;
                if (GUILayout.Button("Autosave"))
                {
                    if (!PlayerMenus.IsSavingLocked(null, true))
                    {
                        SwitchActiveProfile(selectedProfileID);
                        SaveSystem.SaveAutoSave();
                    }
                }
                if (GUILayout.Button("Save new"))
                {
                    if (!PlayerMenus.IsSavingLocked(null, true))
                    {
                        SwitchActiveProfile(selectedProfileID);
                        SaveSystem.SaveNewGame();
                    }
                }
                GUI.enabled = (foundSaveFiles != null && foundSaveFiles.Count > 0);
                if (GUILayout.Button("Delete all saves"))
                {
                    bool canDelete = EditorUtility.DisplayDialog("Delete all save files?", "Are you sure you want to delete all save files? This operation cannot be undone.", "Yes", "No");
                    if (canDelete)
                    {
                        saveFileHandler.DeleteAll(selectedProfileID);
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndVertical();

            if (selectedSaveIndex < 0 || foundSaveFiles == null || selectedSaveIndex >= foundSaveFiles.Count)
            {
                return;
            }

            EditorGUILayout.Space();

            SaveFile selectedSaveFile = foundSaveFiles[selectedSaveIndex];

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showSave = CustomGUILayout.ToggleHeader(showSave, "Save game " + selectedSaveIndex + ": Properties");
            if (showSave)
            {
                EditorGUILayout.LabelField("Label:", selectedSaveFile.label);
                EditorGUILayout.LabelField("ID:", selectedSaveFile.saveID.ToString());

                CustomGUILayout.MultiLineLabelGUI("Filename:", selectedSaveFile.fileName);

                EditorGUILayout.LabelField("Timestamp:", selectedSaveFile.updatedTime.ToString());
                if (!string.IsNullOrEmpty(selectedSaveFile.screenshotFilename))
                {
                    CustomGUILayout.MultiLineLabelGUI("Filename:", selectedSaveFile.screenshotFilename);
                }
                EditorGUILayout.LabelField("Is auto-save?", selectedSaveFile.isAutoSave.ToString());

                GUILayout.BeginHorizontal();
                GUI.enabled = Application.isPlaying;
                if (GUILayout.Button("Load"))
                {
                    SwitchActiveProfile(selectedProfileID);
                    SaveSystem.LoadGame(0, selectedSaveFile.saveID, true);
                }
                if (GUILayout.Button("Save over"))
                {
                    if (!PlayerMenus.IsSavingLocked(null, true))
                    {
                        SwitchActiveProfile(selectedProfileID);
                        SaveSystem.SaveGame(0, selectedSaveFile.saveID, true);
                    }
                }
                GUI.enabled = true;

                if (GUILayout.Button("Delete"))
                {
                    bool canDelete = EditorUtility.DisplayDialog("Delete save file?", "Are you sure you want to delete the save file " + selectedSaveFile.label + "? This operation cannot be undone.", "Yes", "No");
                    if (canDelete)
                    {
                        saveFileHandler.Delete(selectedSaveFile);
                    }
                }
                GUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showSaveData = CustomGUILayout.ToggleHeader(showSaveData, "Save game " + selectedSaveIndex + ": Data");
            if (showSaveData)
            {
                if (GUI.changed || !runCache)
                {
                    CacheSaveData(saveFileHandler, selectedSaveFile);
                }

                if (cachedSaveData != null)
                {
                    cachedSaveData.ShowGUI();
                }

                if (cachedLevelData != null)
                {
                    for (int i = 0; i < cachedLevelData.Count; i++)
                    {
                        GUILayout.Box(string.Empty, GUILayout.ExpandWidth(true), GUILayout.Height(1));
                        EditorGUILayout.LabelField("Scene data " + i.ToString() + ":", CustomStyles.subHeader);
                        cachedLevelData[i].ShowGUI();
                    }
                }
            }
            EditorGUILayout.EndVertical();
        }