public RefitToWindow(ShipListScreenEntry entry, ShipListScreen screen)
 {
     this.screen = screen;
     this.shiptorefit = entry.ship;
     base.IsPopup = true;
     base.TransitionOnTime = TimeSpan.FromSeconds(0.25);
     base.TransitionOffTime = TimeSpan.FromSeconds(0.25);
 }
 public void ResetList(int omit)
 {
     ShipListScreenEntry entry;
     this.ShipSL.Entries.Clear();
     this.ShipSL.Copied.Clear();
     this.ShipSL.indexAtTop = 0;
     if (EmpireManager.GetEmpireByName(this.empUI.screen.PlayerLoyalty).GetShips().Count > 0)
     {
         foreach (Ship ship in EmpireManager.GetEmpireByName(this.empUI.screen.PlayerLoyalty).GetShips())
         {
             if ((!ship.IsPlayerDesign && this.HidePlatforms) || ship.Mothership != null)  //fbedard: never list ships created from hangar
             {
                 continue;
             }
             switch (this.ShowRoles.Options[this.ShowRoles.ActiveIndex].@value)
             {
                 case 1:
                 {
                     if (ship.Role == "platform" || ship.Role == "station")
                     {
                         continue;
                     }
                     entry = new ShipListScreenEntry(ship, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 30, this);
                     this.ShipSL.AddItem(entry);
                     continue;
                 }
                 case 2:
                 {
                     if ((ship.Role != "fighter") && (ship.Role != "scout"))
                     {
                         continue;
                     }
                     entry = new ShipListScreenEntry(ship, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 30, this);
                     this.ShipSL.AddItem(entry);
                     continue;
                 }
                 case 3:
                 {
                     if ((ship.Role != "frigate") && (ship.Role != "destroyer"))
                     {
                         continue;
                     }
                     entry = new ShipListScreenEntry(ship, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 30, this);
                     this.ShipSL.AddItem(entry);
                     continue;
                 }
                 case 4:
                 {
                     if (ship.Role != "cruiser")
                     {
                         continue;
                     }
                     entry = new ShipListScreenEntry(ship, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 30, this);
                     this.ShipSL.AddItem(entry);
                     continue;
                 }
                 case 5:
                 {
                     if (!(ship.Role == "capital") && !(ship.Role == "carrier"))
                     {
                         continue;
                     }
                     entry = new ShipListScreenEntry(ship, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 30, this);
                     this.ShipSL.AddItem(entry);
                     continue;
                 }
                 case 6:
                 {
                     if (ship.fleet == null)
                     {
                         continue;
                     }
                     entry = new ShipListScreenEntry(ship, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 30, this);
                     this.ShipSL.AddItem(entry);
                     continue;
                 }
                 case 7:
                 {
                     if (!ship.IsPlayerDesign)
                     {
                         continue;
                     }
                     entry = new ShipListScreenEntry(ship, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 30, this);
                     this.ShipSL.AddItem(entry);
                     continue;
                 }
                 case 8:
                 {
                     if ((ship.Role != "freighter") && (ship.Role != "construction"))
                     {
                         continue;
                     }
                     entry = new ShipListScreenEntry(ship, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 30, this);
                     this.ShipSL.AddItem(entry);
                     continue;
                 }
                 case 9:
                 {
                     if ((ship.Role != "platform") && (ship.Role != "station") && (ship.Role != "construction"))
                     {
                         continue;
                     }
                     entry = new ShipListScreenEntry(ship, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 30, this);
                     this.ShipSL.AddItem(entry);
                     continue;
                 }
                 case 10:
                 {
                     if ((ship.Role != "corvette"))
                     {
                         continue;
                     }
                     entry = new ShipListScreenEntry(ship, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 30, this);
                     this.ShipSL.AddItem(entry);
                     continue;
                 }
                 default:
                 {
                     continue;
                 }
             }
         }
         if (this.ShipSL.Entries.Count<ScrollList.Entry>() > 0)
         {
             this.SelectedShip = (this.ShipSL.Entries[this.ShipSL.indexAtTop].item as ShipListScreenEntry).ship;
             return;
         }
         this.SelectedShip = null;
     }
 }
        //private bool AutoButtonHover;
        public ShipListScreen(Ship_Game.ScreenManager ScreenManager, EmpireUIOverlay empUI)
        {
            this.empUI = 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(190)).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.EMenu = new Menu2(ScreenManager, this.leftRect);
            this.close = new CloseButton(new Rectangle(this.leftRect.X + this.leftRect.Width - 40, this.leftRect.Y + 20, 20, 20));
            this.eRect = new Rectangle(2, titleRect.Y + titleRect.Height + 25, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 40, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - (titleRect.Y + titleRect.Height) - 7);
            while (this.eRect.Height % 80 != 0)
            {
                this.eRect.Height = this.eRect.Height - 1;
            }
            this.ShipSubMenu = new Submenu(ScreenManager, this.eRect);
            this.ShipSL = new ScrollList(this.ShipSubMenu, 30);
            if (EmpireManager.GetEmpireByName(empUI.screen.PlayerLoyalty).GetShips().Count > 0)
            {
                foreach (Ship ship in EmpireManager.GetEmpireByName(empUI.screen.PlayerLoyalty).GetShips())
                {
                    if (!ship.IsPlayerDesign && this.HidePlatforms)
                    {
                        continue;
                    }
                    ShipListScreenEntry entry = new ShipListScreenEntry(ship, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 30, this);
                    this.ShipSL.AddItem(entry);
                }
                if (this.ShipSL.Entries.Count<ScrollList.Entry>() > 0)
                {
                    this.SelectedShip = (this.ShipSL.Entries[this.ShipSL.indexAtTop].item as ShipListScreenEntry).ship;
                }
                else
                    this.SelectedShip = null;
            }
            Ref<bool> aeRef = new Ref<bool>(() => this.HidePlatforms, (bool x) => {
                this.HidePlatforms = x;
               this.ResetList(this.ShowRoles.Options[this.ShowRoles.ActiveIndex].@value);
            });
            this.cb_hide_proj = new Checkbox(new Vector2((float)(this.TitleBar.Menu.X + this.TitleBar.Menu.Width + 10), (float)(this.TitleBar.Menu.Y + 15)), Localizer.Token(191), aeRef, Fonts.Arial12Bold);
            this.ShowRoles = new DropOptions(new Rectangle(this.TitleBar.Menu.X + this.TitleBar.Menu.Width + 175, this.TitleBar.Menu.Y + 15, 175, 18));
            this.ShowRoles.AddOption("All Ships", 1);
            this.ShowRoles.AddOption("Fighters", 2);
            this.ShowRoles.AddOption("Corvettes", 10);
            this.ShowRoles.AddOption("Frigates", 3);
            this.ShowRoles.AddOption("Cruisers", 4);
            this.ShowRoles.AddOption("Capitals", 5);
            this.ShowRoles.AddOption("Civilian", 8);
            this.ShowRoles.AddOption("All Structures", 9);
            this.ShowRoles.AddOption("Fleets Only", 6);

            // Replaced using the tick-box for player design filtering. Platforms now can be browsed with 'structures'
            // this.ShowRoles.AddOption("Player Designs Only", 7);

            this.AutoButton = new Rectangle(0, 0, 243, 33);
            this.SortSystem = new SortButton(this.empUI.empire.data.SLSort,Localizer.Token(192));
            this.SortName = new SortButton(this.empUI.empire.data.SLSort, Localizer.Token(193));
            this.SortRole = new SortButton(this.empUI.empire.data.SLSort,Localizer.Token(194));
            //Localizer.Token(193)
            this.Maint = new SortButton(this.empUI.empire.data.SLSort, "maint");
            this.SB_FTL = new SortButton(this.empUI.empire.data.SLSort, "FTL");
            this.SB_STL = new SortButton(this.empUI.empire.data.SLSort, "STL");
            this.SB_Troop = new SortButton(this.empUI.empire.data.SLSort, "Troop");
            this.SB_STR = new SortButton(this.empUI.empire.data.SLSort, "STR");
            //this.Maint.rect = this.MaintRect;
            ResetList(1);  //fbedard: initial filter
        }
 public void ResetList()
 {
     this.ShipSL.Copied.Clear();
     this.ShipSL.Entries.Clear();
     this.ShipSL.indexAtTop = 0;
     if (EmpireManager.GetEmpireByName(this.empUI.screen.PlayerLoyalty).GetShips().Count > 0)
     {
         foreach (Ship ship in EmpireManager.GetEmpireByName(this.empUI.screen.PlayerLoyalty).GetShips())
         {
             if (!ship.IsPlayerDesign && this.HidePlatforms)
             {
                 continue;
             }
             ShipListScreenEntry entry = new ShipListScreenEntry(ship, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 30, this);
             this.ShipSL.AddItem(entry);
         }
         if (this.ShipSL.Entries.Count<ScrollList.Entry>() > 0)
         {
             this.SelectedShip = (this.ShipSL.Entries[this.ShipSL.indexAtTop].item as ShipListScreenEntry).ship;
             return;
         }
         this.SelectedShip = null;
     }
 }