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%;
|
position: absolute; top: 50%; left: 33%;
|
||||||
@include transform(translate(-50%, -50%));
|
@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 {
|
.next {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ module.exports = class CraftingTableController extends BaseController
|
|||||||
|
|
||||||
@$next = @$('.next')
|
@$next = @$('.next')
|
||||||
@$prev = @$('.prev')
|
@$prev = @$('.prev')
|
||||||
|
@$tool = @$('.tool p')
|
||||||
super
|
super
|
||||||
|
|
||||||
refresh: ->
|
refresh: ->
|
||||||
@@ -42,6 +43,8 @@ module.exports = class CraftingTableController extends BaseController
|
|||||||
if @model.hasPrevStep then @$prev.addClass 'enabled'
|
if @model.hasPrevStep then @$prev.addClass 'enabled'
|
||||||
if @model.hasNextStep then @$next.addClass 'enabled'
|
if @model.hasNextStep then @$next.addClass 'enabled'
|
||||||
|
|
||||||
|
@$tool.html @model.toolNames
|
||||||
|
|
||||||
super
|
super
|
||||||
|
|
||||||
# Backbone.View Overrides ######################################################################
|
# Backbone.View Overrides ######################################################################
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ module.exports = class CraftingTable extends BaseModel
|
|||||||
constructor: (attributes={}, options={})->
|
constructor: (attributes={}, options={})->
|
||||||
if not attributes.plan? then throw new Error "attributes.plan is required"
|
if not attributes.plan? then throw new Error "attributes.plan is required"
|
||||||
attributes.grid ?= new CraftingGrid modPack:attributes.plan.modPack
|
attributes.grid ?= new CraftingGrid modPack:attributes.plan.modPack
|
||||||
|
attributes.modPack ?= attributes.plan.modPack
|
||||||
super attributes, options
|
super attributes, options
|
||||||
|
|
||||||
@plan.on 'change', => @reset()
|
@plan.on 'change', => @reset()
|
||||||
@@ -26,6 +27,7 @@ module.exports = class CraftingTable extends BaseModel
|
|||||||
hasPrevStep: { get:@hasPrevStep }
|
hasPrevStep: { get:@hasPrevStep }
|
||||||
hasSteps: { get:@hasSteps }
|
hasSteps: { get:@hasSteps }
|
||||||
step: { get:@getStep, set:@setStep }
|
step: { get:@getStep, set:@setStep }
|
||||||
|
toolNames: { get:@getToolNames }
|
||||||
}
|
}
|
||||||
|
|
||||||
# Public Methods ###############################################################################
|
# Public Methods ###############################################################################
|
||||||
@@ -48,7 +50,7 @@ module.exports = class CraftingTable extends BaseModel
|
|||||||
return @_step
|
return @_step
|
||||||
|
|
||||||
setStep: (newStep)->
|
setStep: (newStep)->
|
||||||
newStep = Math.max 0, Math.min @_steps.length, newStep
|
newStep = Math.max 0, Math.min @_steps.length - 1, newStep
|
||||||
|
|
||||||
@_step = newStep
|
@_step = newStep
|
||||||
@grid.recipe = @_steps[@_step]?.recipe
|
@grid.recipe = @_steps[@_step]?.recipe
|
||||||
@@ -59,6 +61,13 @@ module.exports = class CraftingTable extends BaseModel
|
|||||||
hasSteps: ->
|
hasSteps: ->
|
||||||
return @_steps.length > 0
|
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 #############################################################################
|
# Object Overrides #############################################################################
|
||||||
|
|
||||||
toString: ->
|
toString: ->
|
||||||
|
|||||||
@@ -12,5 +12,7 @@
|
|||||||
|
|
||||||
.panel
|
.panel
|
||||||
.prev
|
.prev
|
||||||
table.view__crafting_grid
|
.input
|
||||||
|
table.view__crafting_grid
|
||||||
|
.tool: p
|
||||||
.next
|
.next
|
||||||
|
|||||||
Reference in New Issue
Block a user