Exemplo n.º 1
0
    void LoadData()
    {
        itemGroupData          = null;
        selectedItemGroupIndex = -1;

        EditorHelpers.LoadItemGroupConfigs();
        EditorHelpers.LoadItemConfigs();
    }
Exemplo n.º 2
0
    bool DrawLoadService()
    {
        contentColor    = GUI.contentColor;
        backgroundColor = GUI.backgroundColor;

        EditorGUILayout.BeginHorizontal();
        GUI.backgroundColor = EditorHelpers.orangeColor;
        if (GUILayout.Button("Load", GUILayout.Width(60)))
        {
            LoadData();
        }

        GUI.backgroundColor = EditorHelpers.yellowColor;
        if (GUILayout.Button("New", GUILayout.Width(60)))
        {
            ItemGroupConfigData newData = new ItemGroupConfigData();
            newData.id = "New Item Group " + newItemGroupNameSufix.ToString();
            ++newItemGroupNameSufix;
            EditorHelpers.allItemGroups.Insert(0, newData);
            EditorHelpers.InitItemGroupNames();
            selectedItemGroupIndex = 0;
            itemGroupData          = newData;
            ShowNotification(new GUIContent("New Item Group added."));
            dirty = true;
        }
        GUI.backgroundColor = EditorHelpers.greenColor;
        if (GUILayout.Button("Save", GUILayout.Width(60)))
        {
            Save();
        }
        GUI.backgroundColor = backgroundColor;
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator();
        if (EditorHelpers.allItemGroups == null)
        {
            EditorGUILayout.HelpBox("It seems that there is no data... try reopening the editor.", MessageType.Error);
            return(false);
        }
        if (EditorHelpers.allItemGroups.Count > 0)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Items Groups:", GUILayout.Width(100));
            int oldIntValue = selectedItemGroupIndex;
            selectedItemGroupIndex = EditorGUILayout.Popup(oldIntValue, EditorHelpers.itemGroupNames, GUILayout.Width(250));
            if (oldIntValue != selectedItemGroupIndex)
            {
                itemGroupData = EditorHelpers.allItemGroups[selectedItemGroupIndex];
            }
            if (itemGroupData != null)
            {
                GUI.backgroundColor = EditorHelpers.redColor;
                if (GUILayout.Button("Delete", GUILayout.Width(70)))
                {
                    if (EditorUtility.DisplayDialog("Deleting Item Group!", "Are you sure you want to delete parameter '" + itemGroupData.id + "'?", "Yes, Delete it.", "No!"))
                    {
                        EditorHelpers.gameDB.DeleteConfig(itemGroupData.GetTableName(), itemGroupData.id);
                        EditorHelpers.allItemGroups.Remove(itemGroupData);
                        EditorHelpers.InitItemGroupNames();
                        selectedItemGroupIndex = -1;
                        itemGroupData          = null;
                        ShowNotification(new GUIContent("Item deleted."));
                        return(false);
                    }
                }
                GUI.backgroundColor = EditorHelpers.blueColor;
                if (GUILayout.Button("Duplicate", GUILayout.Width(100)))
                {
                    ItemGroupConfigData newData = itemGroupData.Clone() as ItemGroupConfigData;
                    newData.id = itemGroupData.id + "(Clone)";
                    EditorHelpers.allItemGroups.Insert(0, newData);
                    EditorHelpers.InitItemGroupNames();
                    selectedItemGroupIndex = 0;
                    itemGroupData          = newData;
                    ShowNotification(new GUIContent("Item Group duplicated."));
                    dirty = true;
                }
                GUI.backgroundColor = backgroundColor;
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator(); EditorGUILayout.Separator(); EditorGUILayout.Separator();
        }

        return(itemGroupData != null);
    }