public override void HandleInput(InputState input)
        {
            this.CategoryList.HandleInput(input);
            this.CarrierOnlyBox.HandleInput(input);

            if (this.ActiveModule != null && (this.ActiveModule.InstalledWeapon != null && this.ActiveModule.ModuleType != ShipModuleType.Turret || this.ActiveModule.XSIZE != this.ActiveModule.YSIZE))
            {
                if (input.Left)
                    this.ChangeModuleState(ShipDesignScreen.ActiveModuleState.Left);
                if (input.Right)
                    this.ChangeModuleState(ShipDesignScreen.ActiveModuleState.Right);
                if (input.Down)
                    this.ChangeModuleState(ShipDesignScreen.ActiveModuleState.Rear);
                if (input.Up)
                    this.ChangeModuleState(ShipDesignScreen.ActiveModuleState.Normal);
            }
            if (input.CurrentKeyboardState.IsKeyDown(Keys.Y) && !input.LastKeyboardState.IsKeyDown(Keys.Y) && !GlobalStats.TakingInput)
            {
                AudioManager.PlayCue("echo_affirm");
                this.ExitScreen();
            }
            if (this.close.HandleInput(input))
                this.ExitScreen();
            else if (input.CurrentKeyboardState.IsKeyDown(Keys.Z) && input.LastKeyboardState.IsKeyUp(Keys.Z) && input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl))
            {
                if (this.DesignStack.Count <= 0)
                    return;
                ShipModule shipModule = this.ActiveModule;
                DesignAction designAction = this.DesignStack.Pop();
                SlotStruct slot1 = new SlotStruct();
                foreach (SlotStruct slot2 in this.Slots)
                {
                    if (slot2.pq == designAction.clickedSS.pq)
                    {
                        this.ClearSlotNoStack(slot2);
                        slot1 = slot2;
                        slot1.facing = designAction.clickedSS.facing;
                    }
                    foreach (SlotStruct slotStruct in designAction.AlteredSlots)
                    {
                        if (slot2.pq == slotStruct.pq)
                        {
                            this.ClearSlotNoStack(slot2);
                            break;
                        }
                    }
                }
                if (designAction.clickedSS.ModuleUID != null)
                {
                    this.ActiveModule = ResourceManager.GetModule(designAction.clickedSS.ModuleUID);
                    this.ResetModuleState();
                    this.InstallModuleNoStack(slot1);
                }
                foreach (SlotStruct slotStruct in designAction.AlteredSlots)
                {
                    foreach (SlotStruct slot2 in this.Slots)
                    {
                        if (slot2.pq == slotStruct.pq && slotStruct.ModuleUID != null)
                        {
                            this.ActiveModule = ResourceManager.GetModule(slotStruct.ModuleUID);
                            this.ResetModuleState();
                            this.InstallModuleNoStack(slot2);
                            slot2.facing = slotStruct.facing;
                            slot2.ModuleUID = slotStruct.ModuleUID;
                        }
                    }
                }
                this.ActiveModule = shipModule;
                this.ResetModuleState();
            }
            else
            {
                if (!HelperFunctions.CheckIntersection(this.ModuleSelectionMenu.Menu, input.CursorPosition) && !HelperFunctions.CheckIntersection(this.HullSelectionRect, input.CursorPosition) && !HelperFunctions.CheckIntersection(this.ChooseFighterSub.Menu, input.CursorPosition))
                {
                    if (input.ScrollOut)
                    {
                        this.TransitionZoom -= 0.1f;
                        if ((double)this.TransitionZoom < 0.300000011920929)
                            this.TransitionZoom = 0.3f;
                        if ((double)this.TransitionZoom > 2.65000009536743)
                            this.TransitionZoom = 2.65f;
                    }
                    if (input.ScrollIn)
                    {
                        this.TransitionZoom += 0.1f;
                        if ((double)this.TransitionZoom < 0.300000011920929)
                            this.TransitionZoom = 0.3f;
                        if ((double)this.TransitionZoom > 2.65000009536743)
                            this.TransitionZoom = 2.65f;
                    }
                }
                if (input.CurrentKeyboardState.IsKeyDown(Keys.OemTilde))
                    input.LastKeyboardState.IsKeyUp(Keys.OemTilde);
                if (this.Debug)
                {
                    if (input.CurrentKeyboardState.IsKeyDown(Keys.Enter) && input.LastKeyboardState.IsKeyUp(Keys.Enter))
                    {
                        foreach (ModuleSlotData moduleSlotData in this.ActiveHull.ModuleSlotList)
                            moduleSlotData.InstalledModuleUID = (string)null;
                        new XmlSerializer(typeof(ShipData)).Serialize((TextWriter)new StreamWriter("Content/Hulls/" + this.ActiveHull.ShipStyle + "/" + this.ActiveHull.Name + ".xml"), (object)this.ActiveHull);
                    }
                    if (input.Right)
                        ++this.operation;
                    if (this.operation > (ShipDesignScreen.SlotModOperation)6)
                        this.operation = ShipDesignScreen.SlotModOperation.Delete;
                }
                this.HoveredModule = (ShipModule)null;
                this.mouseStateCurrent = Mouse.GetState();
                Vector2 vector2 = new Vector2((float)this.mouseStateCurrent.X, (float)this.mouseStateCurrent.Y);
                this.selector = (Selector)null;
                this.EmpireUI.HandleInput(input, (GameScreen)this);
                this.activeModSubMenu.HandleInputNoReset((object)this);
                this.hullSL.HandleInput(input);
                for (int index = this.hullSL.indexAtTop; index < this.hullSL.Copied.Count && index < this.hullSL.indexAtTop + this.hullSL.entriesToDisplay; ++index)
                {
                    ScrollList.Entry e = this.hullSL.Copied[index];
                    if (e.item is ModuleHeader)
                    {
                        if ((e.item as ModuleHeader).HandleInput(input, e))
                            return;
                    }
                    else if (HelperFunctions.CheckIntersection(e.clickRect, vector2))
                    {
                        this.selector = new Selector(this.ScreenManager, e.clickRect);
                        e.clickRectHover = 1;
                        this.selector = new Selector(this.ScreenManager, e.clickRect);
                        if (input.InGameSelect)
                        {
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                            if (!this.ShipSaved && !this.CheckDesign())
                            {
                                MessageBoxScreen messageBoxScreen = new MessageBoxScreen(Localizer.Token(2121), "Save", "No");
                                messageBoxScreen.Accepted += new EventHandler<EventArgs>(this.SaveWIPThenChangeHull);
                                messageBoxScreen.Cancelled += new EventHandler<EventArgs>(this.JustChangeHull);
                                this.changeto = e.item as ShipData;
                                this.ScreenManager.AddScreen((GameScreen)messageBoxScreen);
                                return;
                            }
                            else
                            {
                                this.ChangeHull(e.item as ShipData);
                                return;
                            }
                        }
                    }
                    else
                        e.clickRectHover = 0;
                }
                this.modSel.HandleInput((object)this);
                if (this.ActiveModule != null)
                {
                    if (this.ActiveModule.ModuleType == ShipModuleType.Hangar && !this.ActiveModule.IsTroopBay && !this.ActiveModule.IsSupplyBay)
                    {
                        this.UpdateHangarOptions(this.ActiveModule);
                        this.ChooseFighterSL.HandleInput(input);
                        for (int index = this.ChooseFighterSL.indexAtTop; index < this.ChooseFighterSL.Copied.Count && index < this.ChooseFighterSL.indexAtTop + this.ChooseFighterSL.entriesToDisplay; ++index)
                        {
                            ScrollList.Entry entry = this.ChooseFighterSL.Copied[index];
                            if (HelperFunctions.CheckIntersection(entry.clickRect, vector2))
                            {
                                this.selector = new Selector(this.ScreenManager, entry.clickRect);
                                entry.clickRectHover = 1;
                                this.selector = new Selector(this.ScreenManager, entry.clickRect);
                                if (input.InGameSelect)
                                {
                                    this.ActiveModule.hangarShipUID = (entry.item as Ship).Name;
                                    this.HangarShipUIDLast = (entry.item as Ship).Name;
                                    AudioManager.PlayCue("sd_ui_accept_alt3");
                                    return;
                                }
                            }
                        }
                    }
                }
                else if (this.HighlightedModule != null && this.HighlightedModule.ModuleType == ShipModuleType.Hangar && (!this.HighlightedModule.IsTroopBay && !this.HighlightedModule.IsSupplyBay))
                {
                    this.ChooseFighterSL.HandleInput(input);
                    for (int index = this.ChooseFighterSL.indexAtTop; index < this.ChooseFighterSL.Copied.Count && index < this.ChooseFighterSL.indexAtTop + this.ChooseFighterSL.entriesToDisplay; ++index)
                    {
                        ScrollList.Entry entry = this.ChooseFighterSL.Copied[index];
                        if (HelperFunctions.CheckIntersection(entry.clickRect, vector2))
                        {
                            this.selector = new Selector(this.ScreenManager, entry.clickRect);
                            entry.clickRectHover = 1;
                            this.selector = new Selector(this.ScreenManager, entry.clickRect);
                            if (input.InGameSelect)
                            {
                                this.HighlightedModule.hangarShipUID = (entry.item as Ship).Name;
                                this.HangarShipUIDLast = (entry.item as Ship).Name;
                                AudioManager.PlayCue("sd_ui_accept_alt3");
                                return;
                            }
                        }
                    }
                }
                for (int index = this.weaponSL.indexAtTop; index < this.weaponSL.Copied.Count && index < this.weaponSL.indexAtTop + this.weaponSL.entriesToDisplay; ++index)
                {
                    ScrollList.Entry e = this.weaponSL.Copied[index];
                    if (e.item is ModuleHeader)
                    {
                        if ((e.item as ModuleHeader).HandleInput(input, e))
                            return;
                    }
                    else if (HelperFunctions.CheckIntersection(e.clickRect, vector2))
                    {
                        this.selector = new Selector(this.ScreenManager, e.clickRect);
                        e.clickRectHover = 1;
                        this.selector = new Selector(this.ScreenManager, e.clickRect);
                        if (input.InGameSelect)
                        {
                            this.SetActiveModule(ResourceManager.GetModule((e.item as ShipModule).UID));
                            this.ResetModuleState();
                            return;
                        }
                    }
                    else
                        e.clickRectHover = 0;
                }
                this.weaponSL.HandleInput(input);
                if (HelperFunctions.CheckIntersection(this.HullSelectionRect, input.CursorPosition) && input.CurrentMouseState.LeftButton == ButtonState.Pressed || HelperFunctions.CheckIntersection(this.modSel.Menu, input.CursorPosition) && input.CurrentMouseState.LeftButton == ButtonState.Pressed || HelperFunctions.CheckIntersection(this.activeModSubMenu.Menu, input.CursorPosition) && input.CurrentMouseState.LeftButton == ButtonState.Pressed)
                    return;
                if (HelperFunctions.CheckIntersection(this.modSel.Menu, vector2))
                {
                    if (this.mouseStateCurrent.ScrollWheelValue > this.mouseStatePrevious.ScrollWheelValue && this.weaponSL.indexAtTop > 0)
                        --this.weaponSL.indexAtTop;
                    if (this.mouseStateCurrent.ScrollWheelValue < this.mouseStatePrevious.ScrollWheelValue && this.weaponSL.indexAtTop + this.weaponSL.entriesToDisplay < this.weaponSL.Entries.Count)
                        ++this.weaponSL.indexAtTop;
                }
                if (HelperFunctions.CheckIntersection(this.ArcsButton.R, input.CursorPosition))
                    ToolTip.CreateTooltip(134, this.ScreenManager);
                if (this.ArcsButton.HandleInput(input))
                {
                    this.ArcsButton.ToggleOn = !this.ArcsButton.ToggleOn;
                    this.ShowAllArcs = this.ArcsButton.ToggleOn;
                }
                if (input.Tab)
                {
                    this.ShowAllArcs = !this.ShowAllArcs;
                    this.ArcsButton.ToggleOn = this.ShowAllArcs;
                }
                if (input.CurrentMouseState.RightButton == ButtonState.Pressed && input.LastMouseState.RightButton == ButtonState.Released)
                {
                    this.StartDragPos = input.CursorPosition;
                    this.cameraVelocity.X = 0.0f;
                    this.cameraVelocity.Y = 0.0f;
                }
                if (input.CurrentMouseState.RightButton == ButtonState.Pressed && input.LastMouseState.RightButton == ButtonState.Pressed)
                {
                    float num1 = input.CursorPosition.X - this.StartDragPos.X;
                    float num2 = input.CursorPosition.Y - this.StartDragPos.Y;
                    this.camera._pos += new Vector2(-num1, -num2);
                    this.StartDragPos = input.CursorPosition;
                    this.cameraPosition.X += -num1;
                    this.cameraPosition.Y += -num2;
                }
                else
                {
                    this.cameraVelocity.X = 0.0f;
                    this.cameraVelocity.Y = 0.0f;
                }
                this.cameraVelocity.X = MathHelper.Clamp(this.cameraVelocity.X, -10f, 10f);
                this.cameraVelocity.Y = MathHelper.Clamp(this.cameraVelocity.Y, -10f, 10f);
                if (input.Escaped)
                    this.ExitScreen();
                if (this.ToggleOverlay)
                {
                    foreach (SlotStruct slotStruct in this.Slots)
                    {
                        Vector2 spaceFromWorldSpace = this.camera.GetScreenSpaceFromWorldSpace(new Vector2((float)slotStruct.pq.enclosingRect.X, (float)slotStruct.pq.enclosingRect.Y));
                        if (HelperFunctions.CheckIntersection(new Rectangle((int)spaceFromWorldSpace.X, (int)spaceFromWorldSpace.Y, (int)(16.0 * (double)this.camera.Zoom), (int)(16.0 * (double)this.camera.Zoom)), vector2))
                        {
                            if (slotStruct.isDummy && slotStruct.parent.module != null)
                                this.HoveredModule = slotStruct.parent.module;
                            else if (slotStruct.module != null)
                                this.HoveredModule = slotStruct.module;
                            if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
                            {
                                AudioManager.GetCue("simple_beep").Play();
                                if (this.Debug)
                                {
                                    this.DebugAlterSlot(slotStruct.slotReference.Position, this.operation);
                                    return;
                                }
                                else if (slotStruct.isDummy && slotStruct.parent.module != null)
                                    this.HighlightedModule = slotStruct.parent.module;
                                else if (slotStruct.module != null)
                                    this.HighlightedModule = slotStruct.module;
                            }
                        }
                    }
                }
                if (HelperFunctions.CheckIntersection(this.upArrow, vector2) && this.mouseStateCurrent.LeftButton == ButtonState.Released && (this.mouseStatePrevious.LeftButton == ButtonState.Pressed && this.scrollPosition > 0))
                {
                    --this.scrollPosition;
                    AudioManager.GetCue("blip_click").Play();
                    foreach (ModuleButton moduleButton in this.ModuleButtons)
                        moduleButton.moduleRect.Y += 128;
                }
                if (HelperFunctions.CheckIntersection(this.downArrow, vector2) && this.mouseStateCurrent.LeftButton == ButtonState.Released && this.mouseStatePrevious.LeftButton == ButtonState.Pressed)
                {
                    ++this.scrollPosition;
                    AudioManager.GetCue("blip_click").Play();
                    foreach (ModuleButton moduleButton in this.ModuleButtons)
                        moduleButton.moduleRect.Y -= 128;
                }
                if (HelperFunctions.CheckIntersection(this.ModuleSelectionArea, vector2))
                {
                    if (input.ScrollIn && this.scrollPosition > 0)
                    {
                        --this.scrollPosition;
                        AudioManager.GetCue("blip_click").Play();
                        foreach (ModuleButton moduleButton in this.ModuleButtons)
                            moduleButton.moduleRect.Y += 128;
                    }
                    if (input.ScrollOut)
                    {
                        ++this.scrollPosition;
                        AudioManager.GetCue("blip_click").Play();
                        foreach (ModuleButton moduleButton in this.ModuleButtons)
                            moduleButton.moduleRect.Y -= 128;
                    }
                }
                if (this.mouseStateCurrent.RightButton == ButtonState.Released && this.mouseStatePrevious.RightButton == ButtonState.Pressed)
                {
                    //this should actually clear slots
                    this.ActiveModule = (ShipModule)null;
                    foreach (SlotStruct parent in this.Slots)
                    {
                        parent.ShowInvalid = false;
                        parent.ShowValid = false;
                        Vector2 spaceFromWorldSpace = this.camera.GetScreenSpaceFromWorldSpace(new Vector2((float)parent.pq.enclosingRect.X, (float)parent.pq.enclosingRect.Y));
                        Rectangle rect = new Rectangle((int)spaceFromWorldSpace.X, (int)spaceFromWorldSpace.Y, (int)(16.0 * (double)this.camera.Zoom), (int)(16.0 * (double)this.camera.Zoom));
                        if ((parent.module != null || parent.isDummy) && HelperFunctions.CheckIntersection(rect, vector2)) //if clicked at this slot
                        {
                            DesignAction designAction = new DesignAction();
                            designAction.clickedSS = new SlotStruct();
                            designAction.clickedSS.pq = parent.isDummy ? parent.parent.pq : parent.pq;
                            designAction.clickedSS.Restrictions = parent.Restrictions;
                            designAction.clickedSS.facing = parent.module != null ? parent.module.facing : 0.0f;
                            designAction.clickedSS.ModuleUID = parent.isDummy ? parent.parent.ModuleUID : parent.ModuleUID;
                            designAction.clickedSS.module = parent.module;
                            designAction.clickedSS.slotReference = parent.isDummy ? parent.parent.slotReference : parent.slotReference;
                            this.DesignStack.Push(designAction);
                            AudioManager.GetCue("sub_bass_whoosh").Play();
                            if (parent.isDummy)
                                this.ClearParentSlot(parent.parent);
                            else
                                this.ClearParentSlot(parent);
                            this.RecalculatePower();
                        }
                    }
                }
                foreach (ModuleButton moduleButton in this.ModuleButtons)
                {
                    if (HelperFunctions.CheckIntersection(this.ModuleSelectionArea, new Vector2((float)(moduleButton.moduleRect.X + 30), (float)(moduleButton.moduleRect.Y + 30))))
                    {
                        if (HelperFunctions.CheckIntersection(moduleButton.moduleRect, vector2))
                        {
                            if (input.InGameSelect)
                                this.SetActiveModule(ResourceManager.GetModule(moduleButton.ModuleUID));
                            moduleButton.isHighlighted = true;
                        }
                        else
                            moduleButton.isHighlighted = false;
                    }
                }
                if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && this.ActiveModule != null)
                {
                    foreach (SlotStruct slot in this.Slots)
                    {
                        Vector2 spaceFromWorldSpace = this.camera.GetScreenSpaceFromWorldSpace(new Vector2((float)slot.pq.enclosingRect.X, (float)slot.pq.enclosingRect.Y));
                        if (HelperFunctions.CheckIntersection(new Rectangle((int)spaceFromWorldSpace.X, (int)spaceFromWorldSpace.Y, (int)(16.0 * (double)this.camera.Zoom), (int)(16.0 * (double)this.camera.Zoom)), vector2))
                        {
                            AudioManager.GetCue("sub_bass_mouseover").Play();
                            this.InstallModule(slot);
                        }
                    }
                }
                else if (this.mouseStateCurrent.LeftButton == ButtonState.Pressed && this.mouseStatePrevious.LeftButton == ButtonState.Pressed)
                    this.HoldTimer -= .01666f;
                else
                    this.HoldTimer = 0.50f;

                foreach (SlotStruct slotStruct in this.Slots)
                {
                    if (slotStruct.ModuleUID != null && this.HighlightedModule != null && (slotStruct.module == this.HighlightedModule && (double)slotStruct.module.FieldOfFire != 0.0) && slotStruct.module.ModuleType == ShipModuleType.Turret)
                    {
                        float num1 = slotStruct.module.FieldOfFire / 2f;
                        Vector2 spaceFromWorldSpace = this.camera.GetScreenSpaceFromWorldSpace(new Vector2((float)(slotStruct.pq.enclosingRect.X + 16 * (int)slotStruct.module.XSIZE / 2), (float)(slotStruct.pq.enclosingRect.Y + 16 * (int)slotStruct.module.YSIZE / 2)));
                        float num2 = Math.Abs(this.findAngleToTarget(spaceFromWorldSpace, vector2));
                        float num3 = this.HighlightedModule.facing;
                        float num4 = Math.Abs(num2 - num3);
                        if ((double)num4 > (double)num1)
                        {
                            if ((double)num2 > 180.0)
                                num2 = (float)(-1.0 * (360.0 - (double)num2));
                            if ((double)num3 > 180.0)
                                num3 = (float)(-1.0 * (360.0 - (double)num3));
                            num4 = Math.Abs(num2 - num3);
                        }

                        if (GlobalStats.AltArcControl)
                        {
                            //The Doctor: ALT (either) + LEFT CLICK to pick and move arcs. This way, it's impossible to accidentally pick the wrong arc, while it's just as responsive and smooth as the original method when you are trying to.
                            if ((double)num4 < (double)num1 && (this.mouseStateCurrent.LeftButton == ButtonState.Pressed && this.mouseStatePrevious.LeftButton == ButtonState.Pressed && ((input.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt) || input.LastKeyboardState.IsKeyDown(Keys.LeftAlt)) || (input.CurrentKeyboardState.IsKeyDown(Keys.RightAlt) || input.LastKeyboardState.IsKeyDown(Keys.RightAlt)))))
                            {

                                this.HighlightedModule.facing = Math.Abs(this.findAngleToTarget(spaceFromWorldSpace, vector2));
                            }
                        }
                        else
                        {
                            //Delay method
                            if ((double)num4 < (double)num1 && (this.mouseStateCurrent.LeftButton == ButtonState.Pressed && this.mouseStatePrevious.LeftButton == ButtonState.Pressed && this.HoldTimer < 0))
                            {
                                this.HighlightedModule.facing = Math.Abs(this.findAngleToTarget(spaceFromWorldSpace, vector2));
                            }

                        }

                    }
                }
                foreach (UIButton uiButton in this.Buttons)
                {
                    if (HelperFunctions.CheckIntersection(uiButton.Rect, vector2))
                    {
                        uiButton.State = UIButton.PressState.Hover;
                        if (this.mouseStateCurrent.LeftButton == ButtonState.Pressed && this.mouseStatePrevious.LeftButton == ButtonState.Pressed)
                            uiButton.State = UIButton.PressState.Pressed;
                        if (this.mouseStateCurrent.LeftButton == ButtonState.Released && this.mouseStatePrevious.LeftButton == ButtonState.Pressed)
                        {
                            switch (uiButton.Launches)
                            {
                                case "Toggle Overlay":
                                    AudioManager.PlayCue("blip_click");
                                    this.ToggleOverlay = !this.ToggleOverlay;
                                    continue;
                                case "Save As...":
                                    if (this.CheckDesign())
                                    {
                                        this.ScreenManager.AddScreen((GameScreen)new DesignManager(this, this.ActiveHull.Name));
                                        continue;
                                    }
                                    else
                                    {
                                        AudioManager.PlayCue("UI_Misc20");
                                        this.ScreenManager.AddScreen((GameScreen)new MessageBoxScreen(Localizer.Token(2049)));
                                        continue;
                                    }
                                case "Load":
                                    this.ScreenManager.AddScreen((GameScreen)new LoadDesigns(this));
                                    continue;
                                default:
                                    continue;
                            }
                        }
                    }
                    else
                        uiButton.State = UIButton.PressState.Normal;
                }
                if (this.ActiveHull != null)
                {
                    foreach (ToggleButton toggleButton in this.CombatStatusButtons)
                    {
                        if (HelperFunctions.CheckIntersection(toggleButton.r, input.CursorPosition))
                        {
                            if (toggleButton.HasToolTip)
                                ToolTip.CreateTooltip(toggleButton.WhichToolTip, this.ScreenManager);
                            if (input.InGameSelect)
                            {
                                AudioManager.PlayCue("sd_ui_accept_alt3");
                                switch (toggleButton.Action)
                                {
                                    case "attack":
                                        this.CombatState = CombatState.AttackRuns;
                                        break;
                                    case "arty":
                                        this.CombatState = CombatState.Artillery;
                                        break;
                                    case "hold":
                                        this.CombatState = CombatState.HoldPosition;
                                        break;
                                    case "orbit_left":
                                        this.CombatState = CombatState.OrbitLeft;
                                        break;
                                    case "broadside_left":
                                        this.CombatState = CombatState.BroadsideLeft;
                                        break;
                                    case "orbit_right":
                                        this.CombatState = CombatState.OrbitRight;
                                        break;
                                    case "broadside_right":
                                        this.CombatState = CombatState.BroadsideRight;
                                        break;
                                    case "evade":
                                        this.CombatState = CombatState.Evade;
                                        break;
                                }
                            }
                        }
                        else
                            toggleButton.Hover = false;
                        switch (toggleButton.Action)
                        {
                            case "attack":
                                toggleButton.Active = this.CombatState == CombatState.AttackRuns;
                                continue;
                            case "arty":
                                toggleButton.Active = this.CombatState == CombatState.Artillery;
                                continue;
                            case "hold":
                                toggleButton.Active = this.CombatState == CombatState.HoldPosition;
                                continue;
                            case "orbit_left":
                                toggleButton.Active = this.CombatState == CombatState.OrbitLeft;
                                continue;
                            case "broadside_left":
                                toggleButton.Active = this.CombatState == CombatState.BroadsideLeft;
                                continue;
                            case "orbit_right":
                                toggleButton.Active = this.CombatState == CombatState.OrbitRight;
                                continue;
                            case "broadside_right":
                                toggleButton.Active = this.CombatState == CombatState.BroadsideRight;
                                continue;
                            case "evade":
                                toggleButton.Active = this.CombatState == CombatState.Evade;
                                continue;
                            default:
                                continue;
                        }
                    }
                }
                this.mouseStatePrevious = this.mouseStateCurrent;
                base.HandleInput(input);
            }
        }
 public override void ExitScreen()
 {
     if (!this.ShipSaved && !this.CheckDesign())
     {
         MessageBoxScreen message = new MessageBoxScreen(Localizer.Token(2121), "Save", "Exit");
         message.Cancelled += new EventHandler<EventArgs>(this.DoExit);
         message.Accepted += new EventHandler<EventArgs>(this.SaveWIP);
         base.ScreenManager.AddScreen(message);
         return;
     }
     if (this.ShipSaved || !this.CheckDesign())
     {
         this.ReallyExit();
         return;
     }
     MessageBoxScreen message0 = new MessageBoxScreen(Localizer.Token(2137), "Save", "Exit");
     message0.Cancelled += new EventHandler<EventArgs>(this.DoExit);
     message0.Accepted += new EventHandler<EventArgs>(this.SaveChanges);
     base.ScreenManager.AddScreen(message0);
 }
 public void ExitToMenu(string launches)
 {
     this.screenToLaunch = launches;
     if (this.ShipSaved || this.CheckDesign())
     {
         this.LaunchScreen(null, null);
         this.ReallyExit();
         return;
     }
     MessageBoxScreen message = new MessageBoxScreen(Localizer.Token(2121), "Save", "Exit");
     message.Cancelled += new EventHandler<EventArgs>(this.LaunchScreen);
     message.Accepted += new EventHandler<EventArgs>(this.SaveWIPThenLaunchScreen);
     base.ScreenManager.AddScreen(message);
 }
        private void ApplySettings()
        {
            try
            {
                this.startingx = base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth;
                this.startingy = base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight;
                Game1.Instance.graphics.SynchronizeWithVerticalRetrace = false;
                Game1.Instance.SetWindowMode(this.ModeToSet, (this.ResolutionDropDown.Active.ReferencedObject as OptionsScreen.Option).x, (this.ResolutionDropDown.Active.ReferencedObject as OptionsScreen.Option).y);
                base.Setup();
                if (this.FromGame)
                {
                    this.uScreen.LoadGraphics();
                    this.uScreen.NotificationManager.ReSize();
                    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 + 20, 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.pauseOnNotification = new Checkbox(new Vector2((float)(this.MainOptionsRect.X + 20), (float)(this.MainOptionsRect.Y + 360)), Localizer.Token(6007), new Ref<bool>(() => GlobalStats.PauseOnNotification, (bool x) => GlobalStats.PauseOnNotification = x), Fonts.Arial12Bold)
                {
                    Tip_Token = 7004
                };
                this.Resolution = new OptionsScreen.Option()
                {
                    Name = "Resolution:     ",
                    NamePosition = new Vector2((float)(this.MainOptionsRect.X + 20), (float)this.MainOptionsRect.Y)
                };
                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 = "Screen Mode:     ",
                    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 + 9, (int)this.FullScreen.NamePosition.Y + 65, 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 + 9, (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;
                //ftlRect = new Rectangle(this.MainOptionsRect.X + 20, (int)this.FullScreen.NamePosition.Y + 200, 270, 50);
                //this.IconSize = new FloatSlider(ftlRect, "Icon Sizes",0,20,GlobalStats.IconSize);
                //this.IconSize.SetAmount(GlobalStats.IconSize);
                //this.IconSize.amount = GlobalStats.IconSize;

                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));
                this.ResolutionDropDown = new DropOptions(new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.Resolution.NamePosition.Y - 2, 105, 18));
                foreach (DisplayMode mode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes)
                {
                    if (mode.Width < 1280)
                    {
                        continue;
                    }
                    OptionsScreen.Option reso1 = new OptionsScreen.Option();
                    //{ //business as usual
                        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 + 60));
                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);
                if (this.StartingMode != Game1.Instance.CurrentMode || this.startingx != this.xtoApply || this.startingy != this.ytoApply)
                {
                    MessageBoxScreen messageBox = new MessageBoxScreen(Localizer.Token(14), 10f);
                    messageBox.Accepted += new EventHandler<EventArgs>(this.AcceptChanges);
                    messageBox.Cancelled += new EventHandler<EventArgs>(this.CancelChanges);
                    base.ScreenManager.AddScreen(messageBox);
                }
                else
                {
                    this.AcceptChanges(this, EventArgs.Empty);
                }
                System.Configuration.ConfigurationManager.AppSettings.Set("IconSize",GlobalStats.IconSize.ToString());
                System.Configuration.ConfigurationManager.AppSettings.Set("PauseOnNotification", GlobalStats.PauseOnNotification.ToString());
                System.Configuration.ConfigurationManager.AppSettings.Set("MemoryLimiter", GlobalStats.MemoryLimiter.ToString());
                System.Configuration.ConfigurationManager.AppSettings.Set("shipcountlimit", GlobalStats.ShipCountLimit.ToString());

            }
            catch
            {
                this.CancelChanges(this, EventArgs.Empty);
            }
        }
        public override void HandleInput(InputState input)
        {
            this.pFacilities.HandleInputNoReset(this);
            if (HelperFunctions.CheckIntersection(this.RightColony.r, input.CursorPosition))
            {
                ToolTip.CreateTooltip(Localizer.Token(2279), this.ScreenManager);
            }
            if (HelperFunctions.CheckIntersection(this.LeftColony.r, input.CursorPosition))
            {
                ToolTip.CreateTooltip(Localizer.Token(2280), this.ScreenManager);
            }
            if ((input.Right || this.RightColony.HandleInput(input)) && (PlanetScreen.screen.Debug || this.p.Owner == EmpireManager.GetEmpireByName(PlanetScreen.screen.PlayerLoyalty)))
            {

                try
                {
                    this.p.Owner.GetPlanets().thisLock.EnterReadLock();
                    int thisindex = this.p.Owner.GetPlanets().IndexOf(this.p);
                    thisindex = (thisindex >= this.p.Owner.GetPlanets().Count - 1 ? 0 : thisindex + 1);
                    if (this.p.Owner.GetPlanets()[thisindex] != this.p)
                    {
                        this.p = this.p.Owner.GetPlanets()[thisindex];
                        PlanetScreen.screen.workersPanel = new ColonyScreen(this.p, this.ScreenManager, this.eui);
                    }
                    this.p.Owner.GetPlanets().thisLock.ExitReadLock();
                }
                catch
                {

                    System.Diagnostics.Debug.WriteLine("Colony Screen Handle Inpu. Likely null reference.");
                }
                if (input.CurrentMouseState.RightButton != ButtonState.Released || this.previousMouse.RightButton != ButtonState.Released)
                {
                    this.eui.screen.ShipsInCombat.Active = true;
                    this.eui.screen.PlanetsInCombat.Active = true;
                }
                return;
            }
            if ((input.Left || this.LeftColony.HandleInput(input)) && (PlanetScreen.screen.Debug || this.p.Owner == EmpireManager.GetEmpireByName(PlanetScreen.screen.PlayerLoyalty)))
            {
                int thisindex = this.p.Owner.GetPlanets().IndexOf(this.p);
                thisindex = (thisindex <= 0 ? this.p.Owner.GetPlanets().Count - 1 : thisindex - 1);
                if (this.p.Owner.GetPlanets()[thisindex] != this.p)
                {
                    this.p = this.p.Owner.GetPlanets()[thisindex];
                    PlanetScreen.screen.workersPanel = new ColonyScreen(this.p, this.ScreenManager, this.eui);
                }
                if (input.CurrentMouseState.RightButton != ButtonState.Released || this.previousMouse.RightButton != ButtonState.Released)
                {
                    this.eui.screen.ShipsInCombat.Active = true;
                    this.eui.screen.PlanetsInCombat.Active = true;
                }
                return;
            }
            this.p.UpdateIncomes();
            this.HandleDetailInfo(input);
            this.currentMouse = Mouse.GetState();
            Vector2 MousePos = new Vector2((float)this.currentMouse.X, (float)this.currentMouse.Y);
            this.buildSL.HandleInput(input);
            this.buildSL.Update();
            this.build.HandleInput(this);
            if (this.p.Owner != EmpireManager.GetEmpireByName(PlanetScreen.screen.PlayerLoyalty))
            {
                this.HandleDetailInfo(input);
                if (input.CurrentMouseState.RightButton != ButtonState.Released || this.previousMouse.RightButton != ButtonState.Released)
                {
                    this.eui.screen.ShipsInCombat.Active = true;
                    this.eui.screen.PlanetsInCombat.Active = true;
                }
                return;
            }
            if (!HelperFunctions.CheckIntersection(this.launchTroops.Rect, input.CursorPosition))
            {
                this.launchTroops.State = UIButton.PressState.Normal;
            }
            else
            {
                this.launchTroops.State = UIButton.PressState.Hover;
                if (input.InGameSelect)
                {
                    bool play = false;
                    foreach (PlanetGridSquare pgs in this.p.TilesList)
                    {
                        if (pgs.TroopsHere.Count <= 0 || pgs.TroopsHere[0].GetOwner() != EmpireManager.GetEmpireByName(PlanetScreen.screen.PlayerLoyalty))
                        {
                            continue;
                        }

                        play = true;

                        ResourceManager.CreateTroopShipAtPoint((this.p.Owner.data.DefaultTroopShip != null) ? this.p.Owner.data.DefaultTroopShip : this.p.Owner.data.DefaultSmallTransport, this.p.Owner, this.p.Position, pgs.TroopsHere[0]);
                        this.p.TroopsHere.Remove(pgs.TroopsHere[0]);
                        pgs.TroopsHere[0].SetPlanet(null);
                        pgs.TroopsHere.Clear();
                        this.ClickedTroop = true;
                        this.detailInfo = null;
                    }
                    if (play)
                    {

                        AudioManager.PlayCue("sd_troop_takeoff");
                    }
                }
            }
            //fbedard: Click button to send troops
            if (!HelperFunctions.CheckIntersection(this.SendTroops.Rect, input.CursorPosition))
            {
                this.SendTroops.State = UIButton.PressState.Normal;
            }
            else
            {
                this.SendTroops.State = UIButton.PressState.Hover;
                if (input.InGameSelect)
                {
                    this.eui.empire.GetShips().thisLock.EnterReadLock();
                    List<Ship> troopShips = new List<Ship>(this.eui.empire.GetShips()
                        .Where(troop => troop.TroopList.Count > 0
                            && troop.GetAI().State == AIState.AwaitingOrders
                            && troop.fleet == null && !troop.InCombat).OrderBy(distance => Vector2.Distance(distance.Center, this.p.Position)));
                    this.eui.empire.GetShips().thisLock.ExitReadLock();
                    this.eui.empire.GetPlanets().thisLock.EnterReadLock();
                    List<Planet> planetTroops = new List<Planet>(this.eui.empire.GetPlanets()
                        .Where(troops => troops.TroopsHere.Count > 1).OrderBy(distance => Vector2.Distance(distance.Position, this.p.Position))
                        .Where(Name => Name.Name != this.p.Name));
                    this.eui.empire.GetPlanets().thisLock.ExitReadLock();
                    if (troopShips.Count > 0)
                    {
                        AudioManager.PlayCue("echo_affirm");
                        troopShips.First().GetAI().OrderRebase(this.p,true);
                    }
                    else
                        if (planetTroops.Count > 0)
                        {
                            {
                                planetTroops.First().TroopsHere.thisLock.EnterWriteLock();
                                Ship troop = planetTroops.First().TroopsHere.First().Launch();
                                if (troop != null)
                                {
                                    AudioManager.PlayCue("echo_affirm");
                                    troop.GetAI().OrderRebase(this.p,true);
                                }
                                planetTroops.First().TroopsHere.thisLock.ExitWriteLock();
                            }
                        }
                        else
                        {
                            AudioManager.PlayCue("blip_click");
                        }
                }
            }
            if (!HelperFunctions.CheckIntersection(this.edit_name_button, MousePos))
            {
                this.editHoverState = 0;
            }
            else
            {
                this.editHoverState = 1;
                if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                {
                    this.PlanetName.HandlingInput = true;
                }
            }
            if (!this.PlanetName.HandlingInput)
            {
                GlobalStats.TakingInput = false;
                bool empty = true;
                string text = this.PlanetName.Text;
                int num = 0;
                while (num < text.Length)
                {
                    if (text[num] == ' ')
                    {
                        num++;
                    }
                    else
                    {
                        empty = false;
                        break;
                    }
                }
                if (empty)
                {
                    int ringnum = 1;
                    foreach (SolarSystem.Ring ring in this.p.system.RingList)
                    {
                        if (ring.planet == this.p)
                        {
                            this.PlanetName.Text = string.Concat(this.p.system.Name, " ", NumberToRomanConvertor.NumberToRoman(ringnum));
                        }
                        ringnum++;
                    }
                }
            }
            else
            {
                GlobalStats.TakingInput = true;
                this.PlanetName.HandleTextInput(ref this.PlanetName.Text, input);
            }
            this.GovernorDropdown.HandleInput(input);
            if (this.GovernorDropdown.Options[this.GovernorDropdown.ActiveIndex].@value != (int)this.p.colonyType)
            {
                this.p.colonyType = (Planet.ColonyType)this.GovernorDropdown.Options[this.GovernorDropdown.ActiveIndex].@value;
                if (this.p.colonyType != Planet.ColonyType.Colony)
                {
                    this.p.FoodLocked = true;
                    this.p.ProdLocked = true;
                    this.p.ResLocked = true;
                    this.p.GovernorOn = true;
                }
                else
                {
                    this.p.GovernorOn = false;
                    this.p.FoodLocked = false;
                    this.p.ProdLocked = false;
                    this.p.ResLocked = false;
                }
            }
            this.HandleSlider();
            if (this.p.HasShipyard && this.build.Tabs.Count > 1 && this.build.Tabs[1].Selected)
            {
                if (HelperFunctions.CheckIntersection(this.playerDesignsToggle.r, input.CursorPosition))
                {
                    ToolTip.CreateTooltip(Localizer.Token(2225), this.ScreenManager);
                }
                if (this.playerDesignsToggle.HandleInput(input))
                {
                    AudioManager.PlayCue("sd_ui_accept_alt3");
                    GlobalStats.ShowAllDesigns = !GlobalStats.ShowAllDesigns;
                    if (GlobalStats.ShowAllDesigns)
                    {
                        this.playerDesignsToggle.Active = true;
                    }
                    else
                    {
                        this.playerDesignsToggle.Active = false;
                    }
                    this.Reset = true;
                }
            }
            if (this.p.colonyType != Planet.ColonyType.Colony)
            {
                this.FoodLock.Locked = true;
                this.ProdLock.Locked = true;
                this.ResLock.Locked = true;
            }
            else
            {
                if (!HelperFunctions.CheckIntersection(this.FoodLock.LockRect, MousePos) || this.p.Owner == null || this.p.Owner.data.Traits.Cybernetic != 0)
                {
                    this.FoodLock.Hover = false;
                }
                else
                {
                    if (this.FoodLock.Locked)
                    {
                        this.FoodLock.Hover = false;
                        if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                        {
                            this.p.FoodLocked = false;
                            this.FoodLock.Locked = false;
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    else
                    {
                        this.FoodLock.Hover = true;
                        if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                        {
                            this.p.FoodLocked = true;
                            this.FoodLock.Locked = true;
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    ToolTip.CreateTooltip(69, this.ScreenManager);
                }
                if (!HelperFunctions.CheckIntersection(this.ProdLock.LockRect, MousePos))
                {
                    this.ProdLock.Hover = false;
                }
                else
                {
                    if (this.ProdLock.Locked)
                    {
                        this.ProdLock.Hover = false;
                        if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                        {
                            this.p.ProdLocked = false;
                            this.ProdLock.Locked = false;
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    else
                    {
                        this.ProdLock.Hover = true;
                        if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                        {
                            this.p.ProdLocked = true;
                            this.ProdLock.Locked = true;
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    ToolTip.CreateTooltip(69, this.ScreenManager);
                }
                if (!HelperFunctions.CheckIntersection(this.ResLock.LockRect, MousePos))
                {
                    this.ResLock.Hover = false;
                }
                else
                {
                    if (this.ResLock.Locked)
                    {
                        this.ResLock.Hover = false;
                        if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                        {
                            this.p.ResLocked = false;
                            this.ResLock.Locked = false;
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    else
                    {
                        this.ResLock.Hover = true;
                        if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                        {
                            this.p.ResLocked = true;
                            this.ResLock.Locked = true;
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    ToolTip.CreateTooltip(69, this.ScreenManager);
                }
            }
            this.selector = null;
            this.ClickedTroop = false;
            foreach (PlanetGridSquare pgs in this.p.TilesList)
            {
                if (!HelperFunctions.CheckIntersection(pgs.ClickRect, MousePos))
                {
                    pgs.highlighted = false;
                }
                else
                {
                    if (!pgs.highlighted)
                    {
                        AudioManager.PlayCue("sd_ui_mouseover");
                    }
                    pgs.highlighted = true;
                }
                if (pgs.TroopsHere.Count <= 0 || !HelperFunctions.CheckIntersection(pgs.TroopClickRect, MousePos))
                {
                    continue;
                }
                this.detailInfo = pgs.TroopsHere[0];
                if (input.RightMouseClick && pgs.TroopsHere[0].GetOwner() == EmpireManager.GetEmpireByName(PlanetScreen.screen.PlayerLoyalty))
                {
                    AudioManager.PlayCue("sd_troop_takeoff");
                    ResourceManager.CreateTroopShipAtPoint((this.p.Owner.data.DefaultTroopShip != null) ? this.p.Owner.data.DefaultTroopShip : this.p.Owner.data.DefaultSmallTransport, this.p.Owner, this.p.Position, pgs.TroopsHere[0]);
                    this.p.TroopsHere.Remove(pgs.TroopsHere[0]);
                    pgs.TroopsHere[0].SetPlanet(null);
                    pgs.TroopsHere.Clear();
                    this.ClickedTroop = true;
                    this.detailInfo = null;
                    rmouse = true;
                }
                return;
            }
            if (!this.ClickedTroop)
            {
                foreach (PlanetGridSquare pgs in this.p.TilesList)
                {
                    if (HelperFunctions.CheckIntersection(pgs.ClickRect, input.CursorPosition))
                    {
                        this.detailInfo = pgs;
                        Rectangle bRect = new Rectangle(pgs.ClickRect.X + pgs.ClickRect.Width / 2 - 32, pgs.ClickRect.Y + pgs.ClickRect.Height / 2 - 32, 64, 64);
                        if (pgs.building != null && pgs.building.Scrappable && HelperFunctions.CheckIntersection(bRect, input.CursorPosition) && input.RightMouseClick)
                        {
                            this.toScrap = pgs.building;
                            string message = string.Concat("Do you wish to scrap ", Localizer.Token(pgs.building.NameTranslationIndex), "? Half of the building's construction cost will be recovered to your storage.");
                            MessageBoxScreen messageBox = new MessageBoxScreen(message);
                            messageBox.Accepted += new EventHandler<EventArgs>(this.ScrapAccepted);
                            this.ScreenManager.AddScreen(messageBox);
                            this.ClickedTroop = true;
                            rmouse = true;
                            return;
                        }
                    }
                    if (pgs.TroopsHere.Count <= 0 || !HelperFunctions.CheckIntersection(pgs.TroopClickRect, input.CursorPosition))
                    {
                        continue;
                    }
                    this.detailInfo = pgs.TroopsHere;
                }
            }
            if (!GlobalStats.HardcoreRuleset)
            {
                if (HelperFunctions.CheckIntersection(this.foodDropDown.r, MousePos) && this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                {
                    this.foodDropDown.Toggle();
                    Planet planet = this.p;
                    planet.fs = (Planet.GoodState)((int)planet.fs + (int)Planet.GoodState.IMPORT);
                    if (this.p.fs > Planet.GoodState.EXPORT)
                    {
                        this.p.fs = Planet.GoodState.STORE;
                    }
                    AudioManager.PlayCue("sd_ui_accept_alt3");
                }
                if (HelperFunctions.CheckIntersection(this.prodDropDown.r, MousePos) && this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                {
                    this.prodDropDown.Toggle();
                    AudioManager.PlayCue("sd_ui_accept_alt3");
                    Planet planet1 = this.p;
                    planet1.ps = (Planet.GoodState)((int)planet1.ps + (int)Planet.GoodState.IMPORT);
                    if (this.p.ps > Planet.GoodState.EXPORT)
                    {
                        this.p.ps = Planet.GoodState.STORE;
                    }
                }
            }
            else
            {
                foreach (ThreeStateButton b in this.ResourceButtons)
                {
                    b.HandleInput(input, this.ScreenManager);
                }
            }
            for (int i = this.QSL.indexAtTop; i < this.QSL.Copied.Count && i < this.QSL.indexAtTop + this.QSL.entriesToDisplay; i++)
            {
                try
                {
                    ScrollList.Entry e = this.QSL.Copied[i];
                    if (!HelperFunctions.CheckIntersection(e.clickRect, MousePos))
                    {
                        e.clickRectHover = 0;
                    }
                    else
                    {
                        this.selector = new Selector(this.ScreenManager, e.clickRect);
                        if (e.clickRectHover == 0)
                        {
                            AudioManager.PlayCue("sd_ui_mouseover");
                        }
                        e.clickRectHover = 1;
                    }
                    if (HelperFunctions.CheckIntersection(e.up, MousePos))
                    {
                        ToolTip.CreateTooltip(63, PlanetScreen.screen.ScreenManager);
                        if (!input.CurrentKeyboardState.IsKeyDown(Keys.RightControl) && !input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl) || this.currentMouse.LeftButton != ButtonState.Pressed || this.previousMouse.LeftButton != ButtonState.Released)
                        {
                            if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released && i > 0)
                            {
                                object tmp = this.p.ConstructionQueue[i - 1];
                                this.p.ConstructionQueue[i - 1] = this.p.ConstructionQueue[i];
                                this.p.ConstructionQueue[i] = tmp as QueueItem;
                                AudioManager.PlayCue("sd_ui_accept_alt3");
                            }
                        }
                        else if (i > 0)
                        {
                            LinkedList<QueueItem> copied = new LinkedList<QueueItem>();
                            foreach (QueueItem qi in this.p.ConstructionQueue)
                            {
                                copied.AddLast(qi);
                            }
                            copied.Remove(this.p.ConstructionQueue[i]);
                            copied.AddFirst(this.p.ConstructionQueue[i]);
                            this.p.ConstructionQueue.Clear();
                            foreach (QueueItem qi in copied)
                            {
                                this.p.ConstructionQueue.Add(qi);
                            }
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                            break;
                        }
                    }
                    if (HelperFunctions.CheckIntersection(e.down, MousePos))
                    {
                        ToolTip.CreateTooltip(64, PlanetScreen.screen.ScreenManager);
                        if (!input.CurrentKeyboardState.IsKeyDown(Keys.RightControl) && !input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl) || this.currentMouse.LeftButton != ButtonState.Pressed || this.previousMouse.LeftButton != ButtonState.Released)
                        {
                            if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released && i + 1 < this.QSL.Copied.Count)
                            {
                                object tmp = this.p.ConstructionQueue[i + 1];
                                this.p.ConstructionQueue[i + 1] = this.p.ConstructionQueue[i];
                                this.p.ConstructionQueue[i] = tmp as QueueItem;
                                AudioManager.PlayCue("sd_ui_accept_alt3");
                            }
                        }
                        else if (i + 1 < this.QSL.Copied.Count)
                        {
                            LinkedList<QueueItem> copied = new LinkedList<QueueItem>();
                            foreach (QueueItem qi in this.p.ConstructionQueue)
                            {
                                copied.AddLast(qi);
                            }
                            copied.Remove(this.p.ConstructionQueue[i]);
                            copied.AddLast(this.p.ConstructionQueue[i]);
                            this.p.ConstructionQueue.Clear();
                            foreach (QueueItem qi in copied)
                            {
                                this.p.ConstructionQueue.Add(qi);
                            }
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                            break;
                        }
                    }
                    if (HelperFunctions.CheckIntersection(e.apply, MousePos) && !this.p.RecentCombat && this.p.Crippled_Turns <= 0)
                    {
                        if (!input.CurrentKeyboardState.IsKeyDown(Keys.RightControl) && !input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl) || this.currentMouse.LeftButton != ButtonState.Pressed || this.previousMouse.LeftButton != ButtonState.Released)
                        {
                            if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                            {

                                if (this.p.ApplyStoredProduction(i))
                                {
                                    AudioManager.PlayCue("sd_ui_accept_alt3");
                                }
                                else
                                {
                                    AudioManager.PlayCue("UI_Misc20");
                                }
                            }
                        }
                        //else if (PlanetScreen.screen.Debug)
                        //{
                        //    this.p.ApplyProductiontoQueue(this.p.ConstructionQueue[i].Cost - this.p.ConstructionQueue[i].productionTowards, i);
                        //}
                        else if (this.p.ProductionHere == 0f)
                        {
                            AudioManager.PlayCue("UI_Misc20");
                        }
                        else
                        {
                            this.p.ApplyAllStoredProduction(i);
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                    if (HelperFunctions.CheckIntersection(e.cancel, MousePos) && this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                    {
                        Planet productionHere2 = this.p;
                        productionHere2.ProductionHere = productionHere2.ProductionHere + (e.item as QueueItem).productionTowards;
                        if (this.p.ProductionHere > this.p.MAX_STORAGE)
                        {
                            this.p.ProductionHere = this.p.MAX_STORAGE;
                        }
                        QueueItem item = (e.item as QueueItem);
                        if (item.pgs != null)
                        {
                            (e.item as QueueItem).pgs.QItem = null;
                        }
                        if(item.Goal !=null)
                        {
                            if(item.Goal.GoalName=="BuildConstructionShip")
                            {
                                p.Owner.GetGSAI().Goals.Remove(item.Goal);

                            }
                            if(item.Goal.GetFleet() !=null)
                                p.Owner.GetGSAI().Goals.Remove(item.Goal);

                        }
                        this.p.ConstructionQueue.Remove(e.item as QueueItem);
                        AudioManager.PlayCue("sd_ui_accept_alt3");
                    }
                }
                catch
                {
                }
            }
            this.QSL.HandleInput(input, this.p);
            if (this.ActiveBuildingEntry != null)
            {
                foreach (PlanetGridSquare pgs in this.p.TilesList)
                {
                    if (!HelperFunctions.CheckIntersection(pgs.ClickRect, MousePos) || this.currentMouse.LeftButton != ButtonState.Released || this.previousMouse.LeftButton != ButtonState.Pressed)
                    {
                        continue;
                    }
                    if (pgs.Habitable && pgs.building == null && pgs.QItem == null && (this.ActiveBuildingEntry.item as Building).Name != "Biospheres")
                    {
                        QueueItem qi = new QueueItem();
                        //{
                        qi.isBuilding = true;
                        qi.Building = this.ActiveBuildingEntry.item as Building;
                        qi.Cost = ResourceManager.BuildingsDict[qi.Building.Name].Cost * UniverseScreen.GamePaceStatic;
                        qi.productionTowards = 0f;
                        qi.pgs = pgs;
                        //};
                        pgs.QItem = qi;
                        this.p.ConstructionQueue.Add(qi);
                        this.ActiveBuildingEntry = null;
                        break;
                    }
                    else if (pgs.Habitable || pgs.Biosphere || pgs.QItem != null || !(this.ActiveBuildingEntry.item as Building).CanBuildAnywhere)
                    {
                        AudioManager.PlayCue("UI_Misc20");
                        this.ActiveBuildingEntry = null;
                        break;
                    }
                    else
                    {
                        QueueItem qi = new QueueItem();
                        //{
                        qi.isBuilding = true;
                        qi.Building = this.ActiveBuildingEntry.item as Building;
                        qi.Cost = ResourceManager.BuildingsDict[qi.Building.Name].Cost * UniverseScreen.GamePaceStatic;
                        qi.productionTowards = 0f;
                        qi.pgs = pgs;
                        //};
                        pgs.QItem = qi;
                        this.p.ConstructionQueue.Add(qi);
                        this.ActiveBuildingEntry = null;
                        break;
                    }
                }
                if (this.ActiveBuildingEntry != null)
                {
                    foreach (QueueItem qi in this.p.ConstructionQueue)
                    {
                        if (!qi.isBuilding || !(qi.Building.Name == (this.ActiveBuildingEntry.item as Building).Name) || !(this.ActiveBuildingEntry.item as Building).Unique)
                        {
                            continue;
                        }
                        this.ActiveBuildingEntry = null;
                        break;
                    }
                }
                if (this.currentMouse.RightButton == ButtonState.Pressed && this.previousMouse.RightButton == ButtonState.Released)
                {
                    this.ClickedTroop = true;
                    this.ActiveBuildingEntry = null;
                }
                if (this.currentMouse.LeftButton == ButtonState.Released && this.previousMouse.LeftButton == ButtonState.Pressed)
                {
                    this.ClickedTroop = true;
                    this.ActiveBuildingEntry = null;
                }
            }
            for (int i = this.buildSL.indexAtTop; i < this.buildSL.Copied.Count && i < this.buildSL.indexAtTop + this.buildSL.entriesToDisplay; i++)
            {
                ScrollList.Entry e = this.buildSL.Copied[i];
                if (e.item is ModuleHeader)
                {
                    (e.item as ModuleHeader).HandleInput(input, e);
                }
                else if (!HelperFunctions.CheckIntersection(e.clickRect, MousePos))
                {
                    e.clickRectHover = 0;
                }
                else
                {
                    this.selector = new Selector(this.ScreenManager, e.clickRect);
                    if (e.clickRectHover == 0)
                    {
                        AudioManager.PlayCue("sd_ui_mouseover");
                    }
                    e.clickRectHover = 1;
                    if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Pressed && e.item is Building && this.ActiveBuildingEntry == null)
                    {
                        this.ActiveBuildingEntry = e;
                    }
                    if (this.currentMouse.LeftButton == ButtonState.Released && this.previousMouse.LeftButton == ButtonState.Pressed)
                    {
                        if (this.ClickTimer >= this.TimerDelay)
                        {
                            this.ClickTimer = 0f;
                        }
                        else
                        {
                            Rectangle rectangle = e.addRect;
                            if (!HelperFunctions.CheckIntersection(e.addRect, input.CursorPosition))
                            {
                                QueueItem qi = new QueueItem();
                                if (e.item is Ship)
                                {
                                    qi.isShip = true;
                                    qi.sData = (e.item as Ship).GetShipData();
                                    qi.Cost = (e.item as Ship).GetCost(this.p.Owner);
                                    qi.productionTowards = 0f;
                                    this.p.ConstructionQueue.Add(qi);
                                    AudioManager.PlayCue("sd_ui_mouseover");
                                }
                                else if (e.item is Troop)
                                {
                                    qi.isTroop = true;
                                    qi.troop = e.item as Troop;
                                    qi.Cost = (e.item as Troop).GetCost();
                                    qi.productionTowards = 0f;
                                    this.p.ConstructionQueue.Add(qi);
                                    AudioManager.PlayCue("sd_ui_mouseover");
                                }
                                else if (e.item is Building)
                                {
                                    this.p.AddBuildingToCQ(ResourceManager.GetBuilding((e.item as Building).Name));
                                    AudioManager.PlayCue("sd_ui_mouseover");
                                }
                            }
                        }
                    }
                }
                Rectangle rectangle1 = e.addRect;
                if (!HelperFunctions.CheckIntersection(e.addRect, MousePos))
                {
                    e.PlusHover = 0;
                }
                else
                {
                    e.PlusHover = 1;
                    ToolTip.CreateTooltip(51, this.ScreenManager);
                    if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                    {
                        QueueItem qi = new QueueItem();
                        if (e.item is Building)
                        {
                            this.p.AddBuildingToCQ(ResourceManager.GetBuilding((e.item as Building).Name));
                        }
                        else if (e.item is Ship)
                        {
                            qi.isShip = true;
                            qi.sData = (e.item as Ship).GetShipData();
                            qi.Cost = (e.item as Ship).GetCost(this.p.Owner);
                            qi.productionTowards = 0f;
                            this.p.ConstructionQueue.Add(qi);
                        }
                        else if (e.item is Troop)
                        {
                            qi.isTroop = true;
                            qi.troop = e.item as Troop;
                            qi.Cost = (e.item as Troop).GetCost();
                            qi.productionTowards = 0f;
                            this.p.ConstructionQueue.Add(qi);
                        }
                    }
                }
                Rectangle rectangle2 = e.editRect;
                if (!HelperFunctions.CheckIntersection(e.editRect, MousePos))
                {
                    e.EditHover = 0;
                }
                else
                {
                    e.EditHover = 1;
                    ToolTip.CreateTooltip(52, this.ScreenManager);
                    if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Released)
                    {
                        ShipDesignScreen sdScreen = new ShipDesignScreen(this.eui);
                        this.ScreenManager.AddScreen(sdScreen);
                        sdScreen.ChangeHull((e.item as Ship).GetShipData());
                    }
                }
            }
            this.shipsCanBuildLast = this.p.Owner.ShipsWeCanBuild.Count;
            this.buildingsHereLast = this.p.BuildingList.Count;
            this.buildingsCanBuildLast = this.BuildingsCanBuild.Count;
            if (input.RightMouseClick && !this.ClickedTroop) rmouse = false;
            if (!rmouse && (input.CurrentMouseState.RightButton != ButtonState.Released || this.previousMouse.RightButton != ButtonState.Released))
            {
                this.eui.screen.ShipsInCombat.Active = true;
                this.eui.screen.PlanetsInCombat.Active = true;
            }
            this.previousMouse = this.currentMouse;
        }
 private void TrySave()
 {
     bool needOverWriteConfirmation = true;
     bool SaveOK = true;
     bool Reserved = false;
     foreach (KeyValuePair<string, Ship_Game.Gameplay.Ship> Ship in ResourceManager.ShipsDict)
     {
         if (this.EnterNameArea.Text != Ship.Value.Name)
         {
             continue;
         }
         needOverWriteConfirmation = true;
         SaveOK = false;
         if (!Ship.Value.reserved)
         {
             continue;
         }
         Reserved = true;
     }
     if (Reserved && !this.screen.EmpireUI.screen.Debug)
     {
         AudioManager.PlayCue("UI_Misc20");
         MessageBoxScreen messageBox = new MessageBoxScreen(string.Concat(this.EnterNameArea.Text, " is a reserved ship name and you cannot overwrite this design"));
         base.ScreenManager.AddScreen(messageBox);
         return;
     }
     if (!SaveOK)
     {
         if (needOverWriteConfirmation)
         {
             MessageBoxScreen messageBox = new MessageBoxScreen("Design name already exists.  Overwrite?");
             messageBox.Accepted += new EventHandler<EventArgs>(this.OverWriteAccepted);
             base.ScreenManager.AddScreen(messageBox);
         }
         return;
     }
     AudioManager.PlayCue("echo_affirm1");
     if (this.screen != null)
     {
         this.screen.SaveShipDesign(this.EnterNameArea.Text);
     }
     this.ExitScreen();
 }
 public override void HandleInput(InputState input)
 {
     this.currentMouse = input.CurrentMouseState;
     Vector2 MousePos = new Vector2((float)this.currentMouse.X, (float)this.currentMouse.Y);
     this.ShipDesigns.HandleInput(input);
     if (input.Escaped || input.RightMouseClick)
     {
         this.ExitScreen();
     }
     foreach (UIButton b in this.Buttons)
     {
         if (!HelperFunctions.CheckIntersection(b.Rect, MousePos))
         {
             b.State = UIButton.PressState.Normal;
         }
         else
         {
             b.State = UIButton.PressState.Hover;
             if (this.currentMouse.LeftButton == ButtonState.Pressed && this.previousMouse.LeftButton == ButtonState.Pressed)
             {
                 b.State = UIButton.PressState.Pressed;
             }
             if (this.currentMouse.LeftButton != ButtonState.Released || this.previousMouse.LeftButton != ButtonState.Pressed)
             {
                 continue;
             }
             string launches = b.Launches;
             if (launches == null || !(launches == "Load"))
             {
                 continue;
             }
             this.LoadShipToScreen();
         }
     }
     this.selector = null;
     for (int i = this.ShipDesigns.indexAtTop; i < this.ShipDesigns.Copied.Count && i < this.ShipDesigns.indexAtTop + this.ShipDesigns.entriesToDisplay; i++)
     {
         ScrollList.Entry e = this.ShipDesigns.Copied[i];
         if (e.item is ModuleHeader)
         {
             (e.item as ModuleHeader).HandleInput(input, e);
         }
         else if (e.item is ShipData)
         {
             if (!HelperFunctions.CheckIntersection(e.clickRect, MousePos))
             {
                 e.clickRectHover = 0;
             }
             else
             {
                 if (HelperFunctions.CheckIntersection(e.cancel, MousePos) && input.InGameSelect)
                 {
                     this.ShipToDelete = (e.item as ShipData).Name;
                     MessageBoxScreen messageBox = new MessageBoxScreen("Confirm Delete:");
                     messageBox.Accepted += new EventHandler<EventArgs>(this.DeleteDataAccepted);
                     base.ScreenManager.AddScreen(messageBox);
                 }
                 this.selector = new Selector(base.ScreenManager, e.clickRect);
                 if (e.clickRectHover == 0)
                 {
                     AudioManager.PlayCue("sd_ui_mouseover");
                 }
                 e.clickRectHover = 1;
                 if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
                 {
                     this.EnterNameArea.Text = (e.item as ShipData).Name;
                     this.selectedWIP = e.item as ShipData;
                     AudioManager.PlayCue("sd_ui_accept_alt3");
                 }
             }
         }
         else if (!HelperFunctions.CheckIntersection(e.clickRect, MousePos))
         {
             e.clickRectHover = 0;
         }
         else
         {
             if (HelperFunctions.CheckIntersection(e.cancel, MousePos) && !(e.item as Ship).reserved && !(e.item as Ship).FromSave && input.InGameSelect)
             {
                 this.ShipToDelete = (e.item as Ship).Name;
                 MessageBoxScreen messageBox = new MessageBoxScreen("Confirm Delete:");
                 messageBox.Accepted += new EventHandler<EventArgs>(this.DeleteAccepted);
                 base.ScreenManager.AddScreen(messageBox);
             }
             this.selector = new Selector(base.ScreenManager, e.clickRect);
             if (e.clickRectHover == 0)
             {
                 AudioManager.PlayCue("sd_ui_mouseover");
             }
             e.clickRectHover = 1;
             if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
             {
                 this.EnterNameArea.Text = (e.item as Ship).Name;
                 AudioManager.PlayCue("sd_ui_accept_alt3");
             }
         }
     }
     if (this.playerDesignsToggle.HandleInput(input))
     {
         AudioManager.PlayCue("sd_ui_accept_alt3");
         this.ShowAllDesigns = !this.ShowAllDesigns;
         if (this.ShowAllDesigns)
         {
             this.playerDesignsToggle.Active = true;
         }
         else
         {
             this.playerDesignsToggle.Active = false;
         }
         this.ResetSL();
     }
     if (HelperFunctions.CheckIntersection(this.playerDesignsToggle.r, input.CursorPosition))
     {
         ToolTip.CreateTooltip(Localizer.Token(2225), base.ScreenManager);
     }
     this.previousMouse = input.LastMouseState;
     base.HandleInput(input);
 }
 private void TrySave()
 {
     bool needOverWriteConfirmation = true;
     bool SaveOK = true;
     foreach (ScrollList.Entry entry in this.SavesSL.Entries)
     {
         if (this.EnterNameArea.Text != (entry.item as HeaderData).SaveName)
         {
             continue;
         }
         needOverWriteConfirmation = true;
         SaveOK = false;
     }
     if (SaveOK)
     {
         this.DoSave();
         return;
     }
     if (needOverWriteConfirmation)
     {
         MessageBoxScreen messageBox = new MessageBoxScreen("Saved Game already exists.  Overwrite?");
         messageBox.Accepted += new EventHandler<EventArgs>(this.OverWriteAccepted);
         base.ScreenManager.AddScreen(messageBox);
     }
 }