Пример #1
0
        /// <summary>
        /// 给排行榜添加一个元素
        /// </summary>
        /// <param name="rankName">Rank name.</param>
        /// <param name="name">Name.</param>
        /// <param name="value">Value.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public void AddRankNode(string rankName, string name, object value)
        {
            L_RankData rankData = RootData.FindChild(rankName);

            if (rankData == null)
            {
                Debug.LogWarning("排行榜[" + rankName + "]尚未创建!"); return;
            }

            if (rankData.GetValue <string>() != value.GetType().ToString())
            {
                Debug.LogWarning("排行榜[" + rankName + "]数据类型[" + rankData.Value + "],与添加的数据[" + name + "]类型[" + value.GetType() + "]不一致!");
                return;
            }

            L_RankData data = rankData.FindChild(name);

            if (data == null)
            {
                data = rankData.CreatChildData(name, value);
            }
            else
            {
                data.Value = value;
            }
        }
        public void T004_InitRootData()
        {
            _RootVM = new RootVM();
            var data = new RootData {
                TestObject = new TestData {
                    Number = 1
                }, TestList = new List <TestData> {
                    new TestData {
                        Number = 2
                    }
                }
            };

            _RootVM.Data = data;
            _RootVM.TestList.Metadata.DataProvider.NotifyDataChanged();            //HACK

            Assert.AreEqual(1, data.TestObject.Number);
            Assert.AreEqual(1, data.TestList.Count);
            Assert.AreEqual(2, data.TestList[0].Number);

            Assert.IsNotNull(_RootVM.TestObject.Data);
            Assert.IsNotNull(_RootVM.TestList.MːData);

            Assert.AreEqual(1, _RootVM.TestObject.Number.Value);
            Assert.AreEqual(1, _RootVM.TestList.Count);
            Assert.AreEqual(2, _RootVM.TestList[0].Number.Value);
        }
Пример #3
0
 public void SetContSize(int arrsize, int MaxWid, RootData rda)
 {
     MaximumWid = MaxWid;
     if (_Child != null)
     {
         IModuleInterface imi = _Child.GetComponent <IModuleInterface>();
         imi.HeightAllowance = arrsize;
         int size = imi.DesiredWidth + arrsize;
         if (size < MaximumWid)
         {
             MaxWid = size;
         }
     }
     _ContRT.pivot         = new Vector2(0, 1);
     _ContRT.sizeDelta     = new Vector2(MaxWid - arrsize, arrsize);
     _ContRT.localPosition = new Vector3(arrsize, 0, 0);
     if (_Child != null)
     {
         RectTransform rt = _Child.GetComponent <RectTransform>();
         rt.pivot         = new Vector2(0, 1);
         rt.sizeDelta     = _ContRT.sizeDelta;
         rt.localPosition = new Vector3(arrsize, 0, 0);
         IModuleInterface imi = _Child.GetComponent <IModuleInterface>();
         imi.SizeEvent(_ContRT);
     }
     _Width = MaxWid;
 }
Пример #4
0
        // 获得数据节点
        public IDataNode GetRankData(string rankname, bool isOrder = true)
        {
            L_RankData rankData = RootData.FindChild(rankname);

            OrderRank(rankData, isOrder); // 排序
            return((IDataNode)rankData);
        }
Пример #5
0
 void Awake()
 {
     #region Check Root
     DropControl dc = this.GetComponent <DropControl>();
     if (dc == null)
     {
         rd                     = (RootData)gameObject.AddComponent <RootData>();
         rd.HiddenData          = HiddObj;
         rd.BaseDropPanelPrefab = BaseDropPanelPrefab;
         IsRoot                 = true;
         Folded                 = false;
         rd.ArrowAlpha          = ArrowAlpha;
     }
     else
     {
         dc.ArrowToggle += ArrowToggle;
         MyDropControl   = dc;
     }
     #endregion
     #region Initialize Prefab Dic
     if (IsRoot)
     {
         if (PrefabKeys.Count == PrefabReferences.Count)
         {
             for (int i = 0; i < PrefabKeys.Count; i++)
             {
                 rd.PrefabDic.Add(PrefabKeys[i], PrefabReferences[i]);
             }
         }
         rfmm = this;
         rd.HighlightColor = HighlightColor;
         InitializeRDA();
     }
     #endregion
 }
Пример #6
0
 /// <summary>
 /// Clears the data.
 /// </summary>
 public void ClearData(string name)
 {
     // 清理排行榜
     LoadRank(name);
     RootData.FindChild(name).ClearChildren();
     SaveTheRank(name);
 }
Пример #7
0
        static List <Voter> GetListOfVoters(Tps tps, string province = "")
        {
            WebClient client = new WebClient();
            string    url    = GetListOfPemilihUrl.Replace("{{tps}}", tps.tps);

            url = url.Replace("{{namapropinsi}}", tps.namaPropinsi);
            url = url.Replace("{{namakabupaten}}", tps.namaKabKota);
            url = url.Replace("{{namakecamatan}}", tps.namaKecamatan);
            url = url.Replace("{{namakelurahan}}", tps.namaKelurahan);

            string s = "";

            s = client.DownloadString(url);

            RootData rootData = JsonConvert.DeserializeObject <RootData>(s);

            s = JsonConvert.SerializeObject(rootData.data);

            List <Voter> voters = JsonConvert.DeserializeObject <List <Voter> >(s);

            if (province.Length > 0)
            {
                foreach (Voter voter in voters)
                {
                    voter.birthProvince = province;
                }
            }
            return(voters);
        }
Пример #8
0
 protected virtual void BuildToRootData()
 {
     RootData.Clear();
     foreach (var v_item in m_items)
     {
         RootData.AddItem(v_item.text);
     }
     _cachedItems = null;
 }
Пример #9
0
 public void UpdateChildSize(RootData rda)
 {
     if (_Child != null)
     {
         RectTransform art = ArrowObj.GetComponent <RectTransform>();
         int           wid = (int)art.sizeDelta.x;
         SetContSize(wid, MaximumWid, rda);
     }
 }
Пример #10
0
        public int IndexOf(GenericMenuElementData p_element)
        {
            if (_cachedItems == null)
            {
                _cachedItems = RootData.GetNonFolderElements();
            }

            return(_cachedItems.IndexOf(p_element));
        }
Пример #11
0
        /// <summary>
        /// 存储数据
        /// </summary>
        /// <param name="rankname">排行榜名.</param>
        /// <param name="isOrder">If set to <c>true</c> 正序/逆序.</param>
        public void SaveTheRank(string rankname, bool isOrder = true)
        {
            L_RankData rankData = RootData.FindChild(rankname);

            OrderRank(rankData, isOrder); // 排序
            if (rankData != null)
            {
                XmlTool.SaveData <L_RankData>(rankData, FilePath + rankname);
            }
        }
Пример #12
0
 public void MergeWith(IData data)
 {
     if (Root != this)
     {
         Root.MergeWith(data);
     }
     else
     {
         RootData.MergeWith(data);
     }
 }
Пример #13
0
        static List <Province> GetListOfProvince()
        {
            WebClient client = new WebClient();
            string    s      = client.DownloadString(GetListOfProvinceUrl);

            RootData rootData = JsonConvert.DeserializeObject <RootData>(s);

            s = JsonConvert.SerializeObject(rootData.aaData);

            List <Province> provinces = JsonConvert.DeserializeObject <List <Province> >(s);

            return(provinces);
        }
Пример #14
0
        /// <summary>
        /// 创建一个排行榜
        /// </summary>
        /// <param name="name">排行榜名字</param>
        /// <param name="value">排行榜的内容</param>
        /// <typeparam name="T">排行榜的类型</typeparam>
        public void CreateRank <T>(string rankname)
        {
            if (typeof(T) != typeof(int) && typeof(T) != typeof(float))
            {
                Debug.LogWarning("排行榜只支持Int 和 float 两种数据类型!"); return;
            }

            if (RootData.Exist(rankname))
            {
                Debug.LogWarning("当前排行榜已经存在!"); return;
            }
            L_RankData rankData = RootData.CreatChildData(rankname, typeof(T).ToString());
        }
        public HomeController(ILogger <HomeController> logger)
        {
            _logger = logger;

            logger.LogDebug(".LogDebug()");
            logger.LogTrace("LogTrace");
            RootData rootData = new RootData()
            {
                Code    = Guid.NewGuid().ToString(),
                Message = "这是你们的错误  我没有问题哦"
            };

            logger.LogInformation(Newtonsoft.Json.JsonConvert.SerializeObject(rootData));
        }
Пример #16
0
        static List <Kabupaten> GetListOfKabupaten(Province province)
        {
            WebClient client = new WebClient();
            string    url    = GetListOfKabupatenUrl.Replace("{{namapropinsi}}", province.namaWilayah.ToUpper());
            string    s      = client.DownloadString(url);

            RootData rootData = JsonConvert.DeserializeObject <RootData>(s);

            s = JsonConvert.SerializeObject(rootData.aaData);

            List <Kabupaten> kabupatens = JsonConvert.DeserializeObject <List <Kabupaten> >(s);

            return(kabupatens);
        }
