コード例 #1
0
 public IVFSBuilder UseProfile(string profileName)
 {
     mProfileName = profileName;
     curProfile   = VFSManagerEditor.GetProfileRecord(profileName);
     mDevelopMode = XCoreEditor.IsXProfileDevelopMode(mProfileName);
     return(this);
 }
コード例 #2
0
 private void refreshProfileInfos()
 {
     if (curProfile == null)
     {
         curProfile = VFSManagerEditor.GetProfileRecord(XCoreEditor.GetCurrentActiveXProfileName());
     }
 }
コード例 #3
0
        //private Dictionary<string, WebVFSNetworkConfig.NetworkConfig> mDict_NetworkConfigs = new Dictionary<string, WebVFSNetworkConfig.NetworkConfig>();
        //private Dictionary<string, SerializedProperty> mDict_NetworkConfigs_SerializedProperty = new Dictionary<string, SerializedProperty>();

        private void OnEnable()
        {
            if (XCoreEditor.GetXProfileNames().Length == 0)
            {
                XCoreEditor.RefreshXProfile();
            }
            refreshXprofilesCacheData();

            if (param_toolbar_index != null && param_toolbar_index.Value < toolbar_str.Length)
            {
                mToolbar_Index      = param_toolbar_index.Value;
                param_toolbar_index = null;
            }
        }
コード例 #4
0
        void refreshXprofilesCacheData()
        {
            xprofiles = XCoreEditor.GetXProfileNames();
            //get cur index
            int    cur_index = 0;
            string cur_name  = XCoreEditor.GetCurrentActiveXProfileName();

            for (var i = 0; i < xprofiles.Length; i++)
            {
                if (xprofiles[i] == cur_name)
                {
                    cur_index = i;
                    break;
                }
            }
            select_xprofile = cur_index;
        }
コード例 #5
0
        /// <summary>
        /// 初始值
        /// </summary>
        private static void initProfileRecord()
        {
            if (VFSProfileEditor == null)
            {
                VFSProfileEditor = new VFSProfileModel();
            }
            var profiles = XCoreEditor.GetXProfileNames();

            foreach (var profileName in profiles)
            {
                if (!VFSProfileEditor.TryGetProfille(profileName, out var pr))
                {
                    var profile = new ProfileRecord()
                                  .SetProfileName(profileName)
                                  .DefaultByGrousp(Groups);
                    VFSProfileEditor.AddProfileIfNotExists(profile);
                }
            }
        }
