Elin Decompiled Documentation EA 23.301 Nightly
Loading...
Searching...
No Matches
UIBook Class Reference
Inheritance diagram for UIBook:

Classes

class  Item
 
class  Page
 

Public Types

enum  Mode {
  Help , Announce , Book , Parchment ,
  Gallery , About
}
 

Public Member Functions

void Search (string s)
 
void ClearSearch ()
 
void ModPage (int a)
 
void Show (string _idFile=null, string _idTopic=null, string title=null, BookList.Item _bookItem=null)
 
void Show ()
 
void BuildPages ()
 
void AddPage (Page page)
 
void RefreshTopics ()
 
void AddButtonClose ()
 
UIButton AddButton (string lang, Action action)
 

Public Attributes

Mode mode
 
int currentPage
 
List< Pagepages = new List<Page>()
 
UINote note
 
UINote note2
 
UINote noteSearch
 
UIList list
 
UIDynamicList listSearchResult
 
UIText textTitle
 
UIText textPage
 
UIText textPage2
 
string idFile
 
string idTopic
 
string idFirstFile
 
string idFirstTopic
 
SkinRootStatic skin
 
LayoutGroup layoutButton
 
UIButton moldButton
 
BookList.Item bookItem
 
Scrollbar scrollbar
 
Window window
 
UIButton buttonPrev
 
UIButton buttonNext
 
InputField inputSearch
 
UIButton buttonClear
 
UIScrollView scrollView
 
Transform transSearchResult
 
string lastSearch
 
bool showSearchResult
 
float searchResultHeight
 
float marginSearchResult
 
Color colorSearchHit
 

Static Public Attributes

static string str_pc
 
static string searchWord
 
static Dictionary< string, string > helpTitles = new Dictionary<string, string>()
 
static SearchContext searchContext
 
static List< Func< string[]> > topicLoaders = new List<Func<string[]>>()
 

Private Member Functions

void Awake ()
 
void Update ()
 

Detailed Description

Definition at line 8 of file UIBook.cs.

Member Enumeration Documentation

◆ Mode

Enumerator
Help 
Announce 
Book 
Parchment 
Gallery 
About 

Definition at line 10 of file UIBook.cs.

Member Function Documentation

◆ AddButton()

UIButton UIBook.AddButton ( string  lang,
Action  action 
)
inline

Definition at line 645 of file UIBook.cs.

648 {
649 item2 = item3;
650 idFirstFile = null;
651 }
652 }
653 this.list.Refresh();
654 if (item2 != null)
UIList list
Definition: UIBook.cs:274
string idFirstFile
Definition: UIBook.cs:291
virtual void Refresh(bool highlightLast=false)
Definition: UIList.cs:476

◆ AddButtonClose()

void UIBook.AddButtonClose ( )
inline

Definition at line 637 of file UIBook.cs.

640 {
641 item.items.Add(item3);
642 }
643 else

Referenced by UIBook.Page.BuildNote().

◆ AddPage()

void UIBook.AddPage ( Page  page)
inline

Definition at line 551 of file UIBook.cs.

552 {
553 page.idx = pages.Count;
554 pages.Add(page);
555 page.book = this;
556 }
List< Page > pages
Definition: UIBook.cs:266

References pages.

Referenced by BuildPages(), and ContentGallery.Refresh().

◆ Awake()

void UIBook.Awake ( )
inlineprivate

Definition at line 334 of file UIBook.cs.

335 {
336 if (searchContext == null || Application.isEditor)
337 {
340 }
341 if ((bool)inputSearch)
342 {
343 inputSearch.onValueChanged.AddListener(Search);
344 inputSearch.onSubmit.AddListener(Search);
345 lastSearch = null;
346 }
347 }
string lastSearch
Definition: UIBook.cs:320
InputField inputSearch
Definition: UIBook.cs:312
static SearchContext searchContext
Definition: UIBook.cs:330

References SearchContext.Init(), inputSearch, lastSearch, Search, and searchContext.

◆ BuildPages()

void UIBook.BuildPages ( )
inline

Definition at line 495 of file UIBook.cs.

