protected virtual float GetSectionHorizontalNormalizedPosition(UserSection section) { if (section == null) { return(0); } var contentCorners = new Vector3[4]; scrollRect.content.GetWorldCorners(contentCorners); var contentWidth = GetWidth(contentCorners); var viewportWidth = GetWidth(scrollRect.viewport); var divisor = contentWidth - viewportWidth; if (divisor <= 0) { return(0); } var buttonX = GetButtonX((RectTransform)SectionButtons[section].transform, contentCorners); var dividend = buttonX - viewportWidth / 2; return(Mathf.Clamp01(dividend / divisor)); }
public override void Initialize(UserSection section) { base.Initialize(section); if (started) { ResetIsOn(); } }
protected virtual void OnSectionSelected(object sender, UserSectionSelectedEventArgs eventArgs) { if (CurrentSection != null) { CurrentSection.StatusChanged -= UpdateOn; } CurrentSection = eventArgs.SelectedSection; CurrentSection.StatusChanged += UpdateOn; UpdateOn(); }
public UserEncounter(User user, Encounter data, EncounterStatus status) { User = user; Data = data; Status = status; foreach (var section in data.Content.NonImageContent.Sections) { var sectionStatus = status.ContentStatus.GetSectionStatus(section.Key); var userSection = new UserSection(this, section.Value, sectionStatus); userSection.StatusChanged += UpdateIsRead; Sections.Add(section.Key, userSection); } }
protected UserTab GetLastSequentialTabRead(UserSection section) { UserTab lastTab = null; foreach (var tab in section.Tabs.Values) { if (!tab.IsRead()) { return(lastTab); } lastTab = tab; } return(lastTab); }
protected SectionTabPair GetStartPoint(UserSection lastReadSection, UserSection firstUnreadSection) { UserTab tab = GetLastSequentialTabRead(firstUnreadSection); if (tab != null) { return(new SectionTabPair(firstUnreadSection, tab)); } if (lastReadSection == null || lastReadSection.Tabs.ValueArr.Length == 0) { return(null); } tab = lastReadSection.Tabs.ValueArr[lastReadSection.Tabs.ValueArr.Length - 1]; return(new SectionTabPair(lastReadSection, tab)); }
protected SectionTabPair GetStartPoint(UserEncounter encounter) { UserSection lastSection = null; foreach (var section in encounter.Sections.Values) { if (section.IsRead()) { lastSection = section; continue; } return(GetStartPoint(lastSection, section)); } return(null); }
protected virtual void OnSectionSelected(object sender, UserSectionSelectedEventArgs e) { var encounter = EncounterSelectedListener.CurrentValue.Encounter; var nonImageContent = encounter.Data.Content.NonImageContent; var sectionIndex = nonImageContent.CurrentSectionIndex; PreviousSection = (sectionIndex > 0) ? encounter.Sections[sectionIndex - 1].Value : null; NextSection = (sectionIndex + 1 < encounter.Sections.Count) ? encounter.Sections[sectionIndex + 1].Value : null; CurrentSection = e.SelectedSection; if ((object)sender == this || (e.ChangeType != ChangeType.Next && e.ChangeType != ChangeType.Previous)) { return; } if (CurrentCoroutine != null) { StopCoroutine(CurrentCoroutine); } var direction = (e.ChangeType == ChangeType.Next) ? Direction.Next : Direction.Previous; CurrentCoroutine = StartCoroutine(SectionChanged(direction)); }
protected override void OnSectionSelected(object sender, UserSectionSelectedEventArgs e) { if (CurrentSection == e.SelectedSection) { return; } var encounter = EncounterSelector.CurrentValue.Encounter; var content = encounter.Data.Content.NonImageContent; var sections = encounter.Sections; var currentIndex = content.CurrentSectionIndex; CurrentSection = e.SelectedSection; NextSection = (currentIndex + 1 < sections.Count) ? sections[currentIndex + 1].Value : null; PreviousSection = (currentIndex > 0) ? sections[currentIndex - 1].Value : null; if (e.ChangeType != ChangeType.Next && e.ChangeType != ChangeType.Previous) { UpdatePosition(CurrentSection); } base.OnSectionSelected(sender, e); }
public override void Initialize(UserSection section) { base.Initialize(section); ToggleChanged(false); }
public UserSectionSelectedEventArgs(UserSection selectedSection, ChangeType changeType) { SelectedSection = selectedSection; ChangeType = changeType; }
public SectionTabPair(UserSection section, UserTab tab) { Section = section; Tab = tab; }
protected virtual void UpdatePosition(UserSection section) { Canvas.ForceUpdateCanvases(); shouldUpdate = true; SetScrollPosition(GetSectionHorizontalNormalizedPosition(section)); }
public virtual void Initialize(UserSection section) => base.Display(this, new UserSectionSelectedEventArgs(Section = section, ChangeType.JumpTo));
protected virtual void OnSectionSelected(object sender, UserSectionSelectedEventArgs eventArgs) => CurrentUserSection = eventArgs.SelectedSection;