Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/lobby/prelobby.js
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | else if (!Engine.GetGUIObjectByName("pageWelcome").hidden) | ||||
g_DisplayingSystemMessage = false; | g_DisplayingSystemMessage = false; | ||||
} | } | ||||
// Check that they entered a username. | // Check that they entered a username. | ||||
else if (!username) | else if (!username) | ||||
{ | { | ||||
continueButton.enabled = false; | continueButton.enabled = false; | ||||
feedback.caption = translate("Please enter your username"); | feedback.caption = translate("Please enter your username"); | ||||
} | } | ||||
// Check that they are using a valid username. | |||||
else if (username != sanitizePlayerName(username, true, true)) | // Prevent registation (but not login) with non-alphanumerical characters | ||||
if (!pageRegisterHidden && (!username.match(/^[a-z0-9._-]*$/i) || username.length > 20)) | |||||
{ | { | ||||
continueButton.enabled = false; | continueButton.enabled = false; | ||||
feedback.caption = translate("Usernames can't contain \\[, ], unicode, whitespace, or commas"); | feedback.caption = translate("Usernames can't contain \\[, ], unicode, whitespace, or commas"); | ||||
} | } | ||||
// Check that they entered a password. | // Check that they entered a password. | ||||
else if (!password) | else if (!password) | ||||
{ | { | ||||
continueButton.enabled = false; | continueButton.enabled = false; | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | case "registered": | ||||
Engine.GetGUIObjectByName("connectPassword").caption = password; | Engine.GetGUIObjectByName("connectPassword").caption = password; | ||||
Engine.StopXmppClient(); | Engine.StopXmppClient(); | ||||
switchPage("connect"); | switchPage("connect"); | ||||
break; | break; | ||||
case "connected": | case "connected": | ||||
{ | { | ||||
Engine.PopGuiPage(); | Engine.PopGuiPage(); | ||||
Engine.SwitchGuiPage("page_lobby.xml"); | Engine.SwitchGuiPage("page_lobby.xml"); | ||||
Engine.ConfigDB_CreateValue("user", "playername.multiplayer", sanitizePlayerName(username, true, true)); | Engine.ConfigDB_CreateValue("user", "playername.multiplayer", username); | ||||
Engine.ConfigDB_WriteValueToFile("user", "playername.multiplayer", sanitizePlayerName(username, true, true), "config/user.cfg"); | Engine.ConfigDB_WriteValueToFile("user", "playername.multiplayer", username, "config/user.cfg"); | ||||
Engine.ConfigDB_CreateValue("user", "lobby.login", username); | Engine.ConfigDB_CreateValue("user", "lobby.login", username); | ||||
Engine.ConfigDB_WriteValueToFile("user", "lobby.login", username, "config/user.cfg"); | Engine.ConfigDB_WriteValueToFile("user", "lobby.login", username, "config/user.cfg"); | ||||
// We only store the encrypted password, so make sure to re-encrypt it if changed before saving. | // We only store the encrypted password, so make sure to re-encrypt it if changed before saving. | ||||
if (password != g_EncryptedPassword.substring(0, 10)) | if (password != g_EncryptedPassword.substring(0, 10)) | ||||
g_EncryptedPassword = Engine.EncryptPassword(password, username); | g_EncryptedPassword = Engine.EncryptPassword(password, username); | ||||
Engine.ConfigDB_CreateValue("user", "lobby.password", g_EncryptedPassword); | Engine.ConfigDB_CreateValue("user", "lobby.password", g_EncryptedPassword); | ||||
Engine.ConfigDB_WriteValueToFile("user", "lobby.password", g_EncryptedPassword, "config/user.cfg"); | Engine.ConfigDB_WriteValueToFile("user", "lobby.password", g_EncryptedPassword, "config/user.cfg"); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | Engine.PushGuiPage("page_manual.xml", { | ||||
"title": translate("Terms of Use"), | "title": translate("Terms of Use"), | ||||
}); | }); | ||||
} | } | ||||
function prelobbyCancel() | function prelobbyCancel() | ||||
{ | { | ||||
lobbyStop(); | lobbyStop(); | ||||
Engine.GetGUIObjectByName("feedback").caption = ""; | |||||
if (Engine.GetGUIObjectByName("pageWelcome").hidden) | if (Engine.GetGUIObjectByName("pageWelcome").hidden) | ||||
switchPage("welcome"); | switchPage("welcome"); | ||||
else | else | ||||
Engine.PopGuiPage(); | Engine.PopGuiPage(); | ||||
} | } |
Wildfire Games · Phabricator