1. import os
  2. import ui
  3. import player
  4. import mouseModule
  5. import net
  6. import app
  7. import snd
  8. import item
  9. import player
  10. import chat
  11. import grp
  12. import uiScriptLocale
  13. import localeInfo
  14. import constInfo
  15. import ime
  16. import wndMgr
  17. import petskill
  18. import uipetfeed
  19. import uiToolTip
  20. import uipetsystem
  21. import interfaceModule
  22. AFFECT_DICT = {
  23. item.APPLY_MAX_HP : localeInfo.TOOLTIP_MAX_HP,
  24. item.APPLY_MAX_SP : localeInfo.TOOLTIP_MAX_SP,
  25. item.APPLY_CON : localeInfo.TOOLTIP_CON,
  26. item.APPLY_INT : localeInfo.TOOLTIP_INT,
  27. item.APPLY_STR : localeInfo.TOOLTIP_STR,
  28. item.APPLY_DEX : localeInfo.TOOLTIP_DEX,
  29. item.APPLY_ATT_SPEED : localeInfo.TOOLTIP_ATT_SPEED,
  30. item.APPLY_MOV_SPEED : localeInfo.TOOLTIP_MOV_SPEED,
  31. item.APPLY_CAST_SPEED : localeInfo.TOOLTIP_CAST_SPEED,
  32. item.APPLY_HP_REGEN : localeInfo.TOOLTIP_HP_REGEN,
  33. item.APPLY_SP_REGEN : localeInfo.TOOLTIP_SP_REGEN,
  34. item.APPLY_POISON_PCT : localeInfo.TOOLTIP_APPLY_POISON_PCT,
  35. item.APPLY_STUN_PCT : localeInfo.TOOLTIP_APPLY_STUN_PCT,
  36. item.APPLY_SLOW_PCT : localeInfo.TOOLTIP_APPLY_SLOW_PCT,
  37. item.APPLY_CRITICAL_PCT : localeInfo.TOOLTIP_APPLY_CRITICAL_PCT,
  38. item.APPLY_PENETRATE_PCT : localeInfo.TOOLTIP_APPLY_PENETRATE_PCT,
  39. item.APPLY_ATTBONUS_WARRIOR : localeInfo.TOOLTIP_APPLY_ATTBONUS_WARRIOR,
  40. item.APPLY_ATTBONUS_ASSASSIN : localeInfo.TOOLTIP_APPLY_ATTBONUS_ASSASSIN,
  41. item.APPLY_ATTBONUS_SURA : localeInfo.TOOLTIP_APPLY_ATTBONUS_SURA,
  42. item.APPLY_ATTBONUS_SHAMAN : localeInfo.TOOLTIP_APPLY_ATTBONUS_SHAMAN,
  43. item.APPLY_ATTBONUS_MONSTER : localeInfo.TOOLTIP_APPLY_ATTBONUS_MONSTER,
  44. item.APPLY_ATTBONUS_HUMAN : localeInfo.TOOLTIP_APPLY_ATTBONUS_HUMAN,
  45. item.APPLY_ATTBONUS_ANIMAL : localeInfo.TOOLTIP_APPLY_ATTBONUS_ANIMAL,
  46. item.APPLY_ATTBONUS_ORC : localeInfo.TOOLTIP_APPLY_ATTBONUS_ORC,
  47. item.APPLY_ATTBONUS_MILGYO : localeInfo.TOOLTIP_APPLY_ATTBONUS_MILGYO,
  48. item.APPLY_ATTBONUS_UNDEAD : localeInfo.TOOLTIP_APPLY_ATTBONUS_UNDEAD,
  49. item.APPLY_ATTBONUS_DEVIL : localeInfo.TOOLTIP_APPLY_ATTBONUS_DEVIL,
  50. item.APPLY_STEAL_HP : localeInfo.TOOLTIP_APPLY_STEAL_HP,
  51. item.APPLY_STEAL_SP : localeInfo.TOOLTIP_APPLY_STEAL_SP,
  52. item.APPLY_MANA_BURN_PCT : localeInfo.TOOLTIP_APPLY_MANA_BURN_PCT,
  53. item.APPLY_DAMAGE_SP_RECOVER : localeInfo.TOOLTIP_APPLY_DAMAGE_SP_RECOVER,
  54. item.APPLY_BLOCK : localeInfo.TOOLTIP_APPLY_BLOCK,
  55. item.APPLY_DODGE : localeInfo.TOOLTIP_APPLY_DODGE,
  56. item.APPLY_RESIST_SWORD : localeInfo.TOOLTIP_APPLY_RESIST_SWORD,
  57. item.APPLY_RESIST_TWOHAND : localeInfo.TOOLTIP_APPLY_RESIST_TWOHAND,
  58. item.APPLY_RESIST_DAGGER : localeInfo.TOOLTIP_APPLY_RESIST_DAGGER,
  59. item.APPLY_RESIST_BELL : localeInfo.TOOLTIP_APPLY_RESIST_BELL,
  60. item.APPLY_RESIST_FAN : localeInfo.TOOLTIP_APPLY_RESIST_FAN,
  61. item.APPLY_RESIST_BOW : localeInfo.TOOLTIP_RESIST_BOW,
  62. item.APPLY_RESIST_FIRE : localeInfo.TOOLTIP_RESIST_FIRE,
  63. item.APPLY_RESIST_ELEC : localeInfo.TOOLTIP_RESIST_ELEC,
  64. item.APPLY_RESIST_MAGIC : localeInfo.TOOLTIP_RESIST_MAGIC,
  65. item.APPLY_RESIST_WIND : localeInfo.TOOLTIP_APPLY_RESIST_WIND,
  66. item.APPLY_REFLECT_MELEE : localeInfo.TOOLTIP_APPLY_REFLECT_MELEE,
  67. item.APPLY_REFLECT_CURSE : localeInfo.TOOLTIP_APPLY_REFLECT_CURSE,
  68. item.APPLY_POISON_REDUCE : localeInfo.TOOLTIP_APPLY_POISON_REDUCE,
  69. item.APPLY_KILL_SP_RECOVER : localeInfo.TOOLTIP_APPLY_KILL_SP_RECOVER,
  70. item.APPLY_EXP_DOUBLE_BONUS : localeInfo.TOOLTIP_APPLY_EXP_DOUBLE_BONUS,
  71. item.APPLY_GOLD_DOUBLE_BONUS : localeInfo.TOOLTIP_APPLY_GOLD_DOUBLE_BONUS,
  72. item.APPLY_ITEM_DROP_BONUS : localeInfo.TOOLTIP_APPLY_ITEM_DROP_BONUS,
  73. item.APPLY_POTION_BONUS : localeInfo.TOOLTIP_APPLY_POTION_BONUS,
  74. item.APPLY_KILL_HP_RECOVER : localeInfo.TOOLTIP_APPLY_KILL_HP_RECOVER,
  75. item.APPLY_IMMUNE_STUN : localeInfo.TOOLTIP_APPLY_IMMUNE_STUN,
  76. item.APPLY_IMMUNE_SLOW : localeInfo.TOOLTIP_APPLY_IMMUNE_SLOW,
  77. item.APPLY_IMMUNE_FALL : localeInfo.TOOLTIP_APPLY_IMMUNE_FALL,
  78. item.APPLY_BOW_DISTANCE : localeInfo.TOOLTIP_BOW_DISTANCE,
  79. item.APPLY_DEF_GRADE_BONUS : localeInfo.TOOLTIP_DEF_GRADE,
  80. item.APPLY_ATT_GRADE_BONUS : localeInfo.TOOLTIP_ATT_GRADE,
  81. item.APPLY_MAGIC_ATT_GRADE : localeInfo.TOOLTIP_MAGIC_ATT_GRADE,
  82. item.APPLY_MAGIC_DEF_GRADE : localeInfo.TOOLTIP_MAGIC_DEF_GRADE,
  83. item.APPLY_MAX_STAMINA : localeInfo.TOOLTIP_MAX_STAMINA,
  84. item.APPLY_MALL_ATTBONUS : localeInfo.TOOLTIP_MALL_ATTBONUS,
  85. item.APPLY_MALL_DEFBONUS : localeInfo.TOOLTIP_MALL_DEFBONUS,
  86. item.APPLY_MALL_EXPBONUS : localeInfo.TOOLTIP_MALL_EXPBONUS,
  87. item.APPLY_MALL_ITEMBONUS : localeInfo.TOOLTIP_MALL_ITEMBONUS,
  88. item.APPLY_MALL_GOLDBONUS : localeInfo.TOOLTIP_MALL_GOLDBONUS,
  89. item.APPLY_SKILL_DAMAGE_BONUS : localeInfo.TOOLTIP_SKILL_DAMAGE_BONUS,
  90. item.APPLY_NORMAL_HIT_DAMAGE_BONUS : localeInfo.TOOLTIP_NORMAL_HIT_DAMAGE_BONUS,
  91. item.APPLY_SKILL_DEFEND_BONUS : localeInfo.TOOLTIP_SKILL_DEFEND_BONUS,
  92. item.APPLY_NORMAL_HIT_DEFEND_BONUS : localeInfo.TOOLTIP_NORMAL_HIT_DEFEND_BONUS,
  93. item.APPLY_PC_BANG_EXP_BONUS : localeInfo.TOOLTIP_MALL_EXPBONUS_P_STATIC,
  94. item.APPLY_PC_BANG_DROP_BONUS : localeInfo.TOOLTIP_MALL_ITEMBONUS_P_STATIC,
  95. item.APPLY_RESIST_WARRIOR : localeInfo.TOOLTIP_APPLY_RESIST_WARRIOR,
  96. item.APPLY_RESIST_ASSASSIN : localeInfo.TOOLTIP_APPLY_RESIST_ASSASSIN,
  97. item.APPLY_RESIST_SURA : localeInfo.TOOLTIP_APPLY_RESIST_SURA,
  98. item.APPLY_RESIST_SHAMAN : localeInfo.TOOLTIP_APPLY_RESIST_SHAMAN,
  99. item.APPLY_MAX_HP_PCT : localeInfo.TOOLTIP_APPLY_MAX_HP_PCT,
  100. item.APPLY_MAX_SP_PCT : localeInfo.TOOLTIP_APPLY_MAX_SP_PCT,
  101. item.APPLY_ENERGY : localeInfo.TOOLTIP_ENERGY,
  102. item.APPLY_COSTUME_ATTR_BONUS : localeInfo.TOOLTIP_COSTUME_ATTR_BONUS,
  103. item.APPLY_MAGIC_ATTBONUS_PER : localeInfo.TOOLTIP_MAGIC_ATTBONUS_PER,
  104. item.APPLY_MELEE_MAGIC_ATTBONUS_PER : localeInfo.TOOLTIP_MELEE_MAGIC_ATTBONUS_PER,
  105. item.APPLY_RESIST_ICE : localeInfo.TOOLTIP_RESIST_ICE,
  106. item.APPLY_RESIST_EARTH : localeInfo.TOOLTIP_RESIST_EARTH,
  107. item.APPLY_RESIST_DARK : localeInfo.TOOLTIP_RESIST_DARK,
  108. item.APPLY_ANTI_CRITICAL_PCT : localeInfo.TOOLTIP_ANTI_CRITICAL_PCT,
  109. item.APPLY_ANTI_PENETRATE_PCT : localeInfo.TOOLTIP_ANTI_PENETRATE_PCT,
  110. }
  111. def checkdiv(n):
  112. x = str(n/10.0)
  113. if len(x) > 3:
  114. return str(x)[0:3]
  115. return str(x)
  116. def pointop(n):
  117. t = int(n)
  118. if t / 10 < 1:
  119. return "0."+n
  120. else:
  121. return n[0:len(n)-1]+"."+n[len(n)-1:]
  122. def GetAffectString(affectType, affectValue):
  123. if 0 == affectType:
  124. return None
  125. if 0 == affectValue:
  126. return None
  127. try:
  128. return AFFECT_DICT[affectType](affectValue)
  129. except TypeError:
  130. return "UNKNOWN_VALUE[%s] %s" % (affectType, affectValue)
  131. except KeyError:
  132. return "UNKNOWN_TYPE[%s] %s" % (affectType, affectValue)
  133. class PetSystemMain(ui.ScriptWindow):
  134. class TextToolTip(ui.Window):
  135. def __init__(self, y):
  136. ui.Window.__init__(self, "TOP_MOST")
  137. textLine = ui.TextLine()
  138. textLine.SetParent(self)
  139. textLine.SetHorizontalAlignLeft()
  140. textLine.SetOutline()
  141. textLine.Show()
  142. self.y = y
  143. self.textLine = textLine
  144. def __del__(self):
  145. ui.Window.__del__(self)
  146. def SetText(self, text):
  147. self.textLine.SetText(text)
  148. def OnRender(self):
  149. (mouseX, mouseY) = wndMgr.GetMousePosition()
  150. self.textLine.SetPosition(mouseX, mouseY - 60 + self.y)
  151. def __init__(self, vnum = 0):
  152. ui.ScriptWindow.__init__(self)
  153. self.vnum = vnum
  154. self.__LoadWindow()
  155. def __del__(self):
  156. ui.ScriptWindow.__del__(self)
  157. def Show(self):
  158. ui.ScriptWindow.Show(self)
  159. def Close(self):
  160. self.Hide()
  161. constInfo.PET_MAIN = 0
  162. self.feedwind.Close()
  163. def OnPressEscapeKey(self):
  164. self.Close()
  165. return True
  166. def __LoadWindow(self):
  167. try:
  168. pyScrLoader = ui.PythonScriptLoader()
  169. pyScrLoader.LoadScriptFile(self, "uiscript/PetInformationWindow.py")
  170. except:
  171. import exception
  172. exception.Abort("PetInformationWindow.LoadWindow.LoadObject")
  173. try:
  174. self.feedwind = uipetfeed.PetFeedWindow()
  175. self.board = self.GetChild("board")
  176. self.boardclose = self.GetChild("CloseButton")
  177. self.slotimgpet = self.GetChild("UpBringing_Pet_Slot")
  178. self.evolname = self.GetChild("EvolName")
  179. self.petname = self.GetChild("PetName")
  180. self.expwind = self.GetChild("UpBringing_Pet_EXP_Gauge_Board")
  181. self.tooltipexp = []
  182. for i in range(0,4):
  183. self.tooltipexp.append(self.TextToolTip(15*i))
  184. self.tooltipexp[i].Hide()
  185. self.petlifeg = self.GetChild("LifeGauge")
  186. self.petlevel = self.GetChild("LevelValue")
  187. self.petexpa = self.GetChild("UpBringing_Pet_EXPGauge_01")
  188. self.petexpb = self.GetChild("UpBringing_Pet_EXPGauge_02")
  189. self.petexpc = self.GetChild("UpBringing_Pet_EXPGauge_03")
  190. self.petexpd = self.GetChild("UpBringing_Pet_EXPGauge_04")
  191. self.petexpe = self.GetChild("UpBringing_Pet_EXPGauge_05")
  192. self.petexppages = []
  193. self.petexppages.append(self.petexpa)
  194. self.petexppages.append(self.petexpb)
  195. self.petexppages.append(self.petexpc)
  196. self.petexppages.append(self.petexpd)
  197. self.petexppages.append(self.petexpe)
  198. for exp in self.petexppages:
  199. exp.SetSize(0, 0)
  200. #exp.Hide()
  201. self.petages = self.GetChild("AgeValue")
  202. self.petdur = self.GetChild("LifeTextValue")
  203. #gaugehp
  204. self.nutribtn = self.GetChild("FeedLifeTimeButton")
  205. self.sviluppobtn = self.GetChild("FeedEvolButton")
  206. self.itemexp = self.GetChild("FeedExpButton")
  207. self.pethp = self.GetChild("HpValue")
  208. self.petdef = self.GetChild("DefValue")
  209. self.petsp = self.GetChild("SpValue")
  210. self.petskill0 = self.GetChild("PetSkillSlot0")
  211. #self.petskill0.SetPetSkillSlot(0, 2, 10)
  212. #self.petskill0.SetPetSkillSlot(1, 11, 10)
  213. #self.petskill0.SetPetSkillSlot(2, 5, 10)
  214. self.petskill0.SetSlot(0, 2, 32, 32, petskill.GetEmptySkill())
  215. self.petskill0.SetSlot(1, 2, 32, 32, petskill.GetEmptySkill())
  216. self.petskill0.SetSlot(2, 2, 32, 32, petskill.GetEmptySkill())
  217. #self.petskill0.SetCoverButton(0)
  218. #self.petskill0.SetCoverButton(1)
  219. #self.petskill0.SetCoverButton(2)
  220. #self.petskill0.SetAlwaysRenderCoverButton(0, TRUE)
  221. #self.petskill0.SetAlwaysRenderCoverButton(1, TRUE)
  222. #self.petskill0.SetAlwaysRenderCoverButton(2, TRUE)
  223. self.petskill0.SetSelectItemSlotEvent(ui.__mem_func__(self.UseSkill))
  224. self.petskill0.SetUseSlotEvent(ui.__mem_func__(self.UseSkill))
  225. self.petskill0.SetOverInItemEvent(ui.__mem_func__(self.PetSkillTooltipShow))
  226. self.petskill0.SetOverOutItemEvent(ui.__mem_func__(self.PetSkillTooltipHide))
  227. self.SetDefaultInfo()
  228. self.arrytooltip = [ [-1,-1], [-1,-1], [-1,-1]]
  229. PET_FILE_NAME = "%s/pet_skill.txt" % app.GetLocalePath()
  230. PET_FILE_SKILL = "%s/pet_skill_bonus.txt" % app.GetLocalePath()
  231. self.linespet = pack_open(PET_FILE_NAME, "r").readlines()
  232. self.linespetskill = pack_open(PET_FILE_SKILL, "r").readlines()
  233. self.SkillTooltip = uiToolTip.ToolTip(180)
  234. #Event
  235. self.boardclose.SetEvent(ui.__mem_func__(self.Close,))
  236. self.nutribtn.SetToggleDownEvent(lambda arg=0,arg1=1: self.OpenFeedBox(arg,arg1))
  237. self.nutribtn.SetToggleUpEvent(lambda arg=1,arg1=0: self.OpenFeedBox(arg,arg1))
  238. self.itemexp.SetToggleDownEvent(lambda arg=0,arg1=3: self.OpenFeedBox(arg,arg1))
  239. self.itemexp.SetToggleUpEvent(lambda arg=1,arg1=0: self.OpenFeedBox(arg,arg1))
  240. self.sviluppobtn.SetToggleDownEvent(lambda arg=0: self.evolution(arg))
  241. self.sviluppobtn.SetToggleUpEvent(lambda arg=1: self.evolution(arg))
  242. except:
  243. import exception
  244. exception.Abort("PetInformationWindow.LoadWindow.BindObject")
  245. def PetSkillTooltipShow(self, slot):
  246. if self.arrytooltip[slot][0] > 0:
  247. tokens = self.linespet[self.arrytooltip[slot][0]-1][:-1].split("\t")
  248. tokens2 = self.linespetskill[self.arrytooltip[slot][0]-1][:-1].split("\t")
  249. self.SkillTooltip.ClearToolTip()
  250. self.SkillTooltip.AutoAppendTextLine(tokens[1], grp.GenerateColor(0.9490, 0.9058, 0.7568, 1.0))
  251. self.SkillTooltip.AppendDescription(tokens[4], 26)
  252. self.SkillTooltip.AppendSpace(5)
  253. if self.arrytooltip[slot][0] != 10 and self.arrytooltip[slot][0] != 17 and self.arrytooltip[slot][0] != 18:
  254. self.SkillTooltip.AutoAppendTextLine(GetAffectString(int(tokens2[1]), int(tokens2[self.arrytooltip[slot][1]+1])))
  255. elif self.arrytooltip[slot][0] == 10:
  256. self.SkillTooltip.AutoAppendTextLine(localeInfo.PET_SYSTEM_HP_RESTORED + str(tokens2[self.arrytooltip[slot][1]+1]))
  257. elif self.arrytooltip[slot][0] == 17:
  258. self.SkillTooltip.AutoAppendTextLine(localeInfo.PET_SYSTEM_IMMORTAL_TIME + checkdiv(int(tokens2[self.arrytooltip[slot][1]+1])) + "s")
  259. self.SkillTooltip.AutoAppendTextLine(localeInfo.PET_SYSTEM_SKILL_COOLDOWN+tokens[5]+"s", grp.GenerateColor(1.0, 0.7843, 0.0, 1.0))
  260. self.SkillTooltip.AlignHorizonalCenter()
  261. self.SkillTooltip.ShowToolTip()
  262. def PetSkillTooltipHide(self):
  263. self.SkillTooltip.HideToolTip()
  264. def evolution(self, mode):
  265. if mode == 0:
  266. net.SendChatPacket("/petvoincrease")
  267. self.sviluppobtn.Enable()
  268. #self.SkillTooltip.HideToolTip()
  269. def SetDefaultInfo(self):
  270. self.evolname.SetText("")
  271. self.petname.SetText("")
  272. self.petlevel.SetText("")
  273. self.petages.SetText("")
  274. self.petdur.SetText("")
  275. self.pethp.SetText("")
  276. self.petdef.SetText("")
  277. self.petsp.SetText("")
  278. self.SetDuration("0", "0")
  279. self.SetDurationYas("0")
  280. self.slotimgpet.ClearSlot(0)
  281. self.petskill0.ClearSlot(0)
  282. self.petskill0.ClearSlot(1)
  283. self.petskill0.ClearSlot(2)
  284. self.petskill0.SetSlot(0, 2, 32, 32, petskill.GetEmptySkill())
  285. self.petskill0.SetSlot(1, 2, 32, 32, petskill.GetEmptySkill())
  286. self.petskill0.SetSlot(2, 2, 32, 32, petskill.GetEmptySkill())
  287. self.SetExperience(0,0,0)
  288. self.arrytooltip = [ [-1,-1], [-1,-1], [-1,-1]]
  289. self.nutribtn.Disable()
  290. self.sviluppobtn.Disable()
  291. self.itemexp.Disable()
  292. def OpenFeedBox(self, mode, btn):
  293. if constInfo.FEEDWIND == btn or constInfo.FEEDWIND == 0:
  294. if mode == 0:
  295. self.feedwind.Show()
  296. constInfo.FEEDWIND = btn
  297. else:
  298. self.feedwind.Close()
  299. constInfo.FEEDWIND = 0
  300. else:
  301. self.nutribtn.Enable()
  302. self.sviluppobtn.Enable()
  303. self.itemexp.Enable()
  304. self.feedwind.Close()
  305. constInfo.FEEDWIND = 0
  306. def SetImageSlot(self, vnum):
  307. self.slotimgpet.SetItemSlot(0, int(vnum), 0)
  308. self.slotimgpet.SetAlwaysRenderCoverButton(0, TRUE)
  309. def SetEvolveName(self, name):
  310. self.evolname.SetText(name)
  311. def SetName(self, name):
  312. if name != "":
  313. self.nutribtn.Enable()
  314. self.sviluppobtn.Enable()
  315. self.itemexp.Enable()
  316. #pet.SetTop()
  317. else:
  318. self.nutribtn.Disable()
  319. self.sviluppobtn.Disable()
  320. self.itemexp.Disable()
  321. self.petname.SetText(name)
  322. def SetLevel(self, level):
  323. if int(level) == 40 or int(level) == 60 or int(level) == 80:
  324. constInfo.EVOLUTION = int(level)
  325. else:
  326. constInfo.EVOLUTION = 0
  327. self.petlevel.SetText(level)
  328. def SetAges(self, ages):
  329. self.petages.SetText(ages)
  330. def SetDuration(self, dur, durt):
  331. dur1 = int(dur)/60
  332. durt1 = int(durt)/60
  333. tmpage = int((int(durt)/60 -int(dur) /60)/24)
  334. if int(dur) > 0:
  335. self.petlifeg.SetPercentage(int(dur)*1.6, int(durt))
  336. self.petlifeg.Show()
  337. else:
  338. self.petlifeg.Hide()
  339. self.petdur.SetText(str(dur1)+"/"+str(durt1)+localeInfo.PET_SYSTEM_ORE)
  340. if tmpage == 0:
  341. tmpage = 1
  342. self.SetAges(str(tmpage)+localeInfo.PET_SYSTEM_ZILE)
  343. def SetDurationYas(self, dur_yas):
  344. merhaba_canim = int(dur_yas)/60/24
  345. self.SetAges(str(merhaba_canim)+" Gun")
  346. def SetHp(self, hp):
  347. self.pethp.SetText(pointop(hp)+"%")
  348. def SetDef(self, deff):
  349. self.petdef.SetText(pointop(deff)+"%")
  350. def SetSp(self, sp):
  351. self.petsp.SetText(pointop(sp)+"%")
  352. def SetSkill(self, slot, idx, lv):
  353. if int(idx) != -1:
  354. self.petskill0.ClearSlot(int(slot))
  355. self.petskill0.SetPetSkillSlot(int(slot), int(idx), int(lv))
  356. self.petskill0.SetCoverButton(int(slot))
  357. self.petskill0.SetAlwaysRenderCoverButton(int(slot), TRUE)
  358. self.arrytooltip[int(slot)][0] = int(idx)
  359. self.arrytooltip[int(slot)][1] = int(lv)
  360. #chat.AppendChat(chat.CHAT_TYPE_INFO, "Slot:"+str(slot)+" idx: "+str(idx)+" Lv:"+str(lv))
  361. def SetExperience(self, expm, expi, exptot):
  362. expm = int(expm)
  363. expi = int(expi)
  364. exptot = int(exptot)
  365. if exptot > 0:
  366. totalexp = exptot
  367. totexpm = int( float(totalexp) / 100 * 90 )
  368. totexpi = totalexp - totexpm
  369. expi = min(expi, totexpi)
  370. expmp = float(expm) / totexpm * 100
  371. expip = float(expi) / totexpi * 100
  372. else:
  373. totalexp = 0
  374. totexpm = 0
  375. totexpi = 0
  376. expmp = 0
  377. expip = 0
  378. curPoint = int(min(expm, totexpm))
  379. curPoint = int(max(expm, 0))
  380. maxPoint = int(max(totexpm, 0))
  381. curPointi = int(min(expi, totexpi))
  382. curPointi = int(max(expi, 0))
  383. maxPointi = int(max(totexpi, 0))
  384. quarterPoint = maxPoint / 4
  385. quarterPointi = maxPointi
  386. FullCount = 0
  387. FullCounti = 0
  388. if 0 != quarterPoint:
  389. FullCount = min(4, curPoint / quarterPoint)
  390. if 0 != quarterPointi:
  391. FullCounti = min(1, curPointi / quarterPointi)
  392. for i in xrange(4):
  393. self.petexppages[i].Hide()
  394. self.petexppages[4].Hide()
  395. for i in xrange(FullCount):
  396. self.petexppages[i].SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  397. self.petexppages[i].Show()
  398. for i in xrange(FullCounti):
  399. self.petexppages[4].SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  400. self.petexppages[4].Show()
  401. if 0 != quarterPoint:
  402. if FullCount < 4:
  403. Percentage = float(curPoint % quarterPoint) / quarterPoint - 1.0
  404. self.petexppages[FullCount].SetRenderingRect(0.0, Percentage, 0.0, 0.0)
  405. self.petexppages[FullCount].Show()
  406. if 0 != quarterPointi:
  407. if FullCounti < 1:
  408. Percentage = float(curPointi % quarterPointi) / quarterPointi - 1.0
  409. self.petexppages[4].SetRenderingRect(0.0, Percentage, 0.0, 0.0)
  410. self.petexppages[4].Show()
  411. #chat.AppendChat(chat.CHAT_TYPE_INFO, str(curPoint)+"-"+str(maxPoint)+"-"+str(FullCount)+"--"+str(quarterPoint))
  412. #####
  413. self.tooltipexp[0].SetText(localeInfo.PET_INFO_EXP % expmp)
  414. self.tooltipexp[1].SetText(localeInfo.PET_INFO_NEXT_EXP % (totexpm - expm, totexpm))
  415. self.tooltipexp[2].SetText(localeInfo.PET_INFO_ITEM_EXP % expip)
  416. self.tooltipexp[3].SetText(localeInfo.PET_INFO_NEXT_ITEM_EXP % (totexpi - expi, totexpi))
  417. def UseSkill(self, slot):
  418. #chat.AppendChat(chat.CHAT_TYPE_INFO, "+ --> "+str(slot))
  419. #chat.AppendChat(chat.CHAT_TYPE_INFO, "Skill: "+ str(petskill.GetSkillbySlot(slot)))
  420. net.SendChatPacket("/petskills "+str(slot))
  421. def OnUpdate(self):
  422. if constInfo.FEEDWIND == 0:
  423. self.nutribtn.Enable()
  424. #self.sviluppobtn.Enable()
  425. self.itemexp.Enable()
  426. if TRUE == self.expwind.IsIn():
  427. for i in range(0,4):
  428. self.tooltipexp[i].Show()
  429. else:
  430. for i in range(0,4):
  431. self.tooltipexp[i].Hide()
  432. class PetSystemMini(ui.ScriptWindow):
  433. class TextToolTip(ui.Window):
  434. def __init__(self, y):
  435. ui.Window.__init__(self, "TOP_MOST")
  436. textLine = ui.TextLine()
  437. textLine.SetParent(self)
  438. textLine.SetHorizontalAlignLeft()
  439. textLine.SetOutline()
  440. textLine.Show()
  441. self.y = y
  442. self.textLine = textLine
  443. def __del__(self):
  444. ui.Window.__del__(self)
  445. def SetText(self, text):
  446. self.textLine.SetText(text)
  447. def OnRender(self):
  448. (mouseX, mouseY) = wndMgr.GetMousePosition()
  449. self.textLine.SetPosition(mouseX, mouseY - 60 + self.y)
  450. def __init__(self, vnum = 0):
  451. ui.ScriptWindow.__init__(self)
  452. self.vnum = vnum
  453. self.__LoadWindow()
  454. def __del__(self):
  455. ui.ScriptWindow.__del__(self)
  456. def Show(self):
  457. ui.ScriptWindow.Show(self)
  458. def Close(self):
  459. self.Hide()
  460. def OnPressEscapeKey(self):
  461. self.Close()
  462. return True
  463. def __LoadWindow(self):
  464. try:
  465. pyScrLoader = ui.PythonScriptLoader()
  466. pyScrLoader.LoadScriptFile(self, "uiscript/PetMiniInformationWindow.py")
  467. except:
  468. import exception
  469. exception.Abort("PetMiniInformationWindow.LoadWindow.LoadObject")
  470. try:
  471. self.expwind = self.GetChild("pet_mini_info_exp_gauge_board")
  472. self.expwind1 = self.GetChild("pet_mini_info_exp_gauge_board1")
  473. self.mainbg = self.GetChild("main_bg")
  474. self.mainicon = self.GetChild("main_slot_img")
  475. self.main_slot_img = self.GetChild("pet_icon_slot")
  476. self.tooltipexp = []
  477. for i in range(0,4):
  478. self.tooltipexp.append(self.TextToolTip(15*i))
  479. self.tooltipexp[i].Hide()
  480. self.pet_icon_slot_ani_img = self.GetChild("pet_icon_slot_ani_img")
  481. self.pet_mini_exp_01 = self.GetChild("pet_mini_EXPGauge_01")
  482. self.pet_mini_exp_02 = self.GetChild("pet_mini_EXPGauge_02")
  483. self.pet_mini_exp_03 = self.GetChild("pet_mini_EXPGauge_03")
  484. self.pet_mini_exp_04 = self.GetChild("pet_mini_EXPGauge_04")
  485. self.pet_mini_exp_05 = self.GetChild("pet_mini_EXPGauge_05")
  486. self.petmini_exp = []
  487. self.petmini_exp.append(self.pet_mini_exp_01)
  488. self.petmini_exp.append(self.pet_mini_exp_02)
  489. self.petmini_exp.append(self.pet_mini_exp_03)
  490. self.petmini_exp.append(self.pet_mini_exp_04)
  491. self.petmini_exp.append(self.pet_mini_exp_05)
  492. self.petlifeg = self.GetChild("LifeGauge")
  493. self.pet_icon_slot_ani_img.Hide()
  494. self.skillslot = self.GetChild("mini_skill_slot0")
  495. #self.skillslot.SetSlotScale(0, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  496. #self.skillslot.SetSlotScale(1, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  497. #self.skillslot.SetSlotScale(2, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  498. self.skillslot.SetSelectItemSlotEvent(ui.__mem_func__(self.UseSkill))
  499. self.skillslot.SetUseSlotEvent(ui.__mem_func__(self.UseSkill))
  500. self.main_slot_img.SetUseSlotEvent(ui.__mem_func__(self.OpenPet))
  501. self.main_slot_img.SetSelectItemSlotEvent(ui.__mem_func__(self.OpenPet))
  502. self.SetDefaultInfo()
  503. #self.mainbg.Show()
  504. except:
  505. import exception
  506. exception.Abort("PetMiniInformationWindow.LoadWindow.BindObject")
  507. def SetDefaultInfo(self):
  508. self.SetDuration("0", "0")
  509. self.main_slot_img.ClearSlot(0)
  510. self.skillslot.ClearSlot(0)
  511. self.skillslot.ClearSlot(1)
  512. self.skillslot.ClearSlot(2)
  513. self.skillslot.SetSlotScale(0, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  514. self.skillslot.SetSlotScale(1, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  515. self.skillslot.SetSlotScale(2, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  516. self.SetExperience(0,0,0)
  517. def OpenPet(self):
  518. net.SendChatPacket("/gift")
  519. def SetImageSlot(self, vnum):
  520. self.main_slot_img.SetItemSlot(0, int(vnum), 0)
  521. self.main_slot_img.SetAlwaysRenderCoverButton(0, TRUE)
  522. def SetDuration(self, dur, durt):
  523. tmpage = int((int(durt)/60 -int(dur) /60)/24)
  524. if int(dur) > 0:
  525. self.petlifeg.SetPercentage(int(dur), int(durt))
  526. self.petlifeg.Show()
  527. else:
  528. self.petlifeg.Hide()
  529. def SetSkill(self, slot, idx, lv):
  530. if int(idx) != -1:
  531. self.skillslot.ClearSlot(int(slot))
  532. self.skillslot.SetPetSkillSlot(int(slot), int(idx), int(lv), 0.5, 0.5)
  533. self.skillslot.SetCoverButton(int(slot), "d:/ymir work/ui/pet/mini_window/pet_slot_corvermini.sub", "d:/ymir work/ui/pet/mini_window/pet_slot_corvermini.sub", "d:/ymir work/ui/pet/mini_window/pet_slot_corvermini.sub" , "d:/ymir work/ui/pet/mini_window/pet_slot_corvermini.sub")
  534. self.skillslot.SetAlwaysRenderCoverButton(int(slot), TRUE)
  535. def SetExperience(self, expm, expi, exptot):
  536. expm = int(expm)
  537. expi = int(expi)
  538. exptot = int(exptot)
  539. if exptot > 0:
  540. totalexp = exptot
  541. totexpm = int( float(totalexp) / 100 * 90 )
  542. totexpi = totalexp - totexpm
  543. expi = min(expi, totexpi)
  544. expmp = float(expm) / totexpm * 100
  545. expip = float(expi) / totexpi * 100
  546. else:
  547. totalexp = 0
  548. totexpm = 0
  549. totexpi = 0
  550. expmp = 0
  551. expip = 0
  552. curPoint = int(min(expm, totexpm))
  553. curPoint = int(max(expm, 0))
  554. maxPoint = int(max(totexpm, 0))
  555. curPointi = int(min(expi, totexpi))
  556. curPointi = int(max(expi, 0))
  557. maxPointi = int(max(totexpi, 0))
  558. quarterPoint = maxPoint / 4
  559. quarterPointi = maxPointi
  560. FullCount = 0
  561. FullCounti = 0
  562. if 0 != quarterPoint:
  563. FullCount = min(4, curPoint / quarterPoint)
  564. if 0 != quarterPointi:
  565. FullCounti = min(1, curPointi / quarterPointi)
  566. for i in xrange(4):
  567. self.petmini_exp[i].Hide()
  568. self.petmini_exp[4].Hide()
  569. for i in xrange(FullCount):
  570. self.petmini_exp[i].SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  571. self.petmini_exp[i].Show()
  572. for i in xrange(FullCounti):
  573. self.petmini_exp[4].SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  574. self.petmini_exp[4].Show()
  575. if 0 != quarterPoint:
  576. if FullCount < 4:
  577. Percentage = float(curPoint % quarterPoint) / quarterPoint - 1.0
  578. self.petmini_exp[FullCount].SetRenderingRect(0.0, Percentage, 0.0, 0.0)
  579. self.petmini_exp[FullCount].Show()
  580. if 0 != quarterPointi:
  581. if FullCounti < 1:
  582. Percentage = float(curPointi % quarterPointi) / quarterPointi - 1.0
  583. self.petmini_exp[4].SetRenderingRect(0.0, Percentage, 0.0, 0.0)
  584. self.petmini_exp[4].Show()
  585. #####
  586. self.tooltipexp[0].SetText(localeInfo.PET_INFO_EXP % expmp)
  587. self.tooltipexp[1].SetText(localeInfo.PET_INFO_NEXT_EXP % (totexpm - expm, totexpm))
  588. self.tooltipexp[2].SetText(localeInfo.PET_INFO_ITEM_EXP % expip)
  589. self.tooltipexp[3].SetText(localeInfo.PET_INFO_NEXT_ITEM_EXP % (totexpi - expi, totexpi))
  590. def UseSkill(self, slot):
  591. chat.AppendChat(chat.CHAT_TYPE_INFO, "+ --> "+str(slot))
  592. #chat.AppendChat(chat.CHAT_TYPE_INFO, "Skill: "+ str(petskill.GetSkillbySlot(slot)))
  593. net.SendChatPacket("/petskills "+str(slot))
  594. def OnUpdate(self):
  595. if constInfo.PET_LEVEL == 40 and constInfo.PET_EVOLUTION == 0:
  596. self.pet_icon_slot_ani_img.Show()
  597. elif constInfo.PET_LEVEL == 81 and constInfo.PET_EVOLUTION == 1:
  598. self.pet_icon_slot_ani_img.Show()
  599. elif constInfo.PET_LEVEL == 81 and constInfo.PET_EVOLUTION == 2:
  600. self.pet_icon_slot_ani_img.Show()
  601. else:
  602. self.pet_icon_slot_ani_img.Hide()
  603. if TRUE == self.expwind1.IsIn():
  604. for i in range(0,4):
  605. self.tooltipexp[i].Show()
  606. else:
  607. for i in range(0,4):
  608. self.tooltipexp[i].Hide()