Jump to content

Recommended Posts

  • Premium

M2 Download Center

This is the hidden content, please
( Internal )

https://metin2.download/picture/kUj102rSyOr1IH9fsQwNY3zH8FO2DrIL/.gifv

uiCommon.py

class ItemQuestionDialog(ui.ScriptWindow):
	def __init__(self):
		ui.ScriptWindow.__init__(self)
		self.__CreateDialog()
		
		self.tooltipItem = uiToolTip.ItemToolTip()
		self.toolTip = uiToolTip.ToolTip()
		
		self.window_type = 0
		self.count = 0
	
		self.dropType = 0
		self.dropCount = 0
		self.dropNumber = 0

	def __del__(self):
		ui.ScriptWindow.__del__(self)

	def __CreateDialog(self):
		pyScrLoader = ui.PythonScriptLoader()
		pyScrLoader.LoadScriptFile(self, "QuestionDialog.py")

		self.board = self.GetChild("board")
		self.textLine = self.GetChild("message")
		self.acceptButton = self.GetChild("accept")
		self.cancelButton = self.GetChild("cancel")

		self.titleBar = ui.TitleBar()
		self.titleBar.SetParent(self.board)
		self.titleBar.MakeTitleBar(244, "yellow")
		self.titleBar.SetPosition(8, 7)
		self.titleBar.Show()

		self.titleName = ui.TextLine()
		self.titleName.SetParent(self.titleBar)
		self.titleName.SetPosition(0, 4)
		self.titleName.SetWindowHorizontalAlignCenter()
		self.titleName.SetHorizontalAlignCenter()
		self.titleName.Show()

		self.slotList = []
		for i in xrange(3):
			slot = ui.ImageBox()
			slot.LoadImage("d:/ymir work/ui/public/slot_base.sub")
			slot.SetParent(self)
			slot.SetWindowHorizontalAlignCenter()
			self.slotList.append(slot)

	def Open(self, vnum, slot = None, price = None):
		item.SelectItem(vnum)
		xSlotCount, ySlotCount = item.GetItemSize()

		try:
			if self.window_type == "inv":
				metinSlot = [player.GetItemMetinSocket(player.INVENTORY, slot, i) for i in xrange(player.METIN_SOCKET_MAX_NUM)]
			elif self.window_type == "shop":
				metinSlot = [shop.GetItemMetinSocket(slot, i) for i in xrange(player.METIN_SOCKET_MAX_NUM)]
		except:
			pass

		if vnum in (50300, 70037):
			self.titleName.SetText("%s %s" % (skill.GetSkillName(metinSlot[0]), item.GetItemName()))
		elif vnum == 70104:
			self.titleName.SetText("%s %s" % (nonplayer.GetMonsterName(metinSlot[0]), item.GetItemName()))
		else:
			self.titleName.SetText(item.GetItemName())

		newHeight = 0	
			
		if price:
			newHeight = 20
		
			itemPrice = ui.TextLine()
			itemPrice.SetPosition(0, 77 + 32*ySlotCount)
			itemPrice.SetWindowHorizontalAlignCenter()
			itemPrice.SetHorizontalAlignCenter()
			itemPrice.SetVerticalAlignCenter()
			itemPrice.SetParent(self.board)
			if str(price).isdigit():
				itemPrice.SetText(localeInfo.NumberToMoneyString(price))
			else:
				itemPrice.SetText(price)
			itemPrice.Show()
			self.itemPrice = itemPrice

		slotGrid = ui.SlotWindow()
		slotGrid.SetParent(self)
		slotGrid.SetPosition(-16, 62)
		slotGrid.SetWindowHorizontalAlignCenter()
		slotGrid.AppendSlot(0, 0, 0, 32*xSlotCount, 32*ySlotCount)
		slotGrid.AddFlag("not_pick")
		slotGrid.Show()
		self.slotGrid = slotGrid

		if self.count > 1 and vnum != 1:
			self.slotGrid.SetItemSlot(0, vnum, self.count)
		else:
			self.slotGrid.SetItemSlot(0, vnum)
				
		self.SetSize(260, 110 + 32*ySlotCount + newHeight)
		self.board.SetSize(260, 110 + 32*ySlotCount + newHeight)
		self.textLine.SetPosition(0, 44)

		for i in xrange(min(3, ySlotCount)):
			self.slotList[i].SetPosition(0, 30 + ySlotCount*32 - i*32)
			if vnum != 1:
				self.slotList[i].OnMouseOverIn = lambda arg = slot: self.OverInItem(arg)
				self.slotList[i].OnMouseOverOut = lambda arg = self.tooltipItem: self.OverOutItem(arg)
			else:
				self.slotList[i].OnMouseOverIn = lambda arg = localeInfo.MONETARY_UNIT0: self.OverInToolTip(arg)
				self.slotList[i].OnMouseOverOut = lambda: self.OverOutToolTip()
			self.slotList[i].Show()

		self.GetChild("accept").SetPosition(-40, 74 + 32*ySlotCount + newHeight)
		self.GetChild("cancel").SetPosition(40, 74 + 32*ySlotCount + newHeight)

		self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
		
		self.SetCenterPosition()
		self.SetTop()
		self.Show()

	def SetCloseEvent(self, event):
		self.titleBar.SetCloseEvent(event)
		
	def SetMessage(self, text):
		self.textLine.SetText(text)

	def OverInToolTip(self, arg):
		self.toolTip.ClearToolTip()
		self.toolTip.AppendTextLine(arg, 0xffffff00)
		self.toolTip.Show()
	
	def OverOutToolTip(self):
		self.toolTip.Hide()
		
	def OverInItem(self, slot):
		if self.window_type == "shop":
			self.tooltipItem.SetShopItem(slot)
		elif self.window_type == "inv":
			self.tooltipItem.SetInventoryItem(slot)
		
	def OverOutItem(self, tooltipItem):
		if None != tooltipItem:
			self.tooltipItem.HideToolTip()
			self.tooltipItem.ClearToolTip()
	
	def Close(self):
		self.ClearDictionary()
		self.slotList = []
		self.titleBar = None
		self.titleName = None
		self.itemPrice = None
		self.slotGrid = None
		
		self.toolTip = None
		self.tooltipItem = None
		self.Hide()
		
		constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
		
	def SetWidth(self, width):
		height = self.GetHeight()
		self.SetSize(width, height)
		self.board.SetSize(width, height)
		self.SetCenterPosition()
		self.UpdateRect()

	def SAFE_SetAcceptEvent(self, event):
		self.acceptButton.SAFE_SetEvent(event)

	def SAFE_SetCancelEvent(self, event):
		self.cancelButton.SAFE_SetEvent(event)

	def SetAcceptEvent(self, event):
		self.acceptButton.SetEvent(event)

	def SetCancelEvent(self, event):
		self.cancelButton.SetEvent(event)

	def SetText(self, text):
		self.textLine.SetText(text)

	def SetAcceptText(self, text):
		self.acceptButton.SetText(text)

	def SetCancelText(self, text):
		self.cancelButton.SetText(text)

	def OnPressEscapeKey(self):
		self.Close()
		
		return True

add imports

import constInfo
import skill
import nonplayer

 

This is just a class, now you just have to call it

itemQuestionDialog = uiCommon.ItemQuestionDialog()

itemQuestionDialog.window_type = "inv" #for inventory
itemQuestionDialog.window_type = "shop" #for shops

itemQuestionDialog.count = ...

drop 		MONEY 		itemQuestionDialog.Open(1, "", attachedMoney)
drop 		ITEM		itemQuestionDialog.Open(itemVNum, slotNumber)
buy&sell 	ITEM		itemQuestionDialog.Open(itemVNum, slotNumber, price)
Spoiler

I wont help with further implementation, it's your task to do ^^

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 28
  • Eyes 1
  • Good 8
  • Love 1
  • Love 30
Link to comment
https://metin2.dev/topic/17515-ui-class-dialog-drop-buy-sell/
Share on other sites

1212 19:40:11992 :: Traceback (most recent call last):

1212 19:40:11993 ::   File "game.py", line 1314, in OnMouseLeftButtonUp

1212 19:40:11993 ::   File "game.py", line 1351, in __PutItem

1212 19:40:11993 ::   File "game.py", line 1426, in __DropItem

1212 19:40:11993 :: TypeError
1212 19:40:11993 :: : 
1212 19:40:11993 :: Open() takes at least 3 arguments (1 given)
1212 19:40:11993 :: 

 

  • Premium
On 12/12/2017 at 4:46 PM, Sumnix said:

1212 19:40:11992 :: Traceback (most recent call last):

1212 19:40:11993 ::   File "game.py", line 1314, in OnMouseLeftButtonUp

1212 19:40:11993 ::   File "game.py", line 1351, in __PutItem

1212 19:40:11993 ::   File "game.py", line 1426, in __DropItem

1212 19:40:11993 :: TypeError
1212 19:40:11993 :: : 
1212 19:40:11993 :: Open() takes at least 3 arguments (1 given)
1212 19:40:11993 :: 

 

He stated clearly that you have to call it differently from your previous Open().
 

Just call the others, 

Mydick = ItemQuestionDialog() # Should be already done in game.py
Mydick.Open(vnum, slot, text)

Didnt test but it should work

Acum 2 ore, Fleon a spus:


 
Acum 2 ore, Fleon a spus:

He stated clearly that you have to call it differently from your previous Open().
 

Just call the others, 



Mydick = ItemQuestionDialog() # Should be already done in game.py


Mydick.Open(vnum, slot, text)

Didnt test but it should work

For me it`s not working

1219 13:52:17113 :: Traceback (most recent call last):

1219 13:52:17113 ::   File "game.py", line 781, in BINARY_NEW_AddAffect

1219 13:52:17113 ::   File "game.py", line 1851, in BINARY_DragonSoulGiveQuilification

1219 13:52:17113 ::   File "interfaceModule.py", line 1017, in DragonSoulGiveQuilification

1219 13:52:17113 :: AttributeError
1219 13:52:17113 :: : 
1219 13:52:17113 :: 'NoneType' object has no attribute 'SetToolTipText'
1219 13:52:17113 :: 

1219 13:52:21535 :: Failed to load script file : QuestionDialog.py
1219 13:52:21535 :: error  : No file or directory
1219 13:52:21536 :: 
ui.py(line:3146) LoadScriptFile
system.py(line:192) execfile
system.py(line:161) Run
system.py(line:176) __LoadTextFile__
system.py(line:61) __init__

1220 15:39:29380 :: Traceback (most recent call last):

1220 15:39:29380 ::   File "game.py", line 1415, in OnMouseLeftButtonUp

1220 15:39:29381 ::   File "game.py", line 1470, in __PutItem

1220 15:39:29381 ::   File "game.py", line 1565, in __DropItem

1220 15:39:29381 :: TypeError
1220 15:39:29381 :: :
1220 15:39:29381 :: Open() takes at least 3 arguments (1 given)

16 minutes ago, veterano1998 said:

how you call code ?

19 minutes ago, veterano1998 said:

sand def __DropItem here plese

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 1
2 minutes ago, veterano1998 said:

I did not do it,
You can contact him if you want him to tell you. (I do not think it's free.)

 

felipe.ardila8

There is no problem sharing free codes, but, always so you only like your personal interests

1230 12:02:35479 ::   File "game.py", line 1343, in OnMouseLeftButtonUp

1230 12:02:35479 ::   File "game.py", line 1379, in __PutItem

1230 12:02:35479 ::   File "game.py", line 1446, in __DropItem

1230 12:02:35480 :: NameError
1230 12:02:35480 :: :
1230 12:02:35480 :: global name 'vnum' is not defined
1230 12:02:35480 ::

any help possible?

Dnia 23.12.2017 o 16:51, iPizder napisał:

Add:

import shop
import player

 

Dnia 30.12.2017 o 01:16, TRBizeps napisał:

1230 12:02:35479 ::   File "game.py", line 1343, in OnMouseLeftButtonUp

1230 12:02:35479 ::   File "game.py", line 1379, in __PutItem

1230 12:02:35479 ::   File "game.py", line 1446, in __DropItem

1230 12:02:35480 :: NameError
1230 12:02:35480 :: :
1230 12:02:35480 :: global name 'vnum' is not defined
1230 12:02:35480 ::

any help possible?

RpGkH7V.png

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 1
  • Love 1
4 godziny temu, TRBizeps napisał:

Thanks -  i already fixed the Problems, thanks to @Nevisor

 

he is a very friendly guy!!

 

But my problem is that i can't use destroy function....

Just comment this line

pjFRura.png

Edited by Metin2 Dev
Core X - External 2 Internal

Hi, please, everything is Ok but i cant see tooltip at top of item in new drop dialog. I use unedited nevisor's class, can anyone help me? I think problem is there:

		for i in xrange(min(3, ySlotCount)):
			self.slotList[i].SetPosition(0, 30 + ySlotCount*32 - i*32)
			if vnum != 1:
				self.slotList[i].OnMouseOverIn = lambda arg = slot: self.OverInItem(arg) ####HEREEEEE
				self.slotList[i].OnMouseOverOut = lambda arg = self.tooltipItem: self.OverOutItem(arg)
			else:
				self.slotList[i].OnMouseOverIn = lambda arg = localeInfo.MONETARY_UNIT0: self.OverInToolTip(arg)
				self.slotList[i].OnMouseOverOut = lambda: self.OverOutToolTip()
			self.slotList[i].Show()

I tried edit it to:

self.slotList[i].OnMouseOverIn = lambda arg = slot: self.OverInItem(vnum)

But it still dont work, sysser is clear and tooltip works with yangs.

Thanks

  • 2 weeks later...
  • Premium
Dnia 4.01.2018 o 23:50, Dimitar napisał:

Hi, please, everything is Ok but i cant see tooltip at top of item in new drop dialog. I use unedited nevisor's class, can anyone help me? I think problem is there:


		for i in xrange(min(3, ySlotCount)):
			self.slotList[i].SetPosition(0, 30 + ySlotCount*32 - i*32)
			if vnum != 1:
				self.slotList[i].OnMouseOverIn = lambda arg = slot: self.OverInItem(arg) ####HEREEEEE
				self.slotList[i].OnMouseOverOut = lambda arg = self.tooltipItem: self.OverOutItem(arg)
			else:
				self.slotList[i].OnMouseOverIn = lambda arg = localeInfo.MONETARY_UNIT0: self.OverInToolTip(arg)
				self.slotList[i].OnMouseOverOut = lambda: self.OverOutToolTip()
			self.slotList[i].Show()

I tried edit it to:


self.slotList[i].OnMouseOverIn = lambda arg = slot: self.OverInItem(vnum)

But it still dont work, sysser is clear and tooltip works with yangs.

Thanks

 

Dnia 10.12.2017 o 22:04, Nevisor napisał:

itemQuestionDialog.window_type = "inv" #for inventory

itemQuestionDialog.window_type = "shop" #for shops

 

  • 7 years later...

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.