public void SetShipList(List<Ship> shipList, bool isFleet)
        {
            this.Orders.Clear();
            this.isFleet = isFleet;
            if (shipList != this.ShipList)
            {
                this.SelectedShipsSL.indexAtTop = 0;
            }
            this.ShipList = shipList;
            this.SelectedShipsSL.Entries.Clear();
            SelectedShipEntry entry = new SelectedShipEntry();
            bool AllResupply = true;
            this.AllShipsMine = true;
            bool AllFreighters = true;
            bool AllCombat = true;
            for (int i = 0; i < shipList.Count; i++)
            {
                Ship ship = shipList[i];
                SkinnableButton button = new SkinnableButton(new Rectangle(0, 0, 20, 20), string.Concat("TacticalIcons/symbol_", ship.Role))
                {
                    IsToggle = false,
                    ReferenceObject = ship,
                    BaseColor = ship.loyalty.EmpireColor
                };
                if (entry.ShipButtons.Count < 8)
                {
                    entry.ShipButtons.Add(button);
                }
                if (entry.ShipButtons.Count == 8 || i == shipList.Count - 1)
                {
                    this.SelectedShipsSL.AddItem(entry);
                    entry = new SelectedShipEntry();
                }
                if (ship.GetAI().State != AIState.Resupply)
                {
                    AllResupply = false;
                }
                if (ship.loyalty != EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty))
                {
                    this.AllShipsMine = false;
                }
                //if (ship.CargoSpace_Max == 0f)
                if (ship.CargoSpace_Max == 0f || ship.Role == "troop" || ship.GetAI().State == AIState.Colonize || ship.Role == "station" || ship.Mothership != null)
                {
                    AllFreighters = false;
                }
                if (ship.Role == "construction" || ship.Role == "platform" || ship.Role == "freighter" || ship.Role == "troop" || ship.GetAI().State == AIState.Colonize || ship.Role == "station" || ship.Mothership != null)
                {
                    AllCombat = false;
                }
            }
            OrdersButton resupply = new OrdersButton(shipList, Vector2.Zero, OrderType.OrderResupply, 149)
            {
                SimpleToggle = true,
                Active = AllResupply
            };
            this.Orders.Add(resupply);

            if (AllCombat)
            {
            OrdersButton SystemDefense = new OrdersButton(shipList, Vector2.Zero, OrderType.EmpireDefense, 150)
            {
                SimpleToggle = true,
                Active = false
            };
            this.Orders.Add(SystemDefense);
            OrdersButton Explore = new OrdersButton(shipList, Vector2.Zero, OrderType.Explore, 136)
            {
                SimpleToggle = true,
                Active = false
            };
            this.Orders.Add(Explore);
            OrdersButton ordersButton = new OrdersButton(shipList, Vector2.Zero, OrderType.DefineAO, 15);
            SystemDefense.SimpleToggle = true;
            }

            if (AllFreighters)
            {
                OrdersButton tf = new OrdersButton(shipList, Vector2.Zero, OrderType.TradeFood, 15)
                {
                    SimpleToggle = true
                };
                this.Orders.Add(tf);
                OrdersButton tpass = new OrdersButton(shipList, Vector2.Zero, OrderType.PassTran, 152)
                {
                    SimpleToggle = true
                };
                this.Orders.Add(tpass);
            }

            //Added by McShooterz: fleet scrap button
            OrdersButton Scrap = new OrdersButton(shipList, Vector2.Zero, OrderType.Scrap, 157)
            {
                SimpleToggle = true,
                Active = false
            };
            this.Orders.Add(Scrap);

            int ex = 0;
            int y = 0;
            for (int i = 0; i < this.Orders.Count; i++)
            {
                OrdersButton ob = this.Orders[i];
                if (i % 2 == 0 && i > 0)
                {
                    ex++;
                    y = 0;
                }
                ob.clickRect.X = this.ElementRect.X + this.ElementRect.Width + 2 + 52 * ex;
                ob.clickRect.Y = this.sliding_element.Housing.Y + 15 + y * 52;
                y++;
            }
        }
        public void SetShip(Ship s)
        {
            if (s.loyalty == EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty))
            {
                this.CanRename = true;
            }
            else
            {
                this.CanRename = false;
            }
            this.ShipNameArea.HandlingInput = false;
            this.ShipNameArea.Text = s.VanityName;
            this.Orders.Clear();
            this.ship = s;
            if (this.ship.loyalty != EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty))
            {
                return;
            }
            if (this.ship.GetAI().OrderQueue.Count<ArtificialIntelligence.ShipGoal>() > 0)
            {
                try
                {
                    if (this.ship.GetAI().OrderQueue.Last<ArtificialIntelligence.ShipGoal>().Plan == ArtificialIntelligence.Plan.DeployStructure)
                    {
                        return;
                    }
                }
                catch
                {
                    return;
                }
            }
            if (this.ship.Role != "station" && this.ship.Role != "platform")
            {
                OrdersButton resupply = new OrdersButton(this.ship, Vector2.Zero, OrderType.OrderResupply, 149)
                {
                    ValueToModify = new Ref<bool>(() => this.ship.DoingResupply, (bool x) => this.ship.DoingResupply = x)
                };
                this.Orders.Add(resupply);
            }
            if (this.ship.CargoSpace_Max > 0f && this.ship.Role != "troop" && this.ship.GetAI().State != AIState.Colonize && this.ship.Role != "station" && ship.Mothership == null)
            {
                OrdersButton ao = new OrdersButton(this.ship, Vector2.Zero, OrderType.DefineAO, 15)
                {
                    ValueToModify = new Ref<bool>(() => this.screen.DefiningAO, (bool x) => {
                        this.screen.DefiningAO = x;
                        this.screen.AORect = new Rectangle(0, 0, 0, 0);
                    })
                };
                this.Orders.Add(ao);
                OrdersButton tf = new OrdersButton(this.ship, Vector2.Zero, OrderType.TradeFood, 16)
                {
                    ValueToModify = new Ref<bool>(() => this.ship.DoingTransport, (bool x) => this.ship.DoingTransport = x),
                    RightClickValueToModify = new Ref<bool>(() => this.ship.TransportingFood, (bool x) => this.ship.TransportingFood = x)
                };
                this.Orders.Add(tf);
                OrdersButton tp = new OrdersButton(this.ship, Vector2.Zero, OrderType.TradeProduction, 17)
                {
                    ValueToModify = new Ref<bool>(() => this.ship.DoingTransport, (bool x) => this.ship.DoingTransport = x),
                    RightClickValueToModify = new Ref<bool>(() => this.ship.TransportingProduction, (bool x) => this.ship.TransportingProduction = x)
                };
                this.Orders.Add(tp);
                OrdersButton tpass = new OrdersButton(this.ship, Vector2.Zero, OrderType.PassTran, 137)
                {
                    ValueToModify = new Ref<bool>(() => this.ship.DoingPassTransport, (bool x) => this.ship.DoingPassTransport = x)
                };
                this.Orders.Add(tpass);
            }
            if (this.ship.shield_max > 0f)
            {
                OrdersButton ob = new OrdersButton(this.ship, Vector2.Zero, OrderType.ShieldToggle, 18)
                {
                    ValueToModify = new Ref<bool>(() => this.ship.ShieldsUp, (bool x) => this.ship.ShieldsUp = x)
                };
                this.Orders.Add(ob);
            }
            if (this.ship.GetHangars().Count > 0 && ship.Mothership == null)
            {
                bool hasTroops = false;
                bool hasFighters = false;
                foreach (ShipModule hangar in this.ship.GetHangars())
                {
                    if (hangar.TroopCapacity != 0 || hangar.IsSupplyBay)
                    {
                        if (!hangar.IsTroopBay)
                        {
                            continue;
                        }
                        hasTroops = true;
                    }
                    else
                    {
                        hasFighters = true;
                    }
                }
                if (hasFighters)
                {
                    OrdersButton ob = new OrdersButton(this.ship, Vector2.Zero, OrderType.FighterToggle, 19)
                    {
                        ValueToModify = new Ref<bool>(() => this.ship.FightersOut, (bool x) => {
                            this.ship.FightersOut = x;
                            this.ship.ManualHangarOverride = true;
                        })
                    };
                    this.Orders.Add(ob);
                    if (this.ship.Role != "station")
                    {
                        OrdersButton ob2 = new OrdersButton(this.ship, Vector2.Zero, OrderType.FighterRecall, 146)
                        {
                            ValueToModify = new Ref<bool>(() => this.ship.RecallFightersBeforeFTL, (bool x) => this.ship.RecallFightersBeforeFTL = x)
                        };
                        this.Orders.Add(ob2);
                    }
                }
                if (hasTroops)
                {
                    OrdersButton ob = new OrdersButton(this.ship, Vector2.Zero, OrderType.TroopToggle, 19)
                    {
                        ValueToModify = new Ref<bool>(() => this.ship.TroopsOut, (bool x) => {
                            this.ship.TroopsOut = x;
                            this.ship.ManualHangarOverride = true;
                        })
                    };
                    this.Orders.Add(ob);
                }
            }
            if (this.ship.Role != "station" && ship.Mothership == null && this.ship.Role != "platform" && this.ship.Role != "troop" && this.ship.GetAI().State != AIState.Colonize && this.ship.Role != "freighter")
            {
                OrdersButton exp = new OrdersButton(this.ship, Vector2.Zero, OrderType.Explore, 136)
                {
                    ValueToModify = new Ref<bool>(() => this.ship.DoingExplore, (bool x) => this.ship.DoingExplore = x)
                };
                this.Orders.Add(exp);
                OrdersButton SystemDefense = new OrdersButton(this.ship, Vector2.Zero, OrderType.EmpireDefense, 150)
                {
                    ValueToModify = new Ref<bool>(() => this.ship.DoingSystemDefense, (bool x) => this.ship.DoingSystemDefense = x),
                    Active = false
                };
                this.Orders.Add(SystemDefense);
            }
            if (ship.Mothership == null)
            {
                OrdersButton rf = new OrdersButton(this.ship, Vector2.Zero, OrderType.Refit, 158)
                {
                    ValueToModify = new Ref<bool>(() => this.ship.doingRefit, (bool x) => this.ship.doingRefit = x),
                    Active = false
                };
                this.Orders.Add(rf);
                //Added by McShooterz: scrap order
                OrdersButton sc = new OrdersButton(this.ship, Vector2.Zero, OrderType.Scrap, 157)
                {
                    ValueToModify = new Ref<bool>(() => this.ship.doingScrap, (bool x) => this.ship.doingScrap = x),
                    Active = false
                };
                this.Orders.Add(sc);
            }

            int ex = 0;
            int y = 0;
            for (int i = 0; i < this.Orders.Count; i++)
            {
                OrdersButton ob = this.Orders[i];
                if (i % 2 == 0 && i > 0)
                {
                    ex++;
                    y = 0;
                }
                ob.clickRect.X = this.ElementRect.X + this.ElementRect.Width + 2 + 52 * ex;
                ob.clickRect.Y = this.sliding_element.Housing.Y + 15 + y * 52;
                y++;
            }
        }