public void ResetListSorted(IOrderedEnumerable<Planet> SortedList)
 {
     this.ColoniesList.Entries.Clear();
     this.ColoniesList.indexAtTop = 0;
     foreach (Planet p in SortedList)
     {
         EmpireScreenEntry entry = new EmpireScreenEntry(p, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 80, this);
         this.ColoniesList.AddItem(entry);
     }
     this.SelectedPlanet = (this.ColoniesList.Entries[this.ColoniesList.indexAtTop].item as EmpireScreenEntry).p;
     this.GovernorDropdown.ActiveIndex = ColonyScreen.GetIndex(this.SelectedPlanet);
     if (this.GovernorDropdown.Options[this.GovernorDropdown.ActiveIndex].@value != (int)this.SelectedPlanet.colonyType)
     {
         this.SelectedPlanet.colonyType = (Planet.ColonyType)this.GovernorDropdown.Options[this.GovernorDropdown.ActiveIndex].@value;
         if (this.SelectedPlanet.colonyType != Planet.ColonyType.Colony)
         {
             this.SelectedPlanet.FoodLocked = true;
             this.SelectedPlanet.ProdLocked = true;
             this.SelectedPlanet.ResLocked = true;
             this.SelectedPlanet.GovernorOn = true;
         }
         else
         {
             this.SelectedPlanet.GovernorOn = false;
             this.SelectedPlanet.FoodLocked = false;
             this.SelectedPlanet.ProdLocked = false;
             this.SelectedPlanet.ResLocked = false;
         }
     }
     for (int i = this.ColoniesList.indexAtTop; i < this.ColoniesList.Entries.Count && i < this.ColoniesList.indexAtTop + this.ColoniesList.entriesToDisplay; i++)
     {
         EmpireScreenEntry entry = this.ColoniesList.Entries[i].item as EmpireScreenEntry;
         entry.SetNewPos(this.eRect.X + 22, this.ColoniesList.Entries[i].clickRect.Y);
     }
 }
        public EmpireScreen(Ship_Game.ScreenManager ScreenManager, EmpireUIOverlay empUI)
        {
            base.TransitionOnTime = TimeSpan.FromSeconds(0.25);
            base.TransitionOffTime = TimeSpan.FromSeconds(0.25);
            base.IsPopup = true;
            this.eui = empUI;
            base.ScreenManager = ScreenManager;
            if (base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth <= 1280)
            {
                //this.LowRes = true;
            }

            Rectangle titleRect = new Rectangle(2, 44, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 2 / 3, 80);
            this.TitleBar = new Menu2(ScreenManager, titleRect);
            this.TitlePos = new Vector2((float)(titleRect.X + titleRect.Width / 2) - Fonts.Laserian14.MeasureString(Localizer.Token(383)).X / 2f, (float)(titleRect.Y + titleRect.Height / 2 - Fonts.Laserian14.LineSpacing / 2));
            this.leftRect = new Rectangle(2, titleRect.Y + titleRect.Height + 5, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 10, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - (titleRect.Y + titleRect.Height) - 7);
            this.close = new CloseButton(new Rectangle(this.leftRect.X + this.leftRect.Width - 40, this.leftRect.Y + 20, 20, 20));
            this.EMenu = new Menu2(ScreenManager, this.leftRect);
            this.eRect = new Rectangle(2, titleRect.Y + titleRect.Height + 25, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 40, (int)(0.66f * (float)(ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - (titleRect.Y + titleRect.Height) - 7)));
            while (this.eRect.Height % 80 != 0)
            {
                this.eRect.Height = this.eRect.Height - 1;
            }
            this.ColonySubMenu = new Submenu(ScreenManager, this.eRect);
            this.ColoniesList = new ScrollList(this.ColonySubMenu, 80);
            //if (!this.firstSort || this.pop.Ascending !=true)
            {
                foreach (Planet p in EmpireManager.GetEmpireByName(empUI.screen.PlayerLoyalty).GetPlanets())
                {
                    EmpireScreenEntry entry = new EmpireScreenEntry(p, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 80, this);
                    this.ColoniesList.AddItem(entry);
                }
            }
            this.pop = new SortButton(this.eui.empire.data.ESSort, "pop");
            this.food = new SortButton(this.eui.empire.data.ESSort, "food");
            this.prod = new SortButton(this.eui.empire.data.ESSort, "prod");
            this.res = new SortButton(this.eui.empire.data.ESSort, "res");
            this.money = new SortButton(this.eui.empire.data.ESSort, "money");
            this.SelectedPlanet = (this.ColoniesList.Entries[this.ColoniesList.indexAtTop].item as EmpireScreenEntry).p;
            this.GovernorDropdown = new DropOptions(new Rectangle(0, 0, 100, 18));
            this.GovernorDropdown.AddOption("--", 1);
            this.GovernorDropdown.AddOption(Localizer.Token(4064), 0);
            this.GovernorDropdown.AddOption(Localizer.Token(4065), 2);
            this.GovernorDropdown.AddOption(Localizer.Token(4066), 4);
            this.GovernorDropdown.AddOption(Localizer.Token(4067), 3);
            this.GovernorDropdown.AddOption(Localizer.Token(4068), 5);
            this.GovernorDropdown.AddOption(Localizer.Token(393), 6);
            this.GovernorDropdown.ActiveIndex = ColonyScreen.GetIndex(this.SelectedPlanet);
            if (this.GovernorDropdown.Options[this.GovernorDropdown.ActiveIndex].@value != (int)this.SelectedPlanet.colonyType)
            {
                this.SelectedPlanet.colonyType = (Planet.ColonyType)this.GovernorDropdown.Options[this.GovernorDropdown.ActiveIndex].@value;
                if (this.SelectedPlanet.colonyType != Planet.ColonyType.Colony)
                {
                    this.SelectedPlanet.FoodLocked = true;
                    this.SelectedPlanet.ProdLocked = true;
                    this.SelectedPlanet.ResLocked = true;
                    this.SelectedPlanet.GovernorOn = true;
                }
                else
                {
                    this.SelectedPlanet.GovernorOn = false;
                    this.SelectedPlanet.FoodLocked = false;
                    this.SelectedPlanet.ProdLocked = false;
                    this.SelectedPlanet.ResLocked = false;
                }
            }
            this.AutoButton = new Rectangle(0, 0, 140, 33);
            this.firstSort = true;
        }