public Boomlagoon.JSON.JSONValue ExportDataAsPresetSection(bool saveSampleTextData = true)
        {
            Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();

            if (m_loop_cycles.Count > 0)
            {
                Boomlagoon.JSON.JSONArray loops_data = new Boomlagoon.JSON.JSONArray();

                foreach (ActionLoopCycle action_loop in m_loop_cycles)
                {
                    loops_data.Add(action_loop.ExportData());
                }

                json_data["LOOPS_DATA"] = loops_data;
            }

            Boomlagoon.JSON.JSONArray actions_data = new Boomlagoon.JSON.JSONArray();
            foreach (LetterAction action in m_letter_actions)
            {
                actions_data.Add(action.ExportData());
            }
            json_data["ACTIONS_DATA"] = actions_data;

            if (saveSampleTextData)
            {
                json_data["SAMPLE_NUM_LETTERS_ANIMATED"] = m_letters_to_animate.Count;
            }

            return(new Boomlagoon.JSON.JSONValue(json_data));
        }
        public Boomlagoon.JSON.JSONValue ExportData()
        {
            Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();

            json_data["m_letters_to_animate"]            = m_letters_to_animate.ExportData();
            json_data["m_letters_to_animate_custom_idx"] = m_letters_to_animate_custom_idx;
            json_data["m_letters_to_animate_option"]     = (int)m_letters_to_animate_option;

            if (m_loop_cycles.Count > 0)
            {
                Boomlagoon.JSON.JSONArray loops_data = new Boomlagoon.JSON.JSONArray();

                foreach (ActionLoopCycle action_loop in m_loop_cycles)
                {
                    loops_data.Add(action_loop.ExportData());
                }

                json_data["LOOPS_DATA"] = loops_data;
            }

            Boomlagoon.JSON.JSONArray actions_data = new Boomlagoon.JSON.JSONArray();
            foreach (LetterAction action in m_letter_actions)
            {
                actions_data.Add(action.ExportData());
            }
            json_data["ACTIONS_DATA"] = actions_data;

            return(new Boomlagoon.JSON.JSONValue(json_data));
        }
Exemplo n.º 3
0
        public static Boomlagoon.JSON.JSONValue ExportData(this AnimationCurve curve)
        {
            Boomlagoon.JSON.JSONArray key_frame_data = new Boomlagoon.JSON.JSONArray();

            foreach (UnityEngine.Keyframe key_frame in curve.keys)
            {
                key_frame_data.Add(key_frame.ExportData());
            }

            return(key_frame_data);
        }
Exemplo n.º 4
0
        public static List <int> JSONtoListInt(this Boomlagoon.JSON.JSONArray json_array)
        {
            List <int> int_list = new List <int>();

            foreach (Boomlagoon.JSON.JSONValue int_val in json_array)
            {
                int_list.Add((int)int_val.Number);
            }

            return(int_list);
        }
Exemplo n.º 5
0
        public static AnimationCurve JSONtoAnimationCurve(this Boomlagoon.JSON.JSONArray json_data)
        {
            AnimationCurve anim_curve = new AnimationCurve();

            anim_curve.keys = new Keyframe[0];

            foreach (Boomlagoon.JSON.JSONValue frame_data in json_data)
            {
                anim_curve.AddKey(frame_data.Obj.JSONtoKeyframe());
            }

            return(anim_curve);
        }
Exemplo n.º 6
0
        public static Boomlagoon.JSON.JSONArray ExportData(this List <int> list)
        {
            Boomlagoon.JSON.JSONArray json_array = new Boomlagoon.JSON.JSONArray();

            if (list != null)
            {
                foreach (int num in list)
                {
                    json_array.Add(num);
                }
            }

            return(json_array);
        }
Exemplo n.º 7
0
        public Boomlagoon.JSON.JSONValue ExportData()
        {
            Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();

            Boomlagoon.JSON.JSONArray  anchors_data = new Boomlagoon.JSON.JSONArray();
            Boomlagoon.JSON.JSONObject anchor_point_data;

            foreach (BezierCurvePoint anchor_point in m_anchor_points)
            {
                anchor_point_data = new Boomlagoon.JSON.JSONObject();
                anchor_point_data["m_anchor_point"] = anchor_point.m_anchor_point.ExportData();
                anchor_point_data["m_handle_point"] = anchor_point.m_handle_point.ExportData();

                anchors_data.Add(anchor_point_data);
            }

            json_data["ANCHORS_DATA"] = anchors_data;

            return(new Boomlagoon.JSON.JSONValue(json_data));
        }
Exemplo n.º 8
0
		public Boomlagoon.JSON.JSONValue ExportData()
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			json_data["m_action_type"] = (int) m_action_type;
			json_data["m_ease_type"] = (int) m_ease_type;
			json_data["m_force_same_start_time"] = m_force_same_start_time;
			json_data["m_letter_anchor_start"] = m_letter_anchor_start;
			json_data["m_letter_anchor_end"] = m_letter_anchor_end;
			json_data["m_letter_anchor_2_way"] = m_letter_anchor_2_way;
			json_data["m_offset_from_last"] = m_offset_from_last;
			json_data["m_position_axis_ease_data"] = m_position_axis_ease_data.ExportData();
			json_data["m_rotation_axis_ease_data"] = m_rotation_axis_ease_data.ExportData();
			json_data["m_scale_axis_ease_data"] = m_scale_axis_ease_data.ExportData();
			
			json_data ["m_colour_transition_active"] = m_colour_transition_active;
			json_data["m_start_colour"] = m_start_colour.ExportData();
			json_data ["m_position_transition_active"] = m_position_transition_active;
			json_data["m_start_pos"] = m_start_pos.ExportData();
			json_data ["m_local_rotation_transition_active"] = m_local_rotation_transition_active;
			json_data["m_start_euler_rotation"] = m_start_euler_rotation.ExportData();
			json_data ["m_local_scale_transition_active"] = m_local_scale_transition_active;
			json_data["m_start_scale"] = m_start_scale.ExportData();
			json_data ["m_global_rotation_transition_active"] = m_global_rotation_transition_active;
			json_data["m_global_start_euler_rotation"] = m_global_start_euler_rotation.ExportData();
			json_data ["m_global_scale_transition_active"] = m_global_scale_transition_active;
			json_data["m_global_start_scale"] = m_global_start_scale.ExportData();
			
			json_data["m_end_colour"] = m_end_colour.ExportData();
			json_data["m_end_pos"] = m_end_pos.ExportData();
			json_data["m_end_euler_rotation"] = m_end_euler_rotation.ExportData();
			json_data["m_end_scale"] = m_end_scale.ExportData();
			json_data["m_global_end_euler_rotation"] = m_global_end_euler_rotation.ExportData();
			json_data["m_global_end_scale"] = m_global_end_scale.ExportData();
			
			json_data["m_delay_progression"] = m_delay_progression.ExportData();
			json_data["m_duration_progression"] = m_duration_progression.ExportData();
			
			
			Boomlagoon.JSON.JSONArray audio_effects_data = new Boomlagoon.JSON.JSONArray();
			foreach(AudioEffectSetup effect_setup in m_audio_effects)
			{
				if(effect_setup.m_audio_clip == null)
					continue;
				
				audio_effects_data.Add(effect_setup.ExportData());
			}
			json_data["AUDIO_EFFECTS_DATA"] = audio_effects_data;
			
			Boomlagoon.JSON.JSONArray particle_effects_data = new Boomlagoon.JSON.JSONArray();
			foreach(ParticleEffectSetup effect_setup in m_particle_effects)
			{
				if(effect_setup.m_legacy_particle_effect == null && effect_setup.m_shuriken_particle_effect == null)
					continue;
				
				particle_effects_data.Add(effect_setup.ExportData());
			}
			json_data["PARTICLE_EFFECTS_DATA"] = particle_effects_data;
			
			return new Boomlagoon.JSON.JSONValue(json_data);
		}
		public string ExportData(bool hard_copy = false)
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();

			json_data["TEXTFX_EXPORTER_VERSION"] = JSON_EXPORTER_VERSION;
			json_data["m_animate_per"] = (int) m_animate_per;
			
			if (hard_copy)
			{
				json_data["m_begin_delay"] = m_begin_delay;
				json_data["m_begin_on_start"] = m_begin_on_start;
				json_data["m_on_finish_action"] = (int) m_on_finish_action;
				json_data["m_time_type"] = (int) m_time_type;
			}
			
			Boomlagoon.JSON.JSONArray letter_animations_data = new Boomlagoon.JSON.JSONArray();
			if(m_master_animations != null)
			{
				foreach(LetterAnimation anim in m_master_animations)
				{
					letter_animations_data.Add(anim.ExportData());
				}
			}
			json_data["LETTER_ANIMATIONS_DATA"] = letter_animations_data;


			// Handle exporting quick setup configuration fields
			Boomlagoon.JSON.JSONArray effect_settings_options = new Boomlagoon.JSON.JSONArray();
			if(m_preset_effect_settings != null)
			{
				foreach(PresetEffectSetting effect_setting in m_preset_effect_settings)
				{
					effect_settings_options.Add(effect_setting.ExportData());
				}
			}
			json_data["PRESET_EFFECT_SETTINGS"] = effect_settings_options;

			
			return json_data.ToString();
		}
	//	public void ExportData(Boomlagoon.JSON.JSONObject json_data, bool hard_copy = false)
	//	{
	//		json_data["TEXTFX_EXPORTER_VERSION"] = JSON_EXPORTER_VERSION;
	//		json_data["m_animate_per"] = (int) m_animate_per;
	//
	//		if (hard_copy)
	//		{
	//			json_data["m_begin_delay"] = m_begin_delay;
	//			json_data["m_begin_on_start"] = m_begin_on_start;
	//			json_data["m_on_finish_action"] = (int) m_on_finish_action;
	//			json_data["m_time_type"] = (int) m_time_type;
	//		}
	//
	//		Boomlagoon.JSON.JSONArray letter_animations_data = new Boomlagoon.JSON.JSONArray();
	//		if(m_master_animations != null)
	//			foreach(LetterAnimation anim in m_master_animations)
	//		{
	//			letter_animations_data.Add(anim.ExportData());
	//		}
	//		json_data["LETTER_ANIMATIONS_DATA"] = letter_animations_data;
	//	}



