예제 #1
0
    public static string Save(Component component, string fullPath)
    {
        vp_ComponentPreset vp_ComponentPreset = new vp_ComponentPreset();

        vp_ComponentPreset.InitFromComponent(component);
        return(vp_ComponentPreset.Save(vp_ComponentPreset, fullPath, false));
    }
예제 #2
0
    /// <summary>
    /// saves every supported field of 'preset' to text at 'fullPath'
    /// </summary>
    public static string Save(Component component, string fullPath)
    {
        vp_ComponentPreset preset = new vp_ComponentPreset();

        preset.InitFromComponent(component);
        return(Save(preset, fullPath));
    }
예제 #3
0
    public static string SaveDifference(vp_ComponentPreset initialStatePreset, Component modifiedComponent, string fullPath, vp_ComponentPreset diskPreset)
    {
        if (initialStatePreset.ComponentType != modifiedComponent.GetType())
        {
            vp_ComponentPreset.Error("Tried to save difference between different type components in 'SaveDifference'");
            return(null);
        }
        vp_ComponentPreset vp_ComponentPreset = new vp_ComponentPreset();

        vp_ComponentPreset.InitFromComponent(modifiedComponent);
        vp_ComponentPreset vp_ComponentPreset2 = new vp_ComponentPreset();

        vp_ComponentPreset2.m_ComponentType = vp_ComponentPreset.ComponentType;
        for (int i = 0; i < vp_ComponentPreset.m_Fields.Count; i++)
        {
            if (!initialStatePreset.m_Fields[i].Args.Equals(vp_ComponentPreset.m_Fields[i].Args))
            {
                vp_ComponentPreset2.m_Fields.Add(vp_ComponentPreset.m_Fields[i]);
            }
        }
        foreach (vp_ComponentPreset.Field current in diskPreset.m_Fields)
        {
            bool flag = true;
            foreach (vp_ComponentPreset.Field current2 in vp_ComponentPreset2.m_Fields)
            {
                if (current.FieldHandle == current2.FieldHandle)
                {
                    flag = false;
                }
            }
            bool flag2 = false;
            foreach (vp_ComponentPreset.Field current3 in vp_ComponentPreset.m_Fields)
            {
                if (current.FieldHandle == current3.FieldHandle)
                {
                    flag2 = true;
                }
            }
            if (!flag2)
            {
                flag = false;
            }
            if (flag)
            {
                vp_ComponentPreset2.m_Fields.Add(current);
            }
        }
        return(vp_ComponentPreset.Save(vp_ComponentPreset2, fullPath, true));
    }
	/// <summary>
	/// saves every supported field of 'preset' to text at 'fullPath'
	/// </summary>
	public static string Save(Component component, string fullPath)
	{
		vp_ComponentPreset preset = new vp_ComponentPreset();
		preset.InitFromComponent(component);
		return Save(preset, fullPath);
	}
	/// <summary>
	/// saves only the fields that were changed
	/// </summary>
	public static string SaveDifference(vp_ComponentPreset initialStatePreset, Component modifiedComponent, string fullPath, vp_ComponentPreset diskPreset)
	{

		if (initialStatePreset.ComponentType != modifiedComponent.GetType())
		{
			Error("Tried to save difference between different type components in 'SaveDifference'");
			return null;
		}

		// create a preset to hold the current state of the component
		vp_ComponentPreset modifiedPreset = new vp_ComponentPreset();
		modifiedPreset.InitFromComponent(modifiedComponent);

		// create an empty preset of the same type
		vp_ComponentPreset result = new vp_ComponentPreset();
		result.m_ComponentType = modifiedPreset.ComponentType;

		for (int v = 0; v < modifiedPreset.m_Fields.Count; v++)
		{
			// if the field in the current preset has been changed since
			// the initial preset was created, add the differing field to
			// our result
			if (!initialStatePreset.m_Fields[v].Args.Equals(modifiedPreset.m_Fields[v].Args))
				result.m_Fields.Add(modifiedPreset.m_Fields[v]);
		}

		// if the target filename already contains a preset with values,
		// we copy those values into our new result - but only if they
		// don't exist in the new result

		// for each field in the disk preset
		foreach (Field d in diskPreset.m_Fields)
		{

			bool copyField = true;

			// check it against all the fields in our new preset
			foreach (Field r in result.m_Fields)
			{
				// if the field also exists in the 'result' preset,
				// don't copy it since it has changed
				if (d.FieldHandle == r.FieldHandle)
					copyField = false;
			}

			// only copy the field if it in fact belongs in this type of
			// component (we may be saving over a different preset type
			// and should not be copying unknown parameters)
			bool found = false;
			foreach (Field m in modifiedPreset.m_Fields)
			{
				if (d.FieldHandle == m.FieldHandle)
					found = true;
			}
			if (found == false)
				copyField = false;

			// done, copy the field
			if (copyField)
				result.m_Fields.Add(d);

		}

		return Save(result, fullPath, true);

	}
예제 #6
0
    /// <summary>
    /// saves only the fields that were changed
    /// </summary>
    public static string SaveDifference(vp_ComponentPreset initialStatePreset, Component modifiedComponent, string fullPath, vp_ComponentPreset diskPreset)
    {
        if (initialStatePreset.ComponentType != modifiedComponent.GetType())
        {
            Error("Tried to save difference between different type components in 'SaveDifference'");
            return(null);
        }

        // create a preset to hold the current state of the component
        vp_ComponentPreset modifiedPreset = new vp_ComponentPreset();

        modifiedPreset.InitFromComponent(modifiedComponent);

        // create an empty preset of the same type
        vp_ComponentPreset result = new vp_ComponentPreset();

        result.m_ComponentType = modifiedPreset.ComponentType;

        for (int v = 0; v < modifiedPreset.m_Fields.Count; v++)
        {
            // if the field in the current preset has been changed since
            // the initial preset was created, add the differing field to
            // our result
            if (!initialStatePreset.m_Fields[v].Args.Equals(modifiedPreset.m_Fields[v].Args))
            {
                result.m_Fields.Add(modifiedPreset.m_Fields[v]);
            }
        }

        // if the target filename already contains a preset with values,
        // we copy those values into our new result - but only if they
        // don't exist in the new result

        // for each field in the disk preset
        foreach (Field d in diskPreset.m_Fields)
        {
            bool copyField = true;

            // check it against all the fields in our new preset
            foreach (Field r in result.m_Fields)
            {
                // if the field also exists in the 'result' preset,
                // don't copy it since it has changed
                if (d.FieldHandle == r.FieldHandle)
                {
                    copyField = false;
                }
            }

            // only copy the field if it in fact belongs in this type of
            // component (we may be saving over a different preset type
            // and should not be copying unknown parameters)
            bool found = false;
            foreach (Field m in modifiedPreset.m_Fields)
            {
                if (d.FieldHandle == m.FieldHandle)
                {
                    found = true;
                }
            }
            if (found == false)
            {
                copyField = false;
            }

            // done, copy the field
            if (copyField)
            {
                result.m_Fields.Add(d);
            }
        }

        return(Save(result, fullPath, true));
    }