Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --not tested, experimental
- --pastebin get XVV4t1dF startup
- --will display a clickable list of games
- os.loadAPI("txUI")
- --function to set to enable or disable ctrl-t
- --http://www.computercraft.info/forums2/index.php?/topic/2732-disable-ctrlt/
- local pullEventCopy = os.pullEvent
- function setCtrlT(value)
- if value then
- os.pullEvent = pullEventCopy
- else
- os.pullEvent = os.pullEventRaw
- end
- end
- function clear()
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.white)
- term.setBackgroundColor(colors.black)
- term.clear()
- end
- function about()
- clear()
- textutils.slowWrite("At the beginning of time Connor commissioned")
- print()
- textutils.slowWrite("theinsekt to make an arcade program.")
- print()
- sleep(1)
- textutils.slowWrite("After trying to make his own button api he soon gave up (lazy),")
- print()
- textutils.slowWrite("and instead used txUI (by tuogex).")
- print()
- sleep(1)
- textutils.slowWrite("He managed to make version 0.1 dev.")
- print()
- sleep(1)
- textutils.slowWrite("It was not great but it works as a proof of concept.")
- print()
- sleep(1)
- textutils.slowWrite("The End!")
- print()
- sleep(3)
- end
- function history2()
- clear()
- textutils.slowWrite("On the second day theinsekt fixed the flickering problem.")
- print()
- sleep(1)
- textutils.slowWrite("Like the genius he is he redirected the output to a non-visible window,")
- print()
- sleep(1)
- textutils.slowWrite("and after all the drawing was done he turned it visible and used window.redraw().")
- print()
- sleep(1)
- textutils.slowWrite("He truly is a worthy bearer of 'the red belt of destiny'.")
- print()
- sleep(1)
- textutils.slowWrite("Now he only need to add some games.")
- print()
- sleep(1)
- textutils.slowWrite("What man, what a man...")
- print()
- sleep(1)
- textutils.slowWrite("The End!")
- print()
- sleep(3)
- print("lol")
- print()
- sleep(1)
- end
- function getGames(debugLabel)
- local games={
- --{"debug close",function(self) error("Exited") end},
- --add a function to the games list
- {"History of arcade 0.1 dev",about},
- {"History of arcade 0.2 dev (fair and balanced)",history2},
- {"gamename1",function(self) debugLabel.text="gameName1" end},
- {"gamename2",function(self) debugLabel.text="gameName2" end},
- --add a program to the games list
- {"Hello World! - theinsekt",function(self) shell.run("helloworld") end},
- {"errorTest",function(self) error("errorTest") end},
- }
- return games
- end
- function arcade()
- --[[
- http://www.computercraft.info/forums2/index.php?/topic/19575-txui-elegant-gui-components-with-application-framework-capabilities/
- ]]
- local bg=colors.black
- local bg2=colors.black
- local te=colors.red
- local w, h = term.getSize()
- local windowA = txUI.Window:new({w = w; h = h; bgColor = bg; textColor = te;})
- txUI.UIManager:addWindow(windowA)
- txUI.UIManager:setVisibleWindow(windowA)
- windowA:setTitleLabel(txUI.Label:new({text = "Arcade 0.2 dev (powered by txUI)"; bgColor = bg2; textColor = te; w = windowA.w; x = windowA.x; textAlign = "center";}))
- --debug label under list
- local debugLabel=txUI.Label:new({text="debugLabel";x = 1; y = h; w = w; h = 1; bgColor = bg2; textColor = te;})
- windowA:addComponent(debugLabel)
- local games=getGames(debugLabel)
- --add label over list
- --windowA:addComponent(txUI.Label:new({text="Applications:";x = 1; y = 2; bgColor = bg; textColor = te;}))
- --make a click-able and scrollable list
- local list = txUI.List:new({x = 1; y = 2;h=h-2;w=w;bgColor = bg; textColor = te;bgColorStripe= bg;textColorStripe=te;scrollBarTextColor=te;})
- windowA:addComponent(list)
- for _, game in ipairs(games) do
- local gameName,startFunction=unpack(game)
- list:addComponent(txUI.Button:new({text = gameName; action = startFunction;bgColor = bg; textColor = te;}))
- end
- txUI.UIManager.appUpdate = function(self)
- --do nothing
- end
- print("starting UI...")
- sleep(1)
- txUI.UIManager:startUpdateCycle()
- end
- --start the arcade program
- --setCtrlT(false)
- while(true) do
- local ret, err=pcall(arcade)
- clear()
- if not ret then
- print(err)
- end
- print("Arcade is restarting...")
- sleep(4)
- end
- --setCtrlT(true)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement