private void CreateAddingEntry() { ResourceRequestEditor editor = Instantiate(editorPrefab, editorParent.transform); //editor.Setup(LevelID.FromCurrentSceneName(), null, editorScroller, SortEditors, () => OnRequestDeleted(editor)); //editor.OnNewRequestCreated.AddListener(OnNewEntryCreated); currentEditors.Add(editor); // Sort the editors now that the new one is added SortEditors(); }
private void Start() { // Load the notebook from save, or create a new one if save data doesn't exist data = GameManager.Instance.LoadNotebook() ?? new NotebookData(config); // Set the configuration of the notebook data data.SetConfig(config); // Add the current level data.OnLevelEncountered(LevelID.Current()); // Try to get an instance of the game manager GameManager instance = GameManager.Instance; // If the instance exists then unlock all item id's that exist in the list of items if (instance) { foreach (LevelData.ItemData item in instance.LevelData.ItemQuantities) { data.UnlockItem(item.itemObject.ItemID); } } // Setup the tab picker first of all children tabPicker.Setup(); // Get the resource request editor manually resourceRequestEditor = GetComponentInChildren <ResourceRequestEditor>(true); // Setup all children, ensuring correct initialization order NotebookUIChild[] children = GetComponentsInChildren <NotebookUIChild>(true); foreach (NotebookUIChild child in children) { child.Setup(); } // Map all bookmark targets to their corresponding game object names BookmarkTarget[] allBookmarkTargets = GetComponentsInChildren <BookmarkTarget>(true); foreach (BookmarkTarget bookmarkTarget in allBookmarkTargets) { nameTargetMap.Add(bookmarkTarget.name, bookmarkTarget); } // Setup sound events after all children are set up soundManager.SetupSoundEvents(); // This line of code prevents the notebook from turning off the first time that it is turned on, // while also making sure it is turned off at the start if (!isOpen) { SetIsOpen(false); } }
private void FreezeUntilResourceRequestSubmitted(ItemID requestedItem, int requestQuantity) { // Grab a bunch of references to various scripts in the Notebook NotebookUI notebook = GameManager.Instance.NotebookUI; ConceptsUI concepts = notebook.GetComponentInChildren <ConceptsUI>(true); ResourceRequestEditor requestEditor = notebook.ResourceRequestEditor; ReviewedResourceRequestDisplay reviewDisplay = notebook.GetComponentInChildren <ReviewedResourceRequestDisplay>(true); TMP_InputField quantityInput = requestEditor.QuantityInput; ItemDropdown itemRequestedDropdown = requestEditor.ItemRequestedDropdown; // Freeze conversation until correct review was confirmed FreezingScheduler.FreezeUntilConditionIsMet(() => ResourceRequestWasSubmitted(requestedItem, requestQuantity), HighlightingScheduler.ClearHighlights); HighlightingScheduler.SetHighlights(HighlightNotebookButton(), HighlightNotebookTabButton(NotebookTab.Concepts), HighlightItemDropdown(itemRequestedDropdown, requestedItem)[0], HighlightItemDropdown(itemRequestedDropdown, requestedItem)[1], HighlightInputField(quantityInput, requestQuantity.ToString()), new ConditionalHighlight() { predicate = () => !reviewDisplay.gameObject.activeInHierarchy, target = () => concepts.RequestButton.transform as RectTransform }); }
private void OnRequestDeleted(ResourceRequestEditor editorDeleted) { currentEditors.Remove(editorDeleted); }