- import app
- import net
- import ui
- import snd
- import wndMgr
- import musicInfo
- import systemSetting
- import localeInfo
- import constInfo
- import ime
- import uiScriptLocale
- ''' codin' pass '''
- import binascii
- ''' Registry '''
- import _winreg
- REG_PATH = r"SOFTWARE\VegaS"
- def set_vegas(name, value):
- try:
- _winreg.CreateKey(_winreg.HKEY_CURRENT_USER, REG_PATH)
- registry_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, REG_PATH, 0,
- _winreg.KEY_WRITE)
- _winreg.SetValueEx(registry_key, name, 0, _winreg.REG_SZ, value)
- _winreg.CloseKey(registry_key)
- return True
- except WindowsError:
- return False
- def get_vegas(name):
- try:
- registry_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, REG_PATH, 0,
- _winreg.KEY_READ)
- value, regtype = _winreg.QueryValueEx(registry_key, name)
- _winreg.CloseKey(registry_key)
- return value
- except WindowsError:
- return None
- class LoginWindow(ui.ScriptWindow):
- IS_TEST = net.IsTest()
- def __init__(self, stream):
- ui.ScriptWindow.__init__(self)
- net.SetPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
- net.SetAccountConnectorHandler(self)
- self.stream = stream
- self.channels = 0
- self.channelButton = None
- self.panelButton = None
- def __del__(self):
- ui.ScriptWindow.__del__(self)
- net.ClearPhaseWindow(net.PHASE_WINDOW_LOGIN, self)
- net.SetAccountConnectorHandler(0)
- def Open(self):
- self.loginFailureMsgDict={
- "ALREADY" : localeInfo.LOGIN_FAILURE_ALREAY,
- "NOID" : localeInfo.LOGIN_FAILURE_NOT_EXIST_ID,
- "WRONGPWD" : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
- "FULL" : localeInfo.LOGIN_FAILURE_TOO_MANY_USER,
- "SHUTDOWN" : localeInfo.LOGIN_FAILURE_SHUTDOWN,
- "REPAIR" : localeInfo.LOGIN_FAILURE_REPAIR_ID,
- "BLOCK" : localeInfo.LOGIN_FAILURE_BLOCK_ID,
- "WRONGMAT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER,
- "QUIT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER_TRIPLE,
- "BESAMEKEY" : localeInfo.LOGIN_FAILURE_BE_SAME_KEY,
- "NOTAVAIL" : localeInfo.LOGIN_FAILURE_NOT_AVAIL,
- "NOBILL" : localeInfo.LOGIN_FAILURE_NOBILL,
- "BLKLOGIN" : localeInfo.LOGIN_FAILURE_BLOCK_LOGIN,
- "WEBBLK" : localeInfo.LOGIN_FAILURE_WEB_BLOCK,
- }
- self.loginFailureFuncDict = {
- "WRONGPWD" : localeInfo.LOGIN_FAILURE_WRONG_PASSWORD,
- "WRONGMAT" : localeInfo.LOGIN_FAILURE_WRONG_MATRIX_CARD_NUMBER,
- "QUIT" : app.Exit,
- }
- self.SetSize(wndMgr.GetScreenWidth(), wndMgr.GetScreenHeight())
- self.SetWindowName("LoginWindow")
- self.__LoadScript(uiScriptLocale.LOCALE_UISCRIPT_PATH + "LoginWindow.py")
- if musicInfo.loginMusic != "":
- snd.SetMusicVolume(systemSetting.GetMusicVolume())
- snd.FadeInMusic("BGM/" + musicInfo.loginMusic)
- snd.SetSoundVolume(systemSetting.GetSoundVolume())
- ime.AddExceptKey(91)
- ime.AddExceptKey(93)
- self.SetChannelKurwy("CH1")
- self.idEditLine.SetFocus()
- self.Show()
- app.ShowCursor()
- def Close(self):
- if musicInfo.loginMusic != "" and musicInfo.selectMusic != "":
- snd.FadeOutMusic("BGM/"+musicInfo.loginMusic)
- if self.stream.popupWindow:
- self.stream.popupWindow.Close()
- self.Hide()
- app.HideCursor()
- ime.ClearExceptKey()
- def OnConnectFailure(self):
- snd.PlaySound("sound/ui/loginfail.wav")
- self.PopupNotifyMessage(localeInfo.LOGIN_CONNECT_FAILURE, self.EmptyFunc)
- def OnHandShake(self):
- snd.PlaySound("sound/ui/loginok.wav")
- self.PopupDisplayMessage(localeInfo.LOGIN_CONNECT_SUCCESS)
- def OnLoginStart(self):
- self.PopupDisplayMessage(localeInfo.LOGIN_PROCESSING)
- def OnLoginFailure(self, error):
- try:
- loginFailureMsg = self.loginFailureMsgDict[error]
- except KeyError:
- loginFailureMsg = localeInfo.LOGIN_FAILURE_UNKNOWN + error
- loginFailureFunc = self.loginFailureFuncDict.get(error, self.EmptyFunc)
- self.PopupNotifyMessage(loginFailureMsg, loginFailureFunc)
- snd.PlaySound("sound/ui/loginfail.wav")
- def __LoadScript(self, fileName):
- try:
- pyScrLoader = ui.PythonScriptLoader()
- pyScrLoader.LoadScriptFile(self, fileName)
- except:
- import exception
- exception.Abort("LoginWindow.__LoadScript.LoadObject")
- try:
- self.idEditLine = self.GetChild("id")
- self.pwdEditLine = self.GetChild("pwd")
- self.loginButton = self.GetChild("enter")
- self.channelButton = {
- "CH1" : self.GetChild("ch1"),
- "CH2" : self.GetChild("ch2"),
- "CH3" : self.GetChild("ch3"),
- "CH4" : self.GetChild("ch4"),
- "CH5" : self.GetChild("ch5"),
- "CH6" : self.GetChild("ch6")}
- self.panelButton = {
- "EXIT" : self.GetChild("exit")}
- for (action, button) in self.panelButton.items():
- button.SetEvent(ui.__mem_func__(self.MainBoard), action)
- for (channelID, channelButtons) in self.channelButton.items():
- channelButtons.SetEvent(ui.__mem_func__(self.SetChannelKurwy), channelID)
- if (get_vegas("id") != None) and (get_vegas("pwd") != None):
- self.idEditLine.SetText("%s" % binascii.a2b_base64("%s" % get_vegas("id")))
- self.pwdEditLine.SetText("%s" % binascii.a2b_base64("%s" % get_vegas("pwd")))
- except:
- import exception
- exception.Abort("LoginWindow.__LoadScript.BindObject")
- self.loginButton.SetEvent(ui.__mem_func__(self.__OnClickLoginButton))
- self.idEditLine.SetReturnEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))
- self.idEditLine.SetTabEvent(ui.__mem_func__(self.pwdEditLine.SetFocus))
- self.pwdEditLine.SetReturnEvent(ui.__mem_func__(self.__OnClickLoginButton))
- self.pwdEditLine.SetTabEvent(ui.__mem_func__(self.idEditLine.SetFocus))
- def MainBoard(self, action):
- actions = {
- "EXIT" : 0}
- if actions.has_key(action):
- if action != "EXIT":
- pass
- else:
- self.stream.SetPhaseWindow(0)
- def SetChannelKurwy(self, ch):
- self.SetChannelInfo(ch)
- for (channelID, channelButtons) in self.channelButton.items():
- if ch != channelID:
- channelButtons.SetUp()
- self.stream.SetConnectInfo("188.212.103.219", self.ChannelPort(ch, 0), "188.212.103.219", self.ChannelPort("LOGIN"))
- net.SetMarkServer("188.212.103.219", self.ChannelPort("LOGO"))
- app.SetGuildMarkPath("10.tga")
- app.SetGuildSymbolPath("10")
- net.SetServerInfo(self.ChannelPort(ch, 2))
- def SetChannelInfo(self, ch):
- self.channels = str(ch)
- def GetChannel(self):
- return self.channels
- def ChannelPort(self, ch="CH1", value=0):
- channel = {
- "CH1" : [21000, "ROG II -", "CH 1"],
- "CH2" : [22000, "ROG II -", "CH 2"],
- "CH3" : [24000, "ROG II -", "CH 3"],
- "CH4" : [25000, "ROG II -", "CH 4"],
- "CH5" : [21000, "ROG II -", "CH 5"],
- "CH6" : [21000, "ROG II -", "CH 6"]}
- if ch == "LOGIN":
- return 31009
- elif ch == "LOGO":
- return channel["CH1"][0]
- elif value == 2:
- return "%s, %s" % (channel[ch][1], channel[ch][2])
- else:
- return channel[ch][value]
- def Connect(self, id, pwd):
- if constInfo.SEQUENCE_PACKET_ENABLE:
- net.SetPacketSequenceMode()
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(localeInfo.LOGIN_CONNETING, self.EmptyFunc, localeInfo.UI_CANCEL)
- self.stream.SetLoginInfo(id, pwd)
- self.stream.Connect()
- def PopupDisplayMessage(self, msg):
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(msg)
- def PopupNotifyMessage(self, msg, func=0):
- if not func:
- func = self.EmptyFunc
- self.stream.popupWindow.Close()
- self.stream.popupWindow.Open(msg, func, localeInfo.UI_OK)
- def OnPressExitKey(self):
- if self.stream.popupWindow:
- self.stream.popupWindow.Close()
- self.stream.SetPhaseWindow(0)
- return TRUE
- def OnUpdate(self):
- for (channelID, channelButtons) in self.channelButton.items():
- if self.GetChannel() == channelID:
- channelButtons.Down()
- def EmptyFunc(self):
- pass
- def __OnClickLoginButton(self):
- id = self.idEditLine.GetText()
- pwd = self.pwdEditLine.GetText()
- if len(id)==0:
- self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_ID, self.EmptyFunc)
- return
- if len(pwd)==0:
- self.PopupNotifyMessage(localeInfo.LOGIN_INPUT_PASSWORD, self.EmptyFunc)
- return
- set_vegas("id", str(binascii.b2a_base64(id)))
- set_vegas("pwd", str(binascii.b2a_base64(pwd)))
- self.Connect(id, pwd)
intrologin.py