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:
@@ -7,15 +7,11 @@ All rights reserved.
|
||||
|
||||
BaseController = require './base_controller'
|
||||
ImageLoader = require './image_loader'
|
||||
{ImageUrl} = require '../constants'
|
||||
util = require 'util'
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
module.exports = class CraftingGridController extends BaseController
|
||||
|
||||
@EMPTY_IMAGE = '/images/empty.png'
|
||||
|
||||
constructor: (options={})->
|
||||
if not options.model? then throw new Error 'options.model is required'
|
||||
options.imageLoader ?= new ImageLoader default:'/images/unknown.png'
|
||||
@@ -39,14 +35,14 @@ module.exports = class CraftingGridController extends BaseController
|
||||
|
||||
slot.a.addClass 'empty'
|
||||
slot.a.removeAttr 'href'
|
||||
slot.img.attr 'src', CraftingGridController.EMPTY_IMAGE
|
||||
slot.img.attr 'src', '/images/empty.png'
|
||||
slot.img.removeAttr 'alt'
|
||||
|
||||
itemData = @model.getItemDataAt index
|
||||
if itemData?
|
||||
display = @model.getItemDisplayAt index
|
||||
if display?
|
||||
slot.a.removeClass 'empty'
|
||||
slot.a.attr 'href', "/items/#{encodeURIComponent(itemData.name)}"
|
||||
logger.debug "item data: #{util.inspect(itemData)}"
|
||||
@_imageLoader.load ImageUrl(itemData), slot.img
|
||||
slot.img.attr 'alt', itemData.name
|
||||
slot.a.attr 'href', display.itemUrl
|
||||
@_imageLoader.load display.iconUrl, slot.img
|
||||
slot.img.attr 'alt', display.itemName
|
||||
|
||||
super
|
||||
|
||||
@@ -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 ######################################################################
|
||||
|
||||
@@ -36,32 +36,32 @@ module.exports = class ItemPageController extends BaseController
|
||||
# BaseController Overrides #####################################################################
|
||||
|
||||
onDidRender: ->
|
||||
options =
|
||||
@haveController = @addChild InventoryController, '.have',
|
||||
editable: true,
|
||||
imageLoader: @imageLoader
|
||||
model: @model.plan.have,
|
||||
modPack: @model.modPack,
|
||||
title: 'Items you have'
|
||||
@haveController = @addChild InventoryController, '.have', options
|
||||
|
||||
options =
|
||||
@wantController = @addChild InventoryController, '.want',
|
||||
editable: true
|
||||
icon: '/images/fishing_rod.png',
|
||||
imageLoader: @imageLoader
|
||||
model: @model.plan.want,
|
||||
modPack: @model.modPack,
|
||||
title: 'Items you want'
|
||||
@wantController = @addChild InventoryController, '.want', options
|
||||
|
||||
options =
|
||||
@needController = @addChild InventoryController, '.need',
|
||||
editable: false
|
||||
icon: '/images/boots.png',
|
||||
imageLoader: @imageLoader
|
||||
model: @model.plan.need,
|
||||
modPack: @model.modPack,
|
||||
title: "Items you'll need"
|
||||
@needController = @addChild InventoryController, '.need', options
|
||||
|
||||
@craftingTableController = @addChild CraftingTableController, '.view__crafting_table', model:@model.table
|
||||
@craftingTableController = @addChild CraftingTableController, '.view__crafting_table',
|
||||
model: @model.table
|
||||
modPack: @model.modPack
|
||||
|
||||
@modPackController = @addChild ModPackController, '.view__mod_pack', model:@model.modPack
|
||||
super
|
||||
|
||||
@@ -6,7 +6,6 @@ All rights reserved.
|
||||
###
|
||||
|
||||
BaseController = require './base_controller'
|
||||
{ImageUrl} = require '../constants'
|
||||
ImageLoader = require './image_loader'
|
||||
|
||||
########################################################################################################################
|
||||
@@ -32,24 +31,9 @@ module.exports = class StackController extends BaseController
|
||||
super
|
||||
|
||||
refresh: ->
|
||||
{itemName, itemSlug, modSlug} = @_gatherData()
|
||||
imageUrl = ImageUrl itemSlug:itemSlug, modSlug:modSlug
|
||||
display = @modPack.findItemDisplay @model.itemSlug
|
||||
|
||||
@$nameField.html itemName
|
||||
@$nameField.html display.itemName
|
||||
@$quantityField.html @model.quantity
|
||||
@_imageLoader.load imageUrl, @$image
|
||||
@_imageLoader.load display.iconUrl, @$image
|
||||
super
|
||||
|
||||
# Private Methods ##############################################################################
|
||||
|
||||
_gatherData: ->
|
||||
itemSlug = @model.itemSlug
|
||||
item = @modPack.findItem @model.itemSlug
|
||||
if item?
|
||||
itemName = item.name
|
||||
modSlug = item.modVersion.slug
|
||||
else
|
||||
itemName = @modPack.findName @model.itemSlug
|
||||
modSlug = 'minecraft'
|
||||
|
||||
return itemName:itemName, itemSlug:itemSlug, modSlug:modSlug
|
||||
|
||||
Reference in New Issue
Block a user