public AutomationWindow(Ship_Game.ScreenManager ScreenManager, UniverseScreen screen)
        {
            this.screen = screen;
            this.ScreenManager = ScreenManager;
            int WindowWidth = 210;
            this.win = new Rectangle(ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 115 - WindowWidth, 490, WindowWidth, 300);
            Rectangle rectangle = new Rectangle(ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 5 - WindowWidth + 20, 225, WindowWidth - 40, 455);
            this.ConstructionSubMenu = new Submenu(ScreenManager, this.win, true);
            this.ConstructionSubMenu.AddTab(Localizer.Token(304));

            Ref<bool> aeRef = new Ref<bool>(() => EmpireManager.GetEmpireByName(screen.PlayerLoyalty).AutoExplore, (bool x) => EmpireManager.GetEmpireByName(screen.PlayerLoyalty).AutoExplore = x);
            Checkbox cb = new Checkbox(new Vector2((float)this.win.X, (float)(this.win.Y + 25)), Localizer.Token(305), aeRef, Fonts.Arial12Bold);
            this.Checkboxes.Add(cb);
            cb.Tip_Token = 2226;

            this.ScoutDropDown = new DropOptions(new Rectangle(this.win.X + 12, this.win.Y + 25 + Fonts.Arial12Bold.LineSpacing + 7, 190, 18));

            Ref<bool> acRef = new Ref<bool>(() => EmpireManager.GetEmpireByName(screen.PlayerLoyalty).AutoColonize, (bool x) => EmpireManager.GetEmpireByName(screen.PlayerLoyalty).AutoColonize = x);
            cb = new Checkbox(new Vector2((float)this.win.X, (float)(this.win.Y + 65)), Localizer.Token(306), acRef, Fonts.Arial12Bold);
            this.Checkboxes.Add(cb);
            cb.Tip_Token = 2227;

            this.ColonyShipDropDown = new DropOptions(new Rectangle(this.win.X + 12, this.win.Y + 65 + Fonts.Arial12Bold.LineSpacing + 7, 190, 18));

            Ref<bool> afRef = new Ref<bool>(() => EmpireManager.GetEmpireByName(screen.PlayerLoyalty).AutoFreighters, (bool x) => EmpireManager.GetEmpireByName(screen.PlayerLoyalty).AutoFreighters = x);
            cb = new Checkbox(new Vector2((float)this.win.X, (float)(this.win.Y + 105)), Localizer.Token(308), afRef, Fonts.Arial12Bold);
            this.Checkboxes.Add(cb);
            cb.Tip_Token = 2229;

            this.AutoFreighterDropDown = new DropOptions(new Rectangle(this.win.X + 12, this.win.Y + 105 + Fonts.Arial12Bold.LineSpacing + 7, 190, 18));

            this.ConstructorTitle = new Vector2((float)this.win.X + 29, (float)(this.win.Y + 155));
            this.ConstructorString = Localizer.Token(6181);
            this.ConstructorDropDown = new DropOptions(new Rectangle(this.win.X + 12, this.win.Y + 155 + Fonts.Arial12Bold.LineSpacing + 7, 190, 18));

            Ref<bool> abRef = new Ref<bool>(() => EmpireManager.GetEmpireByName(screen.PlayerLoyalty).AutoBuild, (bool x) => EmpireManager.GetEmpireByName(screen.PlayerLoyalty).AutoBuild = x);
            cb = new Checkbox(new Vector2((float)this.win.X, (float)(this.win.Y + 210)), string.Concat(Localizer.Token(307), " Projectors"), abRef, Fonts.Arial12Bold);
            this.Checkboxes.Add(cb);
            cb.Tip_Token = 2228;

            Ref<bool> acomRef = new Ref<bool>(() => GlobalStats.AutoCombat, (bool x) => GlobalStats.AutoCombat = x);
            cb = new Checkbox(new Vector2((float)this.win.X, (float)(this.win.Y + 210 + Fonts.Arial12Bold.LineSpacing + 3)), Localizer.Token(2207), acomRef, Fonts.Arial12Bold);
            this.Checkboxes.Add(cb);
            cb.Tip_Token = 2230;

            Ref<bool> arRef = new Ref<bool>(() => EmpireManager.GetEmpireByName(screen.PlayerLoyalty).AutoResearch, (bool x) => EmpireManager.GetEmpireByName(screen.PlayerLoyalty).AutoResearch = x);
            cb = new Checkbox(new Vector2((float)this.win.X, (float)(this.win.Y + 210 + Fonts.Arial12Bold.LineSpacing * 2 + 6)), Localizer.Token(6136), arRef, Fonts.Arial12Bold);
            this.Checkboxes.Add(cb);
            cb.Tip_Token = 7039;

            Ref<bool> atRef = new Ref<bool>(() => EmpireManager.GetEmpireByName(screen.PlayerLoyalty).AutoTaxes, (bool x) => EmpireManager.GetEmpireByName(screen.PlayerLoyalty).AutoTaxes = x);
            cb = new Checkbox(new Vector2((float)this.win.X, (float)(this.win.Y + 210 + Fonts.Arial12Bold.LineSpacing * 3 + 9)), Localizer.Token(6138), atRef, Fonts.Arial12Bold);
            this.Checkboxes.Add(cb);
            cb.Tip_Token = 7040;

            this.SetDropDowns();
        }
        //added by gremlin deveksmod spy draw
        public void Draw()
        {
            Primitives2D.FillRectangle(this.ScreenManager.SpriteBatch, this.SubRect, Color.Black);
            this.AgentSL.Draw(this.ScreenManager.SpriteBatch);
            this.RecruitButton.Draw(this.ScreenManager);
            Rectangle MoneyRect = new Rectangle(this.RecruitButton.r.X, this.RecruitButton.r.Y + 30, 21, 20);
            this.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["NewUI/icon_money"], MoneyRect, Color.White);
            Vector2 costPos = new Vector2((float)(MoneyRect.X + 25), (float)(MoneyRect.Y + 10 - Fonts.Arial12Bold.LineSpacing / 2));
            this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, (ResourceManager.AgentMissionData.AgentCost + ResourceManager.AgentMissionData.TrainingCost).ToString(), costPos, Color.White);

            //aeRef = new Ref<bool>(() => this.HideUninhab, (bool x) =>
            //{
            //    this.HideUninhab = x;
            //    this.ResetList();
            //});

            Ref<bool> ATRef = new Ref<bool>(() => AutoTrain, (bool x) => AutoTrain = x);
            Vector2 ATCBPos = new Vector2((float)(this.OpsSubRect.X - 10), (float)(MoneyRect.Y - 30));
            CBAutoRepeat = new Checkbox(ATCBPos, "Repeat Missions", ATRef, Fonts.Arial12);
            Ref<bool> muteATRef = new Ref<bool>(() => SpyMute, (bool x) => SpyMute = x);
            Vector2 muteCBPos = new Vector2((float)(ATCBPos.X), (float)(ATCBPos.Y + 15));
            cbSpyMute = new Checkbox(muteCBPos, "Mute Spies", muteATRef, Fonts.Arial12);

            CBAutoRepeat.Draw(ScreenManager);
            cbSpyMute.Draw(ScreenManager);

            Rectangle spyLimit = new Rectangle((int)MoneyRect.X + 65, (int)MoneyRect.Y, 21, 20);
            this.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["NewUI/icon_lock"], spyLimit, Color.White);
            Vector2 spyLimitPos = new Vector2((float)(spyLimit.X + 25), (float)(spyLimit.Y + 10 - Fonts.Arial12.LineSpacing / 2));
            //empirePlanetSpys = EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).GetPlanets().Where(canBuildTroops => canBuildTroops.CanBuildInfantry() == true).Count();
            //if (EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).GetPlanets().Where(canBuildTroops => canBuildTroops.BuildingList.Where(building => building.Name == "Capital City") != null).Count() > 0) empirePlanetSpys = empirePlanetSpys + 2;
            empirePlanetSpys = EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).GetPlanets().Count() / 3 + 3;
            spyLimitCount = (empirePlanetSpys - EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).data.AgentList.Count);
            if (empirePlanetSpys < 0) empirePlanetSpys = 0;
            this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12, string.Concat("For Hire : ", spyLimitCount.ToString(), " / ", empirePlanetSpys.ToString()), spyLimitPos, Color.White);

            //Rectangle spyDefense = new Rectangle(spyLimitPos.Y, spyLimitPos, 21, 20);
            //this.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["NewUI/icon_planetshield"], spyDefense, Color.White);
            //Vector2 spyDefensePos = new Vector2((float)(spyLimit.X + 100), (float)(spyLimit.Y ));
            //this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, "SpyDefense: ", spyDefensePos, Color.White);

            for (int i = this.AgentSL.indexAtTop; i < this.AgentSL.Entries.Count && i < this.AgentSL.indexAtTop + this.AgentSL.entriesToDisplay; i++)
            {
                try
                {
                    ScrollList.Entry e = this.AgentSL.Entries[i];
                    Agent agent = e.item as Agent;
                    Rectangle r = new Rectangle(e.clickRect.X, e.clickRect.Y, 25, 26);
                    this.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["UI/icon_spy"], r, Color.White);
                    Vector2 namecursor = new Vector2((float)(r.X + 30), (float)r.Y);
                    //Ref<bool> acomRef = new Ref<bool>(() => GlobalStats.PlanetaryGravityWells, (bool x) => GlobalStats.PlanetaryGravityWells = x);

                    this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12Bold, agent.Name, namecursor, Color.White);
                    namecursor.Y = namecursor.Y + (float)(Fonts.Arial12Bold.LineSpacing + 2);
                    string missionstring = Localizer.Token(agent.MissionNameIndex);
                    this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12, missionstring, namecursor, Color.Gray);
                    for (int j = 0; j < agent.Level; j++)
                    {
                        Rectangle levelRect = new Rectangle(e.clickRect.X + e.clickRect.Width - 18 - 12 * j, e.clickRect.Y, 12, 11);
                        this.ScreenManager.SpriteBatch.Draw(Ship_Game.ResourceManager.TextureDict["UI/icon_star"], levelRect, Color.White);
                    }
                    if ((e.item as Agent).Mission != AgentMission.Defending)
                    {
                        if (!string.IsNullOrEmpty((e.item as Agent).TargetEmpire) && (e.item as Agent).Mission != AgentMission.Training && (e.item as Agent).Mission != AgentMission.Undercover)
                        {
                            Vector2 targetCursor = namecursor;
                            targetCursor.X = targetCursor.X + 75f;
                            missionstring = string.Concat(Localizer.Token(2199), ": ", EmpireManager.GetEmpireByName((e.item as Agent).TargetEmpire).data.Traits.Plural);
                            this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12, missionstring, targetCursor, Color.Gray);
                        }
                        else if ((e.item as Agent).TargetGUID != Guid.Empty && (e.item as Agent).Mission == AgentMission.Undercover)
                        {
                            Vector2 targetCursor = namecursor;
                            targetCursor.X = targetCursor.X + 75f;
                            missionstring = string.Concat(Localizer.Token(2199), ": ", Ship.universeScreen.PlanetsDict[(e.item as Agent).TargetGUID].Name);
                            this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12, missionstring, targetCursor, Color.Gray);
                        }
                        if ((e.item as Agent).Mission != AgentMission.Undercover)
                        {
                            Vector2 turnsCursor = namecursor;
                            turnsCursor.X = turnsCursor.X + 193f;
                            missionstring = string.Concat(Localizer.Token(2200), ": ", (e.item as Agent).TurnsRemaining);
                            this.ScreenManager.SpriteBatch.DrawString(Fonts.Arial12, missionstring, turnsCursor, Color.Gray);
                        }
                    }
                }
                catch
                {
                }
            }
            if (this.selector != null)
            {
                this.selector.Draw();
            }
            if (this.SelectedAgent != null)
            {
                Primitives2D.FillRectangle(this.ScreenManager.SpriteBatch, this.OpsSubRect, Color.Black);
                this.OpsSL.Draw(this.ScreenManager.SpriteBatch);
                for (int i = this.OpsSL.indexAtTop; i < this.OpsSL.Entries.Count && i < this.OpsSL.indexAtTop + this.OpsSL.entriesToDisplay; i++)
                {
                    try
                    {
                        ScrollList.Entry e = this.OpsSL.Entries[i];
                        (e.item as MissionEntry).Draw(this.ScreenManager, e.clickRect);
                    }
                    catch
                    {
                    }
                }
            }
        }
        public override void LoadContent()
        {
            if (base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth <= 1366 || base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight <= 720)
            {
                this.LowRes = true;
            }
            Rectangle titleRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 203, (this.LowRes ? 10 : 44), 406, 80);
            Rectangle nameRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - (int)((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 0.5f) / 2, titleRect.Y + titleRect.Height + 5, (int)((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 0.5f), 150);
            Rectangle leftRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - (int)((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 0.5f) / 2, nameRect.Y + nameRect.Height + 5, (int)((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 0.5f), base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - (titleRect.Y + titleRect.Height) - (int)(0.28f * (float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight));
            if (leftRect.Height > 580)
            {
                leftRect.Height = 580;
            }
            this.close = new CloseButton(new Rectangle(leftRect.X + leftRect.Width - 40, leftRect.Y + 20, 20, 20));

            Rectangle ftlRect = new Rectangle(leftRect.X + 60, leftRect.Y + 100, 270, 50);
            this.FTLPenaltySlider = new FloatSlider(ftlRect, Localizer.Token(4007));
            this.FTLPenaltySlider.SetAmount(GlobalStats.FTLInSystemModifier);
            this.FTLPenaltySlider.amount = GlobalStats.FTLInSystemModifier;

            Rectangle EftlRect = new Rectangle(leftRect.X + 60, leftRect.Y + 150, 270, 50);
            this.EnemyFTLPenaltySlider = new FloatSlider(EftlRect, Localizer.Token(6139));
            this.EnemyFTLPenaltySlider.SetAmount(GlobalStats.EnemyFTLInSystemModifier);
            this.EnemyFTLPenaltySlider.amount = GlobalStats.EnemyFTLInSystemModifier;

            Ref<bool> acomRef = new Ref<bool>(() => GlobalStats.PlanetaryGravityWells, (bool x) => GlobalStats.PlanetaryGravityWells = x);
            Checkbox cb = new Checkbox(new Vector2((float)ftlRect.X, (float)(ftlRect.Y + 100)), Localizer.Token(4008), acomRef, Fonts.Arial12Bold);
            this.Checkboxes.Add(cb);

            cb.Tip_Token = 2288;

            //Added by McShooterz: new checkbox to prevent AI federations
            Ref<bool> pfRef = new Ref<bool>(() => GlobalStats.preventFederations, (bool x) => GlobalStats.preventFederations = x);
            Checkbox cb2 = new Checkbox(new Vector2((float)(ftlRect.X + 500), (float)(ftlRect.Y)), Localizer.Token(6022), pfRef, Fonts.Arial12Bold);
            this.Checkboxes.Add(cb2);

            cb2.Tip_Token = 7011;

            Ref<bool> FTLsRef = new Ref<bool>(() => GlobalStats.WarpInSystem, (bool x) => GlobalStats.WarpInSystem = x);
            Checkbox cb3 = new Checkbox(new Vector2((float)(ftlRect.X + 500), (float)(EftlRect.Y)), Localizer.Token(6178), FTLsRef, Fonts.Arial12Bold);
            this.Checkboxes.Add(cb3);

            Rectangle gwRect = new Rectangle(leftRect.X + 60, leftRect.Y + 220, 270, 50);
            this.GravityWellSize = new FloatSlider(gwRect, Localizer.Token(6002),0,20000,GlobalStats.GravityWellRange);

            //added by gremlin init extra planets slider
            Rectangle epRect = new Rectangle(leftRect.X + 60, leftRect.Y + 280, 270, 50);
            this.extraPlanets = new FloatSlider(epRect, "Extra Planets",0,6f,(float)GlobalStats.ExtraPlanets);

            Rectangle StartingPlanetRichness = new Rectangle(leftRect.X  + 60, leftRect.Y + 340, 270, 50);
            this.StartingPlanetRichness = new FloatSlider(StartingPlanetRichness, "Starting Planet Richness Bonus", 0, 5f, GlobalStats.StartingPlanetRichness);
            Rectangle MinimumWarpRange = new Rectangle(leftRect.X *2 + 60, leftRect.Y + 340, 270, 50);
            this.MinimumWarpRange = new FloatSlider(MinimumWarpRange, "Minimum Warp Range", 0, 1200000f, GlobalStats.MinimumWarpRange);
            Rectangle MemoryLimiter = new Rectangle(leftRect.X + 60, leftRect.Y + 400, 270, 50);
            this.MemoryLimiter = new FloatSlider(MemoryLimiter, "Memory Limit", 150000, 300000f, GlobalStats.MemoryLimiter);
            Rectangle OptionIncreaseShipMaintenance = new Rectangle(leftRect.X *2 + 60, leftRect.Y + 400, 270, 50);
            this.OptionIncreaseShipMaintenance = new FloatSlider(OptionIncreaseShipMaintenance, "Increase Maintenance", 1, 10f, GlobalStats.OptionIncreaseShipMaintenance);
            //Added by McShooterz: slider to change time for turns
            Rectangle OptionTurnTimer = new Rectangle(leftRect.X * 2 + 60, leftRect.Y + 275, 270, 50);
            this.TurnTimer = new FloatSlider(OptionTurnTimer, "Change Turn Timer", 2f, 18f, GlobalStats.TurnTimer);

            this.MainMenu = new Menu2(base.ScreenManager, leftRect);
        }
        public override void LoadContent()
        {
            LightRig rig = base.ScreenManager.Content.Load<LightRig>("example/ShipyardLightrig");
            lock (GlobalStats.ObjectManagerLocker)
            {
                base.ScreenManager.inter.LightManager.Clear();
                base.ScreenManager.inter.LightManager.Submit(rig);
            }
            if (base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth <= 1280 || base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight <= 768)
            {
                this.LowRes = true;
            }
            Rectangle leftRect = new Rectangle(5, 45, 405, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 45 - (int)(0.4f * (float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight) + 10);
            this.ModuleSelectionMenu = new Menu1(base.ScreenManager, leftRect);
            Rectangle modSelR = new Rectangle(0, (this.LowRes ? 45 : 100), 305, (this.LowRes ? 350 : 400));
            this.modSel = new Submenu(base.ScreenManager, modSelR, true);
            this.modSel.AddTab("Wpn");
            this.modSel.AddTab("Pwr");
            this.modSel.AddTab("Def");
            this.modSel.AddTab("Spc");
            this.weaponSL = new ScrollList(this.modSel);
            Vector2 Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 175), 80f);
            Rectangle active = new Rectangle(modSelR.X, modSelR.Y + modSelR.Height + 15, modSelR.Width, 300);
            this.activeModWindow = new Menu1(base.ScreenManager, active);
            Rectangle acsub = new Rectangle(active.X, modSelR.Y + modSelR.Height + 15, 305, 320);
            if (base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight > 760)
            {
                acsub.Height = acsub.Height + 120;
            }
            this.activeModSubMenu = new Submenu(base.ScreenManager, acsub);
            this.activeModSubMenu.AddTab("Active Module");
            this.choosefighterrect = new Rectangle(acsub.X + acsub.Width + 5, acsub.Y, 240, 270);
            if (this.choosefighterrect.Y + this.choosefighterrect.Height > base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight)
            {
                int diff = this.choosefighterrect.Y + this.choosefighterrect.Height - base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight;
                this.choosefighterrect.Height = this.choosefighterrect.Height - (diff + 10);
            }
            this.choosefighterrect.Height = acsub.Height;
            this.ChooseFighterSub = new Submenu(base.ScreenManager, this.choosefighterrect);
            this.ChooseFighterSub.AddTab("Choose Fighter");
            this.ChooseFighterSL = new ScrollList(this.ChooseFighterSub, 40);
            foreach (KeyValuePair<string, bool> hull in EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetHDict())
            {
                if (!hull.Value)
                {
                    continue;
                }
                this.AvailableHulls.Add(Ship_Game.ResourceManager.HullsDict[hull.Key]);
            }
            PrimitiveQuad.graphicsDevice = base.ScreenManager.GraphicsDevice;
            float width = (float)base.ScreenManager.GraphicsDevice.Viewport.Width;
            Viewport viewport = base.ScreenManager.GraphicsDevice.Viewport;
            float aspectRatio = width / (float)viewport.Height;
            this.offset = new Vector2();
            Viewport viewport1 = base.ScreenManager.GraphicsDevice.Viewport;
            this.offset.X = (float)(viewport1.Width / 2 - 256);
            Viewport viewport2 = base.ScreenManager.GraphicsDevice.Viewport;
            this.offset.Y = (float)(viewport2.Height / 2 - 256);
            this.camera = new Camera2d();
            Camera2d vector2 = this.camera;
            Viewport viewport3 = base.ScreenManager.GraphicsDevice.Viewport;
            float single = (float)viewport3.Width / 2f;
            Viewport viewport4 = base.ScreenManager.GraphicsDevice.Viewport;
            vector2.Pos = new Vector2(single, (float)viewport4.Height / 2f);
            Vector3 camPos = this.cameraPosition * new Vector3(-1f, 1f, 1f);
            this.view = ((Matrix.CreateTranslation(0f, 0f, 0f) * Matrix.CreateRotationY(MathHelper.ToRadians(180f))) * Matrix.CreateRotationX(MathHelper.ToRadians(0f))) * Matrix.CreateLookAt(camPos, new Vector3(camPos.X, camPos.Y, 0f), new Vector3(0f, -1f, 0f));
            this.projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f, aspectRatio, 1f, 20000f);
            this.ChangeHull(this.AvailableHulls[0]);
            lock (GlobalStats.ObjectManagerLocker)
            {
                if (!this.ActiveHull.Animated)
                {
                    this.ActiveModel = base.ScreenManager.Content.Load<Model>(this.ActiveHull.ModelPath);
                    this.CreateSOFromHull();
                }
                else
                {
                    base.ScreenManager.inter.ObjectManager.Remove(this.shipSO);
                    SkinnedModel sm = Ship_Game.ResourceManager.GetSkinnedModel(this.ActiveHull.ModelPath);
                    this.shipSO = new SceneObject(sm.Model)
                    {
                        ObjectType = ObjectType.Dynamic,
                        World = this.worldMatrix
                    };
                    base.ScreenManager.inter.ObjectManager.Submit(this.shipSO);
                    this.SetupSlots();
                }
            }
            foreach (ModuleSlotData slot in this.ActiveHull.ModuleSlotList)
            {
                if (slot.Position.X < this.LowestX)
                {
                    this.LowestX = slot.Position.X;
                }
                if (slot.Position.X <= this.HighestX)
                {
                    continue;
                }
                this.HighestX = slot.Position.X;
            }
            float xDistance = this.HighestX - this.LowestX;
            BoundingSphere bs = this.shipSO.WorldBoundingSphere;
            Viewport viewport5 = base.ScreenManager.GraphicsDevice.Viewport;
            Vector3 pScreenSpace = viewport5.Project(Vector3.Zero, this.projection, this.view, Matrix.Identity);
            Vector2 pPos = new Vector2(pScreenSpace.X, pScreenSpace.Y);
            Vector2 radialPos = this.GeneratePointOnCircle(90f, Vector2.Zero, xDistance);
            Viewport viewport6 = base.ScreenManager.GraphicsDevice.Viewport;
            Vector3 insetRadialPos = viewport6.Project(new Vector3(radialPos, 0f), this.projection, this.view, Matrix.Identity);
            Vector2 insetRadialSS = new Vector2(insetRadialPos.X, insetRadialPos.Y);
            float Radius = Vector2.Distance(insetRadialSS, pPos) + 10f;
            if (Radius >= xDistance)
            {
                while (Radius > xDistance)
                {
                    camPos = this.cameraPosition * new Vector3(-1f, 1f, 1f);
                    this.view = ((Matrix.CreateTranslation(0f, 0f, 0f) * Matrix.CreateRotationY(MathHelper.ToRadians(180f))) * Matrix.CreateRotationX(MathHelper.ToRadians(0f))) * Matrix.CreateLookAt(camPos, new Vector3(camPos.X, camPos.Y, 0f), new Vector3(0f, -1f, 0f));
                    bs = this.shipSO.WorldBoundingSphere;
                    Viewport viewport7 = base.ScreenManager.GraphicsDevice.Viewport;
                    pScreenSpace = viewport7.Project(Vector3.Zero, this.projection, this.view, Matrix.Identity);
                    pPos = new Vector2(pScreenSpace.X, pScreenSpace.Y);
                    radialPos = this.GeneratePointOnCircle(90f, Vector2.Zero, xDistance);
                    Viewport viewport8 = base.ScreenManager.GraphicsDevice.Viewport;
                    insetRadialPos = viewport8.Project(new Vector3(radialPos, 0f), this.projection, this.view, Matrix.Identity);
                    insetRadialSS = new Vector2(insetRadialPos.X, insetRadialPos.Y);
                    Radius = Vector2.Distance(insetRadialSS, pPos) + 10f;
                    this.cameraPosition.Z = this.cameraPosition.Z + 1f;
                }
            }
            else
            {
                while (Radius < xDistance)
                {
                    camPos = this.cameraPosition * new Vector3(-1f, 1f, 1f);
                    this.view = ((Matrix.CreateTranslation(0f, 0f, 0f) * Matrix.CreateRotationY(MathHelper.ToRadians(180f))) * Matrix.CreateRotationX(MathHelper.ToRadians(0f))) * Matrix.CreateLookAt(camPos, new Vector3(camPos.X, camPos.Y, 0f), new Vector3(0f, -1f, 0f));
                    bs = this.shipSO.WorldBoundingSphere;
                    Viewport viewport9 = base.ScreenManager.GraphicsDevice.Viewport;
                    pScreenSpace = viewport9.Project(Vector3.Zero, this.projection, this.view, Matrix.Identity);
                    pPos = new Vector2(pScreenSpace.X, pScreenSpace.Y);
                    radialPos = this.GeneratePointOnCircle(90f, Vector2.Zero, xDistance);
                    Viewport viewport10 = base.ScreenManager.GraphicsDevice.Viewport;
                    insetRadialPos = viewport10.Project(new Vector3(radialPos, 0f), this.projection, this.view, Matrix.Identity);
                    insetRadialSS = new Vector2(insetRadialPos.X, insetRadialPos.Y);
                    Radius = Vector2.Distance(insetRadialSS, pPos) + 10f;
                    this.cameraPosition.Z = this.cameraPosition.Z - 1f;
                }
            }
            this.BlackBar = new Rectangle(0, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 70, 3000, 70);
            this.SideBar = new Rectangle(0, 0, 280, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight);
            Rectangle w = new Rectangle(20, this.modSel.Menu.Y - 10, 32, 32);
            Rectangle p = new Rectangle(80, w.Y, 32, 32);
            Rectangle df = new Rectangle(150, w.Y, 32, 32);
            Rectangle sp = new Rectangle(220, w.Y, 32, 32);
            this.wpn = new SkinnableButton(w, "Modules/FlakTurret3x3")
            {
                IsToggle = true,
                Toggled = true
            };
            this.pwr = new SkinnableButton(p, "Modules/NuclearReactorMedium")
            {
                IsToggle = true
            };
            this.def = new SkinnableButton(df, "Modules/SteelArmorMedium")
            {
                IsToggle = true
            };
            this.spc = new SkinnableButton(sp, "Modules/sensors_2x2")
            {
                IsToggle = true
            };
            this.SelectedCatTextPos = new Vector2(20f, (float)(w.Y - 25 - Fonts.Arial20Bold.LineSpacing / 2));
            this.SearchBar = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 585, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 47, 210, 25);
            Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 370), (float)(modSelR.Y + modSelR.Height + 408));
            Vector2 OrdersBarPos = new Vector2(Cursor.X - 60f, (float)((int)Cursor.Y + 10));
            ToggleButton AttackRuns = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_headon");
            this.CombatStatusButtons.Add(AttackRuns);
            AttackRuns.Action = "attack";
            AttackRuns.HasToolTip = true;
            AttackRuns.WhichToolTip = 1;
            OrdersBarPos.X = OrdersBarPos.X + 29f;
            ToggleButton Artillery = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_aft");
            this.CombatStatusButtons.Add(Artillery);
            Artillery.Action = "arty";
            Artillery.HasToolTip = true;
            Artillery.WhichToolTip = 2;
            OrdersBarPos.X = OrdersBarPos.X + 29f;
            ToggleButton HoldPos = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_x");
            this.CombatStatusButtons.Add(HoldPos);
            HoldPos.Action = "hold";
            HoldPos.HasToolTip = true;
            HoldPos.WhichToolTip = 65;
            OrdersBarPos.X = OrdersBarPos.X + 29f;
            ToggleButton OrbitLeft = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_left");
            this.CombatStatusButtons.Add(OrbitLeft);
            OrbitLeft.Action = "orbit_left";
            OrbitLeft.HasToolTip = true;
            OrbitLeft.WhichToolTip = 3;
            OrdersBarPos.Y = OrdersBarPos.Y + 29f;

            ToggleButton BroadsideLeft = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_bleft");
            this.CombatStatusButtons.Add(BroadsideLeft);
            BroadsideLeft.Action = "broadside_left";
            BroadsideLeft.HasToolTip = true;
            BroadsideLeft.WhichToolTip = 159;
            OrdersBarPos.Y = OrdersBarPos.Y - 29f;
            OrdersBarPos.X = OrdersBarPos.X + 29f;
            ToggleButton OrbitRight = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_right");
            this.CombatStatusButtons.Add(OrbitRight);
            OrbitRight.Action = "orbit_right";
            OrbitRight.HasToolTip = true;
            OrbitRight.WhichToolTip = 4;
            OrdersBarPos.Y = OrdersBarPos.Y + 29f;

            ToggleButton BroadsideRight = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_bright");
            this.CombatStatusButtons.Add(BroadsideRight);
            BroadsideRight.Action = "broadside_right";
            BroadsideRight.HasToolTip = true;
            BroadsideRight.WhichToolTip = 160;
            OrdersBarPos.Y = OrdersBarPos.Y - 29f;
            OrdersBarPos.X = OrdersBarPos.X + 29f;
            ToggleButton Evade = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_stop");
            this.CombatStatusButtons.Add(Evade);
            Evade.Action = "evade";
            Evade.HasToolTip = true;
            Evade.WhichToolTip = 6;

            Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 150), (float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 47);

            this.SaveButton = new UIButton()
            {
                Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height),
                NormalTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"],
                HoverTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_hover"],
                PressedTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_pressed"],
                Text = Localizer.Token(105),
                Launches = "Save As..."
            };
            this.Buttons.Add(this.SaveButton);
            this.LoadButton = new UIButton()
            {
                Rect = new Rectangle((int)Cursor.X - 78, (int)Cursor.Y, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Width, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height),
                NormalTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"],
                HoverTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_hover"],
                PressedTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_pressed"],
                Text = Localizer.Token(8),
                Launches = "Load"
            };
            this.Buttons.Add(this.LoadButton);
            this.ToggleOverlayButton = new UIButton()
            {
                Rect = new Rectangle(this.LoadButton.Rect.X - 140, (int)Cursor.Y, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height),
                NormalTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"],
                HoverTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_hover"],
                PressedTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_pressed"],
                Launches = "Toggle Overlay",
                Text = Localizer.Token(106)
            };
            this.Buttons.Add(this.ToggleOverlayButton);
            this.bottom_sep = new Rectangle(this.BlackBar.X, this.BlackBar.Y, this.BlackBar.Width, 1);
            this.HullSelectionRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 285, (this.LowRes ? 45 : 100), 280, (this.LowRes ? 350 : 400));
            this.hullSelectionSub = new Submenu(base.ScreenManager, this.HullSelectionRect, true);
            this.weaponSL = new ScrollList(this.modSel);
            this.hullSelectionSub.AddTab(Localizer.Token(107));
            this.hullSL = new ScrollList(this.hullSelectionSub);
            List<string> Categories = new List<string>();
            foreach (KeyValuePair<string, ShipData> hull in Ship_Game.ResourceManager.HullsDict)
            {
                if (!EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetHDict()[hull.Key])
                {
                    continue;
                }
                string cat = Localizer.GetRole(hull.Value.Role, EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty));
                if (Categories.Contains(cat))
                {
                    continue;
                }
                Categories.Add(cat);
            }
            Categories.Sort();
            foreach (string cat in Categories)
            {
                ModuleHeader type = new ModuleHeader(cat, 240f);
                this.hullSL.AddItem(type);
            }
            foreach (ScrollList.Entry e in this.hullSL.Entries)
            {
                foreach (KeyValuePair<string, ShipData> hull in Ship_Game.ResourceManager.HullsDict)
                {
                    if (!EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetHDict()[hull.Key] || !((e.item as ModuleHeader).Text == Localizer.GetRole(hull.Value.Role, EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty))))
                    {
                        continue;
                    }
                    e.AddItem(hull.Value);
                }
            }
            Rectangle ShipStatsPanel = new Rectangle(this.HullSelectionRect.X + 50, this.HullSelectionRect.Y + this.HullSelectionRect.Height - 20, 280, 320);

            this.classifCursor = new Vector2(ShipStatsPanel.X - 100, ShipStatsPanel.Y + ShipStatsPanel.Height + 92);

            dropdownRect = new Rectangle((int)ShipStatsPanel.X, (int)ShipStatsPanel.Y + ShipStatsPanel.Height + 118, 100, 18);

            this.CategoryList = new DropOptions(dropdownRect);
            this.CategoryList.AddOption("Unclassified", 1);
            this.CategoryList.AddOption("Civilian", 2);
            this.CategoryList.AddOption("Recon", 3);
            this.CategoryList.AddOption("Fighter", 4);
            this.CategoryList.AddOption("Bomber", 5);

            this.CarrierOnly = this.ActiveHull.CarrierShip;
            Ref<bool> CORef = new Ref<bool>(() => this.CarrierOnly, (bool x) => {
                this.CarrierOnly = x;
            });

            this.COBoxCursor = new Vector2(dropdownRect.X + 106, dropdownRect.Y);
            this.CarrierOnlyBox = new Checkbox(this.COBoxCursor, "Carrier Only", CORef, Fonts.Arial12Bold);

            this.ShipStats = new Menu1(base.ScreenManager, ShipStatsPanel);
            this.statsSub = new Submenu(base.ScreenManager, ShipStatsPanel);
            this.statsSub.AddTab(Localizer.Token(108));
            this.ArcsButton = new GenericButton(new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 32), 97f), "Arcs", Fonts.Pirulen20, Fonts.Pirulen16);
            this.close = new CloseButton(new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 27, 99, 20, 20));
            this.OriginalZ = this.cameraPosition.Z;
        }
 private void CancelChanges(object sender, EventArgs e1)
 {
     Game1.Instance.graphics.PreferredBackBufferWidth = this.startingx;
     Game1.Instance.graphics.PreferredBackBufferHeight = this.startingy;
     Game1.Instance.graphics.SynchronizeWithVerticalRetrace = false;
     Game1.Instance.SetWindowMode(this.StartingMode, this.startingx, this.startingy);
     this.ModeToSet = this.StartingMode;
     base.Setup();
     if (this.FromGame)
     {
         this.uScreen.LoadGraphics();
         this.gpmmscreen.LoadGraphics();
         this.LoadGraphics();
     }
     else
     {
         this.mmscreen.Buttons.Clear();
         this.mmscreen.LoadContent();
     }
     this.MainOptionsRect = new Rectangle(this.r.X + 20, this.r.Y + 175, 300, 375);
     this.SecondaryOptionsRect = new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width, this.MainOptionsRect.Y, 210, 305);
     this.GamespeedCap = new Checkbox(new Vector2((float)(this.MainOptionsRect.X + 20), (float)(this.MainOptionsRect.Y + 300)), Localizer.Token(2206), new Ref<bool>(() => GlobalStats.LimitSpeed, (bool x) => GlobalStats.LimitSpeed = x), Fonts.Arial12Bold)
     {
         Tip_Token = 2205
     };
     this.Resolution = new OptionsScreen.Option()
     {
         Name = string.Concat(Localizer.Token(9), ":     "),
         NamePosition = new Vector2((float)(this.MainOptionsRect.X + 20), (float)(this.MainOptionsRect.Y + 20))
     };
     string xResolution = base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth.ToString();
     string yResolution = base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight.ToString();
     this.xtoApply = base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth;
     this.ytoApply = base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight;
     string reso = string.Concat(xResolution, " x ", yResolution);
     this.Resolution.ClickableArea = new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.Resolution.NamePosition.Y, (int)Fonts.Arial20Bold.MeasureString(reso).X, Fonts.Arial20Bold.LineSpacing);
     this.Resolution.Value = reso;
     this.Resolution.highlighted = false;
     this.FullScreen = new OptionsScreen.Option()
     {
         Name = string.Concat(Localizer.Token(10), ":     "),
         NamePosition = new Vector2((float)(this.MainOptionsRect.X + 20), (float)(this.MainOptionsRect.Y + Fonts.Arial20Bold.LineSpacing * 2 + 2 + 20)),
         Value = Game1.Instance.CurrentMode,
         ClickableArea = new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.FullScreen.NamePosition.Y, (int)Fonts.Arial20Bold.MeasureString(this.FullScreen.Value.ToString()).X, Fonts.Arial20Bold.LineSpacing)
     };
     Rectangle ftlRect = new Rectangle(this.MainOptionsRect.X + 20, (int)this.FullScreen.NamePosition.Y + 40, 270, 50);
     this.MusicVolumeSlider = new FloatSlider(ftlRect, "Music Volume");
     this.MusicVolumeSlider.SetAmount(GlobalStats.Config.MusicVolume);
     this.MusicVolumeSlider.amount = GlobalStats.Config.MusicVolume;
     ftlRect = new Rectangle(this.MainOptionsRect.X + 20, (int)ftlRect.Y + 50, 270, 50);
     this.EffectsVolumeSlider = new FloatSlider(ftlRect, "Effects Volume");
     this.EffectsVolumeSlider.SetAmount(GlobalStats.Config.EffectsVolume);
     this.EffectsVolumeSlider.amount = GlobalStats.Config.EffectsVolume;
     Vector2 Cursor = new Vector2((float)(this.SecondaryOptionsRect.X + 10), (float)(this.SecondaryOptionsRect.Y + 10));
     this.ResolutionOptions.Clear();
     this.ResolutionDropDown = new DropOptions(new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.Resolution.NamePosition.Y + 3, 105, 18));
     foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
     {
         if (mode.Width < 1280)
         {
             continue;
         }
         OptionsScreen.Option reso1 = new OptionsScreen.Option();
         //{
             reso1.x = mode.Width;
             reso1.y = mode.Height;
             reso1.Name = string.Concat(reso1.x.ToString(), " x ", reso1.y.ToString());
             reso1.NamePosition = Cursor;
             reso1.ClickableArea = new Rectangle((int)reso1.NamePosition.X, (int)reso1.NamePosition.Y, (int)Fonts.Arial12Bold.MeasureString(reso1.Name).X, Fonts.Arial12Bold.LineSpacing);
         //};
         bool oktoadd = true;
         foreach (OptionsScreen.Option opt in this.ResolutionOptions)
         {
             if (opt.x != reso1.x || opt.y != reso1.y)
             {
                 continue;
             }
             oktoadd = false;
         }
         if (!oktoadd)
         {
             continue;
         }
         this.ResolutionDropDown.AddOption(reso1.Name, reso1);
         this.ResolutionOptions.Add(reso1);
         Cursor.Y = Cursor.Y + (float)Fonts.Arial12Bold.LineSpacing;
     }
     foreach (OptionsScreen.Option resolut in this.ResolutionOptions)
     {
         if (base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth != resolut.x || base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight != resolut.y)
         {
             continue;
         }
         foreach (Entry e in this.ResolutionDropDown.Options)
         {
             if ((e.ReferencedObject as OptionsScreen.Option).Name != resolut.Name)
             {
                 continue;
             }
             this.ResolutionDropDown.ActiveIndex = this.ResolutionDropDown.Options.IndexOf(e);
         }
     }
     Cursor = new Vector2((float)this.SecondaryOptionsRect.X, (float)(this.SecondaryOptionsRect.Y + this.SecondaryOptionsRect.Height + 15));
     this.Apply.Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height);
     this.Apply.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"];
     this.Apply.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"];
     this.Apply.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"];
     this.Apply.Text = Localizer.Token(13);
 }
        public override void LoadContent()
        {
            base.LoadContent();
            this.MainOptionsRect = new Rectangle(this.r.X + 20, this.r.Y + 175, 300, 375);

            this.Resolution = new OptionsScreen.Option();
            this.Resolution.Name = Localizer.Token(9) + ":";
            this.Resolution.NamePosition = new Vector2((float)(this.MainOptionsRect.X + 20), (float)this.MainOptionsRect.Y);

            this.GamespeedCap = new Checkbox(new Vector2((float)(this.MainOptionsRect.X + this.MainOptionsRect.Width + 5), (float)(this.Resolution.NamePosition.Y)), Localizer.Token(2206), new Ref<bool>((Func<bool>)(() => GlobalStats.LimitSpeed), (Action<bool>)(x => GlobalStats.LimitSpeed = x)), Fonts.Arial12Bold);
            this.GamespeedCap.Tip_Token = 2205;
            this.ForceFullSim = new Checkbox(new Vector2((float)(this.MainOptionsRect.X + this.MainOptionsRect.Width + 5), (float)(this.Resolution.NamePosition.Y + 30)), "Force Full Simulation", new Ref<bool>((Func<bool>)(() => GlobalStats.ForceFullSim), (Action<bool>)(x => GlobalStats.ForceFullSim = x)), Fonts.Arial12Bold);
            this.ForceFullSim.Tip_Token = 2205;
            this.pauseOnNotification = new Checkbox(new Vector2((float)(this.MainOptionsRect.X + this.MainOptionsRect.Width + 5), (float)(this.Resolution.NamePosition.Y + 60)), Localizer.Token(6007), new Ref<bool>((Func<bool>)(() => GlobalStats.PauseOnNotification), (Action<bool>)(x => GlobalStats.PauseOnNotification = x)), Fonts.Arial12Bold);
            this.pauseOnNotification.Tip_Token = 7004;

            this.KeyboardArc = new Checkbox(new Vector2((float)(this.MainOptionsRect.X + this.MainOptionsRect.Width + 5), (float)(this.Resolution.NamePosition.Y + 90)), Localizer.Token(6184), new Ref<bool>((Func<bool>)(() => GlobalStats.AltArcControl), (Action<bool>)(x => GlobalStats.AltArcControl = x)), Fonts.Arial12Bold);
            this.KeyboardArc.Tip_Token = 7081;

            this.SecondaryOptionsRect = new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width + 20, this.MainOptionsRect.Y, 210, 305);

            string str1 = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth.ToString();
            string str2 = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight.ToString();
            this.startingx = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth;
            this.startingy = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight;
            this.startingfullscreen = Game1.Instance.graphics.IsFullScreen;
            this.xtoApply = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth;
            this.ytoApply = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight;
            string text = str1 + " x " + str2;
            this.Resolution.ClickableArea = new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.Resolution.NamePosition.Y, (int)Fonts.Arial20Bold.MeasureString(text).X, Fonts.Arial20Bold.LineSpacing);
            this.Resolution.Value = (object)text;
            this.Resolution.highlighted = false;
            this.FullScreen = new OptionsScreen.Option();
            this.FullScreen.Name = Localizer.Token(10) + ":";
            this.FullScreen.NamePosition = new Vector2((float)(this.MainOptionsRect.X + 20), (float)(this.MainOptionsRect.Y + Fonts.Arial20Bold.LineSpacing * 2 + 2 + 17));
            this.FullScreen.Value = (object)((object)Game1.Instance.CurrentMode).ToString();
            this.FullScreen.ClickableArea = new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.FullScreen.NamePosition.Y, (int)Fonts.Arial20Bold.MeasureString(this.FullScreen.Value.ToString()).X, Fonts.Arial20Bold.LineSpacing);
            Rectangle r = new Rectangle(this.MainOptionsRect.X + 9, (int)this.FullScreen.NamePosition.Y + 65, 270, 50);
            this.MusicVolumeSlider = new FloatSlider(r, "Music Volume");
            this.MusicVolumeSlider.SetAmount(GlobalStats.Config.MusicVolume);
            this.MusicVolumeSlider.amount = GlobalStats.Config.MusicVolume;
            r = new Rectangle(this.MainOptionsRect.X + 9, (int)r.Y + 50, 270, 50);
            this.EffectsVolumeSlider = new FloatSlider(r, "Effects Volume");
            this.EffectsVolumeSlider.SetAmount(GlobalStats.Config.EffectsVolume);
            this.EffectsVolumeSlider.amount = GlobalStats.Config.EffectsVolume;

            r = new Rectangle(this.MainOptionsRect.X + 9, (int)this.FullScreen.NamePosition.Y + 185, 225, 50);
            this.IconSize = new FloatSlider(r, "Icon Sizes", 0, 30, GlobalStats.IconSize);

            r = new Rectangle(this.MainOptionsRect.X + 9, (int)this.FullScreen.NamePosition.Y + 235, 225, 50);

            this.memoryLimit = new FloatSlider(r, string.Concat("Memory limit. KBs In Use: ",(int)(GC.GetTotalMemory(true)/1000f)), 150000, 300000, GlobalStats.MemoryLimiter);
            int ships =0;
            if (Empire.universeScreen != null )
             ships= Empire.universeScreen.globalshipCount;
            r = new Rectangle(this.MainOptionsRect.X - 9 + this.MainOptionsRect.Width, (int)this.FullScreen.NamePosition.Y + 235, 225, 50);
            this.ShipLimiter = new FloatSlider(r, string.Concat("All AI Ship Limit. AI Ships: ", ships), 500, 3500, GlobalStats.ShipCountLimit);
            r = new Rectangle(this.MainOptionsRect.X - 9 + this.MainOptionsRect.Width, (int)this.FullScreen.NamePosition.Y + 185, 225, 50);
            this.FreighterLimiter = new FloatSlider(r, string.Concat("Per AI Freighter Limit."), 25, 125, GlobalStats.freighterlimit);
            Vector2 vector2 = new Vector2((float)(this.SecondaryOptionsRect.X + 10), (float)(this.SecondaryOptionsRect.Y + 10));

            this.ResolutionDropDown = new DropOptions(new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.Resolution.NamePosition.Y - 2, 105, 18));
            foreach (DisplayMode displayMode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
            {
                if (displayMode.Width >= 1280)
                {
                    OptionsScreen.Option option1 = new OptionsScreen.Option();
                    option1.x = displayMode.Width;
                    option1.y = displayMode.Height;
                    option1.Name = option1.x.ToString() + " x " + option1.y.ToString();
                    option1.NamePosition = vector2;
                    option1.ClickableArea = new Rectangle((int)option1.NamePosition.X, (int)option1.NamePosition.Y, (int)Fonts.Arial12Bold.MeasureString(option1.Name).X, Fonts.Arial12Bold.LineSpacing);
                    bool flag = true;
                    foreach (OptionsScreen.Option option2 in this.ResolutionOptions)
                    {
                        if (option2.x == option1.x && option2.y == option1.y)
                            flag = false;
                    }
                    if (flag)
                    {
                        this.ResolutionDropDown.AddOption(option1.Name, (object)option1);
                        this.ResolutionOptions.Add(option1);
                        vector2.Y += (float)Fonts.Arial12Bold.LineSpacing;
                    }
                }
            }
            int qualityLevels = 0;
            //this.AntiAliasingDD = new DropOptions(new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.Resolution.NamePosition.Y + 26, 105, 18));
            //if (GraphicsAdapter.DefaultAdapter.CheckDeviceMultiSampleType(DeviceType.Hardware, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Format, false, MultiSampleType.EightSamples, out qualityLevels))
            //    this.AntiAliasingDD.AddOption("8x AA", 8);
            //if (GraphicsAdapter.DefaultAdapter.CheckDeviceMultiSampleType(DeviceType.Hardware, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Format, false, MultiSampleType.EightSamples, out qualityLevels))
            //    this.AntiAliasingDD.AddOption("4x AA", 4);
            //if (GraphicsAdapter.DefaultAdapter.CheckDeviceMultiSampleType(DeviceType.Hardware, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Format, false, MultiSampleType.EightSamples, out qualityLevels))
            //    this.AntiAliasingDD.AddOption("2x AA", 2);
            //this.AntiAliasingDD.AddOption("No AA", 0);
            //this.AntiAliasingDD.ActiveIndex = 0;
            //switch (GlobalStats.Config.AASamples)
            //{
            //    case 0:
            //        this.AntiAliasingDD.ActiveIndex = 3;
            //        break;
            //    case 2:
            //        this.AntiAliasingDD.ActiveIndex = 2;
            //        break;
            //    case 4:
            //        this.AntiAliasingDD.ActiveIndex = 1;
            //        break;
            //    case 8:
            //        this.AntiAliasingDD.ActiveIndex = 0;
            //        break;
            //}
            foreach (OptionsScreen.Option option in this.ResolutionOptions)
            {
                if (this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth == option.x && this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight == option.y)
                {
                    foreach (Entry entry in this.ResolutionDropDown.Options)
                    {
                        if ((entry.ReferencedObject as OptionsScreen.Option).Name == option.Name)
                            this.ResolutionDropDown.ActiveIndex = this.ResolutionDropDown.Options.IndexOf(entry);
                    }
                }
            }
            vector2 = new Vector2((float)this.SecondaryOptionsRect.X, (float)(this.SecondaryOptionsRect.Y + this.SecondaryOptionsRect.Height + 60));
            this.Apply = new UIButton();
            this.Apply.Rect = new Rectangle((int)vector2.X, (int)vector2.Y, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height);
            this.Apply.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"];
            this.Apply.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"];
            this.Apply.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"];
            this.Apply.Text = Localizer.Token(13);
            this.Apply.Launches = "Apply Settings";
            this.Buttons.Add(this.Apply);
        }
        //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 ColonyScreen(Planet p, Ship_Game.ScreenManager ScreenManager, EmpireUIOverlay empUI)
        {
            this.eui = empUI;
            this.ScreenManager = ScreenManager;
            this.p = p;
            if (this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth <= 1366)
                this.LowRes = true;
            Rectangle theMenu1 = new Rectangle(2, 44, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 2 / 3, 80);
            this.TitleBar = new Menu2(ScreenManager, theMenu1);
            this.LeftColony = new ToggleButton(new Rectangle(theMenu1.X + 25, theMenu1.Y + 24, 14, 35), "SelectionBox/button_arrow_left", "SelectionBox/button_arrow_left", "SelectionBox/button_arrow_left_hover", "SelectionBox/button_arrow_left_hover", "");
            this.RightColony = new ToggleButton(new Rectangle(theMenu1.X + theMenu1.Width - 39, theMenu1.Y + 24, 14, 35), "SelectionBox/button_arrow_right", "SelectionBox/button_arrow_right", "SelectionBox/button_arrow_right_hover", "SelectionBox/button_arrow_right_hover", "");
            this.TitlePos = new Vector2((float)(theMenu1.X + theMenu1.Width / 2) - Fonts.Laserian14.MeasureString("Colony Overview").X / 2f, (float)(theMenu1.Y + theMenu1.Height / 2 - Fonts.Laserian14.LineSpacing / 2));
            Rectangle theMenu2 = new Rectangle(2, theMenu1.Y + theMenu1.Height + 5, theMenu1.Width, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - (theMenu1.Y + theMenu1.Height) - 7);
            this.LeftMenu = new Menu1(ScreenManager, theMenu2);
            Rectangle theMenu3 = new Rectangle(theMenu1.X + theMenu1.Width + 10, theMenu1.Y, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 3 - 15, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - theMenu1.Y - 2);
            this.RightMenu = new Menu1(ScreenManager, theMenu3);
            this.MoneyRect = new Rectangle(theMenu2.X + theMenu2.Width - 75, theMenu2.Y + 20, ResourceManager.TextureDict["NewUI/icon_money"].Width, ResourceManager.TextureDict["NewUI/icon_money"].Height);
            this.close = new CloseButton(new Rectangle(theMenu3.X + theMenu3.Width - 52, theMenu3.Y + 22, 20, 20));
            Rectangle theMenu4 = new Rectangle(theMenu2.X + 20, theMenu2.Y + 20, (int)(0.400000005960464 * (double)theMenu2.Width), (int)(0.25 * (double)(theMenu2.Height - 80)));
            this.PlanetInfo = new Submenu(ScreenManager, theMenu4);
            this.PlanetInfo.AddTab(Localizer.Token(326));
            Rectangle theMenu5 = new Rectangle(theMenu2.X + 20, theMenu2.Y + 20 + theMenu4.Height, (int)(0.400000005960464 * (double)theMenu2.Width), (int)(0.25 * (double)(theMenu2.Height - 80)));
            this.pDescription = new Submenu(ScreenManager, theMenu5);
            Rectangle theMenu6 = new Rectangle(theMenu2.X + 20, theMenu2.Y + 20 + theMenu4.Height + theMenu5.Height + 20, (int)(0.400000005960464 * (double)theMenu2.Width), (int)(0.25 * (double)(theMenu2.Height - 80)));
            this.pLabor = new Submenu(ScreenManager, theMenu6);
            this.pLabor.AddTab(Localizer.Token(327));
            float num1 = (float)(int)((double)theMenu6.Width * 0.600000023841858);
            while ((double)num1 % 10.0 != 0.0)
                ++num1;
            Rectangle rectangle1 = new Rectangle(theMenu6.X + 60, theMenu6.Y + 25 + (int)(0.25 * (double)(theMenu6.Height - 25)), (int)num1, 6);
            this.SliderFood = new ColonyScreen.Slider();
            this.SliderFood.sRect = rectangle1;
            this.SliderFood.amount = p.FarmerPercentage;
            this.FoodLock = new ColonyScreen.Lock();
            this.FoodLock.LockRect = new Rectangle(this.SliderFood.sRect.X + this.SliderFood.sRect.Width + 50, this.SliderFood.sRect.Y + 2 + this.SliderFood.sRect.Height / 2 - ResourceManager.TextureDict[this.FoodLock.Path].Height / 2, ResourceManager.TextureDict[this.FoodLock.Path].Width, ResourceManager.TextureDict[this.FoodLock.Path].Height);
            if (p.Owner != null && p.Owner.data.Traits.Cybernetic > 0)
                p.FoodLocked = true;
            this.FoodLock.Locked = p.FoodLocked;
            Rectangle rectangle2 = new Rectangle(theMenu6.X + 60, theMenu6.Y + 25 + (int)(0.5 * (double)(theMenu6.Height - 25)), (int)num1, 6);
            this.SliderProd = new ColonyScreen.Slider();
            this.SliderProd.sRect = rectangle2;
            this.SliderProd.amount = p.WorkerPercentage;
            this.ProdLock = new ColonyScreen.Lock();
            this.ProdLock.LockRect = new Rectangle(this.SliderFood.sRect.X + this.SliderFood.sRect.Width + 50, this.SliderProd.sRect.Y + 2 + this.SliderFood.sRect.Height / 2 - ResourceManager.TextureDict[this.FoodLock.Path].Height / 2, ResourceManager.TextureDict[this.FoodLock.Path].Width, ResourceManager.TextureDict[this.FoodLock.Path].Height);
            this.ProdLock.Locked = p.ProdLocked;
            Rectangle rectangle3 = new Rectangle(theMenu6.X + 60, theMenu6.Y + 25 + (int)(0.75 * (double)(theMenu6.Height - 25)), (int)num1, 6);
            this.SliderRes = new ColonyScreen.Slider();
            this.SliderRes.sRect = rectangle3;
            this.SliderRes.amount = p.ResearcherPercentage;
            this.ResLock = new ColonyScreen.Lock();
            this.ResLock.LockRect = new Rectangle(this.SliderFood.sRect.X + this.SliderFood.sRect.Width + 50, this.SliderRes.sRect.Y + 2 + this.SliderFood.sRect.Height / 2 - ResourceManager.TextureDict[this.FoodLock.Path].Height / 2, ResourceManager.TextureDict[this.FoodLock.Path].Width, ResourceManager.TextureDict[this.FoodLock.Path].Height);
            this.ResLock.Locked = p.ResLocked;
            Rectangle theMenu7 = new Rectangle(theMenu2.X + 20, theMenu2.Y + 20 + theMenu4.Height + theMenu5.Height + theMenu6.Height + 40, (int)(0.400000005960464 * (double)theMenu2.Width), (int)(0.25 * (double)(theMenu2.Height - 80)));
            this.pStorage = new Submenu(ScreenManager, theMenu7);
            this.pStorage.AddTab(Localizer.Token(328));
            this.eui.screen.ShipsInCombat.Active = false;
            this.eui.screen.PlanetsInCombat.Active = false;

            if (GlobalStats.HardcoreRuleset)
            {
                int num2 = (theMenu7.Width - 40) / 4;
                this.ResourceButtons.Add(new ThreeStateButton(p.fs, "Food", new Vector2((float)(theMenu7.X + 20), (float)(theMenu7.Y + 30))));
                this.ResourceButtons.Add(new ThreeStateButton(p.ps, "Production", new Vector2((float)(theMenu7.X + 20 + num2), (float)(theMenu7.Y + 30))));
                this.ResourceButtons.Add(new ThreeStateButton(Planet.GoodState.EXPORT, "Fissionables", new Vector2((float)(theMenu7.X + 20 + num2 * 2), (float)(theMenu7.Y + 30))));
                this.ResourceButtons.Add(new ThreeStateButton(Planet.GoodState.EXPORT, "ReactorFuel", new Vector2((float)(theMenu7.X + 20 + num2 * 3), (float)(theMenu7.Y + 30))));
            }
            else
            {
                this.FoodStorage = new ProgressBar(new Rectangle(theMenu7.X + 100, theMenu7.Y + 25 + (int)(0.330000013113022 * (double)(theMenu7.Height - 25)), (int)(0.400000005960464 * (double)theMenu7.Width), 18));
                this.FoodStorage.Max = p.MAX_STORAGE;
                this.FoodStorage.Progress = p.FoodHere;
                this.FoodStorage.color = "green";
                this.foodDropDown = this.LowRes ? new DropDownMenu(new Rectangle(theMenu7.X + 90 + (int)(0.400000005960464 * (double)theMenu7.Width) + 20, this.FoodStorage.pBar.Y + this.FoodStorage.pBar.Height / 2 - 9, (int)(0.200000002980232 * (double)theMenu7.Width), 18)) : new DropDownMenu(new Rectangle(theMenu7.X + 100 + (int)(0.400000005960464 * (double)theMenu7.Width) + 20, this.FoodStorage.pBar.Y + this.FoodStorage.pBar.Height / 2 - 9, (int)(0.200000002980232 * (double)theMenu7.Width), 18));
                this.foodDropDown.AddOption(Localizer.Token(329));
                this.foodDropDown.AddOption(Localizer.Token(330));
                this.foodDropDown.AddOption(Localizer.Token(331));
                this.foodDropDown.ActiveIndex = (int)p.fs;
                this.foodStorageIcon = new Rectangle(theMenu7.X + 20, this.FoodStorage.pBar.Y + this.FoodStorage.pBar.Height / 2 - ResourceManager.TextureDict["NewUI/icon_storage_food"].Height / 2, ResourceManager.TextureDict["NewUI/icon_storage_food"].Width, ResourceManager.TextureDict["NewUI/icon_storage_food"].Height);
                this.ProdStorage = new ProgressBar(new Rectangle(theMenu7.X + 100, theMenu7.Y + 25 + (int)(0.660000026226044 * (double)(theMenu7.Height - 25)), (int)(0.400000005960464 * (double)theMenu7.Width), 18));
                this.ProdStorage.Max = p.MAX_STORAGE;
                this.ProdStorage.Progress = p.ProductionHere;
                this.profStorageIcon = new Rectangle(theMenu7.X + 20, this.ProdStorage.pBar.Y + this.ProdStorage.pBar.Height / 2 - ResourceManager.TextureDict["NewUI/icon_storage_food"].Height / 2, ResourceManager.TextureDict["NewUI/icon_storage_production"].Width, ResourceManager.TextureDict["NewUI/icon_storage_food"].Height);
                this.prodDropDown = this.LowRes ? new DropDownMenu(new Rectangle(theMenu7.X + 90 + (int)(0.400000005960464 * (double)theMenu7.Width) + 20, this.ProdStorage.pBar.Y + this.FoodStorage.pBar.Height / 2 - 9, (int)(0.200000002980232 * (double)theMenu7.Width), 18)) : new DropDownMenu(new Rectangle(theMenu7.X + 100 + (int)(0.400000005960464 * (double)theMenu7.Width) + 20, this.ProdStorage.pBar.Y + this.FoodStorage.pBar.Height / 2 - 9, (int)(0.200000002980232 * (double)theMenu7.Width), 18));
                this.prodDropDown.AddOption(Localizer.Token(329));
                this.prodDropDown.AddOption(Localizer.Token(330));
                this.prodDropDown.AddOption(Localizer.Token(331));
                this.prodDropDown.ActiveIndex = (int)p.ps;
            }
            Rectangle theMenu8 = new Rectangle(theMenu2.X + 20 + theMenu4.Width + 20, theMenu4.Y, theMenu2.Width - 60 - theMenu4.Width, (int)((double)theMenu2.Height * 0.5));
            this.subColonyGrid = new Submenu(ScreenManager, theMenu8);
            this.subColonyGrid.AddTab(Localizer.Token(332));
            Rectangle theMenu9 = new Rectangle(theMenu2.X + 20 + theMenu4.Width + 20, theMenu8.Y + theMenu8.Height + 20, theMenu2.Width - 60 - theMenu4.Width, theMenu2.Height - 20 - theMenu8.Height - 40);
            this.pFacilities = new Submenu(ScreenManager, theMenu9);
            this.pFacilities.AddTab(Localizer.Token(333));
            this.launchTroops = new UIButton();
            this.launchTroops.Rect = new Rectangle(theMenu9.X + theMenu9.Width - 175, theMenu9.Y - 5, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height);
            this.launchTroops.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"];
            this.launchTroops.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"];
            this.launchTroops.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"];
            this.launchTroops.Text = "Launch Troops";
            this.launchTroops.Launches = "Launch Troops";

            //fbedard: Add Send Troops button
            this.SendTroops = new UIButton();
            this.SendTroops.Rect = new Rectangle(theMenu9.X + theMenu9.Width - this.launchTroops.Rect.Width - 185, theMenu9.Y - 5, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height);
            this.SendTroops.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"];
            this.SendTroops.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"];
            this.SendTroops.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"];
            this.SendTroops.Text = "Send Troops";
            this.SendTroops.Launches = "Send Troops";

            this.CommoditiesSL = new ScrollList(this.pFacilities, 40);
            Rectangle theMenu10 = new Rectangle(theMenu3.X + 20, theMenu3.Y + 20, theMenu3.Width - 40, (int)(0.5 * (double)(theMenu3.Height - 60)));
            this.build = new Submenu(ScreenManager, theMenu10);
            this.build.AddTab(Localizer.Token(334));
            this.buildSL = new ScrollList(this.build);
            this.playerDesignsToggle = new ToggleButton(new Rectangle(this.build.Menu.X + this.build.Menu.Width - 270, this.build.Menu.Y, 29, 20), "SelectionBox/button_grid_active", "SelectionBox/button_grid_inactive", "SelectionBox/button_grid_hover", "SelectionBox/button_grid_pressed", "SelectionBox/icon_grid");
            this.playerDesignsToggle.Active = GlobalStats.ShowAllDesigns;
            if (p.HasShipyard)
                this.build.AddTab(Localizer.Token(335));
            if (p.AllowInfantry)
                this.build.AddTab(Localizer.Token(336));
            Rectangle theMenu11 = new Rectangle(theMenu3.X + 20, theMenu3.Y + 20 + 20 + theMenu10.Height, theMenu3.Width - 40, theMenu3.Height - 40 - theMenu10.Height - 20 - 3);
            this.queue = new Submenu(ScreenManager, theMenu11);
            this.queue.AddTab(Localizer.Token(337));
            this.QSL = new ScrollList(this.queue);
            this.QSL.IsDraggable = true;
            this.PlanetIcon = new Rectangle(theMenu4.X + theMenu4.Width - 148, theMenu4.Y + (theMenu4.Height - 25) / 2 - 64 + 25, 128, 128);
            this.gridPos = new Rectangle(this.subColonyGrid.Menu.X + 10, this.subColonyGrid.Menu.Y + 30, this.subColonyGrid.Menu.Width - 20, this.subColonyGrid.Menu.Height - 35);
            int width = this.gridPos.Width / 7;
            int height = this.gridPos.Height / 5;
            foreach (PlanetGridSquare planetGridSquare in p.TilesList)
                planetGridSquare.ClickRect = new Rectangle(this.gridPos.X + planetGridSquare.x * width, this.gridPos.Y + planetGridSquare.y * height, width, height);
            this.PlanetName.Text = p.Name;
            this.PlanetName.MaxCharacters = 12;
            if (p.Owner != null)
            {
                this.shipsCanBuildLast = p.Owner.ShipsWeCanBuild.Count;
                this.buildingsHereLast = p.BuildingList.Count;
                this.buildingsCanBuildLast = this.BuildingsCanBuild.Count;
                this.detailInfo = (object)p.Description;
                Rectangle rectangle4 = new Rectangle(this.pDescription.Menu.X + 10, this.pDescription.Menu.Y + 30, 124, 148);
                Rectangle rectangle5 = new Rectangle(rectangle4.X + rectangle4.Width + 20, rectangle4.Y + rectangle4.Height - 15, (int)Fonts.Pirulen16.MeasureString(Localizer.Token(370)).X, Fonts.Pirulen16.LineSpacing);
                this.GovernorDropdown = new DropOptions(new Rectangle(rectangle5.X + 30, rectangle5.Y + 30, 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(5087), 6);
                this.GovernorDropdown.ActiveIndex = ColonyScreen.GetIndex(p);
                if ((Planet.ColonyType)this.GovernorDropdown.Options[this.GovernorDropdown.ActiveIndex].value != this.p.colonyType)
                {
                    this.p.colonyType = (Planet.ColonyType)this.GovernorDropdown.Options[this.GovernorDropdown.ActiveIndex].value;
                    if (this.p.colonyType == Planet.ColonyType.Colony)
                    {
                        this.p.GovernorOn = false;
                        this.p.FoodLocked = false;
                        this.p.ProdLocked = false;
                        this.p.ResLocked = false;
                    }
                    else
                    {
                        this.p.FoodLocked = true;
                        this.p.ProdLocked = true;
                        this.p.ResLocked = true;
                        this.p.GovernorOn = true;
                    }
                }
                Ref<bool> connectedTo = new Ref<bool>((Func<bool>)(() => p.GovBuildings), (Action<bool>)(x => p.GovBuildings = x));
                Ref<bool> @ref = new Ref<bool>((Func<bool>)(() => p.GovSliders), (Action<bool>)(x => p.GovSliders = x));
                this.GovBuildings = new Checkbox(new Vector2((float)(rectangle5.X - 10), (float)(rectangle5.Y - (Fonts.Arial12Bold.LineSpacing * 2 + 15))), "Governor manages buildings", connectedTo, Fonts.Arial12Bold);
                this.GovSliders = new Checkbox(new Vector2((float)(rectangle5.X - 10), (float)(rectangle5.Y - (Fonts.Arial12Bold.LineSpacing + 10))), "Governor manages labor sliders", connectedTo, Fonts.Arial12Bold);
            }
            else
                PlanetScreen.screen.LookingAtPlanet = false;
        }
        //private bool AutoButtonHover;
        public PlanetListScreen(Ship_Game.ScreenManager ScreenManager, EmpireUIOverlay empUI)
        {
            this.empUI = empUI;
            base.TransitionOnTime = TimeSpan.FromSeconds(0.25);
            base.TransitionOffTime = TimeSpan.FromSeconds(0.25);
            base.IsPopup = true;
            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(1402)).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) - 15);
            this.sb_Sys = new SortButton(this.empUI.empire.data.PLSort, Localizer.Token(192));
            this.sb_Name = new SortButton(this.empUI.empire.data.PLSort, Localizer.Token(389));
            this.sb_Fert = new SortButton(this.empUI.empire.data.PLSort,Localizer.Token(386) );
            this.sb_Rich = new SortButton(this.empUI.empire.data.PLSort,Localizer.Token(387));
            this.sb_Pop = new SortButton(this.empUI.empire.data.PLSort,Localizer.Token(1403));
            this.sb_Owned = new SortButton(this.empUI.empire.data.PLSort, "Owner");

            while (this.eRect.Height % 40 != 0)
            {
                this.eRect.Height = this.eRect.Height - 1;
            }
            this.eRect.Height = this.eRect.Height - 20;
            this.ShipSubMenu = new Submenu(ScreenManager, this.eRect);
            this.PlanetSL = new ScrollList(this.ShipSubMenu, 40);
               // this.LastSorted = this.empUI.empire.data.PLSort;

            foreach (SolarSystem system in UniverseScreen.SolarSystemList.OrderBy(distance => Vector2.Distance(distance.Position, EmpireManager.GetEmpireByName(empUI.screen.PlayerLoyalty).GetWeightedCenter())))
            {
                foreach (Planet p in system.PlanetList)
                {
                    if (!p.ExploredDict[EmpireManager.GetEmpireByName(empUI.screen.PlayerLoyalty)])
                    {
                        continue;
                    }
                    this.planets.Add(p);
                }
            }
            //foreach (Planet p in this.planets)
            //{
            //    if (this.HideOwned && p.Owner != null || this.HideUninhab && !p.habitable)
            //    {
            //        continue;
            //    }
            //    PlanetListScreenEntry entry = new PlanetListScreenEntry(p, this.eRect.X + 22, this.leftRect.Y + 20, this.EMenu.Menu.Width - 30, 40, this);
            //    this.PlanetSL.AddItem(entry);
            //}

            //this.ResetList();
            //this.SelectedPlanet = (this.PlanetSL.Entries[this.PlanetSL.indexAtTop].item as PlanetListScreenEntry).planet;
            Ref<bool> aeRef = new Ref<bool>(() => this.HideOwned, (bool x) => {
                this.HideOwned = x;
                this.ResetList();
            });
            this.cb_hideOwned = new Checkbox(new Vector2((float)(this.TitleBar.Menu.X + this.TitleBar.Menu.Width + 15), (float)(this.TitleBar.Menu.Y + 15)), "Hide Owned", aeRef, Fonts.Arial12Bold);
            aeRef = new Ref<bool>(() => this.HideUninhab, (bool x) => {
                this.HideUninhab = x;
                this.ResetList();
            });
            this.cb_hideUninhabitable = new Checkbox(new Vector2((float)(this.TitleBar.Menu.X + this.TitleBar.Menu.Width + 15), (float)(this.TitleBar.Menu.Y + 35)), "Hide Uninhabitable", aeRef, Fonts.Arial12Bold);
            this.AutoButton = new Rectangle(0, 0, 243, 33);
        }