public void DrawItems()
    {
        if (!metaTarget)
        {
            EditorGUILayout.HelpBox("BerryStoreAssistant is missing", MessageType.Error);
            return;
        }
        main = (BerryStoreAssistant)metaTarget;
        Undo.RecordObject(main, "");

        EditorGUILayout.BeginHorizontal();

        GUILayout.Space(20);
        GUILayout.Label("Name", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(80));
        GUILayout.Label("ID", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(60));
        GUILayout.Label("Localiz. Name", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(150));
        GUILayout.Label("Localiz. Descipt.", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(150));

        EditorGUILayout.EndHorizontal();

        foreach (BerryStoreAssistant.ItemInfo item in main.items)
        {
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                main.items.Remove(item);
                break;
            }
            item.name = EditorGUILayout.TextField(item.name, GUILayout.Width(80));
            item.id   = EditorGUILayout.TextField(item.id, GUILayout.Width(60));
            EditorGUILayout.LabelField(item.localization_name, GUILayout.Width(150));
            EditorGUILayout.LabelField(item.localization_description, GUILayout.Width(150));

            EditorGUILayout.EndHorizontal();
        }

        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("Add", GUILayout.Width(60)))
        {
            main.items.Add(new BerryStoreAssistant.ItemInfo());
        }
        if (GUILayout.Button("Edit Localization", GUILayout.Width(150)))
        {
            AllInOnePanel.CreateBerryPanel().EditLocalization("item_");
        }

        EditorGUILayout.EndHorizontal();
    }
Пример #2
0
    public override void OnInspectorGUI()
    {
        if (!metaTarget)
        {
            EditorGUILayout.HelpBox("ServiceAssistant is missing", MessageType.Error);
            return;
        }

        ServiceAssistant main = (ServiceAssistant)metaTarget;

        Undo.RecordObject(main, "");

        main.lifes_refilled_notification = EditorGUILayout.BeginToggleGroup("Lifes Refilling Notification", main.lifes_refilled_notification);
        if (GUILayout.Button("Edit Text", GUILayout.Width(100)))
        {
            AllInOnePanel.CreateBerryPanel().EditLocalization("notification_lifesrefilled");
        }
        EditorGUILayout.EndToggleGroup();

        EditorGUILayout.Space();

        main.daily_reward_notification = EditorGUILayout.BeginToggleGroup("Daily Reward Notification", main.daily_reward_notification);
        main.daily_reward_hour         = Mathf.RoundToInt(EditorGUILayout.Slider("Notification Time: " + main.daily_reward_hour.ToString("D2") + ":00", main.daily_reward_hour, 0, 23));
        if (GUILayout.Button("Edit Text", GUILayout.Width(100)))
        {
            AllInOnePanel.CreateBerryPanel().EditLocalization("notification_dailyreward");
        }
        EditorGUILayout.EndToggleGroup();

        EditorGUILayout.Space();

        main.good_morning_notification = EditorGUILayout.BeginToggleGroup("Good Morning Notification", main.good_morning_notification);
        main.good_morning_hour         = Mathf.RoundToInt(EditorGUILayout.Slider("Notification Time: " + main.good_morning_hour.ToString("D2") + ":00", main.good_morning_hour, 0, 23));
        main.good_morning_days_delay   = Mathf.RoundToInt(EditorGUILayout.Slider("Days Delay: " + main.good_morning_days_delay.ToString() + " day(s)", main.good_morning_days_delay, 1, 14));
        if (GUILayout.Button("Edit Text", GUILayout.Width(100)))
        {
            AllInOnePanel.CreateBerryPanel().EditLocalization("notification_goodmorning");
        }
        EditorGUILayout.EndToggleGroup();
    }
    public override void OnInspectorGUI()
    {
        if (!metaTarget)
        {
            EditorGUILayout.HelpBox("LocalizationAssistant is missing", MessageType.Error);
            return;
        }
        main = (LocalizationAssistant)metaTarget;
        Undo.RecordObject(main, "localization changings");



        EditorGUILayout.BeginVertical(EditorStyles.textArea, GUILayout.ExpandWidth(true));
        main.use_system_language_by_default = GUILayout.Toggle(main.use_system_language_by_default, "Use system language by default");
        if (!main.use_system_language_by_default)
        {
            List <string> languages = main.languages.Select(x => x.ToString()).ToList();
            int           id        = languages.IndexOf(main.default_language.ToString());
            if (id < 0)
            {
                id = 0;
            }
            id = EditorGUILayout.Popup("Default language", id, languages.ToArray());
            main.default_language = (SystemLanguage)System.Enum.Parse(typeof(SystemLanguage), languages[id]);
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.Space();

        EditorGUILayout.BeginVertical(EditorStyles.textArea, GUILayout.ExpandWidth(true));

        #region Languages list panel
        EditorGUILayout.BeginHorizontal();

        GUILayout.Label("-", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(20));
        GUILayout.Label("Edit", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(35));
        GUILayout.Label("Name", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(200));

        EditorGUILayout.EndHorizontal();

        foreach (SystemLanguage language in main.languages)
        {
            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button("X", GUILayout.Width(20)))
            {
                main.languages.Remove(language);
                break;
            }
            if (GUILayout.Button("Edit", GUILayout.Width(35)))
            {
                AllInOnePanel.CreateBerryPanel().EditLocalization(language);
            }
            EditorGUILayout.LabelField(language.ToString(), GUILayout.Width(200));

            EditorGUILayout.EndHorizontal();
        }
        #endregion

        EditorGUILayout.Space();


        #region "Add new" panel
        EditorGUILayout.BeginHorizontal();
        GUI.enabled = !main.languages.Contains(new_language);
        if (GUILayout.Button("Add", GUILayout.Width(40)))
        {
            main.languages.Add(new_language);
        }
        GUI.enabled = true;

        new_language = (SystemLanguage)EditorGUILayout.EnumPopup(new_language, GUILayout.Width(200));
        EditorGUILayout.EndHorizontal();
        #endregion

        EditorGUILayout.EndVertical();
    }
