Пример #1
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);
        }
Пример #2
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);
        }