Skip to content
Snippets Groups Projects
Commit 8d526066 authored by DarkGod's avatar DarkGod
Browse files

checkbox

parent 764bc6f0
No related branches found
Tags tome-1.5.0
No related merge requests found
...@@ -386,10 +386,11 @@ function _M:performlogin(login, pass) ...@@ -386,10 +386,11 @@ function _M:performlogin(login, pass)
end end
end end
function _M:performloginSteam(token, name, email) function _M:performloginSteam(token, name, email, news)
self.steam_token = token self.steam_token = token
self.steam_token_name = name self.steam_token_name = name
if email then self.steam_token_email = email end if email then self.steam_token_email = email end
if news ~= nil then self.steam_token_news = news end
print("[ONLINE PROFILE] attempting log in steam", token) print("[ONLINE PROFILE] attempting log in steam", token)
self.auth_tried = nil self.auth_tried = nil
self:tryAuth() self:tryAuth()
...@@ -579,7 +580,7 @@ function _M:tryAuth() ...@@ -579,7 +580,7 @@ function _M:tryAuth()
print("[ONLINE PROFILE] auth") print("[ONLINE PROFILE] auth")
self.auth_last_error = nil self.auth_last_error = nil
if self.steam_token then if self.steam_token then
core.profile.pushOrder(table.serialize{o="SteamLogin", token=self.steam_token, name=self.steam_token_name, email=self.steam_token_email}) core.profile.pushOrder(table.serialize{o="SteamLogin", token=self.steam_token, name=self.steam_token_name, email=self.steam_token_email, news=self.steam_token_news})
else else
core.profile.pushOrder(table.serialize{o="Login", l=self.login, p=self.pass}) core.profile.pushOrder(table.serialize{o="Login", l=self.login, p=self.pass})
end end
...@@ -861,10 +862,10 @@ function _M:currentCharacter(module, title, uuid) ...@@ -861,10 +862,10 @@ function _M:currentCharacter(module, title, uuid)
print("[ONLINE PROFILE] current character ", title) print("[ONLINE PROFILE] current character ", title)
end end
function _M:newProfile(Login, Name, Password, Email) function _M:newProfile(Login, Name, Password, Email, Newsletter)
print("[ONLINE PROFILE] profile options ", Login, Email, Name) print("[ONLINE PROFILE] profile options ", Login, Email, Name, Newsletter)
core.profile.pushOrder(table.serialize{o="NewProfile2", login=Login, email=Email, name=Name, pass=Password}) core.profile.pushOrder(table.serialize{o="NewProfile2", login=Login, email=Email, name=Name, pass=Password, newsletter=Newsletter and 'yes' or 'no'})
local id = nil local id = nil
local reason = nil local reason = nil
self:waitEvent("NewProfile2", function(e) id = e.uid reason = e.reason end) self:waitEvent("NewProfile2", function(e) id = e.uid reason = e.reason end)
......
...@@ -594,7 +594,7 @@ function _M:createProfile(loginItem) ...@@ -594,7 +594,7 @@ function _M:createProfile(loginItem)
else else
self.auth_tried = nil self.auth_tried = nil
local d = Dialog:simpleWaiter("Registering...", "Registering on http://te4.org/, please wait...") core.display.forceRedraw() local d = Dialog:simpleWaiter("Registering...", "Registering on http://te4.org/, please wait...") core.display.forceRedraw()
local ok, err = profile:newProfile(loginItem.login, loginItem.name, loginItem.pass, loginItem.email) local ok, err = profile:newProfile(loginItem.login, loginItem.name, loginItem.pass, loginItem.email, loginItem.news)
profile:waitFirstAuth() profile:waitFirstAuth()
d:done() d:done()
if profile.auth then if profile.auth then
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
require "engine.class" require "engine.class"
local Dialog = require "engine.ui.Dialog" local Dialog = require "engine.ui.Dialog"
local Button = require "engine.ui.Button" local Button = require "engine.ui.Button"
local Checkbox = require "engine.ui.Checkbox"
local Textbox = require "engine.ui.Textbox" local Textbox = require "engine.ui.Textbox"
local Textzone = require "engine.ui.Textzone" local Textzone = require "engine.ui.Textzone"
...@@ -64,6 +65,8 @@ function _M:init(dialogdef, profile_help_text) ...@@ -64,6 +65,8 @@ function _M:init(dialogdef, profile_help_text)
self.c_pass = Textbox.new{title="Password: ", size_title=pwa, text="", chars=30, max_len=20, hide=true, filter=pass_filter, fct=function(text) self:okclick() end} self.c_pass = Textbox.new{title="Password: ", size_title=pwa, text="", chars=30, max_len=20, hide=true, filter=pass_filter, fct=function(text) self:okclick() end}
self.c_pass2 = Textbox.new{title=pwa, text="", size_title=pwa, chars=30, max_len=20, hide=true, filter=pass_filter, fct=function(text) self:okclick() end} self.c_pass2 = Textbox.new{title=pwa, text="", size_title=pwa, chars=30, max_len=20, hide=true, filter=pass_filter, fct=function(text) self:okclick() end}
self.c_email = Textbox.new{title="Email: ", size_title=pwa, text="", chars=30, max_len=60, filter=pass_filter, fct=function(text) self:okclick() end} self.c_email = Textbox.new{title="Email: ", size_title=pwa, text="", chars=30, max_len=60, filter=pass_filter, fct=function(text) self:okclick() end}
self.c_news = Checkbox.new{title="Accept to receive #{bold}#very infrequent#{normal}# (a few per year) mails", default=true, fct=function() self:okclick() end}
self.c_news2 = Textzone.new{text="about important game events from us.", width=self.iw - 20, auto_height=true}
local ok = require("engine.ui.Button").new{text="Create", fct=function() self:okclick() end} local ok = require("engine.ui.Button").new{text="Create", fct=function() self:okclick() end}
local cancel = require("engine.ui.Button").new{text="Cancel", fct=function() self:cancelclick() end} local cancel = require("engine.ui.Button").new{text="Cancel", fct=function() self:cancelclick() end}
...@@ -73,6 +76,8 @@ function _M:init(dialogdef, profile_help_text) ...@@ -73,6 +76,8 @@ function _M:init(dialogdef, profile_help_text)
{left=0, top=self.c_desc.h+self.c_login.h+5, ui=self.c_pass}, {left=0, top=self.c_desc.h+self.c_login.h+5, ui=self.c_pass},
{left=0, top=self.c_desc.h+self.c_login.h+self.c_pass.h+5, ui=self.c_pass2}, {left=0, top=self.c_desc.h+self.c_login.h+self.c_pass.h+5, ui=self.c_pass2},
{left=0, top=self.c_desc.h+self.c_login.h+self.c_pass.h+self.c_pass2.h+10, ui=self.c_email}, {left=0, top=self.c_desc.h+self.c_login.h+self.c_pass.h+self.c_pass2.h+10, ui=self.c_email},
{left=0, top=self.c_desc.h+self.c_login.h+self.c_pass.h+self.c_pass2.h+self.c_email.h+10, ui=self.c_news},
{left=0, top=self.c_desc.h+self.c_login.h+self.c_pass.h+self.c_pass2.h+self.c_email.h+self.c_news2.h+10, ui=self.c_news2},
{left=0, bottom=0, ui=ok}, {left=0, bottom=0, ui=ok},
{right=0, bottom=0, ui=cancel}, {right=0, bottom=0, ui=cancel},
} }
...@@ -105,7 +110,7 @@ function _M:okclick() ...@@ -105,7 +110,7 @@ function _M:okclick()
end end
game:unregisterDialog(self) game:unregisterDialog(self)
game:createProfile({create=self.c_email and true or false, login=self.c_login.text, pass=self.c_pass.text, email=self.c_email and self.c_email.text}) game:createProfile({create=self.c_email and true or false, login=self.c_login.text, pass=self.c_pass.text, email=self.c_email and self.c_email.text, news=self.c_news.checked})
end end
function _M:cancelclick() function _M:cancelclick()
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
require "engine.class" require "engine.class"
local Dialog = require "engine.ui.Dialog" local Dialog = require "engine.ui.Dialog"
local Button = require "engine.ui.Button" local Button = require "engine.ui.Button"
local Checkbox = require "engine.ui.Checkbox"
local Textbox = require "engine.ui.Textbox" local Textbox = require "engine.ui.Textbox"
local Textzone = require "engine.ui.Textzone" local Textzone = require "engine.ui.Textzone"
...@@ -42,12 +43,16 @@ Luckily this is very easy to do: you only require a profile name and optionally ...@@ -42,12 +43,16 @@ Luckily this is very easy to do: you only require a profile name and optionally
self.c_login = Textbox.new{title="Username: ", text="", chars=30, max_len=20, fct=function(text) self:okclick() end} self.c_login = Textbox.new{title="Username: ", text="", chars=30, max_len=20, fct=function(text) self:okclick() end}
self.c_email = Textbox.new{title="Email: ", size_title=self.c_login.title, text="", chars=30, max_len=60, fct=function(text) self:okclick() end} self.c_email = Textbox.new{title="Email: ", size_title=self.c_login.title, text="", chars=30, max_len=60, fct=function(text) self:okclick() end}
self.c_news = Checkbox.new{title="Accept to receive #{bold}#very infrequent#{normal}# (a few per year) mails", default=true, fct=function() self:okclick() end}
self.c_news2 = Textzone.new{text="about important game events from us.", width=self.iw - 20, auto_height=true}
local ok = require("engine.ui.Button").new{text="Register", fct=function() self:okclick() end} local ok = require("engine.ui.Button").new{text="Register", fct=function() self:okclick() end}
local cancel = require("engine.ui.Button").new{text="Cancel", fct=function() self:cancelclick() end} local cancel = require("engine.ui.Button").new{text="Cancel", fct=function() self:cancelclick() end}
self:loadUI{ self:loadUI{
{left=0, top=0, ui=self.c_desc}, {left=0, top=0, ui=self.c_desc},
{left=0, top=self.c_desc.h, ui=self.c_login}, {left=0, top=self.c_desc.h, ui=self.c_login},
{left=0, top=self.c_desc.h+self.c_login.h+5, ui=self.c_email}, {left=0, top=self.c_desc.h+self.c_login.h+5, ui=self.c_email},
{left=0, top=self.c_desc.h+self.c_login.h+self.c_email.h+5, ui=self.c_news},
{left=0, top=self.c_desc.h+self.c_login.h+self.c_email.h+self.c_news.h+5, ui=self.c_news2},
{left=0, bottom=0, ui=ok}, {left=0, bottom=0, ui=ok},
{right=0, bottom=0, ui=cancel}, {right=0, bottom=0, ui=cancel},
} }
...@@ -78,7 +83,7 @@ function _M:okclick() ...@@ -78,7 +83,7 @@ function _M:okclick()
return return
end end
profile:performloginSteam(ticket:toHex(), self.c_login.text, self.c_email.text ~= "" and self.c_email.text) profile:performloginSteam(ticket:toHex(), self.c_login.text, self.c_email.text ~= "" and self.c_email.text, self.c_news.checked)
profile:waitFirstAuth() profile:waitFirstAuth()
d:done() d:done()
if not profile.auth and profile.auth_last_error then if not profile.auth and profile.auth_last_error then
......
...@@ -162,6 +162,8 @@ function _M:login() ...@@ -162,6 +162,8 @@ function _M:login()
if self.steam_token_email then if self.steam_token_email then
self:command("STM_ EMAIL", self.steam_token_email) self:command("STM_ EMAIL", self.steam_token_email)
self:read("200") self:read("200")
self:command("STM_ NEWS", self.steam_token_news and 'yes' or 'no')
self:read("200")
end end
self:command("STM_ AUTH", self.steam_token) self:command("STM_ AUTH", self.steam_token)
if not self:read("200") then if not self:read("200") then
...@@ -303,7 +305,10 @@ end ...@@ -303,7 +305,10 @@ end
function _M:orderSteamLogin(o) function _M:orderSteamLogin(o)
self.steam_token = o.token self.steam_token = o.token
self.steam_token_name = o.name self.steam_token_name = o.name
if o.email and #o.email > 1 then self.steam_token_email = o.email end if o.email and #o.email > 1 then
self.steam_token_email = o.email
self.steam_token_news = o.news
end
if not self.sock then cprofile.pushEvent("e='Disconnected'") return end if not self.sock then cprofile.pushEvent("e='Disconnected'") return end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment