/// <summary> /// Loads all custom locations /// </summary> public static void LoadCustomLocations() { Targets = new List <SimpleTeleportTarget>(); if (!File.Exists(CONFIG_FILE_CUSTOM_LOCATIONS)) { return; } IniFile ini = new IniFile(CONFIG_FILE_CUSTOM_LOCATIONS); int count = Utils.ParseInt(ini.GetValue(CONFIG_CL, CONFIG_CL_COUNT)); if (count <= 0) { return; } Targets.Capacity = count; for (int i = 0; i < count; i++) { SimpleTeleportTarget target = SimpleTeleportTarget.Deserialize(ini.GetValue(CONFIG_CL, Utils.FormatML(CONFIG_CL_ENTRY, i + 1))); if (target != null) { Targets.Add(target); } } Targets.Sort(); }
/// <summary> /// Overwrite with current location /// </summary> /// <param name="sender">Source menu item</param> public static void Overwrite(MenuItem sender) { SimpleTeleportTarget target = (sender.Data as SimpleTeleportTarget); Configuration.Location.Targets[target.Index].Coords = Game.Player.Character.Position; Configuration.Location.SaveCustomLocations(); Utils.ShowNotification(GlobalConst.Message.CL_OVERWRITTEN); }
/// <summary> /// Teleports to custom location /// </summary> /// <param name="sender">Source menu item</param> public static void Teleport(MenuItem sender) { SimpleTeleportTarget target = (sender.Data as SimpleTeleportTarget); int handle = Utils.GetPlayerContainerHandle(); Function.Call(Hash.SET_ENTITY_COORDS, handle, target.Coords.X, target.Coords.Y, target.Coords.Z, 0, 0, 1, false); Utils.ShowNotification(GlobalConst.Message.CL_TELEPORTED); }
/// <summary> /// Deletes the custom location /// </summary> /// <param name="sender">Source menu item</param> public static void Delete(MenuItem sender) { SimpleTeleportTarget target = (sender.Data as SimpleTeleportTarget); Configuration.Location.Targets.RemoveAt(target.Index); Configuration.Location.SaveCustomLocations(); GenerateTargetList(null); MenuStorage.ReturnToPrevMenu(); Utils.ShowNotification(GlobalConst.Message.CL_DELETED); }
/// <summary> /// Enters a target menu item /// </summary> /// <param name="sender">Source menu item</param> public static void PreEnterTargetItem(MenuItem sender) { SimpleTeleportTarget target = (sender.Data as SimpleTeleportTarget); MenuStorage.Menus.Locations.CLTeleporters.Item.Title = Utils.FormatML(FORMAT_TARGET_NAME, target.Name); MenuStorage.MenuItems.Location.CustomLocationTeleporter.Item.Teleport.Data = target; MenuStorage.MenuItems.Location.CustomLocationTeleporter.Item.Rename.Data = target; MenuStorage.MenuItems.Location.CustomLocationTeleporter.Item.Overwrite.Data = target; MenuStorage.MenuItems.Location.CustomLocationTeleporter.Item.Delete.Data = target; MenuStorage.Menus.Locations.CLTeleporters.Item.SelectedIndex = 0; }
/// <summary> /// Generates the custom location target list /// </summary> /// <param name="sender">Source menu item</param> public static void GenerateTargetList(MenuItem sender) { MenuStorage.Menus.Locations.CLTeleporter.Clear(); MenuStorage.Menus.Locations.CLTeleporter.Add(MenuStorage.MenuItems.Location.CustomLocationTeleporter.SaveCurrentLocation); for (int i = 0; i < Configuration.Location.Targets.Count; i++) { SimpleTeleportTarget target = Configuration.Location.Targets[i]; target.Index = i; MenuItem mi = MenuStorage.AddMenuItem(MenuStorage.Menus.Locations.CLTeleporter, Utils.FormatML(FORMAT_TARGET_NAME, target.Name), false, false, MenuStorage.Menus.Locations.CLTeleporters.Item, null, PreEnterTargetItem, null, target); } }
/// <summary> /// Renames the custom location /// </summary> /// <param name="sender">Source menu item</param> public static void Rename(MenuItem sender) { SimpleTeleportTarget target = (sender.Data as SimpleTeleportTarget); string name = Utils.ShowInGameKeyboard(null, target.Name, MAX_INPUT_LENGTH); if (string.IsNullOrEmpty(name)) { return; } MenuStorage.Menus.Locations.CLTeleporters.Item.Title = name; Configuration.Location.Targets[target.Index].Name = name; Configuration.Location.Targets.Sort(); Configuration.Location.SaveCustomLocations(); GenerateTargetList(null); Utils.ShowNotification(GlobalConst.Message.CL_RENAMED); }
/// <summary> /// Saves the current location as a custom location /// </summary> /// <param name="sender">Source menu item</param> public static void SaveCurrentLocation(MenuItem sender) { RDR2.Math.Vector3 coords = Game.Player.Character.Position; string name = Utils.ShowInGameKeyboard(null, Utils.FormatML(FORMAT_DEFAULT_NAME, coords.X, coords.Y, coords.Z), MAX_INPUT_LENGTH); if (string.IsNullOrEmpty(name)) { return; } SimpleTeleportTarget target = new SimpleTeleportTarget(name, coords.X, coords.Y, coords.Z); Configuration.Location.Targets.Add(target); Configuration.Location.Targets.Sort(); Configuration.Location.SaveCustomLocations(); GenerateTargetList(null); Utils.ShowNotification(GlobalConst.Message.CL_SAVED); }
/// <summary> /// Saves the current location as a custom location /// </summary> /// <param name="sender">Source menu item</param> public static void SaveCurrentLocation(MenuItem sender) { GTA.Math.Vector3 coords = Game.Player.Character.Position; string name = Utils.ShowInGameKeyboard(null, Utils.FormatML(FORMAT_DEFAULT_NAME, coords.X, coords.Y, coords.Z), MAX_INPUT_LENGTH); if (string.IsNullOrEmpty(name)) return; SimpleTeleportTarget target = new SimpleTeleportTarget(name, coords.X, coords.Y, coords.Z); Configuration.Location.Targets.Add(target); Configuration.Location.Targets.Sort(); Configuration.Location.SaveCustomLocations(); GenerateTargetList(null); Utils.ShowNotificationAboveMap(GlobalConst.Message.CL_SAVED); }