public override void OnInspectorGUI()
    {
        if (editorType == EditorType.SINGLE_ASSET)
        {
            localizedText.isExpandedGlobal = true;
        }

        // Update the state of the serializedObject to the current values of the target.
        serializedObject.Update();

        // Global GUI Box
        GUILayout.BeginVertical(GUI.skin.box);

        EditorColors.SET_SUBTITLE2_COLOR();
        GUILayout.BeginHorizontal(GUI.skin.box);
        GUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);

        GUIStyle myFoldoutStyle = new GUIStyle(EditorStyles.foldout);

        myFoldoutStyle.fontStyle    = FontStyle.Bold;
        myFoldoutStyle.fontSize     = 11;
        myFoldoutStyle.fixedHeight  = 16f;
        myFoldoutStyle.stretchWidth = true;

        // Global Foldout
        localizedText.isExpandedGlobal = EditorGUILayout.Foldout(localizedText.isExpandedGlobal, new GUIContent(localizedText.name), true, myFoldoutStyle);

        // Show remove button only in case that this LocalizedText belongs to one LocalizedTextsGroup
        if (editorType == EditorType.ALL_ASSETS)
        {
            // Display a button showing a '-' that if clicked removes this item from the group.
            if (EditorTools.createListButton(" - ", true))
            {
                removeLocalizedText();
                return;
            }
        }

        GUILayout.EndHorizontal();
        GUILayout.EndHorizontal();
        EditorColors.SET_DEFAULT_COLOR();

        if (localizedText.isExpandedGlobal)
        {
            expandedGUI();
        }

        GUILayout.EndVertical();

        // Push data back from the serializedObject to the target.
        serializedObject.ApplyModifiedProperties();
    }
Example #2
0
        private static void RenderView(MVCEditor editor)
        {
            EditorGUILayout.LabelField(
                "View Settings", CategoryLabelStyle
                );

            EditorGUILayout.Space();

            EditorColors.SetBackgroundColor(Color.green);
            {
                if (GUILayout.Button("Apply configuration"))
                {
                    if (Config.IsConfigValid())
                    {
                        ConfigSynchronizer.Sync(Config);
                    }
                }
            }
            EditorColors.ResetBackgroundColor();

            EditorGUILayout.HelpBox("Click the button above whenever you make changes in this area.", MessageType.Info);

            EditorGUILayout.Space();

            if (GUILayout.Button("Generate prefabs"))
            {
                if (Config.IsConfigValid() && !EditorApplication.isCompiling)
                {
                    MvcPrefabMaker.CreatePrefabs(editor.I, Config);
                }
            }

            EditorGUILayout.Space();

            WarningView.Render(editor, Config);

            EditorGUILayout.Space();

            ConfigViewLayout.Render(editor, Config);

            EditorGUILayout.Space();

            if (GUILayout.Button(isAdvancedViewSettings ? "Hide advanced settings" : "Show advnaced settings"))
            {
                isAdvancedViewSettings = !isAdvancedViewSettings;
            }
            if (isAdvancedViewSettings)
            {
                RenderAdvancedView(editor);
            }
        }
 private void setFoldoutDefaultColor(int index, ref GUIStyle myFoldoutStyle, ref string defaultText)
 {
     if (AllGameLanguages.Instance.gameLanguagesList[index].isDefault)
     {
         GUI.color = Color.yellow;
         myFoldoutStyle.fontStyle = FontStyle.Bold;
         defaultText = " [DEFAULT]";
     }
     else
     {
         EditorColors.SET_DEFAULT_COLOR();
         myFoldoutStyle.fontStyle = FontStyle.Normal;
         defaultText = "";
     }
 }
Example #4
0
        public static void createTitleBox(string title, bool subTitle = false)
        {
            if (subTitle)
            {
                EditorColors.SET_SUBTITLE_COLOR();
            }
            else
            {
                EditorColors.SET_MAINTITLE_COLOR();
            }

            GUILayout.BeginVertical(GUI.skin.box);

            EditorGUILayout.LabelField(title, EditorStyles.boldLabel);

            GUILayout.EndVertical();
            EditorColors.SET_DEFAULT_COLOR();
        }
    private void createGameLanguagesBoxes()
    {
        GUIStyle myFoldoutStyle = new GUIStyle(EditorStyles.foldout);
        string   defaultText    = "";

        for (int i = 0; i < allLanguages.gameLanguagesList.Count; i++)
        {
            setFoldoutDefaultColor(i, ref myFoldoutStyle, ref defaultText);

            EditorGUILayout.BeginVertical(GUI.skin.box);

            EditorGUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);

            isExpanded[i] = EditorGUILayout.Foldout(isExpanded[i], allLanguages.gameLanguagesList[i].gameLanguage.code + " - " + allLanguages.gameLanguagesList[i].gameLanguage.name + defaultText, true, myFoldoutStyle);

            EditorColors.SET_DEFAULT_COLOR();

            allLanguages.gameLanguagesList[i].isDefault = EditorGUILayout.Toggle(allLanguages.gameLanguagesList[i].isDefault, GUILayout.Width(30));

            if (allLanguages.gameLanguagesList[i].isDefault)
            {
                allLanguages.setDefaultLanguage(i);
            }

            CreateRemoveButton(i);

            EditorGUILayout.EndHorizontal();

            // If the foldout is open show the expanded GUI.
            if (isExpanded[i])
            {
                ExpandedGUI(allLanguages.gameLanguagesList[i]);
            }

            EditorGUILayout.EndVertical();
        }

        allLanguages.checkDefaultLanguage();
    }
    private void createISOLanguagesBox()
    {
        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.LabelField("ISO Languages", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);

        if (fileISOLanguages != null)
        {
            // Create the options for all iso languages stored in memory
            string[] isoLanguageOptions = new string[fileISOLanguages.Length];
            string   prefix             = "";

            // If the json items in the file are sorted by code, then they will be already sorted for popup submenus
            // so we can use the first char of the language code to order them.
            for (int i = 0; i < isoLanguageOptions.Length; i++)
            {
                prefix = fileISOLanguages[i].code[0] + "/";
                isoLanguageOptions[i] = prefix + fileISOLanguages[i].code + " - " + fileISOLanguages[i].name + " - " + fileISOLanguages[i].nativeName;
            }

            string label = "File Languages";
            EditorGUILayout.LabelField(label, GUILayout.Width((label.Length * 7)));
            ISOListSelectedIndex = EditorGUILayout.Popup(ISOListSelectedIndex, isoLanguageOptions);

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);

            EditorColors.SET_ADD_BUTTON_COLOR();
            if (GUILayout.Button(" Add Selected Language to Game ", GUILayout.ExpandWidth(true)))
            {
                AddLanguage(fileISOLanguages[ISOListSelectedIndex]);
            }
            EditorColors.SET_DEFAULT_COLOR();
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();
    }
Example #7
0
        private static void DrawViews(MVCEditor editor, MvcConfig config)
        {
            if (!IsShowingView)
            {
                return;
            }

            GUILayout.BeginVertical("GroupBox");

            for (int i = 0; i < config.Views.Count; i++)
            {
                if (ConfigViewEditorFlags.IsOpen[i])
                {
                    DrawOpenedView(editor, config, config.Views[i], i);
                }
                else
                {
                    DrawClosedView(editor, config, config.Views[i], i);
                }
            }

            EditorColors.SetBackgroundColor(Color.green);
            {
                if (GUILayout.Button("Create View"))
                {
                    config.Views.Add(new MvcConfig.View(config)
                    {
                        Name = "View" + config.Views.Count
                    });

                    ConfigViewEditorFlags.Setup(config);
                    ConfigViewEditorFlags.SetOpen(config.Views.Count - 1);
                    SetEdit(config.Views.GetLast());
                }
            }
            EditorColors.ResetBackgroundColor();

            GUILayout.EndVertical();
        }
Example #8
0
        public static bool createListButton(string title, bool removeButton = false, GUILayoutOption option = null)
        {
            if (removeButton)
            {
                EditorColors.SET_REMOVE_BUTTON_COLOR();
            }
            else
            {
                EditorColors.SET_ADD_BUTTON_COLOR();
            }

            if (option == null)
            {
                option = GUILayout.ExpandWidth(false);
            }

            bool pressed = GUILayout.Button(title, option);

            EditorColors.SET_DEFAULT_COLOR();

            return(pressed);
        }
    private void createLocalizedTextsListGUIBOXES()
    {
        EditorTools.createTitleBox("Localized Texts", true);

        GUIStyle myFoldoutStyle = new GUIStyle(EditorStyles.miniButton);
        string   defaultText    = "";

        myFoldoutStyle.fixedWidth = 35f;

        for (int i = 0; i < localizedText.localizedTextsList.Count; i++)
        {
            //AllGameLanguagesEditor.setFoldoutDefaultColor(i, ref myFoldoutStyle, ref defaultText);

            GUILayout.BeginVertical(GUI.skin.box);

            GUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);

            string LanguageKey = localizedText.localizedTextsList[i].languageInfo.code;

            // Handle foldut through isExpanded variable
            localizedText.isExpandedLocalText[i] = EditorGUILayout.Foldout(localizedText.isExpandedLocalText[i], new GUIContent(LanguageKey + defaultText), true, myFoldoutStyle);

            if (localizedText.localizedTextsList[i].getText() == "")
            {
                EditorGUILayout.LabelField(new GUIContent("Empty Text", EditorGUIUtility.IconContent("console.warnicon.sml").image), EditorStyles.boldLabel, GUILayout.ExpandWidth(false));
            }
            else
            {
                EditorGUILayout.LabelField(new GUIContent("OK", EditorGUIUtility.IconContent("Collab").image), EditorStyles.boldLabel, GUILayout.ExpandWidth(false));
            }

            GUILayout.EndHorizontal();

            EditorColors.SET_DEFAULT_COLOR();


            if (localizedText.isExpandedLocalText[i])
            {
                string lText = localizedText.localizedTextsList[i].getText();

                float minWidth, maxWidth;

                GUI.skin.label.CalcMinMaxWidth(new GUIContent(lText), out minWidth, out maxWidth);
                float currentViewWidth = EditorGUIUtility.currentViewWidth;

                int numLines = (int)Math.Round(maxWidth / currentViewWidth + 1) + lText.Split('\n').Length - 1;
                lText = EditorGUILayout.TextArea(lText, EditorStyles.textArea, GUILayout.Height(EditorGUIUtility.singleLineHeight * numLines));

                localizedText.localizedTextsList[i].setText(lText);

                GUILayout.Space(2.5f);
            }

            GUILayout.EndVertical();

            if (i != localizedText.localizedTextsList.Count - 1 &&
                editorType == EditorType.SINGLE_ASSET)
            {
                EditorTools.createHorizontalSeparator();
            }
        }
    }
