// AVA2 lock lines apply to every real item container; keep the seven-attribute base packet. static const char c_szAttrLockViewsScript[] = R"PY(# -*- coding: utf-8 -*- import exchange,shop,safebox,player,uiToolTip,uiEquipmentDialog,uiSafebox,game,weakref,mt_attr_lock as core Tip=uiToolTip.ItemToolTip _epochs={101:0,102:0,103:0,104:0,105:0,106:0} _visible={104:False,105:False} _tips=weakref.WeakKeyDictionary() def Invalidate(kinds): for kind in kinds:_epochs[kind]+=1 for tip in list(_tips.keys()): context=getattr(tip,'attrLockContext',None) if context and context[0] in kinds: tip.attrLockContext=None;tip.attrLockMask=0;tip.HideToolTip() def Triple(vnum,attribute,socket,epoch): return (vnum,tuple(attribute(i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)), tuple(socket(i) for i in xrange(player.METIN_SOCKET_MAX_NUM)),epoch) def Read(tip,cell,kind): if not tip:return None epoch=_epochs[kind] if kind in (101,102): if not exchange.isTrading():return None side='Self' if kind==101 else 'Target' return Triple(getattr(exchange,'GetItemVnumFrom'+side)(cell),lambda i:getattr(exchange,'GetItemAttributeFrom'+side)(cell,i),lambda i:getattr(exchange,'GetItemMetinSocketFrom'+side)(cell,i),epoch) if kind==103: if not shop.IsOpen():return None return Triple(shop.GetItemID(cell),lambda i:shop.GetItemAttribute(cell,i),lambda i:shop.GetItemMetinSocket(cell,i),epoch) if kind in (104,105): if not _visible[kind]:return None prefix='Get' if kind==104 else 'GetMall' return Triple(getattr(safebox,prefix+'ItemID')(cell),lambda i:getattr(safebox,prefix+'ItemAttribute')(cell,i),lambda i:getattr(safebox,prefix+'ItemMetinSocket')(cell,i),epoch) if kind==106: dialog=tip.attrLockViewOwner() if not dialog or not dialog.IsShow() or dialog.vid!=tip.attrLockVid:return None data=dialog.itemDataDict.get(cell) if not data:return None return (data[0],tuple(data[3]),tuple(data[2]),epoch) def Bind(tip,kind,cell,render,args,owner=None): # The original setter clears and draws the complete tooltip, including prices/flags. tip.attrLockRender=(render,args,weakref.ref(owner) if owner else None) tip.attrLockVid=owner.vid if owner else 0 tip.attrLockViewOwner=weakref.ref(owner) if owner else None snapshot=Read(tip,cell,kind) if not snapshot or not snapshot[0] or not any(a[0] for a in snapshot[1][:5]):return tip.attrLockContext=(kind,cell,snapshot);tip.attrLockMask=0 _tips[tip]=True;core.Query(tip) def Render(tip,cell): render,args,owner=tip.attrLockRender target=owner() if owner else tip if target:render(target,*args) for _kind in _epochs: core._views[_kind]=(lambda tip,cell,kind=_kind:Read(tip,cell,kind),Render) def WrapTip(name,kind): original=getattr(Tip,name) def Wrapped(self,cell,*args): self.ClearToolTip();self.HideToolTip() original(self,cell,*args) Bind(self,kind,cell,original,(cell,)+args) setattr(Tip,name,Wrapped) for _name,_kind in (('SetExchangeOwnerItem',101),('SetExchangeTargetItem',102),('SetShopItem',103),('SetShopItemBySecondaryCoin',103),('SetSafeBoxItem',104),('SetMallItem',105)): if hasattr(Tip,_name):WrapTip(_name,_kind) _builder=Tip.SetPrivateShopBuilderItem def Builder(self,window,cell,shopcell): self.ClearToolTip();self.HideToolTip() _builder(self,window,cell,shopcell) snapshot=core.Snapshot(window,cell) if snapshot[0] and any(a[0] for a in snapshot[1][:5]): # Register the original price-preserving renderer as a normal own-item context. self.attrLockContext=(window,cell,snapshot) self.attrLockBuilderRender=(_builder,(window,cell,shopcell)) core.Query(self) Tip.SetPrivateShopBuilderItem=Builder # Own-item rebuilding normally uses SetInventoryItem; retain the builder's selling price. _rebuild=core.Rebuild def Rebuild(self): builder=getattr(self,'attrLockBuilderRender',None) context=getattr(self,'attrLockContext',None) if builder and context and core.Snapshot(context[0],context[1],self)==context[2]: self.attrLockRendering=True try:builder[0](self,*builder[1]) finally:self.attrLockRendering=False else:_rebuild(self) core.Rebuild=Rebuild _clear=Tip.ClearToolTip def Clear(self): if not getattr(self,'attrLockRendering',False):self.attrLockBuilderRender=None return _clear(self) Tip.ClearToolTip=Clear _equip=uiEquipmentDialog.EquipmentDialog.OverInItem def Equipment(self,cell): if self.tooltipItem:self.tooltipItem.ClearToolTip();self.tooltipItem.HideToolTip() _equip(self,cell) if self.tooltipItem:Bind(self.tooltipItem,106,cell,_equip,(cell,),self) uiEquipmentDialog.EquipmentDialog.OverInItem=Equipment def Wrap(cls,name,kinds,visible=None): original=getattr(cls,name) def Wrapped(self,*args,**kwargs): Invalidate(kinds) result=original(self,*args,**kwargs) if visible is not None: for kind in kinds:_visible[kind]=visible return result setattr(cls,name,Wrapped) for _name in ('StartExchange','EndExchange','RefreshExchange'):Wrap(game.GameWindow,_name,(101,102)) for _name in ('StartShop','EndShop','RefreshShop'):Wrap(game.GameWindow,_name,(103,)) Wrap(uiSafebox.SafeboxWindow,'ShowWindow',(104,),True) Wrap(uiSafebox.SafeboxWindow,'CommandCloseSafebox',(104,),False) Wrap(uiSafebox.MallWindow,'ShowWindow',(105,),True) Wrap(uiSafebox.MallWindow,'CommandCloseMall',(105,),False) for _name in ('Open','Close','SetEquipmentDialogItem','SetEquipmentDialogSocket','SetEquipmentDialogAttr'): Wrap(uiEquipmentDialog.EquipmentDialog,_name,(106,)) _close=game.GameWindow.Close def Close(self): Invalidate(tuple(_epochs));_visible[104]=False;_visible[105]=False return _close(self) game.GameWindow.Close=Close )PY";