diff --git a/src/css/templates/crafting_table.scss b/src/css/templates/crafting_table.scss index 56a5c76c6..8f7b676f2 100644 --- a/src/css/templates/crafting_table.scss +++ b/src/css/templates/crafting_table.scss @@ -27,9 +27,16 @@ All rights reserved. } } - .view__crafting_grid { + .input { position: absolute; top: 50%; left: 33%; @include transform(translate(-50%, -50%)); + + .tool { + position: absolute; right: 0; bottom: -2em; left: 0; height: 1.5em; + text-align: center; + + p { font-weight: bold; } + } } .next { diff --git a/src/scripts/controllers/crafting_table_controller.coffee b/src/scripts/controllers/crafting_table_controller.coffee index 3bc6d80de..4bdc97b33 100644 --- a/src/scripts/controllers/crafting_table_controller.coffee +++ b/src/scripts/controllers/crafting_table_controller.coffee @@ -32,6 +32,7 @@ module.exports = class CraftingTableController extends BaseController @$next = @$('.next') @$prev = @$('.prev') + @$tool = @$('.tool p') super refresh: -> @@ -42,6 +43,8 @@ module.exports = class CraftingTableController extends BaseController if @model.hasPrevStep then @$prev.addClass 'enabled' if @model.hasNextStep then @$next.addClass 'enabled' + @$tool.html @model.toolNames + super # Backbone.View Overrides ###################################################################### diff --git a/src/scripts/models/crafting_table.coffee b/src/scripts/models/crafting_table.coffee index efa1ea8cd..fb6e61c8a 100644 --- a/src/scripts/models/crafting_table.coffee +++ b/src/scripts/models/crafting_table.coffee @@ -15,6 +15,7 @@ module.exports = class CraftingTable extends BaseModel constructor: (attributes={}, options={})-> if not attributes.plan? then throw new Error "attributes.plan is required" attributes.grid ?= new CraftingGrid modPack:attributes.plan.modPack + attributes.modPack ?= attributes.plan.modPack super attributes, options @plan.on 'change', => @reset() @@ -26,6 +27,7 @@ module.exports = class CraftingTable extends BaseModel hasPrevStep: { get:@hasPrevStep } hasSteps: { get:@hasSteps } step: { get:@getStep, set:@setStep } + toolNames: { get:@getToolNames } } # Public Methods ############################################################################### @@ -48,7 +50,7 @@ module.exports = class CraftingTable extends BaseModel return @_step setStep: (newStep)-> - newStep = Math.max 0, Math.min @_steps.length, newStep + newStep = Math.max 0, Math.min @_steps.length - 1, newStep @_step = newStep @grid.recipe = @_steps[@_step]?.recipe @@ -59,6 +61,13 @@ module.exports = class CraftingTable extends BaseModel hasSteps: -> return @_steps.length > 0 + getToolNames: -> + recipe = @_steps[@_step]?.recipe + return '' unless recipe? + toolSlugs = (stack.itemSlug for stack in recipe.tools) + toolNames = (@modPack.findName(slug) for slug in toolSlugs).join ', ' + return toolNames + # Object Overrides ############################################################################# toString: -> diff --git a/src/templates/crafting_table.jade b/src/templates/crafting_table.jade index 9109beb24..5da6a719a 100644 --- a/src/templates/crafting_table.jade +++ b/src/templates/crafting_table.jade @@ -12,5 +12,7 @@ .panel .prev - table.view__crafting_grid + .input + table.view__crafting_grid + .tool: p .next