private void Init() { glowSprite = CreateChild <UguiSprite>("glow"); { glowSprite.Size = new Vector2(BaseSize + GlowSizeOffset, BaseSize + GlowSizeOffset); glowSprite.SpriteName = "glow-square-32"; glowSprite.ImageType = Image.Type.Sliced; glowSprite.Color = ColorPreset.SecondaryFocus; glowSprite.RotationZ = 45f; glowSprite.IsRaycastTarget = false; } fillSprite = CreateChild <UguiSprite>("fill"); { fillSprite.Anchor = AnchorType.Fill; fillSprite.Offset = Offset.Zero; fillSprite.Color = ColorPreset.SecondaryFocus; fillSprite.RotationZ = 45f; fillSprite.IsRaycastTarget = false; fillSprite.AddEffect(new AdditiveShaderEffect()); } showAni = new Anime(); showAni.AnimateFloat((alpha) => glowSprite.Alpha = alpha) .AddTime(0f, 0f) .AddTime(0.05f, 0f, EaseType.QuadEaseOut) .AddTime(0.15f, 1f) .Build(); showAni.AnimateFloat((alpha) => fillSprite.Alpha = alpha) .AddTime(0f, 0.85f, EaseType.QuadEaseOut) .AddTime(0.15f, 0.25f) .Build(); showAni.AnimateVector2((size) => fillSprite.Size = size) .AddTime(0f, new Vector2(BaseSize + ShowShrinkSize, BaseSize + ShowShrinkSize), EaseType.CubicEaseOut) .AddTime(0.15f, new Vector2(BaseSize, BaseSize)) .Build(); showAni.AddEvent(showAni.Duration, () => repeatAni.PlayFromStart()); hideAni = new Anime(); hideAni.AddEvent(0f, () => repeatAni.Pause()); hideAni.AnimateFloat((alpha) => glowSprite.Alpha = alpha) .AddTime(0f, () => glowSprite.Alpha) .AddTime(0.25f, 0f) .Build(); hideAni.AnimateFloat((alpha) => fillSprite.Alpha = alpha) .AddTime(0f, () => fillSprite.Alpha) .AddTime(0.25f, 0f) .Build(); hideAni.AddEvent(hideAni.Duration, () => Recycler.Return(this)); repeatAni = new Anime() { WrapMode = WrapModeType.Loop, }; repeatAni.AnimateFloat((alpha) => fillSprite.Alpha = alpha) .AddTime(0f, 0.25f, EaseType.QuadEaseOut) .AddTime(0.4f, 0.75f, EaseType.QuadEaseIn) .AddTime(0.8f, 0.25f) .Build(); }
private void Init(IMapSelection mapSelection) { blur = CreateChild <BlurDisplay>("focus-blur", 0); { blur.Anchor = AnchorType.Fill; blur.Offset = Offset.Zero; } gradientSprite = CreateChild <UguiSprite>("gradient", 1); { gradientSprite.Anchor = AnchorType.Fill; gradientSprite.RawSize = Vector2.zero; gradientEffect = gradientSprite.AddEffect(new GradientEffect()); gradientEffect.Component.direction = UIGradient.Direction.Vertical; } quitButton = CreateChild <MenuButton>("quit-button", 2); { quitButton.Anchor = AnchorType.Bottom; quitButton.Y = 100; quitButton.Size = new Vector2(160f, 160f); quitButton.LabelText = "Quit"; quitButton.IconName = "icon-power"; quitButton.OnTriggered += OnQuitButton; } backButton = CreateChild <MenuButton>("back-button", 2); { backButton.X = -160f; backButton.Size = new Vector2(160f, 160f); backButton.LabelText = "Back"; backButton.IconName = "icon-arrow-left"; backButton.OnTriggered += OnBackButton; } playButton = CreateChild <MenuButton>("play-button", 2); { playButton.Size = new Vector2(160f, 160f); playButton.LabelText = "Play"; playButton.IconName = "icon-play"; playButton.OnTriggered += OnPlayButton; } downloadButton = CreateChild <MenuButton>("download-button", 2); { downloadButton.X = 160f; downloadButton.Size = new Vector2(160f, 160f); downloadButton.LabelText = "Download"; downloadButton.IconName = "icon-download"; downloadButton.OnTriggered += OnDownloadButton; } OnEnableInited(); }
private void Init() { blurDisplay = CreateChild <BlurDisplay>("blur", 0); { blurDisplay.Anchor = AnchorType.Fill; blurDisplay.RawSize = Vector2.zero; } darkSprite = CreateChild <UguiSprite>("dark", 1); { darkSprite.Anchor = AnchorType.Fill; darkSprite.RawSize = Vector2.zero; darkSprite.Color = new Color(0f, 0f, 0f, 0.75f); } brightenSprite = CreateChild <UguiSprite>("brighten", 2); { float size = Math.Max(RootMain.Resolution.x, RootMain.Resolution.y); brightenSprite.Size = new Vector2(size, size); brightenSprite.Color = Color.gray; brightenSprite.SpriteName = "glow-128"; brightenSprite.AddEffect(new AdditiveShaderEffect()); } shadeSprite = CreateChild <UguiSprite>("shade", 3); { shadeSprite.Anchor = AnchorType.TopRight; shadeSprite.Pivot = PivotType.TopRight; shadeSprite.RotationZ = -5f; shadeSprite.Color = new Color(1f, 1f, 1f, 0.25f); shadeSprite.X = -480f; shadeSprite.Y = 0f; var gradient = shadeSprite.AddEffect(new GradientEffect()).Component; gradient.color1 = Color.black; gradient.direction = UIGradient.Direction.Vertical; } AdjustShade(); }
private void Init() { mapTagRecycler = new ManagedRecycler <MapMetaTag>(CreateMapTag); OnTriggered += () => { if (Active && Mapset != null) { if (Model.SelectedMapset.Value != Mapset) { Model.SelectMapset(Mapset); } else { Model.NavigateToPrepare(); } } }; container = CreateChild <UguiObject>("container"); { container.Anchor = AnchorType.CenterStretch; container.SetOffsetVertical(5f); container.Width = UnfocusedWidth; highlight = container.CreateChild <UguiSprite>("highlight"); { highlight.Size = new Vector2(1920f, 144f); highlight.SpriteName = "glow-128"; highlight.Alpha = UnfocusedHighlightAlpha; highlight.IsRaycastTarget = false; highlight.AddEffect(new AdditiveShaderEffect()); } glow = container.CreateChild <UguiSprite>("glow"); { glow.Anchor = AnchorType.Fill; glow.RawSize = new Vector2(30f, 30f); glow.SpriteName = "glow-circle-32"; glow.ImageType = Image.Type.Sliced; glow.Color = UnfocusedGlowColor; } thumbContainer = container.CreateChild <UguiSprite>("thumb"); { thumbContainer.Anchor = AnchorType.Fill; thumbContainer.RawSize = Vector2.zero; thumbContainer.SpriteName = "circle-32"; thumbContainer.ImageType = Image.Type.Sliced; thumbContainer.Color = Color.black; thumbContainer.AddEffect(new MaskEffect()); thumbImage = thumbContainer.CreateChild <UguiTexture>("image"); { thumbImage.Anchor = AnchorType.Fill; thumbImage.RawSize = Vector2.zero; thumbImage.Color = UnfocusedThumbColor; } } titleLabel = container.CreateChild <Label>("title"); { titleLabel.Anchor = AnchorType.TopStretch; titleLabel.Pivot = PivotType.Top; titleLabel.Y = -8f; titleLabel.Height = 32f; titleLabel.SetOffsetHorizontal(20f); titleLabel.IsItalic = true; titleLabel.IsBold = true; titleLabel.WrapText = true; titleLabel.Alignment = TextAnchor.MiddleLeft; titleLabel.FontSize = 22; titleShadow = titleLabel.AddEffect(new ShadowEffect()).Component; titleShadow.style = ShadowStyle.Shadow; titleShadow.effectColor = Color.black; titleShadow.enabled = false; } artistLabel = container.CreateChild <Label>("artist"); { artistLabel.Anchor = AnchorType.BottomStretch; artistLabel.Pivot = PivotType.Bottom; artistLabel.Y = 8f; artistLabel.Height = 24f; artistLabel.SetOffsetHorizontal(20f); artistLabel.WrapText = true; artistLabel.Alignment = TextAnchor.MiddleLeft; artistLabel.FontSize = 18; artistShadow = artistLabel.AddEffect(new ShadowEffect()).Component; artistShadow.style = ShadowStyle.Shadow; artistShadow.effectColor = Color.black; artistShadow.enabled = false; } creatorLabel = container.CreateChild <Label>("creator"); { creatorLabel.Anchor = AnchorType.BottomStretch; creatorLabel.Pivot = PivotType.Bottom; creatorLabel.Y = 8f; creatorLabel.Height = 24f; creatorLabel.SetOffsetHorizontal(20f); creatorLabel.WrapText = true; creatorLabel.Alignment = TextAnchor.MiddleRight; creatorLabel.FontSize = 18; creatorShadow = creatorLabel.AddEffect(new ShadowEffect()).Component; creatorShadow.style = ShadowStyle.Shadow; creatorShadow.effectColor = Color.black; creatorShadow.enabled = false; } mapTagGrid = container.CreateChild <UguiGrid>("map-tag-grid"); { mapTagGrid.Anchor = AnchorType.TopStretch; mapTagGrid.Pivot = PivotType.Top; mapTagGrid.Y = -8f; mapTagGrid.Height = MapTagCellSize.y; mapTagGrid.SetOffsetHorizontal(20f); mapTagGrid.Alignment = TextAnchor.MiddleRight; mapTagGrid.Axis = GridLayoutGroup.Axis.Horizontal; mapTagGrid.SpaceWidth = 8f; mapTagGrid.CellSize = MapTagCellSize; mapTagGrid.Limit = 0; } } backgroundAgent = new CacherAgent <IMap, IMapBackground>(BackgroundCacher) { UseDelayedRemove = true, RemoveDelay = 2f }; backgroundAgent.OnFinished += OnBackgroundLoaded; OnEnableInited(); }
private void Init(IGameSession gameSession) { gameSession.OnSoftInit += () => { scoreProcessor = gameSession.ScoreProcessor; scoreProcessor.Health.BindAndTrigger(OnHealthChange); SetFailingForce(false); }; gameSession.OnSoftDispose += () => { ProgressBar.Value = 0f; }; ProgressBar = CreateChild <UguiProgressBar>("progress", 0); { fgSprite = ProgressBar.Foreground; fgSprite.Color = ColorPreset.PrimaryFocus.Base; thumbSprite = ProgressBar.Thumb; thumbSprite.Active = true; thumbSprite.SpriteName = "glow-128"; thumbSprite.Color = ColorPreset.PrimaryFocus.Alpha(0f); thumbSprite.Size = new Vector2(36f, 88f); pinEffectSprite = thumbSprite.CreateChild <UguiSprite>("effect"); { pinEffectSprite.Color = ColorPreset.PrimaryFocus.Alpha(0f); pinEffectSprite.SpriteName = "glow-128"; pinEffectSprite.Size = thumbSprite.Size * 6.5f; pinEffectSprite.AddEffect(new AdditiveShaderEffect()); } } Indicator = CreateChild <UguiSprite>("indicator", 1); { Indicator.Color = ColorPreset.PrimaryFocus.Base; } changeAni = new Anime(); changeAni.AnimateFloat((progress) => ProgressBar.Value = progress) .AddTime(0f, () => ProgressBar.Value) .AddTime(0.2f, () => curHealth) .Build(); changeAni.AnimateColor((tint) => fgSprite.Tint = tint) .AddTime(0f, () => barTintFromColor) .AddTime(0.35f, () => barTintToColor) .Build(); pinAni = new Anime(); // Thumb sprite fade and scale pinAni.AnimateFloat((alpha) => thumbSprite.Alpha = alpha) .AddTime(0f, 0f) .AddTime(0.05f, 1f, EaseType.QuadEaseIn) .AddTime(0.25f, 0f) .Build(); pinAni.AnimateVector3((scale) => thumbSprite.Scale = scale) .AddTime(0f, new Vector3(1.1f, 1.1f), EaseType.QuadEaseIn) .AddTime(0.25f, Vector3.one) .Build(); // Pin effect fade and scale pinAni.AnimateFloat((alpha) => pinEffectSprite.Alpha = alpha) .AddTime(0f, 1f, EaseType.QuadEaseOut) .AddTime(0.25f, 0f) .Build(); pinAni.AnimateVector3((scale) => pinEffectSprite.Scale = scale) .AddTime(0f, Vector3.zero, EaseType.CubicEaseOut) .AddTime(0.25f, Vector3.one) .Build(); }
private void Init() { background = CreateChild <UguiSprite>("background", 1); { background.Anchor = AnchorType.Fill; background.Offset = Offset.Zero; background.Color = ColorPreset.Background; } mask = CreateChild <UguiSprite>("mask", 3); { mask.Anchor = AnchorType.Fill; mask.RawSize = Vector2.zero; mask.Position = Vector2.zero; mask.SpriteName = "box"; var maskEffect = mask.AddEffect(new MaskEffect()); maskEffect.Component.showMaskGraphic = false; loggedInView = mask.CreateChild <LoggedInView>("logged-in", 0); { loggedInView.Anchor = AnchorType.Fill; loggedInView.Offset = Offset.Zero; } loggedOutView = mask.CreateChild <LoggedOutView>("logged-out", 0); { loggedOutView.Anchor = AnchorType.Fill; loggedOutView.Offset = Offset.Zero; loggedOutView.CurLoginView.OnNewValue += OnLoginProviderViewChange; } } blocker = CreateChild <Blocker>("blocker", 4); loggedInAni = new Anime(); loggedInAni.AnimateFloat(alpha => loggedInView.Alpha = alpha) .AddTime(0f, () => loggedInView.Alpha) .AddTime(0.25f, 1f) .Build(); loggedInAni.AnimateFloat(alpha => loggedOutView.Alpha = alpha) .AddTime(0f, () => loggedOutView.Alpha) .AddTime(0.25f, 0f) .Build(); loggedInAni.AnimateFloat(height => this.Height = height) .AddTime(0f, () => this.Height) .AddTime(0.25f, LoggedInHeight) .Build(); loggedInAni.AddEvent(0f, () => loggedInView.Active = blocker.Active = true); loggedInAni.AddEvent(loggedInAni.Duration, () => loggedOutView.Active = blocker.Active = false); loggedOutAni = new Anime(); loggedOutAni.AnimateFloat(alpha => loggedInView.Alpha = alpha) .AddTime(0f, () => loggedInView.Alpha) .AddTime(0.25f, 0f) .Build(); loggedOutAni.AnimateFloat(alpha => loggedOutView.Alpha = alpha) .AddTime(0f, () => loggedOutView.Alpha) .AddTime(0.25f, 1f) .Build(); loggedOutAni.AnimateFloat(height => this.Height = height) .AddTime(0f, () => this.Height) .AddTime(0.25f, () => loggedOutView.DesiredHeight) .Build(); loggedOutAni.AddEvent(0f, () => loggedOutView.Active = blocker.Active = true); loggedOutAni.AddEvent(loggedInAni.Duration, () => loggedInView.Active = blocker.Active = false); OnEnableInited(); }
private void Init() { hoverSprite.Depth = 1; hoverSprite.Anchor = AnchorType.Fill; hoverSprite.RawSize = new Vector2(28f, 30f); hoverSprite.Color = Color.black; hoverSprite.SpriteName = "glow-parallel-64"; hoverSprite.ImageType = Image.Type.Sliced; hoverSprite.AddEffect(new FlipEffect()).Component.horizontal = true; mask = CreateChild <UguiSprite>("mask", 0); { mask.Anchor = AnchorType.Fill; mask.RawSize = Vector2.zero; mask.Color = HexColor.Create("2A313A"); mask.SpriteName = "parallel-64"; mask.ImageType = Image.Type.Sliced; mask.AddEffect(new MaskEffect()); mask.AddEffect(new FlipEffect()).Component.horizontal = true; imageDisplay = mask.CreateChild <MapImageDisplay>("imageDisplay", 0); { imageDisplay.Anchor = AnchorType.Fill; imageDisplay.RawSize = Vector2.zero; imageGradient = imageDisplay.CreateChild <UguiSprite>("gradient", 100); { imageGradient.Anchor = AnchorType.Fill; imageGradient.RawSize = Vector2.zero; imageGradient.SpriteName = "gradation-left"; imageGradient.Color = new Color(0f, 0f, 0f, 0.5f); } } progressBar = mask.CreateChild <UguiProgressBar>("progress", 1); { progressBar.Anchor = AnchorType.BottomStretch; progressBar.Pivot = PivotType.Bottom; progressBar.SetOffsetHorizontal(22f, 0f); progressBar.Height = 6f; progressBar.Y = 0f; progressBar.Background.Color = new Color(0f, 0f, 0f, 0.5f); progressBar.Foreground.SetOffsetTop(2f); } titleLabel = mask.CreateChild <Label>("title", 2); { titleLabel.Anchor = AnchorType.TopStretch; titleLabel.Pivot = PivotType.Top; titleLabel.SetOffsetHorizontal(20f, 32f); titleLabel.Y = -8f; titleLabel.Height = 30f; titleLabel.IsBold = true; titleLabel.FontSize = 22; titleLabel.Alignment = TextAnchor.UpperLeft; titleLabel.WrapText = true; var shadow = titleLabel.AddEffect(new ShadowEffect()).Component; shadow.style = ShadowStyle.Outline; shadow.effectDistance = Vector2.one; shadow.effectColor = new Color(0f, 0f, 0f, 0.5f); } artistLabel = mask.CreateChild <Label>("artist", 3); { artistLabel.Anchor = AnchorType.BottomStretch; artistLabel.Pivot = PivotType.Bottom; artistLabel.SetOffsetHorizontal(32f, 20f); artistLabel.Y = 8f; artistLabel.Height = 30f; artistLabel.Alignment = TextAnchor.LowerLeft; artistLabel.WrapText = true; var shadow = artistLabel.AddEffect(new ShadowEffect()).Component; shadow.style = ShadowStyle.Outline; shadow.effectDistance = Vector2.one; shadow.effectColor = new Color(0f, 0f, 0f, 0.5f); } } hoverInAni = new Anime(); hoverInAni.AnimateColor(color => hoverSprite.Color = color) .AddTime(0f, () => hoverSprite.Color) .AddTime(0.25f, () => MapSelection.Background.Value.Highlight) .Build(); hoverInAni.AnimateFloat(alpha => imageGradient.Alpha = alpha) .AddTime(0f, () => imageGradient.Alpha) .AddTime(0.25f, 0f) .Build(); hoverOutAni = new Anime(); hoverOutAni.AnimateColor(color => hoverSprite.Color = color) .AddTime(0f, () => hoverSprite.Color) .AddTime(0.25f, Color.black) .Build(); hoverOutAni.AnimateFloat(alpha => imageGradient.Alpha = alpha) .AddTime(0f, () => imageGradient.Alpha) .AddTime(0.25f, 0.5f) .Build(); OnEnableInited(); }