PICK_ITEM_TITLE Item Number
import wndMgrimport work as uiimport imeimport localeInfoimport reclass PickItemDialog(ui.ScriptWindow): def __init__(self): ui.ScriptWindow.__init__(self) self.unitValue = 1 self.maxValue = 0 self.eventAccept = 0 def __del__(self): ui.ScriptWindow.__del__(self) def LoadDialog(self): try: pyScrLoader = ui.PythonScriptLoader() pyScrLoader.LoadScriptFile(self, "UIScript/pickitemdialog.py") except: import exception exception.Abort("PickItemDialog.LoadDialog.LoadScript") try: self.board = self.GetChild("board") self.maxValueTextLine = self.GetChild("max_value") self.pickValueEditLine = self.GetChild("money_value") self.acceptButton = self.GetChild("accept_button") self.cancelButton = self.GetChild("cancel_button") except: import exception exception.Abort("PickItemDialog.LoadDialog.BindObject") self.pickValueEditLine.SetReturnEvent(ui.__mem_func__(self.OnAccept)) self.pickValueEditLine.SetEscapeEvent(ui.__mem_func__(self.Close)) self.acceptButton.SetEvent(ui.__mem_func__(self.OnAccept)) self.cancelButton.SetEvent(ui.__mem_func__(self.Close)) self.board.SetCloseEvent(ui.__mem_func__(self.Close)) def Destroy(self): self.ClearDictionary() self.eventAccept = 0 self.maxValue = 0 self.pickValueEditLine = 0 self.acceptButton = 0 self.cancelButton = 0 self.board = None def SetTitleName(self, text): self.board.SetTitleName(text) def SetAcceptEvent(self, event): self.eventAccept = event def SetMax(self, max): self.pickValueEditLine.SetMax(max) def Open(self, maxValue, unitValue=1): width = self.GetWidth() (mouseX, mouseY) = wndMgr.GetMousePosition() if mouseX + width/2 > wndMgr.GetScreenWidth(): xPos = wndMgr.GetScreenWidth() - width elif mouseX - width/2 < 0: xPos = 0 else: xPos = mouseX - width/2 self.SetPosition(xPos, mouseY - self.GetHeight() - 20) self.maxValueTextLine.SetText(" / " + str(localeInfo.AddPointToNumberString(maxValue))) self.pickValueEditLine.SetText(str(unitValue)) self.pickValueEditLine.SetFocus() ime.SetCursorPosition(1) self.unitValue = unitValue self.maxValue = maxValue self.Show() self.SetTop() def Close(self): self.pickValueEditLine.KillFocus() self.Hide() def __ConvertMoneyText(self, text, powers=dict(k=10**3, m=10**6, b=10**9)): """ Format string value in thousands, millions or billions. '1k' = 1.000 '100kk' = 100.000.000 '100m' = 100.000.000 '1b' = 1.000.000.000 '1kmb' = 1.000 (can't use multiple suffixes types) :param text: string :return: int :date: 10.01.2020 :author: Vegas """ match = re.search(r'(\d+)({:s}+)?'.format('+|'.join(powers.keys())), text, re.I) if match: moneyValue, suffixName = match.groups() moneyValue = int(moneyValue) if not suffixName: return moneyValue return moneyValue * (powers[suffixName[0]] ** len(suffixName)) return 0 def OnAccept(self): text = self.pickValueEditLine.GetText() if text: moneyValue = min(self.__ConvertMoneyText(text), self.maxValue) if moneyValue: if self.eventAccept: self.eventAccept(moneyValue) self.Close()
import uiPickItem
(def __init__(self):) self.itemBuyQuestionDialog = None
self.dlgPickItem = None
(def LoadDialog(self):) self.coinType = shop.SHOP_COIN_TYPE_GOLD self.Refresh()
dlgPickItem = uiPickItem.PickItemDialog() dlgPickItem.LoadDialog() dlgPickItem.Hide() self.dlgPickItem = dlgPickItem
(def Destroy(self):) self.popup = None
self.dlgPickItem.Destroy() self.dlgPickItem = 0
(def UnselectItemSlot(self, selectedSlotPos):) net.SendShopBuyPacket(self.__GetRealIndex(selectedSlotPos))
if app.IsPressed(app.DIK_LCONTROL): itemIndex = shop.GetItemID(selectedSlotPos) item.SelectItem(itemIndex) itemName = item.GetItemName() self.dlgPickItem.SetTitleName(itemName) self.dlgPickItem.SetAcceptEvent(ui.__mem_func__(self.OnPickItem)) self.dlgPickItem.Open(200) self.dlgPickItem.SetMax(200) self.dlgPickItem.itemGlobalSlotIndex = selectedSlotPos else: net.SendShopBuyPacket(self.__GetRealIndex(selectedSlotPos))
def OnPickItem(self, count): itemSlotIndex = self.dlgPickItem.itemGlobalSlotIndex n = 0 while n < count: net.SendShopBuyPacket(self.__GetRealIndex(itemSlotIndex)) n = n + 1
def SetShopItem(self, slotIndex): [...] self.AppendPrice(price)
self.AppendSpace(5) self.AppendTextLine("Multiple Buy: |Eemoji/key_ctrl|e + |Eemoji/key_rclick|e", self.CAN_LEVEL_UP_COLOR)
import uiScriptLocaleimport localeInfowindow = { "name" : "PickItemDialog", "x" : 100, "y" : 100, "style" : ("movable", "float",), "width" : 170, "height" : 90, "children" : ( { "name" : "board", "type" : "board_with_titlebar", "x" : 0, "y" : 0, "width" : 170, "height" : 90, "title" : localeInfo.PICK_ITEM_TITLE, "children" : ( ## Money Slot { "name" : "money_slot", "type" : "image", "x" : 20, "y" : 34, "image" : "d:/ymir work/ui/public/Parameter_Slot_02.sub", "children" : ( { "name" : "money_value", "type" : "editline", "x" : 3, "y" : 2, "width" : 60, "height" : 18, "input_limit" : 6, "only_number" : 0, "text" : "1", }, { "name" : "max_value", "type" : "text", "x" : 63, "y" : 3, "text" : "/ 999999", }, ), }, ## Button { "name" : "accept_button", "type" : "button", "x" : 170/2 - 61 - 5, "y" : 58, "text" : uiScriptLocale.OK, "default_image" : "d:/ymir work/ui/public/middle_button_01.sub", "over_image" : "d:/ymir work/ui/public/middle_button_02.sub", "down_image" : "d:/ymir work/ui/public/middle_button_03.sub", }, { "name" : "cancel_button", "type" : "button", "x" : 170/2 + 5, "y" : 58, "text" : uiScriptLocale.CANCEL, "default_image" : "d:/ymir work/ui/public/middle_button_01.sub", "over_image" : "d:/ymir work/ui/public/middle_button_02.sub", "down_image" : "d:/ymir work/ui/public/middle_button_03.sub", }, ), }, ),}
(long long CShop::Buy(LPCHARACTER ch, BYTE pos)) else { if (item->IsDragonSoul()) item->AddToCharacter(ch, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyPos)); item->AddToCharacter(ch, TItemPos(INVENTORY, iEmptyPos)); ITEM_MANAGER::instance().FlushDelayedSave(item); if (item->GetVnum() >= 500219 && item->GetVnum() <= 500222) LogManager::instance().GoldLog(ch->GetPlayerID(), item->GetID(), PERSONAL_SHOP_BUY, "", ch->IsGM() ? "Yes" : "No"); DBManager::instance().SendMoneyLog(MONEY_LOG_SHOP, item->GetVnum(), -dwPrice); }
else { if (item->IsDragonSoul()) item->AddToCharacter(ch, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyPos)); else { WORD bCount = item->GetCount(); if (IS_SET(item->GetFlag(), ITEM_FLAG_STACKABLE)) { for (WORD i = 0; i < INVENTORY_MAX_NUM; ++i) { LPITEM item2 = ch->GetInventoryItem(i); if (!item2) continue; if (item2->GetVnum() == item->GetVnum()) { int j; for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j) if (item2->GetSocket(j) != item->GetSocket(j)) break; if (j != ITEM_SOCKET_MAX_NUM) continue; WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount); bCount -= bCount2; item2->SetCount(item2->GetCount() + bCount2); if (bCount == 0) break; } } item->SetCount(bCount); } if (bCount > 0) item->AddToCharacter(ch, TItemPos(INVENTORY, iEmptyPos)); else M2_DESTROY_ITEM(item); } ITEM_MANAGER::instance().FlushDelayedSave(item); if (item->GetVnum() >= 500219 && item->GetVnum() <= 500222) LogManager::instance().GoldLog(ch->GetPlayerID(), item->GetID(), PERSONAL_SHOP_BUY, "", ch->IsGM() ? "Yes" : "No"); DBManager::instance().SendMoneyLog(MONEY_LOG_SHOP, item->GetVnum(), -dwPrice); }