public MessageBoxScreen(string message, string oktext, string canceltext) { this.message = message; this.message = HelperFunctions.parseText(Fonts.Arial12Bold, message, 250f); base.IsPopup = true; base.TransitionOnTime = TimeSpan.FromSeconds(0.25); base.TransitionOffTime = TimeSpan.FromSeconds(0.25); this.OK = new UIButton() { Rect = new Rectangle(0, 0, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_pressed"], Text = oktext, Launches = "OK" }; this.Buttons.Add(this.OK); this.Cancel = new UIButton() { Rect = new Rectangle(0, 0, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_pressed"], Text = canceltext, Launches = "Cancel" }; this.Buttons.Add(this.Cancel); }
public MissionEntry(AgentMission am, AgentComponent parent) { this.Component = parent; this.TheMission = am; this.DoMission = new UIButton() { NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_low_btn_80px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_low_btn_80px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_low_btn_80px_pressed"], Text = "Go", Launches = "New Campaign" }; }
public override void LoadContent() { if (base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth <= 1366 || base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight <= 720) { this.LowRes = true; } Rectangle titleRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 203, (this.LowRes ? 10 : 44), 406, 80); this.TitleBar = new Menu2(base.ScreenManager, titleRect); this.TitlePos = new Vector2((float)(titleRect.X + titleRect.Width / 2) - Fonts.Laserian14.MeasureString(Localizer.Token(18)).X / 2f, (float)(titleRect.Y + titleRect.Height / 2 - Fonts.Laserian14.LineSpacing / 2)); Rectangle nameRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - (int)((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 0.5f) / 2, titleRect.Y + titleRect.Height + 5, (int)((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 0.5f), 150); this.Name = new Menu1(base.ScreenManager, nameRect); Rectangle nsubRect = new Rectangle(nameRect.X + 20, nameRect.Y - 5, nameRect.Width - 40, nameRect.Height - 15); this.NameSub = new Submenu(base.ScreenManager, nsubRect); this.ColorSelector = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 310, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 280, 620, 560); this.ColorSelectMenu = new Menu1(base.ScreenManager, this.ColorSelector); this.RaceNamePos = new Vector2((float)(nameRect.X + 40), (float)(nameRect.Y + 30)); this.FlagPos = new Vector2((float)(nameRect.X + nameRect.Width - 80 - 100), (float)(nameRect.Y + 30)); Rectangle leftRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - (int)((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 0.5f) / 2, nameRect.Y + nameRect.Height + 5, (int)((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 0.5f), base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - (titleRect.Y + titleRect.Height) - (int)(0.28f * (float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight)); if (leftRect.Height > 580) { leftRect.Height = 580; } this.Left = new Menu1(base.ScreenManager, leftRect); Vector2 Position = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 84), (float)(leftRect.Y + leftRect.Height + 10)); this.RulesOptions = new UIButton() { Rect = new Rectangle((int)Position.X, (int)Position.Y, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = Localizer.Token(4006), Launches = "Rule Options" }; this.Buttons.Add(this.RulesOptions); Rectangle ChooseRaceRect = new Rectangle(5, (this.LowRes ? nameRect.Y : leftRect.Y), leftRect.X - 10, (this.LowRes ? leftRect.Y + leftRect.Height - nameRect.Y : leftRect.Height)); this.ChooseRaceMenu = new Menu1(base.ScreenManager, ChooseRaceRect); Rectangle smaller = ChooseRaceRect; smaller.Y = smaller.Y - 20; smaller.Height = smaller.Height + 20; this.arch = new Submenu(base.ScreenManager, smaller); this.RaceArchetypeSL = new ScrollList(this.arch, 135); ResourceManager.Empires.Clear(); ResourceManager.WhichModPath = "Content"; if (GlobalStats.ActiveModInfo != null && !GlobalStats.ActiveModInfo.DisableDefaultRaces) { //ResourceManager.WhichModPath = string.Concat("Mods/", GlobalStats.ActiveMod.ModPath); ResourceManager.LoadEmpires(); //ResourceManager.LoadSubsetEmpires(); } else if (GlobalStats.ActiveModInfo == null || !GlobalStats.ActiveModInfo.DisableDefaultRaces) { ResourceManager.LoadEmpires(); //ResourceManager.LoadSubsetEmpires(); } else { ResourceManager.LoadSubsetEmpires(); } if (GlobalStats.ActiveMod != null) { ResourceManager.WhichModPath = string.Concat("Mods/", GlobalStats.ActiveMod.ModPath); ResourceManager.LoadModdedEmpires(); } foreach (EmpireData e in ResourceManager.Empires) { if (e.Faction == 1 || e.MinorRace) { continue; } this.RaceArchetypeSL.AddItem(e); if (string.IsNullOrEmpty(e.Traits.VideoPath)) { continue; } this.TextureDict.Add(e, ResourceManager.TextureDict[string.Concat("Races/", e.Traits.VideoPath)]); } foreach (EmpireData e in ResourceManager.Empires) { if (e.Traits.Singular != "Human") { continue; } this.SelectedData = e; } this.RaceName.Text = this.SelectedData.Traits.Name; this.SingEntry.Text = this.SelectedData.Traits.Singular; this.PlurEntry.Text = this.SelectedData.Traits.Plural; this.HomeSystemEntry.Text = this.SelectedData.Traits.HomeSystemName; this.HomeWorldName = this.SelectedData.Traits.HomeworldName; this.GalaxySizeRect = new Rectangle(nameRect.X + nameRect.Width + 40 - 22, nameRect.Y + 5, (int)Fonts.Arial12.MeasureString("Galaxy Size ").X, Fonts.Arial12.LineSpacing); this.NumberStarsRect = new Rectangle(this.GalaxySizeRect.X, this.GalaxySizeRect.Y + Fonts.Arial12.LineSpacing + 10, this.GalaxySizeRect.Width, this.GalaxySizeRect.Height); this.NumOpponentsRect = new Rectangle(this.NumberStarsRect.X, this.NumberStarsRect.Y + Fonts.Arial12.LineSpacing + 10, this.NumberStarsRect.Width, this.NumberStarsRect.Height); this.GameModeRect = new Rectangle(this.NumOpponentsRect.X, this.NumOpponentsRect.Y + Fonts.Arial12.LineSpacing + 10, this.NumberStarsRect.Width, this.NumOpponentsRect.Height); this.PacingRect = new Rectangle(this.GameModeRect.X, this.GameModeRect.Y + Fonts.Arial12.LineSpacing + 10, this.GameModeRect.Width, this.GameModeRect.Height); this.DifficultyRect = new Rectangle(this.PacingRect.X, this.PacingRect.Y + Fonts.Arial12.LineSpacing + 10, this.PacingRect.Width, this.PacingRect.Height); Rectangle dRect = new Rectangle(leftRect.X + leftRect.Width + 5, leftRect.Y, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - leftRect.X - leftRect.Width - 10, leftRect.Height); this.Description = new Menu1(base.ScreenManager, dRect, true); this.dslrect = new Rectangle(leftRect.X + leftRect.Width + 5, leftRect.Y, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - leftRect.X - leftRect.Width - 10, leftRect.Height - 160); Submenu dsub = new Submenu(base.ScreenManager, this.dslrect); this.DescriptionSL = new ScrollList(dsub, Fonts.Arial12.LineSpacing); Rectangle psubRect = new Rectangle(leftRect.X + 20, leftRect.Y + 20, leftRect.Width - 40, leftRect.Height - 40); this.Traits = new Submenu(base.ScreenManager, psubRect); this.Traits.AddTab(Localizer.Token(19)); this.Traits.AddTab(Localizer.Token(20)); this.Traits.AddTab(Localizer.Token(21)); int size = 55; if (GlobalStats.Config.Language != "German" && base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth <= 1280) { size = 65; } if (GlobalStats.Config.Language == "Russian" || GlobalStats.Config.Language == "Polish") { size = 70; } this.traitsSL = new ScrollList(this.Traits, size); foreach (TraitEntry t in this.AllTraits) { if (t.trait.Category == "Physical") this.traitsSL.AddItem(t); } this.Engage = new UIButton() { Rect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 140, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 40, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_pressed"], Text = Localizer.Token(22), Launches = "Engage" }; this.Buttons.Add(this.Engage); this.Abort = new UIButton() { Rect = new Rectangle(10, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 40, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_pressed"], Text = Localizer.Token(23), Launches = "Abort" }; this.Buttons.Add(this.Abort); this.ClearTraits = new UIButton() { Rect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 150, this.Description.Menu.Y + this.Description.Menu.Height - 40, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_pressed"], Text = "Clear Traits", Launches = "Clear" }; this.Buttons.Add(this.ClearTraits); this.DoRaceDescription(); this.SetEmpireData(this.SelectedData); base.LoadContent(); }
public override void LoadContent() { this.Window = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 350, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 300, 700, 600); this.SaveMenu = new Menu1(base.ScreenManager, this.Window); Rectangle sub = new Rectangle(this.Window.X + 20, this.Window.Y + 20, this.Window.Width - 40, 80); this.NameSave = new Submenu(base.ScreenManager, sub); this.NameSave.AddTab("Load Saved Game..."); Vector2 Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 84), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 100)); this.TitlePosition = new Vector2((float)(sub.X + 20), (float)(sub.Y + 45)); Rectangle scrollList = new Rectangle(sub.X, sub.Y + 90, sub.Width, this.Window.Height - sub.Height - 50); this.AllSaves = new Submenu(base.ScreenManager, scrollList); this.AllSaves.AddTab("Saved Fleets"); this.SavesSL = new ScrollList(this.AllSaves); FileInfo[] filesFromDirectory; if (GlobalStats.ActiveMod != null && Directory.Exists(string.Concat(Ship_Game.ResourceManager.WhichModPath, "/FleetDesigns"))) { filesFromDirectory = HelperFunctions.GetFilesFromDirectory(string.Concat(Ship_Game.ResourceManager.WhichModPath, "/FleetDesigns")); } else { filesFromDirectory = HelperFunctions.GetFilesFromDirectory("Content/FleetDesigns"); } for (int i = 0; i < (int)filesFromDirectory.Length; i++) { FileInfo FI = filesFromDirectory[i]; bool OK = true; XmlSerializer serializer1 = new XmlSerializer(typeof(FleetDesign)); foreach (FleetDataNode node in ((FleetDesign)serializer1.Deserialize(FI.OpenRead())).Data) { if (EmpireManager.GetEmpireByName(this.parentScreen.EmpireUI.screen.PlayerLoyalty).WeCanBuildThis(node.ShipName)) { continue; } OK = false; break; } if (OK) { this.SavesSL.AddItem(FI); } } string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); FileInfo[] fileInfoArray = HelperFunctions.GetFilesFromDirectory(string.Concat(path, "/StarDrive/Fleet Designs")); for (int j = 0; j < (int)fileInfoArray.Length; j++) { FileInfo FI = fileInfoArray[j]; bool OK = true; XmlSerializer serializer1 = new XmlSerializer(typeof(FleetDesign)); foreach (FleetDataNode node in ((FleetDesign)serializer1.Deserialize(FI.OpenRead())).Data) { if (EmpireManager.GetEmpireByName(this.parentScreen.EmpireUI.screen.PlayerLoyalty).WeCanBuildThis(node.ShipName)) { continue; } OK = false; break; } if (OK) { this.SavesSL.AddItem(FI); } } this.EnternamePos = this.TitlePosition; this.EnterNameArea = new UITextEntry(); this.EnterNameArea.Text = ""; this.EnterNameArea.ClickableArea = new Rectangle((int)this.EnternamePos.X, (int)this.EnternamePos.Y - 2, (int)Fonts.Arial20Bold.MeasureString(this.EnterNameArea.Text).X + 20, Fonts.Arial20Bold.LineSpacing); this.Save = new UIButton() { Rect = new Rectangle(sub.X + sub.Width - 88, this.EnterNameArea.ClickableArea.Y - 2, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_pressed"], Text = "Load" }; this.Buttons.Add(this.Save); Cursor.Y = Cursor.Y + (float)(ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height + 15); base.LoadContent(); base.LoadContent(); }
public void LoadGraphics() { this.projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f, (float)this.ScreenManager.GraphicsDevice.Viewport.Width / (float)this.ScreenManager.GraphicsDevice.Viewport.Height, 1000f, 3E+07f); this.Frustum = new BoundingFrustum(this.view * this.projection); this.mmHousing = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 276, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 256, 276, 256); this.MinimapDisplayRect = new Rectangle(this.mmHousing.X + 61, this.mmHousing.Y + 43, 200, 200); this.minimap = new MiniMap(this.mmHousing); this.mmButtons = new MinimapButtons(this.mmHousing, this.EmpireUI); this.mmShowBorders = new Rectangle(this.MinimapDisplayRect.X, this.MinimapDisplayRect.Y - 25, 32, 32); this.mmDSBW = new Rectangle(this.mmShowBorders.X + 32, this.mmShowBorders.Y, 64, 32); this.mmAutomation = new Rectangle(this.mmDSBW.X + this.mmDSBW.Width, this.mmShowBorders.Y, 96, 32); this.mmShipView = new Rectangle(this.MinimapDisplayRect.X - 32, this.MinimapDisplayRect.Y, 32, 105); this.mmGalaxyView = new Rectangle(this.mmShipView.X, this.mmShipView.Y + 105, 32, 105); this.SectorMap = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 300, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 150, 150, 150); this.GalaxyMap = new Rectangle(this.SectorMap.X + this.SectorMap.Width, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 150, 150, 150); this.SelectedStuffRect = new Rectangle(0, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 247, 407, 242); this.ShipInfoUIElement = new ShipInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.sInfoUI = new SystemInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.pInfoUI = new PlanetInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.shipListInfoUI = new ShipListInfoUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.vuiElement = new VariableUIElement(this.SelectedStuffRect, this.ScreenManager, this); this.SectorSourceRect = new Rectangle((this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 720) / 2, (this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 720) / 2, 720, 720); this.EmpireUI = new EmpireUIOverlay(this.player, this.ScreenManager.GraphicsDevice, this); this.bloomComponent = new BloomComponent(this.ScreenManager); this.bloomComponent.LoadContent(); this.aw = new AutomationWindow(this.ScreenManager, this); PresentationParameters presentationParameters = this.ScreenManager.GraphicsDevice.PresentationParameters; int backBufferWidth = presentationParameters.BackBufferWidth; int backBufferHeight = presentationParameters.BackBufferHeight; SurfaceFormat backBufferFormat = presentationParameters.BackBufferFormat; this.sceneMap = new ResolveTexture2D(this.ScreenManager.GraphicsDevice, backBufferWidth, backBufferHeight, 1, backBufferFormat); this.MainTarget = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); this.LightsTarget = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); this.MiniMapSector = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); this.BorderRT = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); this.StencilRT = BloomComponent.CreateRenderTarget(this.ScreenManager.GraphicsDevice, 1, backBufferFormat); string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); if (this.loadFogPath == null) { this.FogMap = ResourceManager.TextureDict["Textures/UniverseFeather"]; } else { using (FileStream fileStream = File.OpenRead(folderPath + "/StarDrive/Saved Games/Fog Maps/" + this.loadFogPath + ".png")) this.FogMap = Texture2D.FromFile(this.ScreenManager.GraphicsDevice, (Stream)fileStream); } this.FogMapTarget = new RenderTarget2D(this.ScreenManager.GraphicsDevice, 512, 512, 1, backBufferFormat, this.ScreenManager.GraphicsDevice.PresentationParameters.MultiSampleType, presentationParameters.MultiSampleQuality); this.basicFogOfWarEffect = this.ScreenManager.Content.Load<Effect>("Effects/BasicFogOfWar"); this.LoadMenu(); MuzzleFlashManager.universeScreen = this; DroneAI.universeScreen = this; MuzzleFlashManager.flashModel = this.ScreenManager.Content.Load<Model>("Model/Projectiles/muzzleEnergy"); MuzzleFlashManager.FlashTexture = this.ScreenManager.Content.Load<Texture2D>("Model/Projectiles/Textures/MuzzleFlash_01"); ExplosionManager.universeScreen = this; FTLManager.universeScreen = this; FTLManager.FTLTexture = this.ScreenManager.Content.Load<Texture2D>("Textures/Ships/FTL"); this.anomalyManager = new AnomalyManager(); ShipDesignScreen.screen = this; Fleet.screen = this; Bomb.screen = this; Anomaly.screen = this; PlanetScreen.screen = this; MinimapButtons.screen = this; Projectile.contentManager = this.ScreenManager.Content; Projectile.universeScreen = this; ShipModule.universeScreen = this; Asteroid.universeScreen = this; Empire.universeScreen = this; SpaceJunk.universeScreen = this; ResourceManager.universeScreen = this; Planet.universeScreen = this; Weapon.universeScreen = this; Ship.universeScreen = this; ArtificialIntelligence.universeScreen = this; MissileAI.universeScreen = this; Moon.universeScreen = this; CombatScreen.universeScreen = this; FleetDesignScreen.screen = this; this.xnaPlanetModel = this.ScreenManager.Content.Load<Model>("Model/SpaceObjects/planet"); this.atmoModel = this.ScreenManager.Content.Load<Model>("Model/sphere"); this.AtmoEffect = this.ScreenManager.Content.Load<Effect>("Effects/PlanetHalo"); this.cloudTex = this.ScreenManager.Content.Load<Texture2D>("Model/SpaceObjects/earthcloudmap"); this.RingTexture = this.ScreenManager.Content.Load<Texture2D>("Model/SpaceObjects/planet_rings"); this.ThrusterEffect = this.ScreenManager.Content.Load<Effect>("Effects/Thrust"); this.listener = new AudioListener(); this.SunModel = this.ScreenManager.Content.Load<Model>("Model/SpaceObjects/star_plane"); this.NebModel = this.ScreenManager.Content.Load<Model>("Model/SpaceObjects/star_plane"); this.ScreenRectangle = new Rectangle(0, 0, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight); this.starfield = new Starfield(Vector2.Zero, this.ScreenManager.GraphicsDevice, this.ScreenManager.Content); this.starfield.LoadContent(); //fbedard: new button for ShipsInCombat this.ShipsInCombat = new UIButton(); ShipsInCombat.Rect = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 275, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 280, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height); ShipsInCombat.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu"]; ShipsInCombat.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_hover"]; ShipsInCombat.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_pressed"]; ShipsInCombat.Text = "Ships: 0"; ShipsInCombat.Launches = "ShipsInCombat"; //fbedard: new button for PlanetsInCombat this.PlanetsInCombat = new UIButton(); PlanetsInCombat.Rect = new Rectangle(this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 135, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 280, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px"].Height); PlanetsInCombat.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu"]; PlanetsInCombat.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_hover"]; PlanetsInCombat.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_132px_menu_pressed"]; PlanetsInCombat.Text = "Planets: 0"; PlanetsInCombat.Launches = "PlanetsInCombat"; }
public ColonyScreen(Planet p, Ship_Game.ScreenManager ScreenManager, EmpireUIOverlay empUI) { this.eui = empUI; this.ScreenManager = ScreenManager; this.p = p; if (this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth <= 1366) this.LowRes = true; Rectangle theMenu1 = new Rectangle(2, 44, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth * 2 / 3, 80); this.TitleBar = new Menu2(ScreenManager, theMenu1); this.LeftColony = new ToggleButton(new Rectangle(theMenu1.X + 25, theMenu1.Y + 24, 14, 35), "SelectionBox/button_arrow_left", "SelectionBox/button_arrow_left", "SelectionBox/button_arrow_left_hover", "SelectionBox/button_arrow_left_hover", ""); this.RightColony = new ToggleButton(new Rectangle(theMenu1.X + theMenu1.Width - 39, theMenu1.Y + 24, 14, 35), "SelectionBox/button_arrow_right", "SelectionBox/button_arrow_right", "SelectionBox/button_arrow_right_hover", "SelectionBox/button_arrow_right_hover", ""); this.TitlePos = new Vector2((float)(theMenu1.X + theMenu1.Width / 2) - Fonts.Laserian14.MeasureString("Colony Overview").X / 2f, (float)(theMenu1.Y + theMenu1.Height / 2 - Fonts.Laserian14.LineSpacing / 2)); Rectangle theMenu2 = new Rectangle(2, theMenu1.Y + theMenu1.Height + 5, theMenu1.Width, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - (theMenu1.Y + theMenu1.Height) - 7); this.LeftMenu = new Menu1(ScreenManager, theMenu2); Rectangle theMenu3 = new Rectangle(theMenu1.X + theMenu1.Width + 10, theMenu1.Y, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 3 - 15, ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - theMenu1.Y - 2); this.RightMenu = new Menu1(ScreenManager, theMenu3); this.MoneyRect = new Rectangle(theMenu2.X + theMenu2.Width - 75, theMenu2.Y + 20, ResourceManager.TextureDict["NewUI/icon_money"].Width, ResourceManager.TextureDict["NewUI/icon_money"].Height); this.close = new CloseButton(new Rectangle(theMenu3.X + theMenu3.Width - 52, theMenu3.Y + 22, 20, 20)); Rectangle theMenu4 = new Rectangle(theMenu2.X + 20, theMenu2.Y + 20, (int)(0.400000005960464 * (double)theMenu2.Width), (int)(0.25 * (double)(theMenu2.Height - 80))); this.PlanetInfo = new Submenu(ScreenManager, theMenu4); this.PlanetInfo.AddTab(Localizer.Token(326)); Rectangle theMenu5 = new Rectangle(theMenu2.X + 20, theMenu2.Y + 20 + theMenu4.Height, (int)(0.400000005960464 * (double)theMenu2.Width), (int)(0.25 * (double)(theMenu2.Height - 80))); this.pDescription = new Submenu(ScreenManager, theMenu5); Rectangle theMenu6 = new Rectangle(theMenu2.X + 20, theMenu2.Y + 20 + theMenu4.Height + theMenu5.Height + 20, (int)(0.400000005960464 * (double)theMenu2.Width), (int)(0.25 * (double)(theMenu2.Height - 80))); this.pLabor = new Submenu(ScreenManager, theMenu6); this.pLabor.AddTab(Localizer.Token(327)); float num1 = (float)(int)((double)theMenu6.Width * 0.600000023841858); while ((double)num1 % 10.0 != 0.0) ++num1; Rectangle rectangle1 = new Rectangle(theMenu6.X + 60, theMenu6.Y + 25 + (int)(0.25 * (double)(theMenu6.Height - 25)), (int)num1, 6); this.SliderFood = new ColonyScreen.Slider(); this.SliderFood.sRect = rectangle1; this.SliderFood.amount = p.FarmerPercentage; this.FoodLock = new ColonyScreen.Lock(); this.FoodLock.LockRect = new Rectangle(this.SliderFood.sRect.X + this.SliderFood.sRect.Width + 50, this.SliderFood.sRect.Y + 2 + this.SliderFood.sRect.Height / 2 - ResourceManager.TextureDict[this.FoodLock.Path].Height / 2, ResourceManager.TextureDict[this.FoodLock.Path].Width, ResourceManager.TextureDict[this.FoodLock.Path].Height); if (p.Owner != null && p.Owner.data.Traits.Cybernetic > 0) p.FoodLocked = true; this.FoodLock.Locked = p.FoodLocked; Rectangle rectangle2 = new Rectangle(theMenu6.X + 60, theMenu6.Y + 25 + (int)(0.5 * (double)(theMenu6.Height - 25)), (int)num1, 6); this.SliderProd = new ColonyScreen.Slider(); this.SliderProd.sRect = rectangle2; this.SliderProd.amount = p.WorkerPercentage; this.ProdLock = new ColonyScreen.Lock(); this.ProdLock.LockRect = new Rectangle(this.SliderFood.sRect.X + this.SliderFood.sRect.Width + 50, this.SliderProd.sRect.Y + 2 + this.SliderFood.sRect.Height / 2 - ResourceManager.TextureDict[this.FoodLock.Path].Height / 2, ResourceManager.TextureDict[this.FoodLock.Path].Width, ResourceManager.TextureDict[this.FoodLock.Path].Height); this.ProdLock.Locked = p.ProdLocked; Rectangle rectangle3 = new Rectangle(theMenu6.X + 60, theMenu6.Y + 25 + (int)(0.75 * (double)(theMenu6.Height - 25)), (int)num1, 6); this.SliderRes = new ColonyScreen.Slider(); this.SliderRes.sRect = rectangle3; this.SliderRes.amount = p.ResearcherPercentage; this.ResLock = new ColonyScreen.Lock(); this.ResLock.LockRect = new Rectangle(this.SliderFood.sRect.X + this.SliderFood.sRect.Width + 50, this.SliderRes.sRect.Y + 2 + this.SliderFood.sRect.Height / 2 - ResourceManager.TextureDict[this.FoodLock.Path].Height / 2, ResourceManager.TextureDict[this.FoodLock.Path].Width, ResourceManager.TextureDict[this.FoodLock.Path].Height); this.ResLock.Locked = p.ResLocked; Rectangle theMenu7 = new Rectangle(theMenu2.X + 20, theMenu2.Y + 20 + theMenu4.Height + theMenu5.Height + theMenu6.Height + 40, (int)(0.400000005960464 * (double)theMenu2.Width), (int)(0.25 * (double)(theMenu2.Height - 80))); this.pStorage = new Submenu(ScreenManager, theMenu7); this.pStorage.AddTab(Localizer.Token(328)); this.eui.screen.ShipsInCombat.Active = false; this.eui.screen.PlanetsInCombat.Active = false; if (GlobalStats.HardcoreRuleset) { int num2 = (theMenu7.Width - 40) / 4; this.ResourceButtons.Add(new ThreeStateButton(p.fs, "Food", new Vector2((float)(theMenu7.X + 20), (float)(theMenu7.Y + 30)))); this.ResourceButtons.Add(new ThreeStateButton(p.ps, "Production", new Vector2((float)(theMenu7.X + 20 + num2), (float)(theMenu7.Y + 30)))); this.ResourceButtons.Add(new ThreeStateButton(Planet.GoodState.EXPORT, "Fissionables", new Vector2((float)(theMenu7.X + 20 + num2 * 2), (float)(theMenu7.Y + 30)))); this.ResourceButtons.Add(new ThreeStateButton(Planet.GoodState.EXPORT, "ReactorFuel", new Vector2((float)(theMenu7.X + 20 + num2 * 3), (float)(theMenu7.Y + 30)))); } else { this.FoodStorage = new ProgressBar(new Rectangle(theMenu7.X + 100, theMenu7.Y + 25 + (int)(0.330000013113022 * (double)(theMenu7.Height - 25)), (int)(0.400000005960464 * (double)theMenu7.Width), 18)); this.FoodStorage.Max = p.MAX_STORAGE; this.FoodStorage.Progress = p.FoodHere; this.FoodStorage.color = "green"; this.foodDropDown = this.LowRes ? new DropDownMenu(new Rectangle(theMenu7.X + 90 + (int)(0.400000005960464 * (double)theMenu7.Width) + 20, this.FoodStorage.pBar.Y + this.FoodStorage.pBar.Height / 2 - 9, (int)(0.200000002980232 * (double)theMenu7.Width), 18)) : new DropDownMenu(new Rectangle(theMenu7.X + 100 + (int)(0.400000005960464 * (double)theMenu7.Width) + 20, this.FoodStorage.pBar.Y + this.FoodStorage.pBar.Height / 2 - 9, (int)(0.200000002980232 * (double)theMenu7.Width), 18)); this.foodDropDown.AddOption(Localizer.Token(329)); this.foodDropDown.AddOption(Localizer.Token(330)); this.foodDropDown.AddOption(Localizer.Token(331)); this.foodDropDown.ActiveIndex = (int)p.fs; this.foodStorageIcon = new Rectangle(theMenu7.X + 20, this.FoodStorage.pBar.Y + this.FoodStorage.pBar.Height / 2 - ResourceManager.TextureDict["NewUI/icon_storage_food"].Height / 2, ResourceManager.TextureDict["NewUI/icon_storage_food"].Width, ResourceManager.TextureDict["NewUI/icon_storage_food"].Height); this.ProdStorage = new ProgressBar(new Rectangle(theMenu7.X + 100, theMenu7.Y + 25 + (int)(0.660000026226044 * (double)(theMenu7.Height - 25)), (int)(0.400000005960464 * (double)theMenu7.Width), 18)); this.ProdStorage.Max = p.MAX_STORAGE; this.ProdStorage.Progress = p.ProductionHere; this.profStorageIcon = new Rectangle(theMenu7.X + 20, this.ProdStorage.pBar.Y + this.ProdStorage.pBar.Height / 2 - ResourceManager.TextureDict["NewUI/icon_storage_food"].Height / 2, ResourceManager.TextureDict["NewUI/icon_storage_production"].Width, ResourceManager.TextureDict["NewUI/icon_storage_food"].Height); this.prodDropDown = this.LowRes ? new DropDownMenu(new Rectangle(theMenu7.X + 90 + (int)(0.400000005960464 * (double)theMenu7.Width) + 20, this.ProdStorage.pBar.Y + this.FoodStorage.pBar.Height / 2 - 9, (int)(0.200000002980232 * (double)theMenu7.Width), 18)) : new DropDownMenu(new Rectangle(theMenu7.X + 100 + (int)(0.400000005960464 * (double)theMenu7.Width) + 20, this.ProdStorage.pBar.Y + this.FoodStorage.pBar.Height / 2 - 9, (int)(0.200000002980232 * (double)theMenu7.Width), 18)); this.prodDropDown.AddOption(Localizer.Token(329)); this.prodDropDown.AddOption(Localizer.Token(330)); this.prodDropDown.AddOption(Localizer.Token(331)); this.prodDropDown.ActiveIndex = (int)p.ps; } Rectangle theMenu8 = new Rectangle(theMenu2.X + 20 + theMenu4.Width + 20, theMenu4.Y, theMenu2.Width - 60 - theMenu4.Width, (int)((double)theMenu2.Height * 0.5)); this.subColonyGrid = new Submenu(ScreenManager, theMenu8); this.subColonyGrid.AddTab(Localizer.Token(332)); Rectangle theMenu9 = new Rectangle(theMenu2.X + 20 + theMenu4.Width + 20, theMenu8.Y + theMenu8.Height + 20, theMenu2.Width - 60 - theMenu4.Width, theMenu2.Height - 20 - theMenu8.Height - 40); this.pFacilities = new Submenu(ScreenManager, theMenu9); this.pFacilities.AddTab(Localizer.Token(333)); this.launchTroops = new UIButton(); this.launchTroops.Rect = new Rectangle(theMenu9.X + theMenu9.Width - 175, theMenu9.Y - 5, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height); this.launchTroops.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"]; this.launchTroops.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"]; this.launchTroops.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"]; this.launchTroops.Text = "Launch Troops"; this.launchTroops.Launches = "Launch Troops"; //fbedard: Add Send Troops button this.SendTroops = new UIButton(); this.SendTroops.Rect = new Rectangle(theMenu9.X + theMenu9.Width - this.launchTroops.Rect.Width - 185, theMenu9.Y - 5, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height); this.SendTroops.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"]; this.SendTroops.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"]; this.SendTroops.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"]; this.SendTroops.Text = "Send Troops"; this.SendTroops.Launches = "Send Troops"; this.CommoditiesSL = new ScrollList(this.pFacilities, 40); Rectangle theMenu10 = new Rectangle(theMenu3.X + 20, theMenu3.Y + 20, theMenu3.Width - 40, (int)(0.5 * (double)(theMenu3.Height - 60))); this.build = new Submenu(ScreenManager, theMenu10); this.build.AddTab(Localizer.Token(334)); this.buildSL = new ScrollList(this.build); this.playerDesignsToggle = new ToggleButton(new Rectangle(this.build.Menu.X + this.build.Menu.Width - 270, this.build.Menu.Y, 29, 20), "SelectionBox/button_grid_active", "SelectionBox/button_grid_inactive", "SelectionBox/button_grid_hover", "SelectionBox/button_grid_pressed", "SelectionBox/icon_grid"); this.playerDesignsToggle.Active = GlobalStats.ShowAllDesigns; if (p.HasShipyard) this.build.AddTab(Localizer.Token(335)); if (p.AllowInfantry) this.build.AddTab(Localizer.Token(336)); Rectangle theMenu11 = new Rectangle(theMenu3.X + 20, theMenu3.Y + 20 + 20 + theMenu10.Height, theMenu3.Width - 40, theMenu3.Height - 40 - theMenu10.Height - 20 - 3); this.queue = new Submenu(ScreenManager, theMenu11); this.queue.AddTab(Localizer.Token(337)); this.QSL = new ScrollList(this.queue); this.QSL.IsDraggable = true; this.PlanetIcon = new Rectangle(theMenu4.X + theMenu4.Width - 148, theMenu4.Y + (theMenu4.Height - 25) / 2 - 64 + 25, 128, 128); this.gridPos = new Rectangle(this.subColonyGrid.Menu.X + 10, this.subColonyGrid.Menu.Y + 30, this.subColonyGrid.Menu.Width - 20, this.subColonyGrid.Menu.Height - 35); int width = this.gridPos.Width / 7; int height = this.gridPos.Height / 5; foreach (PlanetGridSquare planetGridSquare in p.TilesList) planetGridSquare.ClickRect = new Rectangle(this.gridPos.X + planetGridSquare.x * width, this.gridPos.Y + planetGridSquare.y * height, width, height); this.PlanetName.Text = p.Name; this.PlanetName.MaxCharacters = 12; if (p.Owner != null) { this.shipsCanBuildLast = p.Owner.ShipsWeCanBuild.Count; this.buildingsHereLast = p.BuildingList.Count; this.buildingsCanBuildLast = this.BuildingsCanBuild.Count; this.detailInfo = (object)p.Description; Rectangle rectangle4 = new Rectangle(this.pDescription.Menu.X + 10, this.pDescription.Menu.Y + 30, 124, 148); Rectangle rectangle5 = new Rectangle(rectangle4.X + rectangle4.Width + 20, rectangle4.Y + rectangle4.Height - 15, (int)Fonts.Pirulen16.MeasureString(Localizer.Token(370)).X, Fonts.Pirulen16.LineSpacing); this.GovernorDropdown = new DropOptions(new Rectangle(rectangle5.X + 30, rectangle5.Y + 30, 100, 18)); this.GovernorDropdown.AddOption("--", 1); this.GovernorDropdown.AddOption(Localizer.Token(4064), 0); this.GovernorDropdown.AddOption(Localizer.Token(4065), 2); this.GovernorDropdown.AddOption(Localizer.Token(4066), 4); this.GovernorDropdown.AddOption(Localizer.Token(4067), 3); this.GovernorDropdown.AddOption(Localizer.Token(4068), 5); this.GovernorDropdown.AddOption(Localizer.Token(5087), 6); this.GovernorDropdown.ActiveIndex = ColonyScreen.GetIndex(p); if ((Planet.ColonyType)this.GovernorDropdown.Options[this.GovernorDropdown.ActiveIndex].value != this.p.colonyType) { this.p.colonyType = (Planet.ColonyType)this.GovernorDropdown.Options[this.GovernorDropdown.ActiveIndex].value; if (this.p.colonyType == Planet.ColonyType.Colony) { this.p.GovernorOn = false; this.p.FoodLocked = false; this.p.ProdLocked = false; this.p.ResLocked = false; } else { this.p.FoodLocked = true; this.p.ProdLocked = true; this.p.ResLocked = true; this.p.GovernorOn = true; } } Ref<bool> connectedTo = new Ref<bool>((Func<bool>)(() => p.GovBuildings), (Action<bool>)(x => p.GovBuildings = x)); Ref<bool> @ref = new Ref<bool>((Func<bool>)(() => p.GovSliders), (Action<bool>)(x => p.GovSliders = x)); this.GovBuildings = new Checkbox(new Vector2((float)(rectangle5.X - 10), (float)(rectangle5.Y - (Fonts.Arial12Bold.LineSpacing * 2 + 15))), "Governor manages buildings", connectedTo, Fonts.Arial12Bold); this.GovSliders = new Checkbox(new Vector2((float)(rectangle5.X - 10), (float)(rectangle5.Y - (Fonts.Arial12Bold.LineSpacing + 10))), "Governor manages labor sliders", connectedTo, Fonts.Arial12Bold); } else PlanetScreen.screen.LookingAtPlanet = false; }
public override void LoadContent() { this.Window = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 350, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 300, 700, 600); this.SaveMenu = new Menu1(base.ScreenManager, this.Window); Rectangle sub = new Rectangle(this.Window.X + 20, this.Window.Y + 20, this.Window.Width - 40, 80); this.NameSave = new Submenu(base.ScreenManager, sub); this.NameSave.AddTab("Save Fleet As..."); Vector2 Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 84), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 100)); this.TitlePosition = new Vector2((float)(sub.X + 20), (float)(sub.Y + 45)); Rectangle scrollList = new Rectangle(sub.X, sub.Y + 90, sub.Width, this.Window.Height - sub.Height - 50); this.AllSaves = new Submenu(base.ScreenManager, scrollList); this.AllSaves.AddTab("All Fleet Designs"); this.SavesSL = new ScrollList(this.AllSaves); string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); FileInfo[] filesFromDirectory = HelperFunctions.GetFilesFromDirectory(string.Concat(path, "/StarDrive/Fleet Designs")); for (int i = 0; i < (int)filesFromDirectory.Length; i++) { FileInfo FI = filesFromDirectory[i]; this.SavesSL.AddItem(FI); } FileInfo[] fileInfoArray = HelperFunctions.GetFilesFromDirectory("Content/FleetDesigns"); for (int j = 0; j < (int)fileInfoArray.Length; j++) { FileInfo FI = fileInfoArray[j]; this.SavesSL.AddItem(FI); } this.EnternamePos = this.TitlePosition; this.EnterNameArea = new UITextEntry(); this.EnterNameArea.Text = this.f.Name; this.EnterNameArea.ClickableArea = new Rectangle((int)this.EnternamePos.X, (int)this.EnternamePos.Y - 2, (int)Fonts.Arial20Bold.MeasureString(this.EnterNameArea.Text).X + 20, Fonts.Arial20Bold.LineSpacing); this.Save = new UIButton() { Rect = new Rectangle(sub.X + sub.Width - 88, this.EnterNameArea.ClickableArea.Y - 2, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_pressed"], Text = "Save" }; this.Buttons.Add(this.Save); Cursor.Y = Cursor.Y + (float)(ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height + 15); base.LoadContent(); base.LoadContent(); }
public override void LoadContent() { Rectangle shipDesignsRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 140, 100, 280, 500); this.sub_ships = new Submenu(base.ScreenManager, shipDesignsRect); this.ShipSL = new ScrollList(this.sub_ships, 40); this.sub_ships.AddTab("Refit to..."); foreach (string shipname in this.shiptorefit.loyalty.ShipsWeCanBuild) { if (!(ResourceManager.ShipsDict[shipname].GetShipData().Hull == this.shiptorefit.GetShipData().Hull) || !(shipname != this.shiptorefit.Name) || ResourceManager.ShipRoles[ResourceManager.ShipsDict[shipname].Role].Protected) { continue; } this.ShipSL.AddItem(shipname); } this.ConfirmRefit = new DanButton(new Vector2((float)shipDesignsRect.X, (float)(shipDesignsRect.Y + 505)), "Do Refit"); this.RefitOne = new UIButton() { Rect = new Rectangle(shipDesignsRect.X + 25, shipDesignsRect.Y + 505, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_low_btn_100px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_low_btn_100px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_low_btn_100px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_low_btn_100px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_low_btn_100px_pressed"], Text = Localizer.Token(2265) }; this.RefitAll = new UIButton() { Rect = new Rectangle(shipDesignsRect.X + 140, shipDesignsRect.Y + 505, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_low_btn_100px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_low_btn_100px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_low_btn_100px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_low_btn_100px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_low_btn_100px_pressed"], Text = Localizer.Token(2266) }; base.LoadContent(); }
public override void LoadContent() { Vector2 Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 84), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 100)); this.window = new Menu2(base.ScreenManager, new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 100, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 150, 200, 330)); this.Save = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Launches = "Save", Text = Localizer.Token(300) }; this.Buttons.Add(this.Save); Cursor.Y = Cursor.Y + (float)(ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height + 15); this.Load = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = Localizer.Token(2), Launches = "Load Game" }; this.Buttons.Add(this.Load); Cursor.Y = Cursor.Y + (float)(ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height + 15); this.Options = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = Localizer.Token(4), Launches = "Options" }; this.Buttons.Add(this.Options); Cursor.Y = Cursor.Y + (float)(ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height + 15); this.Return = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Launches = "Return to Game", Text = Localizer.Token(301) }; this.Buttons.Add(this.Return); Cursor.Y = Cursor.Y + (float)(ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height + 15); this.ExitToMain = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Launches = "Exit to Main Menu", Text = Localizer.Token(302) }; this.Buttons.Add(this.ExitToMain); Cursor.Y = Cursor.Y + (float)(ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height + 15); this.Exit = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Launches = "Exit to Windows", Text = Localizer.Token(303) }; this.Buttons.Add(this.Exit); Cursor.Y = Cursor.Y + (float)(ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height + 15); base.LoadContent(); }
public CombatScreen(Ship_Game.ScreenManager sm, Planet p) { this.p = p; this.ScreenManager = sm; int screenWidth = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth; this.GridRect = new Rectangle(screenWidth / 2 - 639, this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight - 490, 1278, 437); Rectangle titleRect = new Rectangle(screenWidth / 2 - 250, 44, 500, 80); this.TitleBar = new Menu2(this.ScreenManager, titleRect); this.TitlePos = new Vector2((float)(titleRect.X + titleRect.Width / 2) - Fonts.Laserian14.MeasureString("Ground Combat").X / 2f, (float)(titleRect.Y + titleRect.Height / 2 - Fonts.Laserian14.LineSpacing / 2)); this.SelectedItemRect = new Rectangle(screenWidth - 240, 100, 225, 205); this.AssetsRect = new Rectangle(10, 48, 225, 200); this.HoveredItemRect = new Rectangle(10, 248, 225, 200); this.assetsUI = new OrbitalAssetsUIElement(this.AssetsRect, this.ScreenManager, PlanetScreen.screen, p); this.tInfo = new TroopInfoUIElement(this.SelectedItemRect, this.ScreenManager, PlanetScreen.screen); this.hInfo = new TroopInfoUIElement(this.HoveredItemRect, this.ScreenManager, PlanetScreen.screen); Rectangle ColonyGrid = new Rectangle(screenWidth / 2 - screenWidth * 2 / 3 / 2, 130, screenWidth * 2 / 3, screenWidth * 2 / 3 * 5 / 7); this.CombatField = new Menu2(sm, ColonyGrid); Rectangle OrbitalRect = new Rectangle(5, ColonyGrid.Y, (screenWidth - ColonyGrid.Width) / 2 - 20, ColonyGrid.Height+20); this.OrbitalResources = new Menu1(this.ScreenManager, OrbitalRect); Rectangle psubRect = new Rectangle(this.AssetsRect.X + 225, this.AssetsRect.Y+23, 185, this.AssetsRect.Height); this.orbitalResourcesSub = new Submenu(this.ScreenManager, psubRect); this.orbitalResourcesSub.AddTab("In Orbit"); this.OrbitSL = new ScrollList(this.orbitalResourcesSub); universeScreen.ShipsInCombat.Active = false; universeScreen.PlanetsInCombat.Active = false; this.LandAll = new UIButton() { Rect = new Rectangle(this.orbitalResourcesSub.Menu.X + 20, this.orbitalResourcesSub.Menu.Y - 2, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Launches = "Land", Text = "Land All" }; this.LaunchAll = new UIButton() { Rect = new Rectangle(this.orbitalResourcesSub.Menu.X + 20, this.LandAll.Rect.Y -2- this.LandAll.Rect.Height, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Launches = "LaunchAll", Text = "Launch All" }; CombatScreen.universeScreen.MasterShipList.thisLock.EnterReadLock(); foreach (Ship ship in CombatScreen.universeScreen.MasterShipList) { if (ship == null) continue; if (Vector2.Distance(p.Position, ship.Center) >= 4000f || ship.loyalty != EmpireManager.GetEmpireByName(CombatScreen.universeScreen.PlayerLoyalty)) { continue; } if (ship.Role != "troop") { if (ship.TroopList.Count <= 0 || (!ship.HasTroopBay && !ship.hasTransporter && !(p.HasShipyard && p.Owner == ship.loyalty))) //fbedard continue; int LandingLimit = ship.GetHangars().Where(ready => ready.IsTroopBay && ready.hangarTimer <= 0).Count(); foreach (ShipModule module in ship.Transporters.Where(module => module.TransporterTimer <= 1)) LandingLimit += module.TransporterTroopLanding; if (p.HasShipyard && p.Owner == ship.loyalty) LandingLimit = ship.TroopList.Count; //fbedard: Allows to unload if shipyard for (int i = 0; i < ship.TroopList.Count() && LandingLimit > 0; i++) { if (ship.TroopList[i] != null && ship.TroopList[i].GetOwner() == ship.loyalty) { this.OrbitSL.AddItem(ship.TroopList[i]); LandingLimit--; } } } else { this.OrbitSL.AddItem(ship); } } CombatScreen.universeScreen.MasterShipList.thisLock.ExitReadLock(); this.gridPos = new Rectangle(ColonyGrid.X + 20, ColonyGrid.Y + 20, ColonyGrid.Width - 40, ColonyGrid.Height - 40); int xsize = this.gridPos.Width / 7; int ysize = this.gridPos.Height / 5; foreach (PlanetGridSquare pgs in p.TilesList) { pgs.ClickRect = new Rectangle(this.gridPos.X + pgs.x * xsize, this.gridPos.Y + pgs.y * ysize, xsize, ysize); } for (int row = 0; row < 6; row++) { for (int i = 0; i < 7; i++) { CombatScreen.PointSet ps = new CombatScreen.PointSet() { point = new Vector2((float)this.GridRect.X + (float)i * this.widthByRow[row] + this.widthByRow[row] / 2f + this.startXByRow[row], (float)(this.GridRect.Y + this.GridRect.Height) - this.distancesByRow[row]), row = row, column = i }; this.pointsList.Add(ps); } } foreach (CombatScreen.PointSet ps in this.pointsList) { foreach (CombatScreen.PointSet toCheck in this.pointsList) { if (ps.column != toCheck.column || ps.row != toCheck.row - 1) { continue; } float Distance = Vector2.Distance(ps.point, toCheck.point); Vector2 vtt = toCheck.point - ps.point; vtt = Vector2.Normalize(vtt); Vector2 cPoint = ps.point + ((vtt * Distance) / 2f); CombatScreen.PointSet cp = new CombatScreen.PointSet() { point = cPoint, row = ps.row, column = ps.column }; this.CenterPoints.Add(cp); } } foreach (PlanetGridSquare pgs in p.TilesList) { foreach (CombatScreen.PointSet ps in this.CenterPoints) { if (pgs.x != ps.column || pgs.y != ps.row) { continue; } pgs.ClickRect = new Rectangle((int)ps.point.X - 32, (int)ps.point.Y - 32, 64, 64); } } foreach (PlanetGridSquare pgs in p.TilesList) { this.ReversedList.Add(pgs); } }
public override void LoadContent() { this.Window = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 280, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 300, 560, 600); this.SaveMenu = new Menu1(base.ScreenManager, this.Window); this.close = new CloseButton(new Rectangle(this.Window.X + this.Window.Width - 35, this.Window.Y + 10, 20, 20)); Rectangle sub = new Rectangle(this.Window.X + 20, this.Window.Y + 20, this.Window.Width - 40, 80); this.NameSave = new Submenu(base.ScreenManager, sub); this.NameSave.AddTab(Localizer.Token(6)); Vector2 Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 84), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 100)); this.TitlePosition = new Vector2((float)(sub.X + 20), (float)(sub.Y + 45)); Rectangle scrollList = new Rectangle(sub.X, sub.Y + 90, sub.Width, this.Window.Height - sub.Height - 50); this.AllSaves = new Submenu(base.ScreenManager, scrollList); this.AllSaves.AddTab(Localizer.Token(7)); this.SavesSL = new ScrollList(this.AllSaves, 55); string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); List<HeaderData> saves = new List<HeaderData>(); FileInfo[] filesFromDirectory = HelperFunctions.GetFilesFromDirectory(string.Concat(path, "/StarDrive/Saved Games/Headers")); for (int i = 0; i < (int)filesFromDirectory.Length; i++) { Stream file = filesFromDirectory[i].OpenRead(); try { HeaderData data = (HeaderData)ResourceManager.HeaderSerializer.Deserialize(file); data.SetFileInfo(new FileInfo(string.Concat(path, "/StarDrive/Saved Games/", data.SaveName, ".xml.gz"))); if (GlobalStats.ActiveMod != null) { if (data.ModName != GlobalStats.ActiveMod.ModPath) { //file.Close(); file.Dispose(); continue; } } else if (!string.IsNullOrEmpty(data.ModName)) { //file.Close(); file.Dispose(); continue; } saves.Add(data); //file.Close(); file.Dispose(); } catch { //file.Close(); file.Dispose(); } //Label0: // continue; } IOrderedEnumerable<HeaderData> sortedList = from header in saves orderby header.Time descending select header; foreach (HeaderData data in sortedList) { this.SavesSL.AddItem(data); } this.SavesSL.indexAtTop = 0; this.EnternamePos = this.TitlePosition; this.EnterNameArea = new UITextEntry(); //{ this.EnterNameArea.Text = ""; this.EnterNameArea.ClickableArea = new Rectangle((int)this.EnternamePos.X, (int)this.EnternamePos.Y - 2, (int)Fonts.Arial20Bold.MeasureString(this.EnterNameArea.Text).X + 20, Fonts.Arial20Bold.LineSpacing); //}; this.Save = new UIButton() { Rect = new Rectangle(sub.X + sub.Width - 88, this.EnterNameArea.ClickableArea.Y - 2, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_pressed"], Text = Localizer.Token(8), Launches = "Load" }; this.Buttons.Add(this.Save); Cursor.Y = Cursor.Y + (float)(ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height + 15); base.LoadContent(); base.LoadContent(); }
public override void LoadContent() { this.Window = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 250, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 300, 500, 600); this.SaveMenu = new Menu1(base.ScreenManager, this.Window); Rectangle sub = new Rectangle(this.Window.X + 20, this.Window.Y + 20, this.Window.Width - 40, 80); this.SaveShips = new Submenu(base.ScreenManager, sub); this.SaveShips.AddTab("Save Ship Design"); Vector2 Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 84), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 100)); this.TitlePosition = new Vector2((float)(sub.X + 20), (float)(sub.Y + 45)); Rectangle scrollList = new Rectangle(sub.X, sub.Y + 90, sub.Width, this.Window.Height - sub.Height - 50); this.subAllDesigns = new Submenu(base.ScreenManager, scrollList); this.subAllDesigns.AddTab("All Designs"); this.ShipDesigns = new ScrollList(this.subAllDesigns); foreach (KeyValuePair<string, Ship_Game.Gameplay.Ship> Ship in ResourceManager.ShipsDict) { this.ShipDesigns.AddItem(Ship.Value); } this.EnternamePos = this.TitlePosition; this.EnterNameArea.ClickableArea = new Rectangle((int)(this.EnternamePos.X + Fonts.Arial20Bold.MeasureString("Design Name: ").X), (int)this.EnternamePos.Y - 2, 256, Fonts.Arial20Bold.LineSpacing); this.EnterNameArea.Text = this.ShipName; this.Save = new UIButton() { Rect = new Rectangle(sub.X + sub.Width - 88, this.EnterNameArea.ClickableArea.Y - 2, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_pressed"], Text = "Save" }; this.Buttons.Add(this.Save); Cursor.Y = Cursor.Y + (float)(ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height + 15); base.LoadContent(); }
public override void LoadContent() { this.Window = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 425, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 300, 850, 600); this.SaveMenu = new Menu1(base.ScreenManager, this.Window); Rectangle sub = new Rectangle(this.Window.X + 20, this.Window.Y + 20, this.Window.Width - 40, 80); this.NameSave = new Submenu(base.ScreenManager, sub); this.NameSave.AddTab(Localizer.Token(4013)); Vector2 Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 84), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 100)); this.TitlePosition = new Vector2((float)(sub.X + 20), (float)(sub.Y + 45)); Rectangle scrollList = new Rectangle(sub.X, sub.Y + 90, sub.Width, this.Window.Height - sub.Height - 50); this.AllSaves = new Submenu(base.ScreenManager, scrollList); this.AllSaves.AddTab(Localizer.Token(4013)); this.ModsSL = new ScrollList(this.AllSaves, 140); FileInfo[] filesFromDirectoryNoSub = ResourceManager.GetFilesFromDirectoryNoSub("Mods"); for (int i = 0; i < (int)filesFromDirectoryNoSub.Length; i++) { FileInfo FI = filesFromDirectoryNoSub[i]; Stream file = FI.OpenRead(); ModInformation data; if(FI.Name.Contains(".txt")) continue; try { data = (ModInformation)ResourceManager.ModSerializer.Deserialize(file); } catch (Exception ex) { ex.Data.Add("Load Error in file", FI.Name); throw; } //file.Close(); file.Dispose(); ModEntry me = new ModEntry(base.ScreenManager, data, Path.GetFileNameWithoutExtension(FI.Name)); this.ModsSL.AddItem(me); } this.EnternamePos = this.TitlePosition; this.EnterNameArea = new UITextEntry(); //{ this.EnterNameArea.Text = ""; this.EnterNameArea.ClickableArea = new Rectangle((int)this.EnternamePos.X, (int)this.EnternamePos.Y - 2, (int)Fonts.Arial20Bold.MeasureString(this.EnterNameArea.Text).X + 20, Fonts.Arial20Bold.LineSpacing); //}; this.Save = new UIButton() { Rect = new Rectangle(sub.X + sub.Width - 88, this.EnterNameArea.ClickableArea.Y - 2, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_pressed"], Text = Localizer.Token(8), Launches = "Load" }; this.Buttons.Add(this.Save); Cursor.Y = Cursor.Y + (float)(ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height + 15); this.Visit = new UIButton() { Rect = new Rectangle(this.Window.X + 3, this.Window.Y + this.Window.Height + 20, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = Localizer.Token(4015), Launches = "Visit" }; this.Buttons.Add(this.Visit); this.shiptool = new UIButton() { Rect = new Rectangle(this.Window.X + 200, this.Window.Y + this.Window.Height + 20, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = Localizer.Token(4044), Launches = "shiptool" }; this.Buttons.Add(this.shiptool); this.Disable = new UIButton() { Rect = new Rectangle(this.Window.X + this.Window.Width - 172, this.Window.Y + this.Window.Height + 20, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = Localizer.Token(4016), Launches = "Disable" }; this.Buttons.Add(this.Disable); base.LoadContent(); }
public override void HandleInput(InputState input) { this.selector = null; if (this.CurrentButton==null &&( input.Escaped || input.RightMouseClick)) { this.ExitScreen(); } foreach (UIButton b in this.Buttons) { if (CurrentButton != null && b.Launches != "Visit") continue; if (!HelperFunctions.CheckIntersection(b.Rect, input.CursorPosition) ) { b.State = UIButton.PressState.Normal; } else { b.State = UIButton.PressState.Hover; if (input.InGameSelect) { b.State = UIButton.PressState.Pressed; } if (!input.InGameSelect) { continue; } string launches = b.Launches; string str = launches; if (launches == null) { continue; } if (str == "Load") { if (this.ActiveEntry == null) { continue; } this.CurrentButton = b; b.Text = "Loading"; if (GlobalStats.ActiveMod != null) { ResourceManager.Reset(); ResourceManager.Initialize(base.ScreenManager.Content); } this.modLoad = Task.Factory.StartNew(loadModTask); } else if (str == "Visit") { if (string.IsNullOrEmpty(this.ActiveEntry.mi.URL)) Process.Start("http://www.stardrivegame.com/forum/viewtopic.php?f=6&t=696"); else Process.Start(this.ActiveEntry.mi.URL); } else if (str == "shiptool" && this.CurrentButton == null) { base.ScreenManager.AddScreen(new ShipToolScreen()); } else if (str == "Disable" && this.CurrentButton==null) { GlobalStats.ActiveMod = null; ResourceManager.WhichModPath = "Content"; GlobalStats.ActiveMod = null; GlobalStats.ActiveModInfo = null; ResourceManager.Reset(); ResourceManager.Initialize(base.ScreenManager.Content); ResourceManager.LoadEmpires(); Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings["ActiveMod"].Value = ""; config.Save(); this.ExitScreen(); this.mmscreen.ResetMusic(); } } } if (this.CurrentButton != null) { if (this.flip) { if (CurrentButton.PressColor.A > 253) this.flip = false; else CurrentButton.PressColor.A++; } else { if (CurrentButton.PressColor.A < 1) this.flip = true; else CurrentButton.PressColor.A--; } if (CurrentButton.State != UIButton.PressState.Pressed) CurrentButton.State = UIButton.PressState.Pressed; return; } this.ModsSL.HandleInput(input); foreach (ScrollList.Entry e in this.ModsSL.Entries) { if (!HelperFunctions.CheckIntersection(e.clickRect, input.CursorPosition)) { e.clickRectHover = 0; } else { if (e.clickRectHover == 0) { AudioManager.PlayCue("sd_ui_mouseover"); } e.clickRectHover = 1; this.selector = new Selector(base.ScreenManager, e.clickRect); if (!input.InGameSelect) { continue; } AudioManager.PlayCue("sd_ui_accept_alt3"); this.EnterNameArea.Text = (e.item as ModEntry).mi.ModName; this.ActiveEntry = e.item as ModEntry; foreach(UIButton button in this.Buttons) { if (button.Launches =="Visit") { string Text; if (this.ActiveEntry == null || string.IsNullOrEmpty(this.ActiveEntry.mi.URL)) Text = Localizer.Token(4015); else Text = "Goto Mod URL"; button.Text = Text; break; } } } } base.HandleInput(input); }
//private string Status_Text; public PlanetListScreenEntry(Planet p, int x, int y, int width1, int height, PlanetListScreen caller) { this.screen = caller; this.planet = p; this.TotalEntrySize = new Rectangle(x, y, width1 - 60, height); this.SysNameRect = new Rectangle(x, y, (int)((float)this.TotalEntrySize.Width * 0.12f), height); this.PlanetNameRect = new Rectangle(x + this.SysNameRect.Width, y, (int)((float)this.TotalEntrySize.Width * 0.25f), height); this.FertRect = new Rectangle(x + this.SysNameRect.Width + this.PlanetNameRect.Width, y, 100, height); this.RichRect = new Rectangle(x + this.SysNameRect.Width + this.PlanetNameRect.Width + this.FertRect.Width, y, 120, height); this.PopRect = new Rectangle(x + this.SysNameRect.Width + this.PlanetNameRect.Width + this.FertRect.Width + this.RichRect.Width, y, 200, height); this.OwnerRect = new Rectangle(x + this.SysNameRect.Width + this.PlanetNameRect.Width + this.FertRect.Width + this.RichRect.Width + this.PopRect.Width, y, 100, height); this.OrdersRect = new Rectangle(x + this.SysNameRect.Width + this.PlanetNameRect.Width + this.FertRect.Width + this.RichRect.Width + this.PopRect.Width + this.OwnerRect.Width, y, 100, height); //this.Status_Text = ""; this.ShipIconRect = new Rectangle(this.PlanetNameRect.X + 5, this.PlanetNameRect.Y + 5, 50, 50); string shipName = this.planet.Name; this.ShipNameEntry.ClickableArea = new Rectangle(this.ShipIconRect.X + this.ShipIconRect.Width + 10, 2 + this.SysNameRect.Y + this.SysNameRect.Height / 2 - Fonts.Arial20Bold.LineSpacing / 2, (int)Fonts.Arial20Bold.MeasureString(shipName).X, Fonts.Arial20Bold.LineSpacing); this.ShipNameEntry.Text = shipName; float width = (float)((int)((float)this.FertRect.Width * 0.8f)); while (width % 10f != 0f) { width = width + 1f; } Goal goal = new Goal(); foreach (Goal g in Ship.universeScreen.player.GetGSAI().Goals) { if (g.GetMarkedPlanet() == null || g.GetMarkedPlanet() != p) { continue; } this.marked = true; } if (this.marked) this.Colonize = new UIButton() { Rect = new Rectangle(this.OrdersRect.X + 10, this.OrdersRect.Y + this.OrdersRect.Height / 2 - ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height / 2, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"] }; else this.Colonize = new UIButton() { Rect = new Rectangle(this.OrdersRect.X + 10, this.OrdersRect.Y + this.OrdersRect.Height / 2 - ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height / 2, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_dip"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_dip_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_dip_pressed"] }; if (!this.marked) this.Colonize.Text = Localizer.Token(1425); else this.Colonize.Text = "Cancel Colonize"; this.Colonize.Launches = Localizer.Token(1425); this.SendTroops = new UIButton() { Rect = new Rectangle(this.OrdersRect.X + this.Colonize.Rect.Width + 10, this.Colonize.Rect.Y, this.Colonize.Rect.Width, this.Colonize.Rect.Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_dip"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_dip_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_dip_pressed"] }; }
public MessageBoxScreen(string message, float Timer) { this.timed = true; this.timer = Timer; this.original = message; this.message = message; base.IsPopup = true; base.TransitionOnTime = TimeSpan.FromSeconds(0.25); base.TransitionOffTime = TimeSpan.FromSeconds(0.25); this.OK = new UIButton() { Rect = new Rectangle(0, 0, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_pressed"], Text = Localizer.Token(15), Launches = "OK" }; this.Buttons.Add(this.OK); this.Cancel = new UIButton() { Rect = new Rectangle(0, 0, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_pressed"], Text = Localizer.Token(16), Launches = "Cancel" }; this.Buttons.Add(this.Cancel); }
public override void LoadContent() { base.LoadContent(); this.MainOptionsRect = new Rectangle(this.r.X + 20, this.r.Y + 175, 300, 375); this.Resolution = new OptionsScreen.Option(); this.Resolution.Name = Localizer.Token(9) + ":"; this.Resolution.NamePosition = new Vector2((float)(this.MainOptionsRect.X + 20), (float)this.MainOptionsRect.Y); this.GamespeedCap = new Checkbox(new Vector2((float)(this.MainOptionsRect.X + this.MainOptionsRect.Width + 5), (float)(this.Resolution.NamePosition.Y)), Localizer.Token(2206), new Ref<bool>((Func<bool>)(() => GlobalStats.LimitSpeed), (Action<bool>)(x => GlobalStats.LimitSpeed = x)), Fonts.Arial12Bold); this.GamespeedCap.Tip_Token = 2205; this.ForceFullSim = new Checkbox(new Vector2((float)(this.MainOptionsRect.X + this.MainOptionsRect.Width + 5), (float)(this.Resolution.NamePosition.Y + 30)), "Force Full Simulation", new Ref<bool>((Func<bool>)(() => GlobalStats.ForceFullSim), (Action<bool>)(x => GlobalStats.ForceFullSim = x)), Fonts.Arial12Bold); this.ForceFullSim.Tip_Token = 2205; this.pauseOnNotification = new Checkbox(new Vector2((float)(this.MainOptionsRect.X + this.MainOptionsRect.Width + 5), (float)(this.Resolution.NamePosition.Y + 60)), Localizer.Token(6007), new Ref<bool>((Func<bool>)(() => GlobalStats.PauseOnNotification), (Action<bool>)(x => GlobalStats.PauseOnNotification = x)), Fonts.Arial12Bold); this.pauseOnNotification.Tip_Token = 7004; this.KeyboardArc = new Checkbox(new Vector2((float)(this.MainOptionsRect.X + this.MainOptionsRect.Width + 5), (float)(this.Resolution.NamePosition.Y + 90)), Localizer.Token(6184), new Ref<bool>((Func<bool>)(() => GlobalStats.AltArcControl), (Action<bool>)(x => GlobalStats.AltArcControl = x)), Fonts.Arial12Bold); this.KeyboardArc.Tip_Token = 7081; this.SecondaryOptionsRect = new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width + 20, this.MainOptionsRect.Y, 210, 305); string str1 = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth.ToString(); string str2 = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight.ToString(); this.startingx = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth; this.startingy = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight; this.startingfullscreen = Game1.Instance.graphics.IsFullScreen; this.xtoApply = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth; this.ytoApply = this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight; string text = str1 + " x " + str2; this.Resolution.ClickableArea = new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.Resolution.NamePosition.Y, (int)Fonts.Arial20Bold.MeasureString(text).X, Fonts.Arial20Bold.LineSpacing); this.Resolution.Value = (object)text; this.Resolution.highlighted = false; this.FullScreen = new OptionsScreen.Option(); this.FullScreen.Name = Localizer.Token(10) + ":"; this.FullScreen.NamePosition = new Vector2((float)(this.MainOptionsRect.X + 20), (float)(this.MainOptionsRect.Y + Fonts.Arial20Bold.LineSpacing * 2 + 2 + 17)); this.FullScreen.Value = (object)((object)Game1.Instance.CurrentMode).ToString(); this.FullScreen.ClickableArea = new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.FullScreen.NamePosition.Y, (int)Fonts.Arial20Bold.MeasureString(this.FullScreen.Value.ToString()).X, Fonts.Arial20Bold.LineSpacing); Rectangle r = new Rectangle(this.MainOptionsRect.X + 9, (int)this.FullScreen.NamePosition.Y + 65, 270, 50); this.MusicVolumeSlider = new FloatSlider(r, "Music Volume"); this.MusicVolumeSlider.SetAmount(GlobalStats.Config.MusicVolume); this.MusicVolumeSlider.amount = GlobalStats.Config.MusicVolume; r = new Rectangle(this.MainOptionsRect.X + 9, (int)r.Y + 50, 270, 50); this.EffectsVolumeSlider = new FloatSlider(r, "Effects Volume"); this.EffectsVolumeSlider.SetAmount(GlobalStats.Config.EffectsVolume); this.EffectsVolumeSlider.amount = GlobalStats.Config.EffectsVolume; r = new Rectangle(this.MainOptionsRect.X + 9, (int)this.FullScreen.NamePosition.Y + 185, 225, 50); this.IconSize = new FloatSlider(r, "Icon Sizes", 0, 30, GlobalStats.IconSize); r = new Rectangle(this.MainOptionsRect.X + 9, (int)this.FullScreen.NamePosition.Y + 235, 225, 50); this.memoryLimit = new FloatSlider(r, string.Concat("Memory limit. KBs In Use: ",(int)(GC.GetTotalMemory(true)/1000f)), 150000, 300000, GlobalStats.MemoryLimiter); int ships =0; if (Empire.universeScreen != null ) ships= Empire.universeScreen.globalshipCount; r = new Rectangle(this.MainOptionsRect.X - 9 + this.MainOptionsRect.Width, (int)this.FullScreen.NamePosition.Y + 235, 225, 50); this.ShipLimiter = new FloatSlider(r, string.Concat("All AI Ship Limit. AI Ships: ", ships), 500, 3500, GlobalStats.ShipCountLimit); r = new Rectangle(this.MainOptionsRect.X - 9 + this.MainOptionsRect.Width, (int)this.FullScreen.NamePosition.Y + 185, 225, 50); this.FreighterLimiter = new FloatSlider(r, string.Concat("Per AI Freighter Limit."), 25, 125, GlobalStats.freighterlimit); Vector2 vector2 = new Vector2((float)(this.SecondaryOptionsRect.X + 10), (float)(this.SecondaryOptionsRect.Y + 10)); this.ResolutionDropDown = new DropOptions(new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.Resolution.NamePosition.Y - 2, 105, 18)); foreach (DisplayMode displayMode in GraphicsAdapter.DefaultAdapter.SupportedDisplayModes) { if (displayMode.Width >= 1280) { OptionsScreen.Option option1 = new OptionsScreen.Option(); option1.x = displayMode.Width; option1.y = displayMode.Height; option1.Name = option1.x.ToString() + " x " + option1.y.ToString(); option1.NamePosition = vector2; option1.ClickableArea = new Rectangle((int)option1.NamePosition.X, (int)option1.NamePosition.Y, (int)Fonts.Arial12Bold.MeasureString(option1.Name).X, Fonts.Arial12Bold.LineSpacing); bool flag = true; foreach (OptionsScreen.Option option2 in this.ResolutionOptions) { if (option2.x == option1.x && option2.y == option1.y) flag = false; } if (flag) { this.ResolutionDropDown.AddOption(option1.Name, (object)option1); this.ResolutionOptions.Add(option1); vector2.Y += (float)Fonts.Arial12Bold.LineSpacing; } } } int qualityLevels = 0; //this.AntiAliasingDD = new DropOptions(new Rectangle(this.MainOptionsRect.X + this.MainOptionsRect.Width / 2 + 10, (int)this.Resolution.NamePosition.Y + 26, 105, 18)); //if (GraphicsAdapter.DefaultAdapter.CheckDeviceMultiSampleType(DeviceType.Hardware, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Format, false, MultiSampleType.EightSamples, out qualityLevels)) // this.AntiAliasingDD.AddOption("8x AA", 8); //if (GraphicsAdapter.DefaultAdapter.CheckDeviceMultiSampleType(DeviceType.Hardware, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Format, false, MultiSampleType.EightSamples, out qualityLevels)) // this.AntiAliasingDD.AddOption("4x AA", 4); //if (GraphicsAdapter.DefaultAdapter.CheckDeviceMultiSampleType(DeviceType.Hardware, GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Format, false, MultiSampleType.EightSamples, out qualityLevels)) // this.AntiAliasingDD.AddOption("2x AA", 2); //this.AntiAliasingDD.AddOption("No AA", 0); //this.AntiAliasingDD.ActiveIndex = 0; //switch (GlobalStats.Config.AASamples) //{ // case 0: // this.AntiAliasingDD.ActiveIndex = 3; // break; // case 2: // this.AntiAliasingDD.ActiveIndex = 2; // break; // case 4: // this.AntiAliasingDD.ActiveIndex = 1; // break; // case 8: // this.AntiAliasingDD.ActiveIndex = 0; // break; //} foreach (OptionsScreen.Option option in this.ResolutionOptions) { if (this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth == option.x && this.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight == option.y) { foreach (Entry entry in this.ResolutionDropDown.Options) { if ((entry.ReferencedObject as OptionsScreen.Option).Name == option.Name) this.ResolutionDropDown.ActiveIndex = this.ResolutionDropDown.Options.IndexOf(entry); } } } vector2 = new Vector2((float)this.SecondaryOptionsRect.X, (float)(this.SecondaryOptionsRect.Y + this.SecondaryOptionsRect.Height + 60)); this.Apply = new UIButton(); this.Apply.Rect = new Rectangle((int)vector2.X, (int)vector2.Y, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height); this.Apply.NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"]; this.Apply.HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"]; this.Apply.PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"]; this.Apply.Text = Localizer.Token(13); this.Apply.Launches = "Apply Settings"; this.Buttons.Add(this.Apply); }
public override void LoadContent() { Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); //if (ConfigurationManager.AppSettings["ActiveMod"] != "") if (!string.IsNullOrEmpty(config.AppSettings.Settings["ActiveMod"].Value)) { //if (!File.Exists(string.Concat("Mods/", ConfigurationManager.AppSettings["ActiveMod"], ".xml"))) if (!File.Exists(string.Concat("Mods/", config.AppSettings.Settings["ActiveMod"].Value, ".xml"))) { //Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings["ActiveMod"].Value = ""; config.Save(); Ship_Game.ResourceManager.WhichModPath = "Content"; Ship_Game.ResourceManager.Reset(); Ship_Game.ResourceManager.Initialize(base.ScreenManager.Content); } else { //Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); FileInfo FI = new FileInfo(string.Concat("Mods/", config.AppSettings.Settings["ActiveMod"].Value, ".xml")); Stream file = FI.OpenRead(); ModInformation data = (ModInformation)Ship_Game.ResourceManager.ModSerializer.Deserialize(file); //file.Close(); file.Dispose(); ModEntry me = new ModEntry(base.ScreenManager, data, Path.GetFileNameWithoutExtension(FI.Name)); GlobalStats.ActiveMod = me; GlobalStats.ActiveModInfo = me.mi; Ship_Game.ResourceManager.LoadMods(string.Concat("Mods/", config.AppSettings.Settings["ActiveMod"].Value)); } } base.ScreenManager.musicCategory.SetVolume(GlobalStats.Config.MusicVolume); base.ScreenManager.racialMusic.SetVolume(GlobalStats.Config.MusicVolume); base.ScreenManager.combatMusic.SetVolume(GlobalStats.Config.MusicVolume); base.ScreenManager.weaponsCategory.SetVolume(GlobalStats.Config.EffectsVolume); base.ScreenManager.defaultCategory.SetVolume(GlobalStats.Config.EffectsVolume *.5f); if(GlobalStats.Config.EffectsVolume ==0 && GlobalStats.Config.MusicVolume == 0) base.ScreenManager.GlobalCategory.SetVolume(0); else base.ScreenManager.GlobalCategory.SetVolume(1); string basepath = "Stardrive Main Logo 2_"; for (int i = 0; i < 81; i++) { string remainder = i.ToString(this.fmt); Texture2D logo = base.ScreenManager.Content.Load<Texture2D>(string.Concat("MainMenu/Stardrive logo/", basepath, remainder)); this.LogoAnimation.Add(logo); } if (base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight <= 1080) { this.StarField = base.ScreenManager.Content.Load<Texture2D>("MainMenu/nebula_stars_bg"); this.StarFieldRect = new Rectangle(0, 0, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight); } else { this.StarFieldRect = new Rectangle(0, 0, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight); this.StarField = base.ScreenManager.Content.Load<Texture2D>("MainMenu/HR_nebula_stars_bg"); } Vector2 Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 200), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 100)); this.PlayGame = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = Localizer.Token(1) }; this.Buttons.Add(this.PlayGame); this.PlayGame.Launches = "New Campaign"; Cursor.Y = Cursor.Y + (float)(Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height + 15); this.Adventure = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = "Battle Mode" }; Cursor.Y = Cursor.Y + (float)(Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height + 15); this.Tutorials = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = Localizer.Token(3), Launches = "Tutorials" }; this.Buttons.Add(this.Tutorials); Cursor.Y = Cursor.Y + (float)(Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height + 15); this.Load = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = Localizer.Token(2), Launches = "Load Game" }; this.Buttons.Add(this.Load); Cursor.Y = Cursor.Y + (float)(Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height + 15); this.Options = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = Localizer.Token(4), Launches = "Options" }; this.Buttons.Add(this.Options); Cursor.Y = Cursor.Y + (float)(Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height + 15); this.Mods = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = "Mods", Launches = "Mods" }; this.Buttons.Add(this.Mods); Cursor.Y = Cursor.Y + (float)(Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height + 15); this.Exit = new UIButton() { Rect = new Rectangle((int)Cursor.X, (int)Cursor.Y, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Width, Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height), NormalTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"], HoverTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_hover"], PressedTexture = Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px_pressed"], Text = Localizer.Token(5), Launches = "Exit" }; this.Buttons.Add(this.Exit); Cursor.Y = Cursor.Y + (float)(Ship_Game.ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_168px"].Height + 15); base.ScreenManager.inter.ObjectManager.Clear(); base.ScreenManager.inter.LightManager.Clear(); this.shieldModel = base.ScreenManager.Content.Load<Model>("Model/Projectiles/shield"); this.shieldTex = base.ScreenManager.Content.Load<Texture2D>("Model/Projectiles/shield_d"); this.shieldAlpha = base.ScreenManager.Content.Load<Texture2D>("Model/Projectiles/shieldgradient"); this.ShieldEffect = base.ScreenManager.Content.Load<Effect>("Effects/scale"); Beam.BeamEffect = base.ScreenManager.Content.Load<Effect>("Effects/BeamFX"); ShieldManager.shieldModel = this.shieldModel; ShieldManager.shieldTexture = this.shieldTex; ShieldManager.gradientTexture = this.shieldAlpha; ShieldManager.ShieldEffect = this.ShieldEffect; this.Portrait = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 960, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 540, 1920, 1080); while (this.Portrait.Width < base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth && this.Portrait.Height < base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight) { this.Portrait.Width = this.Portrait.Width + 12; this.Portrait.X = base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - this.Portrait.Width / 2; this.Portrait.Height = this.Portrait.Height + 7; this.Portrait.Y = base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - this.Portrait.Height / 2; } if (GlobalStats.ActiveMod != null && !string.IsNullOrEmpty(GlobalStats.ActiveMod.MainMenuMusic)) { this.PlayMp3(string.Concat("Mods/", GlobalStats.ActiveMod.ModPath, "/", GlobalStats.ActiveMod.MainMenuMusic)); } else if (base.ScreenManager.Music == null || base.ScreenManager.Music != null && base.ScreenManager.Music.IsStopped) { base.ScreenManager.musicCategory.SetVolume(GlobalStats.Config.MusicVolume); base.ScreenManager.Music = AudioManager.GetCue("SD_Theme_Reprise_06"); base.ScreenManager.Music.Play(); } //this.whichPlanet = 1; //Added by McShooterz: Random Main menu planet Random rd = new Random(); int planetIndex = rd.Next(1,30); Model planetModel = base.ScreenManager.Content.Load<Model>(string.Concat("Model/SpaceObjects/planet_", planetIndex)); ModelMesh mesh = planetModel.Meshes[0]; this.planetSO = new SceneObject(mesh) { ObjectType = ObjectType.Dynamic, World = (((((Matrix.Identity * Matrix.CreateScale(25f)) * Matrix.CreateRotationZ(1.57079637f - this.Zrotate)) * Matrix.CreateRotationX(MathHelper.ToRadians(20f))) * Matrix.CreateRotationY(MathHelper.ToRadians(65f))) * Matrix.CreateRotationZ(1.57079637f)) * Matrix.CreateTranslation(this.ShipPosition.X - 30000f, this.ShipPosition.Y - 500f, 80000f) }; base.ScreenManager.inter.ObjectManager.Submit(this.planetSO); //Added by McShooterz: random ship in main menu this.ShipPosition = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 1200), (float)(this.LogoRect.Y + 400 - base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2)); // FrostHand: do we actually need to show Model/Ships/speeder/ship07 in base version? Or could show random ship for base and modded version? if (GlobalStats.ActiveMod != null && ResourceManager.MainMenuShipList.ModelPaths.Count > 0) { int shipIndex = rd.Next(0, ResourceManager.MainMenuShipList.ModelPaths.Count); this.shipSO = new SceneObject(((ReadOnlyCollection<ModelMesh>)Ship_Game.ResourceManager.GetModel(ResourceManager.MainMenuShipList.ModelPaths[shipIndex]).Meshes)[0]); this.shipSO.ObjectType = ObjectType.Dynamic; this.shipSO.World = this.worldMatrix; this.shipSO.Visibility = ObjectVisibility.Rendered; base.ScreenManager.inter.ObjectManager.Submit(this.shipSO); } else { this.shipSO = new SceneObject(((ReadOnlyCollection<ModelMesh>)Ship_Game.ResourceManager.GetModel("Model/Ships/speeder/ship07").Meshes)[0]); this.shipSO.ObjectType = ObjectType.Dynamic; this.shipSO.World = this.worldMatrix; this.shipSO.Visibility = ObjectVisibility.Rendered; base.ScreenManager.inter.ObjectManager.Submit(this.shipSO); } LightRig rig = base.ScreenManager.Content.Load<LightRig>("example/MM_light_rig"); base.ScreenManager.inter.LightManager.Submit(rig); base.ScreenManager.environment = base.ScreenManager.Content.Load<SceneEnvironment>("example/scene_environment"); float width = (float)base.ScreenManager.GraphicsDevice.Viewport.Width; Viewport viewport = base.ScreenManager.GraphicsDevice.Viewport; float height = width / (float)viewport.Height; Vector3 camPos = new Vector3(0f, 0f, 1500f) * 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.CreateOrthographic((float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth, (float)base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight, 1f, 80000f); base.LoadContent(); this.LogoRect = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth - 600, 128, 512, 128); this.MoonPosition = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 300), (float)(this.LogoRect.Y + 70 - base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2)); this.planetSO.World = (((((Matrix.Identity * Matrix.CreateScale(this.scale)) * Matrix.CreateRotationZ(1.57079637f - this.Zrotate)) * Matrix.CreateRotationX(MathHelper.ToRadians(20f))) * Matrix.CreateRotationY(MathHelper.ToRadians(65f))) * Matrix.CreateRotationZ(1.57079637f)) * Matrix.CreateTranslation(new Vector3(this.MoonPosition, this.zshift)); }
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 override void LoadContent() { this.Window = new Rectangle(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 250, base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 300, 500, 600); this.loadMenu = new Menu1(base.ScreenManager, this.Window); Rectangle sub = new Rectangle(this.Window.X + 20, this.Window.Y + 60, this.Window.Width - 40, this.Window.Height - 80); this.SaveShips = new Submenu(base.ScreenManager, sub); this.SaveShips.AddTab(Localizer.Token(198)); this.ShipDesigns = new ScrollList(this.SaveShips); Vector2 Cursor = new Vector2((float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - 84), (float)(base.ScreenManager.GraphicsDevice.PresentationParameters.BackBufferHeight / 2 - 100)); this.TitlePosition = new Vector2((float)(this.Window.X + 20), (float)(this.Window.Y + 20)); string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); Rectangle gridRect = new Rectangle(this.SaveShips.Menu.X + this.SaveShips.Menu.Width - 44, this.SaveShips.Menu.Y, 29, 20); this.playerDesignsToggle = new ToggleButton(gridRect, "SelectionBox/button_grid_active", "SelectionBox/button_grid_inactive", "SelectionBox/button_grid_hover", "SelectionBox/button_grid_pressed", "SelectionBox/icon_grid") { Active = this.ShowAllDesigns }; FileInfo[] textList = HelperFunctions.GetFilesFromDirectory(string.Concat(path, "/StarDrive/WIP")); List<ShipData> WIPs = new List<ShipData>(); FileInfo[] fileInfoArray = textList; for (int i = 0; i < (int)fileInfoArray.Length; i++) { FileStream stream = fileInfoArray[i].OpenRead(); ShipData newShipData = (ShipData)ResourceManager.serializer_shipdata.Deserialize(stream); //stream.Close(); stream.Dispose(); if (EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty).GetHDict().ContainsKey(newShipData.Hull) && EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty).GetHDict()[newShipData.Hull]) { WIPs.Add(newShipData); } } List<string> ShipRoles = new List<string>(); if (this.screen != null) { foreach (KeyValuePair<string, Ship_Game.Gameplay.Ship> Ship in ResourceManager.ShipsDict) { //added by gremlin HIDING ERRORS try { if (!EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty).WeCanBuildThis(Ship.Key) || ShipRoles.Contains(Localizer.GetRole(Ship.Value.Role, EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty))) || ResourceManager.ShipRoles[Ship.Value.Role].Protected) { continue; } ShipRoles.Add(Localizer.GetRole(Ship.Value.Role, EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty))); ModuleHeader mh = new ModuleHeader(Localizer.GetRole(Ship.Value.Role, EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty))); this.ShipDesigns.AddItem(mh); } catch { } } if (WIPs.Count > 0) { ShipRoles.Add("WIP"); ModuleHeader mh = new ModuleHeader("WIP"); this.ShipDesigns.AddItem(mh); } foreach (ScrollList.Entry e in this.ShipDesigns.Entries) { foreach (KeyValuePair<string, Ship_Game.Gameplay.Ship> Ship in ResourceManager.ShipsDict) { if (!EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty).WeCanBuildThis(Ship.Key) || !(Localizer.GetRole(Ship.Value.Role, EmpireManager.GetEmpireByName(this.screen.EmpireUI.screen.PlayerLoyalty)) == (e.item as ModuleHeader).Text) || Ship.Value.Name == "Subspace Projector" || Ship.Value.Name == "Shipyard" || Ship.Value.Deleted || ResourceManager.ShipRoles[Ship.Value.Role].Protected) { continue; } if (Ship.Value.reserved || Ship.Value.FromSave) { e.AddItem(Ship.Value); } else { e.AddItemWithCancel(Ship.Value); } } if ((e.item as ModuleHeader).Text != "WIP") { continue; } foreach (ShipData data in WIPs) { e.AddItemWithCancel(data); } } } this.EnternamePos = this.TitlePosition; this.EnterNameArea.Text = Localizer.Token(199); this.Load = new UIButton() { Rect = new Rectangle(sub.X + sub.Width - 88, (int)this.EnternamePos.Y - 2, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Width, ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height), NormalTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"], HoverTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_hover"], PressedTexture = ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px_pressed"], Launches = "Load", Text = Localizer.Token(8) }; this.Buttons.Add(this.Load); Cursor.Y = Cursor.Y + (float)(ResourceManager.TextureDict["EmpireTopBar/empiretopbar_btn_68px"].Height + 15); base.LoadContent(); }