Пример #17
0
        /// <summary>
        /// 加载排行榜(覆盖当前排行榜)
        /// </summary>
        /// <param name="rankname">Rankname.</param>
        /// <typeparam name="T">The 1st type parameter.</typeparam>
        public void LoadRank(string rankname)
        {
            // 覆盖
            L_RankData rankData = RootData.FindChild(rankname);

            if (rankData == null)
            {
                rankData = RootData.CreatChildData(rankname, "none");
            }
            else
            {
                rankData.ClearChildren();
            }
            XmlTool.LoadDataWihtPath <L_RankData>(ref rankData, FilePath + rankname);
        }
Пример #18
0
        public GenericMenuElementData GetCurrentSelectedItem()
        {
            if (_cachedItems == null)
            {
                _cachedItems = RootData.GetNonFolderElements();
            }

            //Clamp Values
            m_selectedIndex = Mathf.Clamp(m_selectedIndex, -1, m_items.Count - 1);
            if (m_selectedIndex >= 0 && m_selectedIndex < _cachedItems.Count)
            {
                var v_selectedElement = _cachedItems[m_selectedIndex];
                return(v_selectedElement);
            }
            return(null);
        }
Пример #19
0
        static List <Kecamatan> GetListOfKecamatan(Kabupaten kabupaten, string province = "")
        {
            WebClient client = new WebClient();
            string    url    = GetListOfKecamatanUrl.Replace("{{namakabupaten}}", kabupaten.namaKabKota);

            url = url.Replace("{{namapropinsi}}", kabupaten.namaPropinsi);
            string s = client.DownloadString(url);

            RootData rootData = JsonConvert.DeserializeObject <RootData>(s);

            s = JsonConvert.SerializeObject(rootData.aaData);

            List <Kecamatan> kecamatans = JsonConvert.DeserializeObject <List <Kecamatan> >(s);

            return(kecamatans);
        }
Пример #20
0
        public GenericMenuElementData GetCurrentSelectedFolder()
        {
            if (_cachedItems == null)
            {
                _cachedItems = RootData.GetNonFolderElements();
            }

            var v_folderElement = RootData.GetFolderAtPath(SelectedFolderPath);

            //Invalid Path
            if (!string.IsNullOrEmpty(SelectedFolderPath) && v_folderElement == null)
            {
                m_selectedFolderPath = "";
            }

            return(v_folderElement);
        }
Пример #21
0
        static List <Tps> GetListOfTps(Kelurahan kelurahan, string province = "")
        {
            WebClient client = new WebClient();
            string    url    = GetListOfTpsUrl.Replace("{{namakelurahan}}", kelurahan.namaKelurahan);

            url = url.Replace("{{namapropinsi}}", kelurahan.namaPropinsi);
            url = url.Replace("{{namakabupaten}}", kelurahan.namaKabKota);
            url = url.Replace("{{namakecamatan}}", kelurahan.namaKecamatan);
            string s = client.DownloadString(url);

            RootData rootData = JsonConvert.DeserializeObject <RootData>(s);

            s = JsonConvert.SerializeObject(rootData.aaData);

            List <Tps> tps = JsonConvert.DeserializeObject <List <Tps> >(s);

            return(tps);
        }
Пример #22
0
        protected GenericMenuElementData[] GetCurrentExpandedList()
        {
            if (_cachedItems == null)
            {
                _cachedItems = RootData.GetNonFolderElements();
            }

            GenericMenuElementData[] v_list   = null;
            GenericMenuElementData   v_parent = GetCurrentSelectedFolder();

            if (v_parent != null)
            {
                v_list = v_parent.GetChildren();
            }
            else
            {
                v_list = RootData.GetRootElements();
            }

            return(v_list);
        }
Пример #23
0
 public void Initialize(RootDataArgs rda)
 {
     rd        = rda.rd;
     rfmm      = rda.Root;
     ArrowSize = rda.ArrowSize;
     Parent    = rda.Prev;
     Indent    = rda.Indent;
     Padding   = rda.Padding;
     if (!Parent.IsRoot)
     {
         rda.MaxWidth -= rda.Indent;
     }
     MaxWidth = rda.MaxWidth;
     InitializeRDA();
     LayoutArrow();
     MyDropControl.MaximumWid = MaxWidth;
     if (IsRoot)
     {
         MyDropControl.MaximumWid -= (PaddingLftRgtTpBt[1] + PaddingLftRgtTpBt[3]);
     }
 }
Пример #24
0
        /// <summary>
        /// 基于节点信息获取对象
        /// </summary>
        /// <param name="rootTransform"></param>
        /// <param name="rootData"></param>
        /// <returns></returns>
        private Transform GetTransformByRootData(Transform rootTransform, RootData rootData)
        {
            Transform temp = rootTransform;

            if (isPriorityRootPosition)
            {
                temp = GetTransformByRootDataInNode(temp, rootData.Index);
                if (temp == null)
                {
                    temp = GetTransformByRootDataInName(temp, rootData.Name);
                }
            }
            else
            {
                temp = GetTransformByRootDataInName(temp, rootData.Name);
                if (temp == null)
                {
                    temp = GetTransformByRootDataInNode(temp, rootData.Index);
                }
            }

            return(temp);
        }
Пример #25
0
        public void BlockHelperRootAccess()
        {
            var source = "...{{testhandler 1}}...";

            var rootTestData = new RootData
            {
                Number = 17
            };

            Handlebars.RegisterHelper("testhandler", (writer, root, context, arguments) => {
                Assert.True(root == rootTestData);
                var rootData = root as RootData;

                writer.Write(int.Parse(arguments[0].ToString()) * rootData.GetTicksCounter());
            });

            var template = Handlebars.Compile(source);

            var output = template(rootTestData);

            Assert.StartsWith("...", output);
            Assert.EndsWith("...", output);
        }
Пример #26
0
 public void InstallChild(Transform Child, RootData rda)
 {
     _Child = Child;
     _Child.SetParent(this.transform, false);
     UpdateChildSize(rda);
 }
Пример #27
0
 public void InstallRD(RootData rda)
 {
     Panel.InstallRD(rda);
 }
Пример #28
0
 public static void CreateDataRoot(Core.Misc.Map data)
 {
     root = new RootData();
     root.FromJson(data);
 }
Пример #29
0
 public void SetSize(int value, RootData rd)
 {
     rt.pivot         = new Vector2(.5f, .5f);
     rt.localPosition = new Vector3(value / 2, -(value / 2), 0);
     rt.sizeDelta     = new Vector2(value, value);
 }
