public override void HandleInput(InputState input)
 {
     if (input.Escaped)
     {
         this.ExitScreen();
     }
     foreach (UIButton b in this.Buttons)
     {
         if (!HelperFunctions.CheckIntersection(b.Rect, input.CursorPosition))
         {
             b.State = UIButton.PressState.Normal;
         }
         else
         {
             b.State = UIButton.PressState.Hover;
             if (this.mouseStateCurrent.LeftButton == ButtonState.Pressed && this.mouseStatePrevious.LeftButton == ButtonState.Pressed)
             {
                 b.State = UIButton.PressState.Pressed;
             }
             if (this.mouseStateCurrent.LeftButton != ButtonState.Released || this.mouseStatePrevious.LeftButton != ButtonState.Pressed)
             {
                 continue;
             }
             string text = b.Text;
         }
     }
     base.HandleInput(input);
 }
 public override void HandleInput(InputState input)
 {
     if (this.close.HandleInput(input))
     {
         this.ExitScreen();
         return;
     }
     if (input.Escaped)
     {
         this.ExitScreen();
     }
     if (input.Right || input.InGameSelect)
     {
         TutorialScreen index = this;
         index.Index = index.Index + 1;
         if (this.Index > this.TexDict.Count - 1)
         {
             this.Index = 0;
         }
     }
     if (input.Left || input.RightMouseClick)
     {
         TutorialScreen tutorialScreen = this;
         tutorialScreen.Index = tutorialScreen.Index - 1;
         if (this.Index < 0)
         {
             this.Index = this.TexDict.Count - 1;
         }
     }
 }
 public override void HandleInput(InputState input)
 {
     if (input.MenuUp)
     {
         this.beep = AudioManager.GetCue("blip_click");
         this.beep.Play();
         MenuScreen menuScreen = this;
         menuScreen.selectedEntry = menuScreen.selectedEntry - 1;
         if (this.selectedEntry < 0)
         {
             this.selectedEntry = this.menuEntries.Count - 1;
         }
     }
     if (input.MenuDown)
     {
         this.beep = AudioManager.GetCue("blip_click");
         this.beep.Play();
         MenuScreen menuScreen1 = this;
         menuScreen1.selectedEntry = menuScreen1.selectedEntry + 1;
         if (this.selectedEntry >= this.menuEntries.Count)
         {
             this.selectedEntry = 0;
         }
     }
     if (input.MenuSelect)
     {
         this.OnSelectEntry(this.selectedEntry);
         return;
     }
     if (input.MenuCancel)
     {
         this.OnCancel();
     }
 }
        //added by gremlin MissionHandleInput
        public void HandleInput(InputState input)
        {
            //if (this.Available)
            {
                if (!HelperFunctions.CheckIntersection(this.DoMission.Rect, input.CursorPosition))
                {
                    this.DoMission.State = UIButton.PressState.Normal;

                }
                else
                {
                    if (this.DoMission.State != UIButton.PressState.Hover && this.DoMission.State != UIButton.PressState.Pressed)
                    {
                        AudioManager.PlayCue("mouse_over4");
                    }
                    this.DoMission.State = UIButton.PressState.Hover;
                    if (input.CurrentMouseState.LeftButton == ButtonState.Pressed)
                    {
                        this.DoMission.State = UIButton.PressState.Pressed;
                    }
                    if (input.InGameSelect)
                    {
                        this.Component.SelectedAgent.AssignMission(this.TheMission, EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty), this.Component.Escreen.SelectedEmpire.data.Traits.Name);
                        return;
                    }
                }
            }
        }
        public bool HandleInput(InputState input)
        {
            if (this.saved)
            {
                this.saved = false;

                return true;
            }

            if (!HelperFunctions.CheckIntersection(this.rect, input.CursorPosition))
            {
                this.Hover = false;
            }
            else
            {
                if (!this.Hover)
                {
                    AudioManager.PlayCue("sd_ui_mouseover");
                }
                this.Hover = true;
                if (input.InGameSelect)
                {

                    AudioManager.PlayCue("mouse_over4");
                    if (this.saveButton != null)
                    {
                        this.saveButton.saved = true;
                        this.saveButton.Text = this.Text;
                        this.saveButton.Ascending = this.Ascending;
                    }
                    return true;
                }
            }
            return false;
        }
 public bool HandleInput(InputState input, ScrollList.Entry e)
 {
     if (!HelperFunctions.CheckIntersection(e.clickRect, input.CursorPosition))
     {
         this.Hover = false;
     }
     else
     {
         this.Hover = true;
         if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
         {
             AudioManager.PlayCue("sd_ui_accept_alt3");
             this.Open = !this.Open;
             e.ShowingSub = !e.ShowingSub;
             if (!this.Open)
             {
                 int num = 0;
                 foreach (ScrollList.Entry subEntry in e.SubEntries)
                 {
                     num++;
                 }
                 ScrollList parentList = e.ParentList;
                 parentList.indexAtTop = parentList.indexAtTop - num;
                 if (e.ParentList.indexAtTop < 0)
                 {
                     e.ParentList.indexAtTop = 0;
                 }
             }
             e.ParentList.Update();
             return true;
         }
     }
     return false;
 }
 public bool HandleInput(InputState input)
 {
     if (!HelperFunctions.CheckIntersection(this.r, input.CursorPosition))
     {
         this.Hover = false;
     }
     else
     {
         this.Hover = true;
         if (this.LocalizerTip != 0)
         {
             if (string.IsNullOrEmpty(this.Hotkey))
             {
                 ToolTip.CreateTooltip(Localizer.Token(this.LocalizerTip), Ship.universeScreen.ScreenManager, this.Hotkey);
             }
             else
             {
                 ToolTip.CreateTooltip(Localizer.Token(this.LocalizerTip), Ship.universeScreen.ScreenManager);
             }
         }
         if (input.InGameSelect)
         {
             return true;
         }
     }
     return false;
 }
 public bool HandleInput(InputState input)
 {
     if (HelperFunctions.CheckIntersection(this.CheckRect, input.CursorPosition) && input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
     {
         this.connectedTo.Value = !this.connectedTo.Value;
     }
     return false;
 }
 public static bool ClickedRect(Rectangle toClick, InputState input)
 {
     if (HelperFunctions.CheckIntersection(toClick, input.CursorPosition) && input.InGameSelect)
     {
         return true;
     }
     return false;
 }
 public override void HandleInput(InputState input)
 {
     if (input.Escaped)
     {
         this.ExitScreen();
     }
     base.HandleInput(input);
 }
 public override void HandleInput(InputState input)
 {
     if (this.handleInput)
     {
         if (input.AButtonDown)
         {
             this.ExitScreen();
         }
         this.HandleMouseInput();
     }
 }
 public bool HandleInput(InputState input)
 {
     this.Hover = false;
     if (HelperFunctions.CheckIntersection(this.ClickArea, input.CursorPosition))
     {
         this.Hover = true;
         if (input.InGameSelect)
         {
             this.Open = !this.Open;
             return true;
         }
     }
     return false;
 }
 public string HandleInput(InputState input)
 {
     if (!HelperFunctions.CheckIntersection(this.ClickRect, input.CursorPosition))
     {
         this.Hover = false;
     }
     else
     {
         this.Hover = true;
         if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
         {
             return this.Response;
         }
     }
     return null;
 }
 public bool HandleInput(InputState input)
 {
     if (!HelperFunctions.CheckIntersection(this.rect, input.CursorPosition))
     {
         this.Hover = false;
     }
     else
     {
         this.Hover = true;
         ToolTip.CreateTooltip("Exit Screen", Game1.Instance.screenManager);
         if (input.InGameSelect)
         {
             return true;
         }
     }
     return false;
 }
 public void HandleInput(InputState input, ScreenManager screenManager)
 {
     if (HelperFunctions.CheckIntersection(this.rect, input.CursorPosition))
     {
         ToolTip.CreateTooltip(string.Concat(ResourceManager.GoodsDict[this.Good].Name, " storage. \n\n Click to change Import/Export settings"), screenManager);
         if (input.InGameSelect)
         {
             AudioManager.PlayCue("sd_ui_accept_alt3");
             ThreeStateButton threeStateButton = this;
             threeStateButton.state = (ThreeStateButton.State)((int)threeStateButton.state + (int)ThreeStateButton.State.Out);
             if (this.state > ThreeStateButton.State.Store)
             {
                 this.state = ThreeStateButton.State.In;
             }
         }
     }
 }
 public bool HandleInput(InputState input)
 {
     if (!HelperFunctions.CheckIntersection(this.Button, input.CursorPosition))
     {
         this.Hover = false;
     }
     else
     {
         this.Hover = true;
         if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
         {
             AudioManager.PlayCue("echo_affirm");
             return true;
         }
     }
     return false;
 }
 public string HandleInput(InputState input, ScrollList.Entry e)
 {
     if (!HelperFunctions.CheckIntersection(this.ClickRect, input.CursorPosition))
     {
         this.Hover = false;
     }
     else
     {
         this.Hover = true;
         string response = (e.item as ItemToOffer).Response;
         string str = response;
         if (response != null)
         {
             if (str == "NAPact")
             {
                 ToolTip.CreateTooltip(129, Ship.universeScreen.ScreenManager);
             }
             else if (str == "OpenBorders")
             {
                 ToolTip.CreateTooltip(130, Ship.universeScreen.ScreenManager);
             }
             else if (str == "Peace Treaty")
             {
                 ToolTip.CreateTooltip(131, Ship.universeScreen.ScreenManager);
             }
             else if (str == "TradeTreaty")
             {
                 ToolTip.CreateTooltip(132, Ship.universeScreen.ScreenManager);
             }
             else if (str == "OfferAlliance")
             {
                 ToolTip.CreateTooltip(133, Ship.universeScreen.ScreenManager);
             }
         }
         if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released)
         {
             this.Selected = !this.Selected;
             e.ShowingSub = !e.ShowingSub;
             return this.Response;
         }
     }
     return null;
 }
 public bool HandleInput(InputState input)
 {
     if (!HelperFunctions.CheckIntersection(this.r, input.CursorPosition))
     {
         this.Hover = false;
     }
     else
     {
         this.Hover = true;
         if (input.InGameSelect)
         {
             AudioManager.PlayCue("sd_ui_accept_alt3");
             if (this.IsToggle)
             {
                 this.Toggled = !this.Toggled;
             }
             return true;
         }
     }
     return false;
 }
 public bool HandleInput(InputState input)
 {
     input.CursorPosition = this.Position;
     float x = this.Position.X / (float)base.GraphicsDevice.Viewport.Width;
     float y = this.Position.Y;
     Viewport viewport = base.GraphicsDevice.Viewport;
     input.NormalizedCursorPosition = new Vector2(x, y / (float)viewport.Height);
     bool retVal = this.pieMenu.Visible;
     if (this.cursorMode != CursorMode.GamePad)
     {
         Vector2 selDir = this.position - this.pieMenu.Position;
         selDir.Y = selDir.Y * -1f;
         selDir = selDir / this.pieMenu.Radius;
         this.pieMenu.HandleInput(input, selDir);
     }
     else
     {
         this.pieMenu.HandleInput(input);
     }
     this.deltaMovement = input.CurrentGamePadState.ThumbSticks.Left;
     this.deltaMovement.Y = this.deltaMovement.Y * -1f;
     return retVal;
 }
 public void HandleTextInput(ref string text, InputState input)
 {
     this.currentKeyboardState = Keyboard.GetState();
     Microsoft.Xna.Framework.Input.Keys[] keysArray = this.keysToCheck;
     for (int i = 0; i < (int)keysArray.Length; i++)
     {
         Microsoft.Xna.Framework.Input.Keys key = keysArray[i];
         if (this.CheckKey(key))
         {
             if (text.Length >= this.MaxCharacters)
             {
                 AudioManager.PlayCue("UI_Misc20");
             }
             else
             {
                 this.AddKeyToText(ref text, key);
                 AudioManager.PlayCue("blip_click");
                 break;
             }
         }
     }
     if (this.currentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Enter) || this.currentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape))
     {
         this.HandlingInput = false;
     }
     if (this.currentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Back) && this.boop == 0 && text.Length != 0)
     {
         text = text.Remove(text.Length - 1);
     }
     this.lastKeyboardState = this.currentKeyboardState;
     UITextEntry uITextEntry = this;
     uITextEntry.boop = uITextEntry.boop + 1;
     if (this.boop == 7)
     {
         this.boop = 0;
     }
 }
 public void HandleInput(InputState input, GameScreen caller)
 {
     for (int i = this.ResponseSL.indexAtTop; i < this.ResponseSL.Entries.Count && i < this.ResponseSL.indexAtTop + this.ResponseSL.entriesToDisplay; i++)
     {
         ScrollList.Entry e = this.ResponseSL.Entries[i];
         if (!HelperFunctions.CheckIntersection(e.clickRect, input.CursorPosition))
         {
             e.clickRectHover = 0;
         }
         else
         {
             e.clickRectHover = 1;
             if (input.InGameSelect)
             {
                 Response r = e.item as Response;
                 if (r.DefaultIndex != -1)
                 {
                     this.CurrentMessage = r.DefaultIndex;
                 }
                 else
                 {
                     bool OK = true;
                     if (r.MoneyToThem > 0 && this.playerEmpire.Money < (float)r.MoneyToThem)
                     {
                         OK = false;
                     }
                     if (r.RequiredTech != null && !this.playerEmpire.GetTDict()[r.RequiredTech].Unlocked)
                     {
                         OK = false;
                     }
                     if (r.FailIfNotAlluring && (double)this.playerEmpire.data.Traits.DiplomacyMod < 0.2)
                     {
                         OK = false;
                     }
                     if (!OK)
                     {
                         this.CurrentMessage = r.FailIndex;
                     }
                     else
                     {
                         this.CurrentMessage = r.SuccessIndex;
                         if (r.MoneyToThem > 0 && this.playerEmpire.Money >= (float)r.MoneyToThem)
                         {
                             Empire money = this.playerEmpire;
                             money.Money = money.Money - (float)r.MoneyToThem;
                         }
                     }
                 }
                 if (this.MessageList[this.CurrentMessage].SetWar)
                 {
                     this.empToDiscuss.GetGSAI().DeclareWarFromEvent(this.playerEmpire, WarType.SkirmishWar);
                 }
                 if (this.MessageList[this.CurrentMessage].EndWar)
                 {
                     this.empToDiscuss.GetGSAI().EndWarFromEvent(this.playerEmpire);
                 }
                 this.playerEmpire.GetRelations()[this.empToDiscuss].EncounterStep = this.MessageList[this.CurrentMessage].SetEncounterStep;
                 this.SetResponses();
             }
         }
     }
     if (this.MessageList[this.CurrentMessage].EndTransmission && (input.Escaped || input.CurrentMouseState.RightButton == ButtonState.Released && input.LastMouseState.RightButton == ButtonState.Pressed))
     {
         caller.ExitScreen();
     }
 }
 public void HandleInputorig(InputState input)
 {
     string Names;
     this.AgentSL.HandleInput(input);
     if (this.SelectedAgent != null)
     {
         this.OpsSL.HandleInput(input);
     }
     if (HelperFunctions.CheckIntersection(this.RecruitButton.r, input.CursorPosition))
     {
         ToolTip.CreateTooltip(Localizer.Token(2180), this.ScreenManager);
     }
     if (this.RecruitButton.HandleInput(input))
     {
         if (EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).Money < 250f)
         {
             AudioManager.PlayCue("UI_Misc20");
         }
         else
         {
             Empire empireByName = EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty);
             empireByName.Money = empireByName.Money - 250f;
             Names = (!File.Exists(string.Concat("Content/NameGenerators/spynames_", EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).data.Traits.ShipType, ".txt")) ? File.ReadAllText("Content/NameGenerators/spynames_Humans.txt") : File.ReadAllText(string.Concat("Content/NameGenerators/spynames_", EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).data.Traits.ShipType, ".txt")));
             string[] Tokens = Names.Split(new char[] { ',' });
             Agent a = new Agent()
             {
                 Name = AgentComponent.GetName(Tokens)
             };
             EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).data.AgentList.Add(a);
             this.AgentSL.AddItem(a);
         }
     }
     this.selector = null;
     for (int i = this.AgentSL.indexAtTop; i < this.AgentSL.Entries.Count && i < this.AgentSL.indexAtTop + this.AgentSL.entriesToDisplay; i++)
     {
         try
         {
             ScrollList.Entry e = this.AgentSL.Entries[i];
             if (HelperFunctions.CheckIntersection(e.clickRect, input.CursorPosition))
             {
                 this.selector = new Selector(this.ScreenManager, e.clickRect);
                 if (input.InGameSelect)
                 {
                     this.SelectedAgent = e.item as Agent;
                     foreach (ScrollList.Entry entry in this.OpsSL.Entries)
                     {
                         (entry.item as MissionEntry).Initialize();
                     }
                     AudioManager.PlayCue("sd_ui_accept_alt3");
                 }
             }
         }
         catch
         {
         }
     }
     if (this.SelectedAgent != null)
     {
         for (int i = this.OpsSL.indexAtTop; i < this.OpsSL.Entries.Count && i < this.OpsSL.indexAtTop + this.OpsSL.entriesToDisplay; i++)
         {
             try
             {
                 ScrollList.Entry e = this.OpsSL.Entries[i];
                 (e.item as MissionEntry).HandleInput(input);
                 if (HelperFunctions.CheckIntersection(e.clickRect, input.CursorPosition))
                 {
                     if (!HelperFunctions.CheckIntersection((e.item as MissionEntry).DoMission.Rect, input.CursorPosition))
                     {
                         ToolTip.CreateTooltip(Localizer.Token((e.item as MissionEntry).DescriptionIndex), this.ScreenManager);
                     }
                     else
                     {
                         ToolTip.CreateTooltip(Localizer.Token(2198), Ship.universeScreen.ScreenManager);
                     }
                 }
             }
             catch
             {
             }
         }
     }
 }
        //added by gremlin deveksmod Spy Handleinput
        public void HandleInput(InputState input)
        {
            string Names;
            this.AgentSL.HandleInput(input);
            if (this.SelectedAgent != null)
            {
                this.OpsSL.HandleInput(input);
            }
            if (HelperFunctions.CheckIntersection(this.RecruitButton.r, input.CursorPosition))
            {
                ToolTip.CreateTooltip(Localizer.Token(2180), this.ScreenManager);
            }
            if (this.RecruitButton.HandleInput(input))
            {
                if (EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).Money < (ResourceManager.AgentMissionData.AgentCost + ResourceManager.AgentMissionData.TrainingCost) || spyLimitCount <= 0)//EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).data.AgentList.Count >= EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).GetPlanets().Count)
                {
                    AudioManager.PlayCue("UI_Misc20");
                }
                else
                {
                    Empire empireByName = EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty);
                    empireByName.Money -= ResourceManager.AgentMissionData.AgentCost;
                    Names = (!File.Exists(string.Concat("Content/NameGenerators/spynames_", EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).data.Traits.ShipType, ".txt")) ? File.ReadAllText("Content/NameGenerators/spynames_Humans.txt") : File.ReadAllText(string.Concat("Content/NameGenerators/spynames_", EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).data.Traits.ShipType, ".txt")));
                    string[] Tokens = Names.Split(new char[] { ',' });
                    Agent a = new Agent();
                    a.Name = AgentComponent.GetName(Tokens);
                    //Added new agent information
                    a.Age = RandomMath.RandomBetween(20, 30);
                    int RandomPlanetIndex = HelperFunctions.GetRandomIndex(EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).GetPlanets().Count);
                    a.HomePlanet = EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).GetPlanets()[RandomPlanetIndex].Name;
                    EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).data.AgentList.Add(a);
                    this.AgentSL.AddItem(a);
                    a.AssignMission(AgentMission.Training, empireByName, "");

                }
            }
            this.selector = null;
            for (int i = this.AgentSL.indexAtTop; i < this.AgentSL.Entries.Count && i < this.AgentSL.indexAtTop + this.AgentSL.entriesToDisplay; i++)
            {
                try
                {
                    ScrollList.Entry e = this.AgentSL.Entries[i];
                    if (HelperFunctions.CheckIntersection(e.clickRect, input.CursorPosition))
                    {
                        this.selector = new Selector(this.ScreenManager, e.clickRect);
                        if (input.InGameSelect)
                        {
                            this.SelectedAgent = e.item as Agent;
                            foreach (ScrollList.Entry entry in this.OpsSL.Entries)
                            {
                                (entry.item as MissionEntry).Initialize();
                            }
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                        }
                    }
                }
                catch
                {
                }
            }
            if (this.SelectedAgent != null)
            {
                for (int i = this.OpsSL.indexAtTop; i < this.OpsSL.Entries.Count && i < this.OpsSL.indexAtTop + this.OpsSL.entriesToDisplay; i++)
                {
                    try
                    {
                        ScrollList.Entry e = this.OpsSL.Entries[i];
                        (e.item as MissionEntry).HandleInput(input);
                        if (HelperFunctions.CheckIntersection(e.clickRect, input.CursorPosition))
                        {
                            if (!HelperFunctions.CheckIntersection((e.item as MissionEntry).DoMission.Rect, input.CursorPosition))
                            {
                                ToolTip.CreateTooltip(Localizer.Token((e.item as MissionEntry).DescriptionIndex), this.ScreenManager);
                            }
                            else
                            {
                                ToolTip.CreateTooltip(Localizer.Token(2198), Ship.universeScreen.ScreenManager);
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
            if (CBAutoRepeat != null && cbSpyMute != null)
            {
                CBAutoRepeat.HandleInput(input);
                cbSpyMute.HandleInput(input);
            }
        }
        public bool HandleInput(InputState input)
        {
            if (!this.ColonyShipDropDown.Open)
            {
                if (!this.ScoutDropDown.Open)
                {
                    if (!this.ConstructorDropDown.Open)
                    {
                        this.AutoFreighterDropDown.HandleInput(input);
                    }
                }
            }
            try
            {
                EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).data.CurrentAutoFreighter = this.AutoFreighterDropDown.Options[this.AutoFreighterDropDown.ActiveIndex].Name;
            }
            catch
            {
                this.AutoFreighterDropDown.ActiveIndex = 0;
            }

            if (!this.AutoFreighterDropDown.Open)
            {
                if (!this.ScoutDropDown.Open)
                {
                    if (!this.ConstructorDropDown.Open)
                    {
                        this.ColonyShipDropDown.HandleInput(input);
                    }
                }
            }
            try
            {
                EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).data.CurrentAutoColony = this.ColonyShipDropDown.Options[this.ColonyShipDropDown.ActiveIndex].Name;
            }
            catch
            {
                this.ColonyShipDropDown.ActiveIndex = 0;
            }

            if (!this.ColonyShipDropDown.Open)
            {
                if (!this.AutoFreighterDropDown.Open)
                {
                    if (!this.ConstructorDropDown.Open)
                    {
                        this.ScoutDropDown.HandleInput(input);
                    }
                }
            }
            try
            {
                EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).data.CurrentAutoScout = this.ScoutDropDown.Options[this.ScoutDropDown.ActiveIndex].Name;
            }
            catch
            {
                this.ScoutDropDown.ActiveIndex = 0;
            }

            if (!this.ColonyShipDropDown.Open)
            {
                if (!this.AutoFreighterDropDown.Open)
                {
                    if (!this.ScoutDropDown.Open)
                    {
                        this.ConstructorDropDown.HandleInput(input);
                    }
                }
            }
            try
            {
                EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).data.CurrentConstructor = this.ConstructorDropDown.Options[this.ConstructorDropDown.ActiveIndex].Name;
            }
            catch
            {
                this.ConstructorDropDown.ActiveIndex = 0;
            }

            foreach (Checkbox checkbox in this.Checkboxes)
            {
                if (checkbox.HandleInput(input))
                    return true;
            }
            if (!HelperFunctions.CheckIntersection(this.ConstructionSubMenu.Menu, input.CursorPosition) || !input.RightMouseClick)
                return false;
            this.isOpen = false;
            return true;
        }
        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 bool HandleInput(InputState input)
        {
            List<Ship> ships = new List<Ship>();
            bool reset = false;
            for (int i = this.SelectedShipsSL.indexAtTop; i < this.SelectedShipsSL.Entries.Count && i < this.SelectedShipsSL.indexAtTop + this.SelectedShipsSL.entriesToDisplay; i++)
            {
                foreach (SkinnableButton button in (this.SelectedShipsSL.Entries[i].item as SelectedShipEntry).ShipButtons)
                {
                    if ((button.ReferenceObject as Ship).Active)
                    {
                        continue;
                    }
                    reset = true;
                    break;
                }
                if (reset)
                {
                    break;
                }
            }
            if (reset)
            {
                this.SetShipList(this.ShipList, this.isFleet);
            }
            if (this.screen.SelectedShipList.Count == 0 || this.screen.SelectedShipList.Count == 1)
            {
                return false;
            }
            if (this.ShipList == null || this.ShipList.Count == 0)
            {
                return false;
            }
            if (this.gridbutton.HandleInput(input))
            {
                AudioManager.PlayCue("sd_ui_accept_alt3");
                this.ShowModules = !this.ShowModules;
                if (!this.ShowModules)
                {
                    this.gridbutton.Active = false;
                }
                else
                {
                    this.gridbutton.Active = true;
                }
                return true;
            }
            if (this.AllShipsMine)
            {
                foreach (ToggleButton button in this.CombatStatusButtons)
                {
                    if (!HelperFunctions.CheckIntersection(button.r, input.CursorPosition))
                    {
                        button.Hover = false;
                    }
                    else
                    {
                        button.Hover = true;
                        if (button.HasToolTip)
                        {
                            ToolTip.CreateTooltip(button.WhichToolTip, this.ScreenManager);
                        }
                        if (input.InGameSelect)
                        {
                            AudioManager.PlayCue("sd_ui_accept_alt3");
                            string action = button.Action;
                            string str = action;
                            if (action != null)
                            {
                                if (str == "attack")
                                {
                                    foreach (Ship ship in this.ShipList)
                                    {
                                        ship.GetAI().CombatState = CombatState.AttackRuns;
                                    }
                                }
                                else if (str == "arty")
                                {
                                    foreach (Ship ship in this.ShipList)
                                    {
                                        ship.GetAI().CombatState = CombatState.Artillery;
                                    }
                                }
                                else if (str == "hold")
                                {
                                    foreach (Ship ship in this.ShipList)
                                    {
                                        ship.GetAI().CombatState = CombatState.HoldPosition;
                                    }
                                }
                                else if (str == "orbit_left")
                                {
                                    foreach (Ship ship in this.ShipList)
                                    {
                                        ship.GetAI().CombatState = CombatState.OrbitLeft;
                                    }
                                }
                                else if (str == "broadside_left")
                                {
                                    foreach (Ship ship in this.ShipList)
                                    {
                                        ship.GetAI().CombatState = CombatState.BroadsideLeft;
                                    }
                                }
                                else if (str == "orbit_right")
                                {
                                    foreach (Ship ship in this.ShipList)
                                    {
                                        ship.GetAI().CombatState = CombatState.OrbitRight;
                                    }
                                }
                                else if (str == "broadside_right")
                                {
                                    foreach (Ship ship in this.ShipList)
                                    {
                                        ship.GetAI().CombatState = CombatState.BroadsideRight;
                                    }
                                }
                                else if (str == "evade")
                                {
                                    foreach (Ship ship in this.ShipList)
                                    {
                                        ship.GetAI().CombatState = CombatState.Evade;
                                    }
                                }
                            }
                        }
                    }
                    if (this.HoveredShip == null)
                    {
                        button.Active = false;
                    }
                    else
                    {
                        string action1 = button.Action;
                        string str1 = action1;
                        if (action1 == null)
                        {
                            continue;
                        }
                        if (str1 == "attack")
                        {
                            if (this.HoveredShip.GetAI().CombatState != CombatState.AttackRuns)
                            {
                                button.Active = false;
                            }
                            else
                            {
                                button.Active = true;
                            }
                        }
                        else if (str1 == "arty")
                        {
                            if (this.HoveredShip.GetAI().CombatState != CombatState.Artillery)
                            {
                                button.Active = false;
                            }
                            else
                            {
                                button.Active = true;
                            }
                        }
                        else if (str1 == "hold")
                        {
                            if (this.HoveredShip.GetAI().CombatState != CombatState.HoldPosition)
                            {
                                button.Active = false;
                            }
                            else
                            {
                                button.Active = true;
                            }
                        }
                        else if (str1 == "orbit_left")
                        {
                            if (this.HoveredShip.GetAI().CombatState != CombatState.OrbitLeft)
                            {
                                button.Active = false;
                            }
                            else
                            {
                                button.Active = true;
                            }
                        }
                        else if (str1 == "broadside_left")
                        {
                            if (this.HoveredShip.GetAI().CombatState != CombatState.BroadsideLeft)
                            {
                                button.Active = false;
                            }
                            else
                            {
                                button.Active = true;
                            }
                        }
                        else if (str1 != "orbit_right")
                        {
                            if (str1 == "evade")
                            {
                                if (this.HoveredShip.GetAI().CombatState != CombatState.Evade)
                                {
                                    button.Active = false;
                                }
                                else
                                {
                                    button.Active = true;
                                }
                            }
                        }
                        else if (str1 == "broadside_right")
                        {
                            if (this.HoveredShip.GetAI().CombatState != CombatState.BroadsideRight)
                            {
                                button.Active = false;
                            }
                            else
                            {
                                button.Active = true;
                            }
                        }
                        else if (this.HoveredShip.GetAI().CombatState != CombatState.OrbitRight)
                        {
                            button.Active = false;
                        }
                        else
                        {
                            button.Active = true;
                        }
                    }
                }
                if (this.sliding_element.HandleInput(input))
                {
                    if (!this.sliding_element.Open)
                    {
                        base.State = UIElement.ElementState.TransitionOff;
                    }
                    else
                    {
                        base.State = UIElement.ElementState.TransitionOn;
                    }
                    return true;
                }
                if (base.State == UIElement.ElementState.Open)
                {
                    bool orderhover = false;
                    foreach (OrdersButton ob in this.Orders)
                    {
                        if (!ob.HandleInput(input, this.ScreenManager))
                        {
                            continue;
                        }
                        orderhover = true;
                    }
                    if (orderhover)
                    {
                        return true;
                    }
                }
            }
            this.SelectedShipsSL.HandleInput(input);
            this.HoveredShipLast = this.HoveredShip;
            this.HoveredShip = null;
            for (int i = this.SelectedShipsSL.indexAtTop; i < this.SelectedShipsSL.Entries.Count && i < this.SelectedShipsSL.indexAtTop + this.SelectedShipsSL.entriesToDisplay; i++)
            {
                try
                {
                    foreach (SkinnableButton button in (this.SelectedShipsSL.Entries[i].item as SelectedShipEntry).ShipButtons)
                    {
                        if (!HelperFunctions.CheckIntersection(button.r, input.CursorPosition))
                        {
                            button.Hover = false;
                        }
                        else
                        {
                            if (this.HoveredShipLast != (Ship)button.ReferenceObject)
                            {
                                AudioManager.PlayCue("sd_ui_mouseover");
                            }
                            button.Hover = true;
                            this.HoveredShip = (Ship)button.ReferenceObject;
                            if (!input.InGameSelect)
                            {
                                continue;
                            }
                            //added by gremlin filter by selected ship in shiplist.
                            if (input.CurrentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift))
                            {

                                foreach(Ship filter in this.screen.SelectedShipList)

                                {
                                    if(filter.Role != this.HoveredShip.Role)
                                    {
                                        this.screen.SelectedShipList.QueuePendingRemoval(filter);

                                    }

                                }
                                this.screen.SelectedShipList.ApplyPendingRemovals();
                                this.SetShipList(this.screen.SelectedShipList, false);
                                this.SelectedShipsSL.indexAtTop = 0;
                                this.SelectedShipsSL.ScrollBar.Y = this.SelectedShipsSL.ScrollBarHousing.Y;

                                continue;
                            }
                            else
                            {
                                this.screen.SelectedFleet = null;
                                this.screen.SelectedShipList.Clear();
                                this.screen.SelectedShip = this.HoveredShip;  //fbedard: multi-select
                                if (this.screen.SelectedShip != null && this.screen.SelectedShip != this.screen.previousSelection)
                                    this.screen.previousSelection = this.screen.SelectedShip;
                                this.screen.ShipInfoUIElement.SetShip(this.HoveredShip);
                            }
                            return true;
                        }
                    }
                }
                catch
                {
                }
            }
            foreach (ShipListInfoUIElement.TippedItem ti in this.ToolTipItems)
            {
                if (!HelperFunctions.CheckIntersection(ti.r, input.CursorPosition))
                {
                    continue;
                }
                ToolTip.CreateTooltip(ti.TIP_ID, this.ScreenManager);
            }
            if (HelperFunctions.CheckIntersection(this.ElementRect, input.CursorPosition))
            {
                return true;
            }
            return false;
        }
 public bool HandleInput(InputState input)
 {
     this.Pressed = false;
     if (!HelperFunctions.CheckIntersection(this.r, input.CursorPosition))
     {
         this.Hover = false;
     }
     else
     {
         if (!this.Hover)
         {
             AudioManager.PlayCue("sd_ui_mouseover");
         }
         this.Hover = true;
         if (input.CurrentMouseState.LeftButton == ButtonState.Pressed)
         {
             this.Pressed = true;
         }
         if (input.InGameSelect)
         {
             return true;
         }
     }
     return false;
 }
 public float HandleInput(InputState input)
 {
     if (!HelperFunctions.CheckIntersection(this.rect, input.CursorPosition))
     {
         this.Hover = false;
     }
     else
     {
         this.Hover = true;
     }
     Rectangle clickCursor = this.cursor;
     clickCursor.X = clickCursor.X - this.cursor.Width / 2;
     if (HelperFunctions.CheckIntersection(clickCursor, input.CursorPosition) && input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Pressed)
     {
         this.dragging = true;
     }
     if (this.dragging)
     {
         this.cursor.X = (int)input.CursorPosition.X;
         if (this.cursor.X > this.rect.X + this.rect.Width)
         {
             this.cursor.X = this.rect.X + this.rect.Width;
         }
         else if (this.cursor.X < this.rect.X)
         {
             this.cursor.X = this.rect.X;
         }
         if (input.CurrentMouseState.LeftButton == ButtonState.Released)
         {
             this.dragging = false;
         }
         this.amount = 1f - (float)((float)this.rect.X + (float)this.rect.Width - (float)this.cursor.X) / (float)this.rect.Width;
     }
     return this.amount;
 }
 public override void HandleInput(InputState input)
 {
     if (input.Escaped || input.RightMouseClick || this.close.HandleInput(input))
     {
         this.ExitScreen();
     }
     base.HandleInput(input);
 }
 public override void HandleInput(InputState input)
 {
     this.ShipSL.HandleInput(input);
     if (input.Escaped || input.CurrentMouseState.RightButton == ButtonState.Pressed)
     {
         this.ExitScreen();
     }
     this.selector = null;
     for (int i = this.ShipSL.indexAtTop; i < this.ShipSL.Copied.Count && i < this.ShipSL.indexAtTop + this.ShipSL.entriesToDisplay; i++)
     {
         ScrollList.Entry e = this.ShipSL.Copied[i];
         if (HelperFunctions.CheckIntersection(e.clickRect, input.CursorPosition))
         {
             this.selector = new Selector(base.ScreenManager, e.clickRect);
             if (input.InGameSelect)
             {
                 AudioManager.PlayCue("sd_ui_accept_alt3");
                 this.RefitTo = e.item as string;
             }
         }
     }
     if (this.RefitTo != null)
     {
         if (HelperFunctions.CheckIntersection(this.RefitOne.Rect, input.CursorPosition))
         {
             ToolTip.CreateTooltip(Localizer.Token(2267), base.ScreenManager);
             if (input.InGameSelect)
             {
                 this.shiptorefit.GetAI().OrderRefitTo(this.RefitTo);
                 AudioManager.PlayCue("echo_affirm");
                 this.ExitScreen();
             }
         }
         if (HelperFunctions.CheckIntersection(this.RefitAll.Rect, input.CursorPosition))
         {
             ToolTip.CreateTooltip(Localizer.Token(2268), base.ScreenManager);
             if (input.InGameSelect)
             {
                 foreach (Ship ship in EmpireManager.GetEmpireByName(Ship.universeScreen.PlayerLoyalty).GetShips())
                 {
                     if (ship.Name != this.shiptorefit.Name)
                     {
                         continue;
                     }
                     ship.GetAI().OrderRefitTo(this.RefitTo);
                 }
                 AudioManager.PlayCue("echo_affirm");
                 this.ExitScreen();
             }
         }
     }
 }