Exemplo n.º 1
0
        private void OnPreviewFavoriteToggled(Widget_MapPreview preview)
        {
            var makeFavorite = !preview.IsFavorite;

            (makeFavorite ? SoundDefOf.Checkbox_TurnedOn : SoundDefOf.Checkbox_TurnedOff).PlayOneShotOnCamera();
            if (makeFavorite)
            {
                favoritesProvider.Add(new Widget_MapPreview(preview));
            }
            else
            {
                favoritesProvider.Remove(preview);
            }
            var fav = favoritesProvider.TryFindPreview(preview.Seed);

            if (fav != null)
            {
                fav.IsFavorite = makeFavorite;
            }
            var gen = previewGenerator.TryFindPreview(preview.Seed);

            if (gen != null)
            {
                gen.IsFavorite = makeFavorite;
            }
        }
 private void OnFavorite(Widget_MapPreview widget)
 {
     if (OnFavoriteToggled != null)
     {
         OnFavoriteToggled(widget);
     }
 }
        private void DrawPage(int page, Rect inRect)
        {
            float rowCount     = Mathf.Sqrt(PreviewsPerPage);
            var   totalSpacing = PreviewSpacing * (rowCount - 1);
            var   previewSize  = new Vector2((inRect.width - totalSpacing) / rowCount, (inRect.height - totalSpacing) / rowCount);
            bool  anyOverlayDrawingRequired = false;
            var   maxPreviewIndex           = Mathf.Min(MaxIndexOnPage(page), previews.Count - 1);

            for (int i = maxPreviewIndex; i >= MinIndexOnPage(page); i--)
            {
                var preview         = previews[i];
                var previewPosition = GetPreviewPositionFromIndex(i);
                var previewRect     = new Rect(
                    inRect.x + (inRect.width - previewSize.x) * previewPosition.x,
                    inRect.y + (inRect.height - previewSize.y) * previewPosition.y,
                    previewSize.x, previewSize.y);
                var isInteractive = overlayPreview == null && !PageTransitionInProgress;
                preview.Draw(previewRect, i, isInteractive);
                if (preview.WantsOverlayDrawing)
                {
                    overlayPreview            = preview;
                    anyOverlayDrawingRequired = true;
                }
            }
            if (!anyOverlayDrawingRequired)
            {
                overlayPreview = null;
            }
        }
 public virtual void OpenPage(int pageIndex)
 {
     if (!PageIsAvailable(pageIndex))
     {
         return;
     }
     overlayPreview = null;
     if (pageIndex != currentPage)
     {
         outgoingPage           = currentPage;
         currentPage            = pageIndex;
         pageInterpolator.value = 0f;
         pageInterpolator.StartInterpolation(1f, PageFlipDuration, CurveType.CubicInOut).SetFinishedCallback(OnPageFlipFinished);
     }
 }