Пример #4
0
    public override void OnInspectorGUI()
    {
        Undo.RecordObject(main, "DinaLabel changes");

        main.localized = EditorGUILayout.Toggle("Localized", main.localized);

        List <string> masks = new List <string>();

        EditorGUILayout.BeginVertical(EditorStyles.textArea, GUILayout.Width(300));
        EditorGUILayout.Space();

        if (main.localized)
        {
            #region Localized settings
            if (!assistant)
            {
                EditorGUILayout.HelpBox("Localization Assistant is missing", MessageType.Error);
            }
            else
            {
                int id = LocalizationAssistantEditor.keys.IndexOf(main.key);
                if (id < 0)
                {
                    id = 0;
                }

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("key", GUILayout.Width(50));
                id = EditorGUILayout.Popup(id, LocalizationAssistantEditor.keys_menu);
                EditorGUILayout.EndHorizontal();

                main.key = LocalizationAssistantEditor.keys[id];

                foreach (SystemLanguage language in assistant.languages)
                {
                    EditorGUILayout.LabelField(language.ToString(), EditorStyles.miniLabel);
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Edit", GUILayout.Width(40)))
                    {
                        AllInOnePanel.CreateBerryPanel().EditLocalization(language, main.key);
                    }
                    if (LocalizationAssistantEditor.content.ContainsKey(language) && (LocalizationAssistantEditor.content[language].ContainsKey(main.key)))
                    {
                        EditorGUILayout.HelpBox(LocalizationAssistantEditor.content[language][main.key], MessageType.None);
                        masks.AddRange(GetMasks(LocalizationAssistantEditor.content[language][main.key]));
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("", MessageType.None);
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            #endregion
        }
        else
        {
            #region Non localized settings
            main.text = EditorGUILayout.TextField("Text", main.text);
            masks.AddRange(GetMasks(main.text));
            #endregion
        }

        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();

        masks = masks.Distinct().ToList();
        masks.Sort();

        Dictionary <string, DinaLabel.Mask> _masks = main.masks.ToDictionary(x => x.key, x => x);

        foreach (string mask in masks)
        {
            if (!_masks.ContainsKey(mask))
            {
                _masks.Add(mask, new DinaLabel.Mask(mask));
            }
        }

        if (_masks.Count > 0)
        {
            main.update = EditorGUILayout.Toggle("Update", main.update);
            GUI.enabled = main.update;
            main.delay  = EditorGUILayout.Slider("Delay", main.delay, 0.1f, 3f);
            GUI.enabled = true;
        }
        else
        {
            main.update = false;
        }

        #region Masks panel
        EditorGUILayout.BeginVertical(EditorStyles.textArea, GUILayout.MinWidth(300));
        EditorGUILayout.BeginHorizontal();

        GUILayout.Label("Key", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(100));
        GUILayout.Label("Value", EditorStyles.centeredGreyMiniLabel, GUILayout.Width(200));

        EditorGUILayout.EndHorizontal();
        foreach (string key in _masks.Keys.ToArray())
        {
            if (!masks.Contains(key))
            {
                _masks.Remove(key);
            }
            else
            {
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(key, GUILayout.Width(100));

                int id = mask_values.IndexOf(_masks[key].value);
                if (id < 0)
                {
                    id = 0;
                }

                id = EditorGUILayout.Popup(id, mask_values.ToArray(), GUILayout.Width(200));
                _masks[key].value = mask_values[id];

                EditorGUILayout.EndHorizontal();
            }
        }
        main.masks = _masks.Values.ToList();
        EditorGUILayout.Space();
        EditorGUILayout.EndVertical();
        #endregion
    }