Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- MCNet Mail UI
- Console screen
- ]]--
- ui = ui or {}
- local ConsoleScreen = common.newClass({
- background = colours.black,
- horizontal = false,
- _name = "console"
- }, ccgui.Page)
- ui.ConsoleScreen = ConsoleScreen
- function ConsoleScreen:init()
- ccgui.Page.init(self)
- -- Header
- self.header = ccgui.FlowContainer:new{
- horizontal = true,
- _name = "console.header"
- }
- self.headerTitle = ccgui.TextElement:new{
- align = ccgui.Align.Center,
- stretch = true,
- foreground = colours.white,
- background = colours.blue,
- _name = "console.headerTitle"
- }
- self.btnQuit = ccgui.Button:new{
- text = "X",
- align = ccgui.Align.Right,
- padding = ccgui.newMargins(0),
- _name = "console.btnQuit"
- }
- self.btnQuit:on("buttonpress", function()
- self:trigger("quit")
- end)
- self.header:add(self.headerTitle, self.btnQuit)
- -- Console
- self.console = ccgui.TextElement:new{
- valign = ccgui.VAlign.Bottom,
- foreground = colours.white,
- background = colours.black,
- padding = ccgui.newMargins(1),
- stretch = true,
- _name = "console.console"
- }
- self:add(self.header, self.console)
- self:setTitle(self.title)
- end
- function ConsoleScreen:setTitle(title)
- assert(type(title) == "string", "invalid title")
- self.headerTitle:setText(self.title)
- end
- function ConsoleScreen:write(...)
- local newText = self.console.text
- for i,text in ipairs({...}) do
- newText = newText..tostring(text)
- end
- self.console:setText(newText)
- end
- function ConsoleScreen:print(...)
- self:write(...)
- self:write("\n")
- end
Advertisement
Add Comment
Please, Sign In to add comment