public MinimapButtons(Rectangle r, EmpireUIOverlay eui) { this.Rect = r; Vector2 Cursor = new Vector2((float)(r.X + 11), (float)(r.Y + 13)); Color baseColor = new Color(34, 42, 56); this.home = new SkinnableButton(new Rectangle((int)Cursor.X + 3, (int)Cursor.Y, 15, 16), "UI/icon_home") { BaseColor = baseColor, HoverColor = new Color(140, 88, 50), IsToggle = false }; Cursor.Y = Cursor.Y + 25f; this.zoom = new SkinnableButton(new Rectangle((int)Cursor.X, (int)Cursor.Y, 22, 22), "UI/icon_minus") { BaseColor = baseColor, HoverColor = new Color(140, 88, 50), IsToggle = false }; Cursor.Y = Cursor.Y + 28f; this.bDSBW = new SkinnableButton(new Rectangle((int)Cursor.X, (int)Cursor.Y, 22, 17), "UI/icon_dsbw") { BaseColor = baseColor, HoverColor = new Color(140, 88, 50), IsToggle = false }; Cursor.Y = Cursor.Y + 28f; this.bPlanetsList = new SkinnableButton(new Rectangle((int)Cursor.X, (int)Cursor.Y, 21, 21), "UI/icon_planetslist") { BaseColor = baseColor, HoverColor = new Color(140, 88, 50), IsToggle = false }; Cursor.Y = Cursor.Y + 28f; this.bShipsList = new SkinnableButton(new Rectangle((int)Cursor.X + 2, (int)Cursor.Y, 18, 19), "UI/icon_shipslist") { BaseColor = baseColor, IsToggle = false, HoverColor = new Color(140, 88, 50) }; Cursor.Y = Cursor.Y + 28f; this.bFleets = new SkinnableButton(new Rectangle((int)Cursor.X + 2, (int)Cursor.Y, 18, 16), "UI/icon_fleets") { BaseColor = baseColor, HoverColor = new Color(140, 88, 50), IsToggle = false }; Cursor.Y = Cursor.Y + 28f; this.bAutomation = new SkinnableButton(new Rectangle((int)Cursor.X + 2, (int)Cursor.Y, 15, 12), "UI/icon_automation") { BaseColor = baseColor, IsToggle = false, HoverColor = new Color(140, 88, 50) }; }
public override void LoadContent() { LightRig rig = base.ScreenManager.Content.Load<LightRig>("example/ShipyardLightrig"); lock (GlobalStats.ObjectManagerLocker) { base.ScreenManager.inter.LightManager.Clear(); base.ScreenManager.inter.LightManager.Submit(rig); } if (base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth <= 1280 || base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight <= 768) { this.LowRes = true; } Rectangle leftRect = new Rectangle(5, 45, 405, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 45 - (int)(0.4f * (float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight) + 10); this.ModuleSelectionMenu = new Menu1(base.ScreenManager, leftRect); Rectangle modSelR = new Rectangle(0, (this.LowRes ? 45 : 100), 305, (this.LowRes ? 350 : 400)); this.modSel = new Submenu(base.ScreenManager, modSelR, true); this.modSel.AddTab("Wpn"); this.modSel.AddTab("Pwr"); this.modSel.AddTab("Def"); this.modSel.AddTab("Spc"); this.weaponSL = new ScrollList(this.modSel); Vector2 Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 175), 80f); Rectangle active = new Rectangle(modSelR.X, modSelR.Y + modSelR.Height + 15, modSelR.Width, 300); this.activeModWindow = new Menu1(base.ScreenManager, active); Rectangle acsub = new Rectangle(active.X, modSelR.Y + modSelR.Height + 15, 305, 320); if (base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight > 760) { acsub.Height = acsub.Height + 120; } this.activeModSubMenu = new Submenu(base.ScreenManager, acsub); this.activeModSubMenu.AddTab("Active Module"); this.choosefighterrect = new Rectangle(acsub.X + acsub.Width + 5, acsub.Y, 240, 270); if (this.choosefighterrect.Y + this.choosefighterrect.Height > base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight) { int diff = this.choosefighterrect.Y + this.choosefighterrect.Height - base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight; this.choosefighterrect.Height = this.choosefighterrect.Height - (diff + 10); } this.choosefighterrect.Height = acsub.Height; this.ChooseFighterSub = new Submenu(base.ScreenManager, this.choosefighterrect); this.ChooseFighterSub.AddTab("Choose Fighter"); this.ChooseFighterSL = new ScrollList(this.ChooseFighterSub, 40); foreach (KeyValuePair<string, bool> hull in EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetHDict()) { if (!hull.Value) { continue; } this.AvailableHulls.Add(Ship_Game.ResourceManager.HullsDict[hull.Key]); } PrimitiveQuad.graphicsDevice = base.ScreenManager.GraphicsDevice; float width = (float)base.ScreenManager.GraphicsDevice.Viewport.Width; Viewport viewport = base.ScreenManager.GraphicsDevice.Viewport; float aspectRatio = width / (float)viewport.Height; this.offset = new Vector2(); Viewport viewport1 = base.ScreenManager.GraphicsDevice.Viewport; this.offset.X = (float)(viewport1.Width / 2 - 256); Viewport viewport2 = base.ScreenManager.GraphicsDevice.Viewport; this.offset.Y = (float)(viewport2.Height / 2 - 256); this.camera = new Camera2d(); Camera2d vector2 = this.camera; Viewport viewport3 = base.ScreenManager.GraphicsDevice.Viewport; float single = (float)viewport3.Width / 2f; Viewport viewport4 = base.ScreenManager.GraphicsDevice.Viewport; vector2.Pos = new Vector2(single, (float)viewport4.Height / 2f); Vector3 camPos = this.cameraPosition * new Vector3(-1f, 1f, 1f); this.view = ((Matrix.CreateTranslation(0f, 0f, 0f) * Matrix.CreateRotationY(MathHelper.ToRadians(180f))) * Matrix.CreateRotationX(MathHelper.ToRadians(0f))) * Matrix.CreateLookAt(camPos, new Vector3(camPos.X, camPos.Y, 0f), new Vector3(0f, -1f, 0f)); this.projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f, aspectRatio, 1f, 20000f); this.ChangeHull(this.AvailableHulls[0]); lock (GlobalStats.ObjectManagerLocker) { if (!this.ActiveHull.Animated) { this.ActiveModel = base.ScreenManager.Content.Load<Model>(this.ActiveHull.ModelPath); this.CreateSOFromHull(); } else { base.ScreenManager.inter.ObjectManager.Remove(this.shipSO); SkinnedModel sm = Ship_Game.ResourceManager.GetSkinnedModel(this.ActiveHull.ModelPath); this.shipSO = new SceneObject(sm.Model) { ObjectType = ObjectType.Dynamic, World = this.worldMatrix }; base.ScreenManager.inter.ObjectManager.Submit(this.shipSO); this.SetupSlots(); } } foreach (ModuleSlotData slot in this.ActiveHull.ModuleSlotList) { if (slot.Position.X < this.LowestX) { this.LowestX = slot.Position.X; } if (slot.Position.X <= this.HighestX) { continue; } this.HighestX = slot.Position.X; } float xDistance = this.HighestX - this.LowestX; BoundingSphere bs = this.shipSO.WorldBoundingSphere; Viewport viewport5 = base.ScreenManager.GraphicsDevice.Viewport; Vector3 pScreenSpace = viewport5.Project(Vector3.Zero, this.projection, this.view, Matrix.Identity); Vector2 pPos = new Vector2(pScreenSpace.X, pScreenSpace.Y); Vector2 radialPos = this.GeneratePointOnCircle(90f, Vector2.Zero, xDistance); Viewport viewport6 = base.ScreenManager.GraphicsDevice.Viewport; Vector3 insetRadialPos = viewport6.Project(new Vector3(radialPos, 0f), this.projection, this.view, Matrix.Identity); Vector2 insetRadialSS = new Vector2(insetRadialPos.X, insetRadialPos.Y); float Radius = Vector2.Distance(insetRadialSS, pPos) + 10f; if (Radius >= xDistance) { while (Radius > xDistance) { camPos = this.cameraPosition * new Vector3(-1f, 1f, 1f); this.view = ((Matrix.CreateTranslation(0f, 0f, 0f) * Matrix.CreateRotationY(MathHelper.ToRadians(180f))) * Matrix.CreateRotationX(MathHelper.ToRadians(0f))) * Matrix.CreateLookAt(camPos, new Vector3(camPos.X, camPos.Y, 0f), new Vector3(0f, -1f, 0f)); bs = this.shipSO.WorldBoundingSphere; Viewport viewport7 = base.ScreenManager.GraphicsDevice.Viewport; pScreenSpace = viewport7.Project(Vector3.Zero, this.projection, this.view, Matrix.Identity); pPos = new Vector2(pScreenSpace.X, pScreenSpace.Y); radialPos = this.GeneratePointOnCircle(90f, Vector2.Zero, xDistance); Viewport viewport8 = base.ScreenManager.GraphicsDevice.Viewport; insetRadialPos = viewport8.Project(new Vector3(radialPos, 0f), this.projection, this.view, Matrix.Identity); insetRadialSS = new Vector2(insetRadialPos.X, insetRadialPos.Y); Radius = Vector2.Distance(insetRadialSS, pPos) + 10f; this.cameraPosition.Z = this.cameraPosition.Z + 1f; } } else { while (Radius < xDistance) { camPos = this.cameraPosition * new Vector3(-1f, 1f, 1f); this.view = ((Matrix.CreateTranslation(0f, 0f, 0f) * Matrix.CreateRotationY(MathHelper.ToRadians(180f))) * Matrix.CreateRotationX(MathHelper.ToRadians(0f))) * Matrix.CreateLookAt(camPos, new Vector3(camPos.X, camPos.Y, 0f), new Vector3(0f, -1f, 0f)); bs = this.shipSO.WorldBoundingSphere; Viewport viewport9 = base.ScreenManager.GraphicsDevice.Viewport; pScreenSpace = viewport9.Project(Vector3.Zero, this.projection, this.view, Matrix.Identity); pPos = new Vector2(pScreenSpace.X, pScreenSpace.Y); radialPos = this.GeneratePointOnCircle(90f, Vector2.Zero, xDistance); Viewport viewport10 = base.ScreenManager.GraphicsDevice.Viewport; insetRadialPos = viewport10.Project(new Vector3(radialPos, 0f), this.projection, this.view, Matrix.Identity); insetRadialSS = new Vector2(insetRadialPos.X, insetRadialPos.Y); Radius = Vector2.Distance(insetRadialSS, pPos) + 10f; this.cameraPosition.Z = this.cameraPosition.Z - 1f; } } this.BlackBar = new Rectangle(0, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 70, 3000, 70); this.SideBar = new Rectangle(0, 0, 280, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight); Rectangle w = new Rectangle(20, this.modSel.Menu.Y - 10, 32, 32); Rectangle p = new Rectangle(80, w.Y, 32, 32); Rectangle df = new Rectangle(150, w.Y, 32, 32); Rectangle sp = new Rectangle(220, w.Y, 32, 32); this.wpn = new SkinnableButton(w, "Modules/FlakTurret3x3") { IsToggle = true, Toggled = true }; this.pwr = new SkinnableButton(p, "Modules/NuclearReactorMedium") { IsToggle = true }; this.def = new SkinnableButton(df, "Modules/SteelArmorMedium") { IsToggle = true }; this.spc = new SkinnableButton(sp, "Modules/sensors_2x2") { IsToggle = true }; this.SelectedCatTextPos = new Vector2(20f, (float)(w.Y - 25 - Fonts.Arial20Bold.LineSpacing / 2)); this.SearchBar = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 585, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 47, 210, 25); Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 370), (float)(modSelR.Y + modSelR.Height + 408)); Vector2 OrdersBarPos = new Vector2(Cursor.X - 60f, (float)((int)Cursor.Y + 10)); ToggleButton AttackRuns = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_headon"); this.CombatStatusButtons.Add(AttackRuns); AttackRuns.Action = "attack"; AttackRuns.HasToolTip = true; AttackRuns.WhichToolTip = 1; OrdersBarPos.X = OrdersBarPos.X + 29f; ToggleButton Artillery = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_aft"); this.CombatStatusButtons.Add(Artillery); Artillery.Action = "arty"; Artillery.HasToolTip = true; Artillery.WhichToolTip = 2; OrdersBarPos.X = OrdersBarPos.X + 29f; ToggleButton HoldPos = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_x"); this.CombatStatusButtons.Add(HoldPos); HoldPos.Action = "hold"; HoldPos.HasToolTip = true; HoldPos.WhichToolTip = 65; OrdersBarPos.X = OrdersBarPos.X + 29f; ToggleButton OrbitLeft = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_left"); this.CombatStatusButtons.Add(OrbitLeft); OrbitLeft.Action = "orbit_left"; OrbitLeft.HasToolTip = true; OrbitLeft.WhichToolTip = 3; OrdersBarPos.Y = OrdersBarPos.Y + 29f; ToggleButton BroadsideLeft = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_bleft"); this.CombatStatusButtons.Add(BroadsideLeft); BroadsideLeft.Action = "broadside_left"; BroadsideLeft.HasToolTip = true; BroadsideLeft.WhichToolTip = 159; OrdersBarPos.Y = OrdersBarPos.Y - 29f; OrdersBarPos.X = OrdersBarPos.X + 29f; ToggleButton OrbitRight = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_right"); this.CombatStatusButtons.Add(OrbitRight); OrbitRight.Action = "orbit_right"; OrbitRight.HasToolTip = true; OrbitRight.WhichToolTip = 4; OrdersBarPos.Y = OrdersBarPos.Y + 29f; ToggleButton BroadsideRight = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_bright"); this.CombatStatusButtons.Add(BroadsideRight); BroadsideRight.Action = "broadside_right"; BroadsideRight.HasToolTip = true; BroadsideRight.WhichToolTip = 160; OrdersBarPos.Y = OrdersBarPos.Y - 29f; OrdersBarPos.X = OrdersBarPos.X + 29f; ToggleButton Evade = new ToggleButton(new Rectangle((int)OrdersBarPos.X, (int)OrdersBarPos.Y, 24, 24), "SelectionBox/button_formation_active", "SelectionBox/button_formation_inactive", "SelectionBox/button_formation_hover", "SelectionBox/button_formation_press", "SelectionBox/icon_formation_stop"); this.CombatStatusButtons.Add(Evade); Evade.Action = "evade"; Evade.HasToolTip = true; Evade.WhichToolTip = 6; Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 150), (float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 47); this.SaveButton = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height), NormalTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"], HoverTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_hover"], PressedTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_pressed"], Text = Localizer.Token(105), Launches = "Save As..." }; this.Buttons.Add(this.SaveButton); this.LoadButton = new UIButton() { Rect = new Rectangle((int)Cursor.X - 78, (int)Cursor.Y, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Width, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height), NormalTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"], HoverTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_hover"], PressedTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_pressed"], Text = Localizer.Token(8), Launches = "Load" }; this.Buttons.Add(this.LoadButton); this.ToggleOverlayButton = new UIButton() { Rect = new Rectangle(this.LoadButton.Rect.X - 140, (int)Cursor.Y, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height), NormalTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"], HoverTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_hover"], PressedTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_pressed"], Launches = "Toggle Overlay", Text = Localizer.Token(106) }; this.Buttons.Add(this.ToggleOverlayButton); this.bottom_sep = new Rectangle(this.BlackBar.X, this.BlackBar.Y, this.BlackBar.Width, 1); this.HullSelectionRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 285, (this.LowRes ? 45 : 100), 280, (this.LowRes ? 350 : 400)); this.hullSelectionSub = new Submenu(base.ScreenManager, this.HullSelectionRect, true); this.weaponSL = new ScrollList(this.modSel); this.hullSelectionSub.AddTab(Localizer.Token(107)); this.hullSL = new ScrollList(this.hullSelectionSub); List<string> Categories = new List<string>(); foreach (KeyValuePair<string, ShipData> hull in Ship_Game.ResourceManager.HullsDict) { if (!EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetHDict()[hull.Key]) { continue; } string cat = Localizer.GetRole(hull.Value.Role, EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty)); if (Categories.Contains(cat)) { continue; } Categories.Add(cat); } Categories.Sort(); foreach (string cat in Categories) { ModuleHeader type = new ModuleHeader(cat, 240f); this.hullSL.AddItem(type); } foreach (ScrollList.Entry e in this.hullSL.Entries) { foreach (KeyValuePair<string, ShipData> hull in Ship_Game.ResourceManager.HullsDict) { if (!EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty).GetHDict()[hull.Key] || !((e.item as ModuleHeader).Text == Localizer.GetRole(hull.Value.Role, EmpireManager.GetEmpireByName(this.EmpireUI.screen.PlayerLoyalty)))) { continue; } e.AddItem(hull.Value); } } Rectangle ShipStatsPanel = new Rectangle(this.HullSelectionRect.X + 50, this.HullSelectionRect.Y + this.HullSelectionRect.Height - 20, 280, 320); this.classifCursor = new Vector2(ShipStatsPanel.X - 100, ShipStatsPanel.Y + ShipStatsPanel.Height + 92); dropdownRect = new Rectangle((int)ShipStatsPanel.X, (int)ShipStatsPanel.Y + ShipStatsPanel.Height + 118, 100, 18); this.CategoryList = new DropOptions(dropdownRect); this.CategoryList.AddOption("Unclassified", 1); this.CategoryList.AddOption("Civilian", 2); this.CategoryList.AddOption("Recon", 3); this.CategoryList.AddOption("Fighter", 4); this.CategoryList.AddOption("Bomber", 5); this.CarrierOnly = this.ActiveHull.CarrierShip; Ref<bool> CORef = new Ref<bool>(() => this.CarrierOnly, (bool x) => { this.CarrierOnly = x; }); this.COBoxCursor = new Vector2(dropdownRect.X + 106, dropdownRect.Y); this.CarrierOnlyBox = new Checkbox(this.COBoxCursor, "Carrier Only", CORef, Fonts.Arial12Bold); this.ShipStats = new Menu1(base.ScreenManager, ShipStatsPanel); this.statsSub = new Submenu(base.ScreenManager, ShipStatsPanel); this.statsSub.AddTab(Localizer.Token(108)); this.ArcsButton = new GenericButton(new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 32), 97f), "Arcs", Fonts.Pirulen20, Fonts.Pirulen16); this.close = new CloseButton(new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 27, 99, 20, 20)); this.OriginalZ = this.cameraPosition.Z; }
public void SetShipList(List<Ship> shipList, bool isFleet) { this.Orders.Clear(); this.isFleet = isFleet; if (shipList != this.ShipList) { this.SelectedShipsSL.indexAtTop = 0; } this.ShipList = shipList; this.SelectedShipsSL.Entries.Clear(); SelectedShipEntry entry = new SelectedShipEntry(); bool AllResupply = true; this.AllShipsMine = true; bool AllFreighters = true; bool AllCombat = true; for (int i = 0; i < shipList.Count; i++) { Ship ship = shipList[i]; SkinnableButton button = new SkinnableButton(new Rectangle(0, 0, 20, 20), string.Concat("TacticalIcons/symbol_", ship.Role)) { IsToggle = false, ReferenceObject = ship, BaseColor = ship.loyalty.EmpireColor }; if (entry.ShipButtons.Count < 8) { entry.ShipButtons.Add(button); } if (entry.ShipButtons.Count == 8 || i == shipList.Count - 1) { this.SelectedShipsSL.AddItem(entry); entry = new SelectedShipEntry(); } if (ship.GetAI().State != AIState.Resupply) { AllResupply = false; } if (ship.loyalty != EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty)) { this.AllShipsMine = false; } //if (ship.CargoSpace_Max == 0f) if (ship.CargoSpace_Max == 0f || ship.Role == "troop" || ship.GetAI().State == AIState.Colonize || ship.Role == "station" || ship.Mothership != null) { AllFreighters = false; } if (ship.Role == "construction" || ship.Role == "platform" || ship.Role == "freighter" || ship.Role == "troop" || ship.GetAI().State == AIState.Colonize || ship.Role == "station" || ship.Mothership != null) { AllCombat = false; } } OrdersButton resupply = new OrdersButton(shipList, Vector2.Zero, OrderType.OrderResupply, 149) { SimpleToggle = true, Active = AllResupply }; this.Orders.Add(resupply); if (AllCombat) { OrdersButton SystemDefense = new OrdersButton(shipList, Vector2.Zero, OrderType.EmpireDefense, 150) { SimpleToggle = true, Active = false }; this.Orders.Add(SystemDefense); OrdersButton Explore = new OrdersButton(shipList, Vector2.Zero, OrderType.Explore, 136) { SimpleToggle = true, Active = false }; this.Orders.Add(Explore); OrdersButton ordersButton = new OrdersButton(shipList, Vector2.Zero, OrderType.DefineAO, 15); SystemDefense.SimpleToggle = true; } if (AllFreighters) { OrdersButton tf = new OrdersButton(shipList, Vector2.Zero, OrderType.TradeFood, 15) { SimpleToggle = true }; this.Orders.Add(tf); OrdersButton tpass = new OrdersButton(shipList, Vector2.Zero, OrderType.PassTran, 152) { SimpleToggle = true }; this.Orders.Add(tpass); } //Added by McShooterz: fleet scrap button OrdersButton Scrap = new OrdersButton(shipList, Vector2.Zero, OrderType.Scrap, 157) { SimpleToggle = true, Active = false }; this.Orders.Add(Scrap); int ex = 0; int y = 0; for (int i = 0; i < this.Orders.Count; i++) { OrdersButton ob = this.Orders[i]; if (i % 2 == 0 && i > 0) { ex++; y = 0; } ob.clickRect.X = this.ElementRect.X + this.ElementRect.Width + 2 + 52 * ex; ob.clickRect.Y = this.sliding_element.Housing.Y + 15 + y * 52; y++; } }
public override void LoadContent() { float screenWidth = (float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth; float screenHeight = (float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight; Rectangle titleRect = new Rectangle((int)screenWidth / 2 - 200, 44, 400, 80); this.TitleBar = new Menu2(base.ScreenManager, titleRect); this.TitlePos = new Vector2((float)(titleRect.X + titleRect.Width / 2) - Fonts.Laserian14.MeasureString(Localizer.Token(1600)).X / 2f, (float)(titleRect.Y + titleRect.Height / 2 - Fonts.Laserian14.LineSpacing / 2)); Rectangle leftRect = new Rectangle((int)screenWidth / 2 - 640, (screenHeight > 768f ? titleRect.Y + titleRect.Height + 5 : 44), 1280, 660); this.DMenu = new Menu2(base.ScreenManager, leftRect); this.close = new CloseButton(new Rectangle(leftRect.X + leftRect.Width - 40, leftRect.Y + 20, 20, 20)); this.SelectedInfoRect = new Rectangle(leftRect.X + 60, leftRect.Y + 250, 368, 376); this.IntelligenceRect = new Rectangle(this.SelectedInfoRect.X + this.SelectedInfoRect.Width + 30, this.SelectedInfoRect.Y, 368, 376); this.OperationsRect = new Rectangle(this.IntelligenceRect.X + this.IntelligenceRect.Width + 30, this.SelectedInfoRect.Y, 368, 376); this.ArtifactsRect = new Rectangle(this.SelectedInfoRect.X + 20, this.SelectedInfoRect.Y + 180, this.SelectedInfoRect.Width - 40, 130); Submenu ArtifactsSub = new Submenu(base.ScreenManager, this.ArtifactsRect); this.ArtifactsSL = new ScrollList(ArtifactsSub, 40); this.Contact = new DanButton(new Vector2((float)(this.SelectedInfoRect.X + this.SelectedInfoRect.Width / 2 - 91), (float)(this.SelectedInfoRect.Y + this.SelectedInfoRect.Height - 45)), Localizer.Token(1644)) { Toggled = true }; foreach (Empire e in EmpireManager.EmpireList) { if (e != EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty)) { if (e.isFaction || e.MinorRace) { continue; } RaceEntry re = new RaceEntry() { e = e }; this.Races.Add(re); } else { RaceEntry re = new RaceEntry() { e = e }; this.SelectedEmpire = e; this.ArtifactsSL.Entries.Clear(); this.ArtifactsSL.indexAtTop = 0; ArtifactEntry entry = new ArtifactEntry(); for (int i = 0; i < e.data.OwnedArtifacts.Count; i++) { Artifact art = e.data.OwnedArtifacts[i]; SkinnableButton button = new SkinnableButton(new Rectangle(0, 0, 32, 32), string.Concat("Artifact Icons/", art.Name)) { IsToggle = false, ReferenceObject = art, BaseColor = Color.White }; if (entry.ArtifactButtons.Count < 5) { entry.ArtifactButtons.Add(button); } if (entry.ArtifactButtons.Count == 5 || i == e.data.OwnedArtifacts.Count - 1) { this.ArtifactsSL.AddItem(entry); entry = new ArtifactEntry(); } } this.Races.Add(re); } } Vector2 Cursor = new Vector2(screenWidth / 2f - (float)(148 * this.Races.Count / 2), (float)(leftRect.Y + 10)); int j = 0; foreach (RaceEntry re in this.Races) { re.container = new Rectangle((int)Cursor.X + 10 + j * 148, leftRect.Y + 40, 124, 148); j++; } base.ScreenManager.racialMusic.SetVolume(0f); }
public override void HandleInput(InputState input) { if (input.CurrentKeyboardState.IsKeyDown(Keys.I) && !input.LastKeyboardState.IsKeyDown(Keys.I) && !GlobalStats.TakingInput) { AudioManager.PlayCue("echo_affirm"); this.ExitScreen(); return; } if (this.close.HandleInput(input)) { this.ExitScreen(); return; } //this.showExecuteButton = false; if (this.SelectedEmpire != EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty) && !this.SelectedEmpire.data.Defeated && this.Contact.HandleInput(input)) { base.ScreenManager.AddScreen(new DiplomacyScreen(this.SelectedEmpire, EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty), "Greeting")); } foreach (RaceEntry race in this.Races) { if (EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty) == race.e || !EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty).GetRelations()[race.e].Known) { if (EmpireManager.GetEmpireByName(this.screen.PlayerLoyalty) != race.e || !HelperFunctions.ClickedRect(race.container, input)) { continue; } this.SelectedEmpire = race.e; this.ArtifactsSL.Entries.Clear(); this.ArtifactsSL.indexAtTop = 0; ArtifactEntry entry = new ArtifactEntry(); for (int i = 0; i < this.SelectedEmpire.data.OwnedArtifacts.Count; i++) { Artifact art = this.SelectedEmpire.data.OwnedArtifacts[i]; SkinnableButton button = new SkinnableButton(new Rectangle(0, 0, 32, 32), string.Concat("Artifact Icons/", art.Name)) { IsToggle = false, ReferenceObject = art, BaseColor = Color.White }; if (entry.ArtifactButtons.Count < 5) { entry.ArtifactButtons.Add(button); } if (entry.ArtifactButtons.Count == 5 || i == this.SelectedEmpire.data.OwnedArtifacts.Count - 1) { this.ArtifactsSL.AddItem(entry); entry = new ArtifactEntry(); } } AudioManager.PlayCue("echo_affirm"); } else { if (!HelperFunctions.ClickedRect(race.container, input)) { continue; } this.SelectedEmpire = race.e; this.ArtifactsSL.Entries.Clear(); this.ArtifactsSL.indexAtTop = 0; ArtifactEntry entry = new ArtifactEntry(); for (int i = 0; i < this.SelectedEmpire.data.OwnedArtifacts.Count; i++) { Artifact art = this.SelectedEmpire.data.OwnedArtifacts[i]; SkinnableButton button = new SkinnableButton(new Rectangle(0, 0, 32, 32), string.Concat("Artifact Icons/", art.Name)) { IsToggle = false, ReferenceObject = art, BaseColor = Color.White }; if (entry.ArtifactButtons.Count < 5) { entry.ArtifactButtons.Add(button); } if (entry.ArtifactButtons.Count == 5 || i == this.SelectedEmpire.data.OwnedArtifacts.Count - 1) { this.ArtifactsSL.AddItem(entry); entry = new ArtifactEntry(); } } } } for (int i = this.ArtifactsSL.indexAtTop; i < this.ArtifactsSL.Entries.Count && i < this.ArtifactsSL.indexAtTop + this.ArtifactsSL.entriesToDisplay; i++) { foreach (SkinnableButton button in (this.ArtifactsSL.Entries[i].item as ArtifactEntry).ArtifactButtons) { if (!HelperFunctions.CheckIntersection(button.r, input.CursorPosition)) { continue; } string Text = string.Concat(Localizer.Token((button.ReferenceObject as Artifact).NameIndex), "\n\n"); Text = string.Concat(Text, Localizer.Token((button.ReferenceObject as Artifact).DescriptionIndex)); ToolTip.CreateTooltip(Text, base.ScreenManager); } } if (input.Escaped || input.CurrentMouseState.RightButton == ButtonState.Pressed) { this.ExitScreen(); } base.HandleInput(input); }