//this performs an automatic sweep of all items in the user's backpack, and fills the the list entry with the items if it is possible public void FillFromBackpack(Mobile from) { if (from == null || from.Backpack == null) { return; } //generate a list of all items in the backpack List <Item> packitems = ItemStore.RecurseFindItemsInPack(from.Backpack); //go through backpack list, and try to add the items foreach (Item item in packitems) { AddItem(null, item); } //resend the store gump after it's all done if (!ItemStoreGump.RefreshGump(from)) { //send a new store gump if there's no existing one up from.SendGump(new ItemStoreGump(from, Store)); } //resend the item list entry gump after it's all done if (!ListEntryGump.RefreshGump(from)) { //send a new list entry gump if there's no existing one up from.SendGump(new ListEntryGump(from, this)); } }
//this produces a clone of the specified ItemStore public static ItemStore Clone(ItemStore store) { //create a new itemstore and populate its store entry list with a clone of the store entry list belonging to the source store ItemStore newstore = new ItemStore(StoreEntry.CloneList(store.StoreEntries)); newstore.ExpelStoreEntries = StoreEntry.CloneList(store.ExpelStoreEntries); newstore.Label = store.Label; newstore.Dynamic = store.Dynamic; newstore.OfferDeeds = store.OfferDeeds; newstore.WithdrawAmount = store.WithdrawAmount; newstore.MinWithdrawAmount = store.MinWithdrawAmount; newstore.LootType = store.LootType; newstore.Insured = store.Insured; newstore.LockWithdrawalAmount = store.LockWithdrawalAmount; newstore.DisplayColumns = store.DisplayColumns; //this is reset to the new containing object after the cloning process is complete. newstore.Owner = store.Owner; foreach (StoreEntry entry in store.StoreEntries) { entry.Store = newstore; } return(newstore); }
public static bool RefreshGump( Mobile player, ItemStore store ) { //if this mobile has an item store gump up if( player.HasGump( typeof( ItemStoreGump ) ) ) { ItemStoreGump gump = (ItemStoreGump)player.FindGump( typeof( ItemStoreGump ) ); //if this gump that's up is showing this store, or if no store was specified if( store == null || gump.Store == store ) { //then, resend this gump! player.SendGump( new ItemStoreGump( gump ) ); return true; } } return false; }
//master constructor, with page number specified public ItemStoreGump( Mobile owner, ItemStore store, int page ) : base(50, 50) { if( !( owner is PlayerMobile ) ) { return; } _Owner = (PlayerMobile)owner; _Store = store; //clear old gumps that are up _Owner.CloseGump( typeof( ItemStoreGump ) ); //set up the page AddPage(0); _Page = page; //determine page layout, sizes, and what gets displayed where DeterminePageLayout(); AddBackground(0, 0, _Width, _Height, 9270); AddImageTiled(11, 10, _Width - 23, _Height - 20, 2624); //old width -16 //AddAlphaRegion(8, 10, _Width - 20, _Height - 20); AddAlphaRegion(11, 10, _Width - 22, _Height - 20); AddTitle(); if( !AddStoreListing() ) { //clear old gumps that are up _Owner.CloseGump( typeof( ItemStoreGump ) ); return; } if( _MaxPages > 1 ) { AddPageButtons(); } AddControlButtons(); }
//base constructor for custom defined keys public BaseStoreKey( ItemStore Store, int hue ) : base( ITEM_ID ) { if( Store == null ) { //this makes a call to an overloadable function, so any derived object that is constructed gets the store entries loaded here _Store = GenerateItemStore(); } else { //connect the specified item store to this new set of keys _Store = Store; } //let the item store know that this keyring is its containing object _Store.Owner = this; _Store.MinWithdrawAmount = 1; Hue = hue; Weight = 1; }
public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); switch( version ) { case 0: default: { int count = reader.ReadInt(); for( int i = 0; i < count; i++ ) { ItemStore store = new ItemStore( reader ); Stores.Add( store ); store.Owner = this; //TODO: handle exceptions Type keytype = ScriptCompiler.FindTypeByName( reader.ReadString() ); KeyTypes.Add( keytype ); //handle synchronization between store and entry listing within the KeyType try { BaseStoreKey synchkey = (BaseStoreKey)Activator.CreateInstance( keytype ); store.SynchronizeStore( synchkey.EntryStructure ); store.DisplayColumns = synchkey.DisplayColumns; synchkey.Delete(); } catch { } } break; } } }
ItemStore _Store; //reference the store //constructor public AddItemTarget(ItemStore store) : base(1, false, TargetFlags.None) { _Store = store; }
//this allows to explicitly reset the store contents public void SetStore( ItemStore newstore ) { _Store = newstore; }
public override void Deserialize( GenericReader reader ) { base.Deserialize( reader ); int version = reader.ReadInt(); switch( version ) { case 1: { _SecureLevel = (SecureLevel)reader.ReadInt(); goto case 0; } case 0: default: { if( reader.ReadBool() ) { _Store = new ItemStore( reader ); //this makes sure the script listing synchronizes with the saved keys _Store.SynchronizeStore( EntryStructure ); //synch up the display column number from the item definition with the store _Store.DisplayColumns = DisplayColumns; //reference this item so the store can connect back to this _Store.Owner = this; } break; } } }
//the basic initialization of the item store protected virtual ItemStore GenerateItemStore() { //load the item entry structure. Note that contents is specific because EntryStructure can be //overloaded in child entities ItemStore newstore = new ItemStore( StoreEntry.CloneList( EntryStructure ) ); //write the new display column number to the store newstore.DisplayColumns = DisplayColumns; newstore.RegisterEntries(); return newstore; }
//default first page constructor public ItemStoreGump( Mobile owner, ItemStore store ) : this(owner, store, 0) { }
//this produces a clone of the specified ItemStore public static ItemStore Clone( ItemStore store ) { //create a new itemstore and populate its store entry list with a clone of the store entry list belonging to the source store ItemStore newstore = new ItemStore( StoreEntry.CloneList( store.StoreEntries ) ); newstore.ExpelStoreEntries = StoreEntry.CloneList( store.ExpelStoreEntries ); newstore.Label = store.Label; newstore.Dynamic = store.Dynamic; newstore.OfferDeeds = store.OfferDeeds; newstore.WithdrawAmount = store.WithdrawAmount; newstore.MinWithdrawAmount = store.MinWithdrawAmount; newstore.LootType = store.LootType; newstore.Insured = store.Insured; newstore.LockWithdrawalAmount = store.LockWithdrawalAmount; newstore.DisplayColumns = store.DisplayColumns; //this is reset to the new containing object after the cloning process is complete. newstore.Owner = store.Owner; foreach( StoreEntry entry in store.StoreEntries ) { entry.Store = newstore; } return newstore; }
ItemStore _Store; //reference the store //constructor public AddItemTarget( ItemStore store ) : base ( 1, false, TargetFlags.None ) { _Store = store; }