Kezdjük a legelején.
Nyissuk meg az inventorywindow.py (locale/uiscript):
Keressük meg ezt :
"y" : SCREEN_HEIGHT - 37 - 565,
"y" : SCREEN_HEIGHT - 37 - 589,
2x irjuk át erre:
"height" : 565,
"height" : 589,
irjuk bele még ezt is:
## Print
{
"name":"Money_Slot",
"type":"button",
"x":8,
"y":28,
"horizontal_align":"center",
"vertical_align":"bottom",
"default_image" : "d:/ymir work/ui/public/parameter_slot_05.sub",
"over_image" : "d:/ymir work/ui/public/parameter_slot_05.sub",
"down_image" : "d:/ymir work/ui/public/parameter_slot_05.sub",
"children" :
(
{
"name":"Money_Icon",
"type":"image",
"x":-18,
"y":2,
"image":"d:/ymir work/ui/game/windows/money_icon.sub",
},
{
"name" : "Money",
"type" : "text",
"x" : 3,
"y" : 3,
"horizontal_align" : "right",
"text_horizontal_align" : "right",
"text" : "123456789",
},
),
},
## Print
{
"name":"Money_Slot",
"type":"button",
"x":8,
"y":28+24,
"horizontal_align":"center",
"vertical_align":"bottom",
"default_image" : "d:/ymir work/ui/public/parameter_slot_05.sub",
"over_image" : "d:/ymir work/ui/public/parameter_slot_05.sub",
"down_image" : "d:/ymir work/ui/public/parameter_slot_05.sub",
"children" :
(
{
"name":"Money_Icon",
"type":"image",
"x":-18,
"y":2,
"image":"d:/ymir work/ui/game/windows/money_icon.sub",
},
{
"name" : "Money",
"type" : "text",
"x" : 3,
"y" : 3,
"horizontal_align" : "right",
"text_horizontal_align" : "right",
"text" : "123456789",
},
),
},
## Print
{
"name":"Premium_Slot",
"type":"button",
"x":8,
"y":28,
"horizontal_align":"center",
"vertical_align":"bottom",
"default_image" : "d:/ymir work/ui/public/parameter_slot_05.sub",
"over_image" : "d:/ymir work/ui/public/parameter_slot_05.sub",
"down_image" : "d:/ymir work/ui/public/parameter_slot_05.sub",
"children" :
(
{
"name":"Premium_Icon",
"type":"image",
"x":-18,
"y":2,
"image":"d:/ymir work/ui/game/windows/money_icon.sub",
},
{
"name" : "Premium",
"type" : "text",
"x" : 3,
"y" : 3,
"horizontal_align" : "right",
"text_horizontal_align" : "right",
"text" : "123456789",
},
),
},
game.py (root):
A "servercommandlist"-hez irjuk be ezeket:
"GetInputStart" : self.GetInputStart,
"GetInputStop" : self.GetInputStop,
"GetInput" : self.GetInput,
"SetQuestIndex" : self.QuestIndexShop,
"SetIsNpc" : self.SetIsNpc,
"SetPrice" : self.SetIsPrice,
"NieMamPP" : self.NieMamPP,
"setPP" : self.__setAchievementPoints,
Ezeket pedig a "servercommandlist" alá:
def NieMamPP(self):
import uiShop
self.wndShop = uiShop.ShopDialog()
self.wndShop.NieMamPP()
def __setAchievementPoints(self, points):
constInfo.ACHIEVEMENT_POINTS = int(points)
self.interface.wndInventory.UpdatePremiumInSlot()
def SetIsPrice(self, value):
self.interface.dlgShop.SetShopPrice(value)
def SetIsNpc(self):
constInfo.IsItemShop = 1
def QuestIndexShop(self, value):
constInfo.IS_QUEST = int(value)
def GetInputStart(self):
constInfo.INPUT_IGNORE = 1
def GetInputStop(self):
constInfo.INPUT_IGNORE = 0
def GetInput(self):
net.SendQuestInputStringPacket(str(constInfo.INPUT_DATA))
constinfo.py (root):
ACHIEVEMENT_POINTS = 0
IS_QUEST = 0
IsItemShop = 0
INPUT_IGNORE = 0
INPUT_DATA = ""
uitooltip.py (root):
def SetShopItem(self, slotIndex):
itemVnum = shop.GetItemID(slotIndex)
if 0 == itemVnum:
return
price = shop.GetItemPrice(slotIndex)
self.ClearToolTip()
self.isShopItem = TRUE
item.SelectItem(itemVnum)
metinSlot = []
for i in xrange(player.METIN_SOCKET_MAX_NUM):
metinSlot.append(shop.GetItemMetinSocket(slotIndex, i))
attrSlot = []
for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
attrSlot.append(shop.GetItemAttribute(slotIndex, i))
self.AddItemData(itemVnum, metinSlot, attrSlot)
self.AppendPrice(price)
def SetShopItem(self, slotIndex, addprice = 0, waltype = 0):
itemVnum = shop.GetItemID(slotIndex)
if 0 == itemVnum:
return
price = shop.GetItemPrice(slotIndex)
self.ClearToolTip()
self.isShopItem = TRUE
item.SelectItem(itemVnum)
metinSlot = []
for i in xrange(player.METIN_SOCKET_MAX_NUM):
metinSlot.append(shop.GetItemMetinSocket(slotIndex, i))
attrSlot = []
for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
attrSlot.append(shop.GetItemAttribute(slotIndex, i))
self.AddItemData(itemVnum, metinSlot, attrSlot)
if waltype == 0:
self.AppendPrice(price)
else:
self.AppendSpace(5)
self.AppendTextLine("Cena: %s TR" % (locale.NumberToMoneyString(addprice)[:-5]), self.SPECIAL_TITLE_COLOR)
uiinventory.py (root):
keressük meg ezt :
def RefreshStatus(self):
money = player.GetElk()
self.wndMoney.SetText(locale.NumberToMoneyString(money))
Alá irjuk be ezt :
def UpdatePremiumInSlot(self):
import constInfo
value = str(constInfo.ACHIEVEMENT_POINTS)
self.wndPremium.SetText(locale.NumberToMoneyString(value)[:-5] + " TR")
Ez alá :
self.wndMoneySlot = 0
ezt
self.wndPremium = 0
self.wndPremiumSlot = 0
Most keresük meg ezt :
self.wndMoneySlot = self.GetChild("Money_Slot")
Alá pedig :
self.wndPremium = self.GetChild("Premium")
self.wndPremiumSlot = self.GetChild("Premium_Slot")
Ezt a funkciót pedig irjuk felül.
def SelectEmptySlot(self, selectedSlotPos):
if constInfo.GET_ITEM_DROP_QUESTION_DIALOG_STATUS() == 1:
return
selectedSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(selectedSlotPos)
if mouseModule.mouseController.isAttached():
attachedSlotType = mouseModule.mouseController.GetAttachedType()
attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
attachedItemCount = mouseModule.mouseController.GetAttachedItemCount()
attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
if player.SLOT_TYPE_INVENTORY == attachedSlotType:
itemCount = player.GetItemCount(attachedSlotPos)
attachedCount = mouseModule.mouseController.GetAttachedItemCount()
self.__SendMoveItemPacket(attachedSlotPos, selectedSlotPos, attachedCount)
if item.IsRefineScroll(attachedItemIndex):
self.wndItem.SetUseMode(FALSE)
elif player.SLOT_TYPE_PRIVATE_SHOP == attachedSlotType:
mouseModule.mouseController.RunCallBack("INVENTORY")
elif player.SLOT_TYPE_SHOP == attachedSlotType:
if constInfo.IsItemShop == 0:
net.SendShopBuyPacket(attachedSlotPos)
else:
import uiShop
self.wndShop = uiShop.ShopDialog()
self.wndShop.BuyFromIS(attachedSlotPos)
elif player.SLOT_TYPE_SAFEBOX == attachedSlotType:
if player.ITEM_MONEY == attachedItemIndex:
net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
snd.PlaySound("sound/ui/money.wav")
else:
net.SendSafeboxCheckoutPacket(attachedSlotPos, selectedSlotPos)
elif player.SLOT_TYPE_MALL == attachedSlotType:
net.SendMallCheckoutPacket(attachedSlotPos, selectedSlotPos)
mouseModule.mouseController.DeattachObject()
Uishop.py:
http://metin2hungary.net/index.php?topic=185573.0
Quest:
http://metin2hungary.net/index.php?topic=185574.0
import net
import player
import item
import snd
import shop
import net
import wndMgr
import app
import chat
import ui
import uiCommon
import mouseModule
import locale
import constInfo
import event
###################################################################################################
## Shop
class ShopDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
self.tooltipItem = 0
self.xShopStart = 0
self.yShopStart = 0
self.questionDialog = None
self.popup = None
self.itemBuyQuestionDialog = None
self.shopPrice = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
def __del__(self):
ui.ScriptWindow.__del__(self)
def Refresh(self):
getItemID=shop.GetItemID
getItemCount=shop.GetItemCount
setItemID=self.itemSlotWindow.SetItemSlot
for i in xrange(shop.SHOP_SLOT_COUNT):
itemCount = getItemCount(i)
if itemCount <= 1:
itemCount = 0
setItemID(i, getItemID(i), itemCount)
wndMgr.RefreshSlot(self.itemSlotWindow.GetWindowHa ndle())
def SetShopPrice(self, arg):
slots = arg.split("|")
for i in xrange(40):
self.shopPrice = int(slots)
def SetItemData(self, pos, itemID, itemCount, itemPrice):
shop.SetItemData(pos, itemID, itemCount, itemPrice)
def LoadDialog(self):
try:
PythonScriptLoader = ui.PythonScriptLoader()
PythonScriptLoader.LoadScriptFi le(self, "UIScript/shopdialog.py")
except:
import exception
exception.Abort("ShopDialog.LoadDialog.LoadObjec t")
try:
GetObject = self.GetChild
self.itemSlotWindow = GetObject("ItemSlot")
self.btnBuy = GetObject("BuyButton")
self.btnSell = GetObject("SellButton")
self.btnClose = GetObject("CloseButton")
self.titleBar = GetObject("TitleBar")
except:
import exception
exception.Abort("ShopDialog.LoadDialog.BindObjec t")
self.itemSlotWindow.SetSlotStyl e(wndMgr.SLOT_STYLE_NONE)
self.itemSlotWindow.SAFE_SetBut tonEvent("LEFT", "EMPTY", self.SelectEmptySlot)
self.itemSlotWindow.SAFE_SetBut tonEvent("LEFT", "EXIST", self.SelectItemSlot)
self.itemSlotWindow.SAFE_SetBut tonEvent("RIGHT", "EXIST", self.UnselectItemSlot)
self.itemSlotWindow.SetOverInIt emEvent(ui.__mem_func__(self.OverInItem))
self.itemSlotWindow.SetOverOutI temEvent(ui.__mem_func__(self.OverOutItem))
self.btnBuy.SetToggleUpEvent(ui.__mem_func__(self.CancelShopping))
self.btnBuy.SetToggleDownEvent(ui.__mem_func__(self.OnBuy))
self.btnSell.SetToggleUpEvent(ui.__mem_func__(self.CancelShopping))
self.btnSell.SetToggleDownEvent(ui.__mem_func__(self.OnSell))
self.btnClose.SetEvent(ui.__mem_func__(self.AskClosePrivateShop))
self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
self.Refresh()
def Destroy(self):
self.shopPrice = None
constInfo.IsItemShop = 0
self.Close()
self.ClearDictionary()
self.tooltipItem = 0
self.itemSlotWindow = 0
self.btnBuy = 0
self.btnSell = 0
self.btnClose = 0
self.titleBar = 0
self.questionDialog = None
self.popup = None
def Open(self, vid):
isPrivateShop = FALSE
isMainPlayerPrivateShop = FALSE
import chr
if chr.IsNPC(vid):
isPrivateShop = FALSE
else:
isPrivateShop = TRUE
if player.IsMainCharacterIndex(vid):
isMainPlayerPrivateShop = TRUE
self.btnBuy.Hide()
self.btnSell.Hide()
self.btnClose.Show()
else:
isMainPlayerPrivateShop = FALSE
self.btnBuy.Show()
self.btnSell.Show()
self.btnClose.Hide()
shop.Open(isPrivateShop, isMainPlayerPrivateShop)
self.Refresh()
self.SetTop()
self.Show()
(self.xShopStart, self.yShopStart, z) = player.GetMainCharacterPosition()
def Close(self):
self.shopPrice = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
constInfo.IsItemShop = 0
self.OnCloseQuestionDialog()
shop.Close()
net.SendShopEndPacket()
self.CancelShopping()
self.tooltipItem.HideToolTip()
self.Hide()
def AskClosePrivateShop(self):
questionDialog = uiCommon.QuestionDialog()
questionDialog.SetText(locale.PRIVATE_SHOP_CLOSE_QUEST ION)
questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnClosePrivateShop))
questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
questionDialog.Open()
self.questionDialog = questionDialog
return TRUE
def OnClosePrivateShop(self):
net.SendChatPacket("/close_shop")
self.OnCloseQuestionDialog()
return TRUE
def OnPressEscapeKey(self):
self.Close()
return TRUE
def OnPressExitKey(self):
self.Close()
return TRUE
def OnBuy(self):
chat.AppendChat(chat.CHAT_TYPE_INFO, locale.SHOP_BUY_INFO)
app.SetCursor(app.BUY)
self.btnSell.SetUp()
def OnSell(self):
chat.AppendChat(chat.CHAT_TYPE_INFO, locale.SHOP_SELL_INFO)
app.SetCursor(app.SELL)
self.btnBuy.SetUp()
def CancelShopping(self):
self.btnBuy.SetUp()
self.btnSell.SetUp()
app.SetCursor(app.NORMAL)
def __OnClosePopupDialog(self):
self.pop = None
def SellAttachedItem(self):
if shop.IsPrivateShop():
mouseModule.mouseController.Dea ttachObject()
return
attachedSlotType = mouseModule.mouseController.Get AttachedType()
attachedSlotPos = mouseModule.mouseController.Get AttachedSlotNumber()
attachedCount = mouseModule.mouseController.Get AttachedItemCount()
if player.SLOT_TYPE_INVENTORY == attachedSlotType:
itemIndex = player.GetItemIndex(attachedSlotPos)
item.SelectItem(itemIndex)
if item.IsAntiFlag(item.ITEM_ANTIFLAG_SELL):
popup = uiCommon.PopupDialog()
popup.SetText(locale.SHOP_CANNOT_SELL_ITEM)
popup.SetAcceptEvent(self.__OnClosePopupDialog)
popup.Open()
self.popup = popup
elif player.IsValuableItem(attachedSlotPos):
itemPrice = item.GetISellItemPrice()
if item.Is1GoldItem():
itemPrice = attachedCount / itemPrice / 5
else:
itemPrice = itemPrice * max(1, attachedCount) / 5
itemName = item.GetItemName()
questionDialog = uiCommon.QuestionDialog()
questionDialog.SetText(locale.DO_YOU_SELL_ITEM(itemName, attachedCount, itemPrice))
questionDialog.SetAcceptEvent(lambda arg1=attachedSlotPos, arg2=attachedCount: self.OnSellItem(arg1, arg2))
questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
questionDialog.Open()
self.questionDialog = questionDialog
else:
self.OnSellItem(attachedSlotPos, attachedCount)
else:
snd.PlaySound("sound/ui/loginfail.wav")
mouseModule.mouseController.Dea ttachObject()
def OnSellItem(self, slotPos, count):
net.SendShopSellPacketNew(slotPos, count)
snd.PlaySound("sound/ui/money.wav")
self.OnCloseQuestionDialog()
def NieMamPP(self):
self.popup = uiCommon.PopupDialog()
self.popup.SetText("Niewystarczająca ilość TR")
self.popup.SetAcceptEvent(self.__OnClosePopupDialog)
self.popup.Open()
def OnCloseQuestionDialog(self):
if self.questionDialog:
self.questionDialog.Close()
self.questionDialog = None
def SelectEmptySlot(self, selectedSlotPos):
isAttached = mouseModule.mouseController.isA ttached()
if isAttached:
self.SellAttachedItem()
def UnselectItemSlot(self, selectedSlotPos):
if shop.IsPrivateShop():
self.AskBuyItem(selectedSlotPos)
else:
if constInfo.IsItemShop == 1:
self.BuyFromIS(selectedSlotPos)
else:
net.SendShopBuyPacket(selectedSlotPos)
def SelectItemSlot(self, selectedSlotPos):
isAttached = mouseModule.mouseController.isA ttached()
if isAttached:
self.SellAttachedItem()
else:
if TRUE == shop.IsMainPlayerPrivateShop():
return
curCursorNum = app.GetCursor()
if app.BUY == curCursorNum:
if constInfo.IsItemShop == 1:
self.AskBuyFromIS(selectedSlotPos)
else:
self.AskBuyItem(selectedSlotPos)
elif app.SELL == curCursorNum:
chat.AppendChat(chat.CHAT_TYPE_INFO, locale.SHOP_SELL_INFO)
else:
selectedItemID = shop.GetItemID(selectedSlotPos)
itemCount = shop.GetItemCount(selectedSlotPos)
type = player.SLOT_TYPE_SHOP
if shop.IsPrivateShop():
type = player.SLOT_TYPE_PRIVATE_SHOP
mouseModule.mouseController.Att achObject(self, type, selectedSlotPos, selectedItemID, itemCount)
mouseModule.mouseController.Set CallBack("INVENTORY", ui.__mem_func__(self.DropToInventory))
snd.PlaySound("sound/ui/pick.wav")
def DropToInventory(self):
attachedSlotPos = mouseModule.mouseController.Get AttachedSlotNumber()
self.AskBuyItem(attachedSlotPos, constInfo.IsItemShop)
def BuyFromIS(self, slotPos, type=0):
constInfo.INPUT_DATA = slotPos
event.QuestButtonClick(constInfo.IS_QUEST)
if type == 1:
self.itemBuyQuestionDialog.Clos e()
self.itemBuyQuestionDialog = None
def AskBuyFromIS(self, slotPos):
itemIndex = shop.GetItemID(slotPos)
itemPrice = shop.GetItemPrice(slotPos)
itemCount = shop.GetItemCount(slotPos)
item.SelectItem(itemIndex)
itemName = item.GetItemName()
itemBuyQuestionDialog = uiCommon.QuestionDialog()
itemBuyQuestionDialog.SetText("Czy chcesz kupić " + itemName + " za " + (locale.NumberToMoneyString(self.shopPrice[slotPos])[:-5]) + " TR?")
itemBuyQuestionDialog.SetAccept Event(lambda arg=TRUE: self.BuyFromIS(slotPos, 1))
itemBuyQuestionDialog.SetCancel Event(lambda arg=FALSE: self.AnswerBuyItem(arg, type))
itemBuyQuestionDialog.Open()
itemBuyQuestionDialog.pos = slotPos
self.itemBuyQuestionDialog = itemBuyQuestionDialog
def AskBuyItem(self, slotPos, type=0):
if type == 1:
self.AskBuyFromIS(slotPos)
return
itemIndex = shop.GetItemID(slotPos)
itemPrice = shop.GetItemPrice(slotPos)
itemCount = shop.GetItemCount(slotPos)
item.SelectItem(itemIndex)
itemName = item.GetItemName()
itemBuyQuestionDialog = uiCommon.QuestionDialog()
itemBuyQuestionDialog.SetText(locale.DO_YOU_BUY_ITEM(itemName, itemCount, locale.NumberToMoneyString(itemPrice)))
itemBuyQuestionDialog.SetAccept Event(lambda arg=TRUE: self.AnswerBuyItem(arg, type))
itemBuyQuestionDialog.SetCancel Event(lambda arg=FALSE: self.AnswerBuyItem(arg, type))
itemBuyQuestionDialog.Open()
itemBuyQuestionDialog.pos = slotPos
self.itemBuyQuestionDialog = itemBuyQuestionDialog
def AnswerBuyItem(self, flag, type):
if flag:
pos = self.itemBuyQuestionDialog.pos
if type == 0:
net.SendShopBuyPacket(pos)
else:
self.BuyFromIS(pos)
self.itemBuyQuestionDialog.Clos e()
self.itemBuyQuestionDialog = None
def SetItemToolTip(self, tooltipItem):
self.tooltipItem = tooltipItem
def OverInItem(self, slotIndex):
if mouseModule.mouseController.isA ttached():
return
if 0 != self.tooltipItem:
if constInfo.IsItemShop == 0:
self.tooltipItem.SetShopItem(slotIndex, 0, 0)
else:
self.tooltipItem.SetShopItem(slotIndex, self.shopPrice[slotIndex], 1)
def OverOutItem(self):
if 0 != self.tooltipItem:
self.tooltipItem.HideToolTip()
def OnUpdate(self):
USE_SHOP_LIMIT_RANGE = 1000
(x, y, z) = player.GetMainCharacterPosition()
if abs(x - self.xShopStart) > USE_SHOP_LIMIT_RANGE or abs(y - self.yShopStart) > USE_SHOP_LIMIT_RANGE:
self.Close()
class MallPageDialog(ui.ScriptWindow):
def __init__(self):
ui.ScriptWindow.__init__(self)
def __del__(self):
ui.ScriptWindow.__del__(self)
def Destroy(self):
self.ClearDictionary()
def Open(self):
scriptLoader = ui.PythonScriptLoader()
scriptLoader.LoadScriptFile(self, "uiscript/mallpagedialog.py")
self.GetChild("titlebar").SetCloseEvent(ui.__mem_func__(self.Close))
(x, y)=self.GetGlobalPosition()
x+=10
y+=30
MALL_PAGE_WIDTH = 600
MALL_PAGE_HEIGHT = 480
app.ShowWebPage(
"http://metin2.co.kr/08_mall/game_mall/login_fail.htm",
(x, y, x+MALL_PAGE_WIDTH, y+MALL_PAGE_HEIGHT))
self.Lock()
self.Show()
def Close(self):
app.HideWebPage()
self.Unlock()
self.Hide()
def OnPressEscapeKey(self):
self.Close()
return TRUE
quest ujfizetoeszkoz begin
state start begin
when 20095.chat."Új Bolt " begin
cmdchat("SetIsNpc")
npc.open_shop(16)
setskin(NOWINDOW)
cmdchat("SetPrice 200|200|200|200|200|0|0|100|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0") <---- Árak beálitása
end
when login begin
cmdchat("SetQuestIndex "..q.getcurrentquestindex())
cmdchat("setPP "..pc.getqf("achievement_points"))
end
when button or info begin
local items = {
[0]={71124, 1, 200},
[1]={71125, 1, 200},
[2]={71126, 1, 200},
[3]={71127, 1, 200},
[4]={71128, 1, 200},
}<---------Tárgyak berakása ( az árakat elöbb rendeltük hozzá)
local slot = tonumber(achievement.GetInput("GetInput"))
if pc.getqf("achievement_points") >= items[slot][3] then
pc.setqf("achievement_points", pc.getqf("achievement_points")-items[slot][3])
cmdchat("setPP "..pc.getqf("achievement_points"))
pc.give_item2(items[slot][1], items[slot][2])
else
cmdchat("NieMamPP")
end
end
function GetInput(value)
cmdchat("GetInputStart")
local ret = input(cmdchat(value))
cmdchat("GetInputStop")
return ret
end
end
end