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 DrawModuleSelection()
        {
            Rectangle r = this.modSel.Menu;
            r.Y = r.Y + 25;
            r.Height = r.Height - 25;
            Selector sel = new Selector(base.ScreenManager, r, new Color(0, 0, 0, 210));
            sel.Draw();
            this.modSel.Draw();
            this.weaponSL.Draw(base.ScreenManager.SpriteBatch);
            float x = (float)Mouse.GetState().X;
            MouseState state = Mouse.GetState();
            Vector2 vector2 = new Vector2(x, (float)state.Y);
            if (this.modSel.Tabs[0].Selected)
            {
                if (this.Reset)
                {
                    this.weaponSL.Entries.Clear();
                    List<string> WeaponCategories = new List<string>();
                    foreach (KeyValuePair<string, ShipModule> module in Ship_Game.ResourceManager.ShipModulesDict)
                    {
                        if (!EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetMDict()[module.Key] || module.Value.UID == "Dummy")
                        {
                            continue;
                        }
                        module.Value.ModuleType.ToString();
                        ShipModule tmp = Ship_Game.ResourceManager.GetModule(module.Key);
                        tmp.SetAttributesNoParent();
                        bool restricted = tmp.FighterModule || tmp.CorvetteModule || tmp.FrigateModule || tmp.StationModule || tmp.DestroyerModule || tmp.CruiserModule
                            || tmp.CarrierModule || tmp.CapitalModule || tmp.FreighterModule || tmp.PlatformModule || tmp.DroneModule;
                        if (restricted)
                        {
                            if (this.ActiveHull.Role == "drone" && tmp.DroneModule == false)
                            {
                                continue;
                            }
                            if ((this.ActiveHull.Role == "fighter" || this.ActiveHull.Role == "scout" )&& tmp.FighterModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "corvette" && tmp.CorvetteModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "frigate" && tmp.FrigateModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "destroyer" && tmp.DestroyerModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "cruiser" && tmp.CruiserModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "carrier" && tmp.CarrierModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "capital" && tmp.CapitalModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "freighter" && tmp.FreighterModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "platform" && tmp.PlatformModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "station" && tmp.StationModule == false)
                            {
                                continue;
                            }
                        }
                            // if not using new tags, ensure original <FightersOnly> still functions as in vanilla.
                        else if (!restricted && tmp.FightersOnly && this.ActiveHull.Role != "fighter" && this.ActiveHull.Role != "scout" && this.ActiveHull.Role != "corvette")
                            continue;
                        if (tmp.isWeapon)
                        {
                            if (GlobalStats.ActiveModInfo != null && GlobalStats.ActiveModInfo.expandedWeaponCats)
                            {
                                if (tmp.InstalledWeapon.Tag_Flak && !WeaponCategories.Contains("Flak Cannon"))
                                {
                                    WeaponCategories.Add("Flak Cannon");
                                    ModuleHeader type = new ModuleHeader("Flak Cannon", 240f);
                                    this.weaponSL.AddItem(type);
                                }
                                if (tmp.InstalledWeapon.Tag_Railgun && !WeaponCategories.Contains("Magnetic Cannon"))
                                {
                                    WeaponCategories.Add("Magnetic Cannon");
                                    ModuleHeader type = new ModuleHeader("Magnetic Cannon", 240f);
                                    this.weaponSL.AddItem(type);
                                }
                                if (tmp.InstalledWeapon.Tag_Array && !WeaponCategories.Contains("Beam Array"))
                                {
                                    WeaponCategories.Add("Beam Array");
                                    ModuleHeader type = new ModuleHeader("Beam Array", 240f);
                                    this.weaponSL.AddItem(type);
                                }
                                if (tmp.InstalledWeapon.Tag_Tractor && !WeaponCategories.Contains("Tractor Beam"))
                                {
                                    WeaponCategories.Add("Tractor Beam");
                                    ModuleHeader type = new ModuleHeader("Tractor Beam", 240f);
                                    this.weaponSL.AddItem(type);
                                }
                                if (tmp.InstalledWeapon.Tag_Missile && !tmp.InstalledWeapon.Tag_Guided && !WeaponCategories.Contains("Unguided Rocket"))
                                {
                                    WeaponCategories.Add("Unguided Rocket");
                                    ModuleHeader type = new ModuleHeader("Unguided Rocket", 240f);
                                    this.weaponSL.AddItem(type);
                                }
                                else if (!WeaponCategories.Contains(tmp.InstalledWeapon.WeaponType))
                                {
                                    WeaponCategories.Add(tmp.InstalledWeapon.WeaponType);
                                    ModuleHeader type = new ModuleHeader(tmp.InstalledWeapon.WeaponType, 240f);
                                    this.weaponSL.AddItem(type);
                                }
                            }
                            else
                            {
                                if (!WeaponCategories.Contains(tmp.InstalledWeapon.WeaponType))
                                {
                                    WeaponCategories.Add(tmp.InstalledWeapon.WeaponType);
                                    ModuleHeader type = new ModuleHeader(tmp.InstalledWeapon.WeaponType, 240f);
                                    this.weaponSL.AddItem(type);
                                }
                            }
                        }
                        else if (tmp.ModuleType == ShipModuleType.Bomb && !WeaponCategories.Contains("Bomb"))
                        {
                            WeaponCategories.Add("Bomb");
                            ModuleHeader type = new ModuleHeader("Bomb", 240f);
                            this.weaponSL.AddItem(type);
                        }
                        tmp = null;
                    }
                    foreach (ScrollList.Entry e in this.weaponSL.Entries)
                    {
                        foreach (KeyValuePair<string, ShipModule> module in Ship_Game.ResourceManager.ShipModulesDict)
                        {
                            if (!EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetMDict()[module.Key] || module.Value.UID == "Dummy")
                            {
                                continue;
                            }
                            ShipModule tmp = Ship_Game.ResourceManager.GetModule(module.Key);
                            tmp.SetAttributesNoParent();
                            bool restricted = tmp.FighterModule || tmp.CorvetteModule || tmp.FrigateModule || tmp.StationModule || tmp.DestroyerModule || tmp.CruiserModule
                            || tmp.CarrierModule || tmp.CapitalModule || tmp.FreighterModule || tmp.PlatformModule || tmp.DroneModule;
                            if (restricted)
                            {
                                if (this.ActiveHull.Role == "drone" && tmp.DroneModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "scout" && tmp.FighterModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "fighter" && tmp.FighterModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "corvette" && tmp.CorvetteModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "frigate" && tmp.FrigateModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "destroyer" && tmp.DestroyerModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "cruiser" && tmp.CruiserModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "carrier" && tmp.CarrierModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "capital" && tmp.CapitalModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "freighter" && tmp.FreighterModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "platform" && tmp.PlatformModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "station" && tmp.StationModule == false)
                                {
                                    continue;
                                }
                            }
                            // if not using new tags, ensure original <FightersOnly> still functions as in vanilla.
                            else if (!restricted && tmp.FightersOnly && this.ActiveHull.Role != "fighter" && this.ActiveHull.Role != "scout" && this.ActiveHull.Role != "corvette")
                                continue;
                            if (tmp.isWeapon)
                            {
                                if (GlobalStats.ActiveModInfo != null && GlobalStats.ActiveModInfo.expandedWeaponCats)
                                {
                                    if (tmp.InstalledWeapon.Tag_Flak || tmp.InstalledWeapon.Tag_Array || tmp.InstalledWeapon.Tag_Railgun || tmp.InstalledWeapon.Tag_Tractor || (tmp.InstalledWeapon.Tag_Missile && !tmp.InstalledWeapon.Tag_Guided))
                                    {
                                        if ((e.item as ModuleHeader).Text == "Flak Cannon" && tmp.InstalledWeapon.Tag_Flak)
                                            e.AddItem(module.Value);
                                        if ((e.item as ModuleHeader).Text == "Magnetic Cannon" && tmp.InstalledWeapon.Tag_Railgun)
                                            e.AddItem(module.Value);
                                        if ((e.item as ModuleHeader).Text == "Beam Array" && tmp.InstalledWeapon.Tag_Array)
                                            e.AddItem(module.Value);
                                        if ((e.item as ModuleHeader).Text == "Tractor Beam" && tmp.InstalledWeapon.Tag_Tractor)
                                            e.AddItem(module.Value);
                                        if ((e.item as ModuleHeader).Text == "Unguided Rocket" && tmp.InstalledWeapon.Tag_Missile && !tmp.InstalledWeapon.Tag_Guided)
                                            e.AddItem(module.Value);
                                    }
                                    else if ((e.item as ModuleHeader).Text == tmp.InstalledWeapon.WeaponType)
                                    {
                                        e.AddItem(module.Value);
                                    }
                                }
                                else
                                {
                                    if ((e.item as ModuleHeader).Text == tmp.InstalledWeapon.WeaponType)
                                    {
                                        e.AddItem(module.Value);
                                    }
                                }
                            }
                            else if (tmp.ModuleType == ShipModuleType.Bomb && (e.item as ModuleHeader).Text == "Bomb")
                            {
                                e.AddItem(module.Value);
                            }
                            tmp = null;
                        }
                    }
                    this.Reset = false;
                }
                this.DrawList();
            }
            if (this.modSel.Tabs[2].Selected)
            {
                if (this.Reset)
                {
                    this.weaponSL.Entries.Clear();
                    List<string> ModuleCategories = new List<string>();
                    foreach (KeyValuePair<string, ShipModule> module in Ship_Game.ResourceManager.ShipModulesDict)
                    {
                        if (!EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetMDict()[module.Key] || module.Value.UID == "Dummy")
                        {
                            continue;
                        }
                        module.Value.ModuleType.ToString();
                        ShipModule tmp = Ship_Game.ResourceManager.GetModule(module.Key);
                        tmp.SetAttributesNoParent();
                        bool restricted = tmp.FighterModule || tmp.CorvetteModule || tmp.FrigateModule || tmp.StationModule || tmp.DestroyerModule || tmp.CruiserModule
                            || tmp.CarrierModule || tmp.CapitalModule || tmp.FreighterModule || tmp.PlatformModule || tmp.DroneModule;
                        if (restricted)
                        {
                            if (this.ActiveHull.Role == "drone" && tmp.DroneModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "scout" && tmp.FighterModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "fighter" && tmp.FighterModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "corvette" && tmp.CorvetteModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "frigate" && tmp.FrigateModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "destroyer" && tmp.DestroyerModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "cruiser" && tmp.CruiserModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "carrier" && tmp.CarrierModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "capital" && tmp.CapitalModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "freighter" && tmp.FreighterModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "platform" && tmp.PlatformModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "station" && tmp.StationModule == false)
                            {
                                continue;
                            }
                        }
                        // if not using new tags, ensure original <FightersOnly> still functions as in vanilla.
                        else if (!restricted && tmp.FightersOnly && this.ActiveHull.Role != "fighter" && this.ActiveHull.Role != "scout" && this.ActiveHull.Role != "corvette")
                            continue;
                        if ((tmp.ModuleType == ShipModuleType.Armor || tmp.ModuleType == ShipModuleType.Shield || tmp.ModuleType == ShipModuleType.Countermeasure) && !tmp.isBulkhead && !tmp.isPowerArmour && !ModuleCategories.Contains(tmp.ModuleType.ToString()))
                        {
                            ModuleCategories.Add(tmp.ModuleType.ToString());
                            ModuleHeader type = new ModuleHeader(tmp.ModuleType.ToString(), 240f);
                            this.weaponSL.AddItem(type);
                        }

                        // These need special booleans as they are ModuleType ARMOR - and the armor ModuleType is needed for vsArmor damage calculations - don't want to use new moduletype therefore.
                        if (tmp.isPowerArmour && tmp.ModuleType == ShipModuleType.Armor && !ModuleCategories.Contains(Localizer.Token(6172)))
                        {
                            ModuleCategories.Add(Localizer.Token(6172));
                            ModuleHeader type = new ModuleHeader(Localizer.Token(6172), 240f);
                            this.weaponSL.AddItem(type);
                        }
                        if (tmp.isBulkhead && tmp.ModuleType == ShipModuleType.Armor && !ModuleCategories.Contains(Localizer.Token(6173)))
                        {
                            ModuleCategories.Add(Localizer.Token(6173));
                            ModuleHeader type = new ModuleHeader(Localizer.Token(6173), 240f);
                            this.weaponSL.AddItem(type);
                        }

                        tmp = null;
                    }
                    foreach (ScrollList.Entry e in this.weaponSL.Entries)
                    {
                        foreach (KeyValuePair<string, ShipModule> module in Ship_Game.ResourceManager.ShipModulesDict)
                        {
                            if (!EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetMDict()[module.Key] || module.Value.UID == "Dummy")
                            {
                                continue;
                            }
                            ShipModule tmp = Ship_Game.ResourceManager.GetModule(module.Key);
                            tmp.SetAttributesNoParent();

                            bool restricted = tmp.FighterModule || tmp.CorvetteModule || tmp.FrigateModule || tmp.StationModule || tmp.DestroyerModule || tmp.CruiserModule
                            || tmp.CarrierModule || tmp.CapitalModule || tmp.FreighterModule || tmp.PlatformModule || tmp.DroneModule;
                            if (restricted)
                            {
                                if (this.ActiveHull.Role == "drone" && tmp.DroneModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "scout" && tmp.FighterModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "fighter" && tmp.FighterModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "corvette" && tmp.CorvetteModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "frigate" && tmp.FrigateModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "destroyer" && tmp.DestroyerModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "cruiser" && tmp.CruiserModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "carrier" && tmp.CarrierModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "capital" && tmp.CapitalModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "freighter" && tmp.FreighterModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "platform" && tmp.PlatformModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "station" && tmp.StationModule == false)
                                {
                                    continue;
                                }
                            }
                            if ((tmp.ModuleType == ShipModuleType.Armor || tmp.ModuleType == ShipModuleType.Shield || tmp.ModuleType == ShipModuleType.Countermeasure) && !tmp.isBulkhead && !tmp.isPowerArmour && (e.item as ModuleHeader).Text == tmp.ModuleType.ToString())
                            {
                                e.AddItem(module.Value);
                            }
                            if (tmp.isPowerArmour && (e.item as ModuleHeader).Text == Localizer.Token(6172))
                            {
                                e.AddItem(module.Value);
                            }
                            if (tmp.isBulkhead && (e.item as ModuleHeader).Text == Localizer.Token(6173))
                            {
                                e.AddItem(module.Value);
                            }
                            tmp = null;
                        }
                    }
                    this.Reset = false;
                }
                this.DrawList();
            }
            if (this.modSel.Tabs[1].Selected)
            {
                if (this.Reset)
                {
                    this.weaponSL.Entries.Clear();
                    List<string> ModuleCategories = new List<string>();
                    foreach (KeyValuePair<string, ShipModule> module in Ship_Game.ResourceManager.ShipModulesDict)
                    {
                        if (!EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetMDict()[module.Key] || module.Value.UID == "Dummy")
                        {
                            continue;
                        }
                        module.Value.ModuleType.ToString();
                        ShipModule tmp = Ship_Game.ResourceManager.GetModule(module.Key);
                        tmp.SetAttributesNoParent();
                        bool restricted = tmp.FighterModule || tmp.CorvetteModule || tmp.FrigateModule || tmp.StationModule || tmp.DestroyerModule || tmp.CruiserModule
                            || tmp.CarrierModule || tmp.CapitalModule || tmp.FreighterModule || tmp.PlatformModule || tmp.DroneModule;
                        if (restricted)
                        {
                            if (this.ActiveHull.Role == "drone" && tmp.DroneModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "scout" && tmp.FighterModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "fighter" && tmp.FighterModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "corvette" && tmp.CorvetteModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "frigate" && tmp.FrigateModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "destroyer" && tmp.DestroyerModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "cruiser" && tmp.CruiserModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "carrier" && tmp.CarrierModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "capital" && tmp.CapitalModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "freighter" && tmp.FreighterModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "platform" && tmp.PlatformModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "station" && tmp.StationModule == false)
                            {
                                continue;
                            }
                        }
                        if ((tmp.ModuleType == ShipModuleType.Engine || tmp.ModuleType == ShipModuleType.FuelCell || tmp.ModuleType == ShipModuleType.PowerPlant || tmp.ModuleType == ShipModuleType.PowerConduit) && !ModuleCategories.Contains(tmp.ModuleType.ToString()))
                        {
                            ModuleCategories.Add(tmp.ModuleType.ToString());
                            ModuleHeader type = new ModuleHeader(tmp.ModuleType.ToString(), 240f);
                            this.weaponSL.AddItem(type);
                        }
                        tmp = null;
                    }
                    foreach (ScrollList.Entry e in this.weaponSL.Entries)
                    {
                        foreach (KeyValuePair<string, ShipModule> module in Ship_Game.ResourceManager.ShipModulesDict)
                        {
                            if (!EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetMDict()[module.Key] || module.Value.UID == "Dummy")
                            {
                                continue;
                            }
                            ShipModule tmp = Ship_Game.ResourceManager.GetModule(module.Key);
                            tmp.SetAttributesNoParent();
                            bool restricted = tmp.FighterModule || tmp.CorvetteModule || tmp.FrigateModule || tmp.StationModule || tmp.DestroyerModule || tmp.CruiserModule
                            || tmp.CarrierModule || tmp.CapitalModule || tmp.FreighterModule || tmp.PlatformModule || tmp.DroneModule;
                            if (restricted)
                            {
                                if (this.ActiveHull.Role == "drone" && tmp.DroneModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "scout" && tmp.FighterModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "fighter" && tmp.FighterModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "corvette" && tmp.CorvetteModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "frigate" && tmp.FrigateModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "destroyer" && tmp.DestroyerModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "cruiser" && tmp.CruiserModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "carrier" && tmp.CarrierModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "capital" && tmp.CapitalModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "freighter" && tmp.FreighterModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "platform" && tmp.PlatformModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "station" && tmp.StationModule == false)
                                {
                                    continue;
                                }
                            }
                            if ((tmp.ModuleType == ShipModuleType.Engine || tmp.ModuleType == ShipModuleType.FuelCell || tmp.ModuleType == ShipModuleType.PowerPlant || tmp.ModuleType == ShipModuleType.PowerConduit) && (e.item as ModuleHeader).Text == tmp.ModuleType.ToString())
                            {
                                e.AddItem(module.Value);
                            }
                            tmp = null;
                        }
                    }
                    this.Reset = false;
                }
                this.DrawList();
            }
            if (this.modSel.Tabs[3].Selected)
            {
                if (this.Reset)
                {
                    this.weaponSL.Entries.Clear();
                    List<string> ModuleCategories = new List<string>();
                    foreach (KeyValuePair<string, ShipModule> module in Ship_Game.ResourceManager.ShipModulesDict)
                    {
                        if (!EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetMDict()[module.Key] || module.Value.UID == "Dummy")
                        {
                            continue;
                        }
                        module.Value.ModuleType.ToString();
                        ShipModule tmp = Ship_Game.ResourceManager.GetModule(module.Key);
                        tmp.SetAttributesNoParent();
                        bool restricted = tmp.FighterModule || tmp.CorvetteModule || tmp.FrigateModule || tmp.StationModule || tmp.DestroyerModule || tmp.CruiserModule
                            || tmp.CarrierModule || tmp.CapitalModule || tmp.FreighterModule || tmp.PlatformModule || tmp.DroneModule;
                        if (restricted)
                        {
                            if (this.ActiveHull.Role == "drone" && tmp.DroneModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "scout" && tmp.FighterModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "fighter" && tmp.FighterModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "corvette" && tmp.CorvetteModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "frigate" && tmp.FrigateModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "destroyer" && tmp.DestroyerModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "cruiser" && tmp.CruiserModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "carrier" && tmp.CarrierModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "capital" && tmp.CapitalModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "freighter" && tmp.FreighterModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "platform" && tmp.PlatformModule == false)
                            {
                                continue;
                            }
                            if (this.ActiveHull.Role == "station" && tmp.StationModule == false)
                            {
                                continue;
                            }
                        }
                        if ((tmp.ModuleType == ShipModuleType.Troop || tmp.ModuleType == ShipModuleType.Colony || tmp.ModuleType == ShipModuleType.Command || tmp.ModuleType == ShipModuleType.Storage || tmp.ModuleType == ShipModuleType.Hangar || tmp.ModuleType == ShipModuleType.Sensors || tmp.ModuleType == ShipModuleType.Special || tmp.ModuleType == ShipModuleType.Transporter || tmp.ModuleType == ShipModuleType.Ordnance || tmp.ModuleType == ShipModuleType.Construction) && !ModuleCategories.Contains(tmp.ModuleType.ToString()))
                        {
                            ModuleCategories.Add(tmp.ModuleType.ToString());
                            ModuleHeader type = new ModuleHeader(tmp.ModuleType.ToString(), 240f);
                            this.weaponSL.AddItem(type);
                        }
                        tmp = null;
                    }
                    foreach (ScrollList.Entry e in this.weaponSL.Entries)
                    {
                        foreach (KeyValuePair<string, ShipModule> module in Ship_Game.ResourceManager.ShipModulesDict)
                        {
                            if (!EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetMDict()[module.Key] || module.Value.UID == "Dummy")
                            {
                                continue;
                            }
                            ShipModule tmp = Ship_Game.ResourceManager.GetModule(module.Key);
                            tmp.SetAttributesNoParent();
                            bool restricted = tmp.FighterModule || tmp.CorvetteModule || tmp.FrigateModule || tmp.StationModule || tmp.DestroyerModule || tmp.CruiserModule
                            || tmp.CarrierModule || tmp.CapitalModule || tmp.FreighterModule || tmp.PlatformModule || tmp.DroneModule;
                            if (restricted)
                            {
                                if (this.ActiveHull.Role == "drone" && tmp.DroneModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "scout" && tmp.FighterModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "fighter" && tmp.FighterModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "corvette" && tmp.CorvetteModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "frigate" && tmp.FrigateModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "destroyer" && tmp.DestroyerModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "cruiser" && tmp.CruiserModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "carrier" && tmp.CarrierModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "capital" && tmp.CapitalModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "freighter" && tmp.FreighterModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "platform" && tmp.PlatformModule == false)
                                {
                                    continue;
                                }
                                if (this.ActiveHull.Role == "station" && tmp.StationModule == false)
                                {
                                    continue;
                                }
                            }
                            if ((tmp.ModuleType == ShipModuleType.Troop || tmp.ModuleType == ShipModuleType.Colony || tmp.ModuleType == ShipModuleType.Command || tmp.ModuleType == ShipModuleType.Storage || tmp.ModuleType == ShipModuleType.Hangar || tmp.ModuleType == ShipModuleType.Sensors || tmp.ModuleType == ShipModuleType.Special || tmp.ModuleType == ShipModuleType.Transporter || tmp.ModuleType == ShipModuleType.Ordnance || tmp.ModuleType == ShipModuleType.Construction) && (e.item as ModuleHeader).Text == tmp.ModuleType.ToString())
                            {
                                e.AddItem(module.Value);
                            }
                            tmp = null;
                        }
                    }
                    this.Reset = false;
                }
                this.DrawList();
            }
        }
 public override void LoadContent()
 {
     base.Setup();
     Vector2 vector2 = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 84), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 100));
     this.CategoriesRect = new Rectangle(this.r.X + 25, this.r.Y + 130, 330, 430);
     Submenu blah = new Submenu(base.ScreenManager, this.CategoriesRect);
     this.CategoriesSL = new ScrollList(blah, 40);
     this.TextRect = new Rectangle(this.CategoriesRect.X + this.CategoriesRect.Width + 5, this.CategoriesRect.Y + 10, 375, 420);
     Rectangle TextSLRect = new Rectangle(this.CategoriesRect.X + this.CategoriesRect.Width + 5, this.CategoriesRect.Y + 10, 375, 420);
     Submenu bler = new Submenu(base.ScreenManager, TextSLRect);
     this.TextSL = new ScrollList(bler, Fonts.Arial12Bold.LineSpacing + 2);
     this.SmallViewer = new Rectangle(this.TextRect.X + 20, this.TextRect.Y + 40, 336, 189);
     this.BigViewer = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 640, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 360, 1280, 720);
     this.VideoPlayer = new Microsoft.Xna.Framework.Media.VideoPlayer();
     this.ActiveTopic = new HelpTopic()
     {
         Title = Localizer.Token(1401),
         Text = Localizer.Token(1400)
     };
     HelperFunctions.parseTextToSL(this.ActiveTopic.Text, (float)(this.TextRect.Width - 40), Fonts.Arial12Bold, ref this.TextSL);
     this.TitlePosition = new Vector2((float)(this.TextRect.X + this.TextRect.Width / 2) - Fonts.Arial20Bold.MeasureString(this.ActiveTopic.Title).X / 2f - 15f, (float)(this.TextRect.Y + 10));
     List<string> Categories = new List<string>();
     foreach (HelpTopic halp in this.ht.HelpTopicsList)
     {
         if (Categories.Contains(halp.Category))
         {
             continue;
         }
         Categories.Add(halp.Category);
         ModuleHeader mh = new ModuleHeader(halp.Category, 295f);
         this.CategoriesSL.AddItem(mh);
     }
     foreach (ScrollList.Entry e in this.CategoriesSL.Entries)
     {
         foreach (HelpTopic halp in this.ht.HelpTopicsList)
         {
             if (halp.Category != (e.item as ModuleHeader).Text)
             {
                 continue;
             }
             e.AddItem(halp);
         }
     }
     base.LoadContent();
 }
 public void PopulateShipSL()
 {
     this.AvailableShips.Clear();
     foreach (Ship ship in EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetShips())
     {
         if (ship.fleet != null)
         {
             continue;
         }
         this.AvailableShips.Add(ship);
     }
     this.ShipSL.Entries.Clear();
     this.ShipSL.indexAtTop = 0;
     if (this.sub_ships.Tabs[0].Selected)
     {
         List<string> Roles = new List<string>();
         foreach (string shipname in EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).ShipsWeCanBuild)
         {
             if (Roles.Contains(Ship_Game.ResourceManager.ShipsDict[shipname].Role))
             {
                 continue;
             }
             Roles.Add(Ship_Game.ResourceManager.ShipsDict[shipname].Role);
             ModuleHeader mh = new ModuleHeader(Ship_Game.ResourceManager.ShipsDict[shipname].Role, 295f);
             this.ShipSL.AddItem(mh);
         }
         foreach (ScrollList.Entry e in this.ShipSL.Entries)
         {
             foreach (string shipname in EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).ShipsWeCanBuild)
             {
                 Ship ship = Ship_Game.ResourceManager.ShipsDict[shipname];
                 if (ship.Role != (e.item as ModuleHeader).Text)
                 {
                     continue;
                 }
                 e.AddItem(ship);
             }
         }
     }
     else if (this.sub_ships.Tabs[1].Selected)
     {
         List<string> Roles = new List<string>();
         foreach (Ship ship in this.AvailableShips)
         {
             if (Roles.Contains(ship.Role) || ship.Role == "Troop")
             {
                 continue;
             }
             Roles.Add(ship.Role);
             ModuleHeader mh = new ModuleHeader(ship.Role, 295f);
             this.ShipSL.AddItem(mh);
         }
         foreach (ScrollList.Entry e in this.ShipSL.Entries)
         {
             foreach (Ship ship in this.AvailableShips)
             {
                 if (ship.Role == "troop" || !(ship.Role == (e.item as ModuleHeader).Text))
                 {
                     continue;
                 }
                 e.AddItem(ship);
             }
         }
     }
 }
 private void ResetSL()
 {
     this.ShipDesigns.Entries.Clear();
     this.ShipDesigns.Copied.Clear();
     string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
     FileInfo[] textList = HelperFunctions.GetFilesFromDirectory(string.Concat(path, "/StarDrive/WIP"));
     List<ShipData> WIPs = new List<ShipData>();
     FileInfo[] fileInfoArray = textList;
     for (int i = 0; i < (int)fileInfoArray.Length; i++)
     {
         FileStream stream = fileInfoArray[i].OpenRead();
         ShipData newShipData = (ShipData)ResourceManager.serializer_shipdata.Deserialize(stream);
         //stream.Close();
         stream.Dispose();
         if (EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty).GetHDict().ContainsKey(newShipData.Hull) && EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty).GetHDict()[newShipData.Hull])
         {
             WIPs.Add(newShipData);
         }
     }
     List<string> ShipRoles = new List<string>();
     if (this.screen != null)
     {
         foreach (KeyValuePair<string, Ship_Game.Gameplay.Ship> Ship in ResourceManager.ShipsDict)
         {
             if (!this.ShowAllDesigns && !ResourceManager.ShipsDict[Ship.Key].IsPlayerDesign || !EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty).WeCanBuildThis(Ship.Key) || ShipRoles.Contains(Localizer.GetRole(Ship.Value.Role, EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty))) || ResourceManager.ShipRoles[Ship.Value.Role].Protected)
             {
                 continue;
             }
             ShipRoles.Add(Localizer.GetRole(Ship.Value.Role, EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty)));
             ModuleHeader mh = new ModuleHeader(Localizer.GetRole(Ship.Value.Role, EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty)));
             this.ShipDesigns.AddItem(mh);
         }
         if (WIPs.Count > 0)
         {
             ShipRoles.Add("WIP");
             ModuleHeader mh = new ModuleHeader("WIP");
             this.ShipDesigns.AddItem(mh);
         }
         foreach (ScrollList.Entry e in this.ShipDesigns.Entries)
         {
             foreach (KeyValuePair<string, Ship_Game.Gameplay.Ship> Ship in ResourceManager.ShipsDict)
             {
                 if (!this.ShowAllDesigns && !ResourceManager.ShipsDict[Ship.Key].IsPlayerDesign || !EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty).WeCanBuildThis(Ship.Key) || !(Localizer.GetRole(Ship.Value.Role, EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty)) == (e.item as ModuleHeader).Text) || Ship.Value.Name == "Subspace Projector" || Ship.Value.Name == "Shipyard" || Ship.Value.Deleted || ResourceManager.ShipRoles[Ship.Value.Role].Protected)
                 {
                     continue;
                 }
                 if (Ship.Value.reserved || Ship.Value.FromSave)
                 {
                     e.AddItem(Ship.Value);
                 }
                 else
                 {
                     e.AddItemWithCancel(Ship.Value);
                 }
             }
             if ((e.item as ModuleHeader).Text != "WIP")
             {
                 continue;
             }
             foreach (ShipData data in WIPs)
             {
                 e.AddItemWithCancel(data);
             }
         }
     }
 }
 public override void LoadContent()
 {
     this.Window = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 250, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 300, 500, 600);
     this.loadMenu = new Menu1(base.ScreenManager, this.Window);
     Rectangle sub = new Rectangle(this.Window.X + 20, this.Window.Y + 60, this.Window.Width - 40, this.Window.Height - 80);
     this.SaveShips = new Submenu(base.ScreenManager, sub);
     this.SaveShips.AddTab(Localizer.Token(198));
     this.ShipDesigns = new ScrollList(this.SaveShips);
     Vector2 Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 84), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 100));
     this.TitlePosition = new Vector2((float)(this.Window.X + 20), (float)(this.Window.Y + 20));
     string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
     Rectangle gridRect = new Rectangle(this.SaveShips.Menu.X + this.SaveShips.Menu.Width - 44, this.SaveShips.Menu.Y, 29, 20);
     this.playerDesignsToggle = new ToggleButton(gridRect, "SelectionBox/button_grid_active", "SelectionBox/button_grid_inactive", "SelectionBox/button_grid_hover", "SelectionBox/button_grid_pressed", "SelectionBox/icon_grid")
     {
         Active = this.ShowAllDesigns
     };
     FileInfo[] textList = HelperFunctions.GetFilesFromDirectory(string.Concat(path, "/StarDrive/WIP"));
     List<ShipData> WIPs = new List<ShipData>();
     FileInfo[] fileInfoArray = textList;
     for (int i = 0; i < (int)fileInfoArray.Length; i++)
     {
         FileStream stream = fileInfoArray[i].OpenRead();
         ShipData newShipData = (ShipData)ResourceManager.serializer_shipdata.Deserialize(stream);
         //stream.Close();
         stream.Dispose();
         if (EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty).GetHDict().ContainsKey(newShipData.Hull) && EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty).GetHDict()[newShipData.Hull])
         {
             WIPs.Add(newShipData);
         }
     }
     List<string> ShipRoles = new List<string>();
     if (this.screen != null)
     {
         foreach (KeyValuePair<string, Ship_Game.Gameplay.Ship> Ship in ResourceManager.ShipsDict)
         {
             //added by gremlin HIDING ERRORS
             try
             {
                 if (!EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty).WeCanBuildThis(Ship.Key) || ShipRoles.Contains(Localizer.GetRole(Ship.Value.Role, EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty))) || ResourceManager.ShipRoles[Ship.Value.Role].Protected)
                 {
                     continue;
                 }
                 ShipRoles.Add(Localizer.GetRole(Ship.Value.Role, EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty)));
                 ModuleHeader mh = new ModuleHeader(Localizer.GetRole(Ship.Value.Role, EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty)));
                 this.ShipDesigns.AddItem(mh);
             }
             catch { }
         }
         if (WIPs.Count > 0)
         {
             ShipRoles.Add("WIP");
             ModuleHeader mh = new ModuleHeader("WIP");
             this.ShipDesigns.AddItem(mh);
         }
         foreach (ScrollList.Entry e in this.ShipDesigns.Entries)
         {
             foreach (KeyValuePair<string, Ship_Game.Gameplay.Ship> Ship in ResourceManager.ShipsDict)
             {
                 if (!EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty).WeCanBuildThis(Ship.Key) || !(Localizer.GetRole(Ship.Value.Role, EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty)) == (e.item as ModuleHeader).Text) || Ship.Value.Name == "Subspace Projector" || Ship.Value.Name == "Shipyard" || Ship.Value.Deleted || ResourceManager.ShipRoles[Ship.Value.Role].Protected)
                 {
                     continue;
                 }
                 if (Ship.Value.reserved || Ship.Value.FromSave)
                 {
                     e.AddItem(Ship.Value);
                 }
                 else
                 {
                     e.AddItemWithCancel(Ship.Value);
                 }
             }
             if ((e.item as ModuleHeader).Text != "WIP")
             {
                 continue;
             }
             foreach (ShipData data in WIPs)
             {
                 e.AddItemWithCancel(data);
             }
         }
     }
     this.EnternamePos = this.TitlePosition;
     this.EnterNameArea.Text = Localizer.Token(199);
     this.Load = new UIButton()
     {
         Rect = new Rectangle(sub.X + sub.Width - 88, (int)this.EnternamePos.Y - 2, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height),
         NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"],
         HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_hover"],
         PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_pressed"],
         Launches = "Load",
         Text = Localizer.Token(8)
     };
     this.Buttons.Add(this.Load);
     Cursor.Y = Cursor.Y + (float)(ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height + 15);
     base.LoadContent();
 }
 public override void LoadContent()
 {
     this.LocalContent = new ContentManager(Game1.Instance.Services, "");
     this.Window = new Rectangle(0, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 300, 400, 600);
     this.SaveMenu = new Menu1(base.ScreenManager, this.Window);
     Rectangle sub = new Rectangle(this.Window.X + 20, this.Window.Y + 20, this.Window.Width - 40, 80);
     Vector2 vector2 = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 84), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 100));
     this.TitlePosition = new Vector2((float)(sub.X + 20), (float)(sub.Y + 45));
     Rectangle scrollList = new Rectangle(sub.X, sub.Y, sub.Width, this.Window.Height - 45);
     this.AllSaves = new Submenu(base.ScreenManager, scrollList);
     this.AllSaves.AddTab("Load Model");
     this.SavesSL = new ScrollList(this.AllSaves, 55);
     Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
     List<ModelData> modelDatas = new List<ModelData>();
     ModuleHeader original = new ModuleHeader("Vanilla StarDrive");
     this.SavesSL.AddItem(original);
     FileInfo[] filesFromDirectoryAndSubs = HelperFunctions.GetFilesFromDirectoryAndSubs("Content/Model/Ships");
     for (int i = 0; i < (int)filesFromDirectoryAndSubs.Length; i++)
     {
         FileInfo FI = filesFromDirectoryAndSubs[i];
         Stream file = FI.OpenRead();
         ModelData data = new ModelData();
         try
         {
             string fullDirectory = (new DirectoryInfo(Environment.CurrentDirectory)).FullName;
             string fullFile = FI.FullName;
             int fileExtPos = fullFile.LastIndexOf(".");
             if (fileExtPos >= 0)
             {
                 fullFile = fullFile.Substring(0, fileExtPos);
             }
             if (fullFile.StartsWith(fullDirectory))
             {
                 Console.WriteLine("Relative path: {0}", fullFile.Substring(fullDirectory.Length + 1));
             }
             else
             {
                 Console.WriteLine("Unable to make relative path");
             }
             data.Name = Path.GetFileNameWithoutExtension(FI.FullName);
             data.model = this.LocalContent.Load<Model>(fullFile.Substring(fullDirectory.Length + 1));
             data.FileInfo = FI;
             this.SavesSL.Entries[0].AddItem(data);
         }
         catch
         {
             continue;
         }
         //file.Close();
         file.Dispose();
     //Label0:
       //  continue;
     }
     ModuleHeader Mods = new ModuleHeader("StarDrive/Ship Tool/Models");
     this.SavesSL.AddItem(Mods);
     FileInfo[] fileInfoArray = HelperFunctions.GetFilesFromDirectoryAndSubs("Ship Tool/Models");
     for (int j = 0; j < (int)fileInfoArray.Length; j++)
     {
         FileInfo FI = fileInfoArray[j];
         Stream file = FI.OpenRead();
         ModelData data = new ModelData();
         try
         {
             string fullDirectory = (new DirectoryInfo(Environment.CurrentDirectory)).FullName;
             string fullFile = FI.FullName;
             int fileExtPos = fullFile.LastIndexOf(".");
             if (fileExtPos >= 0)
             {
                 fullFile = fullFile.Substring(0, fileExtPos);
             }
             if (fullFile.StartsWith(fullDirectory))
             {
                 Console.WriteLine("Relative path: {0}", fullFile.Substring(fullDirectory.Length + 1));
             }
             else
             {
                 Console.WriteLine("Unable to make relative path");
             }
             data.Name = Path.GetFileNameWithoutExtension(FI.FullName);
             data.model = this.LocalContent.Load<Model>(fullFile.Substring(fullDirectory.Length + 1));
             data.FileInfo = FI;
             this.SavesSL.Entries[1].AddItem(data);
         }
         catch
         {
             continue;
         }
         //file.Close();
         file.Dispose();
     //Label1:
       //  continue;
     }
     this.EnternamePos = this.TitlePosition;
     //Added by McShooterz: Temp fix for ship tool
     //this.EnterNameArea = new UITextEntry()
     //{
         //Text = "",
         //ClickableArea = new Rectangle((int)this.EnternamePos.X, (int)this.EnternamePos.Y - 2, 20, Fonts.Arial20Bold.LineSpacing)
     //};
     base.LoadContent();
 }