#if UNITY_EDITOR
		public string ExportDataAsPresetSection(bool saveSampleTextInfo = true)
		{
			if(m_master_animations == null || m_master_animations.Count == 0)
			{
				Debug.LogError("There's no animation to export");
				return "";
			}

			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			json_data["TEXTFX_EXPORTER_VERSION"] = JSON_EXPORTER_VERSION;
			json_data["LETTER_ANIMATIONS_DATA"] = m_master_animations[0].ExportDataAsPresetSection(saveSampleTextInfo);
			
			
			// Handle exporting quick setup configuration fields
			Boomlagoon.JSON.JSONArray effect_settings_options = new Boomlagoon.JSON.JSONArray();
			if(m_preset_effect_settings != null)
			{
				foreach(PresetEffectSetting effect_setting in m_preset_effect_settings)
				{
					effect_settings_options.Add(effect_setting.ExportData());
				}
			}
			json_data["PRESET_EFFECT_SETTINGS"] = effect_settings_options;
			
			return json_data.ToString();
		}
Exemplo n.º 11
0
		public Boomlagoon.JSON.JSONValue ExportData()
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			Boomlagoon.JSON.JSONArray anchors_data = new Boomlagoon.JSON.JSONArray();
			Boomlagoon.JSON.JSONObject anchor_point_data;
			
			foreach(BezierCurvePoint anchor_point in m_anchor_points)
			{
				anchor_point_data = new Boomlagoon.JSON.JSONObject();
				anchor_point_data["m_anchor_point"] = anchor_point.m_anchor_point.ExportData();
				anchor_point_data["m_handle_point"] = anchor_point.m_handle_point.ExportData();
				
				anchors_data.Add(anchor_point_data);
			}
			
			json_data["ANCHORS_DATA"] = anchors_data;
			
			return new Boomlagoon.JSON.JSONValue(json_data);
		}
Exemplo n.º 12
0
        /// <summary>
        /// Attempt to parse a string into a JSONObject.
        /// </summary>
        /// <param name="jsonString"></param>
        /// <returns>A new JSONObject or null if parsing fails.</returns>
        public static JSONObject Parse(string jsonString)
        {
            if (string.IsNullOrEmpty(jsonString))
            {
                return(null);
            }

            JSONValue currentValue = null;

            var keyList = new List <string>();

            var state = JSONParsingState.Object;

            for (var startPosition = 0; startPosition < jsonString.Length; ++startPosition)
            {
                startPosition = SkipWhitespace(jsonString, startPosition);

                switch (state)
                {
                case JSONParsingState.Object:
                    if (jsonString[startPosition] != '{')
                    {
                        return(Fail('{', startPosition));
                    }

                    JSONValue newObj = new JSONObject();
                    if (currentValue != null)
                    {
                        newObj.Parent = currentValue;
                    }
                    currentValue = newObj;

                    state = JSONParsingState.Key;
                    break;

                case JSONParsingState.EndObject:
                    if (jsonString[startPosition] != '}')
                    {
                        return(Fail('}', startPosition));
                    }

                    if (currentValue.Parent == null)
                    {
                        return(currentValue.Obj);
                    }

                    switch (currentValue.Parent.Type)
                    {
                    case JSONValueType.Object:
                        currentValue.Parent.Obj.values[keyList.Pop()] = new JSONValue(currentValue.Obj);
                        break;

                    case JSONValueType.Array:
                        currentValue.Parent.Array.Add(new JSONValue(currentValue.Obj));
                        break;

                    default:
                        return(Fail("valid object", startPosition));
                    }
                    currentValue = currentValue.Parent;

                    state = JSONParsingState.ValueSeparator;
                    break;

                case JSONParsingState.Key:
                    if (jsonString[startPosition] == '}')
                    {
                        --startPosition;
                        state = JSONParsingState.EndObject;
                        break;
                    }

                    var key = ParseString(jsonString, ref startPosition);
                    if (key == null)
                    {
                        return(Fail("key string", startPosition));
                    }
                    keyList.Add(key);
                    state = JSONParsingState.KeyValueSeparator;
                    break;

                case JSONParsingState.KeyValueSeparator:
                    if (jsonString[startPosition] != ':')
                    {
                        return(Fail(':', startPosition));
                    }
                    state = JSONParsingState.Value;
                    break;

                case JSONParsingState.ValueSeparator:
                    switch (jsonString[startPosition])
                    {
                    case ',':
                        state = currentValue.Type == JSONValueType.Object ? JSONParsingState.Key : JSONParsingState.Value;
                        break;

                    case '}':
                        state = JSONParsingState.EndObject;
                        --startPosition;
                        break;

                    case ']':
                        state = JSONParsingState.EndArray;
                        --startPosition;
                        break;

                    default:
                        return(Fail(", } ]", startPosition));
                    }
                    break;

                case JSONParsingState.Value:
                {
                    var c = jsonString[startPosition];
                    if (c == '"')
                    {
                        state = JSONParsingState.String;
                    }
                    else if (char.IsDigit(c) || c == '-')
                    {
                        state = JSONParsingState.Number;
                    }
                    else
                    {
                        switch (c)
                        {
                        case '{':
                            state = JSONParsingState.Object;
                            break;

                        case '[':
                            state = JSONParsingState.Array;
                            break;

                        case ']':
                            if (currentValue.Type == JSONValueType.Array)
                            {
                                state = JSONParsingState.EndArray;
                            }
                            else
                            {
                                return(Fail("valid array", startPosition));
                            }
                            break;

                        case 'f':
                        case 't':
                            state = JSONParsingState.Boolean;
                            break;


                        case 'n':
                            state = JSONParsingState.Null;
                            break;

                        default:
                            return(Fail("beginning of value", startPosition));
                        }
                    }

                    --startPosition;         //To re-evaluate this char in the newly selected state
                    break;
                }

                case JSONParsingState.String:
                    var str = ParseString(jsonString, ref startPosition);
                    if (str == null)
                    {
                        return(Fail("string value", startPosition));
                    }

                    switch (currentValue.Type)
                    {
                    case JSONValueType.Object:
                        currentValue.Obj.values[keyList.Pop()] = new JSONValue(str);
                        break;

                    case JSONValueType.Array:
                        currentValue.Array.Add(str);
                        break;

                    default:
                        JSONLogger.Error("Fatal error, current JSON value not valid");
                        return(null);
                    }

                    state = JSONParsingState.ValueSeparator;
                    break;

                case JSONParsingState.Number:
                    var number = ParseNumber(jsonString, ref startPosition);
                    if (double.IsNaN(number))
                    {
                        return(Fail("valid number", startPosition));
                    }

                    switch (currentValue.Type)
                    {
                    case JSONValueType.Object:
                        currentValue.Obj.values[keyList.Pop()] = new JSONValue(number);
                        break;

                    case JSONValueType.Array:
                        currentValue.Array.Add(number);
                        break;

                    default:
                        JSONLogger.Error("Fatal error, current JSON value not valid");
                        return(null);
                    }

                    state = JSONParsingState.ValueSeparator;

                    break;

                case JSONParsingState.Boolean:
                    if (jsonString[startPosition] == 't')
                    {
                        if (jsonString.Length < startPosition + 4 ||
                            jsonString[startPosition + 1] != 'r' ||
                            jsonString[startPosition + 2] != 'u' ||
                            jsonString[startPosition + 3] != 'e')
                        {
                            return(Fail("true", startPosition));
                        }

                        switch (currentValue.Type)
                        {
                        case JSONValueType.Object:
                            currentValue.Obj.values[keyList.Pop()] = new JSONValue(true);
                            break;

                        case JSONValueType.Array:
                            currentValue.Array.Add(new JSONValue(true));
                            break;

                        default:
                            JSONLogger.Error("Fatal error, current JSON value not valid");
                            return(null);
                        }

                        startPosition += 3;
                    }
                    else
                    {
                        if (jsonString.Length < startPosition + 5 ||
                            jsonString[startPosition + 1] != 'a' ||
                            jsonString[startPosition + 2] != 'l' ||
                            jsonString[startPosition + 3] != 's' ||
                            jsonString[startPosition + 4] != 'e')
                        {
                            return(Fail("false", startPosition));
                        }

                        switch (currentValue.Type)
                        {
                        case JSONValueType.Object:
                            currentValue.Obj.values[keyList.Pop()] = new JSONValue(false);
                            break;

                        case JSONValueType.Array:
                            currentValue.Array.Add(new JSONValue(false));
                            break;

                        default:
                            JSONLogger.Error("Fatal error, current JSON value not valid");
                            return(null);
                        }

                        startPosition += 4;
                    }

                    state = JSONParsingState.ValueSeparator;
                    break;

                case JSONParsingState.Array:
                    if (jsonString[startPosition] != '[')
                    {
                        return(Fail('[', startPosition));
                    }

                    JSONValue newArray = new JSONArray();
                    if (currentValue != null)
                    {
                        newArray.Parent = currentValue;
                    }
                    currentValue = newArray;

                    state = JSONParsingState.Value;
                    break;

                case JSONParsingState.EndArray:
                    if (jsonString[startPosition] != ']')
                    {
                        return(Fail(']', startPosition));
                    }

                    if (currentValue.Parent == null)
                    {
                        return(currentValue.Obj);
                    }

                    switch (currentValue.Parent.Type)
                    {
                    case JSONValueType.Object:
                        currentValue.Parent.Obj.values[keyList.Pop()] = new JSONValue(currentValue.Array);
                        break;

                    case JSONValueType.Array:
                        currentValue.Parent.Array.Add(new JSONValue(currentValue.Array));
                        break;

                    default:
                        return(Fail("valid object", startPosition));
                    }
                    currentValue = currentValue.Parent;

                    state = JSONParsingState.ValueSeparator;
                    break;

                case JSONParsingState.Null:
                    if (jsonString[startPosition] == 'n')
                    {
                        if (jsonString.Length < startPosition + 4 ||
                            jsonString[startPosition + 1] != 'u' ||
                            jsonString[startPosition + 2] != 'l' ||
                            jsonString[startPosition + 3] != 'l')
                        {
                            return(Fail("null", startPosition));
                        }

                        switch (currentValue.Type)
                        {
                        case JSONValueType.Object:
                            currentValue.Obj.values[keyList.Pop()] = new JSONValue(JSONValueType.Null);
                            break;

                        case JSONValueType.Array:
                            currentValue.Array.Add(new JSONValue(JSONValueType.Null));
                            break;

                        default:
                            JSONLogger.Error("Fatal error, current JSON value not valid");
                            return(null);
                        }

                        startPosition += 3;
                    }
                    state = JSONParsingState.ValueSeparator;
                    break;
                }
            }
            JSONLogger.Error("Unexpected end of string");
            return(null);
        }
Exemplo n.º 13
0
 public JSONValue(JSONArray array)
 {
     Type  = JSONValueType.Array;
     Array = array;
 }
Exemplo n.º 14
0
		public Boomlagoon.JSON.JSONValue ExportData()
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			json_data["m_letters_to_animate"] = m_letters_to_animate.ExportData();
			json_data["m_letters_to_animate_custom_idx"] = m_letters_to_animate_custom_idx;
			json_data["m_letters_to_animate_option"] = (int) m_letters_to_animate_option;
			
			if(m_loop_cycles.Count > 0)
			{
				Boomlagoon.JSON.JSONArray loops_data = new Boomlagoon.JSON.JSONArray();
				
				foreach(ActionLoopCycle action_loop in m_loop_cycles)
				{
					loops_data.Add(action_loop.ExportData());
				}
				
				json_data["LOOPS_DATA"] = loops_data;
			}
			
			Boomlagoon.JSON.JSONArray actions_data = new Boomlagoon.JSON.JSONArray();
			foreach(LetterAction action in m_letter_actions)
			{
				actions_data.Add(action.ExportData());
			}
			json_data["ACTIONS_DATA"] = actions_data;
			
			return new Boomlagoon.JSON.JSONValue(json_data);
		}
Exemplo n.º 15
0
		public Boomlagoon.JSON.JSONValue ExportDataAsPresetSection(bool saveSampleTextData = true)
		{
			Boomlagoon.JSON.JSONObject json_data = new Boomlagoon.JSON.JSONObject();
			
			if(m_loop_cycles.Count > 0)
			{
				Boomlagoon.JSON.JSONArray loops_data = new Boomlagoon.JSON.JSONArray();
				
				foreach(ActionLoopCycle action_loop in m_loop_cycles)
				{
					loops_data.Add(action_loop.ExportData());
				}
				
				json_data["LOOPS_DATA"] = loops_data;
			}
			
			Boomlagoon.JSON.JSONArray actions_data = new Boomlagoon.JSON.JSONArray();
			foreach(LetterAction action in m_letter_actions)
			{
				actions_data.Add(action.ExportData());
			}
			json_data["ACTIONS_DATA"] = actions_data;

			if(saveSampleTextData)
				json_data["SAMPLE_NUM_LETTERS_ANIMATED"] = m_letters_to_animate.Count;

			return new Boomlagoon.JSON.JSONValue(json_data);
		}