thanato1994

Untitled

Dec 7th, 2020
14
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import ui
  2. import localeInfo
  3. import app
  4. import ime
  5. import uiScriptLocale
  6.  
  7. class PopupDialog(ui.ScriptWindow):
  8.  
  9. def __init__(self):
  10. ui.ScriptWindow.__init__(self)
  11. self.__LoadDialog()
  12. self.acceptEvent = lambda *arg: None
  13.  
  14. def __del__(self):
  15. ui.ScriptWindow.__del__(self)
  16.  
  17. def __LoadDialog(self):
  18. try:
  19. PythonScriptLoader = ui.PythonScriptLoader()
  20. PythonScriptLoader.LoadScriptFile(self, "UIScript/PopupDialog.py")
  21.  
  22. self.board = self.GetChild("board")
  23. self.message = self.GetChild("message")
  24. self.accceptButton = self.GetChild("accept")
  25. self.accceptButton.SetEvent(ui.__mem_func__(self.Close))
  26.  
  27. except:
  28. import exception
  29. exception.Abort("PopupDialog.LoadDialog.BindObject")
  30.  
  31. def Open(self):
  32. self.SetCenterPosition()
  33. self.SetTop()
  34. self.Show()
  35.  
  36. def Close(self):
  37. self.Hide()
  38. self.acceptEvent()
  39.  
  40. def Destroy(self):
  41. self.Close()
  42. self.ClearDictionary()
  43.  
  44. def SetWidth(self, width):
  45. height = self.GetHeight()
  46. self.SetSize(width, height)
  47. self.board.SetSize(width, height)
  48. self.SetCenterPosition()
  49. self.UpdateRect()
  50.  
  51. def SetText(self, text):
  52. self.message.SetText(text)
  53.  
  54. def SetAcceptEvent(self, event):
  55. self.acceptEvent = event
  56.  
  57. def SetButtonName(self, name):
  58. self.accceptButton.SetText(name)
  59.  
  60. def OnPressEscapeKey(self):
  61. self.Close()
  62. return True
  63.  
  64. def OnIMEReturn(self):
  65. self.Close()
  66. return True
  67.  
  68. class InputDialog(ui.ScriptWindow):
  69.  
  70. def __init__(self):
  71. ui.ScriptWindow.__init__(self)
  72.  
  73. self.__CreateDialog()
  74.  
  75. def __del__(self):
  76. ui.ScriptWindow.__del__(self)
  77.  
  78. def __CreateDialog(self):
  79.  
  80. pyScrLoader = ui.PythonScriptLoader()
  81. pyScrLoader.LoadScriptFile(self, "uiscript/inputdialog.py")
  82.  
  83. getObject = self.GetChild
  84. self.board = getObject("Board")
  85. self.acceptButton = getObject("AcceptButton")
  86. self.cancelButton = getObject("CancelButton")
  87. self.inputSlot = getObject("InputSlot")
  88. self.inputValue = getObject("InputValue")
  89.  
  90. def Open(self):
  91. self.inputValue.SetFocus()
  92. self.SetCenterPosition()
  93. self.SetTop()
  94. self.Show()
  95.  
  96. def Close(self):
  97. self.ClearDictionary()
  98. self.board = None
  99. self.acceptButton = None
  100. self.cancelButton = None
  101. self.inputSlot = None
  102. self.inputValue = None
  103. self.Hide()
  104.  
  105. def SetTitle(self, name):
  106. self.board.SetTitleName(name)
  107.  
  108. def SetNumberMode(self):
  109. self.inputValue.SetNumberMode()
  110.  
  111. def SetSecretMode(self):
  112. self.inputValue.SetSecret()
  113.  
  114. def SetFocus(self):
  115. self.inputValue.SetFocus()
  116.  
  117. def SetMaxLength(self, length):
  118. width = length * 6 + 13
  119. self.SetBoardWidth(max(width + 50, 160))
  120. self.SetSlotWidth(width)
  121. self.inputValue.SetMax(length)
  122.  
  123. def SetSlotWidth(self, width):
  124. self.inputSlot.SetSize(width, self.inputSlot.GetHeight())
  125. self.inputValue.SetSize(width, self.inputValue.GetHeight())
  126. if self.IsRTL():
  127. self.inputValue.SetPosition(self.inputValue.GetWidth(), 0)
  128.  
  129. def SetBoardWidth(self, width):
  130. self.SetSize(max(width + 50, 160), self.GetHeight())
  131. self.board.SetSize(max(width + 50, 160), self.GetHeight())
  132. if self.IsRTL():
  133. self.board.SetPosition(self.board.GetWidth(), 0)
  134. self.UpdateRect()
  135.  
  136. def SetAcceptEvent(self, event):
  137. self.acceptButton.SetEvent(event)
  138. self.inputValue.OnIMEReturn = event
  139.  
  140. def SetCancelEvent(self, event):
  141. self.board.SetCloseEvent(event)
  142. self.cancelButton.SetEvent(event)
  143. self.inputValue.OnPressEscapeKey = event
  144.  
  145. def GetText(self):
  146. return self.inputValue.GetText()
  147.  
  148. class InputDialogWithDescription(InputDialog):
  149.  
  150. def __init__(self):
  151. ui.ScriptWindow.__init__(self)
  152.  
  153. self.__CreateDialog()
  154.  
  155. def __del__(self):
  156. InputDialog.__del__(self)
  157.  
  158. def __CreateDialog(self):
  159.  
  160. pyScrLoader = ui.PythonScriptLoader()
  161. if localeInfo.IsARABIC() :
  162. pyScrLoader.LoadScriptFile(self, uiScriptLocale.LOCALE_UISCRIPT_PATH + "inputdialogwithdescription.py")
  163. else:
  164. pyScrLoader.LoadScriptFile(self, "uiscript/inputdialogwithdescription.py")
  165.  
  166. try:
  167. getObject = self.GetChild
  168. self.board = getObject("Board")
  169. self.acceptButton = getObject("AcceptButton")
  170. self.cancelButton = getObject("CancelButton")
  171. self.inputSlot = getObject("InputSlot")
  172. self.inputValue = getObject("InputValue")
  173. self.description = getObject("Description")
  174.  
  175. except:
  176. import exception
  177. exception.Abort("InputDialogWithDescription.LoadBoardDialog.BindObject")
  178.  
  179. def SetDescription(self, text):
  180. self.description.SetText(text)
  181.  
  182. class InputDialogWithDescription2(InputDialog):
  183.  
  184. def __init__(self):
  185. ui.ScriptWindow.__init__(self)
  186.  
  187. self.__CreateDialog()
  188.  
  189. def __del__(self):
  190. InputDialog.__del__(self)
  191.  
  192. def __CreateDialog(self):
  193.  
  194. pyScrLoader = ui.PythonScriptLoader()
  195. pyScrLoader.LoadScriptFile(self, "uiscript/inputdialogwithdescription2.py")
  196.  
  197. try:
  198. getObject = self.GetChild
  199. self.board = getObject("Board")
  200. self.acceptButton = getObject("AcceptButton")
  201. self.cancelButton = getObject("CancelButton")
  202. self.inputSlot = getObject("InputSlot")
  203. self.inputValue = getObject("InputValue")
  204. self.description1 = getObject("Description1")
  205. self.description2 = getObject("Description2")
  206.  
  207. except:
  208. import exception
  209. exception.Abort("InputDialogWithDescription.LoadBoardDialog.BindObject")
  210.  
  211. def SetDescription1(self, text):
  212. self.description1.SetText(text)
  213.  
  214. def SetDescription2(self, text):
  215. self.description2.SetText(text)
  216.  
  217. class QuestionDialog(ui.ScriptWindow):
  218.  
  219. def __init__(self):
  220. ui.ScriptWindow.__init__(self)
  221. self.__CreateDialog()
  222.  
  223. def __del__(self):
  224. ui.ScriptWindow.__del__(self)
  225.  
  226. def __CreateDialog(self):
  227. pyScrLoader = ui.PythonScriptLoader()
  228. pyScrLoader.LoadScriptFile(self, "uiscript/questiondialog.py")
  229.  
  230. self.board = self.GetChild("board")
  231. self.textLine = self.GetChild("message")
  232. self.acceptButton = self.GetChild("accept")
  233. self.cancelButton = self.GetChild("cancel")
  234.  
  235. def Open(self):
  236. self.SetCenterPosition()
  237. self.SetTop()
  238. self.Show()
  239.  
  240. def Close(self):
  241. self.Hide()
  242.  
  243. def SetWidth(self, width):
  244. height = self.GetHeight()
  245. self.SetSize(width, height)
  246. self.board.SetSize(width, height)
  247. self.SetCenterPosition()
  248. self.UpdateRect()
  249.  
  250. def SAFE_SetAcceptEvent(self, event):
  251. self.acceptButton.SAFE_SetEvent(event)
  252.  
  253. def SAFE_SetCancelEvent(self, event):
  254. self.cancelButton.SAFE_SetEvent(event)
  255.  
  256. def SetAcceptEvent(self, event):
  257. self.acceptButton.SetEvent(event)
  258.  
  259. def SetCancelEvent(self, event):
  260. self.cancelButton.SetEvent(event)
  261.  
  262. def SetText(self, text):
  263. self.textLine.SetText(text)
  264.  
  265. def SetAcceptText(self, text):
  266. self.acceptButton.SetText(text)
  267.  
  268. def SetCancelText(self, text):
  269. self.cancelButton.SetText(text)
  270.  
  271. def OnPressEscapeKey(self):
  272. self.Close()
  273. return True
  274.  
  275. class QuestionDialog2(QuestionDialog):
  276.  
  277. def __init__(self):
  278. QuestionDialog.__init__(self)
  279. self.__CreateDialog()
  280.  
  281. def __del__(self):
  282. QuestionDialog.__del__(self)
  283.  
  284. def __CreateDialog(self):
  285. pyScrLoader = ui.PythonScriptLoader()
  286. pyScrLoader.LoadScriptFile(self, "uiscript/questiondialog2.py")
  287.  
  288. self.board = self.GetChild("board")
  289. self.textLine1 = self.GetChild("message1")
  290. self.textLine2 = self.GetChild("message2")
  291. self.acceptButton = self.GetChild("accept")
  292. self.cancelButton = self.GetChild("cancel")
  293.  
  294. def SetText1(self, text):
  295. self.textLine1.SetText(text)
  296.  
  297. def SetText2(self, text):
  298. self.textLine2.SetText(text)
  299.  
  300. class QuestionDialogWithTimeLimit(QuestionDialog2):
  301.  
  302. def __init__(self):
  303. ui.ScriptWindow.__init__(self)
  304.  
  305. self.__CreateDialog()
  306. self.endTime = 0
  307.  
  308. def __del__(self):
  309. QuestionDialog2.__del__(self)
  310.  
  311. def __CreateDialog(self):
  312. pyScrLoader = ui.PythonScriptLoader()
  313. pyScrLoader.LoadScriptFile(self, "uiscript/questiondialog2.py")
  314.  
  315. self.board = self.GetChild("board")
  316. self.textLine1 = self.GetChild("message1")
  317. self.textLine2 = self.GetChild("message2")
  318. self.acceptButton = self.GetChild("accept")
  319. self.cancelButton = self.GetChild("cancel")
  320.  
  321. def Open(self, msg, timeout):
  322. self.SetCenterPosition()
  323. self.SetTop()
  324. self.Show()
  325.  
  326. self.SetText1(msg)
  327. self.endTime = app.GetTime() + timeout
  328.  
  329. def OnUpdate(self):
  330. leftTime = max(0, self.endTime - app.GetTime())
  331. self.SetText2(localeInfo.UI_LEFT_TIME % (leftTime))
  332.  
  333. class MoneyInputDialog(ui.ScriptWindow):
  334.  
  335. def __init__(self):
  336. ui.ScriptWindow.__init__(self)
  337.  
  338. self.moneyHeaderText = localeInfo.MONEY_INPUT_DIALOG_SELLPRICE
  339. self.__CreateDialog()
  340. self.SetMaxLength(13)
  341.  
  342. def __del__(self):
  343. ui.ScriptWindow.__del__(self)
  344.  
  345. def __CreateDialog(self):
  346.  
  347. pyScrLoader = ui.PythonScriptLoader()
  348. pyScrLoader.LoadScriptFile(self, "uiscript/moneyinputdialog.py")
  349.  
  350. getObject = self.GetChild
  351. self.board = self.GetChild("board")
  352. self.acceptButton = getObject("AcceptButton")
  353. self.cancelButton = getObject("CancelButton")
  354. self.inputValue = getObject("InputValue")
  355. self.inputValue.SetNumberMode()
  356. self.inputValue.OnIMEUpdate = ui.__mem_func__(self.__OnValueUpdate)
  357. self.moneyText = getObject("MoneyValue")
  358.  
  359. def Open(self):
  360. self.inputValue.SetText("")
  361. self.inputValue.SetFocus()
  362. self.__OnValueUpdate()
  363. self.SetCenterPosition()
  364. self.SetTop()
  365. self.Show()
  366.  
  367. def Close(self):
  368. self.ClearDictionary()
  369. self.board = None
  370. self.acceptButton = None
  371. self.cancelButton = None
  372. self.inputValue = None
  373. self.Hide()
  374.  
  375. def SetTitle(self, name):
  376. self.board.SetTitleName(name)
  377.  
  378. def SetFocus(self):
  379. self.inputValue.SetFocus()
  380.  
  381. def SetMaxLength(self, length):
  382. length = min(13, length)
  383. self.inputValue.SetMax(length)
  384.  
  385. def SetMoneyHeaderText(self, text):
  386. self.moneyHeaderText = text
  387.  
  388. def SetAcceptEvent(self, event):
  389. self.acceptButton.SetEvent(event)
  390. self.inputValue.OnIMEReturn = event
  391.  
  392. def SetCancelEvent(self, event):
  393. self.board.SetCloseEvent(event)
  394. self.cancelButton.SetEvent(event)
  395. self.inputValue.OnPressEscapeKey = event
  396.  
  397. def SetValue(self, value):
  398. value=str(value)
  399. self.inputValue.SetText(value)
  400. self.__OnValueUpdate()
  401. ime.SetCursorPosition(len(value))
  402.  
  403.  
  404. def GetText(self):
  405. return self.inputValue.GetText()
  406.  
  407. def __OnValueUpdate(self):
  408. ui.EditLine.OnIMEUpdate(self.inputValue)
  409.  
  410. text = self.inputValue.GetText()
  411.  
  412. money = 0
  413. if text and text.isdigit():
  414. try:
  415. money = long(text)
  416. except ValueError:
  417. money = 199999999
  418.  
  419. self.moneyText.SetText(self.moneyHeaderText + localeInfo.NumberToMoneyString(money))
  420.  
RAW Paste Data