Advertisement
Guest User

Gui.py

a guest
Oct 20th, 2018
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.98 KB | None | 0 0
  1. # Thanks to ProfessorEnte (ScriptVorlage mit Scrollbar)
  2. # By Kilroy
  3. import ui
  4. import app
  5. import chat
  6. import net
  7. import constInfo
  8. import item
  9. import uiToolTip
  10. import event
  11. import localeInfo
  12. import time
  13. import mouseModule
  14. import uiAttachMetin
  15. import uiScriptLocale
  16. import player
  17.  
  18. class Handelscenter(ui.ScriptWindow):
  19.  
  20. def __init__(self):
  21. ui.ScriptWindow.__init__(self)
  22. self.Hide()
  23. self.YangInGui = 0
  24. self.ButtonText = "ITEMS"
  25. self.ItemTable = [-1,-1,-1]
  26. self.tooltipItem = uiToolTip.ItemToolTip()
  27. self.tooltipItem.Hide()
  28.  
  29. def BuildWindow(self):
  30. constInfo.HANDELSCENTER_CONFIG["ITEMS"] = []
  31. constInfo.HANDELSCENTER_CONFIG["OWN_ITEMS"] = []
  32. self.ButtonText = "ITEMS"
  33. self.gui = None
  34. self.LogsDialog = None
  35. self.ItemBoard = None
  36. self.MoneyManager = GuildStorageMoneyManager()
  37. self.board = self.CreateBoard(750, 550, 200, 100)
  38. self.board.SetTitleName("Handelscenter")
  39. self.board.SetCloseEvent(self.Open)
  40. self.board.SetCenterPosition()
  41. self.Button1 = self.CreateButton(self.board, 530, 30, "Startseite", 0, self.__ChangeButton, "large_Button_")
  42. self.Button2 = self.CreateButton(self.board, 620, 30, "Im Verkauf", 1, self.__ChangeButton, "large_Button_")
  43. self.Button5 = self.CreateButton(self.board, 300, 33, "Logs", 0, self.__Logs, "small_Button_")
  44. self.Editline = self.CreateMoneyEditLine(self.board, 50, 35, "", self.OpenManager)
  45. self.Button6 = self.CreateButton(self.board, 350, 33, "Add Item", 2, self.__AddItem, "middle_Button_")
  46. self.PercentText = self.CreateTextline(self.board, 300, 300)
  47. self.PercentText.SetFontName("Arial:25")
  48. self.Editline.SetText("0 Yang")
  49.  
  50. # Kategorie
  51. self.Kategorie = ui.ThinBoard()
  52. self.Kategorie.SetParent(self.board)
  53. self.Kategorie.SetSize(120, 465)
  54. self.Kategorie.SetPosition(30, 65)
  55. self.Kategorie.Show()
  56. self.GUI = []
  57. self.buttons = ["Schwerter", "Zweihänder", "Dolche", "Glocke", "Fächer", "Bögen", "Rüstungen", "Helme", "Schilder", "Armbänder", "Ohrringe", "Halsketten", "Schuhe", "Gürtel", "Kostüme", "Frisuren", "Steine", "Sonstiges"]
  58. a = 10
  59. for i in xrange(len(self.buttons)):
  60. button = self.CreateButton(self.Kategorie, 17, a, self.buttons[i], self.buttons[i], self.__Kategorie, "large_Button_")
  61. a = a + 25
  62. self.GUI.append(button)
  63.  
  64. self.Show()
  65.  
  66. def SetPercantage(self, m1, m2):
  67. per = int(float(m2)/float(m1)*100)
  68. self.PercentText.Show()
  69. self.PercentText.SetText("Loading " + str(per) + "%")
  70.  
  71. def NoLogs(self):
  72. self.__ButtonControl(2, 2)
  73.  
  74. def __ButtonControl(self, arg, logs=1):
  75. if arg==2:
  76. for i in xrange(len(self.GUI)):
  77. self.GUI[i].SetEvent(ui.__mem_func__(self.__Kategorie), self.buttons[i])
  78. self.Button1.SetEvent(ui.__mem_func__(self.__ChangeButton), 0)
  79. self.Button2.SetEvent(ui.__mem_func__(self.__ChangeButton), 1)
  80. self.Button5.SetEvent(ui.__mem_func__(self.__Logs), 0)
  81. elif arg==1:
  82. if logs==1:
  83. if self.gui:
  84. for i in xrange(len(self.gui["boards"])):
  85. self.gui["boards"][i].Close()
  86. self.gui = None
  87. for i in xrange(len(self.GUI)):
  88. self.GUI[i].SetEvent(ui.__mem_func__(self.__Bug), 0)
  89. self.Button1.SetEvent(ui.__mem_func__(self.__Bug), 0)
  90. self.Button2.SetEvent(ui.__mem_func__(self.__Bug), 0)
  91. self.Button5.SetEvent(ui.__mem_func__(self.__Bug), 0)
  92.  
  93. def __Bug(self, arg):
  94. pass
  95.  
  96. def Scrollbar(self):
  97. self.__ButtonControl(2)
  98. if self.gui:
  99. for i in xrange(len(self.gui["boards"])):
  100. self.gui["boards"][i].Close()
  101. del self.gui
  102. self.PercentText.Hide()
  103. self.PercentText.SetText("Loading 0%")
  104. board_count = 7
  105. self.gui = {
  106. "scrollbar" : self.CreateScrollbar(self.board, self.board.GetHeight()-110,self.board.GetWidth()-30,70),
  107. "boards" : []
  108. }
  109.  
  110. for i in xrange(min(board_count, len(constInfo.HANDELSCENTER_CONFIG[self.ButtonText]))):
  111. self.gui["boards"].append(ExampleBoard(self.board, 160, 80 + 61 * i))
  112. self.gui["boards"][i].SetBoardInfo(i, constInfo.HANDELSCENTER_CONFIG[self.ButtonText][i]["vnum"], constInfo.HANDELSCENTER_CONFIG[self.ButtonText][i]["yang"], constInfo.HANDELSCENTER_CONFIG[self.ButtonText][i]["anzahl"], constInfo.HANDELSCENTER_CONFIG[self.ButtonText][i]["owner"], self.ButtonText)
  113.  
  114. if len(constInfo.HANDELSCENTER_CONFIG[self.ButtonText]) <= board_count:
  115. self.gui["scrollbar"].Hide()
  116. else:
  117. self.gui["scrollbar"].SetMiddleBarSize(float(board_count) / float(len(constInfo.HANDELSCENTER_CONFIG[self.ButtonText])))
  118. self.gui["scrollbar"].Show()
  119. self.gui["scrollbar"].SetScrollEvent(self.__OnScroll)
  120.  
  121. def __Kategorie(self, arg):
  122. self.__ButtonControl(1)
  123. constInfo.HANDELSCENTER_CONFIG["ITEMS"] = []
  124. constInfo.HANDELSCENTER_CONFIG["OWN_ITEMS"] = []
  125. self.ButtonText = "ITEMS"
  126. constInfo.HANDELSCENTER_CONFIG["CMD"] = "kategorie/" + arg
  127. event.QuestButtonClick(constInfo.HANDELSCENTER_CONFIG["index"])
  128.  
  129. def __ChangeButton(self, arg):
  130. self.__ButtonControl(1)
  131. constInfo.HANDELSCENTER_CONFIG["ITEMS"] = []
  132. constInfo.HANDELSCENTER_CONFIG["OWN_ITEMS"] = []
  133. self.ButtonText = ["ITEMS", "OWN_ITEMS"][arg]
  134. constInfo.HANDELSCENTER_CONFIG["CMD"] = "change_button/" + self.ButtonText
  135. event.QuestButtonClick(constInfo.HANDELSCENTER_CONFIG["index"])
  136.  
  137.  
  138. def __Logs(self, arg):
  139. if self.LogsDialog and self.LogsDialog.IsShow():
  140. self.CloseMe()
  141. return
  142. self.__ButtonControl(1, 2)
  143. constInfo.HANDELSCENTER_CONFIG["LOGS"] = []
  144. constInfo.HANDELSCENTER_CONFIG["CMD"] = "logs/0"
  145. event.QuestButtonClick(constInfo.HANDELSCENTER_CONFIG["index"])
  146. self.LogsDialog = self.CreateBoard(500, 200, 200, 100)
  147. self.LogsDialog.SetTitleName("Logs")
  148. self.LogsDialog.SetCloseEvent(self.CloseMe)
  149. self.LogsDialog.SetCenterPosition()
  150. self.list_1, self.ListBox1 = self.ListBoxEx(self.LogsDialog, 20, 40, 460, 140, 7)
  151. self.ListBox1.RemoveAllItems()
  152.  
  153. def AddToLog(self):
  154. self.__ButtonControl(2)
  155. for i in xrange(len(constInfo.HANDELSCENTER_CONFIG["LOGS"])):
  156. item.SelectItem(int(constInfo.HANDELSCENTER_CONFIG["LOGS"][i]["vnum"]))
  157. itemName = item.GetItemName()
  158. self.ListBox1.AppendItem(Item((constInfo.HANDELSCENTER_CONFIG["LOGS"][i]["date"].replace("$", " ") + " " + constInfo.HANDELSCENTER_CONFIG["LOGS"][i]["buyer"] + " hast/hat " + constInfo.HANDELSCENTER_CONFIG["LOGS"][i]["count"] + "x " + itemName + " von " + constInfo.HANDELSCENTER_CONFIG["LOGS"][i]["owner"] + " für " + self.NumberToMoneyString(constInfo.HANDELSCENTER_CONFIG["LOGS"][i]["preis"]) + " Yang gekauft.")))
  159.  
  160. def CloseMe(self):
  161. self.LogsDialog.Hide()
  162.  
  163. def OnUpdate(self):
  164. self.Editline.SetText(self.NumberToMoneyString(int(constInfo.HANDELSCENTER_CONFIG["YANG"])) + " Yang")
  165. if self.ItemBoard:
  166. if self.ItemBoard.IsShow():
  167. self.TextBox.SetText(self.NumberToMoneyString(self.Value.GetText()) + " Yang")
  168. if player.GetItemIndex(self.ItemTable[0])!=self.ItemTable[1]:
  169. self.SlotD.SetItemSlot(0, 0, 0)
  170. self.ItemTable = [-1,-1,-1]
  171.  
  172. def __OnScroll(self):
  173. board_count = len(self.gui["boards"])
  174. pos = int(self.gui["scrollbar"].GetPos() * (len(constInfo.HANDELSCENTER_CONFIG[self.ButtonText]) - board_count))
  175.  
  176. for i in xrange(board_count):
  177. realPos = i + pos
  178. self.gui["boards"][i].SetBoardInfo(realPos, constInfo.HANDELSCENTER_CONFIG[self.ButtonText][realPos]["vnum"], constInfo.HANDELSCENTER_CONFIG[self.ButtonText][realPos]["yang"], constInfo.HANDELSCENTER_CONFIG[self.ButtonText][realPos]["anzahl"], constInfo.HANDELSCENTER_CONFIG[self.ButtonText][realPos]["owner"], self.ButtonText)
  179.  
  180. ####### Item Add Function Board
  181. def __AddItem(self, arg):
  182. if arg==2:
  183. self.ItemTable = [-1,-1,-1]
  184. self.ItemBoard = ui.BoardWithTitleBar()
  185. self.ItemBoard.SetSize(195, 210)
  186. self.ItemBoard.SetCenterPosition()
  187. self.ItemBoard.SetTitleName("Handelscenter")
  188. self.ItemBoard.AddFlag("movable")
  189. self.ItemBoard.AddFlag("float")
  190. self.ItemBoard.SetCloseEvent(self.CloseItemBoard)
  191. self.ItemBoard.Show()
  192. self.Slot = ui.ExpandedImageBox()
  193. self.Slot.SetParent(self.ItemBoard)
  194. self.Slot.SetPosition(35, 45)
  195. self.Slot.LoadImage("handelscenter/slot.tga")
  196. self.Slot.Show()
  197. self.SlotBar1 = ui.SlotBar()
  198. self.SlotBar1.SetParent(self.ItemBoard)
  199. self.SlotBar1.SetSize(130, 17)
  200. self.SlotBar1.SetPosition(15, 175)
  201. self.SlotBar1.Show()
  202. self.Button7 = self.CreateButton(self.ItemBoard, 120, 33, "Put In", 3, self.__AddItem, "middle_Button_")
  203. self.Value = ui.EditLine()
  204. self.Value.SetParent(self.SlotBar1)
  205. self.Value.SetSize(130, 17)
  206. self.Value.SetPosition(5, 2)
  207. self.Value.SetMax(14)
  208. self.Value.SetLimitWidth(130)
  209. self.Value.SetMultiLine()
  210. self.Value.SetText("")
  211. self.Value.Show()
  212. self.TextBox = self.CreateTextline(self.ItemBoard, 75, 160)
  213. self.TextBox.SetText("Yang")
  214. self.SlotD = ui.SlotWindow()
  215. self.SlotD.SetParent(self.ItemBoard)
  216. self.SlotD.SetPosition(35, 45)
  217. self.SlotD.SetSize(32, 96)
  218. self.SlotD.AppendSlot(0, 0, 0, 32, 96)
  219. self.SlotD.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectItemSlot))
  220. self.SlotD.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
  221. self.SlotD.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  222. self.SlotD.SetOverOutItemEvent(ui.__mem_func__(self.OnOverOutItem))
  223. self.SlotD.Show()
  224. elif arg==3:
  225. if self.ItemTable[0]!=-1 and self.ItemTable[1]!=-1 and self.ItemTable[2]!=-1:
  226. if self.IsInteger(self.Value.GetText()):
  227. self.Button7.SetEvent(ui.__mem_func__(self.__Bug), 0)
  228. #chat.AppendChat(1, str(self.ItemTable[0]) + " " + str(self.ItemTable[1]))
  229. constInfo.HANDELSCENTER_CONFIG["CMD"] = ("additem/" + str(self.ItemTable[0]) + "/" + str(self.ItemTable[1]) + "/" + self.Value.GetText())
  230. event.QuestButtonClick(constInfo.HANDELSCENTER_CONFIG["index"])
  231. self.CloseItemBoard()
  232. else:
  233. chat.AppendChat(1, "Du musst schon eine Zahl eingeben!")
  234. else:
  235. chat.AppendChat(1, "Du musst schon ein Item in den Slot packen!")
  236.  
  237. def OverInItem(self, slotNumber):
  238. if self.tooltipItem:
  239. if self.ItemTable[0]!=-1:
  240. self.tooltipItem.SetInventoryItem(self.ItemTable[0])
  241.  
  242. def OnOverOutItem(self):
  243. if self.tooltipItem:
  244. self.tooltipItem.HideToolTip()
  245.  
  246. def SelectItemSlot(self, itemSlotIndex):
  247. isAttached = mouseModule.mouseController.isAttached()
  248. if isAttached:
  249. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  250. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  251. itemIndex = player.GetItemIndex(attachedSlotPos)
  252. itemCount = player.GetItemCount(attachedSlotPos)
  253. mouseModule.mouseController.DeattachObject()
  254. item.SelectItem(itemIndex)
  255. self.SlotD.SetItemSlot(itemSlotIndex, itemIndex, itemCount)
  256. self.ItemTable = [int(attachedSlotPos), itemIndex, itemCount]
  257. else:
  258. self.SlotD.SetItemSlot(itemSlotIndex, 0, 0)
  259. self.ItemTable = [-1,-1,-1]
  260.  
  261. def CloseItemBoard(self):
  262. self.ItemBoard.Hide()
  263.  
  264. def IsInteger(self, n):
  265. try:
  266. int(n)
  267. return 1
  268. except ValueError:
  269. return 0
  270. ######## Item Add Function Board End
  271.  
  272.  
  273. def CreateBoard(self, width, height, x, y):
  274. board = ui.BoardWithTitleBar()
  275. board.SetSize(width, height)
  276. board.SetPosition(x, y)
  277. board.AddFlag("movable")
  278. board.Show()
  279. return board
  280.  
  281. def CreateMoneyEditLine(self, parent, x, y, text, func):
  282. button = ui.Button()
  283. button.SetParent(parent)
  284. button.SetPosition(x, y)
  285. button.SetUpVisual("d:/ymir work/ui/public/parameter_slot_05.sub")
  286. button.SetOverVisual("d:/ymir work/ui/public/parameter_slot_05.sub")
  287. button.SetDownVisual("d:/ymir work/ui/public/parameter_slot_05.sub")
  288. button.SetText(text)
  289. button.SetEvent(func)
  290. button.Show()
  291. return button
  292.  
  293. def OpenManager(self):
  294. self.MoneyManager.Open()
  295.  
  296. def CreateButton(self, parent, x, y, text, event, tbutton, sub):
  297. button = ui.Button()
  298. button.SetParent(parent)
  299. button.SetPosition(x, y)
  300. button.SetUpVisual("d:/ymir work/ui/public/" + sub + "01.sub")
  301. button.SetOverVisual("d:/ymir work/ui/public/" + sub+ "02.sub")
  302. button.SetDownVisual("d:/ymir work/ui/public/" + sub+ "03.sub")
  303. button.SetText(text)
  304. button.SetEvent(ui.__mem_func__(tbutton), event)
  305. button.Show()
  306. return button
  307.  
  308. def CreateScrollbar(self, parent, height, x, y):
  309. scrollbar = ui.ScrollBar()
  310. scrollbar.SetParent(parent)
  311. scrollbar.SetScrollBarSize(height)
  312. scrollbar.SetPosition(x, y)
  313. scrollbar.Show()
  314. return scrollbar
  315.  
  316. def CreateTextline(self, parent, x, y):
  317. textline = ui.TextLine()
  318. textline.SetParent(parent)
  319. textline.SetPosition(x,y)
  320. textline.SetHorizontalAlignCenter()
  321. textline.Show()
  322. return textline
  323.  
  324. def ListBoxEx(self, parent, x, y, width, heigh, count):
  325. bar = ui.Bar()
  326. if parent != None:
  327. bar.SetParent(parent)
  328. bar.SetPosition(x, y)
  329. bar.SetSize(width, heigh)
  330. bar.SetColor(0x77000000)
  331. bar.Show()
  332. ListBox=ui.ListBoxEx()
  333. ListBox.SetParent(bar)
  334. ListBox.SetPosition(3, 0)
  335. ListBox.SetSize(width, heigh)
  336. ListBox.SetViewItemCount(count)
  337. ListBox.Show()
  338. scroll = ui.ScrollBar()
  339. scroll.SetParent(ListBox)
  340. scroll.SetPosition(width-15, 0)
  341. scroll.SetScrollBarSize(heigh)
  342. scroll.Show()
  343. ListBox.SetScrollBar(scroll)
  344. return bar, ListBox
  345.  
  346. def NumberToMoneyString(self, money):
  347. sourceText = str(money)
  348. if len(sourceText) <= 3:
  349. return sourceText
  350. return self.NumberToMoneyString(sourceText[:-3]) + "." + sourceText[-3:]
  351.  
  352. def Open(self):
  353. if self.IsShow():
  354. if self.LogsDialog:
  355. self.LogsDialog.Hide()
  356. if self.ItemBoard:
  357. self.CloseItemBoard()
  358. self.board.Hide()
  359. self.Hide()
  360. return
  361. self.BuildWindow()
  362.  
  363.  
  364. class ExampleBoard(ui.ScriptWindow):
  365. boni = {
  366. item.APPLY_MAX_HP : localeInfo.TOOLTIP_MAX_HP,
  367. item.APPLY_MAX_SP : localeInfo.TOOLTIP_MAX_SP,
  368. item.APPLY_CON : localeInfo.TOOLTIP_CON,
  369. item.APPLY_INT : localeInfo.TOOLTIP_INT,
  370. item.APPLY_STR : localeInfo.TOOLTIP_STR,
  371. item.APPLY_DEX : localeInfo.TOOLTIP_DEX,
  372. item.APPLY_ATT_SPEED : localeInfo.TOOLTIP_ATT_SPEED,
  373. item.APPLY_MOV_SPEED : localeInfo.TOOLTIP_MOV_SPEED,
  374. item.APPLY_CAST_SPEED : localeInfo.TOOLTIP_CAST_SPEED,
  375. item.APPLY_HP_REGEN : localeInfo.TOOLTIP_HP_REGEN,
  376. item.APPLY_SP_REGEN : localeInfo.TOOLTIP_SP_REGEN,
  377. item.APPLY_POISON_PCT : localeInfo.TOOLTIP_APPLY_POISON_PCT,
  378. item.APPLY_STUN_PCT : localeInfo.TOOLTIP_APPLY_STUN_PCT,
  379. item.APPLY_SLOW_PCT : localeInfo.TOOLTIP_APPLY_SLOW_PCT,
  380. item.APPLY_CRITICAL_PCT : localeInfo.TOOLTIP_APPLY_CRITICAL_PCT,
  381. item.APPLY_PENETRATE_PCT : localeInfo.TOOLTIP_APPLY_PENETRATE_PCT,
  382.  
  383. item.APPLY_ATTBONUS_WARRIOR : localeInfo.TOOLTIP_APPLY_ATTBONUS_WARRIOR,
  384. item.APPLY_ATTBONUS_ASSASSIN : localeInfo.TOOLTIP_APPLY_ATTBONUS_ASSASSIN,
  385. item.APPLY_ATTBONUS_SURA : localeInfo.TOOLTIP_APPLY_ATTBONUS_SURA,
  386. item.APPLY_ATTBONUS_SHAMAN : localeInfo.TOOLTIP_APPLY_ATTBONUS_SHAMAN,
  387. item.APPLY_ATTBONUS_MONSTER : localeInfo.TOOLTIP_APPLY_ATTBONUS_MONSTER,
  388.  
  389. item.APPLY_ATTBONUS_HUMAN : localeInfo.TOOLTIP_APPLY_ATTBONUS_HUMAN,
  390. item.APPLY_ATTBONUS_ANIMAL : localeInfo.TOOLTIP_APPLY_ATTBONUS_ANIMAL,
  391. item.APPLY_ATTBONUS_ORC : localeInfo.TOOLTIP_APPLY_ATTBONUS_ORC,
  392. item.APPLY_ATTBONUS_MILGYO : localeInfo.TOOLTIP_APPLY_ATTBONUS_MILGYO,
  393. item.APPLY_ATTBONUS_UNDEAD : localeInfo.TOOLTIP_APPLY_ATTBONUS_UNDEAD,
  394. item.APPLY_ATTBONUS_DEVIL : localeInfo.TOOLTIP_APPLY_ATTBONUS_DEVIL,
  395. item.APPLY_STEAL_HP : localeInfo.TOOLTIP_APPLY_STEAL_HP,
  396. item.APPLY_STEAL_SP : localeInfo.TOOLTIP_APPLY_STEAL_SP,
  397. item.APPLY_MANA_BURN_PCT : localeInfo.TOOLTIP_APPLY_MANA_BURN_PCT,
  398. item.APPLY_DAMAGE_SP_RECOVER : localeInfo.TOOLTIP_APPLY_DAMAGE_SP_RECOVER,
  399. item.APPLY_BLOCK : localeInfo.TOOLTIP_APPLY_BLOCK,
  400. item.APPLY_DODGE : localeInfo.TOOLTIP_APPLY_DODGE,
  401. item.APPLY_RESIST_SWORD : localeInfo.TOOLTIP_APPLY_RESIST_SWORD,
  402. item.APPLY_RESIST_TWOHAND : localeInfo.TOOLTIP_APPLY_RESIST_TWOHAND,
  403. item.APPLY_RESIST_DAGGER : localeInfo.TOOLTIP_APPLY_RESIST_DAGGER,
  404. item.APPLY_RESIST_BELL : localeInfo.TOOLTIP_APPLY_RESIST_BELL,
  405. item.APPLY_RESIST_FAN : localeInfo.TOOLTIP_APPLY_RESIST_FAN,
  406. item.APPLY_RESIST_BOW : localeInfo.TOOLTIP_RESIST_BOW,
  407. item.APPLY_RESIST_FIRE : localeInfo.TOOLTIP_RESIST_FIRE,
  408. item.APPLY_RESIST_ELEC : localeInfo.TOOLTIP_RESIST_ELEC,
  409. item.APPLY_RESIST_MAGIC : localeInfo.TOOLTIP_RESIST_MAGIC,
  410. item.APPLY_RESIST_WIND : localeInfo.TOOLTIP_APPLY_RESIST_WIND,
  411. item.APPLY_REFLECT_MELEE : localeInfo.TOOLTIP_APPLY_REFLECT_MELEE,
  412. item.APPLY_REFLECT_CURSE : localeInfo.TOOLTIP_APPLY_REFLECT_CURSE,
  413. item.APPLY_POISON_REDUCE : localeInfo.TOOLTIP_APPLY_POISON_REDUCE,
  414. item.APPLY_KILL_SP_RECOVER : localeInfo.TOOLTIP_APPLY_KILL_SP_RECOVER,
  415. item.APPLY_EXP_DOUBLE_BONUS : localeInfo.TOOLTIP_APPLY_EXP_DOUBLE_BONUS,
  416. item.APPLY_GOLD_DOUBLE_BONUS : localeInfo.TOOLTIP_APPLY_GOLD_DOUBLE_BONUS,
  417. item.APPLY_ITEM_DROP_BONUS : localeInfo.TOOLTIP_APPLY_ITEM_DROP_BONUS,
  418. item.APPLY_POTION_BONUS : localeInfo.TOOLTIP_APPLY_POTION_BONUS,
  419. item.APPLY_KILL_HP_RECOVER : localeInfo.TOOLTIP_APPLY_KILL_HP_RECOVER,
  420. item.APPLY_IMMUNE_STUN : localeInfo.TOOLTIP_APPLY_IMMUNE_STUN,
  421. item.APPLY_IMMUNE_SLOW : localeInfo.TOOLTIP_APPLY_IMMUNE_SLOW,
  422. item.APPLY_IMMUNE_FALL : localeInfo.TOOLTIP_APPLY_IMMUNE_FALL,
  423. item.APPLY_BOW_DISTANCE : localeInfo.TOOLTIP_BOW_DISTANCE,
  424. item.APPLY_DEF_GRADE_BONUS : localeInfo.TOOLTIP_DEF_GRADE,
  425. item.APPLY_ATT_GRADE_BONUS : localeInfo.TOOLTIP_ATT_GRADE,
  426. item.APPLY_MAGIC_ATT_GRADE : localeInfo.TOOLTIP_MAGIC_ATT_GRADE,
  427. item.APPLY_MAGIC_DEF_GRADE : localeInfo.TOOLTIP_MAGIC_DEF_GRADE,
  428. item.APPLY_MAX_STAMINA : localeInfo.TOOLTIP_MAX_STAMINA,
  429. item.APPLY_MALL_ATTBONUS : localeInfo.TOOLTIP_MALL_ATTBONUS,
  430. item.APPLY_MALL_DEFBONUS : localeInfo.TOOLTIP_MALL_DEFBONUS,
  431. item.APPLY_MALL_EXPBONUS : localeInfo.TOOLTIP_MALL_EXPBONUS,
  432. item.APPLY_MALL_ITEMBONUS : localeInfo.TOOLTIP_MALL_ITEMBONUS,
  433. item.APPLY_MALL_GOLDBONUS : localeInfo.TOOLTIP_MALL_GOLDBONUS,
  434. item.APPLY_SKILL_DAMAGE_BONUS : localeInfo.TOOLTIP_SKILL_DAMAGE_BONUS,
  435. item.APPLY_NORMAL_HIT_DAMAGE_BONUS : localeInfo.TOOLTIP_NORMAL_HIT_DAMAGE_BONUS,
  436. item.APPLY_SKILL_DEFEND_BONUS : localeInfo.TOOLTIP_SKILL_DEFEND_BONUS,
  437. item.APPLY_NORMAL_HIT_DEFEND_BONUS : localeInfo.TOOLTIP_NORMAL_HIT_DEFEND_BONUS,
  438. item.APPLY_PC_BANG_EXP_BONUS : localeInfo.TOOLTIP_MALL_EXPBONUS_P_STATIC,
  439. item.APPLY_PC_BANG_DROP_BONUS : localeInfo.TOOLTIP_MALL_ITEMBONUS_P_STATIC,
  440. item.APPLY_RESIST_WARRIOR : localeInfo.TOOLTIP_APPLY_RESIST_WARRIOR,
  441. item.APPLY_RESIST_ASSASSIN : localeInfo.TOOLTIP_APPLY_RESIST_ASSASSIN,
  442. item.APPLY_RESIST_SURA : localeInfo.TOOLTIP_APPLY_RESIST_SURA,
  443. item.APPLY_RESIST_SHAMAN : localeInfo.TOOLTIP_APPLY_RESIST_SHAMAN,
  444. item.APPLY_MAX_HP_PCT : localeInfo.TOOLTIP_APPLY_MAX_HP_PCT,
  445. item.APPLY_MAX_SP_PCT : localeInfo.TOOLTIP_APPLY_MAX_SP_PCT,
  446. item.APPLY_ENERGY : localeInfo.TOOLTIP_ENERGY,
  447. item.APPLY_COSTUME_ATTR_BONUS : localeInfo.TOOLTIP_COSTUME_ATTR_BONUS,
  448.  
  449. item.APPLY_MAGIC_ATTBONUS_PER : localeInfo.TOOLTIP_MAGIC_ATTBONUS_PER,
  450. item.APPLY_MELEE_MAGIC_ATTBONUS_PER : localeInfo.TOOLTIP_MELEE_MAGIC_ATTBONUS_PER,
  451. item.APPLY_RESIST_ICE : localeInfo.TOOLTIP_RESIST_ICE,
  452. item.APPLY_RESIST_EARTH : localeInfo.TOOLTIP_RESIST_EARTH,
  453. item.APPLY_RESIST_DARK : localeInfo.TOOLTIP_RESIST_DARK,
  454. item.APPLY_ANTI_CRITICAL_PCT : localeInfo.TOOLTIP_ANTI_CRITICAL_PCT,
  455. item.APPLY_ANTI_PENETRATE_PCT : localeInfo.TOOLTIP_ANTI_PENETRATE_PCT,
  456. }
  457. def __init__(self, parent, x, y):
  458. ui.ScriptWindow.__init__(self)
  459. self.tooltipItem = uiToolTip.ItemToolTip()
  460. self.tooltipItem.Hide()
  461. self.ButtonText = "ITEMS"
  462. self.board = self.CreateBoard(parent, 550, 60, x, y)
  463. self.gui = {
  464. "buttons" : {
  465. "thebutton" : self.CreateButton(self.board, 30 + 50 * 9, 11 + 10 * 1, "", self.Button_func)
  466. },
  467. "textlines" : {
  468. "name": self.CreateTextline(self.board, 10 + 50 * 2, 23 + 20 * 0),
  469. "yang": self.CreateTextline(self.board, 40 + 50 * 4, 23 + 20 * 0),
  470. "anzahl": self.CreateTextline(self.board, 40 + 50 * 6, 23 + 20 * 0),
  471. "owner": self.CreateTextline(self.board, 10 + 50 * 8, 23 + 20 * 0)
  472. },
  473. "image": {
  474. "picture": self.CreateImage(self.board, 10 + 50 * 0, 10 + 20* 0)
  475. }
  476. }
  477. self.Show()
  478.  
  479. def OnUpdate(self):
  480. if self.gui["image"]["picture"].IsIn():
  481. self.tooltipItem.ClearToolTip()
  482. self.tooltipItem.AddItemData(self.itemid, self.metinSlot, self.attrSlot)
  483. else:
  484. self.tooltipItem.HideToolTip()
  485.  
  486. def Button_func(self):
  487. constInfo.HANDELSCENTER_CONFIG["CMD"] = "buyrem_button/" + self.ButtonText + "/" + str(constInfo.HANDELSCENTER_CONFIG[self.ButtonText][self.index]["id"]) + "/" + str(self.index)
  488. event.QuestButtonClick(constInfo.HANDELSCENTER_CONFIG["index"])
  489.  
  490. def NumberToMoneyString(self, money):
  491. sourceText = str(money)
  492. if len(sourceText) <= 3:
  493. return sourceText
  494. return self.NumberToMoneyString(sourceText[:-3]) + "." + sourceText[-3:]
  495.  
  496.  
  497. def SetBoardInfo(self, index, id, yang, anzahl, owner, button):
  498. self.ButtonText = button
  499. self.index = index
  500. self.itemid = id
  501. self.metinSlot = [constInfo.HANDELSCENTER_CONFIG[button][self.index]["socket0"],constInfo.HANDELSCENTER_CONFIG[button][self.index]["socket1"],constInfo.HANDELSCENTER_CONFIG[button][self.index]["socket2"],constInfo.HANDELSCENTER_CONFIG[button][self.index]["socket3"],constInfo.HANDELSCENTER_CONFIG[button][self.index]["socket4"],constInfo.HANDELSCENTER_CONFIG[button][self.index]["socket5"]]
  502. self.attrSlot = [constInfo.HANDELSCENTER_CONFIG[button][self.index]["boni1"], constInfo.HANDELSCENTER_CONFIG[button][self.index]["boni2"], constInfo.HANDELSCENTER_CONFIG[button][self.index]["boni3"], constInfo.HANDELSCENTER_CONFIG[button][self.index]["boni4"], constInfo.HANDELSCENTER_CONFIG[button][self.index]["boni5"], constInfo.HANDELSCENTER_CONFIG[button][self.index]["boni6"], constInfo.HANDELSCENTER_CONFIG[button][self.index]["boni7"]]
  503. self.gui["buttons"]["thebutton"].SetText({"ITEMS": "Kaufen", "OWN_ITEMS":"Remove"}[button])
  504. item.SelectItem(id)
  505. itemIcon = item.GetIconImageFileName()
  506. itemName = item.GetItemName()
  507. self.gui["textlines"]["name"].SetText(itemName)
  508. self.gui["textlines"]["yang"].SetText(self.NumberToMoneyString(yang) + " Yang")
  509. self.gui["textlines"]["anzahl"].SetText(str(anzahl))
  510. self.gui["textlines"]["owner"].SetText(owner)
  511. self.gui["image"]["picture"].LoadImage(itemIcon)
  512. if self.gui["image"]["picture"].GetHeight()==32:
  513. self.gui["image"]["picture"].SetScale(1,1)
  514. if self.gui["image"]["picture"].GetHeight()==64:
  515. self.gui["image"]["picture"].SetScale(1,0.7)
  516. if self.gui["image"]["picture"].GetHeight()==96:
  517. self.gui["image"]["picture"].SetScale(1,0.5)
  518.  
  519. def Close(self):
  520. self.board.Hide()
  521. self.tooltipItem.HideToolTip()
  522. self.Hide()
  523.  
  524. def CreateTextline(self, parent, x, y):
  525. textline = ui.TextLine()
  526. textline.SetParent(parent)
  527. textline.SetPosition(x,y)
  528. textline.SetHorizontalAlignCenter()
  529. textline.Show()
  530. return textline
  531.  
  532. def CreateImage(self, parent, x, y):
  533. image = ui.ExpandedImageBox()
  534. image.SetParent(parent)
  535. image.SetPosition(x,y)
  536. image.Show()
  537. return image
  538.  
  539. def CreateBoard(self, parent, width, height, x, y):
  540. board = ui.Board()
  541. board.SetParent(parent)
  542. board.SetSize(width, height)
  543. board.SetPosition(x, y)
  544. board.SetTop()
  545. board.Show()
  546. return board
  547.  
  548. def CreateButton(self, parent, x, y, text, event):
  549. button = ui.Button()
  550. button.SetParent(parent)
  551. button.SetPosition(x, y)
  552. button.SetUpVisual("d:/ymir work/ui/public/Middle_Button_01.sub")
  553. button.SetOverVisual("d:/ymir work/ui/public/Middle_Button_02.sub")
  554. button.SetDownVisual("d:/ymir work/ui/public/Middle_Button_03.sub")
  555. button.SetText(text)
  556. button.SetEvent(event)
  557. button.Show()
  558. return button
  559.  
  560. class Item(ui.ListBoxEx.Item):
  561. def __init__(self, text):
  562. ui.ListBoxEx.Item.__init__(self)
  563. self.canLoad=0
  564. self.text=text
  565. self.textLine=self.__CreateTextLine(text[:100])
  566.  
  567. def __del__(self):
  568. ui.ListBoxEx.Item.__del__(self)
  569.  
  570. def GetText(self):
  571. return self.text
  572.  
  573. def SetSize(self, width, height):
  574. pass
  575.  
  576. def __CreateTextLine(self, text):
  577. textLine=ui.TextLine()
  578. textLine.SetParent(self)
  579. textLine.SetPosition(0, 0)
  580. textLine.SetText(text)
  581. textLine.Show()
  582. return textLine
  583.  
  584. class GuildStorageMoneyManager(ui.ScriptWindow):
  585.  
  586. def __init__(self):
  587. ui.ScriptWindow.__init__(self)
  588. self.__Initialize()
  589. self.isLoaded = FALSE
  590.  
  591. def __Initialize(self):
  592. self.children = []
  593. self.xGuildStorageStart = 0
  594. self.yGuildStorageStart = 0
  595.  
  596. def __LoadScript(self):
  597. try:
  598. pyScrLoader = ui.PythonScriptLoader()
  599. pyScrLoader.LoadScriptFile(self, "GuildStorageMoneyManager.py")
  600. except:
  601. import exception
  602. exception.Abort("test.__LoadScript.LoadObject")
  603.  
  604. try:
  605. self.board = self.GetChild("Board")
  606. self.titleBar = self.GetChild("TitleBar")
  607. self.GetChild("CashInButton").SetEvent(self.CashInButton)
  608. self.GetChild("CashOutButton").SetEvent(self.CashOutButton)
  609. self.amountInput = self.GetChild("AmountInput")
  610.  
  611. except:
  612. import exception
  613. exception.Abort("test.__LoadScript.BindObject")
  614.  
  615. self.amountInput.SetNumberMode()
  616.  
  617. self.titleBar.SetCloseEvent(ui.__mem_func__(self.Close))
  618. self.isLoaded = TRUE
  619.  
  620.  
  621. def __del__(self):
  622. ui.ScriptWindow.__del__(self)
  623.  
  624.  
  625. def Destroy(self):
  626. self.Close()
  627.  
  628. def Open(self):
  629. if FALSE == self.isLoaded:
  630. self.__LoadScript()
  631. self.__Initialize()
  632. self.SetTop()
  633. self.Show()
  634. (self.xGuildStorageStart, self.yGuildStorageStart, z) = player.GetMainCharacterPosition()
  635. self.amountInput.SetText("1")
  636.  
  637.  
  638. def CashOutButton(self):
  639. money = self.amountInput.GetText()
  640. if money == "":
  641. self.amountInput.SetText("1")
  642. return
  643. self.QuestCMD("yangabheben/"+str(money))
  644. self.amountInput.SetText("1")
  645. self.Close()
  646.  
  647. def CashInButton(self):
  648. money = self.amountInput.GetText()
  649. if money == "":
  650. self.amountInput.SetText("1")
  651. return
  652. self.QuestCMD("yangabgeben/"+str(money))
  653. self.amountInput.SetText("1")
  654. self.Close()
  655.  
  656. def SendSystemChat(self, text):
  657. chat.AppendChat(chat.CHAT_TYPE_INFO, "<System>: "+str(text))
  658.  
  659. def QuestCMD(self, command):
  660. constInfo.HANDELSCENTER_CONFIG["CMD"] = command
  661. event.QuestButtonClick(int(constInfo.HANDELSCENTER_CONFIG["index"]))
  662.  
  663. def Close(self):
  664. self.Hide()
  665.  
  666. def OnPressEscapeKey(self):
  667. self.Close()
  668. return TRUE
  669.  
  670. def OnPressExitKey(self):
  671. self.Close()
  672. return TRUE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement