Created
July 2, 2014 07:18
-
-
Save freem/1b9dbd3cf14dd1621ab8 to your computer and use it in GitHub Desktop.
a test of calling ScreenTextEntry in StepMania 5 themes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- ScreenTextEntry test | |
t[#t+1] = Def.Actor{ | |
CodeMessageCommand=function(self,param) | |
if param.Name == "Toggle" then | |
SCREENMAN:AddNewScreenToTop("ScreenTextEntry"); | |
local teSettings = { | |
SendOnPop = "", | |
Question = "Are you cool?", | |
InitialAnswer = "I am cool", | |
MaxInputLength = 255, | |
Password = false, | |
Validate = function(answer, errorOut) | |
if answer == "I am cool" then | |
SCREENMAN:SystemMessage("No you're not"); | |
errorOut = "WONGS 2008"; | |
return false, errorOut | |
else | |
SCREENMAN:SystemMessage("I guess you are cool."); | |
end; | |
return true, ""; | |
end, | |
OnOK = function(answer) | |
-- do what you like | |
end, | |
OnCancel = function() | |
-- do what you like | |
end, | |
ValidateAppend = nil, | |
FormatAnswerForDisplay = function(answer) | |
return string.format("[%s]", answer) | |
end, | |
}; | |
local hexSettings = { | |
SendOnPop = "", | |
Question = "Type a hex value", | |
InitialAnswer = "", | |
MaxInputLength = 4, | |
Password = false, | |
Validate = nil, | |
OnOK = function(answer) | |
local value = tonumber(answer,16) | |
local decValue = tonumber(value,10) | |
SCREENMAN:SystemMessage("You entered 0x"..answer..", which = "..decValue); | |
end, | |
OnCancel = nil, | |
ValidateAppend = function(answer,append) | |
return tonumber(append, 16) and true or false; | |
end, | |
FormatAnswerForDisplay = function(answer) | |
return string.format("0x%s", answer) | |
end, | |
}; | |
local passSettings = { | |
SendOnPop = "", | |
Question = "Enter a password.", | |
InitialAnswer = "", | |
MaxInputLength = 255, | |
Password = true, | |
Validate = nil, | |
OnOK = nil, | |
OnCancel = nil, | |
ValidateAppend = nil, | |
FormatAnswerForDisplay = nil, | |
}; | |
local serverSettings = { | |
Question = "Connect to server:", | |
MaxInputLength = 255, | |
OnOK = function(answer) | |
if IsNetConnected() then | |
-- close connection before connecting to new server | |
CloseConnection() | |
end | |
-- connect to server | |
ConnectToServer(answer) | |
end, | |
}; | |
SCREENMAN:GetTopScreen():Load(serverSettings); | |
end; | |
end; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment