Add label showing tool names
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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 ######################################################################
|
||||
|
||||
@@ -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: ->
|
||||
|
||||
@@ -12,5 +12,7 @@
|
||||
|
||||
.panel
|
||||
.prev
|
||||
.input
|
||||
table.view__crafting_grid
|
||||
.tool: p
|
||||
.next
|
||||
|
||||
Reference in New Issue
Block a user