496 {
497 pages.Clear();
498 string[] array = bookItem?.lines;
499 if (bookItem?.path != null && array == null)
500 {
501 array = IO.LoadTextArray(bookItem.path);
502 }
503 if (array.IsEmpty())
504 {
505 List<string> list = new List<string>
506 {
511 CorePath.CorePackage.TextEN
512 };
513 if (idFile == "version" && Lang.langCode == "CN")
514 {
515 list.Insert(1, CorePath.CorePackage.TextEN);
516 }
517 foreach (string item in list)
518 {
519 array = IO.LoadTextArray(item + idFile);
520 if (!array.IsEmpty())
521 {
522 break;
523 }
524 }
525 }
526 if (array == null)
527 {
528 array = Array.Empty<string>();
529 }
530 Page page = new Page();
531 int num = 0;
532 string[] array2 = array;
533 foreach (string text in array2)
534 {
535 if (bookItem != null && num == 0)
536 {
537 num++;
538 continue;
539 }
540 if (text == "{p}")
541 {
542 AddPage(page);
543 page = new Page();
544 }
545 page.lines.Add(text);
546 num++;
547 }
548 AddPage(page);
549 }
static string Help
Definition: CorePath.cs:69
static string TextEN
Definition: CorePath.cs:61
static string Text
Definition: CorePath.cs:59
static string HelpEN
Definition: CorePath.cs:71
static string TextCommon
Definition: CorePath.cs:57
Definition: IO.cs:11
static string[] LoadTextArray(string _path)
Definition: IO.cs:475
Definition: Lang.cs:6
static string langCode
Definition: Lang.cs:28
void AddPage(Page page)
Definition: UIBook.cs:551
BookList.Item bookItem
Definition: UIBook.cs:302
string idFile
Definition: UIBook.cs:285

References AddPage(), bookItem, CorePath.CorePackage.Help, CorePath.CorePackage.HelpEN, idFile, item, Lang.langCode, list, pages, CorePath.CorePackage.Text, CorePath.CorePackage.TextCommon, and CorePath.CorePackage.TextEN.

Referenced by RefreshTopics(), and Show().

◆ ClearSearch()

void UIBook.ClearSearch ( )
inline

Definition at line 434 of file UIBook.cs.

435 {
436 inputSearch.text = "";
437 lastSearch = null;
438 }

References lastSearch.

◆ ModPage()

void UIBook.ModPage ( int  a)
inline

Definition at line 440 of file UIBook.cs.

441 {
442 SE.Play("read_paper");
443 if ((bool)note2)
444 {
445 a *= 2;
446 }
447 currentPage += a;
448 if (currentPage < 0)
449 {
450 currentPage = 0;
451 }
452 if (currentPage >= pages.Count)
453 {
454 currentPage = pages.Count - ((!note2) ? 1 : 2);
455 }
456 ShowPage(currentPage);
457 }
int currentPage
Definition: UIBook.cs:264
UINote note2
Definition: UIBook.cs:270

References currentPage, note2, and pages.

◆ RefreshTopics()

void UIBook.RefreshTopics ( )
inline

Definition at line 558 of file UIBook.cs.

