protected void FillSelectedWithList(IList p_list, bool p_reapplySelection, bool p_acceptNulls = false)
    {
        m_selectedObjects = new AOTDictionaryKV <int, GameObject>();
        List <Object> v_selectedObject = new List <Object>();

        if (p_list != null)
        {
            for (int i = 0; i < p_list.Count; i++)
            {
                AOTKeyValuePair <int, GameObject> v_object = p_list[i] as AOTKeyValuePair <int, GameObject>;
                if (v_object != null)
                {
                    if ((v_object.Value != null || p_acceptNulls))
                    {
                        v_selectedObject.Add(v_object.Value);
                    }
                    m_selectedObjects.Add(v_object);
                }
            }
            foreach (Rope2D v_rope in m_currentCreatedRopes)
            {
                if (v_rope != null && v_rope.gameObject != null)
                {
                    v_selectedObject.Add(v_rope.gameObject);
                }
            }
            if (p_reapplySelection)
            {
                Selection.objects = v_selectedObject.ToArray();
            }
        }
    }
 public override bool Equals(object p_value)
 {
     if (p_value == this)
     {
         return(true);
     }
     if (!AOTHelper.IsNull(p_value))
     {
         try {
             AOTKeyValuePair <TKey, TValue> v_castedObject = p_value as AOTKeyValuePair <TKey, TValue>;
             if (v_castedObject != null)
             {
                                     #pragma warning disable 618
                 if (((AOTHelper.IsNull(v_castedObject.Key) && AOTHelper.IsNull(this.Key)) || v_castedObject.Comparer.Equals(this.Key)) &&
                                     #pragma warning restore 618
                     ((AOTHelper.IsNull(v_castedObject.Value) && AOTHelper.IsNull(this.Value)) || v_castedObject.Value.Equals(this.Value)))
                 {
                     return(true);
                 }
             }
         } catch {
         }
     }
     return(false);
 }
Esempio n. 3
0
    public static void AddDefineChecking(string p_defineName, string p_fileNeeded, bool p_forceSave = false)
    {
        AOTKeyValuePair <string, string> v_founded = null;

        foreach (AOTKeyValuePair <string, string> v_pair in DefineByFolderName)
        {
            if (v_pair != null && !string.IsNullOrEmpty(v_pair.Value) && v_pair.Value.Equals(p_defineName))
            {
                v_founded = v_pair;
                break;
            }
        }
        bool v_needAdd = false;

        if (v_founded == null)
        {
            v_needAdd = true;
            v_founded = new AOTKeyValuePair <string, string>();
        }
        v_founded.Value = p_defineName;
        v_founded.Key   = p_fileNeeded;

        if (v_needAdd)
        {
            DefineByFolderName.Add(v_founded);
        }
        if (p_forceSave)
        {
            Save();
        }
    }
	public static void AddDefineChecking(string p_defineName, string p_fileNeeded, bool p_forceSave = false)
	{
		AOTKeyValuePair<string, string> v_founded = null;
		foreach(AOTKeyValuePair<string,string> v_pair in DefineByFolderName)
		{
			if(v_pair != null && !string.IsNullOrEmpty(v_pair.Value) && v_pair.Value.Equals(p_defineName))
			{
				v_founded = v_pair;
				break;
			}
		}
		bool v_needAdd = false;
		if(v_founded == null)
		{
			v_needAdd = true;
			v_founded = new AOTKeyValuePair<string, string>();
		}
		v_founded.Value = p_defineName;
		v_founded.Key = p_fileNeeded;

		if(v_needAdd)
			DefineByFolderName.Add(v_founded);
		if(p_forceSave)
			Save();
	}
    private static bool DrawDictionaryInternal <ComparerType, ObjectType>(string p_labelString, ref AOTDictionaryKV <ComparerType, ObjectType> p_dict, bool p_isOpened)
    {
        p_isOpened = EditorGUILayout.Foldout(p_isOpened, p_labelString);
        try
        {
            //Try Fill Empty Lists
            if (p_dict == null)
            {
                try
                {
                    p_dict = new AOTDictionaryKV <ComparerType, ObjectType>();
                }
                catch {}
            }
            if (p_isOpened)
            {
                if (p_dict != null)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Space(10);
                    int v_count = Mathf.Max(0, EditorGUILayout.IntField("Size", p_dict.Count));
                    EditorGUILayout.EndHorizontal();

                    while (v_count != p_dict.Count)
                    {
                        if (v_count > p_dict.Count)
                        {
                            p_dict.Add(new AOTKeyValuePair <ComparerType, ObjectType>());
                        }
                        else
                        {
                            p_dict.RemoveAt(p_dict.Count - 1);
                        }
                    }
                    for (int i = 0; i < p_dict.Count; i++)
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Space(10);
                        object p_comparer = DrawType <ComparerType>("Element " + (i + 1), p_dict[i].Key);
                        object p_object   = DrawType <ObjectType>("", p_dict[i].Value);
                        p_dict[i] = new AOTKeyValuePair <ComparerType, ObjectType>((ComparerType)p_comparer, (ObjectType)p_object);
                        EditorGUILayout.EndHorizontal();
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Dictionary cannot be null", MessageType.Warning);
                }
            }
        }
        catch
        {
            EditorGUILayout.HelpBox("Dictionary dont accept " + typeof(ObjectType), MessageType.Warning);
        }
        return(p_isOpened);
    }
    protected void HandleOnDrawElement(Rect p_rect, int p_index, bool p_isActive, bool p_isFocused)
    {
        Color v_oldColor = GUI.backgroundColor;
        AOTKeyValuePair <int, GameObject> v_currentObject = m_selectedObjects[p_index];

        if (v_currentObject != null)
        {
            Rect v_firstRect  = new Rect(p_rect.x, p_rect.y, p_rect.width - 60, p_rect.height);
            Rect v_secondRect = new Rect(p_rect.x + v_firstRect.width, p_rect.y, p_rect.width - v_firstRect.width, p_rect.height);
            GUI.enabled = m_windowInformation != null && !m_windowInformation.PickSelectedObjects;
            if (v_currentObject.Value == null)
            {
                GUI.backgroundColor = Color.red;
            }
            GameObject v_newGameObject = EditorGUI.ObjectField(v_firstRect, v_currentObject.Value, typeof(GameObject), true) as GameObject;
            GUI.backgroundColor = v_oldColor;
            GUI.enabled         = true;
            if (v_newGameObject != v_currentObject.Value)
            {
                v_currentObject.Value = v_newGameObject;
                _needFillSelected     = true;
            }
            //Draw Tack Selector
            if (v_currentObject != null)
            {
                TacksInventory v_controller = v_currentObject.Value != null?v_currentObject.Value.GetNonMarkedComponentInChildren <TacksInventory>() : null;

                if (v_controller != null)
                {
                    v_controller.FillWithChildrenTacks(true);
                }
                if (v_controller != null && v_controller.TacksInObject.Count > 0)
                {
                    GUI.backgroundColor = Color.green;
                    v_currentObject.Key = EditorGUI.Popup(v_secondRect, v_currentObject.Key, v_controller.TacksInObject.GetStringList().ToArray());
                }
                else
                {
                    GUI.enabled = false;
                    //if(v_currentObject.Value == null)
                    GUI.backgroundColor = Color.red;
                    v_currentObject.Key = EditorGUI.Popup(v_secondRect, v_currentObject.Key, new string[0]);
                    GUI.enabled         = true;
                }
                GUI.backgroundColor = v_oldColor;
            }
        }
    }