forked from metin2/client
Added game files from TMP4
This commit is contained in:
@ -12,6 +12,7 @@ import ui
|
||||
import uiCommon
|
||||
import mouseModule
|
||||
import localeInfo
|
||||
import constInfo
|
||||
|
||||
###################################################################################################
|
||||
## Shop
|
||||
@ -28,16 +29,20 @@ class ShopDialog(ui.ScriptWindow):
|
||||
|
||||
def __del__(self):
|
||||
ui.ScriptWindow.__del__(self)
|
||||
|
||||
|
||||
def __GetRealIndex(self, i):
|
||||
return self.tabIdx * shop.SHOP_SLOT_COUNT + i
|
||||
|
||||
def Refresh(self):
|
||||
getItemID=shop.GetItemID
|
||||
getItemCount=shop.GetItemCount
|
||||
setItemID=self.itemSlotWindow.SetItemSlot
|
||||
for i in xrange(shop.SHOP_SLOT_COUNT):
|
||||
itemCount = getItemCount(i)
|
||||
idx = self.__GetRealIndex(i)
|
||||
itemCount = getItemCount(idx)
|
||||
if itemCount <= 1:
|
||||
itemCount = 0
|
||||
setItemID(i, getItemID(i), itemCount)
|
||||
setItemID(i, getItemID(idx), itemCount)
|
||||
|
||||
wndMgr.RefreshSlot(self.itemSlotWindow.GetWindowHandle())
|
||||
|
||||
@ -52,6 +57,12 @@ class ShopDialog(ui.ScriptWindow):
|
||||
import exception
|
||||
exception.Abort("ShopDialog.LoadDialog.LoadObject")
|
||||
|
||||
smallTab1 = None
|
||||
smallTab2 = None
|
||||
smallTab3 = None
|
||||
middleTab1 = None
|
||||
middleTab2 = None
|
||||
|
||||
try:
|
||||
GetObject = self.GetChild
|
||||
self.itemSlotWindow = GetObject("ItemSlot")
|
||||
@ -59,6 +70,11 @@ class ShopDialog(ui.ScriptWindow):
|
||||
self.btnSell = GetObject("SellButton")
|
||||
self.btnClose = GetObject("CloseButton")
|
||||
self.titleBar = GetObject("TitleBar")
|
||||
middleTab1 = GetObject("MiddleTab1")
|
||||
middleTab2 = GetObject("MiddleTab2")
|
||||
smallTab1 = GetObject("SmallTab1")
|
||||
smallTab2 = GetObject("SmallTab2")
|
||||
smallTab3 = GetObject("SmallTab3")
|
||||
except:
|
||||
import exception
|
||||
exception.Abort("ShopDialog.LoadDialog.BindObject")
|
||||
@ -81,8 +97,47 @@ class ShopDialog(ui.ScriptWindow):
|
||||
|
||||
self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
|
||||
|
||||
self.Refresh()
|
||||
self.smallRadioButtonGroup = ui.RadioButtonGroup.Create([[smallTab1, lambda : self.OnClickTabButton(0), None], [smallTab2, lambda : self.OnClickTabButton(1), None], [smallTab3, lambda : self.OnClickTabButton(2), None]])
|
||||
self.middleRadioButtonGroup = ui.RadioButtonGroup.Create([[middleTab1, lambda : self.OnClickTabButton(0), None], [middleTab2, lambda : self.OnClickTabButton(1), None]])
|
||||
|
||||
self.__HideMiddleTabs()
|
||||
self.__HideSmallTabs()
|
||||
|
||||
self.tabIdx = 0
|
||||
self.coinType = shop.SHOP_COIN_TYPE_GOLD
|
||||
|
||||
self.Refresh()
|
||||
|
||||
def __ShowBuySellButton(self):
|
||||
self.btnBuy.Show()
|
||||
self.btnSell.Show()
|
||||
|
||||
def __ShowMiddleTabs(self):
|
||||
self.middleRadioButtonGroup.Show()
|
||||
|
||||
def __ShowSmallTabs(self):
|
||||
self.smallRadioButtonGroup.Show()
|
||||
|
||||
def __HideBuySellButton(self):
|
||||
self.btnBuy.Hide()
|
||||
self.btnSell.Hide()
|
||||
|
||||
def __HideMiddleTabs(self):
|
||||
self.middleRadioButtonGroup.Hide()
|
||||
|
||||
def __HideSmallTabs(self):
|
||||
self.smallRadioButtonGroup.Hide()
|
||||
|
||||
def __SetTabNames(self):
|
||||
if shop.GetTabCount() == 2:
|
||||
self.middleRadioButtonGroup.SetText(0, shop.GetTabName(0))
|
||||
self.middleRadioButtonGroup.SetText(1, shop.GetTabName(1))
|
||||
elif shop.GetTabCount() == 3:
|
||||
self.smallRadioButtonGroup.SetText(0, shop.GetTabName(0))
|
||||
self.smallRadioButtonGroup.SetText(1, shop.GetTabName(1))
|
||||
self.smallRadioButtonGroup.SetText(2, shop.GetTabName(2))
|
||||
|
||||
|
||||
def Destroy(self):
|
||||
self.Close()
|
||||
self.ClearDictionary()
|
||||
@ -98,18 +153,18 @@ class ShopDialog(ui.ScriptWindow):
|
||||
|
||||
def Open(self, vid):
|
||||
|
||||
isPrivateShop = FALSE
|
||||
isMainPlayerPrivateShop = FALSE
|
||||
isPrivateShop = False
|
||||
isMainPlayerPrivateShop = False
|
||||
|
||||
import chr
|
||||
if chr.IsNPC(vid):
|
||||
isPrivateShop = FALSE
|
||||
isPrivateShop = False
|
||||
else:
|
||||
isPrivateShop = TRUE
|
||||
isPrivateShop = True
|
||||
|
||||
if player.IsMainCharacterIndex(vid):
|
||||
|
||||
isMainPlayerPrivateShop = TRUE
|
||||
isMainPlayerPrivateShop = True
|
||||
|
||||
self.btnBuy.Hide()
|
||||
self.btnSell.Hide()
|
||||
@ -117,27 +172,64 @@ class ShopDialog(ui.ScriptWindow):
|
||||
|
||||
else:
|
||||
|
||||
isMainPlayerPrivateShop = FALSE
|
||||
isMainPlayerPrivateShop = False
|
||||
|
||||
self.btnBuy.Show()
|
||||
self.btnSell.Show()
|
||||
self.btnClose.Hide()
|
||||
|
||||
shop.Open(isPrivateShop, isMainPlayerPrivateShop)
|
||||
|
||||
self.tabIdx = 0
|
||||
|
||||
if isPrivateShop:
|
||||
self.__HideMiddleTabs()
|
||||
self.__HideSmallTabs()
|
||||
else:
|
||||
if shop.GetTabCount() == 1:
|
||||
self.__ShowBuySellButton()
|
||||
self.__HideMiddleTabs()
|
||||
self.__HideSmallTabs()
|
||||
elif shop.GetTabCount() == 2:
|
||||
self.__HideBuySellButton()
|
||||
self.__ShowMiddleTabs()
|
||||
self.__HideSmallTabs()
|
||||
self.__SetTabNames()
|
||||
self.middleRadioButtonGroup.OnClick(0)
|
||||
elif shop.GetTabCount() == 3:
|
||||
self.__HideBuySellButton()
|
||||
self.__HideMiddleTabs()
|
||||
self.__ShowSmallTabs()
|
||||
self.__SetTabNames()
|
||||
self.middleRadioButtonGroup.OnClick(1)
|
||||
|
||||
self.Refresh()
|
||||
self.SetTop()
|
||||
|
||||
self.Show()
|
||||
|
||||
(self.xShopStart, self.yShopStart, z) = player.GetMainCharacterPosition()
|
||||
|
||||
def Close(self):
|
||||
self.OnCloseQuestionDialog()
|
||||
if self.itemBuyQuestionDialog:
|
||||
self.itemBuyQuestionDialog.Close()
|
||||
self.itemBuyQuestionDialog = None
|
||||
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
|
||||
if self.questionDialog:
|
||||
self.OnCloseQuestionDialog()
|
||||
shop.Close()
|
||||
net.SendShopEndPacket()
|
||||
self.CancelShopping()
|
||||
self.tooltipItem.HideToolTip()
|
||||
self.Hide()
|
||||
|
||||
def GetIndexFromSlotPos(self, slotPos):
|
||||
return self.tabIdx * shop.SHOP_SLOT_COUNT + slotPos
|
||||
|
||||
def OnClickTabButton(self, idx):
|
||||
self.tabIdx = idx
|
||||
self.Refresh()
|
||||
|
||||
def AskClosePrivateShop(self):
|
||||
questionDialog = uiCommon.QuestionDialog()
|
||||
questionDialog.SetText(localeInfo.PRIVATE_SHOP_CLOSE_QUESTION)
|
||||
@ -146,20 +238,22 @@ class ShopDialog(ui.ScriptWindow):
|
||||
questionDialog.Open()
|
||||
self.questionDialog = questionDialog
|
||||
|
||||
return TRUE
|
||||
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
|
||||
|
||||
return True
|
||||
|
||||
def OnClosePrivateShop(self):
|
||||
net.SendChatPacket("/close_shop")
|
||||
self.OnCloseQuestionDialog()
|
||||
return TRUE
|
||||
return True
|
||||
|
||||
def OnPressEscapeKey(self):
|
||||
self.Close()
|
||||
return TRUE
|
||||
return True
|
||||
|
||||
def OnPressExitKey(self):
|
||||
self.Close()
|
||||
return TRUE
|
||||
return True
|
||||
|
||||
def OnBuy(self):
|
||||
chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO)
|
||||
@ -178,7 +272,9 @@ class ShopDialog(ui.ScriptWindow):
|
||||
|
||||
def __OnClosePopupDialog(self):
|
||||
self.pop = None
|
||||
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
|
||||
|
||||
## <20><>ȥ<EFBFBD><C8A5> <20>ȸ<EFBFBD><C8B8><EFBFBD> <20><><EFBFBD><EFBFBD> <20>߰<EFBFBD>.
|
||||
def SellAttachedItem(self):
|
||||
|
||||
if shop.IsPrivateShop():
|
||||
@ -188,19 +284,37 @@ class ShopDialog(ui.ScriptWindow):
|
||||
attachedSlotType = mouseModule.mouseController.GetAttachedType()
|
||||
attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
|
||||
attachedCount = mouseModule.mouseController.GetAttachedItemCount()
|
||||
if localeInfo.IsBRAZIL() == 0:
|
||||
attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
|
||||
|
||||
# if player.SLOT_TYPE_INVENTORY == attachedSlotType or player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedSlotType:
|
||||
if player.SLOT_TYPE_INVENTORY == attachedSlotType:
|
||||
|
||||
# if localeInfo.IsBRAZIL():
|
||||
# itemIndex = player.GetItemIndex(attachedSlotPos)
|
||||
# item.SelectItem(itemIndex)
|
||||
# else:
|
||||
# item.SelectItem(attachedItemIndex)
|
||||
|
||||
itemIndex = player.GetItemIndex(attachedSlotPos)
|
||||
item.SelectItem(itemIndex)
|
||||
|
||||
|
||||
if item.IsAntiFlag(item.ANTIFLAG_SELL):
|
||||
popup = uiCommon.PopupDialog()
|
||||
popup.SetText(localeInfo.SHOP_CANNOT_SELL_ITEM)
|
||||
popup.SetAcceptEvent(self.__OnClosePopupDialog)
|
||||
popup.Open()
|
||||
self.popup = popup
|
||||
return
|
||||
|
||||
itemtype = player.INVENTORY
|
||||
|
||||
elif player.IsValuableItem(attachedSlotPos):
|
||||
if localeInfo.IsBRAZIL() == 0:
|
||||
if player.SLOT_TYPE_DRAGON_SOUL_INVENTORY == attachedSlotType:
|
||||
itemtype = player.DRAGON_SOUL_INVENTORY
|
||||
|
||||
# if player.IsValuableItem(itemtype, attachedSlotPos):
|
||||
if player.IsValuableItem(attachedSlotPos):
|
||||
|
||||
itemPrice = item.GetISellItemPrice()
|
||||
|
||||
@ -214,29 +328,33 @@ class ShopDialog(ui.ScriptWindow):
|
||||
questionDialog = uiCommon.QuestionDialog()
|
||||
questionDialog.SetText(localeInfo.DO_YOU_SELL_ITEM(itemName, attachedCount, itemPrice))
|
||||
|
||||
questionDialog.SetAcceptEvent(lambda arg1=attachedSlotPos, arg2=attachedCount: self.OnSellItem(arg1, arg2))
|
||||
questionDialog.SetAcceptEvent(lambda arg1=attachedSlotPos, arg2=attachedCount, arg3 = itemtype: self.OnSellItem(arg1, arg2, arg3))
|
||||
questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
|
||||
questionDialog.Open()
|
||||
self.questionDialog = questionDialog
|
||||
|
||||
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
|
||||
|
||||
else:
|
||||
self.OnSellItem(attachedSlotPos, attachedCount)
|
||||
self.OnSellItem(attachedSlotPos, attachedCount, itemtype)
|
||||
|
||||
else:
|
||||
snd.PlaySound("sound/ui/loginfail.wav")
|
||||
|
||||
mouseModule.mouseController.DeattachObject()
|
||||
|
||||
def OnSellItem(self, slotPos, count):
|
||||
net.SendShopSellPacketNew(slotPos, count)
|
||||
def OnSellItem(self, slotPos, count, itemtype):
|
||||
net.SendShopSellPacketNew(slotPos, count, itemtype)
|
||||
snd.PlaySound("sound/ui/money.wav")
|
||||
self.OnCloseQuestionDialog()
|
||||
|
||||
def OnCloseQuestionDialog(self):
|
||||
if self.questionDialog:
|
||||
self.questionDialog.Close()
|
||||
|
||||
if not self.questionDialog:
|
||||
return
|
||||
|
||||
self.questionDialog.Close()
|
||||
self.questionDialog = None
|
||||
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
|
||||
|
||||
def SelectEmptySlot(self, selectedSlotPos):
|
||||
|
||||
@ -245,20 +363,25 @@ class ShopDialog(ui.ScriptWindow):
|
||||
self.SellAttachedItem()
|
||||
|
||||
def UnselectItemSlot(self, selectedSlotPos):
|
||||
if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
|
||||
return
|
||||
if shop.IsPrivateShop():
|
||||
self.AskBuyItem(selectedSlotPos)
|
||||
else:
|
||||
net.SendShopBuyPacket(selectedSlotPos)
|
||||
net.SendShopBuyPacket(self.__GetRealIndex(selectedSlotPos))
|
||||
|
||||
def SelectItemSlot(self, selectedSlotPos):
|
||||
if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
|
||||
return
|
||||
|
||||
isAttached = mouseModule.mouseController.isAttached()
|
||||
selectedSlotPos = self.__GetRealIndex(selectedSlotPos)
|
||||
if isAttached:
|
||||
self.SellAttachedItem()
|
||||
|
||||
else:
|
||||
|
||||
if TRUE == shop.IsMainPlayerPrivateShop():
|
||||
if True == shop.IsMainPlayerPrivateShop():
|
||||
return
|
||||
|
||||
curCursorNum = app.GetCursor()
|
||||
@ -285,6 +408,8 @@ class ShopDialog(ui.ScriptWindow):
|
||||
self.AskBuyItem(attachedSlotPos)
|
||||
|
||||
def AskBuyItem(self, slotPos):
|
||||
slotPos = self.__GetRealIndex(slotPos)
|
||||
|
||||
itemIndex = shop.GetItemID(slotPos)
|
||||
itemPrice = shop.GetItemPrice(slotPos)
|
||||
itemCount = shop.GetItemCount(slotPos)
|
||||
@ -294,11 +419,13 @@ class ShopDialog(ui.ScriptWindow):
|
||||
|
||||
itemBuyQuestionDialog = uiCommon.QuestionDialog()
|
||||
itemBuyQuestionDialog.SetText(localeInfo.DO_YOU_BUY_ITEM(itemName, itemCount, localeInfo.NumberToMoneyString(itemPrice)))
|
||||
itemBuyQuestionDialog.SetAcceptEvent(lambda arg=TRUE: self.AnswerBuyItem(arg))
|
||||
itemBuyQuestionDialog.SetCancelEvent(lambda arg=FALSE: self.AnswerBuyItem(arg))
|
||||
itemBuyQuestionDialog.SetAcceptEvent(lambda arg=True: self.AnswerBuyItem(arg))
|
||||
itemBuyQuestionDialog.SetCancelEvent(lambda arg=False: self.AnswerBuyItem(arg))
|
||||
itemBuyQuestionDialog.Open()
|
||||
itemBuyQuestionDialog.pos = slotPos
|
||||
self.itemBuyQuestionDialog = itemBuyQuestionDialog
|
||||
|
||||
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
|
||||
|
||||
def AnswerBuyItem(self, flag):
|
||||
|
||||
@ -308,17 +435,22 @@ class ShopDialog(ui.ScriptWindow):
|
||||
|
||||
self.itemBuyQuestionDialog.Close()
|
||||
self.itemBuyQuestionDialog = None
|
||||
|
||||
constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
|
||||
|
||||
def SetItemToolTip(self, tooltipItem):
|
||||
self.tooltipItem = tooltipItem
|
||||
|
||||
def OverInItem(self, slotIndex):
|
||||
slotIndex = self.__GetRealIndex(slotIndex)
|
||||
if mouseModule.mouseController.isAttached():
|
||||
return
|
||||
|
||||
if 0 != self.tooltipItem:
|
||||
self.tooltipItem.SetShopItem(slotIndex)
|
||||
|
||||
if shop.SHOP_COIN_TYPE_GOLD == shop.GetTabCoinType(self.tabIdx):
|
||||
self.tooltipItem.SetShopItem(slotIndex)
|
||||
else:
|
||||
self.tooltipItem.SetShopItemBySecondaryCoin(slotIndex)
|
||||
def OverOutItem(self):
|
||||
if 0 != self.tooltipItem:
|
||||
self.tooltipItem.HideToolTip()
|
||||
@ -369,4 +501,4 @@ class MallPageDialog(ui.ScriptWindow):
|
||||
|
||||
def OnPressEscapeKey(self):
|
||||
self.Close()
|
||||
return TRUE
|
||||
return True
|
||||
|
Reference in New Issue
Block a user