--[[ Constants * (all lua builtins that don't allow io/executing code) color (interface) gui (interface) multi (interface bound to a processor) no thread module callback true/false correct/wrong ]] local label local imageHolder local function index(window, q, callback) frame = window:newFrame(0,0,0,0,0,.2,1,.8) frame.visibility = 0 label = window:newTextLabel(" " ..q.title.. " ",0,0,0,0,0,0,1,.2) label.align = ALIGN_CENTER label.textColor = color.white label.color = color.new("#363ac8") label:scaleFont(.4) label:centerFont() label.drawBorder = false local errors = {} if type(q.zoom) ~= "string" and q.zoom ~= "" then table.insert(errors, "Missing 'zoom' fiels for queston! Should be a path to an image.") end if type(q.minzoom) ~= "string" and q.minzoom ~= "" then table.insert(errors, "Missing 'minzoom' field for question! Should be a path to an image.") end if type(q.fullimage) ~= "string" and q.fullimage ~= "" then table.insert(errors, "Missing 'fullimage' field for question! Should be a path to an image.") end local zooms = {q.zoom, q.minzoom, q.fullimage} local index = 1 local mul = 1 imageHolder = frame:newImageLabel(q.zoom) imageHolder:setAspectSize(imageHolder.imageWidth,imageHolder.imageHeight) imageHolder:centerX(true) imageHolder:centerY(true) imageHolder:setDualDim(0,0,imageHolder.imageWidth,imageHolder.imageHeight) imageHolder:OnEnter(function(self) self:setShader(gui.SHADERS.glow) end) imageHolder:OnExit(function(self) self:setShader() end) imageHolder:shaderTime(true) imageHolder:OnReleased(function() index = index + 1 if index == 2 then if q["zoom-deduct"] then mul = .5 end elseif index == 3 then if q["zoom-deduct"] then mul = .25 end else index = 3 end imageHolder:setImage(zooms[index]) setMultiplier(mul) end) useDefaultHandler(callback) end local function update(dt) -- time in seconds that has passed since _,_,w,h = imageHolder.parent:getAbsolutes() local x,y,w,h = imageHolder:GetSizeAdjustedToAspectRatio(w,h) imageHolder:setDualDim(w,h,x,y) end return { index = index, update = update }