Example #1
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Capture the MultiLanugageText Reference we found earlier
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    private static void CaptureMultiTextObject(GameManager rGameManager, GameManager.SystemLanguages eChosenLanguage, ref MultiLanguageTextList[] alMultiLanguageTextItems, MultiLanguageText a_rMultiTextObject, int a_iCurrentSceneID, Component a_parent, MultiLanguageTextReceiveMode eMultiLanguageTextReceiveMode, string a_variableName, string appendedName = "")
    {
        if (eMultiLanguageTextReceiveMode == MultiLanguageTextReceiveMode.BLANK_ONLY)
        {
            if (a_rMultiTextObject.m_arLanguageText[(int)eChosenLanguage].text != "")
            {
                return;
            }
        }
        else if (eMultiLanguageTextReceiveMode == MultiLanguageTextReceiveMode.FILLED_ONLY)
        {
            if (a_rMultiTextObject.m_arLanguageText[(int)eChosenLanguage].text == "")
            {
                return;
            }
        }

        MultiLanguageTextInstanceInfo mlti = new MultiLanguageTextInstanceInfo();

        mlti.rInstance     = a_rMultiTextObject;
        mlti.rOwningParent = a_parent;

        Transform trans = a_parent.transform;

        mlti.sDisplayLabel = a_parent.name + "\\" + a_variableName + appendedName;
        while (trans != rGameManager.m_agoRootParentsOfMultiLanguageTextComponents[a_iCurrentSceneID].transform)
        {
            mlti.sDisplayLabel = trans.name + "\\" + mlti.sDisplayLabel;
            trans = trans.parent;
        }

        if (!alMultiLanguageTextItems[a_iCurrentSceneID].Contains(mlti))
        {
            alMultiLanguageTextItems[a_iCurrentSceneID].AddLast(mlti);
        }
    }
Example #2
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Check Variables INSIDE of a Class/Struct/Interface
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    private static void CheckInnerDeclarations(GameManager rGameManager, GameManager.SystemLanguages eChosenLanguage, ref MultiLanguageTextList[] alMultiLanguageTextItems, FieldInfo a_declaration, int a_iCurrentSceneID, Component a_parent, object a_ContainingType, MultiLanguageTextReceiveMode eMultiLanguageTextReceiveMode, BindingFlags a_flags)
    {
        if (a_declaration.FieldType.IsArray)
        {
            object[] data = a_ContainingType.GetType().GetField(a_declaration.Name).GetValue(a_ContainingType) as object[];
            if (data != null)
            {
                for (int j = 0; j < data.Length; ++j)
                {
                    if (data[j] != null)
                    {
                        FieldInfo[] arrayFields = data[j].GetType().GetFields(a_flags);
                        foreach (FieldInfo info in arrayFields)
                        {
                            CheckVariable(rGameManager, eChosenLanguage, ref alMultiLanguageTextItems, info, a_iCurrentSceneID, a_parent, data[j], eMultiLanguageTextReceiveMode, a_flags, ((j + 1) < 100 ? "0" : "") + ((j + 1) < 10 ? "0" : "") + (j + 1).ToString());
                        }
                    }
                }
                return;
            }
        }

        // Check Fields
        FieldInfo[] fields = a_declaration.GetType().GetFields(a_flags);
        foreach (FieldInfo variable in fields)
        {
            CheckVariable(rGameManager, eChosenLanguage, ref alMultiLanguageTextItems, variable, a_iCurrentSceneID, a_parent, a_ContainingType, eMultiLanguageTextReceiveMode, a_flags);
        }
    }
Example #3
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Check Variable for Valid MultiLanguageText Reference
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    private static void CheckVariable(GameManager rGameManager, GameManager.SystemLanguages eChosenLanguage, ref MultiLanguageTextList[] alMultiLanguageTextItems, FieldInfo a_variable, int a_iCurrentSceneID, Component a_parent, object a_ContainingType, MultiLanguageTextReceiveMode eMultiLanguageTextReceiveMode, BindingFlags a_flags, string appendedName = "")
    {
        FieldInfo currentField = a_ContainingType.GetType().GetField(a_variable.Name);

        if (currentField == null)
        {
            return;
        }
        object currentObject = currentField.GetValue(a_ContainingType);


        if (a_variable.FieldType == typeof(MultiLanguageText))
        {
            CaptureMultiTextObject(rGameManager, eChosenLanguage, ref alMultiLanguageTextItems, currentObject as MultiLanguageText, a_iCurrentSceneID, a_parent, eMultiLanguageTextReceiveMode, a_variable.Name, appendedName);
        }
        else if (a_variable.FieldType == typeof(MultiLanguageText[]))
        {
            MultiLanguageText[] aTextComponents = currentObject as MultiLanguageText[];
            for (int j = 0; j < aTextComponents.Length; ++j)
            {
                CaptureMultiTextObject(rGameManager, eChosenLanguage, ref alMultiLanguageTextItems, aTextComponents[j] as MultiLanguageText, a_iCurrentSceneID, a_parent, eMultiLanguageTextReceiveMode, a_variable.Name, appendedName);
            }
        }
        else
        {
            // Keep Searching through all declared objects... I want EVERY Multi-Laguage Component
            CheckInnerDeclarations(rGameManager, eChosenLanguage, ref alMultiLanguageTextItems, a_variable, a_iCurrentSceneID, a_parent, a_ContainingType, eMultiLanguageTextReceiveMode, a_flags);
        }
    }
Example #4
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* New Method: Scan for Multi-Language Text Components
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    public static MultiLanguageTextList[] ScanForMultiLanguageTextComponents(GameManager rGameManager, GameManager.SystemLanguages eChosenLanguage, MultiLanguageTextReceiveMode eMultiLanguageTextReceiveMode)
    {
        // Declare Holders of Text Items - This is to sort them without having to use exspensive algorthms/RegularExpressions (Even though it doesn't matter so much in the CustomEditor classes).
        MultiLanguageTextList[] alMultiLanguageTextItems = new MultiLanguageTextList[rGameManager.m_agoRootParentsOfMultiLanguageTextComponents.Length];
        for (int i = 0; i < alMultiLanguageTextItems.Length; ++i)
        {
            alMultiLanguageTextItems[i] = new MultiLanguageTextList();
        }

        // Use #Reflection to identify Multi-Language Components found within script fields (i.e Variables) then capture those instances and use them here. Essentially compiling a database
        for (int i = 0; i < rGameManager.m_agoRootParentsOfMultiLanguageTextComponents.Length; ++i)
        {
            LinkedList <Transform> transformList = new LinkedList <Transform>();
            GetAllChildren(transformList, rGameManager.m_agoRootParentsOfMultiLanguageTextComponents[i].transform);
            const BindingFlags flags = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static;
            foreach (Transform obj in transformList)
            {
                foreach (Component component in obj.GetComponents <Component>())
                {
                    FieldInfo[] fields = component.GetType().GetFields(flags);
                    foreach (FieldInfo variable in fields)
                    {
                        CheckVariable(rGameManager, eChosenLanguage, ref alMultiLanguageTextItems, variable, i, component, component, eMultiLanguageTextReceiveMode, flags);
                    }
                }
            }
        }

        return(alMultiLanguageTextItems);
    }