public void ShowManagerDialog(Player player) { ListDialog managerDialog = new ListDialog("Event manager", "Select", "Cancel"); managerDialog.AddItem(Color.Green + "Create event"); foreach (Event evt in eventList) { managerDialog.AddItem(Color.White + "[" + evt.Status.ToString() + "]" + evt.Name); } managerDialog.Show(player); managerDialog.Response += (sender, eventArgs) => { if (eventArgs.DialogButton == DialogButton.Left) { if (eventArgs.ListItem == 0) // Create event { ShowCreateEventTypeDialog(player); } else { ShowEventOptionDialog(player, eventList.ElementAt(eventArgs.ListItem + 1)); } } else { player.Notificate("Cancelled"); } }; }
private static void GetInfo(Player player, int id) { Dictionary <string, string> result = RaceCreator.GetRaceInfo(id); if (result.Count == 0) { player.SendClientMessage("No race found !"); } else { var infoList = new ListDialog("Race info", "Ok", ""); string str = ""; foreach (KeyValuePair <string, string> kvp in result) { str = new Color(50, 50, 255) + kvp.Key + ": " + new Color(255, 255, 255) + kvp.Value; if (str.Length >= 64) { infoList.AddItem(str.Substring(0, 63)); infoList.AddItem(str.Substring(63)); } else { infoList.AddItem(str); } } infoList.Show(player); } }
private static void ModelsDialogCreate(Player player) { var action = new EventHandler <DialogResponseEventArgs>((o, args) => { if (args.DialogButton == DialogButton.Left) { player.SendClientMessage($"Stworzyłeś obiekt o modelu {args.InputText}."); player.ObjectEditor.CreateObjectMode(new MruDynamicObject(Int32.Parse(args.InputText), player.Position)); } else { ModelsDialogCreate(player); } }); var categoriesDialog = new ListDialog("Kategorie modeli", "Wyjdź", "Wybierz"); categoriesDialog.AddItems(Objects.Objects.ObjectModelsCategory.Keys); categoriesDialog.Response += (sender, args) => { var tablistDialog = new TablistDialog($"Modele - Kategoria {args.InputText}", new[] { "Model", "Nazwa", "Rozmiar", "Tagi" }, "Stwórz", "Wróć"); foreach (var objectModel in Objects.Objects.ObjectModelsCategory[args.InputText]) { var o = objectModel.Value; tablistDialog.Add(o.Model.ToString(), o.Name, o.Size.ToString(CultureInfo.CurrentCulture), String.Join(", ", o.Tags)); } tablistDialog.Response += action; tablistDialog.Show(player); }; categoriesDialog.Show(player); }
public static void OnMutedCommand(BasePlayer sender) { var mutedPlayersDialog = new ListDialog("Muted players:", "Ok"); foreach (var basePlayer in Player.All) { var player = (Player)basePlayer; if (!player.IsLoggedIn) { continue; } if (player.Account.Muted > DateTime.Now) { mutedPlayersDialog.AddItem($"{player.Name} (ID:{player.Id})"); } } if (mutedPlayersDialog.Items.Count != 0) { mutedPlayersDialog.Show(sender); } else { sender.SendClientMessage(Color.GreenYellow, Messages.ThereAreNoMutedPlayers); } }
private static void BanIps(Player player) { if (player.IsAdminLevel(3)) { return; } try { var lists = File.ReadAllLines("./samp.ban"); if (lists.Length == 0) { player.SendClientMessage(Color.Red, "Error: No se encontró ninguna IP prohíbida."); return; } var dialog = new ListDialog($"Ban IPs: ({lists.Length})", "Cerrar", ""); foreach (string info in lists) { dialog.AddItem(info); } dialog.Show(player); SendMessageToAdmins(player, "banips"); } catch (FileNotFoundException) { player.SendClientMessage(Color.Red, "Error: No se encontró ninguna IP prohíbida."); } }
private void ShowCheckpointDialog() { Checkpoint cp = editingRace.checkpoints[checkpointIndex]; ListDialog cpDialog = new ListDialog("Checkpoint options", "Select", "Cancel"); cpDialog.AddItem("Edit checkpoint position"); cpDialog.AddItem("Edit checkpoint size [" + cp.Size.ToString() + "]"); if (cp.Type == CheckpointType.Normal || cp.Type == CheckpointType.Finish) { cpDialog.AddItem("Change checkpoint type: " + Color.Green + "Normal" + Color.White + "/Air"); } else if (cp.Type == CheckpointType.Air || cp.Type == CheckpointType.AirFinish) { cpDialog.AddItem("Change checkpoint type: Normal/" + Color.Green + "Air"); } if (checkpointIndex > 0) { cpDialog.AddItem("Edit events"); } cpDialog.Show(player); cpDialog.Response += CpDialog_Response; }
public void ShowCreateEventTypeDialog(Player player) { ListDialog createEventDialog = new ListDialog("Create an event", "Create", "Cancel"); foreach (EventType t in (EventType[])Enum.GetValues(typeof(EventType))) { createEventDialog.AddItem(t.ToString()); } createEventDialog.Show(player); createEventDialog.Response += (sender, eventArgs) => { if (eventArgs.DialogButton == DialogButton.Left) { EventType evtType; if (Enum.TryParse(eventArgs.InputText, out evtType)) { ShowCreateEventNameDialog(player, evtType); } else { ShowCreateEventTypeDialog(player); player.Notificate("Unable to parse event type"); } } else { player.Notificate("Cancelled"); ShowManagerDialog(player); } }; }
//public static IEntry EnsureClassIsInFile(IMEPackage pcc, string className) //{ // //check to see class is already in file // foreach (ImportEntry import in pcc.Imports) // { // if (import.IsClass && import.ObjectName == className) // { // return import; // } // } // foreach (ExportEntry export in pcc.Exports) // { // if (export.IsClass && export.ObjectName == className) // { // return export; // } // } // ClassInfo info = UnrealObjectInfo.GetClassOrStructInfo(pcc.Game, className); // //backup some package state so we can undo changes if something goes wrong // int exportCount = pcc.ExportCount; // int importCount = pcc.ImportCount; // List<string> nameListBackup = pcc.Names.ToList(); // try // { // if (EntryImporter.IsSafeToImportFrom(info.pccPath, pcc.Game)) // { // string package = Path.GetFileNameWithoutExtension(info.pccPath); // return pcc.getEntryOrAddImport($"{package}.{className}"); // } // //It's a class that's defined locally in every file that uses it. // Stream loadStream = null; // if (info.pccPath == UnrealObjectInfo.Me3ExplorerCustomNativeAdditionsName) // { // loadStream = ME3ExplorerCoreUtilities.GetCustomAppResourceStream(pcc.Game); // //string resourceFilePath = App.CustomResourceFilePath(pcc.Game); // //if (File.Exists(resourceFilePath)) // //{ // // sourceFilePath = resourceFilePath; // //} // } // else // { // string testPath = Path.Combine(MEDirectories.GetBioGamePath(pcc.Game), info.pccPath); // if (File.Exists(testPath)) // { // loadStream = new MemoryStream(File.ReadAllBytes(testPath)); // } // else if (pcc.Game == MEGame.ME1) // { // testPath = Path.Combine(ME1Directory.DefaultGamePath, info.pccPath); // if (File.Exists(testPath)) // { // loadStream = new MemoryStream(File.ReadAllBytes(testPath)); // } // } // } // if (loadStream == null) // { // //can't find file to import from. This may occur if user does not have game or neccesary dlc installed // return null; // } // using IMEPackage sourcePackage = MEPackageHandler.OpenMEPackageFromStream(loadStream); // if (!sourcePackage.IsUExport(info.exportIndex)) // { // return null; //not sure how this would happen // } // ExportEntry sourceClassExport = sourcePackage.GetUExport(info.exportIndex); // if (sourceClassExport.ObjectName != className) // { // return null; // } // //Will make sure that, if the class is in a package, that package will exist in pcc // IEntry parent = EntryImporter.GetOrAddCrossImportOrPackage(sourceClassExport.ParentFullPath, sourcePackage, pcc); // var relinkResults = EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.CloneAllDependencies, sourceClassExport, pcc, parent, true, out IEntry result); // if (relinkResults?.Count > 0) // { // ListDialog ld = new ListDialog(relinkResults, "Relink report", "The following items failed to relink.", null); // ld.Show(); // } // return result; // } // catch (Exception e) // { // //remove added entries // var entriesToRemove = new List<IEntry>(); // for (int i = exportCount; i < pcc.Exports.Count; i++) // { // entriesToRemove.Add(pcc.Exports[i]); // } // for (int i = importCount; i < pcc.Imports.Count; i++) // { // entriesToRemove.Add(pcc.Imports[i]); // } // EntryPruner.TrashEntries(pcc, entriesToRemove); // pcc.restoreNames(nameListBackup); // return null; // } //} public static void ShowRelinkResults(List <EntryStringPair> results) { Application.Current.Dispatcher.Invoke(() => { ListDialog ld = new ListDialog(results, "Relink report", "The following items failed to relink.", null); ld.Show(); }); }
public static void OnWeatherCommand(BasePlayer sender) { var weatherListDialog = new ListDialog("Select weather type:", Messages.DialogButtonSelect, Messages.DialogButtonCancel); weatherListDialog.AddItem( "Normal\nStormy\nFoggy\nScorching Hot\nDull, cloudy, rainy\nSandstorm\nGreen Fog\nDark, cloudy, brown\nExtremely bright\nDark toxic clouds\nBlack & white sky"); weatherListDialog.Show(sender); weatherListDialog.Response += (objectSender, e) => { switch (e.ListItem) { case 0: Server.SetWeather(0); break; case 1: Server.SetWeather(8); break; case 2: Server.SetWeather(9); break; case 3: Server.SetWeather(11); break; case 4: Server.SetWeather(16); break; case 5: Server.SetWeather(19); break; case 6: Server.SetWeather(20); break; case 7: Server.SetWeather(33); break; case 8: Server.SetWeather(39); break; case 9: Server.SetWeather(43); break; case 10: Server.SetWeather(44); break; } }; }
public void Show() { if (charCreationMenu != null) { charCreationMenu.GetMenu().Ended += (sender, e) => { if (!(e.Data.ContainsKey("name") && e.Data.ContainsKey("age") && e.Data.ContainsKey("sex"))) { charCreationMenu.Show(player); return; } ServerDbContext dbContext = ((GameMode)GameMode.Instance).DbContext; dbContext.Accounts.Attach(player.AccountData); SpawnLocation chrSpawn = new SpawnLocation(); chrSpawn.Interior = 0; chrSpawn.VirtualWorld = 0; chrSpawn.X = 1762.1357f; chrSpawn.Y = -1862.8958f; chrSpawn.Z = 13.5757f; chrSpawn.RotX = 0f; chrSpawn.RotY = 0f; chrSpawn.RotZ = 269.4686f; Inventory inv = new Inventory(); inv.MaxSpace = Constants.CHARACTER_INVENTORY_SIZE; Character chr = new Character(); chr.Account = player.AccountData; chr.Name = (string)e.Data["name"]; chr.Age = (uint)e.Data["age"]; chr.Sex = (Character.CharSex)e.Data["sex"]; chr.Skin = 26; chr.SpawnLocation = chrSpawn; chr.Inventory = inv; chr.PermsSet = new PermissionSet(); chr.GroupOwner = new List <Group>(); chr.GroupRanks = new List <GroupRank>(); chr.BuildingOwner = new List <Building>(); player.ActiveCharacter = chr; dbContext.Add(chr); dbContext.SaveChanges(); player.SpawnCharacter(); }; charCreationMenu.Show(player); return; } charList.Show(player); }
public static void OnCarOptionCommand(BasePlayer sender) { if (!sender.IsDriving()) { sender.SendClientMessage(Color.Red, Messages.CommandAllowedOnlyAsDriver); return; } var carOptionsDialog = new ListDialog("Select option for your vehicle:", Messages.DialogButtonToggle, Messages.DialogButtonCancel); carOptionsDialog.AddItem("Engine\nLights\nAlarm\nDoors\nBonnet\nBoot\nObjective"); carOptionsDialog.Show(sender); carOptionsDialog.Response += (objectSender, e) => { if (e.DialogButton != DialogButton.Left) { return; } var playerVehicle = sender.Vehicle; switch (e.ListItem) { case 0: playerVehicle.Engine = !playerVehicle.Engine; break; case 1: playerVehicle.Lights = !playerVehicle.Lights; break; case 2: playerVehicle.Alarm = !playerVehicle.Alarm; break; case 3: playerVehicle.Doors = !playerVehicle.Doors; break; case 4: playerVehicle.Bonnet = !playerVehicle.Bonnet; break; case 5: playerVehicle.Boot = !playerVehicle.Boot; break; case 6: playerVehicle.Objective = !playerVehicle.Objective; break; } }; }
public static void Weapons(Player player) { var weapons = new ListDialog("Weapons", "Seleccionar", "Cerrar"); foreach (Gun gun in Gun.GetInstanceArray()) { weapons.AddItem(gun.Weapon.ToString()); } weapons.Show(player); weapons.Response += (sender, e) => { if (e.DialogButton == DialogButton.Left) { int gunIndex; /* Gets the weapon that the player selected in the dialog. */ var itemWeapon = Gun.GetWeapon(e.ListItem); /* Check if the weapon the player selected is not in their current weapon pack. */ if (player.ListGuns.Find(gun => gun == itemWeapon) != null) { player.SendClientMessage(Color.Red, $"Error: {itemWeapon.Weapon} ya se encuentra en el paquete de armas."); weapons.Show(player); return; } /* Check if there is no weapon with the same category in the player's weapon pack. */ if ((gunIndex = player.ListGuns.FindIndex(gun => gun.Slot == itemWeapon.Slot)) != -1) { player.ListGuns[gunIndex] = itemWeapon; } else { player.ListGuns.Add(itemWeapon); } player.GiveWeapon(itemWeapon.Weapon); player.SendClientMessage(Color.Red, $"[Weapon]: {Color.Yellow}{itemWeapon.Weapon} se agregó en tu paquete de armas."); weapons.Show(player); } }; }
public static void OnConvoyCommand(Player sender) { if (sender.PlayerClass != PlayerClassType.TruckDriver) { sender.SendClientMessage(Color.Red, Messages.CommandOnlyAllowedAsTruckDriver); return; } var convoyStatus = string.Empty; var convoyListDialog = new ListDialog("Select convoy:", Messages.DialogButtonSelect, Messages.DialogButtonCancel); foreach (var convoy in MissionConvoy.Convoys) { string leaderName; int memberCount; if (convoy.Status == ConvoyStatus.Empty) { memberCount = 0; leaderName = "None"; convoyStatus = "Empty"; } else { memberCount = convoy.Members.Count; leaderName = convoy.Members[0].Name; switch (convoy.Status) { case ConvoyStatus.Open: convoyStatus = "Open"; break; case ConvoyStatus.Closed: convoyStatus = "Closed"; break; case ConvoyStatus.Full: convoyStatus = "Full"; break; } } convoyListDialog.AddItem( $"Leader: {{00FF00}}{leaderName}{{FFFFFF}}, members: {{FF0000}}{memberCount}{{FFFFFF}}, Status: {{00FF00}}{convoyStatus}{{FFFFFF}}"); } convoyListDialog.Show(sender); convoyListDialog.Response += ConvoyController.ConvoyListDialog_Response; }
private void ShowCheckpointEventDialog() { ListDialog cpEventDialog = new ListDialog("Checkpoint events", "Select", "Cancel"); if (editingRace.checkpoints[checkpointIndex].NextVehicle == null) { cpEventDialog.AddItem("Vehicle event [None]"); } else { cpEventDialog.AddItem("Vehicle event [" + editingRace.checkpoints[checkpointIndex].NextVehicle.ToString() + "]"); } cpEventDialog.Show(player); cpEventDialog.Response += CpEventDialog_Response; }
public static void DialogListCommand(GtaPlayer player, string items) { var dialog = new ListDialog("Captions", "OK!"); foreach (var i in items.Split(' ').Where(s => !string.IsNullOrWhiteSpace(s))) { dialog.Items.Add(i); } dialog.Show(player); dialog.Response += (sender, args) => { player.SendClientMessage("Response: " + args.ListItem); }; }
public static void TopTen(Player player) { var dialogTop = new ListDialog("Top Ten", "Seleccionar", "Cerrar"); var topten = new Top() { Sender = player, DialogMain = dialogTop }; dialogTop.AddItems(new[] { "Total Kills", "Total Deaths", "Killing Sprees", "Headshots", "Dropped Flags" }); dialogTop.Response += (sender, e) => { if (e.DialogButton == DialogButton.Left) { switch (e.ListItem) { case 0: topten.ShowTopTen("totalKills", "Total Kills"); break; case 1: topten.ShowTopTen("totalDeaths", "Total Deaths"); break; case 2: topten.ShowTopTen("killingSprees", "Killing Sprees"); break; case 3: topten.ShowTopTen("headshots", "Headshots"); break; case 4: topten.ShowTopTen("droppedFlags", "Dropped Flags"); break; } } }; dialogTop.Show(player); }
public static void ShowAdminDialog(Player player, Player receiver = null) { listAdmin = new ListDialog("Administration", "Sélectionner", "Quitter"); listAdmin.AddItem("Modération"); listAdmin.AddItem("Donner"); listAdmin.AddItem("Véhicule"); listAdmin.AddItem("Permissions"); listAdmin.Show(player); listAdmin.Response += (sender, EventArgs) => { if (EventArgs.DialogButton == SampSharp.GameMode.Definitions.DialogButton.Right) { return; } switch (EventArgs.ListItem) { case 0: { ShowModerationDialog(player, receiver); break; } case 1: { ShowGiveDialog(player); break; } case 2: { ShowVehicleDialog(player); break; } case 3: { ShowPermsDialog(player); break; } default: return; } }; }
public static void OnConvoyMembersCommand(Player sender) { if (!sender.IsInConvoy) { sender.SendClientMessage(Color.Red, Messages.PlayerNotPartOfAnyConvoy); return; } var convoy = sender.Convoy; var membersListDialog = new ListDialog("Convoy members:", Messages.DialogButtonOk); foreach (var member in convoy.Members) { membersListDialog.AddItem($"{member.Name}\n"); } membersListDialog.Show(sender); }
public static void OnGoBaseCommand(Player sender) { if (sender.State != PlayerState.OnFoot) { sender.SendClientMessage(Color.Red, Messages.MustBeOnFoot); return; } if (sender.Account.Wanted != 0) { sender.SendClientMessage(Color.Red, Messages.MustBeInnocent); return; } if (sender.IsDoingMission) { sender.SendClientMessage(Color.Red, Messages.CommandOnlyIfNotDoingAJob); return; } if (sender.Account.Jailed != 0) { sender.SendClientMessage(Color.Red, Messages.CommandOnlyIfNotJailed); return; } var dialogSpawns = new ListDialog("Select your spawn", "Select", "Cancel"); var spawns = new ClassSpawnRepository(ConnectionFactory.GetConnection).GetAllByClassType((int)sender.PlayerClass); switch (sender.PlayerClass) { default: foreach (var spawn in spawns) { dialogSpawns.AddItem($"{spawn.Name}"); } dialogSpawns.Response += (senderObject, e) => DialogSpawns_Response(senderObject, e, sender.PlayerClass); break; } dialogSpawns.Show(sender); }
public void ShowCreateEventSearchDialog(Player player, EventType eventType, string str) { Dictionary <string, string> row; Dictionary <string, object> param = new Dictionary <string, object> { { "@name", str } }; GameMode.mySQLConnector.OpenReader("SELECT race_id, race_name FROM races WHERE race_name LIKE @name", param); row = GameMode.mySQLConnector.GetNextRow(); if (row.Count == 0) { player.Notificate("No race found"); GameMode.mySQLConnector.CloseReader(); ShowCreateEventNameDialog(player, eventType); } else { List <int> foundRaces = new List <int>(); ListDialog eventSearchDialog = new ListDialog("Found races", "Launch", "Cancel"); while (row.Count > 0) { foundRaces.Add(Convert.ToInt32(row["race_id"])); eventSearchDialog.AddItem(row["race_id"] + "_" + row["race_name"]); row = GameMode.mySQLConnector.GetNextRow(); } eventSearchDialog.Show(player); eventSearchDialog.Response += (sender, eventArgs) => { if (eventArgs.DialogButton == DialogButton.Left) { CreateEvent(player, eventType, foundRaces[eventArgs.ListItem]); } else { player.Notificate("Cancelled"); ShowCreateEventTypeDialog(player); } }; GameMode.mySQLConnector.CloseReader(); } }
public static void OnReportsCommand(BasePlayer sender) { if (Report.Reports[0].IsEmpty) { sender.SendClientMessage(Color.Red, Messages.NoReports); return; } var reportsDialog = new ListDialog("Reports list:", "Ok"); foreach (var report in Report.Reports) { if (!report.IsEmpty) { reportsDialog.AddItem($"{report.OffenderName}: {report.Reason}"); } } reportsDialog.Show(sender); }
public void Show(Player player) { ListDialog dialog = new ListDialog(Title, "Sélectionner", CanQuit ? "Quitter" : null); foreach (Field f in fields) { if (datas.ContainsKey(f.Dataname)) { dialog.AddItem(Color.Green + f.Title); } else { dialog.AddItem(Color.Red + f.Title); } } dialog.AddItem(ContinueButton); dialog.Response += DialogResponse; dialog.Show(player); }
private void ShowRaceDialog() { ListDialog raceDialog = new ListDialog("Race options", "Select", "Cancel"); raceDialog.AddItem("Select starting vehicle [" + editingRace.StartingVehicle + "]"); raceDialog.AddItem("Edit race name"); if (editingRace.startingSpawn[0].Position == Vector3.Zero) { raceDialog.AddItem("Set spawn positions"); } else { raceDialog.AddItem("Edit spawn position"); } raceDialog.AddItem("Lap: " + editingRace.Laps); raceDialog.Show(player); raceDialog.Response += RaceDialog_Response; }
public void Show(BasePlayer player) { menuDialog.Items.Clear(); if (continueItem != null) { if (menuItems.Contains(continueItem)) { menuItems.Remove(continueItem); } this.AddItem(continueItem); } foreach (var menuItem in menuItems) { menuDialog.AddItem(menuItem.Name); } menuDialog.Show(player); }
public static void DialogBusDriverMission_Response(object sender, DialogResponseEventArgs e) { if (e.DialogButton != SampSharp.GameMode.Definitions.DialogButton.Left) { return; } if (!(e.Player is Player player)) { return; } if (player.IsDoingMission) { player.SendClientMessage(Color.Red, Messages.AlreadyDoingAMission); return; } var selectRouteDialog = new ListDialog("Select busroute: ", Messages.DialogButtonSelect, Messages.DialogButtonCancel); switch (e.ListItem) { case 0: foreach (var busRoute in BusRoute.BusRoutes) { selectRouteDialog.AddItem($"Line {busRoute.LineNumber} ({busRoute.Description})\n"); } selectRouteDialog.Show(player); selectRouteDialog.Response += SelectRouteDialog_Response; break; case 1: var random = new Random(); StartMission(player, BusRoute.BusRoutes[random.Next(BusRoute.BusRoutes.Count)]); break; } }
public static void MissionDialogResponse(object sender, DialogResponseEventArgs e) { if (e.DialogButton != DialogButton.Left) { return; } var playerVehicleModel = e.Player.Vehicle?.Model; var playerVehicleTrailerModel = e.Player.Vehicle?.Trailer?.Model; switch (e.ListItem) { case 0: var cargoList = GetMissionCargoes(playerVehicleModel, playerVehicleTrailerModel); if (cargoList == null) { return; } var dialogCargoSelect = new ListDialog(Messages.MissionTruckerDialogSelectLoad, Messages.DialogButtonSelect, Messages.DialogButtonCancel); foreach (var cargo in cargoList) { dialogCargoSelect.AddItem(cargo.Name); } dialogCargoSelect.Show(e.Player); dialogCargoSelect.Response += DialogCargoSelect_Response; break; case 1: StartRandomMission((Player)e.Player); break; } }
private void findExportsWithSerialSizeMismatchToolStripMenuItem_Click(object sender, EventArgs e) { List <string> serialexportsbad = new List <string>(); foreach (IExportEntry entry in pcc.Exports) { Console.WriteLine(entry.Index + " " + entry.Data.Length + " " + entry.DataSize); if (entry.Data.Length != entry.DataSize) { serialexportsbad.Add(entry.GetFullPath + " Header lists: " + entry.DataSize + ", Actual data size: " + entry.Data.Length); } } if (serialexportsbad.Count > 0) { ListDialog lw = new ListDialog(serialexportsbad, "Serial Size Mismatches", "The following exports had serial size mismatches."); lw.Show(); } else { System.Windows.MessageBox.Show("No exports have serial size mismatches."); } }
private static void DialogCargoSelect_Response(object sender, DialogResponseEventArgs e) { if (e.DialogButton != DialogButton.Left) { return; } var playerVehicleModel = e.Player.Vehicle?.Model; var playerVehicleTrailerModel = e.Player.Vehicle?.Trailer?.Model; if (!(e.Player is Player player)) { return; } var cargoList = GetMissionCargoes(playerVehicleModel, playerVehicleTrailerModel); var dialogSelectStartLocation = new ListDialog(Messages.MissionTruckerSelectStartingLocation, Messages.DialogButtonSelect, Messages.DialogButtonCancel); player.MissionCargo = cargoList[e.ListItem]; foreach (var startLocationIndex in player.MissionCargo.FromLocations) { if (startLocationIndex != 0) { dialogSelectStartLocation.AddItem(MissionLocation.MissionLocations[startLocationIndex].Name); } else { break; } } dialogSelectStartLocation.Show(e.Player); dialogSelectStartLocation.Response += DialogSelectStartLocation_Response; }
private static void DialogSelectStartLocation_Response(object sender, DialogResponseEventArgs e) { if (e.DialogButton != DialogButton.Left) { return; } if (!(e.Player is Player player)) { return; } var cargo = player.MissionCargo; var startLocationIndex = player.MissionCargo.FromLocations[e.ListItem]; player.FromLocation = MissionLocation.MissionLocations[startLocationIndex]; var dialogSelectEndLocation = new ListDialog(Messages.MissionTruckerSelectEndingLocation, Messages.DialogButtonSelect, Messages.DialogButtonCancel); for (var i = 0; i < cargo.ToLocations.Length; i++) { var endLocationIndex = player.MissionCargo.ToLocations[i]; if (endLocationIndex != 0) { dialogSelectEndLocation.AddItem(MissionLocation.MissionLocations[endLocationIndex].Name); } else { break; } } dialogSelectEndLocation.Show(e.Player); dialogSelectEndLocation.Response += DialogSelectEndLocation_Response; }
public void ShowEventOptionDialog(Player player, Event evt) { ListDialog managerOptionDialog = new ListDialog(evt.Name, "Select", "Cancel"); if (evt.Status == EventStatus.Loaded) { managerOptionDialog.AddItem("Open event to players"); } if (evt.Status == EventStatus.Waiting) { managerOptionDialog.AddItem("Start event"); } managerOptionDialog.AddItem(Color.Red + "Abort event"); managerOptionDialog.Show(player); managerOptionDialog.Response += (sender, eventArgs) => { if (eventArgs.DialogButton == DialogButton.Left) { if (eventArgs.ListItem == 0) // Open / Start { if (evt.Status == EventStatus.Loaded) { evt.Open(); } if (evt.Status == EventStatus.Waiting) { evt.Start(); } } else if (eventArgs.ListItem == 1) // Abort { evt.End(); } } }; }