Module:UI

local slot = require( Module:Inventory slot ).slot local addSlot = function( args, item, prefix, class, default ) prefix = prefix or item return slot{ args[item], mod = args.Mod, link = args[prefix .. 'link'], title = args[prefix .. 'title'], class = class, default = default, parsed = args.parsed } end

local sugarSlot = require( Module:Sugar Inventory Slot ).slot local addSugarSlot = function( args, item, prefix, class, default ) prefix = prefix or item return sugarSlot{ args[item], mod = args.Mod, link = args[prefix .. 'link'], title = args[prefix .. 'title'], class = class, default = default, parsed = args.parsed } end

local p = {}

-- Crafting table function p.craftingTable( f ) local args = f	if f == mw.getCurrentFrame then args = f:getParent.args else f = mw.getCurrentFrame end local body = mw.html.create( 'span' ):addClass( 'mcui mcui-Crafting_Table' ) local input = body:tag( 'span' ):addClass( 'mcui-input' ) for num = 1, 3 do		local row = input:tag( 'span' ):addClass( 'mcui-row' ) for _, letter in ipairs{ 'A', 'B', 'C' } do row:wikitext( addSlot( args, letter .. num ) ) end end local arrow = body:tag( 'span' ):addClass( 'mcui-arrow sprite' ):tag( 'br' ):done if args.arrow or  ~=  then arrow:css(			'background-image',			''		) end body :tag( 'span' ) :addClass( 'mcui-output' ) :wikitext( addSlot( args, 'Output', 'O', 'invslot-large' ) ) local Shapeless = args.Shapeless or '' local Fixed = args.Fixed or '' if Shapeless ~=  or Fixed ~=  then local icon = body:tag( 'span' ) :addClass( 'mcui-icons' ) :tag( 'span' ) :tag( 'br' ) :done if Shapeless ~= '' then icon:addClass( 'mcui-shapeless sprite' ) :attr( 'title',					'This recipe is shapeless, the inputs may be placed in any arrangement in the crafting grid.'				) elseif Fixed ~= '' then local notFixed = args.notfixed or '' local exceptFixed = '' if notFixed ~= '' then exceptFixed = '; except for ' .. notFixed .. ', which can go anywhere' end icon:addClass( 'mcui-fixed sprite' ) :attr( 'title',					'This recipe is fixed, the input arrangement may not be moved or mirrored in the crafting grid' .. exceptFixed .. '.'				) end end return tostring( mw.html.create( 'div' ):node( body ) ) end

-- Inventory table function p.inventoryTable( f ) local args = f	if f == mw.getCurrentFrame then args = f:getParent.args else f = mw.getCurrentFrame end local body = mw.html.create( 'span' ):addClass( 'mcui mcui-Inventory_Table' ) local input = body:tag( 'span' ):addClass( 'mcui-input' ) for num = 1, 2 do		local row = input:tag( 'span' ):addClass( 'mcui-row' ) for _, letter in ipairs{ 'A', 'B' } do row:wikitext( addSlot( args, letter .. num ) ) end end local arrow = body:tag( 'span' ):addClass( 'mcui-arrow sprite' ):tag( 'br' ):done if args.arrow or  ~=  then arrow:css(			'background-image',			''		) end body :tag( 'span' ) :addClass( 'mcui-output' ) :wikitext( addSlot( args, 'Output', 'O' ) ) local Shapeless = args.Shapeless or '' local Fixed = args.Fixed or '' if Shapeless ~=  or Fixed ~=  then local icon = body:tag( 'span' ) :addClass( 'mcui-icons' ) :tag( 'span' ) :tag( 'br' ) :done if Shapeless ~= '' then icon:addClass( 'mcui-shapeless sprite' ) :attr( 'title',					'This recipe is shapeless, the inputs may be placed in any arrangement in the crafting grid.'				) elseif Fixed ~= '' then local notFixed = args.notfixed or '' local exceptFixed = '' if notFixed ~= '' then exceptFixed = '; except for ' .. notFixed .. ', which can go anywhere' end icon:addClass( 'mcui-fixed sprite' ) :attr( 'title',					'This recipe is fixed, the input arrangement may not be moved or mirrored in the crafting grid' .. exceptFixed .. '.'				) end end return tostring( mw.html.create( 'div' ):node( body ) ) end

-- Furnace function p.furnace( f ) local args = f	if f == mw.getCurrentFrame then args = f:getParent.args else f = mw.getCurrentFrame end local body = mw.html.create( 'span' ):addClass( 'mcui mcui-Furnace' ) local input = body:tag( 'span' ):addClass( 'mcui-input' ) input:wikitext( addSlot( args, 'Input', 'I' ) ) local fuel = input:tag( 'span' ):addClass( 'mcui-fuel sprite' ):tag( 'br' ):done local fuelImg = args.FuelUsage or '' local burning = args.Input or  ~=  and args.Fuel or  ~=  if not burning then fuel:addClass( 'mcui-inactive sprite' ) if fuelImg ~= '' then fuelImg = fuelImg .. ' (in-active)' end end if fuelImg ~= '' then fuel:css(			'background-image',			''		) end input:wikitext( addSlot( args, 'Fuel', 'F' ) ) local arrow = body:tag( 'span' ):addClass( 'mcui-arrow sprite' ):tag( 'br' ):done local arrowImg = args.Progress or '' if not burning or ( args.Output or  ) ==  then arrow:addClass( 'mcui-inactive sprite' ) if arrowImg ~= '' then arrowImg = arrowImg .. ' (in-active)' end end if arrowImg ~= '' then arrow:css(			'background-image',			''		) end body :tag( 'span' ) :addClass( 'mcui-output' ) :wikitext( addSlot( args, 'Output', 'O', 'invslot-large' ) ) return tostring( mw.html.create( 'div' ):node( body ) ) end

-- Sugar Furnace function p.sugarFurnace( f ) local args = f	if f == mw.getCurrentFrame then args = f:getParent.args else f = mw.getCurrentFrame end local body = mw.html.create( 'span' ):addClass( 'mcui-sugar-furnace mcui-Sugar_Furnace' ) local input = body:tag( 'span' ):addClass( 'mcui-input' ) input:wikitext( addSugarSlot( args, 'Input', 'I' ) ) local fuel = input:tag( 'span' ):addClass( 'mcui-fuel sprite' ):tag( 'br' ):done local fuelImg = args.FuelUsage or '' local burning = args.Input or  ~=  and args.Fuel or  ~=  if not burning then fuel:addClass( 'mcui-inactive sprite' ) if fuelImg ~= '' then fuelImg = fuelImg .. ' (in-active)' end end if fuelImg ~= '' then fuel:css(			'background-image',			''		) end input:wikitext( addSugarSlot( args, 'Fuel', 'F' ) ) local arrow = body:tag( 'span' ):addClass( 'mcui-arrow sprite' ):tag( 'br' ):done local arrowImg = args.Progress or '' if not burning or ( args.Output or  ) ==  then arrow:addClass( 'mcui-inactive sprite' ) if arrowImg ~= '' then arrowImg = arrowImg .. ' (in-active)' end end if arrowImg ~= '' then arrow:css(			'background-image',			''		) end body :tag( 'span' ) :addClass( 'mcui-output' ) :wikitext( addSugarSlot( args, 'Output', 'O', 'invslot-sugar-large' ) ) return tostring( mw.html.create( 'div' ):node( body ) ) end

-- Sugar Factory function p.sugarFactory( f ) local args = f	if f == mw.getCurrentFrame then args = f:getParent.args else f = mw.getCurrentFrame end local body = mw.html.create( 'span' ):addClass( 'mcui mcui-Sugar_Factory' ) local input = body:tag( 'span' ):addClass( 'mcui-input' ) input:wikitext( addSlot( args, 'Input', 'I' ) ) local swiggle = body:tag( 'span' ):addClass( 'mcui-swiggle sprite' ):tag( 'br' ):done if swiggleImg or  ~=  then swiggle:css(			'background-image',			''		) end body :tag( 'span' ) :addClass( 'mcui-output' ) :wikitext( addSlot( args, 'Output', 'O' ) ) return tostring( mw.html.create( 'div' ):node( body ) ) end

-- Advanced Sugar Factory function p.advancedSugarFactory( f ) local args = f	if f == mw.getCurrentFrame then args = f:getParent.args else f = mw.getCurrentFrame end local body = mw.html.create( 'span' ):addClass( 'mcui mcui-Advanced_Sugar_Factory' ) local input = body:tag( 'span' ):addClass( 'mcui-input' ) input:wikitext( addSlot( args, 'Input', 'I' ) ) local advancedswiggle = body:tag( 'span' ):addClass( 'mcui-advancedswiggle sprite' ):tag( 'br' ):done if advancedswiggleImg or  ~=  then advancedswiggle:css(			'background-image',			''		) end body :tag( 'span' ) :addClass( 'mcui-output' ) :wikitext( addSlot( args, 'Output', 'O' ) ) return tostring( mw.html.create( 'div' ):node( body ) ) end

-- Inventory table function p.grindstone( f ) local args = f	if f == mw.getCurrentFrame then args = f:getParent.args else f = mw.getCurrentFrame end local body = mw.html.create( 'span' ):addClass( 'mcui mcui-Grindstone' ) local input = body:tag( 'span' ):addClass( 'mcui-input' ) input:wikitext( addSlot( args, 'Input1', 'I1' ) ):tag( 'br' ) input:wikitext( addSlot( args, 'Input2', 'I2' ) )

local arrow = body:tag( 'span' ):addClass( 'mcui-arrow sprite' ):tag( 'br' ):done if args.arrow or  ~=  then arrow:css(			'background-image',			''		) end body :tag( 'span' ) :addClass( 'mcui-output' ) :wikitext( addSlot( args, 'Output', 'O' ) ) return tostring( mw.html.create( 'div' ):node( body ) ) end

return p