Complete the Crafting Table view/controller

* Add output box to the crafting table view
* Add remaining crafting patterns to all MC 1.7.10 recipes
* Add all crafting patterns to Buildcraft 6.2.6
* Disable mods which don't have patterns yet
* Add the Url constants for computing urls from templates
* Add the `findItemDisplay` to ModPack (along with tests) and remove
  all replace all uses of `getPathSlugs` with it
This commit is contained in:
Andrew Miner
2015-01-09 10:08:02 -08:00
parent b8d60ac245
commit b8a0918541
19 changed files with 278 additions and 97 deletions
@@ -5,8 +5,9 @@ Copyright (c) 2014-2015 by Redwood Labs
All rights reserved.
###
BaseController = require './base_controller'
BaseController = require './base_controller'
CraftingGridController = require './crafting_grid_controller'
ImageLoader = require './image_loader'
########################################################################################################################
@@ -14,9 +15,14 @@ module.exports = class CraftingTableController extends BaseController
constructor: (options={})->
if not options.model? then throw new Error 'options.model is required'
if not options.modPack? then throw new Error 'options.modPack is required'
options.imageLoader ?= new ImageLoader default:'/images/unknown.png'
options.templateName = 'crafting_table'
super options
@imageLoader = options.imageLoader
@modPack = options.modPack
# Event Methods ################################################################################
onNextClicked: ->
@@ -30,9 +36,13 @@ module.exports = class CraftingTableController extends BaseController
onDidRender: ->
@gridController = @addChild CraftingGridController, '.view__crafting_grid', model:@model.grid
@$next = @$('.next')
@$prev = @$('.prev')
@$tool = @$('.tool p')
@$multiplier = @$('.multiplier')
@$next = @$('.next')
@$outputImg = @$('.output img')
@$outputLink = @$('.output a')
@$outputQuantity = @$('.quantity')
@$prev = @$('.prev')
@$tool = @$('.tool p')
super
refresh: ->
@@ -45,6 +55,25 @@ module.exports = class CraftingTableController extends BaseController
@$tool.html @model.toolNames
@$outputImg.attr 'src', '/images/empty.png'
@$outputImg.removeAttr 'alt'
@$outputLink.removeAttr 'href'
@$outputQuantity.html ''
outputStack = @model.output
if outputStack?
display = @modPack.findItemDisplay outputStack.itemSlug
@$outputLink.attr 'href', display.itemUrl
@$outputImg.attr 'alt', display.itemName
@$outputQuantity.html outputStack.quantity if outputStack.quantity > 1
@imageLoader.load display.iconUrl, @$outputImg
if @model.multiplier > 1
@$multiplier.html "×#{@model.multiplier}"
else
@$multiplier.html ''
super
# Backbone.View Overrides ######################################################################