private void UpdateMenu(AC.Menu menu) { Vector2 invertedMouse = KickStarter.playerInput.GetInvertedMouse (); UpdateMenuPosition (menu, invertedMouse); menu.HandleTransition (); if (KickStarter.settingsManager.inputMethod == InputMethod.KeyboardOrController && menu.IsEnabled ()) { KickStarter.playerInput.InputControlMenu (menu); } if (menu.appearType == AppearType.Manual) { if (menu.IsVisible () && !menu.isLocked && menu.IsPointInside (invertedMouse) && !menu.ignoreMouseClicks) { foundMouseOverMenu = true; } } else if (menu.appearType == AppearType.DuringGameplay) { if (KickStarter.stateHandler.gameState == GameState.Normal && !menu.isLocked) { if (menu.IsOff ()) { menu.TurnOn (true); } if (menu.IsOn () && menu.IsPointInside (invertedMouse)) { foundMouseOverMenu = true; } } else if (KickStarter.stateHandler.gameState == GameState.Paused) { menu.TurnOff (true); } //else if (KickStarter.stateHandler.gameState != GameState.Normal && menu.IsOn () && (KickStarter.actionListManager.AreActionListsRunning () || KickStarter.playerInput.activeConversation != null)) else if (menu.IsOn () && KickStarter.actionListManager.IsGameplayBlocked ()) { menu.TurnOff (true); } } else if (menu.appearType == AppearType.MouseOver) { if (KickStarter.stateHandler.gameState == GameState.Normal && !menu.isLocked && menu.IsPointInside (invertedMouse)) { if (menu.IsOff ()) { menu.TurnOn (true); } if (!menu.ignoreMouseClicks) { foundMouseOverMenu = true; } } else if (KickStarter.stateHandler.gameState == GameState.Paused) { menu.ForceOff (); } else { menu.TurnOff (true); } } else if (menu.appearType == AppearType.OnContainer) { if (KickStarter.playerInput.activeContainer != null && !menu.isLocked && (KickStarter.stateHandler.gameState == GameState.Normal || (KickStarter.stateHandler.gameState == AC.GameState.Paused && menu.pauseWhenEnabled))) { if (menu.IsVisible () && menu.IsPointInside (invertedMouse) && !menu.ignoreMouseClicks) { foundMouseOverMenu = true; } menu.TurnOn (true); } else { menu.TurnOff (true); } } else if (menu.appearType == AppearType.DuringConversation) { if (KickStarter.playerInput.activeConversation != null && KickStarter.stateHandler.gameState == GameState.DialogOptions) { menu.TurnOn (true); } else if (KickStarter.stateHandler.gameState == GameState.Paused) { menu.ForceOff (); } else { menu.TurnOff (true); } } else if (menu.appearType == AppearType.OnInputKey) { if (menu.IsEnabled () && !menu.isLocked && menu.IsPointInside (invertedMouse) && !menu.ignoreMouseClicks) { foundMouseOverMenu = true; } try { if (KickStarter.playerInput.InputGetButtonDown (menu.toggleKey, true)) { if (!menu.IsEnabled ()) { if (KickStarter.stateHandler.gameState == GameState.Paused) { CrossFade (menu); } else { menu.TurnOn (true); } } else { menu.TurnOff (true); } } } catch { if (KickStarter.settingsManager.inputMethod != InputMethod.TouchScreen) { Debug.LogWarning ("No '" + menu.toggleKey + "' button exists - please define one in the Input Manager."); } } } else if (menu.appearType == AppearType.OnHotspot) { if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive && !menu.isLocked && KickStarter.runtimeInventory.selectedItem == null) { Hotspot hotspot = KickStarter.playerInteraction.GetActiveHotspot (); if (hotspot != null) { menu.HideInteractions (); if (hotspot.HasContextUse ()) { menu.MatchUseInteraction (hotspot.GetFirstUseButton ()); } if (hotspot.HasContextLook ()) { menu.MatchLookInteraction (hotspot.lookButton); } menu.Recalculate (); } } if (hotspotLabel != "" && !menu.isLocked && KickStarter.stateHandler.gameState != GameState.Cutscene) //(KickStarter.stateHandler.gameState == GameState.Normal || KickStarter.stateHandler.gameState == GameState.DialogOptions)) { if (!menu.IsOn ()) { menu.TurnOn (true); if (menu.IsUnityUI ()) { // Update position before next frame (Unity UI bug) UpdateMenuPosition (menu, invertedMouse); } } } //else if (KickStarter.stateHandler.gameState == GameState.Paused) else if (KickStarter.stateHandler.gameState == GameState.Cutscene) { menu.ForceOff (); } else { menu.TurnOff (true); } } else if (menu.appearType == AppearType.OnInteraction) { if (KickStarter.settingsManager.CanClickOffInteractionMenu ()) { if (menu.IsEnabled () && (KickStarter.stateHandler.gameState == GameState.Normal || menu.pauseWhenEnabled)) { interactionMenuIsOn = true; if (menu.IsPointInside (invertedMouse) && !menu.ignoreMouseClicks) { foundMouseOverInteractionMenu = true; } else if (KickStarter.playerInput.GetMouseState () == MouseState.SingleClick) { KickStarter.playerInput.ResetMouseClick (); interactionMenuIsOn = false; menu.TurnOff (true); } } else if (KickStarter.stateHandler.gameState == GameState.Paused) { interactionMenuIsOn = false; menu.ForceOff (); } else if (KickStarter.playerInteraction.GetActiveHotspot () == null) { interactionMenuIsOn = false; menu.TurnOff (true); } } else { if (menu.IsEnabled () && (KickStarter.stateHandler.gameState == GameState.Normal || menu.pauseWhenEnabled)) { if (menu.IsPointInside (invertedMouse) && !menu.ignoreMouseClicks) { foundMouseOverInteractionMenu = true; } else if (!menu.IsPointInside (invertedMouse) && !menu.ignoreMouseClicks && KickStarter.playerInteraction.GetActiveHotspot () == null && KickStarter.runtimeInventory.hoverItem == null && (KickStarter.settingsManager.interactionMethod != AC_InteractionMethod.ChooseHotspotThenInteraction || KickStarter.settingsManager.cancelInteractions == CancelInteractions.CursorLeavesMenuOrHotspot)) { interactionMenuIsOn = false; menu.TurnOff (true); } else if (!menu.IsPointInside (invertedMouse) && !menu.ignoreMouseClicks && KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction && KickStarter.settingsManager.cancelInteractions == CancelInteractions.CursorLeavesMenu && !menu.IsFadingIn ()) { interactionMenuIsOn = false; menu.TurnOff (true); } else if (KickStarter.playerInteraction.GetActiveHotspot () == null && KickStarter.runtimeInventory.hoverItem == null && KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction && KickStarter.settingsManager.selectInteractions == AC.SelectInteractions.CyclingMenuAndClickingHotspot) { interactionMenuIsOn = false; menu.TurnOff (true); } else if (KickStarter.settingsManager.SelectInteractionMethod () == SelectInteractions.CyclingMenuAndClickingHotspot && KickStarter.playerInteraction.GetActiveHotspot () != null) {} else if (KickStarter.settingsManager.SelectInteractionMethod () == SelectInteractions.CyclingMenuAndClickingHotspot && KickStarter.runtimeInventory.hoverItem != null) {} else if (KickStarter.playerInteraction.GetActiveHotspot () == null || KickStarter.settingsManager.inputMethod == InputMethod.TouchScreen) {} else if (KickStarter.runtimeInventory.selectedItem == null && KickStarter.playerInteraction.GetActiveHotspot () != null && KickStarter.runtimeInventory.hoverItem != null) { interactionMenuIsOn = false; menu.TurnOff (true); } else if (KickStarter.runtimeInventory.selectedItem != null && KickStarter.runtimeInventory.selectedItem != KickStarter.runtimeInventory.hoverItem) { interactionMenuIsOn = false; menu.TurnOff (true); } } else if (KickStarter.stateHandler.gameState == GameState.Paused) { interactionMenuIsOn = false; menu.ForceOff (); } else if (KickStarter.playerInteraction.GetActiveHotspot () == null) { interactionMenuIsOn = false; menu.TurnOff (true); } } } else if (menu.appearType == AppearType.WhenSpeechPlays) { if (KickStarter.stateHandler.gameState == GameState.Paused) { menu.TurnOff (); } else { Speech speech = menu.speech; if (!menu.oneMenuPerSpeech) { speech = KickStarter.dialog.GetLatestSpeech (); } if (speech != null && (menu.speechMenuType == SpeechMenuType.All || (menu.speechMenuType == SpeechMenuType.CharactersOnly && speech.GetSpeakingCharacter () != null) || (menu.speechMenuType == SpeechMenuType.NarrationOnly && speech.GetSpeakingCharacter () == null)) && (menu.speechMenuLimit == SpeechMenuLimit.All || (menu.speechMenuLimit == SpeechMenuLimit.BlockingOnly && !speech.isBackground) || (menu.speechMenuLimit == SpeechMenuLimit.BackgroundOnly && speech.isBackground))) { if (Options.optionsData == null || (Options.optionsData != null && Options.optionsData.showSubtitles) || (KickStarter.speechManager.forceSubtitles && !KickStarter.dialog.FoundAudio ())) { menu.TurnOn (true); } else { menu.TurnOff (true); } } else { menu.TurnOff (true); } } } }
/** * <summary>Crossfades to a Menu. Any other Menus will be turned off.</summary> * <param name = "_menuTo">The Menu to crossfade to</param> */ public void CrossFade(AC.Menu _menuTo) { if (_menuTo.isLocked) { Debug.Log ("Cannot crossfade to menu " + _menuTo.title + " as it is locked."); } else if (!_menuTo.IsEnabled()) { // Turn off all other menus crossFadeFrom = null; foreach (AC.Menu menu in menus) { if (menu.IsVisible ()) { if (menu.appearType == AppearType.OnHotspot || menu.fadeSpeed == 0) { menu.ForceOff (); } else { menu.TurnOff (true); crossFadeFrom = menu; } } else { menu.ForceOff (); } } if (crossFadeFrom != null) { crossFadeTo = _menuTo; } else { _menuTo.TurnOn (true); } } }
private void DrawMenu(AC.Menu menu, int languageNumber) { Color tempColor = GUI.color; bool isACMenu = !menu.IsUnityUI (); if (menu.IsEnabled ()) { if (!menu.HasTransition () && menu.IsFading ()) { // Stop until no longer "fading" so that it appears in right place return; } if (isACMenu) { if (menu.transitionType == MenuTransition.Fade || menu.transitionType == MenuTransition.FadeAndPan) { tempColor.a = 1f - menu.GetFadeProgress ();//menu.Get//menu.transitionProgress; GUI.color = tempColor; } else { tempColor.a = 1f; GUI.color = tempColor; } menu.StartDisplay (); } foreach (MenuElement element in menu.elements) { if (element.isVisible) { if (isACMenu) { SetStyles (element); } for (int i=0; i<element.GetNumSlots (); i++) { if (menu.IsEnabled () && KickStarter.stateHandler.gameState != GameState.Cutscene && KickStarter.settingsManager.SelectInteractionMethod () == SelectInteractions.CyclingMenuAndClickingHotspot && menu.appearType == AppearType.OnInteraction) { if (element is MenuInteraction) { MenuInteraction menuInteraction = (MenuInteraction) element; if (menuInteraction.iconID == KickStarter.playerInteraction.GetActiveUseButtonIconID ()) { if (KickStarter.cursorManager.addHotspotPrefix) { if (KickStarter.runtimeInventory.hoverItem != null) { hotspotLabel = KickStarter.cursorManager.GetLabelFromID (menuInteraction.iconID, languageNumber) + KickStarter.runtimeInventory.hoverItem.GetLabel (languageNumber); } else { hotspotLabel = KickStarter.cursorManager.GetLabelFromID (menuInteraction.iconID, languageNumber) + KickStarter.playerInteraction.GetLabel (languageNumber); } } if (isACMenu) { element.Display (highlightedStyle, i, menu.GetZoom (), true); } } else { if (isACMenu) { element.Display (normalStyle, i, menu.GetZoom (), false); } } } else if (element is MenuInventoryBox) { MenuInventoryBox menuInventoryBox = (MenuInventoryBox) element; if (menuInventoryBox.inventoryBoxType == AC_InventoryBoxType.HotspotBased && menuInventoryBox.items[i].id == KickStarter.playerInteraction.GetActiveInvButtonID ()) { if (KickStarter.cursorManager.addHotspotPrefix) { hotspotLabel = KickStarter.runtimeInventory.GetHotspotPrefixLabel (menuInventoryBox.GetItem (i), menuInventoryBox.GetLabel (i, languageNumber), languageNumber); if (KickStarter.runtimeInventory.selectedItem != null) { hotspotLabel += KickStarter.runtimeInventory.selectedItem.GetLabel (languageNumber); } else { hotspotLabel += KickStarter.playerInteraction.GetLabel (languageNumber); } } if (isACMenu) { element.Display (highlightedStyle, i, menu.GetZoom (), true); } } else if (isACMenu) { element.Display (normalStyle, i, menu.GetZoom (), false); } } else if (isACMenu) { element.Display (normalStyle, i, menu.GetZoom (), false); } } else if (isACMenu && menu.IsVisible () && !menu.ignoreMouseClicks && element.isClickable && KickStarter.playerInput.IsCursorReadable () && KickStarter.stateHandler.gameState != GameState.Cutscene && ((KickStarter.settingsManager.inputMethod == InputMethod.MouseAndKeyboard && menu.IsPointerOverSlot (element, i, KickStarter.playerInput.GetInvertedMouse ())) || (KickStarter.settingsManager.inputMethod == InputMethod.TouchScreen && menu.IsPointerOverSlot (element, i, KickStarter.playerInput.GetInvertedMouse ())) || (KickStarter.settingsManager.inputMethod == InputMethod.KeyboardOrController && KickStarter.stateHandler.gameState == GameState.Normal && menu.IsPointerOverSlot (element, i, KickStarter.playerInput.GetInvertedMouse ())) || ((KickStarter.settingsManager.inputMethod == InputMethod.KeyboardOrController && KickStarter.stateHandler.gameState != GameState.Normal && menu.selected_element == element && menu.selected_slot == i)))) { float zoom = 1; if (menu.transitionType == MenuTransition.Zoom) { zoom = menu.GetZoom (); } if ((!interactionMenuIsOn || menu.appearType == AppearType.OnInteraction) && (KickStarter.playerInput.GetDragState () == DragState.None || (KickStarter.playerInput.GetDragState () == DragState.Inventory && CanElementBeDroppedOnto (element)))) { element.Display (highlightedStyle, i, zoom, true); if (element.changeCursor) { elementOverCursorID = element.cursorID; } } else { element.Display (normalStyle, i, zoom, false); } } else if (isACMenu) { element.Display (normalStyle, i, menu.GetZoom (), false); } } if (element is MenuInput) { if (selectedInputBox == null) { if (!menu.IsUnityUI ()) { MenuInput input = (MenuInput) element; SelectInputBox (input); } selectedInputBoxMenuName = menu.title; } } } } if (isACMenu) { menu.EndDisplay (); } } if (isACMenu) { tempColor.a = 1f; GUI.color = tempColor; } }