Exemplo n.º 1
0
    void LoadData()
    {
        rankData          = null;
        selectedRankIndex = -1;

        gameDB.InitLocalDB();
        allRanks = gameDB.LoadConfig <RankConfigData>() as List <RankConfigData>;
        InitIAPNames();
    }
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)))
        {
            RankConfigData newData = new RankConfigData();
            newData.id = "New Rank " + newRankNameSufix.ToString();
            ++newRankNameSufix;
            allRanks.Insert(0, newData);
            InitIAPNames();
            selectedRankIndex = 0;
            rankData          = newData;
            ShowNotification(new GUIContent("New Rank 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 (allRanks == null)
        {
            EditorGUILayout.HelpBox("It seems that there is no data... try reopening the editor.", MessageType.Error);
            return(false);
        }
        if (allRanks.Count > 0)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("iAPs:", GUILayout.Width(100));
            int oldIntValue = selectedRankIndex;
            selectedRankIndex = EditorGUILayout.Popup(oldIntValue, rankNames, GUILayout.Width(250));
            if (oldIntValue != selectedRankIndex)
            {
                rankData = allRanks[selectedRankIndex];
            }
            if (rankData != null)
            {
                GUI.backgroundColor = EditorHelpers.redColor;
                if (GUILayout.Button("Delete", GUILayout.Width(70)))
                {
                    if (EditorUtility.DisplayDialog("Deleting Rank!", "Are you sure you want to delete Rank'" + rankData.id + "'?", "Yes, Delete it.", "No!"))
                    {
                        gameDB.DeleteConfig(rankData.GetTableName(), rankData.id);
                        allRanks.Remove(rankData);
                        InitIAPNames();
                        selectedRankIndex = -1;
                        rankData          = null;
                        ShowNotification(new GUIContent("Rank deleted."));
                        return(false);
                    }
                }
                GUI.backgroundColor = backgroundColor;
            }
            EditorGUILayout.EndHorizontal();

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

        return(rankData != null);
    }