Exemplo n.º 1
0
        public virtual void DrawButtonAt(float topY)
        {
            float num   = (float)UI.screenWidth - 38f - 12f;
            Rect  rect  = new Rect(num, topY, 38f, 30f);
            Rect  rect2 = new Rect(rect);
            float num2  = Time.time - arrivalTime;
            Color color = def.color;

            if (num2 < 1f)
            {
                rect2.y -= (1f - num2) * 200f;
                color.a  = num2 / 1f;
            }
            if (!Mouse.IsOver(rect) && def.bounce && num2 > 15f && num2 % 5f < 1f)
            {
                float num3 = (float)UI.screenWidth * 0.06f;
                float num4 = 2f * (num2 % 1f) - 1f;
                float num5 = num3 * (1f - num4 * num4);
                rect2.x -= num5;
            }
            if (Event.current.type == EventType.Repaint)
            {
                if (def.flashInterval > 0f)
                {
                    float num6 = Time.time - (arrivalTime + 1f);
                    if (num6 > 0f && num6 % def.flashInterval < 1f)
                    {
                        GenUI.DrawFlash(num, topY, (float)UI.screenWidth * 0.6f, Pulser.PulseBrightness(1f, 1f, num6) * 0.55f, def.flashColor);
                    }
                }
                GUI.color = color;
                Widgets.DrawShadowAround(rect2);
                GUI.DrawTexture(rect2, def.Icon);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperRight;
                string  text    = PostProcessedLabel();
                Vector2 vector  = Text.CalcSize(text);
                float   x       = vector.x;
                float   y       = vector.y;
                Vector2 vector2 = new Vector2(rect2.x + rect2.width / 2f, rect2.center.y - y / 2f + 4f);
                float   num7    = vector2.x + x / 2f - (float)(UI.screenWidth - 2);
                if (num7 > 0f)
                {
                    vector2.x -= num7;
                }
                GUI.DrawTexture(new Rect(vector2.x - x / 2f - 6f - 1f, vector2.y, x + 12f, 16f), TexUI.GrayTextBG);
                GUI.color = new Color(1f, 1f, 1f, 0.75f);
                Widgets.Label(new Rect(vector2.x - x / 2f, vector2.y - 3f, x, 999f), text);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperLeft;
            }
            if (CanDismissWithRightClick && Event.current.type == EventType.MouseDown && Event.current.button == 1 && Mouse.IsOver(rect))
            {
                SoundDefOf.Click.PlayOneShotOnCamera();
                Find.LetterStack.RemoveLetter(this);
                Event.current.Use();
            }
            if (Widgets.ButtonInvisible(rect2))
            {
                OpenLetter();
                Event.current.Use();
            }
        }
Exemplo n.º 2
0
        public virtual void DrawButtonAt(float topY)
        {
            float num   = (float)((float)UI.screenWidth - 38.0 - 12.0);
            Rect  rect  = new Rect(num, topY, 38f, 30f);
            Rect  rect2 = new Rect(rect);
            float num2  = Time.time - this.arrivalTime;
            Color color = this.def.color;

            if (num2 < 1.0)
            {
                rect2.y -= (float)((1.0 - num2) * 200.0);
                color.a  = (float)(num2 / 1.0);
            }
            if (!Mouse.IsOver(rect) && this.def.bounce && num2 > 15.0 && num2 % 5.0 < 1.0)
            {
                float num3 = (float)((float)UI.screenWidth * 0.059999998658895493);
                float num4 = (float)(2.0 * (num2 % 1.0) - 1.0);
                float num5 = (float)(num3 * (1.0 - num4 * num4));
                rect2.x -= num5;
            }
            if (this.def.flashInterval > 0.0)
            {
                float num6 = (float)(Time.time - (this.arrivalTime + 1.0));
                if (num6 > 0.0 && num6 % this.def.flashInterval < 1.0)
                {
                    GenUI.DrawFlash(num, topY, (float)((float)UI.screenWidth * 0.60000002384185791), (float)(Pulser.PulseBrightness(1f, 1f, num6) * 0.550000011920929), this.def.flashColor);
                }
            }
            GUI.color = color;
            Widgets.DrawShadowAround(rect2);
            GUI.DrawTexture(rect2, this.def.Icon);
            GUI.color   = Color.white;
            Text.Font   = GameFont.Tiny;
            Text.Anchor = TextAnchor.UpperRight;
            string  text    = this.PostProcessedLabel();
            Vector2 vector  = Text.CalcSize(text);
            float   x       = vector.x;
            float   y       = vector.y;
            double  x2      = rect2.x + rect2.width / 2.0;
            Vector2 center  = rect2.center;
            Vector2 vector2 = new Vector2((float)x2, (float)(center.y - y / 4.0));
            float   num7    = (float)(vector2.x + x / 2.0 - (float)(UI.screenWidth - 2));

            if (num7 > 0.0)
            {
                vector2.x -= num7;
            }
            Rect position = new Rect((float)(vector2.x - x / 2.0 - 4.0 - 1.0), vector2.y, (float)(x + 8.0), 12f);

            GUI.DrawTexture(position, TexUI.GrayTextBG);
            GUI.color = new Color(1f, 1f, 1f, 0.75f);
            Rect rect3 = new Rect((float)(vector2.x - x / 2.0), (float)(vector2.y - 3.0), x, 999f);

            Widgets.Label(rect3, text);
            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
            Text.Font   = GameFont.Small;
            if (Event.current.type == EventType.MouseDown && Event.current.button == 1 && Mouse.IsOver(rect))
            {
                SoundDefOf.Click.PlayOneShotOnCamera(null);
                Find.LetterStack.RemoveLetter(this);
                Event.current.Use();
            }
            if (Widgets.ButtonInvisible(rect2, false))
            {
                this.OpenLetter();
                Event.current.Use();
            }
        }