Пример #30
0
        public void Build(SpaceNode rootNode, DisposableList <HLODBuildInfo> infos, GameObject root,
                          float cullDistance, float lodDistance, bool writeNoPrefab, bool extractMaterial, Action <float> onProgress)
        {
            dynamic options = m_streamingOptions;
            string  path    = options.OutputDirectory;

            HLODTreeNodeContainer container         = new HLODTreeNodeContainer();
            HLODTreeNode          convertedRootNode = ConvertNode(container, rootNode);

            //create settings if there is no settings.
            if (AddressableAssetSettingsDefaultObject.Settings == null)
            {
                AddressableAssetSettings.Create(AddressableAssetSettingsDefaultObject.kDefaultConfigFolder, AddressableAssetSettingsDefaultObject.kDefaultConfigAssetName, true, true);
            }


            var settings = AddressableAssetSettingsDefaultObject.GetSettings(true);
            var group    = GetGroup(settings, options.AddressablesGroupName);

            m_shaderGuids.Clear();

            if (onProgress != null)
            {
                onProgress(0.0f);
            }

            HLODData.TextureCompressionData compressionData;
            compressionData.PCTextureFormat      = options.PCCompression;
            compressionData.WebGLTextureFormat   = options.WebGLCompression;
            compressionData.AndroidTextureFormat = options.AndroidCompression;
            compressionData.iOSTextureFormat     = options.iOSCompression;
            compressionData.tvOSTextureFormat    = options.tvOSCompression;


            string filenamePrefix = $"{path}{root.name}";

            if (Directory.Exists(path) == false)
            {
                Directory.CreateDirectory(path);
            }

            Dictionary <int, HLODData> hlodDatas = new Dictionary <int, HLODData>();

            for (int i = 0; i < infos.Count; ++i)
            {
                if (hlodDatas.ContainsKey(infos[i].ParentIndex) == false)
                {
                    HLODData newData = new HLODData();
                    newData.CompressionData = compressionData;
                    hlodDatas.Add(infos[i].ParentIndex, newData);
                }

                HLODData data = hlodDatas[infos[i].ParentIndex];
                data.AddFromWokringObjects(infos[i].Name, infos[i].WorkingObjects);
                data.AddFromWorkingColliders(infos[i].Name, infos[i].Colliders);

                if (writeNoPrefab)
                {
                    if (hlodDatas.ContainsKey(i) == false)
                    {
                        HLODData newData = new HLODData();
                        newData.CompressionData = compressionData;
                        hlodDatas.Add(i, newData);
                    }

                    HLODData prefabData = hlodDatas[i];
                    var      spaceNode  = infos[i].Target;

                    for (int oi = 0; oi < spaceNode.Objects.Count; ++oi)
                    {
                        if (PrefabUtility.IsAnyPrefabInstanceRoot(spaceNode.Objects[oi]) == false)
                        {
                            prefabData.AddFromGameObject(spaceNode.Objects[oi]);
                        }
                    }
                }


                if (onProgress != null)
                {
                    onProgress((float)i / (float)infos.Count);
                }
            }


            if (extractMaterial)
            {
                ExtractMaterial(hlodDatas, filenamePrefix);
            }

            Dictionary <int, RootData> rootDatas = new Dictionary <int, RootData>();

            foreach (var item in hlodDatas)
            {
                string filename = $"{filenamePrefix}_group{item.Key}.hlod";
                using (Stream stream = new FileStream(filename, FileMode.Create))
                {
                    HLODDataSerializer.Write(stream, item.Value);
                    stream.Close();
                }

                AssetDatabase.ImportAsset(filename, ImportAssetOptions.ForceUpdate);
                RootData rootData = AssetDatabase.LoadAssetAtPath <RootData>(filename);
                m_manager.AddGeneratedResource(rootData);
                AddAddress(settings, group, rootData);

                rootDatas.Add(item.Key, rootData);
            }



            var addressableController = root.AddComponent <AddressableHLODController>();

            for (int i = 0; i < infos.Count; ++i)
            {
                var spaceNode    = infos[i].Target;
                var hlodTreeNode = convertedTable[infos[i].Target];

                for (int oi = 0; oi < spaceNode.Objects.Count; ++oi)
                {
                    int        highId = -1;
                    GameObject obj    = spaceNode.Objects[oi];

                    if (PrefabUtility.IsPartOfAnyPrefab(obj) == false)
                    {
                        GameObject rootGameObject = null;

                        if (rootDatas.ContainsKey(i))
                        {
                            rootGameObject = rootDatas[i].GetRootObject(obj.name);
                        }

                        if (rootGameObject != null)
                        {
                            GameObject go = PrefabUtility.InstantiatePrefab(rootGameObject) as GameObject;
                            go.transform.SetParent(obj.transform.parent);
                            go.transform.localPosition = obj.transform.localPosition;
                            go.transform.localRotation = obj.transform.localRotation;
                            go.transform.localScale    = obj.transform.localScale;

                            if (m_manager.IsGeneratedResource(obj))
                            {
                                m_manager.AddGeneratedResource(go);
                            }
                            else
                            {
                                m_manager.AddConvertedPrefabResource(go);
                            }

                            spaceNode.Objects.Add(go);

                            Object.DestroyImmediate(obj);
                            continue;
                        }
                    }

                    var address = GetAddress(spaceNode.Objects[oi]);
                    if (string.IsNullOrEmpty(address) && PrefabUtility.IsAnyPrefabInstanceRoot(spaceNode.Objects[oi]))
                    {
                        AddAddress(settings, group, spaceNode.Objects[oi]);
                        address = GetAddress(spaceNode.Objects[oi]);
                    }

                    if (address != null)
                    {
                        highId = addressableController.AddHighObject(address, spaceNode.Objects[oi]);
                    }
                    else
                    {
                        highId = addressableController.AddHighObject(spaceNode.Objects[oi]);
                    }

                    hlodTreeNode.HighObjectIds.Add(highId);
                }

                {
                    if (rootDatas[infos[i].ParentIndex].GetRootObject(infos[i].Name) != null)
                    {
                        string filename = $"{filenamePrefix}_group{infos[i].ParentIndex}.hlod";
                        int    lowId    = addressableController.AddLowObject(filename + "[" + infos[i].Name + "]");
                        hlodTreeNode.LowObjectIds.Add(lowId);
                    }
                }
            }

            var shaderEntriesAdded = new List <AddressableAssetEntry>();

            foreach (var shaderGuid in m_shaderGuids)
            {
                if (IsExistsInAddressables(shaderGuid) == false)
                {
                    shaderEntriesAdded.Add(settings.CreateOrMoveEntry(shaderGuid, group, false, false));
                }
            }
            settings.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, shaderEntriesAdded, true);
            m_shaderGuids.Clear();

            addressableController.Container    = container;
            addressableController.Root         = convertedRootNode;
            addressableController.CullDistance = cullDistance;
            addressableController.LODDistance  = lodDistance;
        }