559 {
560 List<UIList> lists = new List<UIList>();
561 lists.Add(this.list);
562 this.list.Clear();
563 this.list.callbacks = new UIList.Callback<Item, ButtonCategory>
564 {
565 onClick = delegate(Item a, ButtonCategory b)
566 {
567 if (a.items.Count > 0)
568 {
569 b.buttonFold.onClick.Invoke();
570 }
571 else
572 {
573 idFile = a.idFile;
574 idTopic = a.id;
575 textTitle.SetText(a.title);
576 BuildPages();
577 ShowPage();
578 }
579 },
580 onInstantiate = delegate(Item a, ButtonCategory b)
581 {
582 b.mainText.text = a.title;
583 bool flag = false;
584 if (a.items.Count > 0)
585 {
586 foreach (Item item4 in a.items)
587 {
588 if (item4.idFile == idFile && item4.id == idTopic)
589 {
590 flag = true;
591 }
592 }
593 }
594 b.SetFold(a.items.Count > 0, !flag, delegate(UIList l)
595 {
596 lists.Add(l);
597 foreach (Item item5 in a.items)
598 {
599 l.Add(item5);
600 }
601 });
602 },
603 onRefresh = null
604 };
605 string oldValue = '\t'.ToString();
606 Item item = null;
607 Item item2 = null;
608 helpTitles.Clear();
609 List<string> list = new List<string>();
610 list.AddRange(LoadBuiltInTopics());
611 foreach (Func<string[]> topicLoader in topicLoaders)
612 {
613 try
614 {
615 list.AddRange(topicLoader());
616 }
617 catch (Exception arg)
618 {
619 Debug.LogWarning($"#book external topic loader failed\n{arg}");
620 }
621 }
622 foreach (string item6 in list)
623 {
624 string[] array = item6.Replace(oldValue, "").Split(',');
625 string[] array2 = array[0].Split('-');
626 Item item3 = new Item
627 {
628 idFile = array2[0],
629 id = array2[1],
630 title = array[1]
631 };
632 helpTitles[array[0]] = item3.title.Replace("$", "");
633 if (item3.title.StartsWith("$"))
634 {
635 item = item3;
item3. title
Definition: UIBook.cs:640
$
Definition: UIBook.cs:638
this[] LoadBuiltInTopics()
Definition: UIBook.cs:676
UIButton buttonFold
void SetFold(bool show, bool folded)
string idTopic
Definition: UIBook.cs:288
UIText textTitle
Definition: UIBook.cs:278
static List< Func< string[]> > topicLoaders
Definition: UIBook.cs:332
static Dictionary< string, string > helpTitles
Definition: UIBook.cs:259
void BuildPages()
Definition: UIBook.cs:495
Definition: UIList.cs:9
override void Clear()
Definition: UIList.cs:401
void SetText(string s)
Definition: UIText.cs:163

References $, BuildPages(), ButtonCategory.buttonFold, UIList.Clear(), Debug, helpTitles, UIBook.Item.id, UIBook.Item.idFile, idFile, idTopic, item, UIBook.Item.items, list, LoadBuiltInTopics(), ButtonCategory.SetFold(), UIText.SetText(), textTitle, UIBook.Item.title, title, and topicLoaders.

Referenced by Show().

◆ Search()

void UIBook.Search ( string  s)
inline

Definition at line 371 of file UIBook.cs.

372 {
373 if (s == lastSearch)
374 {
375 return;
376 }
377 lastSearch = s;
378 if (s.IsEmpty())
379 {
380 return;
381 }
382 transSearchResult.SetActive(enable: true);
384 listSearchResult.callbacks = new UIList.Callback<SearchContext.Item, UIButton>
385 {
386 onClick = delegate(SearchContext.Item a, UIButton b)
387 {
388 if (!a.system)
389 {
390 SE.Play("click_recipe");
391 searchWord = s;
392 Show(a.idFile, a.idTopic);
393 }
394 },
395 onRedraw = delegate(SearchContext.Item a, UIButton b, int i)
396 {
397 if (a.system)
398 {
399 b.mainText.text = "";
400 b.subText.text = a.text;
401 }
402 else
403 {
404 string text = helpTitles.TryGetValue(a.idFile + "-") ?? "";
405 string text2 = helpTitles.TryGetValue(a.idFile + "-" + a.idTopic) ?? a.idTopic;
406 b.mainText.text = (text.IsEmpty() ? "" : (text + " - ")) + text2;
407 string text3 = a.text;
408 if (!text3.Contains("</color>"))
409 {
410 int num = a.textSearch.IndexOf(s.ToLower());
411 if (num != -1)
412 {
413 text3 = text3.Substring(0, num) + text3.Substring(num, s.Length).TagColor(colorSearchHit) + text3.Substring(num + s.Length);
414 }
415 }
416 b.subText.text = text3;
417 }
418 },
419 onList = delegate
420 {
422 {
424 }
425 },
426 onRefresh = null
427 };
429 scrollView.content.RebuildLayout(recursive: true);
430 RectTransform rectTransform = transSearchResult.Rect();
431 rectTransform.sizeDelta = new Vector2(rectTransform.sizeDelta.x, Mathf.Min(searchResultHeight, scrollView.content.sizeDelta.y + marginSearchResult));
432 }
List< Item > Search(string s)
static string searchWord
Definition: UIBook.cs:257
void Show()
Definition: UIBook.cs:472
UIDynamicList listSearchResult
Definition: UIBook.cs:276
float marginSearchResult
Definition: UIBook.cs:326
UIScrollView scrollView
Definition: UIBook.cs:316
float searchResultHeight
Definition: UIBook.cs:324
Color colorSearchHit
Definition: UIBook.cs:328
Transform transSearchResult
Definition: UIBook.cs:318
override void List()
override void Add(object o)
override void Clear()

References UIDynamicList.Add(), UIDynamicList.Clear(), colorSearchHit, helpTitles, item, lastSearch, UIDynamicList.List(), listSearchResult, marginSearchResult, scrollView, SearchContext.Search(), searchContext, searchResultHeight, searchWord, Show(), and transSearchResult.

◆ Show() [1/2]

void UIBook.Show ( )
inline

Definition at line 472 of file UIBook.cs.

473 {
474 note.Clear();
475 if ((bool)note2)
476 {
477 note2.Clear();
478 }
479 if ((bool)layoutButton)
480 {
481 moldButton = layoutButton.CreateMold<UIButton>();
482 }
483 if (mode == Mode.Help)
484 {
488 }
489 else
490 {
491 ShowPage(currentPage);
492 }
493 }
Mode
Definition: UIBook.cs:11
void RefreshTopics()
Definition: UIBook.cs:558
Mode mode
Definition: UIBook.cs:261
LayoutGroup layoutButton
Definition: UIBook.cs:298
string idFirstTopic
Definition: UIBook.cs:294
UIButton moldButton
Definition: UIBook.cs:300
UINote note
Definition: UIBook.cs:268
void Clear()
Definition: UINote.cs:35

References UINote.Clear(), currentPage, idFile, idFirstFile, idFirstTopic, idTopic, layoutButton, mode, moldButton, note, note2, and RefreshTopics().

Referenced by Search(), and Show().

◆ Show() [2/2]

void UIBook.Show ( string  _idFile = null,
string  _idTopic = null,
string  title = null,
BookList::Item  _bookItem = null 
)
inline

Definition at line 459 of file UIBook.cs.

460 {
461 if (!title.IsEmpty() && (bool)window)
462 {
464 }
465 idFile = _idFile;
466 idTopic = _idTopic;
467 bookItem = _bookItem;
468 BuildPages();
469 Show();
470 }
Window window
Definition: UIBook.cs:306
UIText textCaption
Definition: Window.cs:610

References bookItem, BuildPages(), idFile, idTopic, UIText.SetText(), Show(), Window.textCaption, title, and window.

Referenced by LayerHelp.OnAfterInit(), ContentGallery.Refresh(), and LayerHelp.Toggle().

◆ Update()

void UIBook.Update ( )
inlineprivate

Definition at line 349 of file UIBook.cs.

350 {
351 if ((bool)inputSearch)
352 {
353 if (inputSearch.isFocused)
354 {
355 showSearchResult = true;
356 }
357 else if (Input.GetMouseButtonDown(0) && !InputModuleEX.IsPointerOver(scrollView) && !InputModuleEX.IsPointerOver(inputSearch))
358 {
359 showSearchResult = false;
360 }
361 buttonClear.SetActive(inputSearch.text != "");
362 transSearchResult.SetActive((inputSearch.isFocused || showSearchResult) && inputSearch.text != "");
363 if (Input.GetKeyDown(KeyCode.Escape) && inputSearch.text == "")
364 {
366 EInput.Consume(consumeAxis: false, 5);
367 }
368 }
369 }
Definition: EInput.cs:8
static void Consume(int _skipFrame)
Definition: EInput.cs:667
static bool IsPointerOver(Component c)
virtual void Close()
Definition: Layer.cs:463
bool showSearchResult
Definition: UIBook.cs:322
UIButton buttonClear
Definition: UIBook.cs:314
Layer layer
Definition: Window.cs:677

References buttonClear, Layer.Close(), EInput.Consume(), inputSearch, InputModuleEX.IsPointerOver(), Window.layer, scrollView, showSearchResult, transSearchResult, and window.

Member Data Documentation

◆ bookItem

BookList.Item UIBook.bookItem

Definition at line 302 of file UIBook.cs.

Referenced by BuildPages(), and Show().

◆ buttonClear

UIButton UIBook.buttonClear

Definition at line 314 of file UIBook.cs.

Referenced by Update().

◆ buttonNext

UIButton UIBook.buttonNext

Definition at line 310 of file UIBook.cs.

◆ buttonPrev

UIButton UIBook.buttonPrev

Definition at line 308 of file UIBook.cs.

◆ colorSearchHit

Color UIBook.colorSearchHit

Definition at line 328 of file UIBook.cs.

Referenced by UIBook.Page.BuildNote(), and Search().

◆ currentPage

int UIBook.currentPage

Definition at line 264 of file UIBook.cs.

Referenced by ModPage(), ContentGallery.OnDestroy(), Show(), and ContentGallery.ToggleMode().

◆ helpTitles

Dictionary<string, string> UIBook.helpTitles = new Dictionary<string, string>()
static

Definition at line 259 of file UIBook.cs.

Referenced by RefreshTopics(), and Search().

◆ idFile

string UIBook.idFile

Definition at line 285 of file UIBook.cs.

Referenced by BuildPages(), LayerHelp.OnDestroy(), RefreshTopics(), and Show().

◆ idFirstFile

string UIBook.idFirstFile

Definition at line 291 of file UIBook.cs.

Referenced by Show().

◆ idFirstTopic

string UIBook.idFirstTopic

Definition at line 294 of file UIBook.cs.

Referenced by Show().

◆ idTopic

string UIBook.idTopic

Definition at line 288 of file UIBook.cs.

Referenced by UIBook.Page.BuildNote(), LayerHelp.OnDestroy(), RefreshTopics(), and Show().

◆ inputSearch

InputField UIBook.inputSearch

Definition at line 312 of file UIBook.cs.

Referenced by Awake(), LayerHelp.OnRightClick(), and Update().

◆ lastSearch

string UIBook.lastSearch

Definition at line 320 of file UIBook.cs.

Referenced by Awake(), ClearSearch(), and Search().

◆ layoutButton

LayoutGroup UIBook.layoutButton

Definition at line 298 of file UIBook.cs.

Referenced by Show().

◆ list

UIList UIBook.list

Definition at line 274 of file UIBook.cs.

Referenced by BuildPages(), and RefreshTopics().

◆ listSearchResult

UIDynamicList UIBook.listSearchResult

Definition at line 276 of file UIBook.cs.

Referenced by Search().

◆ marginSearchResult

float UIBook.marginSearchResult

Definition at line 326 of file UIBook.cs.

Referenced by Search().

◆ mode

Mode UIBook.mode

◆ moldButton

UIButton UIBook.moldButton

Definition at line 300 of file UIBook.cs.

Referenced by Show().

◆ note

UINote UIBook.note

Definition at line 268 of file UIBook.cs.

Referenced by Show().

◆ note2

UINote UIBook.note2

Definition at line 270 of file UIBook.cs.

Referenced by LoadBuiltInTopics(), ModPage(), and Show().

◆ noteSearch

UINote UIBook.noteSearch

Definition at line 272 of file UIBook.cs.

◆ pages

List<Page> UIBook.pages = new List<Page>()

Definition at line 266 of file UIBook.cs.

Referenced by AddPage(), BuildPages(), ModPage(), and ContentGallery.Refresh().

◆ scrollbar

Scrollbar UIBook.scrollbar

Definition at line 304 of file UIBook.cs.

◆ scrollView

UIScrollView UIBook.scrollView

Definition at line 316 of file UIBook.cs.

Referenced by Search(), and Update().

◆ searchContext

SearchContext UIBook.searchContext
static

Definition at line 330 of file UIBook.cs.

Referenced by Awake(), and Search().

◆ searchResultHeight

float UIBook.searchResultHeight

Definition at line 324 of file UIBook.cs.

Referenced by Search().

◆ searchWord

string UIBook.searchWord
static

Definition at line 257 of file UIBook.cs.

Referenced by UIBook.Page.BuildNote(), and Search().

◆ showSearchResult

bool UIBook.showSearchResult

Definition at line 322 of file UIBook.cs.

Referenced by Update().

◆ skin

SkinRootStatic UIBook.skin

Definition at line 296 of file UIBook.cs.

◆ str_pc

string UIBook.str_pc
static

Definition at line 255 of file UIBook.cs.

Referenced by UIBook.Page.BuildNote().

◆ textPage

UIText UIBook.textPage

Definition at line 280 of file UIBook.cs.

◆ textPage2

UIText UIBook.textPage2

Definition at line 282 of file UIBook.cs.

◆ textTitle

UIText UIBook.textTitle

Definition at line 278 of file UIBook.cs.

Referenced by RefreshTopics().

◆ topicLoaders

List<Func<string[]> > UIBook.topicLoaders = new List<Func<string[]>>()
static

Definition at line 332 of file UIBook.cs.

Referenced by ModUtil.OnModsActivated(), and RefreshTopics().

◆ transSearchResult

Transform UIBook.transSearchResult

Definition at line 318 of file UIBook.cs.

Referenced by LayerHelp.OnRightClick(), Search(), and Update().

◆ window

Window UIBook.window

Definition at line 306 of file UIBook.cs.

Referenced by Show(), and Update().


The documentation for this class was generated from the following file: