private void SetupSlots() { this.Slots.Clear(); foreach (ModuleSlotData slot in this.ActiveHull.ModuleSlotList) { SlotStruct ss = new SlotStruct(); PrimitiveQuad pq = new PrimitiveQuad(slot.Position.X + this.offset.X - 8f, slot.Position.Y + this.offset.Y - 8f, 16f, 16f); ss.pq = pq; ss.Restrictions = slot.Restrictions; ss.facing = slot.facing; ss.ModuleUID = slot.InstalledModuleUID; ss.state = slot.state; ss.slotReference = slot; ss.SlotOptions = slot.SlotOptions; this.Slots.Add(ss); } foreach (SlotStruct slot in this.Slots) { if (slot.ModuleUID == null) { continue; } this.ActiveModule = Ship_Game.ResourceManager.GetModule(slot.ModuleUID); this.ChangeModuleState(slot.state); this.InstallModuleFromLoad(slot); if (slot.module == null || slot.module.ModuleType != ShipModuleType.Hangar) { continue; } slot.module.hangarShipUID = slot.SlotOptions; } this.ActiveModule = null; this.ActiveModState = ShipDesignScreen.ActiveModuleState.Normal; }
private void InstallModuleNoStack(SlotStruct slot) { //System.Diagnostics.Debug.Assert(false); //looks like this function is not actually used, see if anyone manages to trigger this int num = 0; //check for sufficient slots for (int index1 = 0; index1 < (int)this.ActiveModule.YSIZE; ++index1) { for (int index2 = 0; index2 < (int)this.ActiveModule.XSIZE; ++index2) { foreach (SlotStruct slotStruct in this.Slots) { //checks if this slot is within xsize and ysize if (slotStruct.pq.Y == slot.pq.Y + 16 * index1 && slotStruct.pq.X == slot.pq.X + 16 * index2) { if(slotStruct.module == null && slotStruct.parent == null){ //make sure they are actually empty! ++num; } } } } } if (num == (int)this.ActiveModule.XSIZE * (int)this.ActiveModule.YSIZE) { //set module to this slot this.ClearSlotNoStack(slot); this.ClearDestinationSlotsNoStack(slot); slot.ModuleUID = this.ActiveModule.UID; slot.module = this.ActiveModule; slot.module.SetAttributesNoParent(); slot.state = this.ActiveModState; slot.module.hangarShipUID = this.ActiveModule.hangarShipUID; slot.module.facing = this.ActiveModule.facing; slot.tex = ResourceManager.TextureDict[ResourceManager.ShipModulesDict[this.ActiveModule.UID].IconTexturePath]; //set other slots occupied by the module to use this slot as parent for (int index1 = 0; index1 < (int)this.ActiveModule.YSIZE; ++index1) { for (int index2 = 0; index2 < (int)this.ActiveModule.XSIZE; ++index2) { if (!(index2 == 0 && index1 == 0)) //if not the parent slot { foreach (SlotStruct slotStruct in this.Slots) { if (slotStruct.pq.Y == slot.pq.Y + 16 * index1 && slotStruct.pq.X == slot.pq.X + 16 * index2) { slot.facing = 0.0f; slotStruct.facing = 0.0f; slotStruct.ModuleUID = (string)null; slotStruct.isDummy = true; slotStruct.tex = (Texture2D)null; slotStruct.module = (ShipModule)null; slotStruct.parent = slot; } } } } } this.RecalculatePower(); this.ShipSaved = false; if (this.ActiveModule.ModuleType != ShipModuleType.Hangar) { this.ActiveModule = Ship_Game.ResourceManager.GetModule(this.ActiveModule.UID); } //grabs a fresh copy of the same module type to cursor this.ChangeModuleState(this.ActiveModState); //set rotation for new module at cursor } else this.PlayNegativeSound(); }
private void InstallModuleOrig(SlotStruct slot) { int num = 0; for (int index1 = 0; index1 < (int)this.ActiveModule.YSIZE; ++index1) { for (int index2 = 0; index2 < (int)this.ActiveModule.XSIZE; ++index2) { foreach (SlotStruct slotStruct in this.Slots) { if (slotStruct.pq.Y == slot.pq.Y + 16 * index1 && slotStruct.pq.X == slot.pq.X + 16 * index2 && slotStruct.ShowValid) { if (slotStruct.module == null && slotStruct.parent == null) { //make sure they are actually empty! ++num; } } } } } if (num == (int)this.ActiveModule.XSIZE * (int)this.ActiveModule.YSIZE) { DesignAction designAction = new DesignAction(); designAction.clickedSS = new SlotStruct(); designAction.clickedSS.pq = slot.pq; designAction.clickedSS.Restrictions = slot.Restrictions; designAction.clickedSS.facing = slot.module != null ? slot.module.facing : 0.0f; designAction.clickedSS.ModuleUID = slot.ModuleUID; designAction.clickedSS.module = slot.module; designAction.clickedSS.tex = slot.tex; designAction.clickedSS.slotReference = slot.slotReference; designAction.clickedSS.state = slot.state; this.DesignStack.Push(designAction); this.ClearSlot(slot); this.ClearDestinationSlots(slot); slot.ModuleUID = this.ActiveModule.UID; slot.module = this.ActiveModule; slot.module.SetAttributesNoParent(); slot.state = this.ActiveModState; slot.module.facing = this.ActiveModule.facing; slot.tex = ResourceManager.TextureDict[ResourceManager.ShipModulesDict[this.ActiveModule.UID].IconTexturePath]; for (int index1 = 0; index1 < (int)this.ActiveModule.YSIZE; ++index1) { for (int index2 = 0; index2 < (int)this.ActiveModule.XSIZE; ++index2) { if (!(index2 == 0 & index1 == 0)) { foreach (SlotStruct slotStruct in this.Slots) { if (slotStruct.pq.Y == slot.pq.Y + 16 * index1 && slotStruct.pq.X == slot.pq.X + 16 * index2) { slot.facing = 0.0f; slotStruct.facing = 0.0f; slotStruct.ModuleUID = (string)null; slotStruct.isDummy = true; slotStruct.tex = (Texture2D)null; slotStruct.module = (ShipModule)null; slotStruct.parent = slot; } } } } } this.RecalculatePower(); this.ShipSaved = false; if (this.ActiveModule.ModuleType != ShipModuleType.Hangar) { this.ActiveModule = Ship_Game.ResourceManager.GetModule(this.ActiveModule.UID); } this.ChangeModuleState(this.ActiveModState); } else this.PlayNegativeSound(); }
private string GetConduitGraphic(SlotStruct ss) { bool right = false; bool left = false; bool up = false; bool down = false; int numNear = 0; foreach (SlotStruct slot in this.Slots) { if (slot.module == null || slot.module.ModuleType != ShipModuleType.PowerConduit || slot == ss) { continue; } int totalDistanceX = Math.Abs(slot.pq.X - ss.pq.X) / 16; int totalDistanceY = Math.Abs(slot.pq.Y - ss.pq.Y) / 16; if (totalDistanceX == 1 && totalDistanceY == 0) { if (slot.pq.X <= ss.pq.X) { right = true; } else { left = true; } } if (totalDistanceY != 1 || totalDistanceX != 0) { continue; } if (slot.pq.Y <= ss.pq.Y) { down = true; } else { up = true; } } if (left) { numNear++; } if (right) { numNear++; } if (up) { numNear++; } if (down) { numNear++; } if (numNear <= 1) { if (up) { return "conduit_powerpoint_up"; } if (down) { return "conduit_powerpoint_down"; } if (left) { return "conduit_powerpoint_left"; } if (right) { return "conduit_powerpoint_right"; } return "conduit_intersection"; } if (numNear != 3) { if (numNear == 4) { return "conduit_intersection"; } if (numNear == 2) { if (left && up) { return "conduit_corner_TL"; } if (left && down) { return "conduit_corner_BL"; } if (right && up) { return "conduit_corner_TR"; } if (right && down) { return "conduit_corner_BR"; } if (up && down) { return "conduit_straight_vertical"; } if (left && right) { return "conduit_straight_horizontal"; } } } else { if (up && down && left) { return "conduit_tsection_right"; } if (up && down && right) { return "conduit_tsection_left"; } if (left && right && down) { return "conduit_tsection_up"; } if (left && right && up) { return "conduit_tsection_down"; } } return ""; }
private void InstallModuleFromLoad(SlotStruct slot) { int num = 0; for (int index1 = 0; index1 < (int)this.ActiveModule.YSIZE; ++index1) { for (int index2 = 0; index2 < (int)this.ActiveModule.XSIZE; ++index2) { foreach (SlotStruct slotStruct in this.Slots) { if (slotStruct.pq.Y == slot.pq.Y + 16 * index1 && slotStruct.pq.X == slot.pq.X + 16 * index2) ++num; } } } if (num == (int)this.ActiveModule.XSIZE * (int)this.ActiveModule.YSIZE) { ShipDesignScreen.ActiveModuleState activeModuleState = slot.state; this.ClearSlot(slot); this.ClearDestinationSlotsNoStack(slot); slot.ModuleUID = this.ActiveModule.UID; slot.module = this.ActiveModule; slot.module.SetAttributesNoParent(); slot.state = activeModuleState; //slot.module.hangarShipUID = this.ActiveModule.hangarShipUID; slot.module.facing = slot.facing; slot.tex = ResourceManager.TextureDict[ResourceManager.ShipModulesDict[this.ActiveModule.UID].IconTexturePath]; for (int index1 = 0; index1 < (int)this.ActiveModule.YSIZE; ++index1) { for (int index2 = 0; index2 < (int)this.ActiveModule.XSIZE; ++index2) { if (!(index2 == 0 & index1 == 0)) { foreach (SlotStruct slotStruct in this.Slots) { if (slotStruct.pq.Y == slot.pq.Y + 16 * index1 && slotStruct.pq.X == slot.pq.X + 16 * index2) { slotStruct.ModuleUID = (string)null; slotStruct.isDummy = true; slotStruct.tex = (Texture2D)null; slotStruct.module = (ShipModule)null; slotStruct.parent = slot; } } } } } this.RecalculatePower(); } else this.PlayNegativeSound(); }
private void ClearSlot(SlotStruct slot) { //this is the clearslot function actually used atm //only called from installmodule atm, not from manual module removal if (slot.isDummy) { System.Diagnostics.Debug.Assert(slot.module == null); if (slot.parent.module != null) { this.ClearParentSlot(slot.parent); } } else if (slot.module != null) { this.ClearParentSlot(slot); } else { //this requires not being a child slot and not containing a module //only empty parent slots can trigger this //why would we want to clear an empty slot? //might be used on initial load instead of a proper slot constructor slot.ModuleUID = (string)null; slot.isDummy = false; slot.tex = (Texture2D)null; slot.parent = (SlotStruct)null; slot.module = (ShipModule)null; slot.state = ShipDesignScreen.ActiveModuleState.Normal; } }
private void ClearSlotNoStack(SlotStruct slot) { //this function might never be called, see if anyone triggers this //System.Diagnostics.Debug.Assert(false); Appears to part of teh ctrl-Z functionality if (slot.isDummy) { if (slot.parent.module == null) return; this.ClearParentSlotNoStack(slot.parent); } else if (slot.module != null) { this.ClearParentSlotNoStack(slot); } else { slot.ModuleUID = (string)null; slot.isDummy = false; slot.tex = (Texture2D)null; slot.parent = (SlotStruct)null; slot.module = (ShipModule)null; slot.state = ShipDesignScreen.ActiveModuleState.Normal; } }
private void ClearParentSlot(SlotStruct parentSlotStruct) { //actually supposed to clear ALL slots of a module, not just the parent SlotStruct slotStruct1 = new SlotStruct(); slotStruct1.pq = parentSlotStruct.pq; slotStruct1.Restrictions = parentSlotStruct.Restrictions; slotStruct1.facing = parentSlotStruct.facing; slotStruct1.ModuleUID = parentSlotStruct.ModuleUID; slotStruct1.module = parentSlotStruct.module; slotStruct1.state = parentSlotStruct.state; slotStruct1.slotReference = parentSlotStruct.slotReference; if (this.DesignStack.Count > 0) this.DesignStack.Peek().AlteredSlots.Add(slotStruct1); //clear up child slots for (int index1 = 0; index1 < (int)parentSlotStruct.module.YSIZE; ++index1) { for (int index2 = 0; index2 < (int)parentSlotStruct.module.XSIZE; ++index2) { if (!(index2 == 0 & index1 == 0)) { foreach (SlotStruct slotStruct2 in this.Slots) { if (slotStruct2.pq.Y == parentSlotStruct.pq.Y + 16 * index1 && slotStruct2.pq.X == parentSlotStruct.pq.X + 16 * index2) { slotStruct2.ModuleUID = (string)null; slotStruct2.isDummy = false; slotStruct2.tex = (Texture2D)null; slotStruct2.module = (ShipModule)null; slotStruct2.parent = (SlotStruct)null; slotStruct2.state = ShipDesignScreen.ActiveModuleState.Normal; } } } } } //clear parent slot parentSlotStruct.ModuleUID = (string)null; parentSlotStruct.isDummy = false; parentSlotStruct.tex = (Texture2D)null; parentSlotStruct.module = (ShipModule)null; parentSlotStruct.parent = null; parentSlotStruct.state = ShipDesignScreen.ActiveModuleState.Normal; }
private void ClearParentSlotNoStack(SlotStruct parent) { for (int index1 = 0; index1 < (int)parent.module.YSIZE; ++index1) { for (int index2 = 0; index2 < (int)parent.module.XSIZE; ++index2) { if (!(index2 == 0 & index1 == 0)) { foreach (SlotStruct slotStruct in this.Slots) { if (slotStruct.pq.Y == parent.pq.Y + 16 * index1 && slotStruct.pq.X == parent.pq.X + 16 * index2) { slotStruct.ModuleUID = (string)null; slotStruct.isDummy = false; slotStruct.tex = (Texture2D)null; slotStruct.module = (ShipModule)null; slotStruct.parent = (SlotStruct)null; slotStruct.state = ShipDesignScreen.ActiveModuleState.Normal; } } } } } parent.ModuleUID = (string)null; parent.isDummy = false; parent.tex = (Texture2D)null; parent.module = (ShipModule)null; parent.state = ShipDesignScreen.ActiveModuleState.Normal; }
private void ClearDestinationSlotsNoStack(SlotStruct slot) { for (int y = 0; y < this.ActiveModule.YSIZE; y++) { for (int x = 0; x < this.ActiveModule.XSIZE; x++) { //added by gremlin Changed to not like the other methods are. if (!(x == 0 & y == 0)) { foreach (SlotStruct dummyslot in this.Slots) { if (dummyslot.pq.Y != slot.pq.Y + 16 * y || dummyslot.pq.X != slot.pq.X + 16 * x) { continue; } if (dummyslot.module != null) { this.ClearParentSlot(dummyslot); } if (dummyslot.isDummy && dummyslot.parent != null && dummyslot.parent.module != null) { this.ClearParentSlotNoStack(dummyslot.parent); } dummyslot.ModuleUID = null; dummyslot.isDummy = false; dummyslot.tex = null; dummyslot.module = null; dummyslot.parent = slot; dummyslot.state = ShipDesignScreen.ActiveModuleState.Normal; } } } } }
private void ClearDestinationSlots(SlotStruct slot) { for (int y = 0; y < this.ActiveModule.YSIZE; y++) { for (int x = 0; x < this.ActiveModule.XSIZE; x++) { //added by gremlin changed to not like the other modules clear methods are. if (!(x == 0 & y == 0)) { foreach (SlotStruct dummyslot in this.Slots) { if (dummyslot.pq.Y != slot.pq.Y + 16 * y || dummyslot.pq.X != slot.pq.X + 16 * x) { continue; } if (dummyslot.module != null) { SlotStruct copy = new SlotStruct() { pq = dummyslot.pq, Restrictions = dummyslot.Restrictions, facing = dummyslot.facing, ModuleUID = dummyslot.ModuleUID, module = dummyslot.module, state = dummyslot.state, slotReference = dummyslot.slotReference }; if (this.DesignStack.Count > 0) { this.DesignStack.Peek().AlteredSlots.Add(copy); } this.ClearParentSlot(dummyslot); } if (dummyslot.isDummy && dummyslot.parent != null && dummyslot.parent.module != null) { this.ClearParentSlot(dummyslot.parent); } dummyslot.ModuleUID = null; dummyslot.isDummy = false; dummyslot.tex = null; dummyslot.module = null; dummyslot.state = ShipDesignScreen.ActiveModuleState.Normal; dummyslot.parent = slot; } } } } }
private void CheckAndPowerConduit(SlotStruct slot) { slot.module.Powered = true; slot.CheckedConduits = true; foreach (SlotStruct ss in this.Slots) { if (ss == slot || Math.Abs(slot.pq.X - ss.pq.X) / 16 + Math.Abs(slot.pq.Y - ss.pq.Y) / 16 != 1 || ss.module == null || ss.module.ModuleType != ShipModuleType.PowerConduit || ss.CheckedConduits) { continue; } this.CheckAndPowerConduit(ss); } }
public override void HandleInput(InputState input) { this.CategoryList.HandleInput(input); this.CarrierOnlyBox.HandleInput(input); if (this.ActiveModule != null && (this.ActiveModule.InstalledWeapon != null && this.ActiveModule.ModuleType != ShipModuleType.Turret || this.ActiveModule.XSIZE != this.ActiveModule.YSIZE)) { if (input.Left) this.ChangeModuleState(ShipDesignScreen.ActiveModuleState.Left); if (input.Right) this.ChangeModuleState(ShipDesignScreen.ActiveModuleState.Right); if (input.Down) this.ChangeModuleState(ShipDesignScreen.ActiveModuleState.Rear); if (input.Up) this.ChangeModuleState(ShipDesignScreen.ActiveModuleState.Normal); } if (input.CurrentKeyboardState.IsKeyDown(Keys.Y) && !input.LastKeyboardState.IsKeyDown(Keys.Y) && !GlobalStats.TakingInput) { AudioManager.PlayCue("echo_affirm"); this.ExitScreen(); } if (this.close.HandleInput(input)) this.ExitScreen(); else if (input.CurrentKeyboardState.IsKeyDown(Keys.Z) && input.LastKeyboardState.IsKeyUp(Keys.Z) && input.CurrentKeyboardState.IsKeyDown(Keys.LeftControl)) { if (this.DesignStack.Count <= 0) return; ShipModule shipModule = this.ActiveModule; DesignAction designAction = this.DesignStack.Pop(); SlotStruct slot1 = new SlotStruct(); foreach (SlotStruct slot2 in this.Slots) { if (slot2.pq == designAction.clickedSS.pq) { this.ClearSlotNoStack(slot2); slot1 = slot2; slot1.facing = designAction.clickedSS.facing; } foreach (SlotStruct slotStruct in designAction.AlteredSlots) { if (slot2.pq == slotStruct.pq) { this.ClearSlotNoStack(slot2); break; } } } if (designAction.clickedSS.ModuleUID != null) { this.ActiveModule = ResourceManager.GetModule(designAction.clickedSS.ModuleUID); this.ResetModuleState(); this.InstallModuleNoStack(slot1); } foreach (SlotStruct slotStruct in designAction.AlteredSlots) { foreach (SlotStruct slot2 in this.Slots) { if (slot2.pq == slotStruct.pq && slotStruct.ModuleUID != null) { this.ActiveModule = ResourceManager.GetModule(slotStruct.ModuleUID); this.ResetModuleState(); this.InstallModuleNoStack(slot2); slot2.facing = slotStruct.facing; slot2.ModuleUID = slotStruct.ModuleUID; } } } this.ActiveModule = shipModule; this.ResetModuleState(); } else { if (!HelperFunctions.CheckIntersection(this.ModuleSelectionMenu.Menu, input.CursorPosition) && !HelperFunctions.CheckIntersection(this.HullSelectionRect, input.CursorPosition) && !HelperFunctions.CheckIntersection(this.ChooseFighterSub.Menu, input.CursorPosition)) { if (input.ScrollOut) { this.TransitionZoom -= 0.1f; if ((double)this.TransitionZoom < 0.300000011920929) this.TransitionZoom = 0.3f; if ((double)this.TransitionZoom > 2.65000009536743) this.TransitionZoom = 2.65f; } if (input.ScrollIn) { this.TransitionZoom += 0.1f; if ((double)this.TransitionZoom < 0.300000011920929) this.TransitionZoom = 0.3f; if ((double)this.TransitionZoom > 2.65000009536743) this.TransitionZoom = 2.65f; } } if (input.CurrentKeyboardState.IsKeyDown(Keys.OemTilde)) input.LastKeyboardState.IsKeyUp(Keys.OemTilde); if (this.Debug) { if (input.CurrentKeyboardState.IsKeyDown(Keys.Enter) && input.LastKeyboardState.IsKeyUp(Keys.Enter)) { foreach (ModuleSlotData moduleSlotData in this.ActiveHull.ModuleSlotList) moduleSlotData.InstalledModuleUID = (string)null; new XmlSerializer(typeof(ShipData)).Serialize((TextWriter)new StreamWriter("Content/Hulls/" + this.ActiveHull.ShipStyle + "/" + this.ActiveHull.Name + ".xml"), (object)this.ActiveHull); } if (input.Right) ++this.operation; if (this.operation > (ShipDesignScreen.SlotModOperation)6) this.operation = ShipDesignScreen.SlotModOperation.Delete; } this.HoveredModule = (ShipModule)null; this.mouseStateCurrent = Mouse.GetState(); Vector2 vector2 = new Vector2((float)this.mouseStateCurrent.X, (float)this.mouseStateCurrent.Y); this.selector = (Selector)null; this.EmpireUI.HandleInput(input, (GameScreen)this); this.activeModSubMenu.HandleInputNoReset((object)this); this.hullSL.HandleInput(input); for (int index = this.hullSL.indexAtTop; index < this.hullSL.Copied.Count && index < this.hullSL.indexAtTop + this.hullSL.entriesToDisplay; ++index) { ScrollList.Entry e = this.hullSL.Copied[index]; if (e.item is ModuleHeader) { if ((e.item as ModuleHeader).HandleInput(input, e)) return; } else if (HelperFunctions.CheckIntersection(e.clickRect, vector2)) { this.selector = new Selector(this.ScreenManager, e.clickRect); e.clickRectHover = 1; this.selector = new Selector(this.ScreenManager, e.clickRect); if (input.InGameSelect) { AudioManager.PlayCue("sd_ui_accept_alt3"); if (!this.ShipSaved && !this.CheckDesign()) { MessageBoxScreen messageBoxScreen = new MessageBoxScreen(Localizer.Token(2121), "Save", "No"); messageBoxScreen.Accepted += new EventHandler<EventArgs>(this.SaveWIPThenChangeHull); messageBoxScreen.Cancelled += new EventHandler<EventArgs>(this.JustChangeHull); this.changeto = e.item as ShipData; this.ScreenManager.AddScreen((GameScreen)messageBoxScreen); return; } else { this.ChangeHull(e.item as ShipData); return; } } } else e.clickRectHover = 0; } this.modSel.HandleInput((object)this); if (this.ActiveModule != null) { if (this.ActiveModule.ModuleType == ShipModuleType.Hangar && !this.ActiveModule.IsTroopBay && !this.ActiveModule.IsSupplyBay) { this.UpdateHangarOptions(this.ActiveModule); this.ChooseFighterSL.HandleInput(input); for (int index = this.ChooseFighterSL.indexAtTop; index < this.ChooseFighterSL.Copied.Count && index < this.ChooseFighterSL.indexAtTop + this.ChooseFighterSL.entriesToDisplay; ++index) { ScrollList.Entry entry = this.ChooseFighterSL.Copied[index]; if (HelperFunctions.CheckIntersection(entry.clickRect, vector2)) { this.selector = new Selector(this.ScreenManager, entry.clickRect); entry.clickRectHover = 1; this.selector = new Selector(this.ScreenManager, entry.clickRect); if (input.InGameSelect) { this.ActiveModule.hangarShipUID = (entry.item as Ship).Name; this.HangarShipUIDLast = (entry.item as Ship).Name; AudioManager.PlayCue("sd_ui_accept_alt3"); return; } } } } } else if (this.HighlightedModule != null && this.HighlightedModule.ModuleType == ShipModuleType.Hangar && (!this.HighlightedModule.IsTroopBay && !this.HighlightedModule.IsSupplyBay)) { this.ChooseFighterSL.HandleInput(input); for (int index = this.ChooseFighterSL.indexAtTop; index < this.ChooseFighterSL.Copied.Count && index < this.ChooseFighterSL.indexAtTop + this.ChooseFighterSL.entriesToDisplay; ++index) { ScrollList.Entry entry = this.ChooseFighterSL.Copied[index]; if (HelperFunctions.CheckIntersection(entry.clickRect, vector2)) { this.selector = new Selector(this.ScreenManager, entry.clickRect); entry.clickRectHover = 1; this.selector = new Selector(this.ScreenManager, entry.clickRect); if (input.InGameSelect) { this.HighlightedModule.hangarShipUID = (entry.item as Ship).Name; this.HangarShipUIDLast = (entry.item as Ship).Name; AudioManager.PlayCue("sd_ui_accept_alt3"); return; } } } } for (int index = this.weaponSL.indexAtTop; index < this.weaponSL.Copied.Count && index < this.weaponSL.indexAtTop + this.weaponSL.entriesToDisplay; ++index) { ScrollList.Entry e = this.weaponSL.Copied[index]; if (e.item is ModuleHeader) { if ((e.item as ModuleHeader).HandleInput(input, e)) return; } else if (HelperFunctions.CheckIntersection(e.clickRect, vector2)) { this.selector = new Selector(this.ScreenManager, e.clickRect); e.clickRectHover = 1; this.selector = new Selector(this.ScreenManager, e.clickRect); if (input.InGameSelect) { this.SetActiveModule(ResourceManager.GetModule((e.item as ShipModule).UID)); this.ResetModuleState(); return; } } else e.clickRectHover = 0; } this.weaponSL.HandleInput(input); if (HelperFunctions.CheckIntersection(this.HullSelectionRect, input.CursorPosition) && input.CurrentMouseState.LeftButton == ButtonState.Pressed || HelperFunctions.CheckIntersection(this.modSel.Menu, input.CursorPosition) && input.CurrentMouseState.LeftButton == ButtonState.Pressed || HelperFunctions.CheckIntersection(this.activeModSubMenu.Menu, input.CursorPosition) && input.CurrentMouseState.LeftButton == ButtonState.Pressed) return; if (HelperFunctions.CheckIntersection(this.modSel.Menu, vector2)) { if (this.mouseStateCurrent.ScrollWheelValue > this.mouseStatePrevious.ScrollWheelValue && this.weaponSL.indexAtTop > 0) --this.weaponSL.indexAtTop; if (this.mouseStateCurrent.ScrollWheelValue < this.mouseStatePrevious.ScrollWheelValue && this.weaponSL.indexAtTop + this.weaponSL.entriesToDisplay < this.weaponSL.Entries.Count) ++this.weaponSL.indexAtTop; } if (HelperFunctions.CheckIntersection(this.ArcsButton.R, input.CursorPosition)) ToolTip.CreateTooltip(134, this.ScreenManager); if (this.ArcsButton.HandleInput(input)) { this.ArcsButton.ToggleOn = !this.ArcsButton.ToggleOn; this.ShowAllArcs = this.ArcsButton.ToggleOn; } if (input.Tab) { this.ShowAllArcs = !this.ShowAllArcs; this.ArcsButton.ToggleOn = this.ShowAllArcs; } if (input.CurrentMouseState.RightButton == ButtonState.Pressed && input.LastMouseState.RightButton == ButtonState.Released) { this.StartDragPos = input.CursorPosition; this.cameraVelocity.X = 0.0f; this.cameraVelocity.Y = 0.0f; } if (input.CurrentMouseState.RightButton == ButtonState.Pressed && input.LastMouseState.RightButton == ButtonState.Pressed) { float num1 = input.CursorPosition.X - this.StartDragPos.X; float num2 = input.CursorPosition.Y - this.StartDragPos.Y; this.camera._pos += new Vector2(-num1, -num2); this.StartDragPos = input.CursorPosition; this.cameraPosition.X += -num1; this.cameraPosition.Y += -num2; } else { this.cameraVelocity.X = 0.0f; this.cameraVelocity.Y = 0.0f; } this.cameraVelocity.X = MathHelper.Clamp(this.cameraVelocity.X, -10f, 10f); this.cameraVelocity.Y = MathHelper.Clamp(this.cameraVelocity.Y, -10f, 10f); if (input.Escaped) this.ExitScreen(); if (this.ToggleOverlay) { foreach (SlotStruct slotStruct in this.Slots) { Vector2 spaceFromWorldSpace = this.camera.GetScreenSpaceFromWorldSpace(new Vector2((float)slotStruct.pq.enclosingRect.X, (float)slotStruct.pq.enclosingRect.Y)); if (HelperFunctions.CheckIntersection(new Rectangle((int)spaceFromWorldSpace.X, (int)spaceFromWorldSpace.Y, (int)(16.0 * (double)this.camera.Zoom), (int)(16.0 * (double)this.camera.Zoom)), vector2)) { if (slotStruct.isDummy && slotStruct.parent.module != null) this.HoveredModule = slotStruct.parent.module; else if (slotStruct.module != null) this.HoveredModule = slotStruct.module; if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released) { AudioManager.GetCue("simple_beep").Play(); if (this.Debug) { this.DebugAlterSlot(slotStruct.slotReference.Position, this.operation); return; } else if (slotStruct.isDummy && slotStruct.parent.module != null) this.HighlightedModule = slotStruct.parent.module; else if (slotStruct.module != null) this.HighlightedModule = slotStruct.module; } } } } if (HelperFunctions.CheckIntersection(this.upArrow, vector2) && this.mouseStateCurrent.LeftButton == ButtonState.Released && (this.mouseStatePrevious.LeftButton == ButtonState.Pressed && this.scrollPosition > 0)) { --this.scrollPosition; AudioManager.GetCue("blip_click").Play(); foreach (ModuleButton moduleButton in this.ModuleButtons) moduleButton.moduleRect.Y += 128; } if (HelperFunctions.CheckIntersection(this.downArrow, vector2) && this.mouseStateCurrent.LeftButton == ButtonState.Released && this.mouseStatePrevious.LeftButton == ButtonState.Pressed) { ++this.scrollPosition; AudioManager.GetCue("blip_click").Play(); foreach (ModuleButton moduleButton in this.ModuleButtons) moduleButton.moduleRect.Y -= 128; } if (HelperFunctions.CheckIntersection(this.ModuleSelectionArea, vector2)) { if (input.ScrollIn && this.scrollPosition > 0) { --this.scrollPosition; AudioManager.GetCue("blip_click").Play(); foreach (ModuleButton moduleButton in this.ModuleButtons) moduleButton.moduleRect.Y += 128; } if (input.ScrollOut) { ++this.scrollPosition; AudioManager.GetCue("blip_click").Play(); foreach (ModuleButton moduleButton in this.ModuleButtons) moduleButton.moduleRect.Y -= 128; } } if (this.mouseStateCurrent.RightButton == ButtonState.Released && this.mouseStatePrevious.RightButton == ButtonState.Pressed) { //this should actually clear slots this.ActiveModule = (ShipModule)null; foreach (SlotStruct parent in this.Slots) { parent.ShowInvalid = false; parent.ShowValid = false; Vector2 spaceFromWorldSpace = this.camera.GetScreenSpaceFromWorldSpace(new Vector2((float)parent.pq.enclosingRect.X, (float)parent.pq.enclosingRect.Y)); Rectangle rect = new Rectangle((int)spaceFromWorldSpace.X, (int)spaceFromWorldSpace.Y, (int)(16.0 * (double)this.camera.Zoom), (int)(16.0 * (double)this.camera.Zoom)); if ((parent.module != null || parent.isDummy) && HelperFunctions.CheckIntersection(rect, vector2)) //if clicked at this slot { DesignAction designAction = new DesignAction(); designAction.clickedSS = new SlotStruct(); designAction.clickedSS.pq = parent.isDummy ? parent.parent.pq : parent.pq; designAction.clickedSS.Restrictions = parent.Restrictions; designAction.clickedSS.facing = parent.module != null ? parent.module.facing : 0.0f; designAction.clickedSS.ModuleUID = parent.isDummy ? parent.parent.ModuleUID : parent.ModuleUID; designAction.clickedSS.module = parent.module; designAction.clickedSS.slotReference = parent.isDummy ? parent.parent.slotReference : parent.slotReference; this.DesignStack.Push(designAction); AudioManager.GetCue("sub_bass_whoosh").Play(); if (parent.isDummy) this.ClearParentSlot(parent.parent); else this.ClearParentSlot(parent); this.RecalculatePower(); } } } foreach (ModuleButton moduleButton in this.ModuleButtons) { if (HelperFunctions.CheckIntersection(this.ModuleSelectionArea, new Vector2((float)(moduleButton.moduleRect.X + 30), (float)(moduleButton.moduleRect.Y + 30)))) { if (HelperFunctions.CheckIntersection(moduleButton.moduleRect, vector2)) { if (input.InGameSelect) this.SetActiveModule(ResourceManager.GetModule(moduleButton.ModuleUID)); moduleButton.isHighlighted = true; } else moduleButton.isHighlighted = false; } } if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && this.ActiveModule != null) { foreach (SlotStruct slot in this.Slots) { Vector2 spaceFromWorldSpace = this.camera.GetScreenSpaceFromWorldSpace(new Vector2((float)slot.pq.enclosingRect.X, (float)slot.pq.enclosingRect.Y)); if (HelperFunctions.CheckIntersection(new Rectangle((int)spaceFromWorldSpace.X, (int)spaceFromWorldSpace.Y, (int)(16.0 * (double)this.camera.Zoom), (int)(16.0 * (double)this.camera.Zoom)), vector2)) { AudioManager.GetCue("sub_bass_mouseover").Play(); this.InstallModule(slot); } } } else if (this.mouseStateCurrent.LeftButton == ButtonState.Pressed && this.mouseStatePrevious.LeftButton == ButtonState.Pressed) this.HoldTimer -= .01666f; else this.HoldTimer = 0.50f; foreach (SlotStruct slotStruct in this.Slots) { if (slotStruct.ModuleUID != null && this.HighlightedModule != null && (slotStruct.module == this.HighlightedModule && (double)slotStruct.module.FieldOfFire != 0.0) && slotStruct.module.ModuleType == ShipModuleType.Turret) { float num1 = slotStruct.module.FieldOfFire / 2f; Vector2 spaceFromWorldSpace = this.camera.GetScreenSpaceFromWorldSpace(new Vector2((float)(slotStruct.pq.enclosingRect.X + 16 * (int)slotStruct.module.XSIZE / 2), (float)(slotStruct.pq.enclosingRect.Y + 16 * (int)slotStruct.module.YSIZE / 2))); float num2 = Math.Abs(this.findAngleToTarget(spaceFromWorldSpace, vector2)); float num3 = this.HighlightedModule.facing; float num4 = Math.Abs(num2 - num3); if ((double)num4 > (double)num1) { if ((double)num2 > 180.0) num2 = (float)(-1.0 * (360.0 - (double)num2)); if ((double)num3 > 180.0) num3 = (float)(-1.0 * (360.0 - (double)num3)); num4 = Math.Abs(num2 - num3); } if (GlobalStats.AltArcControl) { //The Doctor: ALT (either) + LEFT CLICK to pick and move arcs. This way, it's impossible to accidentally pick the wrong arc, while it's just as responsive and smooth as the original method when you are trying to. if ((double)num4 < (double)num1 && (this.mouseStateCurrent.LeftButton == ButtonState.Pressed && this.mouseStatePrevious.LeftButton == ButtonState.Pressed && ((input.CurrentKeyboardState.IsKeyDown(Keys.LeftAlt) || input.LastKeyboardState.IsKeyDown(Keys.LeftAlt)) || (input.CurrentKeyboardState.IsKeyDown(Keys.RightAlt) || input.LastKeyboardState.IsKeyDown(Keys.RightAlt))))) { this.HighlightedModule.facing = Math.Abs(this.findAngleToTarget(spaceFromWorldSpace, vector2)); } } else { //Delay method if ((double)num4 < (double)num1 && (this.mouseStateCurrent.LeftButton == ButtonState.Pressed && this.mouseStatePrevious.LeftButton == ButtonState.Pressed && this.HoldTimer < 0)) { this.HighlightedModule.facing = Math.Abs(this.findAngleToTarget(spaceFromWorldSpace, vector2)); } } } } foreach (UIButton uiButton in this.Buttons) { if (HelperFunctions.CheckIntersection(uiButton.Rect, vector2)) { uiButton.State = UIButton.PressState.Hover; if (this.mouseStateCurrent.LeftButton == ButtonState.Pressed && this.mouseStatePrevious.LeftButton == ButtonState.Pressed) uiButton.State = UIButton.PressState.Pressed; if (this.mouseStateCurrent.LeftButton == ButtonState.Released && this.mouseStatePrevious.LeftButton == ButtonState.Pressed) { switch (uiButton.Launches) { case "Toggle Overlay": AudioManager.PlayCue("blip_click"); this.ToggleOverlay = !this.ToggleOverlay; continue; case "Save As...": if (this.CheckDesign()) { this.ScreenManager.AddScreen((GameScreen)new DesignManager(this, this.ActiveHull.Name)); continue; } else { AudioManager.PlayCue("UI_Misc20"); this.ScreenManager.AddScreen((GameScreen)new MessageBoxScreen(Localizer.Token(2049))); continue; } case "Load": this.ScreenManager.AddScreen((GameScreen)new LoadDesigns(this)); continue; default: continue; } } } else uiButton.State = UIButton.PressState.Normal; } if (this.ActiveHull != null) { foreach (ToggleButton toggleButton in this.CombatStatusButtons) { if (HelperFunctions.CheckIntersection(toggleButton.r, input.CursorPosition)) { if (toggleButton.HasToolTip) ToolTip.CreateTooltip(toggleButton.WhichToolTip, this.ScreenManager); if (input.InGameSelect) { AudioManager.PlayCue("sd_ui_accept_alt3"); switch (toggleButton.Action) { case "attack": this.CombatState = CombatState.AttackRuns; break; case "arty": this.CombatState = CombatState.Artillery; break; case "hold": this.CombatState = CombatState.HoldPosition; break; case "orbit_left": this.CombatState = CombatState.OrbitLeft; break; case "broadside_left": this.CombatState = CombatState.BroadsideLeft; break; case "orbit_right": this.CombatState = CombatState.OrbitRight; break; case "broadside_right": this.CombatState = CombatState.BroadsideRight; break; case "evade": this.CombatState = CombatState.Evade; break; } } } else toggleButton.Hover = false; switch (toggleButton.Action) { case "attack": toggleButton.Active = this.CombatState == CombatState.AttackRuns; continue; case "arty": toggleButton.Active = this.CombatState == CombatState.Artillery; continue; case "hold": toggleButton.Active = this.CombatState == CombatState.HoldPosition; continue; case "orbit_left": toggleButton.Active = this.CombatState == CombatState.OrbitLeft; continue; case "broadside_left": toggleButton.Active = this.CombatState == CombatState.BroadsideLeft; continue; case "orbit_right": toggleButton.Active = this.CombatState == CombatState.OrbitRight; continue; case "broadside_right": toggleButton.Active = this.CombatState == CombatState.BroadsideRight; continue; case "evade": toggleButton.Active = this.CombatState == CombatState.Evade; continue; default: continue; } } } this.mouseStatePrevious = this.mouseStateCurrent; base.HandleInput(input); } }
private void ConfigureSlots() { this.border = new PrimitiveQuad(this.aspect.X / 2f - 256f, this.aspect.Y / 2f - 256f, 512f, 512f); this.spriteBatch = new SpriteBatch(base.ScreenManager.GraphicsDevice); for (int x = -32; x < 32; x++) { for (int y = -32; y < 32; y++) { PrimitiveQuad newCell = new PrimitiveQuad((float)((int)this.Center.X + 16 * x), (float)((int)this.Center.Y + 16 * y), (float)this.slotsize, (float)this.slotsize); SlotStruct newslot = new SlotStruct() { pq = newCell, Restrictions = Restrictions.I }; this.SlotList.Add(newslot); } } }