コード例 #6
0
        private void OnGUI()
        {
            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal(style_head);
            GUILayout.Label("Profile:", GUILayout.Width(55));


            if (xprofiles == null || (select_xprofile - 1) > xprofiles.Length)
            {
                refreshXprofilesCacheData();
            }

            select_xprofile = EditorGUILayout.Popup(select_xprofile, xprofiles);
            GUILayout.EndHorizontal();

            //数据
            string cur_xprofile_name = xprofiles[select_xprofile];

            if (mCurProfileRecord == null || xprofiles[select_xprofile] != mCurProfileRecord.ProfileName)
            {
                mCurProfileRecord = VFSManagerEditor.GetProfileRecord(xprofiles[select_xprofile]);
                addConfiguredValueToCache();
            }

            // 工具栏
            GUILayout.Space(5);
            mToolbar_Index = GUILayout.Toolbar(mToolbar_Index, toolbar_str);

            if (mToolbar_Index == 0)
            {
                #region Group列表

                GUILayout.BeginVertical(style_body);
                v2_body_groups_scrollview = EditorGUILayout.BeginScrollView(v2_body_groups_scrollview);


                //表头
                EditorGUILayout.BeginHorizontal();
                GUILayout.Label("Group", GUILayout.Width(165));
                GUILayout.Label("|", GUILayout.Width(10));
                GUILayout.Label(IsChinese ? "资源存储位置" : "Assets Storage Location", GUILayout.Width(150));
                GUILayout.Label("|", GUILayout.Width(10));
                GUILayout.Label("Disable", GUILayout.Width(50));

                EditorGUILayout.EndHorizontal();


                if (groups == null)
                {
                    groups = VFSManagerEditor.GetGroups();
                    //groupNames = VFSManagerEditor.GetGroupNames();
                }

                foreach (var group in groups)
                {
                    GUILayout.BeginHorizontal();
                    //GroupName
                    GUILayout.Label(group.GroupName, style_txt_group_item, GUILayout.Width(170));
                    GUILayout.Space(5);
                    //资源存储位置
                    GroupHandleMode handleMode = group.HandleMode;


                    if (handleMode == GroupHandleMode.LocalAndUpdatable || handleMode == GroupHandleMode.LocalOrRemote)
                    {
                        //可以主动设置资源位置
                        if (!assetLocation_cache.ContainsKey(cur_xprofile_name))
                        {
                            assetLocation_cache.Add(cur_xprofile_name, new Dictionary <string, ProfileRecord.E_GroupAssetsLocation>());
                        }

                        if (!assetLocation_cache[cur_xprofile_name].ContainsKey(group.GroupName))
                        {
                            assetLocation_cache[cur_xprofile_name].Add(group.GroupName, ProfileRecord.E_GroupAssetsLocation.Local);
                        }

                        assetLocation_cache[cur_xprofile_name][group.GroupName] = (ProfileRecord.E_GroupAssetsLocation)EditorGUILayout.EnumPopup(assetLocation_cache[cur_xprofile_name][group.GroupName], GUILayout.Width(150));

                        GUILayout.Space(2);
                    }
                    else
                    {
                        //写死资源位置
                        if (handleMode == GroupHandleMode.LocalOnly)
                        {
                            setAssetLocationCacheValue(cur_xprofile_name, group.GroupName, ProfileRecord.E_GroupAssetsLocation.Local);
                            GUILayout.Label($"[{ProfileRecord.E_GroupAssetsLocation.Local.ToString()}]", GUILayout.Width(150));
                        }
                        else if (handleMode == GroupHandleMode.RemoteOnly)
                        {
                            setAssetLocationCacheValue(cur_xprofile_name, group.GroupName, ProfileRecord.E_GroupAssetsLocation.Remote);
                            GUILayout.Label($"[{ProfileRecord.E_GroupAssetsLocation.Remote.ToString()}]", GUILayout.Width(150));
                        }
                    }

                    GUILayout.Space(10);
                    //Disable
                    if (group.ExtensionGroup)
                    {
                        //可以主动设置group disable
                        if (!disable_expansionGroup_cache.ContainsKey(cur_xprofile_name))
                        {
                            disable_expansionGroup_cache.Add(cur_xprofile_name, new Dictionary <string, bool>());
                        }

                        if (!disable_expansionGroup_cache[cur_xprofile_name].ContainsKey(group.GroupName))
                        {
                            disable_expansionGroup_cache[cur_xprofile_name].Add(group.GroupName, false);
                        }
                        GUILayout.Space(10);
                        disable_expansionGroup_cache[cur_xprofile_name][group.GroupName] = EditorGUILayout.Toggle(disable_expansionGroup_cache[cur_xprofile_name][group.GroupName], GUILayout.Width(50));
                    }
                    else
                    {
                        GUILayout.Label("[-]", style_label_center, GUILayout.Width(36));
                        setGroupDisableCacheValue(cur_xprofile_name, group.GroupName, false);
                    }

                    GUILayout.EndHorizontal();
                }



                EditorGUILayout.EndScrollView();



                GUILayout.EndVertical();
                #endregion
            }
            else if (mToolbar_Index == 1)
            {
                #region WebVFS URLs

                if (mWebVFS_Net_Config == null)
                {
                    mWebVFS_Net_Config = XConfig.CreateConfigIfNotExists <WebVFSNetworkConfig>(TinaX.VFSKit.Const.VFSConst.Config_WebVFS_URLs);
                }
                if (mWebVFS_Net_Config_serialized == null)
                {
                    mWebVFS_Net_Config_serialized = new SerializedObject(mWebVFS_Net_Config);
                }
                if (mCur_WebVFS_profileNmae == null || mCur_WebVFS_profileNmae != cur_xprofile_name)
                {
                    if (mWebVFS_Net_Config.Configs == null || !mWebVFS_Net_Config.Configs.Any(item => item.ProfileName == cur_xprofile_name))
                    {
                        ArrayUtil.Combine(ref mWebVFS_Net_Config.Configs, new WebVFSNetworkConfig.NetworkConfig[] {
                            new WebVFSNetworkConfig.NetworkConfig()
                            {
                                ProfileName = cur_xprofile_name
                            }
                        });
                        mWebVFS_Net_Config_serialized.UpdateIfRequiredOrScript();
                    }
                    for (int i = 0; i < mWebVFS_Net_Config.Configs.Length; i++)
                    {
                        if (mWebVFS_Net_Config.Configs[i].ProfileName == cur_xprofile_name)
                        {
                            mCur_ProfileIndex_InWebVFS = i;
                        }
                    }
                    SerializedProperty cur_config = mWebVFS_Net_Config_serialized.FindProperty("Configs").GetArrayElementAtIndex(mCur_ProfileIndex_InWebVFS);
                    SerializedProperty cur_urls   = cur_config.FindPropertyRelative("Urls");

                    reorderableList_urls = new ReorderableList(
                        mWebVFS_Net_Config_serialized,
                        cur_urls,
                        true,
                        true,
                        true,
                        true);
                    reorderableList_urls.drawElementCallback = (rect, index, selected, focused) =>
                    {
                        SerializedProperty itemData = reorderableList_urls.serializedProperty.GetArrayElementAtIndex(index);
                        SerializedProperty mode     = itemData.FindPropertyRelative("NetworkMode");
                        SerializedProperty url      = itemData.FindPropertyRelative("BaseUrl");
                        SerializedProperty helloUrl = itemData.FindPropertyRelative("HelloUrl");

                        rect.y     += 2;
                        rect.height = EditorGUIUtility.singleLineHeight * 1;

                        var rect_mode = rect;
                        EditorGUI.PropertyField(rect_mode, mode, new GUIContent(IsChinese ? "网络模式" : "Network Mode"));
                        //--------------------------------------------------------------------------------------------
                        var rect_url_label = rect;
                        rect_url_label.y    += EditorGUIUtility.singleLineHeight + 2;
                        rect_url_label.width = 58;
                        GUI.Label(rect_url_label, IsChinese ? "基础Url" : "Base Url");

                        var rect_url = rect;
                        rect_url.y     += EditorGUIUtility.singleLineHeight + 2;
                        rect_url.width -= 62;
                        rect_url.x     += 62;
                        EditorGUI.PropertyField(rect_url, url, GUIContent.none);
                        //---------------------------------------------------------------------------------------------------

                        var rect_hellourl_label = rect;
                        rect_hellourl_label.y    += EditorGUIUtility.singleLineHeight * 2 + 4;
                        rect_hellourl_label.width = 58;
                        GUI.Label(rect_hellourl_label, IsChinese ? "HelloUrl" : "Hello Url");

                        var rect_helloUrl = rect;
                        rect_helloUrl.y     += EditorGUIUtility.singleLineHeight * 2 + 4;
                        rect_helloUrl.width -= 62;
                        rect_helloUrl.x     += 62;
                        EditorGUI.PropertyField(rect_helloUrl, helloUrl, GUIContent.none);
                    };
                    reorderableList_urls.elementHeightCallback = (index) =>
                    {
                        return(EditorGUIUtility.singleLineHeight * 3 + 10);
                    };
                    reorderableList_urls.drawHeaderCallback = (rect) =>
                    {
                        GUI.Label(rect, IsChinese?"Web Urls":"Web Urls");
                    };

                    mCur_WebVFS_profileNmae = cur_xprofile_name;
                }

                GUILayout.BeginVertical(style_body);
                v2_body_webvfs_scrollview = EditorGUILayout.BeginScrollView(v2_body_webvfs_scrollview);

                reorderableList_urls.DoLayoutList();
                //EditorGUILayout.PropertyField(cur_urls);

                EditorGUILayout.EndScrollView();

                GUILayout.EndVertical();
                #endregion
            }

            #region 保存和重置值的两个按钮
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            //包存cache的值
            if (GUILayout.Button(IsChinese ? "保存设置" : "Save", GUILayout.Width(100)))
            {
                #region Group Profile
                foreach (var item in assetLocation_cache)
                {
                    //item.key: profile,
                    var profile = VFSManagerEditor.GetProfileRecord(item.Key); //因为获取到的是class,所以直接修改它就行了
                    //item.value 是一个字典,key = groupName, value = value
                    foreach (var item2 in item.Value)
                    {
                        //接下来要在结构体上操作了,所以不能拉过来操作了,只能找到下标之后直接去修改
                        if (!profile.GroupProfileRecords.Any(gpr => gpr.GroupName == item2.Key))
                        {
                            ArrayUtil.Combine(ref profile.GroupProfileRecords, new ProfileRecord.S_GroupProfileRecord[]
                            {
                                new ProfileRecord.S_GroupProfileRecord()
                                {
                                    GroupName = item2.Key,
                                }
                            });
                        }

                        for (var i = 0; i < profile.GroupProfileRecords.Length; i++)
                        {
                            if (profile.GroupProfileRecords[i].GroupName == item2.Key)
                            {
                                profile.GroupProfileRecords[i].Location = item2.Value;
                                break;
                            }
                        }
                    }

                    VFSManagerEditor.AddProfileIfNotExists(profile);
                }

                foreach (var item in disable_expansionGroup_cache)
                {
                    //item.key: profile,
                    var profile = VFSManagerEditor.GetProfileRecord(item.Key); //因为获取到的是class,所以直接修改它就行了
                    //item.value 是一个字典,key = groupName, value = value
                    foreach (var item2 in item.Value)
                    {
                        //接下来要在结构体上操作了,所以不能拉过来操作了,只能找到下标之后直接去修改
                        if (!profile.GroupProfileRecords.Any(gpr => gpr.GroupName == item2.Key))
                        {
                            ArrayUtil.Combine(ref profile.GroupProfileRecords, new ProfileRecord.S_GroupProfileRecord[]
                            {
                                new ProfileRecord.S_GroupProfileRecord()
                                {
                                    GroupName = item2.Key,
                                }
                            });
                        }

                        for (var i = 0; i < profile.GroupProfileRecords.Length; i++)
                        {
                            if (profile.GroupProfileRecords[i].GroupName == item2.Key)
                            {
                                profile.GroupProfileRecords[i].DisableGroup = item2.Value;
                                break;
                            }
                        }
                    }

                    VFSManagerEditor.AddProfileIfNotExists(profile);
                }

                //foreach (var item in developMode_cache)
                //{
                //    //item.key: profile,
                //    var profile = VFSManagerEditor.GetProfileRecord(item.Key); //因为获取到的是class,所以直接修改它就行了
                //    //item.value 是 是否为开发模式的value
                //    profile.DevelopMode = item.Value;
                //    VFSManagerEditor.AddProfileIfNotExists(profile);
                //}


                //通知VFSManager保存到disk
                VFSManagerEditor.SaveProfileRecord();
                #endregion

                #region WebVFS URL
                mWebVFS_Net_Config_serialized?.ApplyModifiedPropertiesWithoutUndo();
                //删掉可能多余的内容
                string[] profiles = XCoreEditor.GetXProfileNames();
                if (mWebVFS_Net_Config.Configs != null && mWebVFS_Net_Config.Configs.Length > 0)
                {
                    List <WebVFSNetworkConfig.NetworkConfig> list_temp = new List <WebVFSNetworkConfig.NetworkConfig>(mWebVFS_Net_Config.Configs);
                    for (var i = list_temp.Count - 1; i >= 0; i--)
                    {
                        if (!profiles.Contains(list_temp[i].ProfileName))
                        {
                            list_temp.RemoveAt(i);
                        }
                    }
                    if (list_temp.Count != mWebVFS_Net_Config.Configs.Length)
                    {
                        mWebVFS_Net_Config.Configs = list_temp.ToArray();
                    }
                }

                AssetDatabase.SaveAssets();
                #endregion
            }

            //重置cache的已记录值
            if (GUILayout.Button(IsChinese ? "重置设置" : "Reset modify", GUILayout.Width(100)))
            {
                assetLocation_cache?.Clear();
                disable_expansionGroup_cache?.Clear();
                addConfiguredValueToCache();
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            #endregion
            GUILayout.Space(5);

            GUILayout.EndVertical();
        }
コード例 #7
0
ファイル: CoreSetting.cs プロジェクト: hyloong/TinaX.Core
        public static SettingsProvider CoreSettingPage()
        {
            return(new SettingsProvider(XEditorConst.ProjectSetting_CorePath, SettingsScope.Project, new string[] { "Nekonya", "TinaX", "Core", "TinaX.Core" })
            {
                label = "X Core",
                activateHandler = (searchContent, uielementRoot) =>
                {
                    XCoreEditor.RefreshXProfile();
                },
                guiHandler = (searchContent) =>
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.Space();

                    #region TinaX Profile
                    GUILayout.Label("TinaX Profile", style_txt_h2);
                    GUILayout.Space(2);

                    GUILayout.BeginHorizontal();
                    if (xprofiles == null)
                    {
                        refreshXprofilesCacheData();
                    }

                    GUILayout.Label(i18n_label_cur_active_profile, GUILayout.MaxWidth(140));
                    select_xprofile = EditorGUILayout.Popup(select_xprofile, xprofiles, GUILayout.MaxWidth(290));

                    if (xprofiles[select_xprofile] != XCoreEditor.GetCurrentActiveXProfileName())
                    {
                        if (GUILayout.Button(i18n_btn_switch_active_profile, GUILayout.MaxWidth(80)))
                        {
                            if (!XCoreEditor.SetActiveXProfile(xprofiles[select_xprofile]))
                            {
                                EditorUtility.DisplayDialog("Error", "Set active profile failed, please check the details in the console", "Okey");
                            }
                        }
                    }
                    GUILayout.EndHorizontal();

                    #region 是否为开发模式
                    //数据
                    if (cached_developMode_profile.IsNullOrEmpty() || cache_isDevelopMode == null || cached_developMode_profile != xprofiles[select_xprofile])
                    {
                        cache_isDevelopMode = XCoreEditor.IsXProfileDevelopMode(xprofiles[select_xprofile]);
                        cached_developMode_profile = xprofiles[select_xprofile];
                    }
                    GUILayout.Space(5);
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(IsChinese ? "开发模式:" : "Develop Mode : ", GUILayout.Width(80));
                    GUILayout.Label(cache_isDevelopMode.Value ? (IsChinese ? "[已启用]" : "[Enabled]") : (IsChinese ? "[未启用]" : "[Disabled]"), (cache_isDevelopMode.Value ? style_txt_warning : style_txt_blue), GUILayout.Width(50));
                    if (GUILayout.Button(cache_isDevelopMode.Value ? (IsChinese ? "关闭" : "Disable") : (IsChinese ? "启用" : "Enable"), GUILayout.Width(50)))
                    {
                        XCoreEditor.SetXProfileDevelopMode(xprofiles[select_xprofile], !cache_isDevelopMode.Value);
                        cache_isDevelopMode = null;
                        cached_developMode_profile = string.Empty;
                        XCoreEditor.SaveXProfiles();
                    }
                    GUILayout.EndHorizontal();

                    #endregion

                    b_flodout_show_xprofiles_detail = EditorGUILayout.Foldout(b_flodout_show_xprofiles_detail, i18n_profiles_detail);
                    if (b_flodout_show_xprofiles_detail)
                    {
                        //列表
                        if (xprofiles != null && xprofiles.Length > 0)
                        {
                            int length = xprofiles.Length;
                            foreach (var name in xprofiles)
                            {
                                GUILayout.BeginHorizontal();
                                GUILayout.Label(name, style_txt_profile_item, GUILayout.MaxWidth(260));
                                if (length > 1)
                                {
                                    if (XCoreEditor.GetCurrentActiveXProfileName() == name)
                                    {
                                        GUILayout.Button("[Active]", style_txt_active, GUILayout.Width(50));
                                    }
                                    else
                                    {
                                        if (GUILayout.Button(i18n_profiles_detail_remove, GUILayout.Width(50)))
                                        {
                                            XCoreEditor.RemoveXProfile(name);
                                            refreshXprofilesCacheData();

                                            break;
                                        }
                                    }
                                }
                                GUILayout.EndHorizontal();
                            }
                        }

                        //添加
                        EditorGUILayout.Space();
                        //EditorGUIUtil.HorizontalLine();
                        EditorGUILayout.Space();
                        EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField(i18n_profiles_detail_label_new, GUILayout.Width(126));
                        input_new_profile_name = EditorGUILayout.TextArea(input_new_profile_name, GUILayout.Width(220));
                        if (GUILayout.Button(i18n_profiles_detail_create, GUILayout.Width(50)))
                        {
                            if (input_new_profile_name.IsNullOrEmpty() || input_new_profile_name.IsNullOrWhiteSpace())
                            {
                                return;
                            }
                            //查重判断
                            if (xprofiles.Any(p => p.ToLower() == input_new_profile_name.ToLower()))
                            {
                                EditorUtility.DisplayDialog("Error", string.Format(i18n_profiles_detail_create_same_name, input_new_profile_name), "Okey");
                                return;
                            }
                            if (!XCoreEditor.AddXProfile(input_new_profile_name))
                            {
                                EditorUtility.DisplayDialog("Error", "Create profile failed, please check the details in the console", "Okey");
                            }
                            else
                            {
                                input_new_profile_name = string.Empty;
                                XCoreEditor.SaveXProfiles();
                                xprofiles = XCoreEditor.GetXProfileNames();
                            }
                        }
                        EditorGUILayout.EndHorizontal();

                        GUILayout.Space(8);
                        EditorGUIUtil.HorizontalLine();
                    }
                    #endregion
                },
                deactivateHandler = () =>
                {
                    XCoreEditor.SaveXProfiles();
                }
            });
        }