public void UpdateSpawnPointInterior() { m_isUpdatingSpawnInterior = true; SafeHouse sf = (SafeHouse)TheEditor.GetGlobal(GlobalVariable.CurrentInterior); float indDistance = Vector3D.Distance(SpawnPoint, PortlandSpawnPoint); float comDistance = Vector3D.Distance(SpawnPoint, StauntonSpawnPoint); float subDistance = Vector3D.Distance(SpawnPoint, ShoresideSpawnPoint); if (sf == SafeHouse.Portland && indDistance < SpawnPointTolerance) { SpawnInterior = SafeHouse.Portland; } else if (sf == SafeHouse.Staunton && comDistance < SpawnPointTolerance) { SpawnInterior = SafeHouse.Staunton; } else if (sf == SafeHouse.Shoreside && subDistance < SpawnPointTolerance) { SpawnInterior = SafeHouse.Shoreside; } else { SpawnInterior = null; } m_isUpdatingSpawnInterior = false; }
public void SetSpawnPointInterior() { if (m_isUpdatingSpawnInterior) { return; } switch (SpawnInterior) { case SafeHouse.Portland: TheEditor.SetGlobal(GlobalVariable.CurrentInterior, (int)SafeHouse.Portland); SpawnPoint = PortlandSpawnPoint; SpawnHeading = 180; break; case SafeHouse.Staunton: TheEditor.SetGlobal(GlobalVariable.CurrentInterior, (int)SafeHouse.Staunton); SpawnPoint = StauntonSpawnPoint; SpawnHeading = 180; break; case SafeHouse.Shoreside: TheEditor.SetGlobal(GlobalVariable.CurrentInterior, (int)SafeHouse.Shoreside); SpawnPoint = ShoresideSpawnPoint; SpawnHeading = 180; break; } }
public void RevertFileRequest_Handler(object sender, FileIOEventArgs e) { if (IsDirty && !e.SuppressPrompting) { PromptConfirmRevert((r) => { if (r == MessageBoxResult.Yes) { ClearDirty(); RevertFile(); } }); return; } m_isRevertingFile = true; Log.Info("Reverting file..."); Tabs.Where(t => t.Visibility == TabPageVisibility.WhenFileIsOpen).ToList().ForEach(t => t.Unload()); TheEditor.CloseFile(); TheEditor.OpenFile(TheSettings.MostRecentFile); Tabs.Where(t => t.Visibility == TabPageVisibility.WhenFileIsOpen).ToList().ForEach(t => t.Load()); Tabs.Where(t => t.Visibility == TabPageVisibility.WhenFileIsOpen).ToList().ForEach(t => t.Update()); Log.Info("File reverted."); m_isRevertingFile = false; }
private void WriteSelectedWeapon() { if (!m_suppressWritingSelectedWeapon) { TheEditor.SetGlobal(GlobalVariable.PlayerWeapon, (int)(Weapon ?? Types.Weapon.Fists)); } }
public override void Load() { IsInitializing = true; base.Load(); m_suppressWritingSelectedWeapon = true; Weapon = (Weapon?)TheEditor.GetGlobal(GlobalVariable.PlayerWeapon); m_suppressWritingSelectedWeapon = false; Scripts.GlobalVariables.CollectionChanged += GlobalVariables_CollectionChanged; ReadSlot(0); ReadSlot(1); ReadSlot(2); ReadSlot(3); ReadSlot(4); ReadSlot(5); ReadSlot(6); ReadSlot(7); ReadSlot(8); ReadSlot(9); UpdateInventory(); UpdateOutfit(); UpdateSpawnPointMarker(); UpdateSpawnPointInterior(); OnPropertyChanged(nameof(Armor)); OnPropertyChanged(nameof(Money)); OnPropertyChanged(nameof(Weapon)); OnPropertyChanged(nameof(SpawnPoint)); OnPropertyChanged(nameof(SpawnHeading)); }
private void GlobalVariables_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { GlobalVariableInfo item = (ShowSavedOnly) ? Globals.Where(x => x.Index == e.NewStartingIndex).FirstOrDefault() : Globals[e.NewStartingIndex]; item.IntValue = TheEditor.GetGlobal(item.Index); item.FloatValue = TheEditor.GetGlobalAsFloat(item.Index); }
public void OpenSelectedItem() { CancelSearch(); if (SelectedFile != null) { TheEditor.OpenFile(SelectedFile.Path); } }
private void GlobalVariables_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (TheEditor.GetGlobalId(e.NewStartingIndex)) { case GlobalVariable.CameraModeOnFoot: OnPropertyChanged(nameof(OnFootCameraMode)); break; } }
public void UpdateIntValue() { if (SelectedItem != null) { int oldVal = TheEditor.GetGlobal(SelectedItem.Index); int newVal = SelectedItem.IntValue; if (oldVal != newVal) { TheEditor.SetGlobal(SelectedItem.Index, newVal); } } }
public void UpdateFloatValue() { if (SelectedItem != null) { float oldVal = TheEditor.GetGlobalAsFloat(SelectedItem.Index); float newVal = SelectedItem.FloatValue; if (oldVal != newVal) { TheEditor.SetGlobal(SelectedItem.Index, newVal); } } }
public int GetNumPackagesFound() { int packagesFound = 0; for (int i = 0; i < Collectibles.NumPackages; i++) { if (TheEditor.GetGlobal(GlobalVariable.Package1Collected + i) != 0) { packagesFound++; } } return(packagesFound); }
public int GetNumStuntJumpsFound() { int stuntJumpsFound = 0; for (int i = 0; i < Collectibles.NumStuntJumps; i++) { if (TheEditor.GetGlobal(GlobalVariable.Package1Collected + i) != 0) { stuntJumpsFound++; } } return(stuntJumpsFound); }
public void OpenFileRequest_Handler(object sender, FileIOEventArgs e) { if (TheEditor.IsFileOpen) { if (IsDirty && !e.SuppressPrompting) { PromptSaveChanges((r) => { if (r != MessageBoxResult.Cancel) { if (r == MessageBoxResult.Yes) { SaveFile(); } ClearDirty(); OpenFile(TheSettings.LastFileAccessed); } }); return; } CloseFile(); } try { TheEditor.OpenFile(e.Path); } catch (Exception ex) { Log.Exception(ex); if (ex is InvalidDataException) { ShowError("The file is not a valid GTA:LCS save file."); return; } ShowException(ex, "The file could not be opened."); #if !DEBUG return; #else throw; #endif } }
public void SaveFileRequest_Handler(object sender, FileIOEventArgs e) { try { TheEditor.SaveFile(e.Path); } catch (Exception ex) { Log.Exception(ex); ShowException(ex, "The file could not be saved."); SetTimedStatusText("Error saving file.", duration: 10); #if !DEBUG return; #else throw; #endif } }
private void PopulateAllVariables() { for (int i = 0, enumIndex = 0; i < TheEditor.GetNumGlobals(); i++, enumIndex++) { while (TheEditor.GetIndexOfGlobal((GlobalVariable)enumIndex) < i) { enumIndex++; } string name = Enum.GetName(typeof(GlobalVariable), enumIndex); Globals.Add(new GlobalVariableInfo() { Index = i, IntValue = TheEditor.GetGlobal(i), FloatValue = TheEditor.GetGlobalAsFloat(i), Name = name }); } }
private void PopulateSavedVariables() { foreach (GlobalVariable var in Enum.GetValues(typeof(GlobalVariable))) { int index = TheEditor.GetIndexOfGlobal(var); if (index == -1) { continue; } Globals.Add(new GlobalVariableInfo() { Index = index, IntValue = TheEditor.GetGlobal(var), FloatValue = TheEditor.GetGlobalAsFloat(var), Name = var.ToString() }); } }
private void GlobalVariables_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action != NotifyCollectionChangedAction.Replace) { return; } int packageMin = TheEditor.GetIndexOfGlobal(GlobalVariable.Package1Collected); int packageMax = TheEditor.GetIndexOfGlobal(GlobalVariable.Package100Collected); int rampageMin = TheEditor.GetIndexOfGlobal(GlobalVariable.Rampage1Passed); int rampageMax = TheEditor.GetIndexOfGlobal(GlobalVariable.Rampage20Passed); int stuntJumpMin = TheEditor.GetIndexOfGlobal(GlobalVariable.StuntJump1Completed); int stuntJumpMax = TheEditor.GetIndexOfGlobal(GlobalVariable.StuntJump26Completed); int index = e.NewStartingIndex; bool isCollected = ((int)e.NewItems[0]) != 0; CollectibleBlip blip = null; if (index >= packageMin && index <= packageMax) { blip = Blips.Where(x => x.Type == BlipType.Package && x.Index == (index - packageMin)).FirstOrDefault(); } if (index >= rampageMin && index <= rampageMax) { blip = Blips.Where(x => x.Type == BlipType.Rampage && x.Index == (index - rampageMin)).FirstOrDefault(); } if (index >= stuntJumpMin && index <= stuntJumpMax) { blip = Blips.Where(x => x.Type == BlipType.StuntJump && x.Index == (index - stuntJumpMin)).FirstOrDefault(); } if (blip != null) { blip.IsCollected = isCollected; if (!isCollected || (isCollected && IsShowingCollected)) { blip.IsEnabled = true; } } }
public void CloseFileRequest_Handler(object sender, FileIOEventArgs e) { if (IsDirty && !e.SuppressPrompting) { PromptSaveChanges((r) => { if (r != MessageBoxResult.Cancel) { if (r == MessageBoxResult.Yes) { SaveFile(); } ClearDirty(); CloseFile(); } }); return; } TheEditor.CloseFile(); }
public void PlotAll(BlipType type) { int stateArrayBase = -1; switch (type) { case BlipType.Package: stateArrayBase = (int)GlobalVariable.Package1Collected; break; case BlipType.Rampage: stateArrayBase = (int)GlobalVariable.Rampage1Passed; break; case BlipType.StuntJump: stateArrayBase = (int)GlobalVariable.StuntJump1Completed; break; } var b = Blips.Where(x => x.Type == type).ToArray(); for (int i = 0; i < b.Length; i++) { int state = TheEditor.GetGlobal(stateArrayBase + i); b[i].IsCollected = (state != 0); b[i].IsEnabled = true; } }
private void GlobalVariables_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { GlobalVariable g = TheEditor.GetGlobalId(e.NewStartingIndex); switch (g) { case GlobalVariable.PlayerX: case GlobalVariable.PlayerY: case GlobalVariable.PlayerZ: OnPropertyChanged(nameof(SpawnPoint)); break; case GlobalVariable.PlayerOutfit: OnPropertyChanged(nameof(Outfit)); break; case GlobalVariable.PlayerArmor: OnPropertyChanged(nameof(Armor)); break; case GlobalVariable.PlayerMoney: OnPropertyChanged(nameof(Money)); break; case GlobalVariable.PlayerWeapon: OnPropertyChanged(nameof(Weapon)); break; } if (m_isWritingWeaponSlot) { return; } switch (g) { case GlobalVariable.Weapon1Ammo: // Brass Knuckles ReadSlot(0); break; case GlobalVariable.Weapon2Ammo: // Melee case GlobalVariable.Weapon3Ammo: case GlobalVariable.Weapon4Ammo: case GlobalVariable.Weapon5Ammo: case GlobalVariable.Weapon6Ammo: case GlobalVariable.Weapon7Ammo: case GlobalVariable.Weapon8Ammo: case GlobalVariable.Weapon9Ammo: case GlobalVariable.Weapon10Ammo: case GlobalVariable.Weapon11Ammo: ReadSlot(1); break; case GlobalVariable.Weapon12Ammo: // Projectiles case GlobalVariable.Weapon13Ammo: case GlobalVariable.Weapon14Ammo: case GlobalVariable.Weapon15Ammo: ReadSlot(2); break; case GlobalVariable.Weapon17Ammo: // Pistols case GlobalVariable.Weapon18Ammo: ReadSlot(3); break; case GlobalVariable.Weapon19Ammo: // Shotguns case GlobalVariable.Weapon20Ammo: case GlobalVariable.Weapon21Ammo: ReadSlot(4); break; case GlobalVariable.Weapon22Ammo: // Sub-machine Guns case GlobalVariable.Weapon23Ammo: case GlobalVariable.Weapon24Ammo: case GlobalVariable.Weapon25Ammo: ReadSlot(5); break; case GlobalVariable.Weapon26Ammo: // Assault Rifles case GlobalVariable.Weapon27Ammo: ReadSlot(6); break; case GlobalVariable.Weapon28Ammo: // Sniper Rifles case GlobalVariable.Weapon29Ammo: ReadSlot(8); break; case GlobalVariable.Weapon30Ammo: // Heavy Weapons case GlobalVariable.Weapon31Ammo: case GlobalVariable.Weapon32Ammo: case GlobalVariable.Weapon33Ammo: ReadSlot(7); break; case GlobalVariable.Weapon36Ammo: // Special ReadSlot(9); break; } }
public void WriteSlot(int index) { IReadOnlyList <Weapon> slotWeapons; Weapon?weapon; int ammo; if (m_isReadingWeaponSlot || m_isWritingWeaponSlot) { return; } m_isWritingWeaponSlot = true; if (index == 0) { TheEditor.SetGlobal(WeaponVars[Types.Weapon.BrassKnuckles], (Slot0Weapon == Types.Weapon.BrassKnuckles) ? 1 : 0); goto Cleanup; } switch (index) { case 1: slotWeapons = Slot1Weapons; weapon = Slot1Weapon; ammo = Slot1Ammo; break; case 2: slotWeapons = Slot2Weapons; weapon = Slot2Weapon; ammo = Slot2Ammo; break; case 3: slotWeapons = Slot3Weapons; weapon = Slot3Weapon; ammo = Slot3Ammo; break; case 4: slotWeapons = Slot4Weapons; weapon = Slot4Weapon; ammo = Slot4Ammo; break; case 5: slotWeapons = Slot5Weapons; weapon = Slot5Weapon; ammo = Slot5Ammo; break; case 6: slotWeapons = Slot6Weapons; weapon = Slot6Weapon; ammo = Slot6Ammo; break; case 7: slotWeapons = Slot7Weapons; weapon = Slot7Weapon; ammo = Slot7Ammo; break; case 8: slotWeapons = Slot8Weapons; weapon = Slot8Weapon; ammo = Slot8Ammo; break; case 9: slotWeapons = Slot9Weapons; weapon = Slot9Weapon; ammo = Slot9Ammo; break; default: throw new InvalidOperationException($"Bad weapon slot number: {index}"); } foreach (Weapon w in slotWeapons) { TheEditor.SetGlobal(WeaponVars[w], (w == weapon) ? ammo : 0); } switch (index) { case 1: Slot1Weapon = weapon; break; case 2: Slot2Weapon = weapon; break; case 3: Slot3Weapon = weapon; break; case 4: Slot4Weapon = weapon; break; case 5: Slot5Weapon = weapon; break; case 6: Slot6Weapon = weapon; break; case 7: Slot7Weapon = weapon; break; case 8: Slot8Weapon = weapon; break; case 9: Slot9Weapon = weapon; break; } Cleanup: UpdateInventory(); m_isWritingWeaponSlot = false; }
public void ReadSlot(int index) { m_isReadingWeaponSlot = true; if (index == 0) { bool hasBrassKnuckles = TheEditor.GetGlobal(WeaponVars[Types.Weapon.BrassKnuckles]) != 0; Slot0Weapon = (hasBrassKnuckles) ? Types.Weapon.BrassKnuckles : Types.Weapon.Fists; goto Cleanup; } IReadOnlyList <Weapon> slotWeapons = index switch { 1 => Slot1Weapons, 2 => Slot2Weapons, 3 => Slot3Weapons, 4 => Slot4Weapons, 5 => Slot5Weapons, 6 => Slot6Weapons, 7 => Slot7Weapons, 8 => Slot8Weapons, 9 => Slot9Weapons, _ => throw new InvalidOperationException($"Bad weapon slot number: {index}"), }; Weapon?weapon = null; int ammo = 0; foreach (Weapon w in slotWeapons) { int a = TheEditor.GetGlobal(WeaponVars[w]); if (a != 0) { ammo = a; weapon = w; break; } } switch (index) { case 1: Slot1Weapon = weapon; Slot1Ammo = ammo; break; case 2: Slot2Weapon = weapon; Slot2Ammo = ammo; break; case 3: Slot3Weapon = weapon; Slot3Ammo = ammo; break; case 4: Slot4Weapon = weapon; Slot4Ammo = ammo; break; case 5: Slot5Weapon = weapon; Slot5Ammo = ammo; break; case 6: Slot6Weapon = weapon; Slot6Ammo = ammo; break; case 7: Slot7Weapon = weapon; Slot7Ammo = ammo; break; case 8: Slot8Weapon = weapon; Slot8Ammo = ammo; break; case 9: Slot9Weapon = weapon; Slot9Ammo = ammo; break; } Cleanup: m_isReadingWeaponSlot = false; }