void DrawText()
        {
            using (new CenterVertical()) {
                GUI.color = colMain;

                if (newVersionAvailable != null)
                {
                    using (ShapesUI.Horizontal) {
                        using (new Center()) {
                            float t    = (float)EditorApplication.timeSinceStartup;
                            float wave = ShapesMath.SmoothCos01(Mathf.PingPong(t, 0.5f) * 2);
                            wave      = Mathf.Lerp(0.5f, 1f, wave);
                            GUI.color = Color.Lerp(Color.white, colF15, wave);
                            LinkLabel(newVersionAvailable + " now available", ShapesInfo.LINK_CHANGELOG);
                            GUI.color = Color.white;
                        }
                    }
                }


                GUILayout.Label($"Shapes {ShapesInfo.Version}", TitleStyle);
                using (ShapesUI.Horizontal) {
                    using (new Center()) {
                        int year = Mathf.Max(DateTime.Now.Year, 2020);                           // just in case your computer clock is wonky~
                        GUILayout.Label($"© {year}", LabelStyle, GUILayout.ExpandWidth(false));
                        LinkLabel("Freya Holmér", ShapesInfo.LINK_TWITTER);
                    }
                }

                GUI.color = Color.white;
                GUILayout.Space(8);
                GUILayout.Label("made possible thanks to\nthe wonderful supporters on", LabelCentered, GUILayout.ExpandWidth(true));
                using (ShapesUI.Horizontal) {
                    using (new Center()) {
                        LinkLabel("Patreon", ShapesInfo.LINK_PATREON);
                    }
                }

                GUI.color = colF15;
                GUILayout.Label("♥", TitleStyle, GUILayout.ExpandWidth(true));
                GUI.color = Color.white;
            }
        }
Example #2
0
        public void DrawBar(FpsController fpsController, float barRadius)
        {
            // get some data
            float barThickness            = fpsController.ammoBarThickness;
            float ammoBarOutlineThickness = fpsController.ammoBarOutlineThickness;
            float angRadMin     = -fpsController.ammoBarAngularSpanRad / 2;
            float angRadMax     = fpsController.ammoBarAngularSpanRad / 2;
            float angRadMinLeft = angRadMin + ShapesMath.TAU / 2;
            float angRadMaxLeft = angRadMax + ShapesMath.TAU / 2;
            float outerRadius   = barRadius + barThickness / 2;

            float chargeAnim = chargeFillCurve.Evaluate(charge);

            // charge bar shake:
            float   chargeMag    = animChargeShakeMagnitude.Evaluate(chargeAnim) * chargeShakeMagnitude;
            Vector2 origin       = fpsController.GetShake(chargeShakeSpeed, chargeMag);         // do shake here
            float   chargeAngRad = Mathf.Lerp(angRadMaxLeft, angRadMinLeft, chargeAnim);
            Color   chargeColor  = chargeFillGradient.Evaluate(chargeAnim);

            Draw.Arc(origin, fpsController.ammoBarRadius, barThickness, angRadMaxLeft, chargeAngRad, chargeColor);

            Vector2 movingLeftPos = origin + ShapesMath.AngToDir(chargeAngRad) * barRadius;
            Vector2 bottomLeftPos = origin + ShapesMath.AngToDir(angRadMaxLeft) * barRadius;

            // bottom fill
            Draw.Disc(bottomLeftPos, barThickness / 2f, chargeColor);

            // ticks
            const int tickCount = 7;

            Draw.LineEndCaps = LineEndCap.None;
            for (int i = 0; i < tickCount; i++)
            {
                float   t      = i / (tickCount - 1f);
                float   angRad = Mathf.Lerp(angRadMaxLeft, angRadMinLeft, t);
                Vector2 dir    = ShapesMath.AngToDir(angRad);
                Vector2 a      = origin + dir * outerRadius;
                bool    lorge  = i % 3 == 0;
                Vector2 b      = a + dir * (lorge ? tickSizeLorge : tickSizeSmol);
                Draw.Line(a, b, tickTickness, tickColor);

                // scale based on distance to real value
                float chargeDelta = t - chargeAnim;
                float growRange   = chargeDelta < 0 ? fontGrowRangePrev : fontGrowRangeNext;
                float tFontScale  = 1f - ShapesMath.SmoothCos01(Mathf.Clamp01(Mathf.Abs(chargeDelta) / growRange));
                float fontScale   = ShapesMath.Eerp(fontSize, fontSizeLorge, tFontScale);
                Draw.FontSize = fontScale;
                Vector2 labelPos = a + dir * percentLabelOffset;
                string  pct      = Mathf.RoundToInt(t * 100) + "%";
                Draw.Text(labelPos, angRad + ShapesMath.TAU / 2, pct, TextAlign.Right);
            }

            // moving dot
            Draw.Disc(movingLeftPos, barThickness / 2f + ammoBarOutlineThickness / 2f);
            Draw.Disc(movingLeftPos, barThickness / 2f - ammoBarOutlineThickness / 2f, chargeColor);

            FpsController.DrawRoundedArcOutline(origin, barRadius, barThickness, ammoBarOutlineThickness, angRadMinLeft, angRadMaxLeft);

            Draw.LineEndCaps = LineEndCap.Round;

            // glow
            Draw.BlendMode = ShapesBlendMode.Additive;
            Draw.DiscGradientRadial(movingLeftPos, barThickness * 2, chargeColor, Color.clear);
            Draw.BlendMode = ShapesBlendMode.Transparent;
        }