Advertisement
Guest User

Touch mk2

a guest
Aug 6th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 45.88 KB | None | 0 0
  1. --Code by Max Wason
  2.  
  3. monitorSide = "right"
  4. wirelessRedstoneSide = "back"
  5. wirelessModemSide = "right"
  6. mystcraftTurtleID = 3
  7. AEcomputerID = 14
  8. tankComputerID = 16
  9. powerComputerID = 6
  10.  
  11. --wr = peripheral.wrap(wirelessRedstoneSide)
  12. --rednet.open(wirelessModemSide)
  13.  
  14.  
  15. monitor = peripheral.wrap(monitorSide)
  16. print(monitor.getSize())
  17.  
  18. os.loadAPI("touchpointEdited")
  19. -- local page1 = touchpointEdited.new(monitorSide)
  20. -- local page2 = touchpointEdited.new(monitorSide)
  21. local loginPage = touchpointEdited.new(monitorSide) --Login
  22. local mainPage = touchpointEdited.new(monitorSide) --Main screen after login
  23.  
  24. local accountPage = touchpointEdited.new(monitorSide)
  25. local changePasswordPage = touchpointEdited.new(monitorSide)
  26. local changeAccessPage = touchpointEdited.new(monitorSide)
  27. local changeAddUserPage = touchpointEdited.new(monitorSide)
  28. local changeRemoveUserPage = touchpointEdited.new(monitorSide)
  29.  
  30. local mystcraftPage = touchpointEdited.new(monitorSide)
  31. local mystcraftInterlinkingPage = touchpointEdited.new(monitorSide)
  32. local mystcraftIntralinkingPage = touchpointEdited.new(monitorSide)
  33.  
  34. local powerPage = touchpointEdited.new(monitorSide)
  35.  
  36. local oreProcessingPage = touchpointEdited.new(monitorSide)
  37.  
  38. local aePage = touchpointEdited.new(monitorSide)
  39.  
  40. local nuclearControlPage = touchpointEdited.new(monitorSide)
  41.  
  42. local t
  43.  
  44. --*******************************************************Profile Class********************************************************************
  45.  
  46. Profile = {}
  47. Profile.__index = Profile
  48.  
  49. function Profile.create(name, password, access)
  50. local profile = {}
  51. setmetatable(profile,Profile)
  52. profile.name = name
  53. profile.password = password
  54. profile.access = access
  55. return profile
  56. end
  57.  
  58.  
  59. --********************************************************END OF PROFILE CLASS*************************************************************
  60.  
  61.  
  62. --*******************************************************FILE IO************************************************************************
  63.  
  64. fileName = "userData.txt"
  65.  
  66. function file_exists(name)
  67. local f=io.open(name,"r")
  68. if f~=nil then io.close(f) return true else return false end
  69. end
  70.  
  71. local write, writeIndent, writers, refCount;
  72.  
  73. persistence =
  74. {
  75. store = function (path, ...)
  76. local file, e = io.open(path, "w");
  77. if not file then
  78. return error(e);
  79. end
  80. local n = select("#", ...);
  81. -- Count references
  82. local objRefCount = {}; -- Stores reference that will be exported
  83. for i = 1, n do
  84. refCount(objRefCount, (select(i,...)));
  85. end;
  86. -- Export Objects with more than one ref and assign name
  87. -- First, create empty tables for each
  88. local objRefNames = {};
  89. local objRefIdx = 0;
  90. file:write("-- Persistent Data\n");
  91. file:write("local multiRefObjects = {\n");
  92. for obj, count in pairs(objRefCount) do
  93. if count > 1 then
  94. objRefIdx = objRefIdx + 1;
  95. objRefNames[obj] = objRefIdx;
  96. file:write("{};"); -- table objRefIdx
  97. end;
  98. end;
  99. file:write("\n} -- multiRefObjects\n");
  100. -- Then fill them (this requires all empty multiRefObjects to exist)
  101. for obj, idx in pairs(objRefNames) do
  102. for k, v in pairs(obj) do
  103. file:write("multiRefObjects["..idx.."][");
  104. write(file, k, 0, objRefNames);
  105. file:write("] = ");
  106. write(file, v, 0, objRefNames);
  107. file:write(";\n");
  108. end;
  109. end;
  110. -- Create the remaining objects
  111. for i = 1, n do
  112. file:write("local ".."obj"..i.." = ");
  113. write(file, (select(i,...)), 0, objRefNames);
  114. file:write("\n");
  115. end
  116. -- Return them
  117. if n > 0 then
  118. file:write("return obj1");
  119. for i = 2, n do
  120. file:write(" ,obj"..i);
  121. end;
  122. file:write("\n");
  123. else
  124. file:write("return\n");
  125. end;
  126. file:close();
  127. end;
  128.  
  129. load = function (path)
  130. local f, e = loadfile(path);
  131. if f then
  132. return f();
  133. else
  134. return nil, e;
  135. end;
  136. end;
  137. }
  138.  
  139. -- Private methods
  140.  
  141. -- write thing (dispatcher)
  142. write = function (file, item, level, objRefNames)
  143. writers[type(item)](file, item, level, objRefNames);
  144. end;
  145.  
  146. -- write indent
  147. writeIndent = function (file, level)
  148. for i = 1, level do
  149. file:write("\t");
  150. end;
  151. end;
  152.  
  153. -- recursively count references
  154. refCount = function (objRefCount, item)
  155. -- only count reference types (tables)
  156. if type(item) == "table" then
  157. -- Increase ref count
  158. if objRefCount[item] then
  159. objRefCount[item] = objRefCount[item] + 1;
  160. else
  161. objRefCount[item] = 1;
  162. -- If first encounter, traverse
  163. for k, v in pairs(item) do
  164. refCount(objRefCount, k);
  165. refCount(objRefCount, v);
  166. end;
  167. end;
  168. end;
  169. end;
  170.  
  171. -- Format items for the purpose of restoring
  172. writers = {
  173. ["nil"] = function (file, item)
  174. file:write("nil");
  175. end;
  176. ["number"] = function (file, item)
  177. file:write(tostring(item));
  178. end;
  179. ["string"] = function (file, item)
  180. file:write(string.format("%q", item));
  181. end;
  182. ["boolean"] = function (file, item)
  183. if item then
  184. file:write("true");
  185. else
  186. file:write("false");
  187. end
  188. end;
  189. ["table"] = function (file, item, level, objRefNames)
  190. local refIdx = objRefNames[item];
  191. if refIdx then
  192. -- Table with multiple references
  193. file:write("multiRefObjects["..refIdx.."]");
  194. else
  195. -- Single use table
  196. file:write("{\n");
  197. for k, v in pairs(item) do
  198. writeIndent(file, level+1);
  199. file:write("[");
  200. write(file, k, level+1, objRefNames);
  201. file:write("] = ");
  202. write(file, v, level+1, objRefNames);
  203. file:write(";\n");
  204. end
  205. writeIndent(file, level);
  206. file:write("}");
  207. end;
  208. end;
  209. ["function"] = function (file, item)
  210. -- Does only work for "normal" functions, not those
  211. -- with upvalues or c functions
  212. local dInfo = debug.getinfo(item, "uS");
  213. if dInfo.nups > 0 then
  214. file:write("nil --[[functions with upvalue not supported]]");
  215. elseif dInfo.what ~= "Lua" then
  216. file:write("nil --[[non-lua function not supported]]");
  217. else
  218. local r, s = pcall(string.dump,item);
  219. if r then
  220. file:write(string.format("loadstring(%q)", s));
  221. else
  222. file:write("nil --[[function could not be dumped]]");
  223. end
  224. end
  225. end;
  226. ["thread"] = function (file, item)
  227. file:write("nil --[[thread]]\n");
  228. end;
  229. ["userdata"] = function (file, item)
  230. file:write("nil --[[userdata]]\n");
  231. end;
  232. }
  233.  
  234. if file_exists(fileName) then
  235. profileArray = persistence.load(fileName);
  236. else
  237. profileArray = {
  238. Profile.create("gr8pefish", "temporary", 1),
  239. Profile.create("admin", "pass", 1),
  240. Profile.create("guest", "password", 3),
  241. Profile.create("Test Account", "Pass 123", 1)
  242. }
  243. persistence.store(fileName, profileArray)
  244. end
  245.  
  246.  
  247. --***************************************************EDN OF FILE IO************************************************************************
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254. --********************************************************KEYBOARD/LOGIN********************************************************************
  255. username = ""
  256. password = ""
  257. input = ""
  258. useUppercase = false
  259. useUsername = true
  260. usePassword = false
  261.  
  262. usernameSubmittedExists = false
  263. loginPasswordExists = false
  264. loginUsernameExists = false
  265. loginPassword = ""
  266. loginUsername = ""
  267.  
  268. currentUser = nil
  269. valid = false
  270.  
  271. function checkValid()
  272. if (loginPasswordExists and loginUsernameExists) then
  273. for key, value in pairs(profileArray) do
  274. if loginUsername == value.name then
  275. usernameSubmittedExists = true
  276. if loginPassword == value.password then
  277. valid = true
  278. currentUser = value
  279. else
  280. valid = false
  281. end
  282. end
  283. end
  284. drawMessage()
  285. end
  286. end
  287.  
  288. function checkValidUsernameAndPassword(confirm)
  289. if confirm == "goOn" then
  290. t = mainPage
  291. elseif confirm == "backToPassword" then
  292. drawPassword()
  293. elseif confirm == "backToUsername" then
  294. drawUsername()
  295. elseif confirm == "password" then
  296. confirmPassword()
  297. checkValid()
  298. elseif confirm == "username" then
  299. confirmUsername()
  300. checkValid()
  301. end
  302. end
  303.  
  304.  
  305.  
  306. function confirmPassword()
  307. loginPassword = input
  308. loginPasswordExists = true
  309. input = ""
  310. usePassword = false
  311. useUsername = true
  312. drawUsername()
  313. doBackspace()
  314. end
  315.  
  316. function confirmUsername()
  317. loginUsername = input
  318. loginUsernameExists = true
  319. input = ""
  320. useUsername = false
  321. usePassword = true
  322. drawPassword()
  323. doBackspace()
  324. end
  325.  
  326. local inputTable = {
  327. " ",
  328. " ",
  329. label = "inputLabel",
  330. }
  331.  
  332. local ArrowTable = {
  333. "-->",
  334. label = "ArrowLabel",
  335. }
  336.  
  337. local additionalOkayTable = {
  338. "Okay",
  339. label = "additionalOkayLabel"
  340. }
  341.  
  342. local loginTable = {
  343. " Please Login ",
  344. " ",
  345. "Enter your username and password.",
  346. "Press okay to confirm each. ",
  347. label = "loginTableLabel",
  348. }
  349.  
  350. local infoTableUsername = {
  351. "Enter your username: ",
  352. label = "infoLabel"
  353. }
  354.  
  355. function drawMessage()
  356. if valid then
  357. infoTableContinue = {"Welcome Back!", label = "infoLabel"}
  358. loginPage:rename("infoLabel", infoTableContinue)
  359.  
  360. inputTableContinue = {currentUser.name,"Access Level: "..currentUser.access, label = "inputLabel"}
  361. loginPage:rename("inputLabel", inputTableContinue)
  362.  
  363. key = "goOn"
  364. elseif usernameSubmittedExists then
  365. infoTableContinue = {"You seem to have entered", label = "infoLabel"}
  366. loginPage:rename("infoLabel", infoTableContinue)
  367.  
  368. inputTableContinue = {"the wrong password",loginUsername, label = "inputLabel"}
  369. loginPage:rename("inputLabel", inputTableContinue)
  370.  
  371. loginPasswordExists = false
  372. useUsername = false
  373. usePassword = true
  374. input = ""
  375. key = "backToPassword"
  376. else
  377. infoTableContinue = {"There is no username called", label = "infoLabel"}
  378. loginPage:rename("infoLabel", infoTableContinue)
  379.  
  380. inputTableContinue = {loginUsername," ", label = "inputLabel"}
  381. loginPage:rename("inputLabel", inputTableContinue)
  382.  
  383. loginPasswordExists = false
  384. loginUsernameExists = false
  385. useUsername = true
  386. usePassword = false
  387. input = ""
  388. key = "backToUsername"
  389. end
  390. end
  391.  
  392.  
  393. function drawUsername()
  394. key = "username"
  395. loginPage:rename("infoLabel", infoTableUsername)
  396. doBackspace()
  397. end
  398.  
  399. function drawPassword()
  400. key = "password"
  401. infoTablePassword = {"Enter your password: ", label = "infoLabel"}
  402. loginPage:rename("infoLabel", infoTablePassword)
  403. doBackspace()
  404. end
  405.  
  406. function updateUsernameOutput(input)
  407. if (#input < 16) then
  408. input = (input..(string.rep(" ",(16-#input))))
  409. end
  410.  
  411. newInput = {input," ", label = "inputLabel"}
  412. loginPage:rename("inputLabel", newInput, true)
  413. end
  414.  
  415. function addToInput(char)
  416. if useUppercase then char = char:upper() end
  417. if (#input >= 16) then
  418. input = input:sub(0,16)
  419. else
  420. input = (input..char)
  421. end
  422.  
  423. if useUsername then
  424. updateUsernameOutput(input)
  425. else
  426. updatePasswordOutput(input)
  427. end
  428. end
  429.  
  430. function updatePasswordOutput(input)
  431. input2 = string.rep("*", #input)
  432.  
  433. if (#input < 16) then
  434. input = (input..(string.rep(" ",(16-#input))))
  435. end
  436.  
  437. newInput = {input2," ", label = "inputLabel"}
  438. loginPage:rename("inputLabel", newInput, true)
  439. end
  440.  
  441. key = "username"
  442. loginPage:add(loginTable, nil, 3, 35, 2, 5, colors.black, colors.black, colors.brown)
  443.  
  444. loginPage:add(infoTableUsername, nil, 5, 28, 9, 9, colors.black, colors.black, colors.lightGray)
  445. loginPage:add(ArrowTable, nil, 1, 4, 10, 10, colors.black, colors.black, colors.brown)
  446. loginPage:add(inputTable, nil, 5, 22, 10, 11, colors.black, colors.black, colors.lightGray)
  447. loginPage:add("Okay", function() checkValidUsernameAndPassword(key) end, 25, 30, 10, 10, colors.black, colors.black, colors.cyan)
  448.  
  449. loginPage:add("1", function() addToInput("1") end, 5, 5, 14, 14, colors.black, colors.black, colors.lightGray)
  450. loginPage:add("2", function() addToInput("2") end, 7, 7, 14, 14, colors.black, colors.black, colors.lightGray)
  451. loginPage:add("3", function() addToInput("3") end, 9, 9, 14, 14, colors.black, colors.black, colors.lightGray)
  452. loginPage:add("4", function() addToInput("4") end, 11, 11, 14, 14, colors.black, colors.black, colors.lightGray)
  453. loginPage:add("5", function() addToInput("5") end, 13, 13, 14, 14, colors.black, colors.black, colors.lightGray)
  454. loginPage:add("6", function() addToInput("6") end, 15, 15, 14, 14, colors.black, colors.black, colors.lightGray)
  455. loginPage:add("7", function() addToInput("7") end, 17, 17, 14, 14, colors.black, colors.black, colors.lightGray)
  456. loginPage:add("8", function() addToInput("8") end, 19, 19, 14, 14, colors.black, colors.black, colors.lightGray)
  457. loginPage:add("9", function() addToInput("9") end, 21, 21, 14, 14, colors.black, colors.black, colors.lightGray)
  458. loginPage:add("0", function() addToInput("0") end, 23, 23, 14, 14, colors.black, colors.black, colors.lightGray)
  459.  
  460. loginPage:add("Q", function() addToInput("q") end, 5, 5, 15, 15, colors.black, colors.black, colors.lightGray)
  461. loginPage:add("W", function() addToInput("w") end, 7, 7, 15, 15, colors.black, colors.black, colors.lightGray)
  462. loginPage:add("E", function() addToInput("e") end, 9, 9, 15, 15, colors.black, colors.black, colors.lightGray)
  463. loginPage:add("R", function() addToInput("r") end, 11, 11, 15, 15, colors.black, colors.black, colors.lightGray)
  464. loginPage:add("T", function() addToInput("t") end, 13, 13, 15, 15, colors.black, colors.black, colors.lightGray)
  465. loginPage:add("Y", function() addToInput("y") end, 15, 15, 15, 15, colors.black, colors.black, colors.lightGray)
  466. loginPage:add("U", function() addToInput("u") end, 17, 17, 15, 15, colors.black, colors.black, colors.lightGray)
  467. loginPage:add("I", function() addToInput("i") end, 19, 19, 15, 15, colors.black, colors.black, colors.lightGray)
  468. loginPage:add("O", function() addToInput("o") end, 21, 21, 15, 15, colors.black, colors.black, colors.lightGray)
  469. loginPage:add("P", function() addToInput("p") end, 23, 23, 15, 15, colors.black, colors.black, colors.lightGray)
  470.  
  471. loginPage:add("A", function() addToInput("a") end, 6, 6, 16, 16, colors.black, colors.black, colors.lightGray)
  472. loginPage:add("S", function() addToInput("s") end, 8, 8, 16, 16, colors.black, colors.black, colors.lightGray)
  473. loginPage:add("D", function() addToInput("d") end, 10, 10, 16, 16, colors.black, colors.black, colors.lightGray)
  474. loginPage:add("F", function() addToInput("f") end, 12, 12, 16, 16, colors.black, colors.black, colors.lightGray)
  475. loginPage:add("G", function() addToInput("g") end, 14, 14, 16, 16, colors.black, colors.black, colors.lightGray)
  476. loginPage:add("H", function() addToInput("h") end, 16, 16, 16, 16, colors.black, colors.black, colors.lightGray)
  477. loginPage:add("J", function() addToInput("j") end, 18, 18, 16, 16, colors.black, colors.black, colors.lightGray)
  478. loginPage:add("K", function() addToInput("k") end, 20, 20, 16, 16, colors.black, colors.black, colors.lightGray)
  479. loginPage:add("L", function() addToInput("l") end, 22, 22, 16, 16, colors.black, colors.black, colors.lightGray)
  480.  
  481. loginPage:add("Z", function() addToInput("z") end, 7, 7, 17, 17, colors.black, colors.black, colors.lightGray)
  482. loginPage:add("X", function() addToInput("x") end, 9, 9, 17, 17, colors.black, colors.black, colors.lightGray)
  483. loginPage:add("C", function() addToInput("c") end, 11, 11, 17, 17, colors.black, colors.black, colors.lightGray)
  484. loginPage:add("V", function() addToInput("v") end, 13, 13, 17, 17, colors.black, colors.black, colors.lightGray)
  485. loginPage:add("B", function() addToInput("b") end, 15, 15, 17, 17, colors.black, colors.black, colors.lightGray)
  486. loginPage:add("N", function() addToInput("n") end, 17, 17, 17, 17, colors.black, colors.black, colors.lightGray)
  487. loginPage:add("M", function() addToInput("m") end, 19, 19, 17, 17, colors.black, colors.black, colors.lightGray)
  488.  
  489. loginPage:add("Shift",function() doShift() end, 29, 35, 15, 15, colors.cyan, colors.green, colors.white)
  490. loginPage:add("Backspace", function() doBackspace() end, 26, 39, 17, 17, colors.black, colors.black, colors.cyan)
  491. loginPage:add("Space", function() addToInput(" ") end, 29, 35, 16, 16, colors.black, colors.black, colors.cyan)
  492.  
  493.  
  494. function doBackspace()
  495. input = input:sub(0, #input-1)
  496. if useUsername then updateUsernameOutput(input) else updatePasswordOutput(input) end
  497. end
  498.  
  499. function doShift()
  500. loginPage:toggleButton("Shift")
  501. if (loginPage.buttonList["Shift"].active) then useUppercase = true else useUppercase = false end
  502. end
  503.  
  504.  
  505.  
  506.  
  507. --**************************************************END OF KEYBOARD/PAGE 3**************************************************************************
  508.  
  509.  
  510.  
  511. --****************************************************START OF ACCOUNT PAGE***********************************************************************
  512. local mainTOaccount = {
  513. "View Account",
  514. " Details",
  515. label = "mainToaccountLabel",
  516. }
  517.  
  518.  
  519.  
  520. function addmainPage()
  521. --Add these for everyone
  522. welcomeMainScreenXPos = ((20) - ((8 + currentUser.name:len())/2))
  523. if math.floor(welcomeMainScreenXPos) <= 0 then welcomeMainScreenXPos = 1 end
  524. -- print("printing name at x="..welcomeMainScreenXPos)
  525. mainPage:add("Welcome "..currentUser.name, nil, math.floor(welcomeMainScreenXPos), math.floor((welcomeMainScreenXPos)+(9+currentUser.name:len())), 2, 2, colors.black, colors.black, colors.brown)
  526. mainPage:add(mainTOaccount, mainToAccountPage, 5,18, 5,6, colors.black, colors.black, colors.cyan)
  527.  
  528. --Add these if the access level is high enough
  529. --[[if (currentUser.access < 3) then
  530. mainPage:add(mainTOae, mainTOaePage, 7,18, 15,16, colors.black, colors.black, colors.cyan)
  531. end]]
  532.  
  533. end
  534.  
  535. function mainToAccountPage() t = accountPage end
  536.  
  537.  
  538. --*************************************************END OF ACCOUNT PAGE*************************************************************************
  539.  
  540. --**************************************************START OF ACCOUNT PAGE*****************************************************************
  541.  
  542.  
  543. goBack = {
  544. "<-",
  545. label = "goBackLabel",
  546. }
  547.  
  548. local accountChangePasswordTable = {
  549. "Change your",
  550. " password ",
  551. label = "accountChangePasswordLabel"
  552. }
  553.  
  554. local accountChangeAccessPermissionsTable = {
  555. "Change Access",
  556. " Permissions ",
  557. label = "accountChangeAccessPermissionsLabel",
  558. }
  559.  
  560. local accountCreateNewUserTable = {
  561. " Create a ",
  562. "New Profile",
  563. label = "accountCreateNewUserLabel",
  564. }
  565.  
  566. local accountRemoveUserTable = {
  567. " Remove an ",
  568. "existing user",
  569. label = "accountRemoveUserLabel",
  570. }
  571.  
  572.  
  573.  
  574. function addAccountPage()
  575. accountPagePasswordTable = {
  576. "Password: "..currentUser.password.."",
  577. label = "accountPagePasswordLabel",
  578. }
  579.  
  580. accountPageAccessTable = {
  581. "Access Level: "..currentUser.access,
  582. label = "accountPageAccessLabel",
  583. }
  584.  
  585. accountPage:add(goBack, goBackMain, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  586. accountPage:add("Account Information", nil, 10, 30, 2, 2, colors.black, colors.black, colors.brown)
  587.  
  588. accountPage:add("Name: "..currentUser.name, nil, 2, tonumber(9+currentUser.name:len()), 6, 6, colors.black, colors.black, colors.lightGray)
  589. accountPage:add(accountPagePasswordTable, nil, 3, 25, 8,8, colors.black, colors.black, colors.lightGray)
  590. accountPage:add(accountPageAccessTable, nil, 3, 19, 10, 10, colors.black, colors.black, colors.lightGray)
  591.  
  592. if currentUser.name ~= "guest" then
  593. accountPage:add(accountChangePasswordTable, accountToChangePassword, 5, 15, 13, 14, colors.black, colors.black, colors.cyan)
  594. end
  595. accountPage:add("Log out", logOut, 27, 35, 8, 8, colors.black, colors.black, colors.cyan)
  596.  
  597. if (currentUser.access < 2) then--if highest access level
  598. accountPage:add(accountChangeAccessPermissionsTable, accountToChangeAccessPermissions, 22, 38, 13, 14, colors.black, colors.black, colors.cyan)
  599. accountPage:add(accountCreateNewUserTable, accountToCreateNewUser, 5,15, 17,18, colors.black, colors.black, colors.cyan)
  600. accountPage:add(accountRemoveUserTable, accountToRemoveUser, 22,38, 17,18, colors.black, colors.black, colors.cyan)
  601. end
  602. end
  603.  
  604. function goBackMain()
  605. mainPage = nil
  606. mainPageNotDrawn = true
  607. mainPage = touchpointEdited.new(monitorSide)
  608. t = mainPage
  609. end
  610.  
  611. function logOut() os.reboot() end
  612.  
  613. function accountToChangePassword() t = changePasswordPage end
  614.  
  615. function accountToChangeAccessPermissions() t = changeAccessPage end
  616.  
  617. function accountToCreateNewUser()
  618. if (#profileArray <= 5) then
  619. t = changeAddUserPage
  620. end
  621. end
  622.  
  623. function accountToRemoveUser() t = changeRemoveUserPage end
  624.  
  625.  
  626. --*************************************************END OF ACCOUNT PAGE*******************************************************************
  627.  
  628.  
  629.  
  630. --*************************************************START OF CHANGE PASSWORD PAGE*********************************************************
  631.  
  632.  
  633.  
  634. function addChangePasswordPage()
  635. passkey = "firstEntry"
  636. input = ""
  637. useUppercase = false
  638.  
  639. useNewPassword = true
  640. useConfirmPassword = false
  641. newPasswordConfirmed = false
  642. confirmedPasswordConfirmed = false
  643.  
  644. changePasswordPageCurrentPasswordTable = {
  645. "Your current password is: "..currentUser.password,
  646. label = "changePasswordPageCurrentPasswordLabel",
  647. }
  648.  
  649. newPasswordInputTable = {
  650. " ",
  651. label = "newPasswordInputLabel",
  652. }
  653.  
  654. local changePasswordTitleTable = {
  655. "Please enter your",
  656. "desired password:",
  657. label = "changePasswordTitleLabel",
  658. }
  659.  
  660. changePasswordPage:add(goBack, goBackAccessPage, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  661. changePasswordPage:add("Change Password", nil, 10,30, 2,2, colors.black, colors.black, colors.brown)
  662. changePasswordPage:add(changePasswordPageCurrentPasswordTable, nil, 2,35, 5,5, colors.black, colors.black, colors.brown)
  663. changePasswordPage:add(changePasswordTitleTable, nil, 4,39, 8,9, colors.black, colors.black, colors.lightGray)
  664. changePasswordPage:add(ArrowTable, nil, 1, 4, 10, 10, colors.black, colors.black, colors.brown)
  665.  
  666. changePasswordPage:add(newPasswordInputTable, nil, 5, 22, 10, 10, colors.black, colors.black, colors.lightGray)
  667. changePasswordPage:add("Okay", function() confirmNewPassword(passkey) end, 25, 30, 10, 10, colors.black, colors.black, colors.cyan)
  668.  
  669. changePasswordPage:add("1", function() addToPasswordInput("1") end, 5, 5, 14, 14, colors.black, colors.black, colors.lightGray)
  670. changePasswordPage:add("2", function() addToPasswordInput("2") end, 7, 7, 14, 14, colors.black, colors.black, colors.lightGray)
  671. changePasswordPage:add("3", function() addToPasswordInput("3") end, 9, 9, 14, 14, colors.black, colors.black, colors.lightGray)
  672. changePasswordPage:add("4", function() addToPasswordInput("4") end, 11, 11, 14, 14, colors.black, colors.black, colors.lightGray)
  673. changePasswordPage:add("5", function() addToPasswordInput("5") end, 13, 13, 14, 14, colors.black, colors.black, colors.lightGray)
  674. changePasswordPage:add("6", function() addToPasswordInput("6") end, 15, 15, 14, 14, colors.black, colors.black, colors.lightGray)
  675. changePasswordPage:add("7", function() addToPasswordInput("7") end, 17, 17, 14, 14, colors.black, colors.black, colors.lightGray)
  676. changePasswordPage:add("8", function() addToPasswordInput("8") end, 19, 19, 14, 14, colors.black, colors.black, colors.lightGray)
  677. changePasswordPage:add("9", function() addToPasswordInput("9") end, 21, 21, 14, 14, colors.black, colors.black, colors.lightGray)
  678. changePasswordPage:add("0", function() addToPasswordInput("0") end, 23, 23, 14, 14, colors.black, colors.black, colors.lightGray)
  679.  
  680. changePasswordPage:add("Q", function() addToPasswordInput("q") end, 5, 5, 15, 15, colors.black, colors.black, colors.lightGray)
  681. changePasswordPage:add("W", function() addToPasswordInput("w") end, 7, 7, 15, 15, colors.black, colors.black, colors.lightGray)
  682. changePasswordPage:add("E", function() addToPasswordInput("e") end, 9, 9, 15, 15, colors.black, colors.black, colors.lightGray)
  683. changePasswordPage:add("R", function() addToPasswordInput("r") end, 11, 11, 15, 15, colors.black, colors.black, colors.lightGray)
  684. changePasswordPage:add("T", function() addToPasswordInput("t") end, 13, 13, 15, 15, colors.black, colors.black, colors.lightGray)
  685. changePasswordPage:add("Y", function() addToPasswordInput("y") end, 15, 15, 15, 15, colors.black, colors.black, colors.lightGray)
  686. changePasswordPage:add("U", function() addToPasswordInput("u") end, 17, 17, 15, 15, colors.black, colors.black, colors.lightGray)
  687. changePasswordPage:add("I", function() addToPasswordInput("i") end, 19, 19, 15, 15, colors.black, colors.black, colors.lightGray)
  688. changePasswordPage:add("O", function() addToPasswordInput("o") end, 21, 21, 15, 15, colors.black, colors.black, colors.lightGray)
  689. changePasswordPage:add("P", function() addToPasswordInput("p") end, 23, 23, 15, 15, colors.black, colors.black, colors.lightGray)
  690.  
  691. changePasswordPage:add("A", function() addToPasswordInput("a") end, 6, 6, 16, 16, colors.black, colors.black, colors.lightGray)
  692. changePasswordPage:add("S", function() addToPasswordInput("s") end, 8, 8, 16, 16, colors.black, colors.black, colors.lightGray)
  693. changePasswordPage:add("D", function() addToPasswordInput("d") end, 10, 10, 16, 16, colors.black, colors.black, colors.lightGray)
  694. changePasswordPage:add("F", function() addToPasswordInput("f") end, 12, 12, 16, 16, colors.black, colors.black, colors.lightGray)
  695. changePasswordPage:add("G", function() addToPasswordInput("g") end, 14, 14, 16, 16, colors.black, colors.black, colors.lightGray)
  696. changePasswordPage:add("H", function() addToPasswordInput("h") end, 16, 16, 16, 16, colors.black, colors.black, colors.lightGray)
  697. changePasswordPage:add("J", function() addToPasswordInput("j") end, 18, 18, 16, 16, colors.black, colors.black, colors.lightGray)
  698. changePasswordPage:add("K", function() addToPasswordInput("k") end, 20, 20, 16, 16, colors.black, colors.black, colors.lightGray)
  699. changePasswordPage:add("L", function() addToPasswordInput("l") end, 22, 22, 16, 16, colors.black, colors.black, colors.lightGray)
  700.  
  701. changePasswordPage:add("Z", function() addToPasswordInput("z") end, 7, 7, 17, 17, colors.black, colors.black, colors.lightGray)
  702. changePasswordPage:add("X", function() addToPasswordInput("x") end, 9, 9, 17, 17, colors.black, colors.black, colors.lightGray)
  703. changePasswordPage:add("C", function() addToPasswordInput("c") end, 11, 11, 17, 17, colors.black, colors.black, colors.lightGray)
  704. changePasswordPage:add("V", function() addToPasswordInput("v") end, 13, 13, 17, 17, colors.black, colors.black, colors.lightGray)
  705. changePasswordPage:add("B", function() addToPasswordInput("b") end, 15, 15, 17, 17, colors.black, colors.black, colors.lightGray)
  706. changePasswordPage:add("N", function() addToPasswordInput("n") end, 17, 17, 17, 17, colors.black, colors.black, colors.lightGray)
  707. changePasswordPage:add("M", function() addToPasswordInput("m") end, 19, 19, 17, 17, colors.black, colors.black, colors.lightGray)
  708.  
  709. changePasswordPage:add("Shift",function() doPasswordShift() end, 29, 35, 15, 15, colors.cyan, colors.green, colors.white)
  710. changePasswordPage:add("Backspace", function() doPasswordBackspace() end, 26, 39, 17, 17, colors.black, colors.black, colors.cyan)
  711. changePasswordPage:add("Space", function() addToPasswordInput(" ") end, 29, 35, 16, 16, colors.black, colors.black, colors.cyan)
  712.  
  713. end
  714.  
  715. function goBackAccessPage()
  716. accountPage = nil
  717. accountPageNotDrawn = true
  718. accountPage = touchpointEdited.new(monitorSide)
  719. t = accountPage
  720. end
  721.  
  722. function confirmNewPassword(Key)
  723. if (Key == "firstEntry") then
  724.  
  725. print("Changing "..currentUser.name.."'s password to: "..input)
  726. currentUser.password = input
  727. persistence.store(fileName, profileArray)
  728.  
  729. newPasswordTable = {
  730. "Your current password is: "..currentUser.password,
  731. label = "changePasswordPageCurrentPasswordLabel",
  732. }
  733. changePasswordPage:rename("changePasswordPageCurrentPasswordLabel", newPasswordTable)
  734.  
  735. for i = 0, 16 do doPasswordBackspace() end
  736.  
  737. elseif (Key == "confrimEntry") then
  738. print("confirming entry")
  739. end
  740. end
  741.  
  742. function doPasswordShift()
  743. changePasswordPage:toggleButton("Shift")
  744. if (changePasswordPage.buttonList["Shift"].active) then useUppercase = true else useUppercase = false end
  745. end
  746.  
  747. function doPasswordBackspace()
  748. input = input:sub(0, #input-1)
  749. updateChangePasswordOutput(input)
  750. end
  751.  
  752. function updateChangePasswordOutput(input)
  753. input2 = string.rep("*", #input)
  754.  
  755. if (#input < 16) then
  756. input = (input..(string.rep(" ",(16-#input))))
  757. end
  758.  
  759. newInput = {input2, label = "newPasswordInputLabel"}
  760. changePasswordPage:rename("newPasswordInputLabel", newInput, true)
  761. end
  762.  
  763. function addToPasswordInput(char)
  764. if useUppercase then char = char:upper() end
  765. if (#input >= 16) then
  766. input = input:sub(0,16)
  767. else
  768. input = (input..char)
  769. end
  770.  
  771. updateChangePasswordOutput(input)
  772. end
  773.  
  774. --************************************************END OF CHANGE PASSWORD PAGE*************************************************************
  775.  
  776. --***********************************************START OF ADD USER PAGE****************************************************************
  777.  
  778. function addAddUserPage()
  779. local addUserTable1 = {
  780. "1",
  781. label = "addUserLabel1",
  782. }
  783.  
  784. local addUserTable2 = {
  785. "2",
  786. label = "addUserLabel2",
  787. }
  788.  
  789. local addUserTable3 = {
  790. "3",
  791. label = "addUserLabel3",
  792. }
  793.  
  794. local addUserInfoTable = {
  795. "Note: The password will",
  796. " default to 'password' ",
  797. label = "addUserInfoLabel",
  798. }
  799.  
  800. local additionalArrowTable = {
  801. "-->",
  802. label = "additionalArrowLabel",
  803. }
  804.  
  805. local addUserCreateProfileTable = {
  806. "Create",
  807. "Profile",
  808. label = "addUserCreateProfileLabel",
  809. }
  810.  
  811. newUserInputTable = {
  812. " ",
  813. label = "newUserInputLabel",
  814. }
  815.  
  816. useUppercase = false
  817. input = ""
  818. tempNewUserAccess = nil
  819.  
  820. changeAddUserPage:add("Add New User", nil, 5, 35, 2, 2, colors.black, colors.black, colors.brown)
  821. changeAddUserPage:add(addUserInfoTable, nil, 9,22, 4,5, colors.black, colors.black, colors.brown)
  822. changeAddUserPage:add(goBack, goBackAccessPage, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  823.  
  824. changeAddUserPage:add("Enter the desired username:", nil, 3, 33, 10, 10, colors.black, colors.black, colors.lightGray)
  825. changeAddUserPage:add(ArrowTable, nil, 1, 4, 11,11, colors.black, colors.black, colors.brown)
  826. changeAddUserPage:add(newUserInputTable, nil, 5, 22, 11, 11, colors.black, colors.black, colors.lightGray)
  827. changeAddUserPage:add(addUserCreateProfileTable, function() checkValidNewUser() end, 29, 39, 11, 12, colors.black, colors.black, colors.cyan)
  828.  
  829. changeAddUserPage:add("Choose the access level:", nil, 1,33, 7, 7, colors.black, colors.black, colors.lightGray)
  830. changeAddUserPage:add(additionalArrowTable, nil, 1,4, 8, 8, colors.black, colors.black, colors.brown)
  831. changeAddUserPage:add(addUserTable1, function() getNewUserAccessLevel(1) end, 5,5, 8,8, colors.black, colors.black, colors.cyan, colors.green)
  832. changeAddUserPage:add("(highest)", nil, 6,16, 8,8, colors.black, colors.black, colors.brown)
  833. changeAddUserPage:add(addUserTable2, function() getNewUserAccessLevel(2) end, 19,19, 8,8, colors.black, colors.black, colors.cyan, colors.green)
  834. changeAddUserPage:add(addUserTable3, function() getNewUserAccessLevel(3) end, 25,25, 8,8, colors.black, colors.black, colors.cyan, colors.green)
  835. changeAddUserPage:add("(lowest)", nil, 26,35, 8,8, colors.black, colors.black, colors.brown)
  836.  
  837. changeAddUserPage:add("1", function() addToAddUserInput("1") end, 5, 5, 14, 14, colors.black, colors.black, colors.lightGray)
  838. changeAddUserPage:add("2", function() addToAddUserInput("2") end, 7, 7, 14, 14, colors.black, colors.black, colors.lightGray)
  839. changeAddUserPage:add("3", function() addToAddUserInput("3") end, 9, 9, 14, 14, colors.black, colors.black, colors.lightGray)
  840. changeAddUserPage:add("4", function() addToAddUserInput("4") end, 11, 11, 14, 14, colors.black, colors.black, colors.lightGray)
  841. changeAddUserPage:add("5", function() addToAddUserInput("5") end, 13, 13, 14, 14, colors.black, colors.black, colors.lightGray)
  842. changeAddUserPage:add("6", function() addToAddUserInput("6") end, 15, 15, 14, 14, colors.black, colors.black, colors.lightGray)
  843. changeAddUserPage:add("7", function() addToAddUserInput("7") end, 17, 17, 14, 14, colors.black, colors.black, colors.lightGray)
  844. changeAddUserPage:add("8", function() addToAddUserInput("8") end, 19, 19, 14, 14, colors.black, colors.black, colors.lightGray)
  845. changeAddUserPage:add("9", function() addToAddUserInput("9") end, 21, 21, 14, 14, colors.black, colors.black, colors.lightGray)
  846. changeAddUserPage:add("0", function() addToAddUserInput("0") end, 23, 23, 14, 14, colors.black, colors.black, colors.lightGray)
  847.  
  848. changeAddUserPage:add("Q", function() addToAddUserInput("q") end, 5, 5, 15, 15, colors.black, colors.black, colors.lightGray)
  849. changeAddUserPage:add("W", function() addToAddUserInput("w") end, 7, 7, 15, 15, colors.black, colors.black, colors.lightGray)
  850. changeAddUserPage:add("E", function() addToAddUserInput("e") end, 9, 9, 15, 15, colors.black, colors.black, colors.lightGray)
  851. changeAddUserPage:add("R", function() addToAddUserInput("r") end, 11, 11, 15, 15, colors.black, colors.black, colors.lightGray)
  852. changeAddUserPage:add("T", function() addToAddUserInput("t") end, 13, 13, 15, 15, colors.black, colors.black, colors.lightGray)
  853. changeAddUserPage:add("Y", function() addToAddUserInput("y") end, 15, 15, 15, 15, colors.black, colors.black, colors.lightGray)
  854. changeAddUserPage:add("U", function() addToAddUserInput("u") end, 17, 17, 15, 15, colors.black, colors.black, colors.lightGray)
  855. changeAddUserPage:add("I", function() addToAddUserInput("i") end, 19, 19, 15, 15, colors.black, colors.black, colors.lightGray)
  856. changeAddUserPage:add("O", function() addToAddUserInput("o") end, 21, 21, 15, 15, colors.black, colors.black, colors.lightGray)
  857. changeAddUserPage:add("P", function() addToAddUserInput("p") end, 23, 23, 15, 15, colors.black, colors.black, colors.lightGray)
  858.  
  859. changeAddUserPage:add("A", function() addToAddUserInput("a") end, 6, 6, 16, 16, colors.black, colors.black, colors.lightGray)
  860. changeAddUserPage:add("S", function() addToAddUserInput("s") end, 8, 8, 16, 16, colors.black, colors.black, colors.lightGray)
  861. changeAddUserPage:add("D", function() addToAddUserInput("d") end, 10, 10, 16, 16, colors.black, colors.black, colors.lightGray)
  862. changeAddUserPage:add("F", function() addToAddUserInput("f") end, 12, 12, 16, 16, colors.black, colors.black, colors.lightGray)
  863. changeAddUserPage:add("G", function() addToAddUserInput("g") end, 14, 14, 16, 16, colors.black, colors.black, colors.lightGray)
  864. changeAddUserPage:add("H", function() addToAddUserInput("h") end, 16, 16, 16, 16, colors.black, colors.black, colors.lightGray)
  865. changeAddUserPage:add("J", function() addToAddUserInput("j") end, 18, 18, 16, 16, colors.black, colors.black, colors.lightGray)
  866. changeAddUserPage:add("K", function() addToAddUserInput("k") end, 20, 20, 16, 16, colors.black, colors.black, colors.lightGray)
  867. changeAddUserPage:add("L", function() addToAddUserInput("l") end, 22, 22, 16, 16, colors.black, colors.black, colors.lightGray)
  868.  
  869. changeAddUserPage:add("Z", function() addToAddUserInput("z") end, 7, 7, 17, 17, colors.black, colors.black, colors.lightGray)
  870. changeAddUserPage:add("X", function() addToAddUserInput("x") end, 9, 9, 17, 17, colors.black, colors.black, colors.lightGray)
  871. changeAddUserPage:add("C", function() addToAddUserInput("c") end, 11, 11, 17, 17, colors.black, colors.black, colors.lightGray)
  872. changeAddUserPage:add("V", function() addToAddUserInput("v") end, 13, 13, 17, 17, colors.black, colors.black, colors.lightGray)
  873. changeAddUserPage:add("B", function() addToAddUserInput("b") end, 15, 15, 17, 17, colors.black, colors.black, colors.lightGray)
  874. changeAddUserPage:add("N", function() addToAddUserInput("n") end, 17, 17, 17, 17, colors.black, colors.black, colors.lightGray)
  875. changeAddUserPage:add("M", function() addToAddUserInput("m") end, 19, 19, 17, 17, colors.black, colors.black, colors.lightGray)
  876.  
  877. changeAddUserPage:add("Shift",function() doAddUserShift() end, 29, 35, 15, 15, colors.cyan, colors.green, colors.white)
  878. changeAddUserPage:add("Backspace", function() doAddUserBackspace() end, 26, 39, 17, 17, colors.black, colors.black, colors.cyan)
  879. changeAddUserPage:add("Space", function() addToAddUserInput(" ") end, 29, 35, 16, 16, colors.black, colors.black, colors.cyan)
  880.  
  881. end
  882.  
  883.  
  884. function addToAddUserInput(char)
  885. if useUppercase then char = char:upper() end
  886. if (#input >= 16) then
  887. input = input:sub(0,16)
  888. else
  889. input = (input..char)
  890. end
  891. updateAddUserOutput(input)
  892. end
  893.  
  894. function getNewUserAccessLevel(num)
  895. if (num == 1) then
  896. changeAddUserPage:toggleButton("addUserLabel1")
  897. if changeAddUserPage.buttonList["addUserLabel1"].active then
  898. tempNewUserAccess = num
  899. end
  900. if changeAddUserPage.buttonList["addUserLabel2"].active then changeAddUserPage:toggleButton("addUserLabel2") end
  901. if changeAddUserPage.buttonList["addUserLabel3"].active then changeAddUserPage:toggleButton("addUserLabel3") end
  902. elseif (num == 2) then
  903. changeAddUserPage:toggleButton("addUserLabel2")
  904. if changeAddUserPage.buttonList["addUserLabel2"].active then
  905. tempNewUserAccess = num
  906. end
  907. if changeAddUserPage.buttonList["addUserLabel1"].active then changeAddUserPage:toggleButton("addUserLabel1") end
  908. if changeAddUserPage.buttonList["addUserLabel3"].active then changeAddUserPage:toggleButton("addUserLabel3") end
  909. elseif (num == 3) then
  910. changeAddUserPage:toggleButton("addUserLabel3")
  911. if changeAddUserPage.buttonList["addUserLabel3"].active then
  912. tempNewUserAccess = num
  913. end
  914. if changeAddUserPage.buttonList["addUserLabel2"].active then changeAddUserPage:toggleButton("addUserLabel2") end
  915. if changeAddUserPage.buttonList["addUserLabel1"].active then changeAddUserPage:toggleButton("addUserLabel1") end
  916. end
  917. end
  918.  
  919. function doAddUserShift()
  920. changeAddUserPage:toggleButton("Shift")
  921. if (changeAddUserPage.buttonList["Shift"].active) then useUppercase = true else useUppercase = false end
  922. end
  923.  
  924. function doAddUserBackspace()
  925. input = input:sub(0, #input-1)
  926. updateAddUserOutput(input)
  927. end
  928.  
  929. function updateAddUserOutput(input)
  930. if (#input < 16) then
  931. input = (input..(string.rep(" ",(16-#input))))
  932. end
  933.  
  934. newInput = {input, label = "newUserInputLabel"}
  935. changeAddUserPage:rename("newUserInputLabel", newInput, true)
  936. end
  937.  
  938. function checkValidNewUser()
  939. if (tempNewUserAccess ~= nil) and (input ~= "") then
  940. profileArray[#profileArray+1] = (Profile.create(input, "password", tempNewUserAccess))
  941. persistence.store(fileName, profileArray)
  942. for i = 0, 16 do doAddUserBackspace() end
  943. if changeAddUserPage.buttonList["addUserLabel1"].active then changeAddUserPage:toggleButton("addUserLabel1") end
  944. if changeAddUserPage.buttonList["addUserLabel2"].active then changeAddUserPage:toggleButton("addUserLabel2") end
  945. if changeAddUserPage.buttonList["addUserLabel3"].active then changeAddUserPage:toggleButton("addUserLabel3") end
  946. goBackAccessPage()
  947. useUppercase = false
  948. input = ""
  949. tempNewUserAccess = nil
  950. end
  951. end
  952.  
  953.  
  954.  
  955. --***********************************************END OF ADD USER PAGE********************************************************************
  956.  
  957. --***********************************************START OF REMOVE USER PAGE****************************************************************
  958.  
  959. function addRemoveUserPage()
  960. local RemoveUsertitleTable = {
  961. "Name: Access Level:",
  962. label = "RemoveUsertitleLabel",
  963. }
  964.  
  965. changeRemoveUserPage:add(goBack, goBackAccessPage3, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  966. changeRemoveUserPage:add("Remove Users", nil, 10,30, 2,2, colors.black, colors.black, colors.brown)
  967. changeRemoveUserPage:add(RemoveUsertitleTable, nil, 8,30, 5,5, colors.black, colors.black, colors.brown)
  968. yposAccess = 7
  969. tableYPOSspot = 1
  970. for key, value in ipairs(profileArray) do
  971.  
  972. local accessValueTable = {
  973. value.access,
  974. label = tostring(yposAccess),
  975. }
  976.  
  977. local removeTable = {
  978. "Remove",
  979. label = tostring(yposAccess).."remove",
  980. }
  981.  
  982. changeRemoveUserPage:add(value.name, nil, 3,19, yposAccess,yposAccess, colors.black, colors.black, colors.lightGray)
  983. changeRemoveUserPage:add(accessValueTable, nil, 25,26, yposAccess,yposAccess, colors.black, colors.black, colors.lightGray)
  984. -- changeRemoveUserPage:add(removeTable, function() removeUsers(key) end, 30,30, yposAccess,yposAccess, colors.black, colors.black, colors.red)
  985. changeRemoveUserPage:add(removeTable, function() removeUsers(key) end, 30,35, yposAccess,yposAccess, colors.black, colors.black, colors.red)
  986.  
  987. yposAccess = yposAccess + 2
  988. end
  989. end
  990.  
  991. function goBackAccessPage3()
  992. changeRemoveUserPage = nil
  993. changeRemoveUserPageNotDrawn = true
  994. changeRemoveUserPage = touchpointEdited.new(monitorSide)
  995. accountPage = nil
  996. accountPageNotDrawn = true
  997. accountPage = touchpointEdited.new(monitorSide)
  998. t = accountPage
  999. end
  1000.  
  1001. function testPrint()
  1002. print("Testing debug")
  1003. end
  1004.  
  1005. function removeUsers(aPos)
  1006. print("Removing "..profileArray[aPos].name)
  1007. -- profileArray[aPos] = nil
  1008. table.remove(profileArray, aPos)
  1009.  
  1010. persistence.store(fileName, profileArray)
  1011. changeRemoveUserPage = nil
  1012. changeRemoveUserPageNotDrawn = true
  1013. changeRemoveUserPage = touchpointEdited.new(monitorSide)
  1014. t = changeRemoveUserPage
  1015. end
  1016.  
  1017.  
  1018.  
  1019.  
  1020. --***********************************************END OF REMOVE USER PAGE********************************************************************
  1021.  
  1022. --***********************************************START OF CHANGE ACCESS PERMISSIONS*******************************************************
  1023.  
  1024. function addAccessPermissionsPage()
  1025. local AccesstitleTable = {
  1026. "Name: Access Level:",
  1027. label = "AccesstitleLabel",
  1028. }
  1029.  
  1030. changeAccessPage:add(goBack, goBackAccessPage2, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  1031. changeAccessPage:add("Access Permissions", nil, 10,30, 2,2, colors.black, colors.black, colors.brown)
  1032. changeAccessPage:add(AccesstitleTable, nil, 8,30, 5,5, colors.black, colors.black, colors.brown)
  1033. yposAccess = 7
  1034. tableYPOSspot = 1
  1035. for key, value in ipairs(profileArray) do
  1036. local accessValueTable = {
  1037. value.access,
  1038. label = tostring(yposAccess),
  1039. }
  1040. local minusTable = {
  1041. "-",
  1042. label = tostring(yposAccess).."-",
  1043. }
  1044. local plusTable = {
  1045. "+",
  1046. label = tostring(yposAccess).."+",
  1047. }
  1048. changeAccessPage:add(value.name, nil, 3,19, yposAccess,yposAccess, colors.black, colors.black, colors.lightGray)
  1049. changeAccessPage:add(accessValueTable, nil, 25,26, yposAccess,yposAccess, colors.black, colors.black, colors.lightGray)
  1050. if value.access > 1 then changeAccessPage:add(minusTable, function() accessChange("minus", key) end, 30,30, yposAccess,yposAccess, colors.black, colors.black, colors.cyan) end
  1051. if value.access < 3 then changeAccessPage:add(plusTable, function() accessChange("plus", key) end, 32,32, yposAccess,yposAccess, colors.black, colors.black, colors.cyan) end
  1052.  
  1053. yposAccess = yposAccess + 2
  1054. end
  1055. end
  1056.  
  1057. function goBackAccessPage2()
  1058. changeAccessPage = nil
  1059. changeAccessPageNotDrawn = true
  1060. changeAccessPage = touchpointEdited.new(monitorSide)
  1061. accountPage = nil
  1062. accountPageNotDrawn = true
  1063. accountPage = touchpointEdited.new(monitorSide)
  1064. t = accountPage
  1065. end
  1066.  
  1067. function accessChange(str, aPos)
  1068. if str == "plus" then
  1069. profileArray[aPos].access = profileArray[aPos].access + 1
  1070. elseif str == "minus" then
  1071. profileArray[aPos].access = profileArray[aPos].access - 1
  1072. end
  1073. persistence.store(fileName, profileArray)
  1074. changeAccessPage = nil
  1075. changeAccessPageNotDrawn = true
  1076. changeAccessPage = touchpointEdited.new(monitorSide)
  1077. t = changeAccessPage
  1078. end
  1079.  
  1080. --***********************************************END OF CHANGE ACCESS PERMISSIONS*********************************************************
  1081. ---**********************************************************MAIN***************************************************************************
  1082. function checkPages()
  1083. if (currentUser ~= nil) then
  1084. if (t == mainPage) and (mainPageNotDrawn) then
  1085. print("initializing main page for "..currentUser.name)
  1086. addmainPage()
  1087. mainPageNotDrawn = false
  1088. elseif (t == accountPage) and (accountPageNotDrawn) then
  1089. print("initializing account page for "..currentUser.name)
  1090. addAccountPage()
  1091. accountPageNotDrawn = false
  1092. elseif(t == accountPage) and (not accountPageNotDrawn) then
  1093. local AnewPasswordTable = {
  1094. "Password: "..currentUser.password,
  1095. label = "accountPagePasswordLabel"
  1096. }
  1097. accountPage:rename("accountPagePasswordLabel", AnewPasswordTable)
  1098. local newAccessTable = {
  1099. "Access Level: "..currentUser.access,
  1100. label = "accountPageAccessLabel",
  1101. }
  1102. accountPage:rename("accountPageAccessLabel", newAccessTable)
  1103. elseif (t == changePasswordPage) and (changePasswordPageNotDrawn) then
  1104. print("initializing changePasswordPage for "..currentUser.name)
  1105. addChangePasswordPage()
  1106. changePasswordPageNotDrawn = false
  1107. elseif (t == changePasswordPage) and (not changePasswordPageNotDrawn) then
  1108. local newPasswordTable = {
  1109. "Your current password is: "..currentUser.password,
  1110. label = "changePasswordPageCurrentPasswordLabel",
  1111. }
  1112. changePasswordPage:rename("changePasswordPageCurrentPasswordLabel", newPasswordTable)
  1113. elseif (t==changeAccessPage) and (changeAccessPageNotDrawn) then
  1114. print("initializing changeAccessPage for "..currentUser.name)
  1115. addAccessPermissionsPage()
  1116. changeAccessPageNotDrawn = false
  1117. elseif (t==changeAddUserPage) and (changeAddUserPageNotDrawn) then
  1118. print("initializing AddUserPage for "..currentUser.name)
  1119. addAddUserPage()
  1120. changeAddUserPageNotDrawn = false
  1121. elseif (t==changeRemoveUserPage) and (changeRemoveUserPageNotDrawn) then
  1122. print("initializing RemoveUserPage for "..currentUser.name)
  1123. addRemoveUserPage()
  1124. changeRemoveUserPageNotDrawn = false
  1125. end
  1126. end
  1127. end
  1128.  
  1129. function callButton(name)
  1130. if t.buttonList[name].func ~= nil then
  1131. t.buttonList[name].func()
  1132. end
  1133. end
  1134.  
  1135. mainPageNotDrawn = true
  1136. accountPageNotDrawn = true
  1137. changePasswordPageNotDrawn = true
  1138. changeAccessPageNotDrawn = true
  1139. changeAddUserPageNotDrawn = true
  1140. changeRemoveUserPageNotDrawn = true
  1141. mystcraftPageNotDrawn = true
  1142. aePageNotDrawn = true
  1143. powerPageNotDrawn = true
  1144.  
  1145. -- t = mainPage
  1146. -- currentUser = profileArray[4]
  1147.  
  1148. t = loginPage
  1149.  
  1150.  
  1151. -- for i=1,#profileArray do
  1152. -- print(profileArray[i].name) --array(profile)
  1153. -- end
  1154.  
  1155. -- for key,value in ipairs(profileArray) do
  1156. -- print(key) --number
  1157. -- print(value.name) --array(profile)
  1158. -- end
  1159.  
  1160. while true do
  1161. checkPages()
  1162. t:draw()
  1163. local event = {t:handleEvents(os.pullEvent())}
  1164. if event[1] == "button_click" then
  1165. callButton(event[2])
  1166. end
  1167. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement