Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1.Client/unpack/root/constinfo.py | 48 +++++++
- 1.Client/unpack/root/intrologin.py | 287 +++++++++++++++++++++++++++++++++++++
- 2 files changed, 335 insertions(+)
- diff --git a/1.Client/unpack/root/constinfo.py b/1.Client/unpack/root/constinfo.py
- index 26e36262..f3860a18 100644
- --- a/1.Client/unpack/root/constinfo.py
- +++ b/1.Client/unpack/root/constinfo.py
- @@ -245,3 +245,51 @@ def IS_AUTO_POTION_SP(itemVnum):
- return 0
- +
- +ENABLE_SAVE_ACCOUNT = True
- +if ENABLE_SAVE_ACCOUNT:
- + class SAB:
- + ST_CACHE, ST_FILE, ST_REGISTRY = xrange(3)
- + slotCount = 4
- + storeType = ST_REGISTRY # 0 cache, 1 file, 2 registry
- + btnName = {
- + "Save": "SaveAccountButton_Save_%02d",
- + "Access": "SaveAccountButton_Access_%02d",
- + "Remove": "SaveAccountButton_Remove_%02d",
- + }
- + accData = {}
- + regPath = r"SOFTWARE\LibresoDigitalService-SellServerfiles"
- + regName = "slot%02d_%s"
- + regValueId = "id"
- + regValuePwd = "pwd"
- + fileExt = ".do.not.share.it.txt"
- +
- + def DelWinRegKeyValue(keyPath, keyName):
- + try:
- + import _winreg
- + _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, keyPath)
- + _tmpKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, keyPath, 0, _winreg.KEY_WRITE)
- + _winreg.DeleteValue(_tmpKey, keyName)
- + _winreg.CloseKey(_tmpKey)
- + return True
- + except WindowsError:
- + return False
- + def GetWinRegKeyValue(keyPath, keyName):
- + try:
- + import _winreg
- + _tmpKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, keyPath, 0, _winreg.KEY_READ)
- + keyValue, keyType = _winreg.QueryValueEx(_tmpKey, keyName)
- + _winreg.CloseKey(_tmpKey)
- + return str(keyValue) # unicode to ascii
- + except WindowsError:
- + return None
- + def SetWinRegKeyValue(keyPath, keyName, keyValue):
- + try:
- + import _winreg
- + _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, keyPath)
- + _tmpKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, keyPath, 0, _winreg.KEY_WRITE)
- + _winreg.SetValueEx(_tmpKey, keyName, 0, _winreg.REG_SZ, keyValue)
- + _winreg.CloseKey(_tmpKey)
- + return True
- + except WindowsError:
- + return False
- diff --git a/1.Client/unpack/root/intrologin.py b/1.Client/unpack/root/intrologin.py
- index 2e439177..f72b4cfc 100644
- --- a/1.Client/unpack/root/intrologin.py
- +++ b/1.Client/unpack/root/intrologin.py
- @@ -229,6 +229,8 @@ class LoginWindow(ui.ScriptWindow):
- if self.isStartError:
- self.connectBoard.Hide()
- self.loginBoard.Hide()
- + if constInfo.ENABLE_SAVE_ACCOUNT:
- + self.saveAccountBoard.Hide()
- self.serverBoard.Hide()
- self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.__ExitGame)
- return
- @@ -272,6 +274,8 @@ class LoginWindow(ui.ScriptWindow):
- self.connectBoard = None
- self.loginBoard = None
- + if constInfo.ENABLE_SAVE_ACCOUNT:
- + self.saveAccountBoard = None
- self.idEditLine = None
- self.pwdEditLine = None
- self.inputDialog = None
- @@ -425,6 +429,274 @@ class LoginWindow(ui.ScriptWindow):
- self.SetPasswordEditLineFocus()
- net.Disconnect()
- + if constInfo.ENABLE_SAVE_ACCOUNT:
- + def SAB_LoadAccountData(self):
- + if constInfo.SAB.storeType == constInfo.SAB.ST_CACHE:
- + return
- + for idx in xrange(constInfo.SAB.slotCount):
- + if constInfo.SAB.storeType == constInfo.SAB.ST_REGISTRY:
- + id = constInfo.GetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValueId))
- + pwd = constInfo.GetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValuePwd))
- + if id and pwd:
- + self.SAB_SetAccountData(idx, (id, pwd))
- + elif constInfo.SAB.storeType == constInfo.SAB.ST_FILE:
- + (id, pwd) = constInfo.GetJsonSABData(idx)
- + if id and pwd:
- + self.SAB_SetAccountData(idx, (id, pwd))
- +
- + def SAB_SaveAccountData(self):
- + if constInfo.SAB.storeType == constInfo.SAB.ST_CACHE:
- + return
- + for idx in xrange(constInfo.SAB.slotCount):
- + if constInfo.SAB.storeType == constInfo.SAB.ST_REGISTRY:
- + _tSlot = self.SAB_GetAccountData(idx)
- + if _tSlot:
- + (id, pwd) = _tSlot
- + constInfo.SetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValueId), id)
- + constInfo.SetWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValuePwd), pwd)
- + else:
- + constInfo.DelWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValueId))
- + constInfo.DelWinRegKeyValue(constInfo.SAB.regPath, constInfo.SAB.regName % (idx, constInfo.SAB.regValuePwd))
- + elif constInfo.SAB.storeType == constInfo.SAB.ST_FILE:
- + _tSlot = self.SAB_GetAccountData(idx)
- + if _tSlot:
- + constInfo.SetJsonSABData(idx, _tSlot)
- + else:
- + constInfo.DelJsonSABData(idx)
- +
- + def SAB_DelAccountData(self, slot):
- + if constInfo.SAB.accData.get(slot):
- + del constInfo.SAB.accData[slot]
- +
- + def SAB_GetAccountData(self, slot):
- + return constInfo.SAB.accData.get(slot)
- +
- + def SAB_SetAccountData(self, slot, data):
- + constInfo.SAB.accData[slot] = data
- +
- + def SAB_BtnRearrange(self):
- + def tooltipArrange(_btnObj):
- + _tMexTip = "Account ID: %s" % id
- + _btnObj.SetToolTipText(_tMexTip)
- + if _btnObj.ToolTipText:
- + _btnObj.ToolTipText.SetPackedFontColor(0xff66FFFF)
- + ## def code
- + GetObject=self.GetChild
- + SetObject=self.InsertChild
- + ## button names
- + btnNameSave = constInfo.SAB.btnName["Save"]
- + btnNameAccess = constInfo.SAB.btnName["Access"]
- + btnNameRemove = constInfo.SAB.btnName["Remove"]
- + ## rearrange code
- + for idx in xrange(constInfo.SAB.slotCount):
- + _tSlot = self.SAB_GetAccountData(idx)
- + # button objects
- + btnObjSave = GetObject(btnNameSave % idx)
- + btnObjAccess = GetObject(btnNameAccess % idx)
- + btnObjRemove = GetObject(btnNameRemove % idx)
- + if _tSlot:
- + (id, pwd) = _tSlot
- + btnObjSave.Hide()
- + btnObjAccess.Show()
- + btnObjRemove.Show()
- + btnObjAccess.SetText("|cffFF0000|hF{}|r Connect {}".format(idx+1, id))
- + else:
- + btnObjSave.Show()
- + btnObjAccess.Hide()
- + btnObjRemove.Hide()
- + # done
- +
- + def SAB_Click_Save(self, slot):
- + if slot >= constInfo.SAB.slotCount:
- + return
- + ## def code
- + GetObject=self.GetChild
- + SetObject=self.InsertChild
- + ## button stuff
- + _tmpName = constInfo.SAB.btnName["Save"] % slot
- + _tmpObj = GetObject(_tmpName)
- + ## code stuff
- + try:
- + id = self.idEditLine.GetText()
- + pwd = self.pwdEditLine.GetText()
- +
- + if len(id)==0:
- + self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.SetIDEditLineFocus)
- + return
- +
- + if len(pwd)==0:
- + self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.SetPasswordEditLineFocus)
- + return
- + except:
- + return
- + self.SAB_SetAccountData(slot, (id,pwd))
- + self.SAB_SaveAccountData()
- + ## rearrange stuff
- + self.SAB_BtnRearrange()
- +
- + def SAB_Click_Access(self, slot):
- + if slot >= constInfo.SAB.slotCount:
- + return
- + ## def code
- + GetObject=self.GetChild
- + SetObject=self.InsertChild
- + ## button stuff
- + _tmpName = constInfo.SAB.btnName["Access"] % slot
- + _tmpObj = GetObject(_tmpName)
- + ## code stuff
- + _tSlot = self.SAB_GetAccountData(slot)
- + if _tSlot:
- + (id, pwd) = _tSlot
- + self.idEditLine.SetText(id)
- + self.pwdEditLine.SetText(pwd)
- + self.__OnClickSelectServerButton()
- + self.__OnClickLoginButton()
- +
- + def SAB_Click_Remove(self, slot):
- + if slot >= constInfo.SAB.slotCount:
- + return
- + ## def code
- + GetObject=self.GetChild
- + SetObject=self.InsertChild
- + ## button stuff
- + _tmpName = constInfo.SAB.btnName["Remove"] % slot
- + _tmpObj = GetObject(_tmpName)
- + ## code stuff
- + self.SAB_DelAccountData(slot)
- + self.SAB_SaveAccountData()
- + ## rearrange stuff
- + self.SAB_BtnRearrange()
- +
- + def __CreateSaveAccountBoard(self):
- + ### SAB INIT
- + self.SAB_LoadAccountData()
- + ## def code
- + GetObject=self.GetChild
- + SetObject=self.InsertChild
- + ## gui stuff
- + SCREEN_WIDTH = wndMgr.GetScreenWidth()
- + SCREEN_HEIGHT = wndMgr.GetScreenHeight()
- + ## button space
- + SPACE_FOR_BUTTON = 25+1
- + ALL_BUTTON_SPACE = SPACE_FOR_BUTTON * constInfo.SAB.slotCount
- + ## board stuff
- + BOARD_SIZE = (210+120, 28 + ALL_BUTTON_SPACE)
- + BOARD_POS = ((SCREEN_WIDTH - 208) / 2 + 210, (SCREEN_HEIGHT - 410) - (10*constInfo.SAB.slotCount))
- + ## button stuff
- + btnNameSave = constInfo.SAB.btnName["Save"]
- + btnNameAccess = constInfo.SAB.btnName["Access"]
- + btnNameRemove = constInfo.SAB.btnName["Remove"]
- + btnPath = "d:/ymir work/ui/public/%s_button_%02d.sub" # xsmall small middle large xlarge big
- + btnImage = {"default":1,"over":2,"down":3}
- + ## SAB BOARD
- + try:
- + ## default init
- + _tmpName = "SaveAccountBoard"
- + SetObject(_tmpName, ui.ThinBoard())
- + #
- + _tmpObj = GetObject(_tmpName)
- + _tmpObj.SetParent(self)
- + ## custom data
- + _tmpObj.SetSize(*BOARD_SIZE)
- + ## default data
- + _tmpObj.SetPosition(*BOARD_POS)
- + _tmpObj.Show()
- + self.saveAccountBoard = _tmpObj
- + except:
- + import exception; exception.Abort("__CreateSaveAccountBoard SAB BOARD")
- + ### SAB TITLE
- + try:
- + ## default init
- + _tmpName = "SaveAccountTitle"
- + SetObject(_tmpName, ui.TextLine())
- + _tmpObj = GetObject(_tmpName)
- + _tmpObj.SetParent(self.saveAccountBoard)
- + ## custom data
- + _tmpObj.SetHorizontalAlignCenter()
- + _tmpObj.SetPackedFontColor(0xFFffbf00)
- + _tmpObj.SetOutline()
- + _tmpObj.SetText("Save Account")
- + ## default data
- + _tmpObj.SetPosition(BOARD_SIZE[0]/2, 5)
- + _tmpObj.Show()
- + except:
- + import exception; exception.Abort("__CreateSaveAccountBoard SAB TITLE")
- + ### SAB LINE
- + try:
- + ## default init
- + _tmpName = "SaveAccountLine"
- + SetObject(_tmpName, ui.Line())
- + _tmpObj = GetObject(_tmpName)
- + _tmpObj.SetParent(self.saveAccountBoard)
- + ## custom data
- + _tmpObj.SetColor(0xFF777777)
- + _tmpObj.SetSize(BOARD_SIZE[0]-10, 0)
- + ## default data
- + _tmpObj.SetPosition(5, 20)
- + _tmpObj.Show()
- + except:
- + import exception; exception.Abort("__CreateSaveAccountBoard SAB LINE")
- + ## SaveAccountButtons
- + for idx in xrange(constInfo.SAB.slotCount):
- + ### SAB SAVE
- + try:
- + ## default init
- + _tmpName = btnNameSave % (idx)
- + SetObject(_tmpName, ui.Button())
- + _tmpObj = GetObject(_tmpName)
- + _tmpObj.SetParent(self.saveAccountBoard)
- + ## custom data
- + _tmpBtnPath = "d:/ymir work/ui/public/xlarge_button_%02d.sub" # xsmall small middle large xlarge big
- + _tmpObj.SetUpVisual(_tmpBtnPath % (btnImage["default"]))
- + _tmpObj.SetOverVisual(_tmpBtnPath % (btnImage["over"]))
- + _tmpObj.SetDownVisual(_tmpBtnPath % (btnImage["down"]))
- + _tmpObj.SetText("Save")
- + _tmpObj.SAFE_SetEvent(self.SAB_Click_Save, idx)
- + ## default data
- + _tmpObj.SetPosition(15 + 60, 25 + (idx * SPACE_FOR_BUTTON))
- + _tmpObj.Hide()
- + except:
- + import exception; exception.Abort("__CreateSaveAccountBoard SAB SAVE")
- + ### SAB ACCESS
- + try:
- + ## default init
- + _tmpName = btnNameAccess % (idx)
- + SetObject(_tmpName, ui.Button())
- + _tmpObj = GetObject(_tmpName)
- + _tmpObj.SetParent(self.saveAccountBoard)
- + ## custom data
- + _tmpBtnPath = "d:/ymir work/ui/public/xlarge_button_%02d.sub" # xsmall small middle large xlarge big
- + _tmpObj.SetUpVisual(_tmpBtnPath % (btnImage["default"]))
- + _tmpObj.SetOverVisual(_tmpBtnPath % (btnImage["over"]))
- + _tmpObj.SetDownVisual(_tmpBtnPath % (btnImage["down"]))
- + _tmpObj.SetText("Connect #{}".format(idx+1))
- + _tmpObj.SAFE_SetEvent(self.SAB_Click_Access, idx)
- + ## default data
- + _tmpObj.SetPosition(35, 25 + (idx * SPACE_FOR_BUTTON))
- + _tmpObj.Show()
- + except:
- + import exception; exception.Abort("__CreateSaveAccountBoard SAB ACCESS")
- + ### SAB REMOVE
- + try:
- + ## default init
- + _tmpName = btnNameRemove % (idx)
- + SetObject(_tmpName, ui.Button())
- + _tmpObj = GetObject(_tmpName)
- + _tmpObj.SetParent(self.saveAccountBoard)
- + ## custom data
- + _tmpBtnPath = "d:/ymir work/ui/public/middle_button_%02d.sub" # xsmall small middle large xlarge big
- + _tmpObj.SetUpVisual(_tmpBtnPath % (btnImage["default"]))
- + _tmpObj.SetOverVisual(_tmpBtnPath % (btnImage["over"]))
- + _tmpObj.SetDownVisual(_tmpBtnPath % (btnImage["down"]))
- + _tmpObj.SetText("Remove")
- + _tmpObj.SAFE_SetEvent(self.SAB_Click_Remove, idx)
- + ## default data
- + _tmpObj.SetPosition(35 + 190, 25 + (idx * SPACE_FOR_BUTTON))
- + _tmpObj.Show()
- + except:
- + import exception; exception.Abort("__CreateSaveAccountBoard SAB REMOVE")
- + self.SAB_BtnRearrange()
- +
- def __LoadScript(self, fileName):
- import dbg
- try:
- @@ -450,6 +722,8 @@ class LoginWindow(ui.ScriptWindow):
- self.selectConnectButton = GetObject("SelectConnectButton")
- self.loginButton = GetObject("LoginButton")
- self.loginExitButton = GetObject("LoginExitButton")
- + if constInfo.ENABLE_SAVE_ACCOUNT:
- + self.__CreateSaveAccountBoard()
- self.virtualKeyboard = self.GetChild2("VirtualKeyboard")
- @@ -843,6 +1117,8 @@ class LoginWindow(ui.ScriptWindow):
- self.serverBoard.Show()
- self.connectBoard.Hide()
- self.loginBoard.Hide()
- + if constInfo.ENABLE_SAVE_ACCOUNT:
- + self.saveAccountBoard.Hide()
- self.KillInputFocus() #@fixme019
- @@ -875,9 +1151,13 @@ class LoginWindow(ui.ScriptWindow):
- self.Connect(self.id, self.pwd)
- self.connectBoard.Hide()
- self.loginBoard.Hide()
- + if constInfo.ENABLE_SAVE_ACCOUNT:
- + self.saveAccountBoard.Hide()
- elif not self.stream.isAutoLogin:
- self.connectBoard.Show()
- self.loginBoard.Show()
- + if constInfo.ENABLE_SAVE_ACCOUNT:
- + self.saveAccountBoard.Show()
- ## if users have the login infomation, then don't initialize.2005.9 haho
- if self.idEditLine == None:
- @@ -1115,6 +1395,13 @@ class LoginWindow(ui.ScriptWindow):
- self.Connect(id, pwd)
- + def OnKeyDown(self, key):
- + if constInfo.ENABLE_SAVE_ACCOUNT:
- + for idx in xrange(constInfo.SAB.slotCount):
- + if app.DIK_F1+idx == key and self.SAB_GetAccountData(idx):
- + self.SAB_Click_Access(idx)
- + return True
- +
- def SameLogin_OpenUI(self):
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(localeInfo.LOGIN_FAILURE_SAMELOGIN, 0, localeInfo.UI_OK)
Advertisement