import ui import mouseModule import player import net import snd import safebox import chat import app import localeInfo import uiScriptLocale if app.ENABLE_PREMIUM_PRIVATE_SHOP: import uiInventory import uiCommon import interfaceModule g_isBuildingPremiumPrivateShop = False def IsBuildingPremiumPrivateShop(): global g_isBuildingPremiumPrivateShop if g_isBuildingPremiumPrivateShop: return True else: return False class PasswordDialog(ui.ScriptWindow): def __init__(self): ui.ScriptWindow.__init__(self) self.__LoadDialog() self.sendMessage = "/safebox_password " def __del__(self): ui.ScriptWindow.__del__(self) def __LoadDialog(self): try: pyScrLoader = ui.PythonScriptLoader() pyScrLoader.LoadScriptFile(self, "uiscript/passworddialog.py") except: import exception exception.Abort("PasswordDialog.__LoadDialog.LoadObject") try: self.passwordValue = self.GetChild("password_value") self.acceptButton = self.GetChild("accept_button") self.cancelButton = self.GetChild("cancel_button") self.titleName = self.GetChild("TitleName") self.GetChild("titlebar").SetCloseEvent(ui.__mem_func__(self.CloseDialog)) except: import exception exception.Abort("PasswordDialog.__LoadDialog.BindObject") self.passwordValue.OnIMEReturn = self.OnAccept self.passwordValue.OnPressEscapeKey = self.OnCancel self.acceptButton.SetEvent(ui.__mem_func__(self.OnAccept)) self.cancelButton.SetEvent(ui.__mem_func__(self.OnCancel)) def Destroy(self): self.ClearDictionary() self.passwordValue = None self.acceptButton = None self.cancelButton = None self.titleName = None def SetTitle(self, title): self.titleName.SetText(title) def SetSendMessage(self, msg): self.sendMessage = msg def ShowDialog(self): self.passwordValue.SetText("") self.passwordValue.SetFocus() self.SetCenterPosition() self.Show() def CloseDialog(self): self.passwordValue.KillFocus() self.Hide() def OnAccept(self): net.SendChatPacket(self.sendMessage + self.passwordValue.GetText()) self.CloseDialog() return True def OnCancel(self): self.CloseDialog() return True class ChangePasswordDialog(ui.ScriptWindow): def __init__(self): ui.ScriptWindow.__init__(self) self.__LoadDialog() def __del__(self): ui.ScriptWindow.__del__(self) def __LoadDialog(self): self.dlgMessage = ui.ScriptWindow() try: pyScrLoader = ui.PythonScriptLoader() pyScrLoader.LoadScriptFile(self.dlgMessage, "uiscript/popupdialog.py") self.dlgMessage.GetChild("message").SetText(localeInfo.SAFEBOX_WRONG_PASSWORD) self.dlgMessage.GetChild("accept").SetEvent(ui.__mem_func__(self.OnCloseMessageDialog)) except: import exception exception.Abort("SafeboxWindow.__LoadDialog.LoadObject") def LoadDialog(self): try: pyScrLoader = ui.PythonScriptLoader() pyScrLoader.LoadScriptFile(self, "uiscript/changepassworddialog.py") except: import exception exception.Abort("ChangePasswordDialog.LoadDialog.LoadObject") try: self.GetChild("accept_button").SetEvent(ui.__mem_func__(self.OnAccept)) self.GetChild("cancel_button").SetEvent(ui.__mem_func__(self.OnCancel)) self.GetChild("titlebar").SetCloseEvent(ui.__mem_func__(self.OnCancel)) oldPassword = self.GetChild("old_password_value") newPassword = self.GetChild("new_password_value") newPasswordCheck = self.GetChild("new_password_check_value") except: import exception exception.Abort("ChangePasswordDialog.LoadDialog.BindObject") oldPassword.SetTabEvent(lambda arg=1: self.OnNextFocus(arg)) newPassword.SetTabEvent(lambda arg=2: self.OnNextFocus(arg)) newPasswordCheck.SetTabEvent(lambda arg=3: self.OnNextFocus(arg)) oldPassword.SetReturnEvent(lambda arg=1: self.OnNextFocus(arg)) newPassword.SetReturnEvent(lambda arg=2: self.OnNextFocus(arg)) newPasswordCheck.SetReturnEvent(ui.__mem_func__(self.OnAccept)) oldPassword.OnPressEscapeKey = self.OnCancel newPassword.OnPressEscapeKey = self.OnCancel newPasswordCheck.OnPressEscapeKey = self.OnCancel self.oldPassword = oldPassword self.newPassword = newPassword self.newPasswordCheck = newPasswordCheck def OnNextFocus(self, arg): if 1 == arg: self.oldPassword.KillFocus() self.newPassword.SetFocus() elif 2 == arg: self.newPassword.KillFocus() self.newPasswordCheck.SetFocus() elif 3 == arg: self.newPasswordCheck.KillFocus() self.oldPassword.SetFocus() def Destroy(self): self.ClearDictionary() self.dlgMessage.ClearDictionary() self.oldPassword = None self.newPassword = None self.newPasswordCheck = None def Open(self): self.oldPassword.SetText("") self.newPassword.SetText("") self.newPasswordCheck.SetText("") self.oldPassword.SetFocus() self.SetCenterPosition() self.SetTop() self.Show() def Close(self): self.oldPassword.SetText("") self.newPassword.SetText("") self.newPasswordCheck.SetText("") self.oldPassword.KillFocus() self.newPassword.KillFocus() self.newPasswordCheck.KillFocus() self.Hide() def OnAccept(self): oldPasswordText = self.oldPassword.GetText() newPasswordText = self.newPassword.GetText() newPasswordCheckText = self.newPasswordCheck.GetText() if newPasswordText != newPasswordCheckText: self.dlgMessage.SetCenterPosition() self.dlgMessage.SetTop() self.dlgMessage.Show() return True net.SendChatPacket("/safebox_change_password %s %s" % (oldPasswordText, newPasswordText)) self.Close() return True def OnCancel(self): self.Close() return True def OnCloseMessageDialog(self): self.newPassword.SetText("") self.newPasswordCheck.SetText("") self.newPassword.SetFocus() self.dlgMessage.Hide() class SafeboxWindow(ui.ScriptWindow): BOX_WIDTH = 176 def __init__(self): ui.ScriptWindow.__init__(self) self.tooltipItem = None if app.WJ_ENABLE_TRADABLE_ICON: self.interface = None self.sellingSlotNumber = -1 self.pageButtonList = [] self.curPageIndex = 0 self.isLoaded = 0 self.xSafeBoxStart = 0 self.ySafeBoxStart = 0 self.__LoadWindow() def __del__(self): ui.ScriptWindow.__del__(self) def Show(self): self.__LoadWindow() ui.ScriptWindow.Show(self) def Destroy(self): self.ClearDictionary() self.dlgPickMoney.Destroy() self.dlgPickMoney = None self.dlgChangePassword.Destroy() self.dlgChangePassword = None self.tooltipItem = None self.wndMoneySlot = None self.wndMoney = None self.wndBoard = None self.wndItem = None if app.WJ_ENABLE_TRADABLE_ICON: self.interface = None self.pageButtonList = [] def __LoadWindow(self): if self.isLoaded == 1: return self.isLoaded = 1 pyScrLoader = ui.PythonScriptLoader() pyScrLoader.LoadScriptFile(self, "UIScript/SafeboxWindow.py") from _weakref import proxy ## Item wndItem = ui.GridSlotWindow() wndItem.SetParent(self) wndItem.SetPosition(8, 35) wndItem.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot)) wndItem.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot)) wndItem.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot)) wndItem.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot)) wndItem.SetOverInItemEvent(ui.__mem_func__(self.OverInItem)) wndItem.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem)) wndItem.Show() ## PickMoneyDialog import uiPickMoney dlgPickMoney = uiPickMoney.PickMoneyDialog() dlgPickMoney.LoadDialog() dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickMoney)) dlgPickMoney.Hide() ## ChangePasswrod dlgChangePassword = ChangePasswordDialog() dlgChangePassword.LoadDialog() dlgChangePassword.Hide() ## Close Button self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close)) self.GetChild("ChangePasswordButton").SetEvent(ui.__mem_func__(self.OnChangePassword)) self.GetChild("ExitButton").SetEvent(ui.__mem_func__(self.Close)) self.wndItem = wndItem self.dlgPickMoney = dlgPickMoney self.dlgChangePassword = dlgChangePassword self.wndBoard = self.GetChild("board") #self.wndMoney = self.GetChild("Money") #self.wndMoneySlot = self.GetChild("Money_Slot") #self.wndMoneySlot.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog)) ## Initialize self.SetTableSize(3) self.RefreshSafeboxMoney() def OpenPickMoneyDialog(self): if mouseModule.mouseController.isAttached(): attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber() if player.SLOT_TYPE_INVENTORY == mouseModule.mouseController.GetAttachedType(): if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex(): net.SendSafeboxSaveMoneyPacket(mouseModule.mouseController.GetAttachedItemCount()) snd.PlaySound("sound/ui/money.wav") mouseModule.mouseController.DeattachObject() else: curMoney = safebox.GetMoney() if curMoney <= 0: return self.dlgPickMoney.Open(curMoney) def ShowWindow(self, size): if app.WJ_ENABLE_TRADABLE_ICON: self.interface.SetOnTopWindow(player.ON_TOP_WND_SAFEBOX) self.interface.RefreshMarkInventoryBag() (self.xSafeBoxStart, self.ySafeBoxStart, z) = player.GetMainCharacterPosition() self.SetTableSize(size) self.Show() def __MakePageButton(self, pageCount): self.curPageIndex = 0 self.pageButtonList = [] text = "I" pos = -int(float(pageCount-1)/2 * 52) for i in xrange(pageCount): button = ui.RadioButton() button.SetParent(self) button.SetUpVisual("d:/ymir work/ui/game/windows/tab_button_middle_01.sub") button.SetOverVisual("d:/ymir work/ui/game/windows/tab_button_middle_02.sub") button.SetDownVisual("d:/ymir work/ui/game/windows/tab_button_middle_03.sub") button.SetWindowHorizontalAlignCenter() button.SetWindowVerticalAlignBottom() button.SetPosition(pos, 85) button.SetText(text) button.SetEvent(lambda arg=i: self.SelectPage(arg)) button.Show() self.pageButtonList.append(button) pos += 52 text += "I" self.pageButtonList[0].Down() def SelectPage(self, index): self.curPageIndex = index for btn in self.pageButtonList: btn.SetUp() self.pageButtonList[index].Down() self.RefreshSafebox() def __LocalPosToGlobalPos(self, local): return self.curPageIndex*safebox.SAFEBOX_PAGE_SIZE + local def SetTableSize(self, size): pageCount = max(1, size / safebox.SAFEBOX_SLOT_Y_COUNT) pageCount = min(3, pageCount) size = safebox.SAFEBOX_SLOT_Y_COUNT self.__MakePageButton(pageCount) self.wndItem.ArrangeSlot(0, safebox.SAFEBOX_SLOT_X_COUNT, size, 32, 32, 0, 0) self.wndItem.RefreshSlot() self.wndItem.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0) wnd_height = 130 + 32 * size self.wndBoard.SetSize(self.BOX_WIDTH, wnd_height) self.SetSize(self.BOX_WIDTH, wnd_height) self.UpdateRect() def RefreshSafebox(self): getItemID=safebox.GetItemID getItemCount=safebox.GetItemCount setItemID=self.wndItem.SetItemSlot for i in xrange(safebox.SAFEBOX_PAGE_SIZE): slotIndex = self.__LocalPosToGlobalPos(i) itemCount = getItemCount(slotIndex) if itemCount <= 1: itemCount = 0 setItemID(i, getItemID(slotIndex), itemCount) self.wndItem.RefreshSlot() def RefreshSafeboxMoney(self): pass #self.wndMoney.SetText(str(safebox.GetMoney())) def SetItemToolTip(self, tooltip): self.tooltipItem = tooltip def Close(self): if app.WJ_ENABLE_TRADABLE_ICON: self.interface.SetOnTopWindow(player.ON_TOP_WND_NONE) net.SendChatPacket("/safebox_close") self.Hide() # @fixme009 def CommandCloseSafebox(self): if self.tooltipItem: self.tooltipItem.HideToolTip() self.dlgPickMoney.Close() self.dlgChangePassword.Close() self.Hide() if app.WJ_ENABLE_TRADABLE_ICON: self.interface.RefreshMarkInventoryBag() ## Slot Event def SelectEmptySlot(self, selectedSlotPos): selectedSlotPos = self.__LocalPosToGlobalPos(selectedSlotPos) if mouseModule.mouseController.isAttached(): attachedSlotType = mouseModule.mouseController.GetAttachedType() attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber() if player.SLOT_TYPE_SAFEBOX == attachedSlotType: net.SendSafeboxItemMovePacket(attachedSlotPos, selectedSlotPos, 0) #snd.PlaySound("sound/ui/drop.wav") else: attachedInvenType = player.SlotTypeToInvenType(attachedSlotType) if player.RESERVED_WINDOW == attachedInvenType: return if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex(): net.SendSafeboxSaveMoneyPacket(mouseModule.mouseController.GetAttachedItemCount()) snd.PlaySound("sound/ui/money.wav") else: net.SendSafeboxCheckinPacket(attachedInvenType, attachedSlotPos, selectedSlotPos) #snd.PlaySound("sound/ui/drop.wav") mouseModule.mouseController.DeattachObject() def SelectItemSlot(self, selectedSlotPos): selectedSlotPos = self.__LocalPosToGlobalPos(selectedSlotPos) if mouseModule.mouseController.isAttached(): attachedSlotType = mouseModule.mouseController.GetAttachedType() if player.SLOT_TYPE_INVENTORY == attachedSlotType: if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex(): net.SendSafeboxSaveMoneyPacket(mouseModule.mouseController.GetAttachedItemCount()) snd.PlaySound("sound/ui/money.wav") else: attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber() #net.SendSafeboxCheckinPacket(attachedSlotPos, selectedSlotPos) #snd.PlaySound("sound/ui/drop.wav") mouseModule.mouseController.DeattachObject() else: curCursorNum = app.GetCursor() if app.SELL == curCursorNum: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SAFEBOX_SELL_DISABLE_SAFEITEM) elif app.BUY == curCursorNum: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO) else: selectedItemID = safebox.GetItemID(selectedSlotPos) mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_SAFEBOX, selectedSlotPos, selectedItemID) snd.PlaySound("sound/ui/pick.wav") def UseItemSlot(self, slotIndex): mouseModule.mouseController.DeattachObject() def __ShowToolTip(self, slotIndex): if self.tooltipItem: self.tooltipItem.SetSafeBoxItem(slotIndex) def OverInItem(self, slotIndex): slotIndex = self.__LocalPosToGlobalPos(slotIndex) self.wndItem.SetUsableItem(False) self.__ShowToolTip(slotIndex) def OverOutItem(self): self.wndItem.SetUsableItem(False) if self.tooltipItem: self.tooltipItem.HideToolTip() def OnPickMoney(self, money): mouseModule.mouseController.AttachMoney(self, player.SLOT_TYPE_SAFEBOX, money) def OnChangePassword(self): self.dlgChangePassword.Open() def OnPressEscapeKey(self): self.Close() return True def OnUpdate(self): USE_SAFEBOX_LIMIT_RANGE = 1000 (x, y, z) = player.GetMainCharacterPosition() if abs(x - self.xSafeBoxStart) > USE_SAFEBOX_LIMIT_RANGE or abs(y - self.ySafeBoxStart) > USE_SAFEBOX_LIMIT_RANGE: self.Close() if app.WJ_ENABLE_TRADABLE_ICON: def BindInterface(self, interface): self.interface = interface def OnTop(self): self.interface.SetOnTopWindow(player.ON_TOP_WND_SAFEBOX) self.interface.RefreshMarkInventoryBag() class MallWindow(ui.ScriptWindow): BOX_WIDTH = 176 def __init__(self): ui.ScriptWindow.__init__(self) self.tooltipItem = None self.sellingSlotNumber = -1 self.pageButtonList = [] self.curPageIndex = 0 self.isLoaded = 0 self.xSafeBoxStart = 0 self.ySafeBoxStart = 0 self.__LoadWindow() def __del__(self): ui.ScriptWindow.__del__(self) def Show(self): self.__LoadWindow() ui.ScriptWindow.Show(self) def Destroy(self): self.ClearDictionary() self.tooltipItem = None self.wndBoard = None self.wndItem = None self.pageButtonList = [] def __LoadWindow(self): if self.isLoaded == 1: return self.isLoaded = 1 pyScrLoader = ui.PythonScriptLoader() pyScrLoader.LoadScriptFile(self, "UIScript/MallWindow.py") from _weakref import proxy ## Item wndItem = ui.GridSlotWindow() wndItem.SetParent(self) wndItem.SetPosition(8, 35) wndItem.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot)) wndItem.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot)) wndItem.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot)) wndItem.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot)) wndItem.SetOverInItemEvent(ui.__mem_func__(self.OverInItem)) wndItem.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem)) wndItem.Show() ## Close Button self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close)) self.GetChild("ExitButton").SetEvent(ui.__mem_func__(self.Close)) self.wndItem = wndItem self.wndBoard = self.GetChild("board") ## Initialize self.SetTableSize(3) def ShowWindow(self, size): (self.xSafeBoxStart, self.ySafeBoxStart, z) = player.GetMainCharacterPosition() self.SetTableSize(size) self.Show() def SetTableSize(self, size): pageCount = max(1, size / safebox.SAFEBOX_SLOT_Y_COUNT) pageCount = min(3, pageCount) size = safebox.SAFEBOX_SLOT_Y_COUNT self.wndItem.ArrangeSlot(0, safebox.SAFEBOX_SLOT_X_COUNT, size, 32, 32, 0, 0) self.wndItem.RefreshSlot() self.wndItem.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0) self.wndBoard.SetSize(self.BOX_WIDTH, 82 + 32*size) self.SetSize(self.BOX_WIDTH, 85 + 32*size) self.UpdateRect() def RefreshMall(self): getItemID=safebox.GetMallItemID getItemCount=safebox.GetMallItemCount setItemID=self.wndItem.SetItemSlot for i in xrange(safebox.GetMallSize()): itemID = getItemID(i) itemCount = getItemCount(i) if itemCount <= 1: itemCount = 0 setItemID(i, itemID, itemCount) self.wndItem.RefreshSlot() def SetItemToolTip(self, tooltip): self.tooltipItem = tooltip def Close(self): net.SendChatPacket("/mall_close") self.Hide() # @fixme009 def CommandCloseMall(self): if self.tooltipItem: self.tooltipItem.HideToolTip() self.Hide() ## Slot Event def SelectEmptySlot(self, selectedSlotPos): if mouseModule.mouseController.isAttached(): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MALL_CANNOT_INSERT) mouseModule.mouseController.DeattachObject() def SelectItemSlot(self, selectedSlotPos): if mouseModule.mouseController.isAttached(): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MALL_CANNOT_INSERT) mouseModule.mouseController.DeattachObject() else: curCursorNum = app.GetCursor() selectedItemID = safebox.GetMallItemID(selectedSlotPos) mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_MALL, selectedSlotPos, selectedItemID) snd.PlaySound("sound/ui/pick.wav") def UseItemSlot(self, slotIndex): mouseModule.mouseController.DeattachObject() def __ShowToolTip(self, slotIndex): if self.tooltipItem: self.tooltipItem.SetMallItem(slotIndex) def OverInItem(self, slotIndex): self.__ShowToolTip(slotIndex) def OverOutItem(self): self.wndItem.SetUsableItem(False) if self.tooltipItem: self.tooltipItem.HideToolTip() def OnPressEscapeKey(self): self.Close() return True def OnUpdate(self): USE_SAFEBOX_LIMIT_RANGE = 1000 (x, y, z) = player.GetMainCharacterPosition() if abs(x - self.xSafeBoxStart) > USE_SAFEBOX_LIMIT_RANGE or abs(y - self.ySafeBoxStart) > USE_SAFEBOX_LIMIT_RANGE: self.Close() if app.ENABLE_PREMIUM_PRIVATE_SHOP: class PremiumPrivateShopWindow(ui.ScriptWindow): BOX_WIDTH = 176 def __init__(self): ui.ScriptWindow.__init__(self) self.tooltipItem = None self.sellingSlotNumber = -1 self.pageButtonList = [] self.curPageIndex = 0 self.isLoaded = 0 self.xSafeBoxStart = 0 self.ySafeBoxStart = 0 self.priceInputBoard = None self.wndMoney = 0 self.wndWon = 0 self.wndTime = 0 if app.WJ_ENABLE_TRADABLE_ICON: self.interface = None self.wndInventory = uiInventory.InventoryWindow() self.lockedItems = {i:(-1,-1) for i in range(safebox.SAFEBOX_SLOT_X_COUNT*(safebox.SAFEBOX_SLOT_Y_COUNT-1))} self.__LoadWindow() def __del__(self): ui.ScriptWindow.__del__(self) def Show(self): self.__LoadWindow() ui.ScriptWindow.Show(self) def Destroy(self): self.ClearDictionary() self.tooltipItem = None self.wndBoard = None self.wndItem = None self.priceInputBoard = None self.pageButtonList = [] self.wndMoney = 0 self.wndWon = 0 self.wndTime = 0 if app.WJ_ENABLE_TRADABLE_ICON: self.interface = None self.wndInventory = None self.lockedItems = {i:(-1,-1) for i in range(safebox.SAFEBOX_SLOT_X_COUNT*(safebox.SAFEBOX_SLOT_Y_COUNT-1))} def __LoadWindow(self): if self.isLoaded == 1: return self.isLoaded = 1 pyScrLoader = ui.PythonScriptLoader() pyScrLoader.LoadScriptFile(self, "UIScript/premiumprivateshopdialog.py") from _weakref import proxy ## Item wndItem = ui.GridSlotWindow() wndItem.SetParent(self) wndItem.SetPosition(8, 35) wndItem.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot)) wndItem.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot)) wndItem.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot)) wndItem.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot)) wndItem.SetOverInItemEvent(ui.__mem_func__(self.OverInItem)) wndItem.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem)) wndItem.Show() ## Close Button self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close)) self.GetChild("ExitButton").SetEvent(ui.__mem_func__(self.Close)) self.GetChild("RefreshMoney").SetEvent(ui.__mem_func__(self.RefreshMoney)) self.wndMoney = self.GetChild("yang_text") self.wndWon = self.GetChild("won_text") self.wndTime = self.GetChild("remain_time_text") self.wndItem = wndItem self.wndBoard = self.GetChild("board") ## Initialize self.SetTableSize(3) def ShowWindow(self, size, gold, time): (self.xSafeBoxStart, self.ySafeBoxStart, z) = player.GetMainCharacterPosition() if app.WJ_ENABLE_TRADABLE_ICON: self.interface.SetOnTopWindow(player.ON_TOP_WND_PRIVATE_SHOP) self.wndInventory.RefreshMarkSlots() # self.interface.RefreshMarkInventoryBag() self.wndTime.SetText(localeInfo.SecondToDHM(time - app.GetGlobalTimeStamp())) self.wndMoney.SetText(localeInfo.NumberToMoneyString(gold)) self.wndWon.SetText(0) global g_isBuildingPremiumPrivateShop g_isBuildingPremiumPrivateShop = True self.SetTableSize(size) self.Show() def SetTableSize(self, size): pageCount = max(1, size / safebox.SAFEBOX_SLOT_Y_COUNT-1) pageCount = min(3, pageCount) size = safebox.SAFEBOX_SLOT_Y_COUNT-1 self.wndItem.SetPosition(17, 35) self.wndItem.ArrangeSlot(0, safebox.SAFEBOX_SLOT_X_COUNT, size, 32, 32, 0, 0) self.wndItem.RefreshSlot() self.wndItem.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0) self.wndBoard.SetSize(self.BOX_WIDTH + 20, 150 + 32*size) self.SetSize(self.BOX_WIDTH + 20, 150 + 32*size) self.UpdateRect() def RefreshPremiumPrivateShop(self): getItemID=safebox.GetPremiumPrivateShopItemID getItemCount=safebox.GetPremiumPrivateShopItemCount setItemID=self.wndItem.SetItemSlot for i in xrange(safebox.GetPremiumPrivateShopSize()): itemID = getItemID(i) itemCount = getItemCount(i) # if app.ENABLE_TRANSMUTATION: # self.wndItem.SetCoverButton(i, "d:/ymir work/ui/game/quest/slot_button_00.sub", "d:/ymir work/ui/game/quest/slot_button_00.sub", "d:/ymir work/ui/game/quest/slot_button_00.sub", "icon/item/ingame_convert_mark.tga", FALSE, FALSE) # itemTransmutation = safebox.GetPremiumPrivateShopItemTransmutation(i) ## if itemTransmutation > 0: # self.wndItem.DisableCoverButton(i) # else: self.wndItem.EnableCoverButton(i) if itemCount <= 1: itemCount = 0 setItemID(i, itemID, itemCount) self.wndItem.RefreshSlot() if app.WJ_ENABLE_TRADABLE_ICON: self.RefreshLockedSlot() def RefreshMoney(self): net.SendPremiumPrivateCheckoutGoldOutPacket() def RefreshGoldMoney(self, gold): self.wndMoney.SetText(localeInfo.NumberToMoneyString(gold)) def SetItemToolTip(self, tooltip): self.tooltipItem = tooltip def Close(self): if self.priceInputBoard: return net.SendChatPacket("/premium_private_shop_close") global g_isBuildingPremiumPrivateShop g_isBuildingPremiumPrivateShop = False if app.WJ_ENABLE_TRADABLE_ICON: for privatePos, (itemInvenPage, itemSlotPos) in self.lockedItems.items(): if itemInvenPage == self.wndInventory.GetInventoryPageIndex(): self.wndInventory.wndItem.SetCanMouseEventSlot(itemSlotPos) self.lockedItems = {i:(-1,-1) for i in range(safebox.SAFEBOX_SLOT_X_COUNT*(safebox.SAFEBOX_SLOT_Y_COUNT-1))} self.interface.SetOnTopWindow(player.ON_TOP_WND_NONE) self.wndInventory.RefreshMarkSlots() #self.interface = interfaceModule.Interface() #self.interface.SetOnTopWindow(player.ON_TOP_WND_NONE) #self.wndInventory.RefreshMarkSlots() def CommandClosePremiumPrivateShop(self): if self.tooltipItem: self.tooltipItem.HideToolTip() if app.WJ_ENABLE_TRADABLE_ICON: if self.interface: self.interface.SetOnTopWindow(player.ON_TOP_WND_NONE) self.wndInventory.RefreshMarkSlots() # self.interface.RefreshMarkInventoryBag() global g_isBuildingPremiumPrivateShop g_isBuildingPremiumPrivateShop = False self.Hide() ## Slot Event def SelectEmptySlot(self, selectedSlotPos): if app.ENABLE_PREMIUM_PRIVATE_SHOP: if mouseModule.mouseController.isAttached(): attachedSlotType = mouseModule.mouseController.GetAttachedType() attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber() if player.SLOT_TYPE_PREMIUM_PRIVATE_SHOP == attachedSlotType: net.SendPremiumPrivateShopItemMovePacket(attachedSlotPos, selectedSlotPos, 0) else: attachedInvenType = player.SlotTypeToInvenType(attachedSlotType) if player.RESERVED_WINDOW == attachedInvenType: return if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex(): return else: itemVNum = player.GetItemIndex(attachedInvenType, attachedSlotPos) item.SelectItem(itemVNum) if item.IsAntiFlag(item.ANTIFLAG_GIVE) or item.IsAntiFlag(item.ANTIFLAG_MYSHOP): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.PRIVATE_SHOP_CANNOT_SELL_ITEM) return if app.WJ_ENABLE_TRADABLE_ICON and player.SLOT_TYPE_INVENTORY == attachedSlotType: self.CantTradableItem(selectedSlotPos, attachedSlotPos) priceInputBoard = uiCommon.MoneyInputDialog() priceInputBoard.SetTitle(localeInfo.PRIVATE_SHOP_INPUT_PRICE_DIALOG_TITLE) priceInputBoard.SetAcceptEvent(ui.__mem_func__(self.AcceptInputPrice)) priceInputBoard.SetCancelEvent(ui.__mem_func__(self.CancelInputPrice)) priceInputBoard.Open() #itemPrice=GetPrivateShopItemPrice(itemVNum) #if itemPrice>0: # priceInputBoard.SetValue(itemPrice) self.priceInputBoard = priceInputBoard self.priceInputBoard.itemVNum = itemVNum self.priceInputBoard.sourceWindowType = attachedInvenType self.priceInputBoard.sourceSlotPos = attachedSlotPos self.priceInputBoard.targetSlotPos = selectedSlotPos mouseModule.mouseController.DeattachObject() else: if mouseModule.mouseController.isAttached(): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MALL_CANNOT_INSERT) mouseModule.mouseController.DeattachObject() def SelectItemSlot(self, selectedSlotPos): if mouseModule.mouseController.isAttached(): attachedSlotType = mouseModule.mouseController.GetAttachedType() if player.SLOT_TYPE_INVENTORY == attachedSlotType: if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex(): net.SendSafeboxSaveMoneyPacket(mouseModule.mouseController.GetAttachedItemCount()) snd.PlaySound("sound/ui/money.wav") else: attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber() mouseModule.mouseController.DeattachObject() else: curCursorNum = app.GetCursor() if app.SELL == curCursorNum: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SAFEBOX_SELL_DISABLE_SAFEITEM) elif app.BUY == curCursorNum: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO) else: selectedItemID = safebox.GetPremiumPrivateShopItemID(selectedSlotPos) mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_PREMIUM_PRIVATE_SHOP, selectedSlotPos, selectedItemID) snd.PlaySound("sound/ui/pick.wav") def AcceptInputPrice(self): if not self.priceInputBoard: return True text = self.priceInputBoard.GetText() if not text: return True if not text.isdigit(): return True if int(text) <= 0: return True attachedInvenType = self.priceInputBoard.sourceWindowType sourceSlotPos = self.priceInputBoard.sourceSlotPos targetSlotPos = self.priceInputBoard.targetSlotPos price = int(self.priceInputBoard.GetText()) net.SendPremiumPrivateShopCheckinPacket(attachedInvenType, sourceSlotPos, targetSlotPos, price) snd.PlaySound("sound/ui/drop.wav") self.RefreshPremiumPrivateShop() ##### if app.WJ_ENABLE_TRADABLE_ICON: for privatePos, (itemInvenPage, itemSlotPos) in self.lockedItems.items(): if itemInvenPage == self.wndInventory.GetInventoryPageIndex(): self.wndInventory.wndItem.SetCanMouseEventSlot(itemSlotPos) self.lockedItems = {i:(-1,-1) for i in range(safebox.SAFEBOX_SLOT_X_COUNT*(safebox.SAFEBOX_SLOT_Y_COUNT-1))} self.priceInputBoard = None return True def CancelInputPrice(self): if app.WJ_ENABLE_TRADABLE_ICON: itemInvenPage = self.priceInputBoard.sourceSlotPos / player.INVENTORY_PAGE_SIZE itemSlotPos = self.priceInputBoard.sourceSlotPos - (itemInvenPage * player.INVENTORY_PAGE_SIZE) if self.wndInventory.GetInventoryPageIndex() == itemInvenPage: self.wndInventory.wndItem.SetCanMouseEventSlot(itemSlotPos) self.lockedItems[self.priceInputBoard.targetSlotPos] = (-1, -1) self.priceInputBoard = None return True def UseItemSlot(self, slotIndex): if mouseModule.mouseController.isAttached(): mouseModule.mouseController.DeattachObject() def __ShowToolTip(self, slotIndex): if self.tooltipItem: self.tooltipItem.SetPremiumPrivateShopItem(slotIndex) def OverInItem(self, slotIndex): self.__ShowToolTip(slotIndex) def OverOutItem(self): self.wndItem.SetUsableItem(FALSE) if self.tooltipItem: self.tooltipItem.HideToolTip() def OnPressEscapeKey(self): if self.priceInputBoard: return self.Close() return TRUE def OnUpdate(self): USE_SAFEBOX_LIMIT_RANGE = 1000 (x, y, z) = player.GetMainCharacterPosition() if abs(x - self.xSafeBoxStart) > USE_SAFEBOX_LIMIT_RANGE or abs(y - self.ySafeBoxStart) > USE_SAFEBOX_LIMIT_RANGE: self.Close() if app.WJ_ENABLE_TRADABLE_ICON: def CantTradableItem(self, destSlotIndex, srcSlotIndex): itemInvenPage = srcSlotIndex / player.INVENTORY_PAGE_SIZE localSlotPos = srcSlotIndex - (itemInvenPage * player.INVENTORY_PAGE_SIZE) self.lockedItems[destSlotIndex] = (itemInvenPage, localSlotPos) if self.wndInventory.GetInventoryPageIndex() == itemInvenPage: self.wndInventory.wndItem.SetCantMouseEventSlot(localSlotPos) def RefreshLockedSlot(self): if self.wndInventory: for privatePos, (itemInvenPage, itemSlotPos) in self.lockedItems.items(): if self.wndInventory.GetInventoryPageIndex() == itemInvenPage: self.wndInventory.wndItem.SetCantMouseEventSlot(itemSlotPos) self.wndInventory.wndItem.RefreshSlot() def BindInterface(self, interface): self.interface = interface def OnTop(self): if self.interface: self.interface.SetOnTopWindow(player.ON_TOP_WND_PRIVATE_SHOP) self.wndInventory.RefreshMarkSlots() #self.interface.RefreshMarkInventoryBag() def SetInven(self, wndInventory): from _weakref import proxy self.wndInventory = proxy(wndInventory) if __name__ == "__main__": import app import wndMgr import systemSetting import mouseModule import grp import ui import chr import background import player #wndMgr.SetOutlineFlag(True) app.SetMouseHandler(mouseModule.mouseController) app.SetHairColorEnable(True) wndMgr.SetMouseHandler(mouseModule.mouseController) wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight()) app.Create("METIN2 CLOSED BETA", systemSetting.GetWidth(), systemSetting.GetHeight(), 1) mouseModule.mouseController.Create() wnd = SafeboxWindow() wnd.ShowWindow(1) app.Loop()