Exemplo n.º 1
0
        public HashSet <SwrveAssetsQueueItem> SetOfAssets()
        {
            HashSet <SwrveAssetsQueueItem> hashSet = new HashSet <SwrveAssetsQueueItem>();

            for (int i = 0; i < this.Formats.Count; i++)
            {
                SwrveMessageFormat swrveMessageFormat = this.Formats[i];
                for (int j = 0; j < swrveMessageFormat.Images.Count; j++)
                {
                    SwrveImage swrveImage = swrveMessageFormat.Images[j];
                    if (!string.IsNullOrEmpty(swrveImage.File))
                    {
                        hashSet.Add(new SwrveAssetsQueueItem(swrveImage.File, swrveImage.File, true));
                    }
                }
                for (int k = 0; k < swrveMessageFormat.Buttons.Count; k++)
                {
                    SwrveButton swrveButton = swrveMessageFormat.Buttons[k];
                    if (!string.IsNullOrEmpty(swrveButton.Image))
                    {
                        hashSet.Add(new SwrveAssetsQueueItem(swrveButton.Image, swrveButton.Image, true));
                    }
                }
            }
            return(hashSet);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Get all the assets in the in-app message.
        /// </summary>
        /// <returns>
        /// All the assets in the in-app message.
        /// </returns>
        public List <string> ListOfAssets()
        {
            List <string> messageAssets = new List <string> ();

            for (int fi = 0; fi < Formats.Count; fi++)
            {
                SwrveMessageFormat format = Formats[fi];
                for (int ii = 0; ii < format.Images.Count; ii++)
                {
                    SwrveImage image = format.Images[ii];
                    if (!string.IsNullOrEmpty(image.File))
                    {
                        messageAssets.Add(image.File);
                    }
                }

                for (int bi = 0; bi < format.Buttons.Count; bi++)
                {
                    SwrveButton button = format.Buttons[bi];
                    if (!string.IsNullOrEmpty(button.Image))
                    {
                        messageAssets.Add(button.Image);
                    }
                }
            }
            return(messageAssets);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get all the assets in the in-app message.
        /// </summary>
        /// <returns>
        /// All the assets in the in-app message.
        /// </returns>
        public HashSet <SwrveAssetsQueueItem> SetOfAssets()
        {
            HashSet <SwrveAssetsQueueItem> messageAssets = new HashSet <SwrveAssetsQueueItem> ();

            for (int fi = 0; fi < Formats.Count; fi++)
            {
                SwrveMessageFormat format = Formats[fi];
                for (int ii = 0; ii < format.Images.Count; ii++)
                {
                    SwrveImage image = format.Images[ii];
                    if (!string.IsNullOrEmpty(image.File))
                    {
                        messageAssets.Add(new SwrveAssetsQueueItem(image.File, image.File, true));
                    }
                }

                for (int bi = 0; bi < format.Buttons.Count; bi++)
                {
                    SwrveButton button = format.Buttons[bi];
                    if (!string.IsNullOrEmpty(button.Image))
                    {
                        messageAssets.Add(new SwrveAssetsQueueItem(button.Image, button.Image, true));
                    }
                }
            }
            return(messageAssets);
        }
 public static void AnimateMessage(SwrveMessageFormat format)
 {
     if (Animator != null)
     {
         Animator.AnimateMessage(format);
     }
 }
Exemplo n.º 5
0
        public static SwrveMessageFormat LoadFromJSON(ISwrveAssetsManager swrveAssetsManager, SwrveMessage message, Dictionary <string, object> messageFormatData, Color?defaultBackgroundColor)
        {
            SwrveMessageFormat swrveMessageFormat = new SwrveMessageFormat(message);

            swrveMessageFormat.Name     = (string)messageFormatData["name"];
            swrveMessageFormat.Language = (string)messageFormatData["language"];
            if (messageFormatData.ContainsKey("scale"))
            {
                swrveMessageFormat.Scale = MiniJsonHelper.GetFloat(messageFormatData, "scale", 1f);
            }
            if (messageFormatData.ContainsKey("orientation"))
            {
                swrveMessageFormat.Orientation = SwrveOrientationHelper.Parse((string)messageFormatData["orientation"]);
            }
            swrveMessageFormat.BackgroundColor = defaultBackgroundColor;
            if (messageFormatData.ContainsKey("color"))
            {
                string text            = (string)messageFormatData["color"];
                Color? backgroundColor = swrveMessageFormat.BackgroundColor;
                if (text.Length == 8)
                {
                    byte a = byte.Parse(text.Substring(0, 2), NumberStyles.HexNumber);
                    byte r = byte.Parse(text.Substring(2, 2), NumberStyles.HexNumber);
                    byte g = byte.Parse(text.Substring(4, 2), NumberStyles.HexNumber);
                    byte b = byte.Parse(text.Substring(6, 2), NumberStyles.HexNumber);
                    backgroundColor = new Color32(r, g, b, a);
                }
                else if (text.Length == 6)
                {
                    byte r = byte.Parse(text.Substring(0, 2), NumberStyles.HexNumber);
                    byte g = byte.Parse(text.Substring(2, 2), NumberStyles.HexNumber);
                    byte b = byte.Parse(text.Substring(4, 2), NumberStyles.HexNumber);
                    backgroundColor = new Color32(r, g, b, byte.MaxValue);
                }
                swrveMessageFormat.BackgroundColor = backgroundColor;
            }
            Dictionary <string, object> dictionary = (Dictionary <string, object>)messageFormatData["size"];

            swrveMessageFormat.Size.X = MiniJsonHelper.GetInt((Dictionary <string, object>)dictionary["w"], "value");
            swrveMessageFormat.Size.Y = MiniJsonHelper.GetInt((Dictionary <string, object>)dictionary["h"], "value");
            IList <object> list = (List <object>)messageFormatData["buttons"];
            int            i    = 0;

            for (int count = list.Count; i < count; i++)
            {
                SwrveButton item = LoadButtonFromJSON(message, (Dictionary <string, object>)list[i]);
                swrveMessageFormat.Buttons.Add(item);
            }
            IList <object> list2 = (List <object>)messageFormatData["images"];
            int            j     = 0;

            for (int count2 = list2.Count; j < count2; j++)
            {
                SwrveImage item2 = LoadImageFromJSON(message, (Dictionary <string, object>)list2[j]);
                swrveMessageFormat.Images.Add(item2);
            }
            return(swrveMessageFormat);
        }
 public static void InitMessage(SwrveMessageFormat format, SwrveOrientation deviceOrientation)
 {
     if (Animator != null)
     {
         Animator.InitMessage(format);
         return;
     }
     format.Init(deviceOrientation);
     format.InitAnimation(new Point(0, 0), new Point(0, 0));
 }
        public void InitMessage(SwrveMessageFormat format, SwrveInAppMessageConfig inAppConfig, SwrveOrientation deviceOrientation, bool afterRotation = false)
        {
            this.format = format;
            format.Init(deviceOrientation);
            renderBackgroundColor = format.BackgroundColor.HasValue;

            if (!afterRotation)
            {
                if (animator != null)
                {
                    animator.InitMessage(format);
                }
                else
                {
                    format.InitAnimation(new Point(0, 0), new Point(0, 0));
                }
            }

            // Create widgets to render and use the cached personalization values
            widgetViews = new SwrveWidgetView[format.Images.Count + format.Buttons.Count];
            int eindex = 0;

            for (int ii = 0; ii < format.Images.Count; ii++)
            {
                SwrveImage      image = format.Images[ii];
                SwrveWidgetView renderer;
                if (image.Text != null)
                {
                    // Get cached resolved template
                    string resolvedTextTemplate = templatingResolver.TextResolution[image];
                    renderer = new SwrveMessagePersonalizedWidgetView(image, resolvedTextTemplate, inAppConfig);
                }
                else
                {
                    renderer = new SwrveImageView(image);
                }
                widgetViews[eindex++] = renderer;
            }
            for (int bi = 0; bi < format.Buttons.Count; bi++)
            {
                SwrveButton     button = format.Buttons[bi];
                SwrveWidgetView renderer;
                if (button.Text != null)
                {
                    string resolvedTextTemplate = templatingResolver.TextResolution[button];
                    renderer = new SwrveMessagePersonalizedWidgetView(button, resolvedTextTemplate, inAppConfig);
                }
                else
                {
                    renderer = new SwrveButtonView(button, inAppConfig.ButtonClickTintColor);
                }
                widgetViews[eindex++] = renderer;
            }
        }
Exemplo n.º 8
0
        protected static SwrveImage LoadImageFromJSON(SwrveMessage message, Dictionary <string, object> imageData)
        {
            SwrveImage swrveImage = new SwrveImage();

            swrveImage.Position.X = SwrveMessageFormat.IntValueFromAttribute(imageData, "x");
            swrveImage.Position.Y = SwrveMessageFormat.IntValueFromAttribute(imageData, "y");
            swrveImage.Size.X     = SwrveMessageFormat.IntValueFromAttribute(imageData, "w");
            swrveImage.Size.Y     = SwrveMessageFormat.IntValueFromAttribute(imageData, "h");
            swrveImage.File       = SwrveMessageFormat.StringValueFromAttribute(imageData, "image");
            return(swrveImage);
        }
Exemplo n.º 9
0
 public static void InitMessage(SwrveMessageFormat format, SwrveOrientation deviceOrientation)
 {
     if (SwrveMessageRenderer.Animator != null)
     {
         SwrveMessageRenderer.Animator.InitMessage(format);
     }
     else
     {
         format.Init(deviceOrientation);
         format.InitAnimation(new Point(0, 0), new Point(0, 0));
     }
 }
Exemplo n.º 10
0
 public void MessageWasShownToUser(SwrveMessageFormat messageFormat)
 {
     WasShownToUser();
     if (Messages.Count > 0)
     {
         if (!RandomOrder)
         {
             int num2 = (base.Next = (base.Next + 1) % Messages.Count);
             SwrveLog.Log("Round Robin: Next message in campaign " + Id + " is " + num2);
         }
         else
         {
             SwrveLog.Log("Next message in campaign " + Id + " is random");
         }
     }
 }
        public bool ResolveTemplating(SwrveMessage message, Dictionary <string, string> properties)
        {
            try {
                for (int fi = 0; fi < message.Formats.Count; fi++)
                {
                    SwrveMessageFormat format = message.Formats[fi];
                    for (int ii = 0; ii < format.Images.Count; ii++)
                    {
                        SwrveImage image = format.Images[ii];

                        if (!ResolveWidgetProperty(image, TextResolution, image.Text, properties))
                        {
                            return(false);
                        }
                    }

                    for (int bi = 0; bi < format.Buttons.Count; bi++)
                    {
                        SwrveButton button = format.Buttons[bi];

                        if (!ResolveWidgetProperty(button, TextResolution, button.Text, properties))
                        {
                            return(false);
                        }

                        // Need to personalize action
                        string personalizedButtonAction = button.Action;
                        if ((button.ActionType == SwrveActionType.Custom || button.ActionType == SwrveActionType.CopyToClipboard) && !string.IsNullOrEmpty(personalizedButtonAction))
                        {
                            if (!ResolveWidgetProperty(button, ActionResolution, personalizedButtonAction, properties))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            ActionResolution[button] = personalizedButtonAction;
                        }
                    }
                }
            } catch (SwrveSDKTextTemplatingException exp) {
                UnityEngine.Debug.LogError("Not showing campaign, error with personalization" + exp.Message);
                return(false);
            }
            return(true);
        }
        /// <summary>
        /// Notify that the message was shown to the user. This function
        /// has to be called only once when the message is displayed to
        /// the user.
        /// This is automatically called by the SDK and will only need
        /// to be manually called if you are implementing your own
        /// in-app message rendering code.
        /// </summary>
        public void MessageWasShownToUser(SwrveMessageFormat messageFormat)
        {
            base.WasShownToUser();

            if (Messages.Count > 0)
            {
                if (!RandomOrder)
                {
                    int nextMessage = (Next + 1) % Messages.Count;
                    Next = nextMessage;
                    SwrveLog.Log("Round Robin: Next message in campaign " + Id + " is " + nextMessage);
                }
                else
                {
                    SwrveLog.Log("Next message in campaign " + Id + " is random");
                }
            }
        }
Exemplo n.º 13
0
        public static SwrveMessage LoadFromJSON(ISwrveAssetsManager swrveAssetsManager, SwrveMessagesCampaign campaign, Dictionary <string, object> messageData, Color?defaultBackgroundColor)
        {
            SwrveMessage swrveMessage = new SwrveMessage(swrveAssetsManager, campaign);

            swrveMessage.Id   = MiniJsonHelper.GetInt(messageData, "id");
            swrveMessage.Name = (string)messageData["name"];
            if (messageData.ContainsKey("priority"))
            {
                swrveMessage.Priority = MiniJsonHelper.GetInt(messageData, "priority");
            }
            Dictionary <string, object> dictionary = (Dictionary <string, object>)messageData["template"];
            IList <object> list = (List <object>)dictionary["formats"];
            int            i    = 0;

            for (int count = list.Count; i < count; i++)
            {
                Dictionary <string, object> messageFormatData = (Dictionary <string, object>)list[i];
                SwrveMessageFormat          item = SwrveMessageFormat.LoadFromJSON(swrveAssetsManager, swrveMessage, messageFormatData, defaultBackgroundColor);
                swrveMessage.Formats.Add(item);
            }
            return(swrveMessage);
        }
Exemplo n.º 14
0
 public void MessageWasShownToUser(SwrveMessageFormat messageFormat)
 {
     base.WasShownToUser();
     if (this.Messages.Count > 0)
     {
         if (!this.RandomOrder)
         {
             int num = (base.Next + 1) % this.Messages.Count;
             base.Next = num;
             SwrveLog.Log(string.Concat(new object[]
             {
                 "Round Robin: Next message in campaign ",
                 this.Id,
                 " is ",
                 num
             }));
         }
         else
         {
             SwrveLog.Log("Next message in campaign " + this.Id + " is random");
         }
     }
 }
Exemplo n.º 15
0
        protected static SwrveButton LoadButtonFromJSON(SwrveMessage message, Dictionary <string, object> buttonData)
        {
            SwrveButton swrveButton = new SwrveButton();

            swrveButton.Position.X = SwrveMessageFormat.IntValueFromAttribute(buttonData, "x");
            swrveButton.Position.Y = SwrveMessageFormat.IntValueFromAttribute(buttonData, "y");
            swrveButton.Size.X     = SwrveMessageFormat.IntValueFromAttribute(buttonData, "w");
            swrveButton.Size.Y     = SwrveMessageFormat.IntValueFromAttribute(buttonData, "h");
            swrveButton.Image      = SwrveMessageFormat.StringValueFromAttribute(buttonData, "image_up");
            swrveButton.Message    = message;
            if (buttonData.ContainsKey("name"))
            {
                swrveButton.Name = (string)buttonData["name"];
            }
            string          text       = SwrveMessageFormat.StringValueFromAttribute(buttonData, "type");
            SwrveActionType actionType = SwrveActionType.Dismiss;

            if (text.ToLower().Equals("install"))
            {
                actionType = SwrveActionType.Install;
            }
            else if (text.ToLower().Equals("custom"))
            {
                actionType = SwrveActionType.Custom;
            }
            swrveButton.ActionType = actionType;
            swrveButton.Action     = SwrveMessageFormat.StringValueFromAttribute(buttonData, "action");
            if (swrveButton.ActionType == SwrveActionType.Install)
            {
                string text2 = SwrveMessageFormat.StringValueFromAttribute(buttonData, "game_id");
                if (text2 != null && text2 != string.Empty)
                {
                    swrveButton.AppId = int.Parse(text2);
                }
            }
            return(swrveButton);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Load an in-app message from a JSON response.
        /// </summary>
        /// <param name="campaign">
        /// Parent in-app campaign.
        /// </param>
        /// <param name="messageData">
        /// JSON object with the individual message data.
        /// </param>
        /// <returns>
        /// Parsed in-app message.
        /// </returns>
        public static SwrveMessage LoadFromJSON(ISwrveAssetsManager swrveAssetsManager, SwrveInAppCampaign campaign, Dictionary <string, object> messageData, Color?defaultBackgroundColor)
        {
            SwrveMessage message = new SwrveMessage(swrveAssetsManager, campaign);

            message.Id   = MiniJsonHelper.GetInt(messageData, "id");
            message.Name = (string)messageData ["name"];

            if (messageData.ContainsKey("priority"))
            {
                message.Priority = MiniJsonHelper.GetInt(messageData, "priority");
            }

            Dictionary <string, object> template = (Dictionary <string, object>)messageData ["template"];
            IList <object> jsonFormats           = (List <object>)template ["formats"];

            for (int i = 0, j = jsonFormats.Count; i < j; i++)
            {
                Dictionary <string, object> messageFormatData = (Dictionary <string, object>)jsonFormats [i];
                SwrveMessageFormat          messageFormat     = SwrveMessageFormat.LoadFromJSON(swrveAssetsManager, message, messageFormatData, defaultBackgroundColor);
                message.Formats.Add(messageFormat);
            }

            return(message);
        }
Exemplo n.º 17
0
        public static void DrawMessage(SwrveMessageFormat format, int centerx, int centery)
        {
            if (Animator != null)
            {
                AnimateMessage(format);
            }
            if (format.BackgroundColor.HasValue && GetBlankTexture() != null)
            {
                Color value = format.BackgroundColor.Value;
                value.a           *= format.Message.BackgroundAlpha;
                GUI.color          = value;
                WholeScreen.width  = Screen.width;
                WholeScreen.height = Screen.height;
                GUI.DrawTexture(WholeScreen, blankTexture, ScaleMode.StretchToFill, alphaBlend: true, 10f);
                GUI.color = Color.white;
            }
            bool rotate = format.Rotate;

            if (rotate)
            {
                Vector2 pivotPoint = new Vector2(centerx, centery);
                GUIUtility.RotateAroundPivot(90f, pivotPoint);
            }
            float num = format.Scale * format.Message.AnimationScale;

            GUI.color = Color.white;
            Point centeredPosition;

            for (int i = 0; i < format.Images.Count; i++)
            {
                SwrveImage swrveImage = format.Images[i];
                if (swrveImage.Texture != null)
                {
                    float num2 = num * swrveImage.AnimationScale;
                    centeredPosition       = swrveImage.GetCenteredPosition(swrveImage.Texture.width, swrveImage.Texture.height, num2, num);
                    centeredPosition.X    += centerx;
                    centeredPosition.Y    += centery;
                    swrveImage.Rect.x      = centeredPosition.X;
                    swrveImage.Rect.y      = centeredPosition.Y;
                    swrveImage.Rect.width  = (float)swrveImage.Texture.width * num2;
                    swrveImage.Rect.height = (float)swrveImage.Texture.height * num2;
                    GUI.DrawTexture(swrveImage.Rect, swrveImage.Texture, ScaleMode.StretchToFill, alphaBlend: true, 10f);
                }
                else
                {
                    GUI.Box(swrveImage.Rect, swrveImage.File);
                }
            }
            for (int j = 0; j < format.Buttons.Count; j++)
            {
                SwrveButton swrveButton = format.Buttons[j];
                if (swrveButton.Texture != null)
                {
                    float num2 = num * swrveButton.AnimationScale;
                    centeredPosition        = swrveButton.GetCenteredPosition(swrveButton.Texture.width, swrveButton.Texture.height, num2, num);
                    swrveButton.Rect.x      = centeredPosition.X + centerx;
                    swrveButton.Rect.y      = centeredPosition.Y + centery;
                    swrveButton.Rect.width  = (float)swrveButton.Texture.width * num2;
                    swrveButton.Rect.height = (float)swrveButton.Texture.height * num2;
                    if (rotate)
                    {
                        Point center = swrveButton.GetCenter(swrveButton.Texture.width, swrveButton.Texture.height, num2);
                        swrveButton.PointerRect.x      = (float)centerx - (float)swrveButton.Position.Y * num + (float)center.Y;
                        swrveButton.PointerRect.y      = (float)centery + (float)swrveButton.Position.X * num + (float)center.X;
                        swrveButton.PointerRect.width  = swrveButton.Rect.height;
                        swrveButton.PointerRect.height = swrveButton.Rect.width;
                    }
                    else
                    {
                        swrveButton.PointerRect = swrveButton.Rect;
                    }
                    if (Animator != null)
                    {
                        Animator.AnimateButtonPressed(swrveButton);
                    }
                    else
                    {
                        GUI.color = (swrveButton.Pressed ? ButtonPressedColor : Color.white);
                    }
                    GUI.DrawTexture(swrveButton.Rect, swrveButton.Texture, ScaleMode.StretchToFill, alphaBlend: true, 10f);
                }
                else
                {
                    GUI.Box(swrveButton.Rect, swrveButton.Image);
                }
                GUI.color = Color.white;
            }
            if ((Animator == null && format.Closing) || (Animator != null && Animator.IsMessageDismissed(format)))
            {
                format.Dismissed = true;
                format.UnloadAssets();
            }
        }
        /// <summary>
        /// Load an in-app message format from a JSON response.
        /// </summary>
        /// <param name="message">
        /// Parent in-app message.
        /// </param>
        /// <param name="messageFormatData">
        /// JSON object with the individual message format data.
        /// </param>
        /// <returns>
        /// Parsed in-app message format.
        /// </returns>
        public static SwrveMessageFormat LoadFromJSON(SwrveSDK sdk, SwrveMessage message, Dictionary <string, object> messageFormatData)
        {
            SwrveMessageFormat messageFormat = new SwrveMessageFormat(message);

            messageFormat.Name     = (string)messageFormatData ["name"];
            messageFormat.Language = (string)messageFormatData ["language"];
            if (messageFormatData.ContainsKey("scale"))
            {
                messageFormat.Scale = MiniJsonHelper.GetFloat(messageFormatData, "scale", 1);
            }

            if (messageFormatData.ContainsKey("orientation"))
            {
                messageFormat.Orientation = SwrveOrientationHelper.Parse((string)messageFormatData ["orientation"]);
            }

            messageFormat.BackgroundColor = sdk.DefaultBackgroundColor;
            if (messageFormatData.ContainsKey("color"))
            {
                string strColor = (string)messageFormatData ["color"];
                Color? c        = messageFormat.BackgroundColor;
                if (strColor.Length == 8)
                {
                    // RRGGBB
                    byte a = byte.Parse(strColor.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
                    byte r = byte.Parse(strColor.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
                    byte g = byte.Parse(strColor.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
                    byte b = byte.Parse(strColor.Substring(6, 2), System.Globalization.NumberStyles.HexNumber);
                    c = new Color32(r, g, b, a);
                }
                else if (strColor.Length == 6)
                {
                    // AARRGGBB
                    byte r = byte.Parse(strColor.Substring(0, 2), System.Globalization.NumberStyles.HexNumber);
                    byte g = byte.Parse(strColor.Substring(2, 2), System.Globalization.NumberStyles.HexNumber);
                    byte b = byte.Parse(strColor.Substring(4, 2), System.Globalization.NumberStyles.HexNumber);
                    c = new Color32(r, g, b, 255);
                }
                messageFormat.BackgroundColor = c;
            }

            Dictionary <string, object> sizeJson = (Dictionary <string, object>)messageFormatData ["size"];

            messageFormat.Size.X = MiniJsonHelper.GetInt(((Dictionary <string, object>)sizeJson ["w"]), "value");
            messageFormat.Size.Y = MiniJsonHelper.GetInt(((Dictionary <string, object>)sizeJson ["h"]), "value");

            IList <object> jsonButtons = (List <object>)messageFormatData ["buttons"];

            for (int i = 0, j = jsonButtons.Count; i < j; i++)
            {
                SwrveButton button = LoadButtonFromJSON(message, (Dictionary <string, object>)jsonButtons [i]);
                messageFormat.Buttons.Add(button);
            }

            IList <object> jsonImages = (List <object>)messageFormatData ["images"];

            for (int ii = 0, ji = jsonImages.Count; ii < ji; ii++)
            {
                SwrveImage image = LoadImageFromJSON(message, (Dictionary <string, object>)jsonImages [ii]);
                messageFormat.Images.Add(image);
            }


            return(messageFormat);
        }
        public static void DrawMessage(SwrveMessageFormat format, int centerx, int centery)
        {
            if (Animator != null)
            {
                AnimateMessage(format);
            }

            if (format.BackgroundColor.HasValue && GetBlankTexture() != null)
            {
                Color backgroundColor = format.BackgroundColor.Value;
                backgroundColor.a  = backgroundColor.a * format.Message.BackgroundAlpha;
                GUI.color          = backgroundColor;
                WholeScreen.width  = Screen.width;
                WholeScreen.height = Screen.height;
                GUI.DrawTexture(WholeScreen, blankTexture, ScaleMode.StretchToFill, true, 10.0f);
                GUI.color = Color.white;
            }

            bool rotatedFormat = format.Rotate;

            // Rotate the inner message if necessary
            if (rotatedFormat)
            {
                Vector2 pivotPoint = new Vector2(centerx, centery);
                GUIUtility.RotateAroundPivot(90, pivotPoint);
            }

            float scale = format.Scale * format.Message.AnimationScale;

            GUI.color = Color.white;
            // Draw images
            for (int ii = 0; ii < format.Images.Count; ii++)
            {
                SwrveImage image = format.Images[ii];
                if (image.Texture != null)
                {
                    float computedSize = scale * image.AnimationScale;
                    Point centerPoint  = image.GetCenteredPosition(image.Texture.width, image.Texture.height, computedSize, scale);
                    centerPoint.X    += centerx;
                    centerPoint.Y    += centery;
                    image.Rect.x      = centerPoint.X;
                    image.Rect.y      = centerPoint.Y;
                    image.Rect.width  = image.Texture.width * computedSize;
                    image.Rect.height = image.Texture.height * computedSize;

                    GUI.DrawTexture(image.Rect, image.Texture, ScaleMode.StretchToFill, true, 10.0f);
                }
                else
                {
                    GUI.Box(image.Rect, image.File);
                }
            }

            // Draw buttons
            for (int bi = 0; bi < format.Buttons.Count; bi++)
            {
                SwrveButton button = format.Buttons[bi];
                if (button.Texture != null)
                {
                    float computedSize = scale * button.AnimationScale;
                    Point centerPoint  = button.GetCenteredPosition(button.Texture.width, button.Texture.height, computedSize, scale);
                    button.Rect.x      = centerPoint.X + centerx;
                    button.Rect.y      = centerPoint.Y + centery;
                    button.Rect.width  = button.Texture.width * computedSize;
                    button.Rect.height = button.Texture.height * computedSize;

                    if (rotatedFormat)
                    {
                        // Rotate 90 degrees the hit area
                        Point widgetCenter = button.GetCenter(button.Texture.width, button.Texture.height, computedSize);
                        button.PointerRect.x      = centerx - (button.Position.Y * scale) + widgetCenter.Y;
                        button.PointerRect.y      = centery + (button.Position.X * scale) + widgetCenter.X;
                        button.PointerRect.width  = button.Rect.height;
                        button.PointerRect.height = button.Rect.width;
                    }
                    else
                    {
                        button.PointerRect = button.Rect;
                    }
                    if (Animator != null)
                    {
                        Animator.AnimateButtonPressed(button);
                    }
                    else
                    {
                        GUI.color = (button.Pressed) ? ButtonPressedColor : Color.white;
                    }
                    GUI.DrawTexture(button.Rect, button.Texture, ScaleMode.StretchToFill, true, 10.0f);
                }
                else
                {
                    GUI.Box(button.Rect, button.Image);
                }
                GUI.color = Color.white;
            }

            // Do closing logic
            if ((Animator == null && format.Closing) || (Animator != null && Animator.IsMessageDismissed(format)))
            {
                format.Dismissed = true;
                format.UnloadAssets();
            }
        }