Example #10
0
		private SettingsCategory CategoryFromDesignerFont(ORMDesignerColorCategory designerColorCategory)
		{
			SettingsCategory retVal = null;
			switch (designerColorCategory)
			{
				case ORMDesignerColorCategory.Editor:
					retVal = myEditorColors;
					if (retVal == null)
					{
						retVal = myEditorColors = new EditorColors(myServiceProvider);
					}
					break;
				case ORMDesignerColorCategory.Verbalizer:
					retVal = myVerbalizerColors;
					if (retVal == null)
					{
						retVal = myVerbalizerColors = new VerbalizerColors(myServiceProvider);
					}
					break;
			}
			Debug.Assert(retVal != null); // Unknown font
			return retVal;
		}
Example #11
0
        private static void DrawOpenedView(MVCEditor editor, MvcConfig config, MvcConfig.View view, int index)
        {
            GUILayout.BeginVertical("LightmapEditorSelectedHighlight");

            editingName = ViewNameTrim(
                EditorGUILayout.TextField("View name", editingName)
                );
            editingBaseClassName = EditorGUILayout.TextField("Custom base class", editingBaseClassName);
            editingLifeType      = (MvcLifeType)EditorGUILayout.EnumPopup("Custom lifecycle", editingLifeType);
            editingRescaleMode   = (MvcRescaleType)EditorGUILayout.EnumPopup("View rescale mode", editingRescaleMode);
            editingInitial       = EditorGUILayout.Toggle("Is initial view?", editingInitial);

            if (GUILayout.Button("Save & Close"))
            {
                if (ApplyEdit(config, view))
                {
                    ConfigViewEditorFlags.ResetFlags();
                }
            }

            EditorColors.SetBackgroundColor(Color.red);
            {
                if (GUILayout.Button("Danger Zone!"))
                {
                    ConfigViewEditorFlags.IsDeleteOpen ^= true;
                }
            }
            EditorColors.ResetBackgroundColor();

            if (ConfigViewEditorFlags.IsDeleteOpen)
            {
                GUILayout.BeginVertical("GroupBox");

                EditorGUILayout.HelpBox(
                    "It is highly recommended to apply configurations first before performing any actions here.",
                    MessageType.Warning
                    );

                // Red background for danger zone buttons
                EditorColors.SetBackgroundColor(Color.red);
                {
                    if (GUILayout.Button("Delete config"))
                    {
                        if (EditorDialog.OpenAlert(
                                "Delete view configuration.",
                                "Are you sure you want to delete this view's configuration? " + DeleteWarning,
                                "Yes", "No"))
                        {
                            // Remove view from views list.
                            MvcViewRemover.RemoveFromConfig(config.Views, index);
                            ConfigViewEditorFlags.Setup(config);
                            ConfigViewEditorFlags.ResetFlags();
                        }
                    }

                    // If loaded from resources, the user must've already created a prefab or at least scripts.
                    if (view.IsFromResources)
                    {
                        EditorGUILayout.Space();

                        if (GUILayout.Button("Delete prefab"))
                        {
                            // Confirm prefab deletion
                            if (EditorDialog.OpenAlert(
                                    "Delete view prefab",
                                    "Are you sure you want to delete this view's prefab? " + DeleteWarning,
                                    "Yes", "No"))
                            {
                                MvcViewRemover.RemovePrefab(view);
                            }
                        }

                        EditorGUILayout.Space();

                        if (GUILayout.Button("Delete all"))
                        {
                            // Confirm deletion of all view-related things
                            if (EditorDialog.OpenAlert(
                                    "Delete view config, scripts, prefab",
                                    "Are you sure you want to delete this view's config, scripts, and prefab?" + DeleteWarning,
                                    "Yes", "No"))
                            {
                                MvcViewRemover.RemoveFromConfig(config.Views, index);
                                MvcViewRemover.RemoveScripts(view);
                                MvcViewRemover.RemovePrefab(view);
                                MvcViewRemover.Finalize(config);

                                ConfigViewEditorFlags.Setup(config);
                                ConfigViewEditorFlags.ResetFlags();
                            }
                        }
                    }
                }
                EditorColors.ResetBackgroundColor();

                GUILayout.EndVertical();
            }

            GUILayout.EndVertical();
        }