Пример #1
0
        private void HandleJobList(NetIncomingMessage msg)
        {
            int byteNum = msg.ReadInt32();

            byte[] compressedXml = msg.ReadBytes(byteNum);

            string jobListXml = ZipString.UnZipStr(compressedXml);

            JobHandler.Singleton.LoadDefinitionsFromString(jobListXml);
            int pos = 5;

            _jobButtonContainer.components.Clear(); //Properly dispose old buttons !!!!!!!
            foreach (JobDefinition definition in JobHandler.Singleton.JobSettings.JobDefinitions)
            {
                var current = new JobSelectButton(definition.Name, definition.JobIcon, definition.Description,
                                                  ResourceManager)
                {
                    Available = definition.Available,
                    Position  = new Vector2i(5, pos)
                };

                current.Clicked += CurrentClicked;
                current.UserData = definition;
                _jobButtonContainer.components.Add(current);
                pos += current.ClientArea.Height + 20;
            }
        }
Пример #2
0
        private void HandleJobList(NetIncomingMessage msg)
        {
            int byteNum = msg.ReadInt32();

            byte[] compressedXml = msg.ReadBytes(byteNum);

            string jobListXml = ZipString.UnZipStr(compressedXml);

            JobHandler.Singleton.LoadDefinitionsFromString(jobListXml);

            _tabJob._shwDepa.ClearItems();
            _tabJob._shwJobs.ClearItems();

            sortedJobs.Clear();

            foreach (DepartmentDefinition dep in JobHandler.Singleton.JobSettings.DepartmentDefinitions)
            {
                var depJobs = (from x in JobHandler.Singleton.JobSettings.JobDefinitions
                               where x.Department.ToLowerInvariant() == dep.Name.ToLowerInvariant()
                               where x.Available
                               orderby x.Name
                               select x).ToList();

                var newEntry = new KeyValuePair <DepartmentDefinition, List <JobDefinition> >(dep, depJobs);
                sortedJobs.Add(newEntry);

                var newDep = new ImageButton
                {
                    ImageNormal = dep.DepartmentIcon,
                };

                DepartmentInfo newInfo = new DepartmentInfo()
                {
                    Department = dep,
                    JobDefs    = depJobs
                };

                _tabJob._shwDepa.AddItem(newDep, newInfo);
            }
        }