public void RefreshNpcList() { // Update the list incase npcs have been modified since form load. cmbNpc.Items.Clear(); cmbNpc.Items.AddRange(NpcBase.Names); // Add the map NPCs lstMapNpcs.Items.Clear(); for (var i = 0; i < Globals.CurrentMap.Spawns.Count; i++) { lstMapNpcs.Items.Add(NpcBase.GetName(Globals.CurrentMap.Spawns[i].NpcId)); } // Don't select if there are no NPCs, to avoid crashes. if (cmbNpc.Items.Count > 0) { cmbNpc.SelectedIndex = 0; } cmbDir.SelectedIndex = 0; rbRandom.Checked = true; if (lstMapNpcs.Items.Count > 0) { lstMapNpcs.SelectedIndex = 0; if (lstMapNpcs.SelectedIndex < Globals.CurrentMap.Spawns.Count) { cmbDir.SelectedIndex = (int)Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].Direction; cmbNpc.SelectedIndex = NpcBase.ListIndex(Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].NpcId); if (Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].X >= 0) { rbDeclared.Checked = true; } } } }
private void lstMapNpcs_Click(object sender, EventArgs e) { if (lstMapNpcs.Items.Count > 0 && lstMapNpcs.SelectedIndex > -1) { cmbNpc.SelectedIndex = NpcBase.ListIndex(Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].NpcId); cmbDir.SelectedIndex = (int)Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].Direction; if (Globals.CurrentMap.Spawns[lstMapNpcs.SelectedIndex].X >= 0) { rbDeclared.Checked = true; } else { rbRandom.Checked = true; } } }
public EventCommandSpawnNpc( FrmEvent eventEditor, MapBase currentMap, EventBase currentEvent, SpawnNpcCommand editingCommand ) { InitializeComponent(); mMyCommand = editingCommand; mEventEditor = eventEditor; mEditingEvent = currentEvent; mCurrentMap = currentMap; InitLocalization(); cmbNpc.Items.Clear(); cmbNpc.Items.AddRange(NpcBase.Names); cmbNpc.SelectedIndex = NpcBase.ListIndex(mMyCommand.NpcId); if (mMyCommand.MapId != Guid.Empty) { cmbConditionType.SelectedIndex = 0; } else { cmbConditionType.SelectedIndex = 1; } nudWarpX.Maximum = Options.MapWidth; nudWarpY.Maximum = Options.MapHeight; UpdateFormElements(); switch (cmbConditionType.SelectedIndex) { case 0: //Tile spawn //Fill in the map cmb nudWarpX.Value = mMyCommand.X; nudWarpY.Value = mMyCommand.Y; cmbDirection.SelectedIndex = mMyCommand.Dir; break; case 1: //On/Around Entity Spawn mSpawnX = mMyCommand.X; mSpawnY = mMyCommand.Y; chkDirRelative.Checked = Convert.ToBoolean(mMyCommand.Dir); UpdateSpawnPreview(); break; } }
public QuestTaskEditor(QuestBase refQuest, QuestBase.QuestTask refTask) { if (refQuest == null) { Log.Warn($@"{nameof(refQuest)} is null."); } if (refTask == null) { Log.Warn($@"{nameof(refTask)} is null."); } InitializeComponent(); mMyTask = refTask; mMyQuest = refQuest; if (mMyTask?.EditingEvent == null) { Log.Warn($@"{nameof(mMyTask.EditingEvent)} is null."); } mEventBackup = mMyTask?.EditingEvent?.JsonData; InitLocalization(); cmbTaskType.SelectedIndex = mMyTask == null ? -1 : (int)mMyTask.Objective; txtStartDesc.Text = mMyTask?.Description; UpdateFormElements(); switch (cmbTaskType.SelectedIndex) { case 0: //Event Driven break; case 1: //Gather Items cmbItem.SelectedIndex = ItemBase.ListIndex(mMyTask?.TargetId ?? Guid.Empty); nudItemAmount.Value = mMyTask?.Quantity ?? 0; break; case 2: //Kill NPCS cmbNpc.SelectedIndex = NpcBase.ListIndex(mMyTask?.TargetId ?? Guid.Empty); nudNpcQuantity.Value = mMyTask?.Quantity ?? 0; break; } }