Beispiel #1
0
    public static string ToLongRegionalString(this DateTime date)
    {
        GeoRegion region = CloudUser.instance.region;

        int pattern = 8000012;

        switch (TextDatabase.GetLanguage())
        {
        case SystemLanguage.English:
            pattern = region == GeoRegion.Europe ? 8000000 : 8000001;
            break;

        case SystemLanguage.German:
            pattern = 8000002;
            break;

        case SystemLanguage.French:
            pattern = region == GeoRegion.Europe ? 8000003 : 8000004;
            break;

        case SystemLanguage.Italian:
            pattern = 8000005;
            break;

        case SystemLanguage.Spanish:
            pattern = region == GeoRegion.Europe ? 8000006 : 8000007;
            break;

        case SystemLanguage.Russian:
            pattern = 8000008;
            break;

        case SystemLanguage.Japanese:
            pattern = 8000009;
            break;

        case SystemLanguage.Chinese:
            pattern = 8000010;
            break;

        case SystemLanguage.Korean:
            pattern = 8000011;
            break;

        default:
            break;
        }

        return(date.ToString(TextDatabase.instance[pattern]));
    }
Beispiel #2
0
    public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
    {
        if (m_IconValid == null)
        {
            m_IconValid = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/!MFCommon/Editor Resources/accept.png", typeof(Texture2D));
        }
        if (m_IconInvalid == null)
        {
            m_IconInvalid = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/!MFCommon/Editor Resources/cross.png", typeof(Texture2D));
        }

        float height = base.GetPropertyHeight(prop, label);

        pos.height = height;

        EditorGUI.BeginProperty(pos, label, prop);

        // text id
        pos.width -= height;
        EditorGUI.BeginChangeCheck();
        int value = EditorGUI.IntField(pos, label, prop.intValue);

        if (EditorGUI.EndChangeCheck() == true)
        {
            prop.intValue = value;
        }
        if (prop.hasMultipleDifferentValues == false && prop.intValue != 0)
        {
            GUIStyle style = new GUIStyle();
            style.fixedHeight       = height;
            style.fixedWidth        = height;
            style.normal.background = TextDatabase.Contains(prop.intValue) ? m_IconValid : m_IconInvalid;
            EditorGUI.LabelField(new Rect(pos.x + pos.width - height, pos.y, height, height), GUIContent.none, style);
        }
        pos.width += height;

        pos.width -= 4;

        // text preview
        pos.y += height;
        EditorGUI.BeginDisabledGroup(true);
        pos = EditorGUI.PrefixLabel(pos, -1, new GUIContent("Text Dyn"));
        if (prop.hasMultipleDifferentValues == false && prop.intValue != 0 && TextDatabase.Contains(prop.intValue))
        {
            GUI.TextField(pos, TextDatabase.instance[prop.intValue], EditorStyles.textField);
        }
        EditorGUI.EndDisabledGroup();

        // language selector
        pos.x     -= 16;
        pos.y     += height;
        pos.width += 16;
        pos.width *= 0.5f;
        EditorGUI.BeginChangeCheck();
        EditorGUI.showMixedValue = false;
        int idx = System.Array.IndexOf(GuiOptions.convertLanguageToSysLanguage, TextDatabase.GetLanguage());

        GuiOptions.E_Language language = idx != -1 ? (GuiOptions.E_Language)idx : GuiOptions.E_Language.English;
        language = (GuiOptions.E_Language)EditorGUI.EnumPopup(pos, language, EditorStyles.toolbarPopup);
        EditorGUI.showMixedValue = prop.hasMultipleDifferentValues;
        if (EditorGUI.EndChangeCheck() == true)
        {
            TextDatabase.SetLanguage(GuiOptions.convertLanguageToSysLanguage[(int)language]);
        }

        // reload button
        pos.x += pos.width;
        EditorGUI.BeginChangeCheck();
        bool reload = GUI.Toggle(pos, false, "Reload", EditorStyles.toolbarButton);

        if (EditorGUI.EndChangeCheck() == true && reload == true)
        {
            TextDatabase.instance.Reload();
        }

        EditorGUI.EndProperty();
    }