Skip to content

Commit

Permalink
Add a hotkey to Login/Logout to online integration
Browse files Browse the repository at this point in the history
to the theme
  • Loading branch information
poco0317 committed Nov 17, 2019
1 parent 553dbf1 commit cdbc3e4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,12 @@ local function ihatestickinginputcallbackseverywhere(event)
toggleNoteField()
end
end
if event.type == "InputEventType_FirstPress" then
local CtrlPressed = INPUTFILTER:IsControlPressed()
if CtrlPressed and event.DeviceInput.button == "DeviceButton_l" then
MESSAGEMAN:Broadcast("LoginHotkeyPressed")
end
end
return false
end

Expand Down
41 changes: 24 additions & 17 deletions Themes/Til Death/BGAnimations/_PlayerInfo.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@ local function highlightIfOver(self)
end
end

local function loginToggler()
if not DLMAN:IsLoggedIn() then
username = function(answer)
user = answer
end
password = function(answer)
pass = answer
DLMAN:Login(user, pass)
end
easyInputStringWithFunction("Password:", 50, true, password)
easyInputStringWithFunction("Username:", 50, false, username)
else
playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).UserName = ""
playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).PasswordToken = ""
playerConfig:set_dirty(pn_to_profile_slot(PLAYER_1))
playerConfig:save(pn_to_profile_slot(PLAYER_1))
DLMAN:Logout()
end
end

t[#t + 1] =
Def.Actor {
BeginCommand = function(self)
Expand Down Expand Up @@ -220,24 +240,11 @@ t[#t + 1] =
end,
MouseLeftClickMessageCommand = function(self)
if isOver(self) and not SCREENMAN:get_input_redirected(PLAYER_1) then
if not DLMAN:IsLoggedIn() then
username = function(answer)
user = answer
end
password = function(answer)
pass = answer
DLMAN:Login(user, pass)
end
easyInputStringWithFunction("Password:", 50, true, password)
easyInputStringWithFunction("Username:", 50, false, username)
else
playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).UserName = ""
playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).PasswordToken = ""
playerConfig:set_dirty(pn_to_profile_slot(PLAYER_1))
playerConfig:save(pn_to_profile_slot(PLAYER_1))
DLMAN:Logout()
end
loginToggler()
end
end,
LoginHotkeyPressedMessageCommand = function(self)
loginToggler()
end
},
LoadFont("Common Normal") ..
Expand Down

0 comments on commit cdbc3e4

Please sign in to comment.