Guest User

Diff Save Account Metin2

a guest
Feb 7th, 2026
83
0
Never
5
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.29 KB | None | 0 0
  1. 1.Client/unpack/root/constinfo.py | 48 +++++++
  2. 1.Client/unpack/root/intrologin.py | 287 +++++++++++++++++++++++++++++++++++++
  3. 2 files changed, 335 insertions(+)
  4.  
  5. diff --git a/1.Client/unpack/root/constinfo.py b/1.Client/unpack/root/constinfo.py
  6. index 26e36262..f3860a18 100644
  7. --- a/1.Client/unpack/root/constinfo.py
  8. +++ b/1.Client/unpack/root/constinfo.py
  9. @@ -245,3 +245,51 @@ def IS_AUTO_POTION_SP(itemVnum):
  10.  
  11. return 0
  12.  
  13. +
  14. +ENABLE_SAVE_ACCOUNT = True
  15. +if ENABLE_SAVE_ACCOUNT:
  16. + class SAB:
  17. + ST_CACHE, ST_FILE, ST_REGISTRY = xrange(3)
  18. + slotCount = 4
  19. + storeType = ST_REGISTRY # 0 cache, 1 file, 2 registry
  20. + btnName = {
  21. + "Save": "SaveAccountButton_Save_%02d",
  22. + "Access": "SaveAccountButton_Access_%02d",
  23. + "Remove": "SaveAccountButton_Remove_%02d",
  24. + }
  25. + accData = {}
  26. + regPath = r"SOFTWARE\LibresoDigitalService-SellServerfiles"
  27. + regName = "slot%02d_%s"
  28. + regValueId = "id"
  29. + regValuePwd = "pwd"
  30. + fileExt = ".do.not.share.it.txt"
  31. +
  32. + def DelWinRegKeyValue(keyPath, keyName):
  33. + try:
  34. + import _winreg
  35. + _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, keyPath)
  36. + _tmpKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, keyPath, 0, _winreg.KEY_WRITE)
  37. + _winreg.DeleteValue(_tmpKey, keyName)
  38. + _winreg.CloseKey(_tmpKey)
  39. + return True
  40. + except WindowsError:
  41. + return False
  42. + def GetWinRegKeyValue(keyPath, keyName):
  43. + try:
  44. + import _winreg
  45. + _tmpKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, keyPath, 0, _winreg.KEY_READ)
  46. + keyValue, keyType = _winreg.QueryValueEx(_tmpKey, keyName)
  47. + _winreg.CloseKey(_tmpKey)
  48. + return str(keyValue) # unicode to ascii
  49. + except WindowsError:
  50. + return None
  51. + def SetWinRegKeyValue(keyPath, keyName, keyValue):
  52. + try:
  53. + import _winreg
  54. + _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, keyPath)
  55. + _tmpKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, keyPath, 0, _winreg.KEY_WRITE)
  56. + _winreg.SetValueEx(_tmpKey, keyName, 0, _winreg.REG_SZ, keyValue)
  57. + _winreg.CloseKey(_tmpKey)
  58. + return True
  59. + except WindowsError:
  60. + return False
  61. diff --git a/1.Client/unpack/root/intrologin.py b/1.Client/unpack/root/intrologin.py
  62. index 2e439177..f72b4cfc 100644
  63. --- a/1.Client/unpack/root/intrologin.py
  64. +++ b/1.Client/unpack/root/intrologin.py
  65. @@ -229,6 +229,8 @@ class LoginWindow(ui.ScriptWindow):
  66. if self.isStartError:
  67. self.connectBoard.Hide()
  68. self.loginBoard.Hide()
  69. + if constInfo.ENABLE_SAVE_ACCOUNT:
  70. + self.saveAccountBoard.Hide()
  71. self.serverBoard.Hide()
  72. self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.__ExitGame)
  73. return
  74. @@ -272,6 +274,8 @@ class LoginWindow(ui.ScriptWindow):
  75.  
  76. self.connectBoard = None
  77. self.loginBoard = None
  78. + if constInfo.ENABLE_SAVE_ACCOUNT:
  79. + self.saveAccountBoard = None
  80. self.idEditLine = None
  81. self.pwdEditLine = None
  82. self.inputDialog = None
  83. @@ -425,6 +429,274 @@ class LoginWindow(ui.ScriptWindow):
  84. self.SetPasswordEditLineFocus()
  85. net.Disconnect()
  86.  
  87. + if constInfo.ENABLE_SAVE_ACCOUNT:
  88. + def SAB_LoadAccountData(self):
  89. + if constInfo.SAB.storeType == constInfo.SAB.ST_CACHE:
  90. + return
  91. + for idx in xrange(constInfo.SAB.slotCount):
  92. + if constInfo.SAB.storeType == constInfo.SAB.ST_REGISTRY:
  93. + id = constInfo.GetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValueId))
  94. + pwd = constInfo.GetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValuePwd))
  95. + if id and pwd:
  96. + self.SAB_SetAccountData(idx, (id, pwd))
  97. + elif constInfo.SAB.storeType == constInfo.SAB.ST_FILE:
  98. + (id, pwd) = constInfo.GetJsonSABData(idx)
  99. + if id and pwd:
  100. + self.SAB_SetAccountData(idx, (id, pwd))
  101. +
  102. + def SAB_SaveAccountData(self):
  103. + if constInfo.SAB.storeType == constInfo.SAB.ST_CACHE:
  104. + return
  105. + for idx in xrange(constInfo.SAB.slotCount):
  106. + if constInfo.SAB.storeType == constInfo.SAB.ST_REGISTRY:
  107. + _tSlot = self.SAB_GetAccountData(idx)
  108. + if _tSlot:
  109. + (id, pwd) = _tSlot
  110. + constInfo.SetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValueId), id)
  111. + constInfo.SetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValuePwd), pwd)
  112. + else:
  113. + constInfo.DelWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValueId))
  114. + constInfo.DelWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValuePwd))
  115. + elif constInfo.SAB.storeType == constInfo.SAB.ST_FILE:
  116. + _tSlot = self.SAB_GetAccountData(idx)
  117. + if _tSlot:
  118. + constInfo.SetJsonSABData(idx, _tSlot)
  119. + else:
  120. + constInfo.DelJsonSABData(idx)
  121. +
  122. + def SAB_DelAccountData(self, slot):
  123. + if constInfo.SAB.accData.get(slot):
  124. + del constInfo.SAB.accData[slot]
  125. +
  126. + def SAB_GetAccountData(self, slot):
  127. + return constInfo.SAB.accData.get(slot)
  128. +
  129. + def SAB_SetAccountData(self, slot, data):
  130. + constInfo.SAB.accData[slot] = data
  131. +
  132. + def SAB_BtnRearrange(self):
  133. + def tooltipArrange(_btnObj):
  134. + _tMexTip = "Account ID: %s" % id
  135. + _btnObj.SetToolTipText(_tMexTip)
  136. + if _btnObj.ToolTipText:
  137. + _btnObj.ToolTipText.SetPackedFontColor(0xff66FFFF)
  138. + ## def code
  139. + GetObject=self.GetChild
  140. + SetObject=self.InsertChild
  141. + ## button names
  142. + btnNameSave = constInfo.SAB.btnName["Save"]
  143. + btnNameAccess = constInfo.SAB.btnName["Access"]
  144. + btnNameRemove = constInfo.SAB.btnName["Remove"]
  145. + ## rearrange code
  146. + for idx in xrange(constInfo.SAB.slotCount):
  147. + _tSlot = self.SAB_GetAccountData(idx)
  148. + # button objects
  149. + btnObjSave = GetObject(btnNameSave % idx)
  150. + btnObjAccess = GetObject(btnNameAccess % idx)
  151. + btnObjRemove = GetObject(btnNameRemove % idx)
  152. + if _tSlot:
  153. + (id, pwd) = _tSlot
  154. + btnObjSave.Hide()
  155. + btnObjAccess.Show()
  156. + btnObjRemove.Show()
  157. + btnObjAccess.SetText("|cffFF0000|hF{}|r Connect {}".format(idx+1, id))
  158. + else:
  159. + btnObjSave.Show()
  160. + btnObjAccess.Hide()
  161. + btnObjRemove.Hide()
  162. + # done
  163. +
  164. + def SAB_Click_Save(self, slot):
  165. + if slot >= constInfo.SAB.slotCount:
  166. + return
  167. + ## def code
  168. + GetObject=self.GetChild
  169. + SetObject=self.InsertChild
  170. + ## button stuff
  171. + _tmpName = constInfo.SAB.btnName["Save"] % slot
  172. + _tmpObj = GetObject(_tmpName)
  173. + ## code stuff
  174. + try:
  175. + id = self.idEditLine.GetText()
  176. + pwd = self.pwdEditLine.GetText()
  177. +
  178. + if len(id)==0:
  179. + self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.SetIDEditLineFocus)
  180. + return
  181. +
  182. + if len(pwd)==0:
  183. + self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.SetPasswordEditLineFocus)
  184. + return
  185. + except:
  186. + return
  187. + self.SAB_SetAccountData(slot, (id,pwd))
  188. + self.SAB_SaveAccountData()
  189. + ## rearrange stuff
  190. + self.SAB_BtnRearrange()
  191. +
  192. + def SAB_Click_Access(self, slot):
  193. + if slot >= constInfo.SAB.slotCount:
  194. + return
  195. + ## def code
  196. + GetObject=self.GetChild
  197. + SetObject=self.InsertChild
  198. + ## button stuff
  199. + _tmpName = constInfo.SAB.btnName["Access"] % slot
  200. + _tmpObj = GetObject(_tmpName)
  201. + ## code stuff
  202. + _tSlot = self.SAB_GetAccountData(slot)
  203. + if _tSlot:
  204. + (id, pwd) = _tSlot
  205. + self.idEditLine.SetText(id)
  206. + self.pwdEditLine.SetText(pwd)
  207. + self.__OnClickSelectServerButton()
  208. + self.__OnClickLoginButton()
  209. +
  210. + def SAB_Click_Remove(self, slot):
  211. + if slot >= constInfo.SAB.slotCount:
  212. + return
  213. + ## def code
  214. + GetObject=self.GetChild
  215. + SetObject=self.InsertChild
  216. + ## button stuff
  217. + _tmpName = constInfo.SAB.btnName["Remove"] % slot
  218. + _tmpObj = GetObject(_tmpName)
  219. + ## code stuff
  220. + self.SAB_DelAccountData(slot)
  221. + self.SAB_SaveAccountData()
  222. + ## rearrange stuff
  223. + self.SAB_BtnRearrange()
  224. +
  225. + def __CreateSaveAccountBoard(self):
  226. + ### SAB INIT
  227. + self.SAB_LoadAccountData()
  228. + ## def code
  229. + GetObject=self.GetChild
  230. + SetObject=self.InsertChild
  231. + ## gui stuff
  232. + SCREEN_WIDTH = wndMgr.GetScreenWidth()
  233. + SCREEN_HEIGHT = wndMgr.GetScreenHeight()
  234. + ## button space
  235. + SPACE_FOR_BUTTON = 25+1
  236. + ALL_BUTTON_SPACE = SPACE_FOR_BUTTON * constInfo.SAB.slotCount
  237. + ## board stuff
  238. + BOARD_SIZE = (210+120, 28 + ALL_BUTTON_SPACE)
  239. + BOARD_POS = ((SCREEN_WIDTH - 208) / 2 + 210, (SCREEN_HEIGHT - 410) - (10*constInfo.SAB.slotCount))
  240. + ## button stuff
  241. + btnNameSave = constInfo.SAB.btnName["Save"]
  242. + btnNameAccess = constInfo.SAB.btnName["Access"]
  243. + btnNameRemove = constInfo.SAB.btnName["Remove"]
  244. + btnPath = "d:/ymir work/ui/public/%s_button_%02d.sub" # xsmall small middle large xlarge big
  245. + btnImage = {"default":1,"over":2,"down":3}
  246. + ## SAB BOARD
  247. + try:
  248. + ## default init
  249. + _tmpName = "SaveAccountBoard"
  250. + SetObject(_tmpName, ui.ThinBoard())
  251. + #
  252. + _tmpObj = GetObject(_tmpName)
  253. + _tmpObj.SetParent(self)
  254. + ## custom data
  255. + _tmpObj.SetSize(*BOARD_SIZE)
  256. + ## default data
  257. + _tmpObj.SetPosition(*BOARD_POS)
  258. + _tmpObj.Show()
  259. + self.saveAccountBoard = _tmpObj
  260. + except:
  261. + import exception; exception.Abort("__CreateSaveAccountBoard SAB BOARD")
  262. + ### SAB TITLE
  263. + try:
  264. + ## default init
  265. + _tmpName = "SaveAccountTitle"
  266. + SetObject(_tmpName, ui.TextLine())
  267. + _tmpObj = GetObject(_tmpName)
  268. + _tmpObj.SetParent(self.saveAccountBoard)
  269. + ## custom data
  270. + _tmpObj.SetHorizontalAlignCenter()
  271. + _tmpObj.SetPackedFontColor(0xFFffbf00)
  272. + _tmpObj.SetOutline()
  273. + _tmpObj.SetText("Save Account")
  274. + ## default data
  275. + _tmpObj.SetPosition(BOARD_SIZE[0]/2, 5)
  276. + _tmpObj.Show()
  277. + except:
  278. + import exception; exception.Abort("__CreateSaveAccountBoard SAB TITLE")
  279. + ### SAB LINE
  280. + try:
  281. + ## default init
  282. + _tmpName = "SaveAccountLine"
  283. + SetObject(_tmpName, ui.Line())
  284. + _tmpObj = GetObject(_tmpName)
  285. + _tmpObj.SetParent(self.saveAccountBoard)
  286. + ## custom data
  287. + _tmpObj.SetColor(0xFF777777)
  288. + _tmpObj.SetSize(BOARD_SIZE[0]-10, 0)
  289. + ## default data
  290. + _tmpObj.SetPosition(5, 20)
  291. + _tmpObj.Show()
  292. + except:
  293. + import exception; exception.Abort("__CreateSaveAccountBoard SAB LINE")
  294. + ## SaveAccountButtons
  295. + for idx in xrange(constInfo.SAB.slotCount):
  296. + ### SAB SAVE
  297. + try:
  298. + ## default init
  299. + _tmpName = btnNameSave % (idx)
  300. + SetObject(_tmpName, ui.Button())
  301. + _tmpObj = GetObject(_tmpName)
  302. + _tmpObj.SetParent(self.saveAccountBoard)
  303. + ## custom data
  304. + _tmpBtnPath = "d:/ymir work/ui/public/xlarge_button_%02d.sub" # xsmall small middle large xlarge big
  305. + _tmpObj.SetUpVisual(_tmpBtnPath % (btnImage["default"]))
  306. + _tmpObj.SetOverVisual(_tmpBtnPath % (btnImage["over"]))
  307. + _tmpObj.SetDownVisual(_tmpBtnPath % (btnImage["down"]))
  308. + _tmpObj.SetText("Save")
  309. + _tmpObj.SAFE_SetEvent(self.SAB_Click_Save, idx)
  310. + ## default data
  311. + _tmpObj.SetPosition(15 + 60, 25 + (idx * SPACE_FOR_BUTTON))
  312. + _tmpObj.Hide()
  313. + except:
  314. + import exception; exception.Abort("__CreateSaveAccountBoard SAB SAVE")
  315. + ### SAB ACCESS
  316. + try:
  317. + ## default init
  318. + _tmpName = btnNameAccess % (idx)
  319. + SetObject(_tmpName, ui.Button())
  320. + _tmpObj = GetObject(_tmpName)
  321. + _tmpObj.SetParent(self.saveAccountBoard)
  322. + ## custom data
  323. + _tmpBtnPath = "d:/ymir work/ui/public/xlarge_button_%02d.sub" # xsmall small middle large xlarge big
  324. + _tmpObj.SetUpVisual(_tmpBtnPath % (btnImage["default"]))
  325. + _tmpObj.SetOverVisual(_tmpBtnPath % (btnImage["over"]))
  326. + _tmpObj.SetDownVisual(_tmpBtnPath % (btnImage["down"]))
  327. + _tmpObj.SetText("Connect #{}".format(idx+1))
  328. + _tmpObj.SAFE_SetEvent(self.SAB_Click_Access, idx)
  329. + ## default data
  330. + _tmpObj.SetPosition(35, 25 + (idx * SPACE_FOR_BUTTON))
  331. + _tmpObj.Show()
  332. + except:
  333. + import exception; exception.Abort("__CreateSaveAccountBoard SAB ACCESS")
  334. + ### SAB REMOVE
  335. + try:
  336. + ## default init
  337. + _tmpName = btnNameRemove % (idx)
  338. + SetObject(_tmpName, ui.Button())
  339. + _tmpObj = GetObject(_tmpName)
  340. + _tmpObj.SetParent(self.saveAccountBoard)
  341. + ## custom data
  342. + _tmpBtnPath = "d:/ymir work/ui/public/middle_button_%02d.sub" # xsmall small middle large xlarge big
  343. + _tmpObj.SetUpVisual(_tmpBtnPath % (btnImage["default"]))
  344. + _tmpObj.SetOverVisual(_tmpBtnPath % (btnImage["over"]))
  345. + _tmpObj.SetDownVisual(_tmpBtnPath % (btnImage["down"]))
  346. + _tmpObj.SetText("Remove")
  347. + _tmpObj.SAFE_SetEvent(self.SAB_Click_Remove, idx)
  348. + ## default data
  349. + _tmpObj.SetPosition(35 + 190, 25 + (idx * SPACE_FOR_BUTTON))
  350. + _tmpObj.Show()
  351. + except:
  352. + import exception; exception.Abort("__CreateSaveAccountBoard SAB REMOVE")
  353. + self.SAB_BtnRearrange()
  354. +
  355. def __LoadScript(self, fileName):
  356. import dbg
  357. try:
  358. @@ -450,6 +722,8 @@ class LoginWindow(ui.ScriptWindow):
  359. self.selectConnectButton = GetObject("SelectConnectButton")
  360. self.loginButton = GetObject("LoginButton")
  361. self.loginExitButton = GetObject("LoginExitButton")
  362. + if constInfo.ENABLE_SAVE_ACCOUNT:
  363. + self.__CreateSaveAccountBoard()
  364.  
  365. self.virtualKeyboard = self.GetChild2("VirtualKeyboard")
  366.  
  367. @@ -843,6 +1117,8 @@ class LoginWindow(ui.ScriptWindow):
  368. self.serverBoard.Show()
  369. self.connectBoard.Hide()
  370. self.loginBoard.Hide()
  371. + if constInfo.ENABLE_SAVE_ACCOUNT:
  372. + self.saveAccountBoard.Hide()
  373.  
  374. self.KillInputFocus() #@fixme019
  375.  
  376. @@ -875,9 +1151,13 @@ class LoginWindow(ui.ScriptWindow):
  377. self.Connect(self.id, self.pwd)
  378. self.connectBoard.Hide()
  379. self.loginBoard.Hide()
  380. + if constInfo.ENABLE_SAVE_ACCOUNT:
  381. + self.saveAccountBoard.Hide()
  382. elif not self.stream.isAutoLogin:
  383. self.connectBoard.Show()
  384. self.loginBoard.Show()
  385. + if constInfo.ENABLE_SAVE_ACCOUNT:
  386. + self.saveAccountBoard.Show()
  387.  
  388. ## if users have the login infomation, then don't initialize.2005.9 haho
  389. if self.idEditLine == None:
  390. @@ -1115,6 +1395,13 @@ class LoginWindow(ui.ScriptWindow):
  391.  
  392. self.Connect(id, pwd)
  393.  
  394. + def OnKeyDown(self, key):
  395. + if constInfo.ENABLE_SAVE_ACCOUNT:
  396. + for idx in xrange(constInfo.SAB.slotCount):
  397. + if app.DIK_F1+idx == key and self.SAB_GetAccountData(idx):
  398. + self.SAB_Click_Access(idx)
  399. + return True
  400. +
  401. def SameLogin_OpenUI(self):
  402. self.stream.popupWindow.Close()
  403. self.stream.popupWindow.Open(localeInfo.LOGIN_FAILURE_SAMELOGIN, 0, localeInfo.UI_OK)
  404.  
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment