public static List <SubEntry> CollectSubEntries(string folder) { List <SubEntry> list = new List <SubEntry>(); string path = (!(folder == string.Empty)) ? Path.Combine(baseEntryPath, folder) : baseEntryPath; string[] array = new string[0]; try { array = Directory.GetFiles(path, "*.yaml", SearchOption.AllDirectories); } catch (UnauthorizedAccessException obj) { Debug.LogWarning(obj); } string[] array2 = array; foreach (string text in array2) { try { SubEntry subEntry = YamlIO.LoadFile <SubEntry>(text, YamlParseErrorCB, widgetTagMappings); if (subEntry != null) { list.Add(subEntry); } } catch (Exception ex) { DebugUtil.DevLogErrorFormat("CodexCache.CollectSubEntries failed to load [{0}]: {1}", text, ex.ToString()); } } list.Sort((SubEntry x, SubEntry y) => x.title.CompareTo(y.title)); return(list); }
/// <summary> /// Extracts all subentries and removes them from the entries collection. /// </summary> /// <param name="entries">Collection of the entries.</param> /// <returns>Collection of all subentries.</returns> private Dictionary <String, SubEntry> ExtractSubEntries(IDictionary <XElement, Headword> entries) { var subEntries = new Dictionary <String, SubEntry>(); var enumerator = entries.GetEnumerator(); enumerator.MoveNext(); var headword = enumerator.Current.Value.HeadwordValue; while (true) { if (!enumerator.MoveNext()) { break; } var nextHeadword = enumerator.Current.Value.HeadwordValue; var nextEntry = enumerator.Current.Key; while (IsSingleWord(headword) && IsSeparateWord(headword, nextHeadword)) { if (subEntries.ContainsKey(nextHeadword) && subEntries[nextHeadword].Headword != headword) { _parseInformation.OnError(new Exception( String.Format("{0} points to two different words: 1. {1} and {2}", nextHeadword, subEntries[nextHeadword], headword))); } subEntries[nextHeadword] = new SubEntry { Entry = nextEntry, Headword = headword }; if (!enumerator.MoveNext()) { break; } nextHeadword = enumerator.Current.Value.HeadwordValue; nextEntry = enumerator.Current.Key; } headword = nextHeadword; } foreach (var subEntry in subEntries) { entries.Remove(subEntry.Value.Entry); } return(subEntries); }
public Entry(int id, SubEntry subEntry = null) { Id = id; SubEntry = subEntry; }
public void ChangeArticle(string id, bool playClickSound = false) { Debug.Assert(id != null); if (playClickSound) { KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click", false)); } if (contentContainerPool == null) { Init(); } SubEntry subEntry = null; if (!CodexCache.entries.ContainsKey(id)) { subEntry = null; subEntry = CodexCache.FindSubEntry(id); if (subEntry != null && !subEntry.disabled) { id = subEntry.parentEntryID.ToUpper(); } } ICodexWidget codexWidget = null; CodexCache.entries[id].GetFirstWidget(); RectTransform rectTransform = null; if (subEntry != null) { foreach (ContentContainer contentContainer2 in CodexCache.entries[id].contentContainers) { if (contentContainer2 == subEntry.contentContainers[0]) { codexWidget = contentContainer2.content[0]; break; } } } if (!CodexCache.entries.ContainsKey(id) || CodexCache.entries[id].disabled) { id = "PAGENOTFOUND"; } int num = 0; string text = string.Empty; while (contentContainers.transform.childCount > 0) { while (!string.IsNullOrEmpty(text) && CodexCache.entries[activeEntryID].contentContainers[num].lockID == text) { num++; } GameObject gameObject = contentContainers.transform.GetChild(0).gameObject; int num2 = 0; while (gameObject.transform.childCount > 0) { GameObject gameObject2 = gameObject.transform.GetChild(0).gameObject; Type key; if (gameObject2.name == "PrefabContentLocked") { text = CodexCache.entries[activeEntryID].contentContainers[num].lockID; key = typeof(CodexContentLockedIndicator); } else { key = CodexCache.entries[activeEntryID].contentContainers[num].content[num2].GetType(); } ContentUIPools[key].ClearElement(gameObject2); num2++; } contentContainerPool.ClearElement(contentContainers.transform.GetChild(0).gameObject); num++; } bool flag = CodexCache.entries[id] is CategoryEntry; activeEntryID = id; if (CodexCache.entries[id].contentContainers == null) { CodexCache.entries[id].contentContainers = new List <ContentContainer>(); } bool flag2 = false; string a = string.Empty; for (int i = 0; i < CodexCache.entries[id].contentContainers.Count; i++) { ContentContainer contentContainer = CodexCache.entries[id].contentContainers[i]; if (!string.IsNullOrEmpty(contentContainer.lockID) && !Game.Instance.unlocks.IsUnlocked(contentContainer.lockID)) { if (a != contentContainer.lockID) { GameObject gameObject3 = contentContainerPool.GetFreeElement(contentContainers.gameObject, true).gameObject; ConfigureContentContainer(contentContainer, gameObject3, flag && flag2); a = contentContainer.lockID; GameObject gameObject4 = ContentUIPools[typeof(CodexContentLockedIndicator)].GetFreeElement(gameObject3, true).gameObject; } } else { GameObject gameObject3 = contentContainerPool.GetFreeElement(contentContainers.gameObject, true).gameObject; ConfigureContentContainer(contentContainer, gameObject3, flag && flag2); flag2 = !flag2; if (contentContainer.content != null) { foreach (ICodexWidget item in contentContainer.content) { GameObject gameObject5 = ContentUIPools[item.GetType()].GetFreeElement(gameObject3, true).gameObject; item.Configure(gameObject5, displayPane, textStyles); if (item == codexWidget) { rectTransform = gameObject5.rectTransform(); } } } } } string text2 = string.Empty; string text3 = id; int num3 = 0; while (text3 != CodexCache.FormatLinkID("HOME") && num3 < 10) { num3++; if (text3 != null) { text2 = ((!(text3 != id)) ? text2.Insert(0, CodexCache.entries[text3].name) : text2.Insert(0, CodexCache.entries[text3].name + " > ")); text3 = CodexCache.entries[text3].parentId; } else { text3 = CodexCache.entries[CodexCache.FormatLinkID("HOME")].id; text2 = text2.Insert(0, CodexCache.entries[text3].name + " > "); } } currentLocationText.text = ((!(text2 == string.Empty)) ? text2 : CodexCache.entries["HOME"].name); if (history.Count == 0) { history.Add(activeEntryID); } else if (history[history.Count - 1] != activeEntryID) { if (history.Count > 1 && history[history.Count - 2] == activeEntryID) { history.RemoveAt(history.Count - 1); } else { history.Add(activeEntryID); } } if (history.Count > 1) { backButton.text = UI.FormatAsLink(string.Format(UI.CODEX.BACK_BUTTON, UI.StripLinkFormatting(CodexCache.entries[history[history.Count - 2]].name)), CodexCache.entries[history[history.Count - 2]].id); } else { backButton.text = UI.StripLinkFormatting(GameUtil.ColourizeString(Color.grey, string.Format(UI.CODEX.BACK_BUTTON, CodexCache.entries["HOME"].name))); } if ((UnityEngine.Object)rectTransform != (UnityEngine.Object)null) { if (scrollToTargetRoutine != null) { StopCoroutine(scrollToTargetRoutine); } scrollToTargetRoutine = StartCoroutine(ScrollToTarget(rectTransform)); } else { displayScrollRect.content.SetLocalPosition(Vector3.zero); } }
public static void MergeSubEntry(string id, SubEntry entry) { }
public static void AddSubEntry(string id, SubEntry entry) { }
private static void CollectYAMLSubEntries(List <CategoryEntry> categories) { baseEntryPath = Application.streamingAssetsPath + "/codex"; List <SubEntry> list = CollectSubEntries(string.Empty); foreach (SubEntry item in list) { if (item.parentEntryID != null && item.id != null) { if (entries.ContainsKey(item.parentEntryID.ToUpper())) { SubEntry subEntry = entries[item.parentEntryID.ToUpper()].subEntries.Find((SubEntry match) => match.id == item.id); if (!string.IsNullOrEmpty(item.lockID)) { foreach (ContentContainer contentContainer in item.contentContainers) { contentContainer.lockID = item.lockID; } } if (subEntry != null) { if (!string.IsNullOrEmpty(item.lockID)) { foreach (ContentContainer contentContainer2 in subEntry.contentContainers) { contentContainer2.lockID = item.lockID; } subEntry.lockID = item.lockID; } for (int i = 0; i < item.contentContainers.Count; i++) { if (!string.IsNullOrEmpty(item.contentContainers[i].lockID)) { int num = subEntry.contentContainers.IndexOf(subEntry.lockedContentContainer); subEntry.contentContainers.Insert(num + 1, item.contentContainers[i]); } else if (item.contentContainers[i].showBeforeGeneratedContent) { subEntry.contentContainers.Insert(0, item.contentContainers[i]); } else { subEntry.contentContainers.Add(item.contentContainers[i]); } } subEntry.contentContainers.Add(new ContentContainer(new List <ICodexWidget> { new CodexLargeSpacer() }, ContentContainer.ContentLayout.Vertical)); subEntry.layoutPriority = item.layoutPriority; } else { entries[item.parentEntryID.ToUpper()].subEntries.Add(item); } } else { Debug.LogWarningFormat("Codex SubEntry {0} cannot find parent codex entry with id {1}", item.name, item.parentEntryID); } } } }
public Entry(string title, int number, SubEntry subEntry) : this(title, number) { SubEntry = subEntry; }