Skip to content

Commit

Permalink
Implemented Bank/Unbank in SaveEdit.
Browse files Browse the repository at this point in the history
  • Loading branch information
gibbed committed Jul 20, 2017
1 parent a5666ca commit 7f36895
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 11 deletions.
18 changes: 18 additions & 0 deletions projects/Gibbed.Borderlands2.FileFormats/Items/BackpackItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ namespace Gibbed.Borderlands2.FileFormats.Items
{
public class BackpackItem : BaseItem, IBackpackSlot
{
public BackpackItem()
{
}

public BackpackItem(BackpackItem other)
: base(other)
{
this.Quantity = other.Quantity;
this.Equipped = other.Equipped;
this.Mark = other.Mark;
}

public BackpackItem(BaseItem other)
: base(other)
{

}

#region Fields
private int _Quantity = 1;
private bool _Equipped;
Expand Down
16 changes: 16 additions & 0 deletions projects/Gibbed.Borderlands2.FileFormats/Items/BackpackWeapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,22 @@ namespace Gibbed.Borderlands2.FileFormats.Items
{
public sealed class BackpackWeapon : BaseWeapon, IBackpackSlot
{
public BackpackWeapon()
{
}

public BackpackWeapon(BackpackWeapon other)
: base(other)
{
this.QuickSlot = other.QuickSlot;
this.Mark = other.Mark;
}

public BackpackWeapon(BaseWeapon other)
: base(other)
{
}

#region Fields
private QuickWeaponSlot _QuickSlot = QuickWeaponSlot.None;
private PlayerMark _Mark = PlayerMark.Standard;
Expand Down
26 changes: 26 additions & 0 deletions projects/Gibbed.Borderlands2.FileFormats/Items/BaseItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,32 @@ namespace Gibbed.Borderlands2.FileFormats.Items
{
public class BaseItem : IPackableItem, INotifyPropertyChanged
{
public BaseItem()
{
}

public BaseItem(BaseItem other)
{
this.Type = other.Type;
this.Balance = other.Balance;
this.Manufacturer = other.Manufacturer;
this.ManufacturerGradeIndex = other.ManufacturerGradeIndex;
this.AlphaPart = other.AlphaPart;
this.BetaPart = other.BetaPart;
this.GammaPart = other.GammaPart;
this.DeltaPart = other.DeltaPart;
this.EpsilonPart = other.EpsilonPart;
this.ZetaPart = other.ZetaPart;
this.EtaPart = other.EtaPart;
this.ThetaPart = other.ThetaPart;
this.MaterialPart = other.MaterialPart;
this.PrefixPart = other.PrefixPart;
this.TitlePart = other.TitlePart;
this.GameStage = other.GameStage;
this.UniqueId = other.UniqueId;
this.AssetLibrarySetId = other.AssetLibrarySetId;
}

#region Fields
private string _Type = "None";
private string _Balance = "None";
Expand Down
28 changes: 28 additions & 0 deletions projects/Gibbed.Borderlands2.FileFormats/Items/BaseWeapon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,32 @@ namespace Gibbed.Borderlands2.FileFormats.Items
{
public class BaseWeapon : IPackableWeapon, INotifyPropertyChanged
{
public BaseWeapon()
{
}

public BaseWeapon(BaseWeapon other)
{
this.Type = other.Type;
this.Balance = other.Balance;
this.Manufacturer = other.Manufacturer;
this.ManufacturerGradeIndex = other.ManufacturerGradeIndex;
this.BodyPart = other.BodyPart;
this.GripPart = other.GripPart;
this.BarrelPart = other.BarrelPart;
this.SightPart = other.SightPart;
this.StockPart = other.StockPart;
this.ElementalPart = other.ElementalPart;
this.Accessory1Part = other.Accessory1Part;
this.Accessory2Part = other.Accessory2Part;
this.MaterialPart = other.MaterialPart;
this.PrefixPart = other.PrefixPart;
this.TitlePart = other.TitlePart;
this.GameStage = other.GameStage;
this.UniqueId = other.UniqueId;
this.AssetLibrarySetId = other.AssetLibrarySetId;
}

#region Fields
private string _Type = "None";
private string _Balance = "None";
Expand All @@ -48,6 +74,7 @@ public class BaseWeapon : IPackableWeapon, INotifyPropertyChanged
private int _AssetLibrarySetId;
#endregion

#region IPackable Members
public void Unpack(PackedWeapon packed, Platform platform)
{
var alm = InfoManager.AssetLibraryManager;
Expand Down Expand Up @@ -99,6 +126,7 @@ public PackedWeapon Pack(Platform platform)
TitlePart = alm.Lookup(this.TitlePart, platform, this.AssetLibrarySetId, AssetGroup.WeaponParts)
};
}
#endregion

#region Properties
public string Type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ internal class BackpackItemViewModel : BaseItemViewModel, IBackpackSlotViewModel
{
private readonly BackpackItem _Item;

public IBackpackSlot BackpackSlot
{
get { return this._Item; }
}

public BackpackItemViewModel(BackpackItem item)
: base(item)
{
Expand All @@ -47,6 +42,16 @@ public BackpackItemViewModel(BackpackItem item)
}

#region Properties
public IBackpackSlot BackpackSlot
{
get { return this._Item; }
}

public BackpackItem Item
{
get { return this._Item; }
}

public int Quantity
{
get { return this._Item.Quantity; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@ internal class BackpackWeaponViewModel : BaseWeaponViewModel, IBackpackSlotViewM
{
private readonly BackpackWeapon _Weapon;

public BackpackWeaponViewModel(BackpackWeapon weapon)
: base(weapon)
{
this._Weapon = weapon;
}

#region Properties
public IBackpackSlot BackpackSlot
{
get { return this._Weapon; }
}

public BackpackWeaponViewModel(BackpackWeapon weapon)
: base(weapon)
public BackpackWeapon Weapon
{
this._Weapon = weapon;
get { return this._Weapon; }
}

#region Properties
public QuickWeaponSlot QuickSlot
{
get { return this._Weapon.QuickSlot; }
Expand Down
2 changes: 2 additions & 0 deletions projects/Gibbed.Borderlands2.SaveEdit/Tabs/BackpackView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
[Shortcut Delete] = [Action DeleteSelectedSlot];
[Shortcut Control+C] = [Action CopySelectedSlotCode];
[Shortcut Control+D] = [Action DuplicateSelectedSlot];
[Shortcut Control+B] = [Action BankSelectedSlot];
</cal:Message.Attach>
<ListView.GroupStyle>
<GroupStyle>
Expand Down Expand Up @@ -188,6 +189,7 @@
Height="16" />
</MenuItem.Icon>
<MenuItem.Header>Bank</MenuItem.Header>
<MenuItem.InputGestureText>Ctrl+B</MenuItem.InputGestureText>
<cal:Message.Attach>BankSelectedSlot</cal:Message.Attach>
</MenuItem>
<Separator />
Expand Down
17 changes: 16 additions & 1 deletion projects/Gibbed.Borderlands2.SaveEdit/Tabs/BackpackViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,22 @@ public void DuplicateSelectedSlot()

public void BankSelectedSlot()
{
// TODO: implement me
if (this.SelectedSlot == null)
{
return;
}

var slot = this.SelectedSlot.BackpackSlot;
this.Slots.Remove(this.SelectedSlot);

if (slot is BaseItem)
{
this.Bank.Slots.Add(new BaseItemViewModel(new BaseItem((BaseItem)slot)));
}
else if (slot is BaseWeapon)
{
this.Bank.Slots.Add(new BaseWeaponViewModel(new BaseWeapon((BaseWeapon)slot)));
}
}

public void DeleteSelectedSlot()
Expand Down
2 changes: 2 additions & 0 deletions projects/Gibbed.Borderlands2.SaveEdit/Tabs/BankView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
[Shortcut Delete] = [Action DeleteSelectedSlot];
[Shortcut Control+C] = [Action CopySelectedSlotCode];
[Shortcut Control+D] = [Action DuplicateSelectedSlot];
[Shortcut Control+B] = [Action UnbankSelectedSlot];
</cal:Message.Attach>
<ListView.GroupStyle>
<GroupStyle>
Expand Down Expand Up @@ -180,6 +181,7 @@
Height="16" />
</MenuItem.Icon>
<MenuItem.Header>Unbank</MenuItem.Header>
<MenuItem.InputGestureText>Ctrl+B</MenuItem.InputGestureText>
<cal:Message.Attach>UnbankSelectedSlot</cal:Message.Attach>
</MenuItem>
<Separator />
Expand Down
17 changes: 16 additions & 1 deletion projects/Gibbed.Borderlands2.SaveEdit/Tabs/BankViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,22 @@ public void DuplicateSelectedSlot()

public void UnbankSelectedSlot()
{
// TODO: implement me
if (this.SelectedSlot == null)
{
return;
}

var slot = this.SelectedSlot.BaseSlot;
this.Slots.Remove(this.SelectedSlot);

if (slot is BaseItem)
{
this.Backpack.Slots.Add(new BackpackItemViewModel(new BackpackItem((BaseItem)slot)));
}
else if (slot is BaseWeapon)
{
this.Backpack.Slots.Add(new BackpackWeaponViewModel(new BackpackWeapon((BaseWeapon)slot)));
}
}

public void DeleteSelectedSlot()
Expand Down

0 comments on commit 7f36895

Please sign in to comment.