Store tool and modVersion enabled states

This commit is contained in:
Andrew Miner
2015-01-12 14:18:07 -08:00
parent 3e70c0deef
commit fef9d155d8
4 changed files with 29 additions and 9 deletions
+15 -5
View File
@@ -13,19 +13,23 @@ Inventory = require './inventory'
module.exports = class CraftingPlan extends BaseModel
constructor: (attributes={}, options={})->
options.storage ?= window.localStorage
if not attributes.modPack then throw new Error 'modPack is required'
attributes.includingTools ?= options.storage.getItem('includingTools')
attributes.includingTools ?= false
super attributes, options
@have = new Inventory
@want = new Inventory
@need = new Inventory
@result = new Inventory
@have = new Inventory
@want = new Inventory
@need = new Inventory
@result = new Inventory
@storage = options.storage
@have.on 'change', => @craft()
@want.on 'change', => @craft()
@modPack.on 'change', => @craft()
@on 'change:includingTools', => @craft()
@on 'change:includingTools', => @onIncludingToolsChanged()
@clear()
@@ -55,6 +59,12 @@ module.exports = class CraftingPlan extends BaseModel
@trigger 'change', this
# Event Methods ################################################################################
onIncludingToolsChanged: ->
@storage.setItem 'includingTools', "#{@includingTools}"
@craft()
# Object Overrides #############################################################################
toString: ->