Ejemplo n.º 1
0
 public virtual void SetConfigString(string StringKey, string Value)
 {
     IgorConfig.SetModuleString(this, StringKey, Value);
 }
Ejemplo n.º 2
0
        public virtual void DrawStringConfigParamDifferentOverride(ref string CurrentParams, string StringLabel, string StringOverrideParam, string ConfigKey, string OverrideCurrentValue = null)
        {
            string CurrentStringValue = "";
            string CurrentConfigValue = IgorConfig.GetModuleString(this, ConfigKey);

            bool bDisplayConfigValue = false;

            if (OverrideCurrentValue == null)
            {
                if (IgorRuntimeUtils.IsStringParamSet(CurrentParams, StringOverrideParam))
                {
                    CurrentStringValue = IgorRuntimeUtils.GetStringParam(CurrentParams, StringOverrideParam);
                }
                else
                {
                    bDisplayConfigValue = true;
                }
            }
            else
            {
                if (CurrentConfigValue == OverrideCurrentValue)
                {
                    bDisplayConfigValue = true;
                }
                else
                {
                    CurrentStringValue = OverrideCurrentValue;
                }
            }

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField(new GUIContent(StringLabel, StringLabel), GUILayout.MaxWidth(100.0f));

            EditorGUILayout.BeginHorizontal();

            string DisplayString = bDisplayConfigValue ? CurrentConfigValue : CurrentStringValue;

            GUIStyle TextFieldStyle = new GUIStyle(GUI.skin.textField);

            if (!bDisplayConfigValue)
            {
                TextFieldStyle.normal.background  = GetTextFieldBGGreenNormal();
                TextFieldStyle.focused.background = GetTextFieldBGGreenActive();
            }

            string NewStringValue = GUILayout.TextField(DisplayString, TextFieldStyle, GUILayout.ExpandWidth(true), GUILayout.MinWidth(100.0f));

            if (!NewStringValue.Contains("\"") && !(NewStringValue.Length == 1 && NewStringValue[0] == ' '))
            {
                CurrentStringValue = NewStringValue;
            }

            if (bDisplayConfigValue && CurrentStringValue == CurrentConfigValue)
            {
                CurrentStringValue = "";
            }

            GUIStyle ButtonStyle = new GUIStyle(GUI.skin.button);

            ButtonStyle.border = new RectOffset();
            ButtonStyle.margin = new RectOffset();

            if (GUILayout.Button(new GUIContent("<-", "Use the config value"), ButtonStyle, GUILayout.Width(25.0f)))
            {
                CurrentStringValue = "";
            }

            if (GUILayout.Button(new GUIContent("->", "Update the config value to the current value (This will change all other jobs that haven't overridden this value!)"), ButtonStyle, GUILayout.Width(25.0f)))
            {
                if (!bDisplayConfigValue)
                {
                    CurrentConfigValue = CurrentStringValue;
                }

                IgorConfig.SetModuleString(this, ConfigKey, CurrentConfigValue);
            }

            string ConfigLabel = CurrentConfigValue + " - From Global Config Key: " + GetModuleName() + "." + ConfigKey;
//			string ConfigLabel = "Global Config: \"" + CurrentConfigValue + "\" from Key: \"" + GetModuleName() + "." + ConfigKey + "\"";

            GUIStyle LabelFieldStyle = new GUIStyle(GUI.skin.label);

            LabelFieldStyle.alignment     = TextAnchor.MiddleLeft;
            LabelFieldStyle.border        = new RectOffset();
            LabelFieldStyle.contentOffset = new Vector2();
            LabelFieldStyle.margin        = new RectOffset();

            if (bDisplayConfigValue)
            {
                LabelFieldStyle.normal.background = GetLabelFieldBGGreen();
            }

            GUILayout.Label(new GUIContent(ConfigLabel, ConfigLabel), LabelFieldStyle, GUILayout.MinWidth(20.0f));

            if (GUILayout.Button(new GUIContent("X", "Clear the config value (This will change all other jobs that haven't overridden this value!)"), ButtonStyle, GUILayout.Width(25.0f)))
            {
                CurrentConfigValue = "";

                IgorConfig.SetModuleString(this, ConfigKey, CurrentConfigValue);
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndHorizontal();

            CurrentParams = IgorRuntimeUtils.SetStringParam(CurrentParams, StringOverrideParam, CurrentStringValue);
        }