--include "process.lua" local milSecs=1000--seconds to milliseconds local minSecs=60--seconds to minutes do menu=process() menu.items={} menu.backs={} menu.x=1 menu.curBack=1 menu.prevBackTime=millis() menu.backSecs=5 function menu:drawBackground(gc) if self.backs[self.curBack]~=nil then gc:drawImage(self.backs[self.curBack], -1,0) end end function menu:arrowKey(key) if key=="up" then if self.x>1 then self.x=self.x-1 else self.x=#self.items end elseif key=="down" then if self.x<#self.items then self.x=self.x+1 else self.x=1 end end disp:invalidate() end function menu:add(name, item) self.items[#self.items+1]={n=name, i=item, id=#self.items+1} end function menu:paint(gc) self:drawBackground(gc) for _, item in pairs(self.items) do gc:setColorRGB(0x000000) centerText(gc, item.n, dispX/2, dispY/2-gc:getStringHeight(item.n)*(#self.items-item.id-1)*2/3) if item.id==self.x then gc:drawRect(dispX/2-gc:getStringWidth(item.n)/2, dispY/2-gc:getStringHeight(item.n)*(#self.items-item.id-1/2)*2/3, gc:getStringWidth(item.n), gc:getStringHeight(item.n)*2/3) end end gc:setFont("sansserif", "r", 18) if self.title~=nil then if self.titleColor~=nil then gc:setColorRGB(self.titleColor) end centerText(gc, self.title, dispX/2, gc:getStringHeight(self.title)/2, "top") end end function menu:setBackSecs(secs) self.backSecs=secs end function menu:timer() if millis()-self.prevBackTime>self.backSecs*1000 then if self.curBack<#self.backs then self.curBack=self.curBack+1 else self.curBack=1 end self.prevBackTime=millis() end disp:invalidate() end function menu:addBackground(img) self.backs[#self.backs+1]=img:copy(dispX+1, dispY) end function menu:activate() self:setDefaults() end function menu:Open() self:setDefaults() end function menu:Close() self:deactivate() end function menu:enterKey() self:deactivate() PushProcess(self.items[self.x].i) disp:invalidate() end function menu:mouseDown(x, y) self:deactivate() PushProcess(self.items[self.x].i) disp:invalidate() end function menu:setTitle(title, color) self.title=title self.titleColor=color end end do readme=process() readme.hlpInfo="" readme.dispHelp=D2Editor.newRichText() function readme:Open() --self:deactivate() --self.inputEnabled=true self.dispHelp:setVisible(false) self.dispHelp:setText(self.hlpInfo, 1) self.dispHelp:move(0, 0) self.dispHelp:setBorder(0) self.dispHelp:setReadOnly(true) self.dispHelp:resize(dispX, dispY) self.dispHelp:setVisible(true) end function readme:timer() self.dispHelp:setFocus(true) end function readme:Close() self.dispHelp:setFocus(false) self.dispHelp:setVisible(false) end function readme:escapeKey() PullProcess() end function readme:backspaceKey() PullProcess() end function readme:setText(text) self.hlpInfo=text end end --[[do hlpScreen=process() hlpScreen.hlpInfo="Going to be made" hlpScreen.dispHelp=D2Editor.newRichText() function hlpScreen:Open() --self:deactivate() --self.inputEnabled=true self.dispHelp:move(0,0) self.dispHelp:setBorder(0) self.dispHelp:setReadOnly(true) self.dispHelp:setText(self.hlpInfo) self.dispHelp:resize(318, 212) self.dispHelp:setVisible(true) end function hlpScreen:Close() self.dispHelp:setVisible(false) end function hlpScreen:escapeKey() PullProcess() end end do settings=process() function settings:escapeKey() PullProcess() end end function on.construction() --menu:setBackground(image.new(_R.IMG.background)) --game:setBackground(image.new(_R.IMG.background)) --menu:add("Play", game) --menu:add("Help Screen", hlpScreen) --menu:add("Settings", settings) PushProcess(menu) disp:invalidate() end function on.activate() timer.start(5) disp:invalidate() end function on.deactivate() timer.stop() end]]