2using System.Collections.Generic;
4using System.Text.RegularExpressions;
8public class UIBook : MonoBehaviour
28 public List<Item>
items =
new List<Item>();
37 public List<string>
lines =
new List<string>();
55 uIItem.text1.alignment = TextAnchor.UpperCenter;
57 LayoutElement component = uIItem.GetComponent<LayoutElement>();
60 component.enabled =
false;
68 foreach (
string line
in lines)
70 string text2 =
Lang.
Parse(line,
"test1",
"test2");
71 if (text2.Length == 0)
73 if (!skip && (
idTopic.IsEmpty() || flag))
75 text += Environment.NewLine;
89 if (text2.Split(
'$')[1] ==
idTopic)
106 current.
AddHeader(
"HeaderPatch_header", line);
109 text = text.TrimEnd(Environment.NewLine.ToCharArray());
111 current.
AddHeader(
"HeaderPatch_category", line);
115 text = line.TrimStart(
'*').TrimStart(
' ').TrimEnd(Environment.NewLine.ToCharArray());
116 current.
AddText(
"NoteText_list", text);
124 string[] array = text2.Split(
'}');
126 string[] array2 = array[0].TrimStart(
'{').Split(array[0].Contains(
'|') ?
'|' :
',');
127 if (!skip || !(array2[0] !=
"endif"))
133 string text5 = array2[1];
134 if (!(text5 ==
"cn"))
155 if (array2[0] ==
"include")
167 if (array3.IsEmpty())
171 if (array3.IsEmpty())
175 if (!array3.IsEmpty())
177 ParseLines(array3.ToList(), text3);
188 if (array2.Length == 1)
194 current = n.
AddNote(STR(array2[1]));
198 current.
AddText(
"NoteText_nerun", STR(text));
201 current.
AddHeader(
"HeaderHelpTopic", array2[1]);
204 current.
AddText(
"NoteText_Q", STR(array2[1]));
207 current.
AddText(
"NoteText_A", STR(array2[1]));
210 current.
AddTopic(
"TopicPair", STR(array2[1]), STR(array2[2]));
219 if (array2[1] ==
"close")
230 text = text + text2 + Environment.NewLine;
236 text = text.Replace(
"#pc",
str_pc);
237 UIItem uIItem2 = current.
AddText(
"NoteText_help", STR(text));
240 uIItem2.text1.alignment = TextAnchor.UpperCenter;
259 public static Dictionary<string, string>
helpTitles =
new Dictionary<string, string>();
266 public List<Page>
pages =
new List<Page>();
361 if (Input.GetKeyDown(KeyCode.Escape) &&
inputSearch.text ==
"")
388 SE.Play(
"click_recipe");
390 Show(a.idFile, a.idTopic);
397 b.mainText.text =
"";
398 b.subText.text = a.text;
402 string text =
helpTitles.TryGetValue(a.idFile +
"-") ??
"";
403 string text2 =
helpTitles.TryGetValue(a.idFile +
"-" + a.idTopic) ?? a.idTopic;
404 b.mainText.text = (text.IsEmpty() ?
"" : (text +
" - ")) + text2;
405 string text3 = a.text;
406 if (!text3.Contains(
"</color>"))
408 int num = a.textSearch.IndexOf(s.ToLower());
411 text3 = text3.Substring(0, num) + text3.Substring(num, s.Length).TagColor(
colorSearchHit) + text3.Substring(num + s.Length);
414 b.subText.text = text3;
427 scrollView.content.RebuildLayout(recursive:
true);
434 inputSearch.text =
"";
440 SE.Play(
"read_paper");
457 public void Show(
string _idFile =
null,
string _idTopic =
null,
string title =
null,
BookList.
Item _bookItem =
null)
519 string[] array2 = array;
520 foreach (
string text
in array2)
532 page.lines.Add(text);
540 page.idx =
pages.Count;
548 List<UIList> lists =
new List<UIList>();
555 if (a.
items.Count > 0)
570 b.mainText.text = a.
title;
572 if (a.
items.Count > 0)
593 string oldValue =
'\t'.ToString();
597 string[] array2 = array;
598 for (
int i = 0; i < array2.Length; i++)
600 string[] array3 = array2[i].Replace(oldValue,
"").Split(
',');
601 string[] array4 = array3[0].Split(
'-');
609 if (item3.
title.StartsWith(
"$"))
612 item3.title = item3.
title.TrimStart(
'$');
615 else if (
item !=
null)
632 foreach (
UIList item6
in lists)
645 SkinManager.tempSkin =
null;
648 public void ShowPage(
int idx = 0)
668 bool flag = pages.Count > idx;
676 button.SetActive(flag);
680 idx = Mathf.Clamp(idx, 0,
pages.Count - 1);
681 Page page =
pages[idx];
682 if (page.idx == 0 &&
bookItem !=
null)
687 n.RebuildLayout(recursive:
true);
689 n.RebuildLayoutTo<
Layer>();
694 LayoutGroup[] componentsInChildren = n.transform.parent.GetComponentsInChildren<LayoutGroup>();
695 foreach (LayoutGroup obj
in componentsInChildren)
697 obj.CalculateLayoutInputHorizontal();
698 obj.CalculateLayoutInputVertical();
699 obj.SetLayoutHorizontal();
700 obj.SetLayoutVertical();
702 this.RebuildLayout(recursive:
true);
709 scrollbar.value = 1f;
727 uIButton.onClick.AddListener(delegate
static string Parse(string idLang, string val1, string val2=null, string val3=null, string val4=null, string val5=null)
List< Item > Search(string s)
virtual void BuildNote(UINote n, string idTopic)
UIButton AddButton(string lang, Action action)
void Show(string _idFile=null, string _idTopic=null, string title=null, BookList.Item _bookItem=null)
UIDynamicList listSearchResult
static Dictionary< string, string > helpTitles
static SearchContext searchContext
Transform transSearchResult
override void Add(object o)
Dictionary< UIButton, UIList > children
void Select(int index=0, bool invoke=false)
override void Add(object item)
virtual void Refresh(bool highlightLast=false)
UIButton AddButtonLink(string text, string url)
UINote AddNote(string id)
void AddImage(Sprite sprite)
UIItem AddHeader(string text, Sprite sprite=null)
UIItem AddTopic(string id, string text, string value=null)
UIItem AddText(string text, FontColor color=FontColor.DontChange)
static Transform Instantiate(string path, Component parent=null)