public void Display(MissionData data) { Clear(); #region Player { var item = new UIMenuItem("Player"); var dict = StaticData.PedData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Player Skin", "PLACE SPAWNPOINT"); menu.Build("Main Characters"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.PlayerSpawnOpen = true; Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; GameFiber.StartNew(delegate { var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) Editor.MarkerData.RepresentedBy.Delete(); Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; Editor.PlayerSpawnOpen = false; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } #endregion #region Objectives { var item = new UIMenuItem("Objectives"); var newMenu = new ObjectivePlacementMenu(data); Editor.Children.Add(newMenu); BindMenuToItem(newMenu, item); AddItem(item); } #endregion #region Actors { var item = new UIMenuItem("Actors"); var dict = StaticData.PedData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Actor"); menu.Build("Cops and Army"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; GameFiber.StartNew(delegate { var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) Editor.MarkerData.RepresentedBy.Delete(); Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } #endregion #region Cars { var item = new UIMenuItem("Cars"); var dict = StaticData.VehicleData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Vehicle"); menu.Build("Muscle"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; Editor.RingData.HeightOffset = 1f; Editor.MarkerData.HeightOffset = 1f; GameFiber.StartNew(delegate { var hash = StaticData.VehicleData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Vehicle(Util.RequestModel(hash), Game.LocalPlayer.Character.Position); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if(Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) Editor.MarkerData.RepresentedBy.Delete(); Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.VehicleData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Vehicle(Util.RequestModel(hash), Game.LocalPlayer.Character.Position); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); Vector3 max; Vector3 min; Util.GetModelDimensions(veh.Model, out max, out min); Editor.RingData.HeightOffset = min.Z - max.Z + 0.2f; Editor.MarkerData.HeightOffset = min.Z - max.Z + 0.2f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } #endregion #region Pickups { var item = new UIMenuItem("Pickups"); var dict = StaticData.PickupData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Weapon"); menu.Build("Pistols"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = false; Editor.MarkerData.RepresentationHeightOffset = 1f; GameFiber.StartNew(delegate { var hash = StaticData.PickupData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var pos = Game.LocalPlayer.Character.Position; var veh = new Rage.Object(Util.RequestModel("prop_mp_repair"), pos); Editor.PlacedWeaponHash = hash; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) Editor.MarkerData.RepresentedBy.Delete(); Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.MarkerData.RepresentationHeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; Editor.PlacedWeaponHash = 0; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { var hash = StaticData.PickupData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; Editor.PlacedWeaponHash = hash; //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; }); }; } #endregion #region Objects { { var item = new UIMenuItem("Objects"); var dict = StaticData.ObjectData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Model"); menu.Build("Ramps"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; Editor.MarkerData.RepresentationHeightOffset = 1f; GameFiber.StartNew(delegate { var hash = StaticData.ObjectData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var pos = Game.LocalPlayer.Character.Position; var veh = new Rage.Object(Util.RequestModel(hash), pos); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) Editor.MarkerData.RepresentedBy.Delete(); Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.MarkerData.RepresentationHeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.ObjectData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var pos = Game.LocalPlayer.Character.Position; var veh = new Rage.Object(Util.RequestModel(hash), pos); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName<uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } } #endregion RefreshIndex(); }
public void Display(MissionData data) { Clear(); #region Player { var item = new NativeMenuItem("Player"); var dict = StaticData.PedData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Player Skin", "PLACE SPAWNPOINT"); menu.Build("Main Characters"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.PlayerSpawnOpen = true; Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; GameFiber.StartNew(delegate { var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { Editor.MarkerData.RepresentedBy.Delete(); } Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; Editor.PlayerSpawnOpen = false; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } #endregion #region Objectives { var item = new NativeMenuItem("Objectives"); var newMenu = new ObjectivePlacementMenu(data); Editor.Children.Add(newMenu); BindMenuToItem(newMenu, item); AddItem(item); } #endregion #region Actors { var item = new NativeMenuItem("Actors"); var dict = StaticData.PedData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Actor"); menu.Build("Cops and Army"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; GameFiber.StartNew(delegate { var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { Editor.MarkerData.RepresentedBy.Delete(); } Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.PedData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Ped(Util.RequestModel(hash), Game.LocalPlayer.Character.Position, 0f); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } #endregion #region Cars { var item = new NativeMenuItem("Cars"); var dict = StaticData.VehicleData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Vehicle"); menu.Build("Muscle"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; Editor.RingData.HeightOffset = 1f; Editor.MarkerData.HeightOffset = 1f; GameFiber.StartNew(delegate { var hash = StaticData.VehicleData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Vehicle(Util.RequestModel(hash), Game.LocalPlayer.Character.Position); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { Editor.MarkerData.RepresentedBy.Delete(); } Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.VehicleData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var veh = new Vehicle(Util.RequestModel(hash), Game.LocalPlayer.Character.Position); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); Vector3 max; Vector3 min; Util.GetModelDimensions(veh.Model, out max, out min); Editor.RingData.HeightOffset = min.Z - max.Z + 0.2f; Editor.MarkerData.HeightOffset = min.Z - max.Z + 0.2f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } #endregion #region Pickups { var item = new NativeMenuItem("Pickups"); var dict = StaticData.PickupData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Weapon"); menu.Build("Pistols"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = false; Editor.MarkerData.RepresentationHeightOffset = 1f; GameFiber.StartNew(delegate { var hash = StaticData.PickupData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var pos = Game.LocalPlayer.Character.Position; var veh = new Rage.Object(Util.RequestModel("prop_mp_repair"), pos); Editor.PlacedWeaponHash = hash; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { Editor.MarkerData.RepresentedBy.Delete(); } Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.MarkerData.RepresentationHeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; Editor.PlacedWeaponHash = 0; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { var hash = StaticData.PickupData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; Editor.PlacedWeaponHash = hash; //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; }); }; } #endregion #region Objects { { var item = new NativeMenuItem("Objects"); var dict = StaticData.ObjectData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Model"); menu.Build("Ramps"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); item.Activated += (men, itm) => { Editor.RingData.Color = Color.MediumPurple; Editor.RingData.Type = RingType.HorizontalSplitArrowCircle; Editor.MarkerData.Display = true; Editor.MarkerData.MarkerType = "prop_mp_placement"; Editor.MarkerData.RepresentationHeightOffset = 1f; GameFiber.StartNew(delegate { var hash = StaticData.ObjectData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var pos = Game.LocalPlayer.Character.Position; var veh = new Rage.Object(Util.RequestModel(hash), pos); veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); }); }; menu.OnMenuClose += (men) => { if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { Editor.MarkerData.RepresentedBy.Delete(); } Editor.MarkerData.RepresentedBy = null; Editor.MarkerData.MarkerType = null; Editor.MarkerData.Display = false; Editor.MarkerData.HeightOffset = 0f; Editor.MarkerData.RepresentationHeightOffset = 0f; Editor.RingData.HeightOffset = 0f; Editor.RingData.Color = Color.Gray; Editor.RingData.Type = RingType.HorizontalCircleSkinny; }; menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { menu.ResetKey(Common.MenuControls.Right); menu.ResetKey(Common.MenuControls.Left); var heading = 0f; if (Editor.MarkerData.RepresentedBy != null && Editor.MarkerData.RepresentedBy.IsValid()) { heading = Editor.MarkerData.RepresentedBy.Heading; Editor.MarkerData.RepresentedBy.Model.Dismiss(); Editor.MarkerData.RepresentedBy.Delete(); } var hash = StaticData.ObjectData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; var pos = Game.LocalPlayer.Character.Position; var veh = new Rage.Object(Util.RequestModel(hash), pos); veh.Heading = heading; veh.IsPositionFrozen = true; Editor.MarkerData.RepresentedBy = veh; NativeFunction.CallByName <uint>("SET_ENTITY_COLLISION", veh.Handle.Value, false, 0); //var dims = Util.GetModelDimensions(veh.Model); //Editor.RingData.HeightOffset = 1f; //Editor.MarkerData.HeightOffset = 1f; menu.SetKey(Common.MenuControls.Left, GameControl.CellphoneLeft, 0); menu.SetKey(Common.MenuControls.Right, GameControl.CellphoneRight, 0); }); }; } } #endregion RefreshIndex(); }
public void BuildFor(SerializableData.SerializableSpawnpoint actor) { Clear(); #region SpawnAfter { var item = new UIMenuListItem("Spawn Before Objective", StaticData.StaticLists.NumberMenu, actor.SpawnAfter); item.OnListChanged += (sender, index) => { actor.SpawnAfter = index; }; AddItem(item); } #endregion #region Weapons { var item = new UIMenuItem("Weapon"); var dict = StaticData.WeaponsData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Weapon", true, "SELECT WEAPON"); menu.Build("Melee"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { var hash = StaticData.WeaponsData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; NativeFunction.CallByName<uint>("REMOVE_ALL_PED_WEAPONS", actor.GetEntity().Handle.Value, true); ((Ped) actor.GetEntity()).Inventory.GiveNewWeapon(hash, (short)(actor.WeaponAmmo == 0 ? 9999 : actor.WeaponAmmo), true); actor.WeaponHash = hash; }); }; } { var listIndex = actor.WeaponAmmo == 0 ? StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic) 9999) : StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic) actor.WeaponAmmo); var item = new UIMenuListItem("Ammo Count", StaticData.StaticLists.AmmoChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((UIMenuListItem) sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.WeaponAmmo = newAmmo; if(actor.WeaponHash == 0) return; NativeFunction.CallByName<uint>("REMOVE_ALL_PED_WEAPONS", actor.GetEntity().Handle.Value, true); ((Ped)actor.GetEntity()).Inventory.GiveNewWeapon(actor.WeaponHash, (short)newAmmo, true); }; AddItem(item); } #endregion #region Health { var listIndex = actor.Health == 0 ? StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)200) : StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Health); var item = new UIMenuListItem("Health", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((UIMenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Health = newAmmo; }; AddItem(item); } #endregion #region Armor { var listIndex = StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Armor); var item = new UIMenuListItem("Armor", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((UIMenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Armor = newAmmo; }; AddItem(item); } #endregion RefreshIndex(); }
public void BuildFor(SerializableData.SerializablePed actor) { Clear(); #region SpawnAfter { var item = new MenuListItem("Spawn After Objective", StaticData.StaticLists.NumberMenu, actor.SpawnAfter); item.OnListChanged += (sender, index) => { actor.SpawnAfter = index; }; AddItem(item); } #endregion #region RemoveAfter { var item = new MenuListItem("Remove After Objective", StaticData.StaticLists.RemoveAfterList, actor.RemoveAfter); item.OnListChanged += (sender, index) => { actor.RemoveAfter = index; }; AddItem(item); } #endregion // TODO: Change NumberMenu to max num of objectives in mission // Note: if adding items before weapons, change item order in VehiclePropertiesMenu #region Weapons { var item = new NativeMenuItem("Weapon"); var dict = StaticData.WeaponsData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Weapon", true, "SELECT WEAPON"); menu.Build("Melee"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { var hash = StaticData.WeaponsData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; NativeFunction.CallByName <uint>("REMOVE_ALL_PED_WEAPONS", actor.GetEntity().Handle.Value, true); ((Ped)actor.GetEntity()).GiveNewWeapon(hash, actor.WeaponAmmo == 0 ? 9999 : actor.WeaponAmmo, true); actor.WeaponHash = hash; }); }; } { var listIndex = actor.WeaponAmmo == 0 ? StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic)9999) : StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic)actor.WeaponAmmo); var item = new MenuListItem("Ammo Count", StaticData.StaticLists.AmmoChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.WeaponAmmo = newAmmo; if (actor.WeaponHash == 0) { return; } NativeFunction.CallByName <uint>("REMOVE_ALL_PED_WEAPONS", actor.GetEntity().Handle.Value, true); ((Ped)actor.GetEntity()).GiveNewWeapon(actor.WeaponHash, newAmmo, true); }; AddItem(item); } #endregion #region Health { var listIndex = actor.Health == 0 ? StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)200) : StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Health); var item = new MenuListItem("Health", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Health = newAmmo; }; AddItem(item); } #endregion #region Armor { var listIndex = StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Armor); var item = new MenuListItem("Armor", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Armor = newAmmo; }; AddItem(item); } #endregion #region Accuracy { var listIndex = StaticData.StaticLists.AccuracyList.FindIndex(n => n == (dynamic)actor.Accuracy); var item = new MenuListItem("Accuracy", StaticData.StaticLists.AccuracyList, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Accuracy = newAmmo; }; AddItem(item); } #endregion #region Relationship { var item = new MenuListItem("Relationship", StaticData.StaticLists.RelationshipGroups, actor.RelationshipGroup); item.OnListChanged += (sender, index) => { actor.RelationshipGroup = index; }; AddItem(item); } #endregion #region Behaviour { var wpyItem = new NativeMenuItem("Waypoints"); { var waypMenu = new WaypointEditor(actor); BindMenuToItem(waypMenu.CreateWaypointMenu, wpyItem); Vector3 camPos = new Vector3(); Rotator camRot = new Rotator(); wpyItem.Activated += (sender, selectedItem) => { camPos = Editor.MainCamera.Position; camRot = Editor.MainCamera.Rotation; waypMenu.Enter(); Editor.WaypointEditor = waypMenu; }; waypMenu.OnEditorExit += (sender, args) => { Editor.WaypointEditor = null; Editor.DisableControlEnabling = true; if (camPos != new Vector3()) { Editor.MainCamera.Position = camPos; Editor.MainCamera.Rotation = camRot; } }; } if (actor.Behaviour != 4) // Follow Waypoints { wpyItem.Enabled = false; } var item = new MenuListItem("Behaviour", StaticData.StaticLists.Behaviour, actor.Behaviour); item.OnListChanged += (sender, index) => { actor.Behaviour = index; wpyItem.Enabled = index == 4; }; AddItem(item); AddItem(wpyItem); } #endregion #region FailOnDeath { var item = new MenuCheckboxItem("Mission Fail On Death", actor.FailMissionOnDeath); item.CheckboxEvent += (sender, @checked) => { actor.FailMissionOnDeath = @checked; }; AddItem(item); } #endregion RefreshIndex(); }
public void BuildFor(SerializableData.SerializablePed actor) { Clear(); #region SpawnAfter { var item = new MenuListItem("Spawn After Objective", StaticData.StaticLists.NumberMenu, actor.SpawnAfter); item.OnListChanged += (sender, index) => { actor.SpawnAfter = index; }; AddItem(item); } #endregion #region RemoveAfter { var item = new MenuListItem("Remove After Objective", StaticData.StaticLists.RemoveAfterList, actor.RemoveAfter); item.OnListChanged += (sender, index) => { actor.RemoveAfter = index; }; AddItem(item); } #endregion // TODO: Change NumberMenu to max num of objectives in mission // Note: if adding items before weapons, change item order in VehiclePropertiesMenu #region Weapons { var item = new NativeMenuItem("Weapon"); var dict = StaticData.WeaponsData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Weapon", true, "SELECT WEAPON"); menu.Build("Melee"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { var hash = StaticData.WeaponsData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; NativeFunction.CallByName<uint>("REMOVE_ALL_PED_WEAPONS", actor.GetEntity().Handle.Value, true); ((Ped) actor.GetEntity()).GiveNewWeapon(hash, actor.WeaponAmmo == 0 ? 9999 : actor.WeaponAmmo, true); actor.WeaponHash = hash; }); }; } { var listIndex = actor.WeaponAmmo == 0 ? StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic) 9999) : StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic) actor.WeaponAmmo); var item = new MenuListItem("Ammo Count", StaticData.StaticLists.AmmoChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem) sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.WeaponAmmo = newAmmo; if(actor.WeaponHash == 0) return; NativeFunction.CallByName<uint>("REMOVE_ALL_PED_WEAPONS", actor.GetEntity().Handle.Value, true); ((Ped)actor.GetEntity()).GiveNewWeapon(actor.WeaponHash, newAmmo, true); }; AddItem(item); } #endregion #region Health { var listIndex = actor.Health == 0 ? StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)200) : StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Health); var item = new MenuListItem("Health", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Health = newAmmo; }; AddItem(item); } #endregion #region Armor { var listIndex = StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Armor); var item = new MenuListItem("Armor", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Armor = newAmmo; }; AddItem(item); } #endregion #region Accuracy { var listIndex = StaticData.StaticLists.AccuracyList.FindIndex(n => n == (dynamic)actor.Accuracy); var item = new MenuListItem("Accuracy", StaticData.StaticLists.AccuracyList, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Accuracy = newAmmo; }; AddItem(item); } #endregion #region Relationship { var item = new MenuListItem("Relationship", StaticData.StaticLists.RelationshipGroups, actor.RelationshipGroup); item.OnListChanged += (sender, index) => { actor.RelationshipGroup = index; }; AddItem(item); } #endregion #region Behaviour { var wpyItem = new NativeMenuItem("Waypoints"); { var waypMenu = new WaypointEditor(actor); BindMenuToItem(waypMenu.CreateWaypointMenu, wpyItem); Vector3 camPos = new Vector3(); Rotator camRot = new Rotator(); wpyItem.Activated += (sender, selectedItem) => { camPos = Editor.MainCamera.Position; camRot = Editor.MainCamera.Rotation; waypMenu.Enter(); Editor.WaypointEditor = waypMenu; }; waypMenu.OnEditorExit += (sender, args) => { Editor.WaypointEditor = null; Editor.DisableControlEnabling = true; if (camPos != new Vector3()) { Editor.MainCamera.Position = camPos; Editor.MainCamera.Rotation = camRot; } }; } if (actor.Behaviour != 4) // Follow Waypoints wpyItem.Enabled = false; var item = new MenuListItem("Behaviour", StaticData.StaticLists.Behaviour, actor.Behaviour); item.OnListChanged += (sender, index) => { actor.Behaviour = index; wpyItem.Enabled = index == 4; }; AddItem(item); AddItem(wpyItem); } #endregion #region FailOnDeath { var item = new MenuCheckboxItem("Mission Fail On Death", actor.FailMissionOnDeath); item.CheckboxEvent += (sender, @checked) => { actor.FailMissionOnDeath = @checked; }; AddItem(item); } #endregion RefreshIndex(); }
public void BuildFor(SerializableData.Objectives.SerializableActorObjective actor) { Clear(); #region SpawnAfter { var item = new MenuListItem("Spawn After Objective", StaticData.StaticLists.NumberMenu, actor.SpawnAfter); item.OnListChanged += (sender, index) => { actor.SpawnAfter = index; }; AddItem(item); } #endregion #region ObjectiveIndex { var item = new MenuListItem("Objective Index", StaticData.StaticLists.ObjectiveIndexList, actor.ActivateAfter); item.OnListChanged += (sender, index) => { actor.ActivateAfter = index; if (string.IsNullOrEmpty(Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter])) { MenuItems[4].SetRightBadge(NativeMenuItem.BadgeStyle.Alert); MenuItems[4].SetRightLabel(""); } else { var title = Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter]; MenuItems[4].SetRightLabel(title.Length > 20 ? title.Substring(0, 20) + "..." : title); MenuItems[4].SetRightBadge(NativeMenuItem.BadgeStyle.None); } }; AddItem(item); } #endregion // TODO: Change NumberMenu to max num of objectives in mission // Note: if adding items before weapons, change item order in VehiclePropertiesMenu #region Weapons { var item = new NativeMenuItem("Weapon"); var dict = StaticData.WeaponsData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Weapon", true, "SELECT WEAPON"); menu.Build("Melee"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { var hash = StaticData.WeaponsData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; NativeFunction.CallByName<uint>("REMOVE_ALL_PED_WEAPONS", actor.GetPed().Handle.Value, true); actor.GetPed().GiveNewWeapon(hash, actor.WeaponAmmo == 0 ? 9999 : actor.WeaponAmmo, true); actor.WeaponHash = hash; }); }; } { var listIndex = actor.WeaponAmmo == 0 ? StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic) 9999) : StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic) actor.WeaponAmmo); var item = new MenuListItem("Ammo Count", StaticData.StaticLists.AmmoChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem) sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.WeaponAmmo = newAmmo; if(actor.WeaponHash == 0) return; NativeFunction.CallByName<uint>("REMOVE_ALL_PED_WEAPONS", actor.GetPed().Handle.Value, true); ((Ped)actor.GetPed()).GiveNewWeapon(actor.WeaponHash, newAmmo, true); }; AddItem(item); } #endregion #region Objective Name { var item = new NativeMenuItem("Objective Name"); if (string.IsNullOrEmpty(Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter])) item.SetRightBadge(NativeMenuItem.BadgeStyle.Alert); else { var title = Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter]; item.SetRightLabel(title.Length > 20 ? title.Substring(0, 20) + "..." : title); } item.Activated += (sender, selectedItem) => { GameFiber.StartNew(delegate { ResetKey(Common.MenuControls.Back); Editor.DisableControlEnabling = true; string title = Util.GetUserInput(); if (string.IsNullOrEmpty(title)) { item.SetRightBadge(NativeMenuItem.BadgeStyle.Alert); Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter] = ""; SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); Editor.DisableControlEnabling = false; return; } item.SetRightBadge(NativeMenuItem.BadgeStyle.None); title = Regex.Replace(title, "-=", "~"); Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter] = title; selectedItem.SetRightLabel(title.Length > 20 ? title.Substring(0, 20) + "..." : title); SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); }); }; AddItem(item); } #endregion #region Health { var listIndex = actor.Health == 0 ? StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)200) : StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Health); var item = new MenuListItem("Health", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Health = newAmmo; }; AddItem(item); } #endregion #region Armor { var listIndex = StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Armor); var item = new MenuListItem("Armor", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Armor = newAmmo; }; AddItem(item); } #endregion #region Accuracy { var listIndex = StaticData.StaticLists.AccuracyList.FindIndex(n => n == (dynamic)actor.Accuracy); var item = new MenuListItem("Accuracy", StaticData.StaticLists.AccuracyList, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Accuracy = newAmmo; }; AddItem(item); } #endregion #region Relationship { var item = new MenuListItem("Relationship", StaticData.StaticLists.RelationshipGroups, actor.RelationshipGroup); item.OnListChanged += (sender, index) => { actor.RelationshipGroup = index; }; AddItem(item); } #endregion #region Behaviour { var wpyItem = new NativeMenuItem("Waypoints"); { var waypMenu = new WaypointEditor(actor); BindMenuToItem(waypMenu.CreateWaypointMenu, wpyItem); Vector3 camPos = new Vector3(); Rotator camRot = new Rotator(); wpyItem.Activated += (sender, selectedItem) => { camPos = Editor.MainCamera.Position; camRot = Editor.MainCamera.Rotation; waypMenu.Enter(); Editor.WaypointEditor = waypMenu; }; waypMenu.OnEditorExit += (sender, args) => { Editor.WaypointEditor = null; Editor.DisableControlEnabling = true; if (camPos != new Vector3()) { Editor.MainCamera.Position = camPos; Editor.MainCamera.Rotation = camRot; } }; } if (actor.Behaviour != 4) // Follow Waypoints wpyItem.Enabled = false; var item = new MenuListItem("Behaviour", StaticData.StaticLists.Behaviour, actor.Behaviour); item.OnListChanged += (sender, index) => { actor.Behaviour = index; wpyItem.Enabled = index == 4; }; AddItem(item); AddItem(wpyItem); } #endregion #region Show Health Bar { var item = new MenuCheckboxItem("Show Healthbar", actor.ShowHealthBar); AddItem(item); item.CheckboxEvent += (sender, @checked) => { actor.ShowHealthBar = @checked; MenuItems[12].Enabled = @checked; }; } #endregion #region Bar Name { var item = new NativeMenuItem("Healthbar Label"); AddItem(item); if (!actor.ShowHealthBar) item.Enabled = false; if (string.IsNullOrEmpty(actor.Name) && actor.ShowHealthBar) actor.Name = "HEALTH"; if(actor.ShowHealthBar) item.SetRightLabel(actor.Name.Length > 20 ? actor.Name.Substring(0, 20) : actor.Name); item.Activated += (sender, selectedItem) => { GameFiber.StartNew(delegate { ResetKey(Common.MenuControls.Back); Editor.DisableControlEnabling = true; string title = Util.GetUserInput(); if (string.IsNullOrEmpty(title)) { actor.Name = "HEALTH"; item.SetRightLabel(actor.Name.Length > 20 ? actor.Name.Substring(0, 20) : actor.Name); SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); Editor.DisableControlEnabling = false; return; } title = Regex.Replace(title, "-=", "~"); actor.Name = title; item.SetRightLabel(actor.Name.Length > 20 ? actor.Name.Substring(0, 20) : actor.Name); SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); }); }; } #endregion RefreshIndex(); }
public void RebuildWaypointPropertiesMenu(SerializableWaypoint waypoint) { _children.Clear(); _waypointPropertiesMenu.Clear(); _waypointPropertiesMenu.Subtitle.Caption = waypoint.Type.ToString().ToUpper() + " PROPERTIES"; { var item = new NativeMenuItem("Duration", "Task duration in seconds. Leave blank to wait until the task is done."); _waypointPropertiesMenu.AddItem(item); item.SetRightLabel(waypoint.Duration == 0 ? "Wait Until Done" : waypoint.Duration.ToString()); item.Activated += (sender, selectedItem) => { GameFiber.StartNew(delegate { _waypointPropertiesMenu.ResetKey(Common.MenuControls.Back); Editor.Editor.DisableControlEnabling = true; string title = Util.GetUserInput(); Editor.Editor.DisableControlEnabling = false; _waypointPropertiesMenu.SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); if (string.IsNullOrEmpty(title)) { waypoint.Duration = 0; selectedItem.SetRightLabel("Wait Until Done"); return; } float duration; if (!float.TryParse(title, NumberStyles.Float, CultureInfo.InvariantCulture, out duration)) { waypoint.Duration = 0; selectedItem.SetRightLabel("Wait Until Done"); Game.DisplayNotification("Incorrect format."); } waypoint.Duration = (int)(duration*1000); selectedItem.SetRightLabel(duration.ToString()); }); }; } if (waypoint.Type == WaypointTypes.Animation) { var db = StaticData.AnimData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(db, "Animation", true, "SELECT ANIMATION"); var item = new NativeMenuItem("Select Animation"); menu.Build(db.ElementAt(0).Key); if (!string.IsNullOrEmpty(waypoint.AnimName)) { var categName = StaticData.AnimData.Database.FirstOrDefault(cats => { return cats.Value.Any(v => v.Item3 == waypoint.AnimName); }).Key; var humanName = StaticData.AnimData.Database[categName].FirstOrDefault(v => v.Item3 == waypoint.AnimName)?.Item1; if(!string.IsNullOrEmpty(humanName)) item.SetRightLabel(humanName); } menu.SelectionChanged += (sender, args) => { var pair = StaticData.AnimData.Database[menu.CurrentSelectedCategory].First( m => m.Item1 == menu.CurrentSelectedItem); waypoint.AnimDict = pair.Item2; waypoint.AnimName = pair.Item3; }; _waypointPropertiesMenu.AddItem(item); _waypointPropertiesMenu.BindMenuToItem(menu, item); _children.Add(menu); } if (waypoint.Type == WaypointTypes.Drive) { { var item = new NativeMenuItem("Driving Speed", "Driving speed in meters per second."); _waypointPropertiesMenu.AddItem(item); item.SetRightLabel(waypoint.VehicleSpeed == 0 ? "Default" : waypoint.VehicleSpeed.ToString()); item.Activated += (sender, selectedItem) => { GameFiber.StartNew(delegate { _waypointPropertiesMenu.ResetKey(Common.MenuControls.Back); Editor.Editor.DisableControlEnabling = true; string title = Util.GetUserInput(); Editor.Editor.DisableControlEnabling = false; _waypointPropertiesMenu.SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); if (string.IsNullOrEmpty(title)) { waypoint.VehicleSpeed = 20; selectedItem.SetRightLabel("Default"); return; } float duration; if (!float.TryParse(title, NumberStyles.Float, CultureInfo.InvariantCulture, out duration)) { waypoint.VehicleSpeed = 20; selectedItem.SetRightLabel("Default"); Game.DisplayNotification("Incorrect format."); } waypoint.VehicleSpeed = duration; selectedItem.SetRightLabel(duration.ToString()); }); }; } { var parsedList = StaticData.StaticLists.DrivingStylesList.Select(t => (dynamic)t.Item1); var indexOf = StaticData.StaticLists.DrivingStylesList.FindIndex(tup => tup.Item2 == waypoint.DrivingStyle); var item = new MenuListItem("Driving Style", parsedList.ToList(), indexOf); _waypointPropertiesMenu.AddItem(item); item.OnListChanged += (sender, index) => { waypoint.DrivingStyle = StaticData.StaticLists.DrivingStylesList[index].Item2; }; } } _waypointPropertiesMenu.RefreshIndex(); }
public void BuildFor(SerializableData.Objectives.SerializableActorObjective actor) { Clear(); #region SpawnAfter { var item = new MenuListItem("Spawn After Objective", StaticData.StaticLists.NumberMenu, actor.SpawnAfter); item.OnListChanged += (sender, index) => { actor.SpawnAfter = index; }; AddItem(item); } #endregion #region ObjectiveIndex { var item = new MenuListItem("Objective Index", StaticData.StaticLists.ObjectiveIndexList, actor.ActivateAfter); item.OnListChanged += (sender, index) => { actor.ActivateAfter = index; if (string.IsNullOrEmpty(Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter])) { MenuItems[4].SetRightBadge(NativeMenuItem.BadgeStyle.Alert); MenuItems[4].SetRightLabel(""); } else { var title = Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter]; MenuItems[4].SetRightLabel(title.Length > 20 ? title.Substring(0, 20) + "..." : title); MenuItems[4].SetRightBadge(NativeMenuItem.BadgeStyle.None); } }; AddItem(item); } #endregion // TODO: Change NumberMenu to max num of objectives in mission // Note: if adding items before weapons, change item order in VehiclePropertiesMenu #region Weapons { var item = new NativeMenuItem("Weapon"); var dict = StaticData.WeaponsData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Weapon", true, "SELECT WEAPON"); menu.Build("Melee"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { var hash = StaticData.WeaponsData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; NativeFunction.CallByName <uint>("REMOVE_ALL_PED_WEAPONS", actor.GetPed().Handle.Value, true); actor.GetPed().GiveNewWeapon(hash, actor.WeaponAmmo == 0 ? 9999 : actor.WeaponAmmo, true); actor.WeaponHash = hash; }); }; } { var listIndex = actor.WeaponAmmo == 0 ? StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic)9999) : StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic)actor.WeaponAmmo); var item = new MenuListItem("Ammo Count", StaticData.StaticLists.AmmoChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.WeaponAmmo = newAmmo; if (actor.WeaponHash == 0) { return; } NativeFunction.CallByName <uint>("REMOVE_ALL_PED_WEAPONS", actor.GetPed().Handle.Value, true); ((Ped)actor.GetPed()).GiveNewWeapon(actor.WeaponHash, newAmmo, true); }; AddItem(item); } #endregion #region Objective Name { var item = new NativeMenuItem("Objective Name"); if (string.IsNullOrEmpty(Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter])) { item.SetRightBadge(NativeMenuItem.BadgeStyle.Alert); } else { var title = Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter]; item.SetRightLabel(title.Length > 20 ? title.Substring(0, 20) + "..." : title); } item.Activated += (sender, selectedItem) => { GameFiber.StartNew(delegate { ResetKey(Common.MenuControls.Back); Editor.DisableControlEnabling = true; string title = Util.GetUserInput(); if (string.IsNullOrEmpty(title)) { item.SetRightBadge(NativeMenuItem.BadgeStyle.Alert); Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter] = ""; SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); Editor.DisableControlEnabling = false; return; } item.SetRightBadge(NativeMenuItem.BadgeStyle.None); title = Regex.Replace(title, "-=", "~"); Editor.CurrentMission.ObjectiveNames[actor.ActivateAfter] = title; selectedItem.SetRightLabel(title.Length > 20 ? title.Substring(0, 20) + "..." : title); SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); }); }; AddItem(item); } #endregion #region Health { var listIndex = actor.Health == 0 ? StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)200) : StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Health); var item = new MenuListItem("Health", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Health = newAmmo; }; AddItem(item); } #endregion #region Armor { var listIndex = StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Armor); var item = new MenuListItem("Armor", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Armor = newAmmo; }; AddItem(item); } #endregion #region Accuracy { var listIndex = StaticData.StaticLists.AccuracyList.FindIndex(n => n == (dynamic)actor.Accuracy); var item = new MenuListItem("Accuracy", StaticData.StaticLists.AccuracyList, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Accuracy = newAmmo; }; AddItem(item); } #endregion #region Relationship { var item = new MenuListItem("Relationship", StaticData.StaticLists.RelationshipGroups, actor.RelationshipGroup); item.OnListChanged += (sender, index) => { actor.RelationshipGroup = index; }; AddItem(item); } #endregion #region Behaviour { var wpyItem = new NativeMenuItem("Waypoints"); { var waypMenu = new WaypointEditor(actor); BindMenuToItem(waypMenu.CreateWaypointMenu, wpyItem); Vector3 camPos = new Vector3(); Rotator camRot = new Rotator(); wpyItem.Activated += (sender, selectedItem) => { camPos = Editor.MainCamera.Position; camRot = Editor.MainCamera.Rotation; waypMenu.Enter(); Editor.WaypointEditor = waypMenu; }; waypMenu.OnEditorExit += (sender, args) => { Editor.WaypointEditor = null; Editor.DisableControlEnabling = true; if (camPos != new Vector3()) { Editor.MainCamera.Position = camPos; Editor.MainCamera.Rotation = camRot; } }; } if (actor.Behaviour != 4) // Follow Waypoints { wpyItem.Enabled = false; } var item = new MenuListItem("Behaviour", StaticData.StaticLists.Behaviour, actor.Behaviour); item.OnListChanged += (sender, index) => { actor.Behaviour = index; wpyItem.Enabled = index == 4; }; AddItem(item); AddItem(wpyItem); } #endregion #region Show Health Bar { var item = new MenuCheckboxItem("Show Healthbar", actor.ShowHealthBar); AddItem(item); item.CheckboxEvent += (sender, @checked) => { actor.ShowHealthBar = @checked; MenuItems[12].Enabled = @checked; }; } #endregion #region Bar Name { var item = new NativeMenuItem("Healthbar Label"); AddItem(item); if (!actor.ShowHealthBar) { item.Enabled = false; } if (string.IsNullOrEmpty(actor.Name) && actor.ShowHealthBar) { actor.Name = "HEALTH"; } if (actor.ShowHealthBar) { item.SetRightLabel(actor.Name.Length > 20 ? actor.Name.Substring(0, 20) : actor.Name); } item.Activated += (sender, selectedItem) => { GameFiber.StartNew(delegate { ResetKey(Common.MenuControls.Back); Editor.DisableControlEnabling = true; string title = Util.GetUserInput(); if (string.IsNullOrEmpty(title)) { actor.Name = "HEALTH"; item.SetRightLabel(actor.Name.Length > 20 ? actor.Name.Substring(0, 20) : actor.Name); SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); Editor.DisableControlEnabling = false; return; } title = Regex.Replace(title, "-=", "~"); actor.Name = title; item.SetRightLabel(actor.Name.Length > 20 ? actor.Name.Substring(0, 20) : actor.Name); SetKey(Common.MenuControls.Back, GameControl.CellphoneCancel, 0); }); }; } #endregion RefreshIndex(); }
public void BuildFor(SerializableData.SerializableSpawnpoint actor) { Clear(); #region SpawnAfter { var item = new MenuListItem("Spawn Before Objective", StaticData.StaticLists.NumberMenu, actor.SpawnAfter); item.OnListChanged += (sender, index) => { actor.SpawnAfter = index; }; AddItem(item); } #endregion #region Weapons { var item = new NativeMenuItem("Weapon"); var dict = StaticData.WeaponsData.Database.ToDictionary(k => k.Key, k => k.Value.Select(x => x.Item1).ToArray()); var menu = new CategorySelectionMenu(dict, "Weapon", true, "SELECT WEAPON"); menu.Build("Melee"); Children.Add(menu); AddItem(item); BindMenuToItem(menu, item); menu.SelectionChanged += (sender, eventargs) => { GameFiber.StartNew(delegate { var hash = StaticData.WeaponsData.Database[menu.CurrentSelectedCategory].First( tuple => tuple.Item1 == menu.CurrentSelectedItem).Item2; NativeFunction.CallByName <uint>("REMOVE_ALL_PED_WEAPONS", actor.GetEntity().Handle.Value, true); ((Ped)actor.GetEntity()).GiveNewWeapon(hash, actor.WeaponAmmo == 0 ? 9999 : actor.WeaponAmmo, true); actor.WeaponHash = hash; }); }; } { var listIndex = actor.WeaponAmmo == 0 ? StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic)9999) : StaticData.StaticLists.AmmoChoses.FindIndex(n => n == (dynamic)actor.WeaponAmmo); var item = new MenuListItem("Ammo Count", StaticData.StaticLists.AmmoChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.WeaponAmmo = newAmmo; if (actor.WeaponHash == 0) { return; } NativeFunction.CallByName <uint>("REMOVE_ALL_PED_WEAPONS", actor.GetEntity().Handle.Value, true); ((Ped)actor.GetEntity()).GiveNewWeapon(actor.WeaponHash, newAmmo, true); }; AddItem(item); } #endregion #region Health { var listIndex = actor.Health == 0 ? StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)200) : StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Health); var item = new MenuListItem("Health", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Health = newAmmo; }; AddItem(item); } #endregion #region Armor { var listIndex = StaticData.StaticLists.HealthArmorChoses.FindIndex(n => n == (dynamic)actor.Armor); var item = new MenuListItem("Armor", StaticData.StaticLists.HealthArmorChoses, listIndex); item.OnListChanged += (sender, index) => { int newAmmo = int.Parse(((MenuListItem)sender).IndexToItem(index).ToString(), CultureInfo.InvariantCulture); actor.Armor = newAmmo; }; AddItem(item); } #endregion RefreshIndex(); }