Skip to content

Commit e840937

Browse files
feature: unequip item by slot (AscensionGameDev#2256)
* feature: unequip by slot - Adds ability to unequip items by slots * fix: unequip options enabled - as long as mMyCommand.Unequip is true, both unequip options should be enabled, they shouldn't disable each other --------- Co-authored-by: Arufonsu <[email protected]>
1 parent 2ea98c9 commit e840937

File tree

7 files changed

+320
-104
lines changed

7 files changed

+320
-104
lines changed

Intersect (Core)/GameObjects/Events/Commands/EventCommands.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,12 @@ public partial class EquipItemCommand : EventCommand
482482

483483
public Guid ItemId { get; set; }
484484

485+
public int Slot { get; set; }
486+
485487
public bool Unequip { get; set; }
486488

489+
public bool IsItem { get; set; } = true;
490+
487491
public bool TriggerCooldown { get; set; }
488492

489493
}

Intersect.Editor/Forms/Editors/Events/CommandPrinter.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,25 @@ private static string GetCommandText(ChangeItemsCommand command, MapInstance map
864864

865865
private static string GetCommandText(EquipItemCommand command, MapInstance map)
866866
{
867-
return command.Unequip ? Strings.EventCommandList.unequipitem.ToString(ItemBase.GetName(command.ItemId)) : Strings.EventCommandList.equipitem.ToString(ItemBase.GetName(command.ItemId));
867+
var commandText = string.Empty;
868+
869+
if(!command.Unequip)
870+
{
871+
commandText = Strings.EventCommandList.equipitem.ToString(ItemBase.GetName(command.ItemId));
872+
}
873+
else
874+
{
875+
if (command.IsItem)
876+
{
877+
commandText = Strings.EventCommandList.unequipitem.ToString(ItemBase.GetName(command.ItemId));
878+
}
879+
else
880+
{
881+
commandText = Strings.EventCommandList.unequipslot.ToString(Options.EquipmentSlots[command.Slot]);
882+
}
883+
}
884+
885+
return commandText;
868886
}
869887

870888
private static string GetCommandText(ChangeSpriteCommand command, MapInstance map)

Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_EquipItem.Designer.cs

Lines changed: 130 additions & 95 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Intersect.Editor/Forms/Editors/Events/Event Commands/EventCommand_EquipItem.cs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,30 @@ public EventCommandEquipItems(EquipItemCommand refCommand, FrmEvent editor)
2626
cmbItem.Items.AddRange(ItemBase.Names);
2727
cmbItem.SelectedIndex = ItemBase.ListIndex(mMyCommand.ItemId);
2828
chkUnequip.Checked = mMyCommand.Unequip;
29+
optUnequipItem.Enabled = mMyCommand.Unequip;
30+
optUnequipItem.Checked = mMyCommand.Unequip && mMyCommand.IsItem;
31+
optUnequipSlot.Enabled = mMyCommand.Unequip;
32+
optUnequipSlot.Checked = mMyCommand.Unequip && !mMyCommand.IsItem;
2933
chkTriggerCooldown.Checked = mMyCommand.TriggerCooldown;
3034
}
3135

3236
private void InitLocalization()
3337
{
3438
grpEquipItem.Text = Strings.EventEquipItems.title;
35-
chkUnequip.Text = Strings.EventEquipItems.unequip;
3639
chkTriggerCooldown.Text = Strings.EventEquipItems.TriggerCooldown;
40+
chkUnequip.Text = Strings.EventEquipItems.unequip;
41+
optUnequipItem.Text = Strings.EventEquipItems.item;
42+
optUnequipSlot.Text = Strings.EventEquipItems.slot;
3743
btnSave.Text = Strings.EventEquipItems.okay;
3844
btnCancel.Text = Strings.EventEquipItems.cancel;
3945
}
4046

4147
private void btnSave_Click(object sender, EventArgs e)
4248
{
43-
mMyCommand.ItemId = ItemBase.IdFromList(cmbItem.SelectedIndex);
49+
mMyCommand.ItemId = optUnequipItem.Checked || !chkUnequip.Checked ? ItemBase.IdFromList(cmbItem.SelectedIndex) : Guid.Empty;
50+
mMyCommand.Slot = optUnequipSlot.Checked ? cmbItem.SelectedIndex : -1;
4451
mMyCommand.Unequip = chkUnequip.Checked;
52+
mMyCommand.IsItem = optUnequipItem.Checked;
4553
mMyCommand.TriggerCooldown = chkTriggerCooldown.Checked;
4654
mEventEditor.FinishCommandEdit();
4755
}
@@ -57,12 +65,34 @@ private void chkUnequip_CheckedChanged(object sender, EventArgs e)
5765
{
5866
chkTriggerCooldown.Checked = false;
5967
chkTriggerCooldown.Enabled = false;
68+
optUnequipItem.Checked = mMyCommand.IsItem;
69+
optUnequipItem.Enabled = true;
70+
optUnequipSlot.Checked = !mMyCommand.IsItem;
71+
optUnequipSlot.Enabled = true;
6072
}
6173
else
6274
{
6375
chkTriggerCooldown.Enabled = true;
76+
optUnequipItem.Checked = false;
77+
optUnequipItem.Enabled = false;
78+
optUnequipSlot.Checked = false;
79+
optUnequipSlot.Enabled = false;
80+
UpdateUnequipOptions();
6481
}
6582
}
83+
84+
private void optUnequipSlot_CheckedChanged(object sender, EventArgs e)
85+
{
86+
UpdateUnequipOptions();
87+
}
88+
89+
private void UpdateUnequipOptions()
90+
{
91+
cmbItem.Items.Clear();
92+
cmbItem.Items.AddRange(optUnequipItem.Checked || !chkUnequip.Checked ? ItemBase.Names : Options.EquipmentSlots.ToArray());
93+
cmbItem.SelectedIndex = cmbItem.Items.Count > 0 ? 0 : -1;
94+
lblItem.Text = optUnequipItem.Checked || !chkUnequip.Checked ? Strings.EventEquipItems.item : Strings.EventEquipItems.slot;
95+
}
6696
}
6797

6898
}

0 commit comments

Comments
 (0)