private void menuButtonError(FPEMenuButton button) { if (shakeUIOnError) { elementToJiggle = button.gameObject.GetComponent <RectTransform>(); originalElementPosition = elementToJiggle.localPosition; jiggleTimer = jiggleDuration; jiggleOffset = jiggleDistance; } }
void Awake() { holdButton = transform.Find("HoldButton").GetComponent <FPEMenuButton>(); dropButton = transform.Find("DropButton").GetComponent <FPEMenuButton>(); consumeButton = transform.Find("ConsumeButton").GetComponent <FPEMenuButton>(); cancelButton = transform.Find("CancelButton").GetComponent <FPEMenuButton>(); if (!holdButton || !dropButton || !consumeButton || !cancelButton) { Debug.LogError("FPEInventoryActionsPanel:: One of the Hold, Drop, or Consume buttons are missing! Did you rename or remove them?"); } }
void Start() { menuCanvas = transform.Find("MenuCanvas").gameObject; errorText = menuCanvas.transform.Find("ErrorText").gameObject.GetComponent <Text>(); if (!menuCanvas || !errorText) { Debug.LogError("FPEMainMenu:: Cannot find MenuCanvas or ErrorText! Did you rename or remove them?"); } // Find buttons - will need to be updated if you add or remove buttons FPEMenuButton[] menuButtons = menuCanvas.gameObject.GetComponentsInChildren <FPEMenuButton>(); for (int t = 0; t < menuButtons.Length; t++) { if (menuButtons[t].transform.name == "NewGameButton") { newGameButton = menuButtons[t]; } else if (menuButtons[t].transform.name == "ContinueGameButton") { continueGameButton = menuButtons[t]; } else if (menuButtons[t].transform.name == "QuitGameButton") { quitGameButton = menuButtons[t]; } } if (!newGameButton || !continueGameButton || !quitGameButton) { Debug.LogError("FPEMainMenu:: Cannot find one or more of the menu buttons! Did you rename or remove them?"); } newGameConfirmationPanel = menuCanvas.gameObject.transform.Find("NewGameConfirmationPanel").gameObject; if (!newGameConfirmationPanel) { Debug.LogError("FPEMainMenu:: Cannot find one or more of the menu panels! Did you rename or remove them?"); } newGameConfirmationPanel.SetActive(true); newGameConfirmationButtons = newGameConfirmationPanel.gameObject.GetComponentsInChildren <FPEMenuButton>(); newGameConfirmationPanel.SetActive(false); refreshButtonStates(); }
public FPEMenuButton getFirstPermittedActionButton() { FPEMenuButton firstPermittedButton = cancelButton; if (holdButton.IsInteractable()) { firstPermittedButton = holdButton; } else if (dropButton.IsInteractable()) { firstPermittedButton = dropButton; } else if (consumeButton.IsInteractable()) { firstPermittedButton = consumeButton; } return(firstPermittedButton); }
public override void Awake() { base.Awake(); menuCanvas = transform.Find("MenuCanvas").gameObject; menuCanvas.SetActive(false); itemData = new FPEInventoryItemData[1]; audioDiaryData = new FPEAudioDiaryData[1]; noteData = new FPENoteData[1]; // Find tabs - will need to be updated if you add or remove tabs FPEMenuTab[] menuTabs = menuCanvas.gameObject.GetComponentsInChildren <FPEMenuTab>(); for (int t = 0; t < menuTabs.Length; t++) { if (menuTabs[t].transform.name == "ItemsTab") { itemsTab = menuTabs[t]; } else if (menuTabs[t].transform.name == "AudioDiariesTab") { audioDiariesTab = menuTabs[t]; } else if (menuTabs[t].transform.name == "NotesTab") { notesTab = menuTabs[t]; } else if (menuTabs[t].transform.name == "SystemTab") { systemTab = menuTabs[t]; } } if (!itemsTab || !audioDiariesTab || !notesTab || !systemTab) { Debug.LogError("FPEGameMenu:: Cannot find one or more of the menu tabs! Did you rename or remove them?"); } // Find panels - will need to be updated if you add or remove tabs inventoryItemInfoPanelParent = menuCanvas.gameObject.transform.Find("InventoryItemInfoPanel").gameObject; inventoryItemsListPanel = menuCanvas.gameObject.transform.Find("InventoryListPanel").gameObject; audioDiariesPanel = menuCanvas.gameObject.transform.Find("AudioDiariesPanel").gameObject; notesPanel = menuCanvas.gameObject.transform.Find("NotesPanel").gameObject; noteContentsPanelParent = menuCanvas.gameObject.transform.Find("NoteContentsPanel").gameObject; systemPanel = menuCanvas.gameObject.transform.Find("SystemPanel").gameObject; exitConfirmationPanel = menuCanvas.gameObject.transform.Find("ExitConfirmationPanel").gameObject; actionsPanelParent = menuCanvas.gameObject.transform.Find("InventoryActionsPanel").gameObject; pageControlPanel = menuCanvas.gameObject.transform.Find("PageControlsPanel").gameObject; if (!inventoryItemInfoPanelParent || !inventoryItemsListPanel || !audioDiariesPanel || !notesPanel || !noteContentsPanelParent || !systemPanel || !actionsPanelParent || !pageControlPanel) { Debug.LogError("FPEGameMenu:: Cannot find one or more of the menu panels! Did you rename or remove them?"); } inventoryItemInfoPanelParent.SetActive(true); itemInfoPanel = inventoryItemInfoPanelParent.GetComponent <FPEInventoryItemInfoPanel>(); if (itemInfoPanel == null) { Debug.LogError("FPEGameMenu:: InventoryItemInfoPanel is missing its 'FPEInventoryItemInfoPanel' (script) component! Did you remove it?"); } actionsPanelParent.SetActive(true); inventoryActionsPanel = actionsPanelParent.GetComponent <FPEInventoryActionsPanel>(); if (inventoryActionsPanel == null) { Debug.LogError("FPEGameMenu:: InventoryActionsPanel is missing its 'FPEInventoryActionsPanel' (script) component! Did you remove it?"); } // Inventory item slots (We should have more than one of these) inventoryItemsListPanel.SetActive(true); inventorySlots = menuCanvas.gameObject.GetComponentsInChildren <FPEInventoryItemSlot>(); if (inventorySlots == null || inventorySlots.Length < 2) { Debug.LogError("FPEGameMenu:: There are 1 or fewer inventory item slots on the inventory item panel! Things will break."); } // Audio diary slots (we should have more than one of these as well) audioDiariesPanel.SetActive(true); audioDiarySlots = menuCanvas.gameObject.GetComponentsInChildren <FPEAudioDiaryEntrySlot>(); if (audioDiarySlots == null || audioDiarySlots.Length < 2) { Debug.LogError("FPEGameMenu:: There are 1 or fewer audio diary slots on the audio diary panel! Things will break."); } // Note slots (we should have more than one of these as well) notesPanel.SetActive(true); noteSlots = menuCanvas.gameObject.GetComponentsInChildren <FPENoteEntrySlot>(); if (noteSlots == null || noteSlots.Length < 2) { Debug.LogError("FPEGameMenu:: There are 1 or fewer note slots on the notes panel! Things will break."); } noteContentsPanelParent.SetActive(true); noteContentsPanel = noteContentsPanelParent.GetComponent <FPENoteContentsPanel>(); if (noteContentsPanel == null) { Debug.LogError("FPEGameMenu:: noteContentsPanel is missing its 'FPENoteContentsPanel' (script) component! Did you remove it?"); } // Find all the system buttons systemPanel.SetActive(true); systemButtons = systemPanel.gameObject.GetComponentsInChildren <FPEMenuButton>(); exitConfirmationPanel.SetActive(true); exitConfirmationButtons = exitConfirmationPanel.gameObject.GetComponentsInChildren <FPEMenuButton>(); mouseSensitivityValueText = systemPanel.gameObject.transform.Find("MouseSensitivityValue").GetComponent <Text>(); lookSmoothingToggle = systemPanel.gameObject.transform.Find("LookSmoothingToggle").GetComponent <FPEMenuToggle>(); useGamepadToggle = systemPanel.gameObject.transform.Find("UseGamepadToggle").GetComponent <FPEMenuToggle>(); loadGameButton = systemPanel.gameObject.transform.Find("LoadGameButton").GetComponent <FPEMenuButton>(); if (!mouseSensitivityValueText || !lookSmoothingToggle || !useGamepadToggle || !loadGameButton) { Debug.LogError("FPEGameMenu:: mouseSensitivityValue Text, smoothing or gamepad toggle, or load game button component(s) are missing! Did you remove them?"); } // Find Previous/Next page buttons and hints pageControlPanel.SetActive(true); previousPageButton = pageControlPanel.transform.Find("PreviousPageButton").gameObject; nextPageButton = pageControlPanel.transform.Find("NextPageButton").gameObject; previousPageHint = pageControlPanel.transform.Find("RightStickHintLeft").gameObject; nextPageHint = pageControlPanel.transform.Find("RightStickHintRight").gameObject; pageIndicatorText = pageControlPanel.transform.Find("PageIndicatorText").gameObject.GetComponent <Text>(); if (!previousPageButton || !nextPageButton || !previousPageHint || !nextPageHint || !pageIndicatorText) { Debug.LogError("FPEGameMenu:: Page changing buttons, hints, or text are missing from InventoryListPanel! Did you remove them?"); } // items per page and previous page selections for each tab itemsPerPage = new int[Enum.GetNames(typeof(eMenuTab)).Length]; itemsPerPage[(int)eMenuTab.ITEMS] = inventorySlots.Length; itemsPerPage[(int)eMenuTab.AUDIO_DIARIES] = audioDiarySlots.Length; itemsPerPage[(int)eMenuTab.NOTES] = noteSlots.Length; previouslySelectedPage = new int[Enum.GetNames(typeof(eMenuTab)).Length]; previouslySelectedPage[(int)eMenuTab.ITEMS] = 0; previouslySelectedPage[(int)eMenuTab.AUDIO_DIARIES] = 0; previouslySelectedTab = eMenuTab.ITEMS; previouslySelectedItemSlot = inventorySlots[0]; previouslySelectedAudioDiarySlot = audioDiarySlots[0]; previouslySelectedNoteSlotIndex = -1; }