Adjust animations, fix bugs, and tweak a few algos
* Adjust page change animations to slide the page closed and then open again. * Add Railcraft to the standard set of mods * Change every controller which uses an `ImageLoader` to only accept it from a parent controller (with the router creating the one shared instance). * Fix several places where controllers need to refresh when the mod pack changes * Fix a few places which should be using the `ImageLoader` but were not. * Remove a number of animations which caused performance issues (esp. animating individual items in item group views). * Fix a bug where changing the current version of a mod didn't cause the current crafting plan to be re-evaluated * Simplify the name finder to allow regular expressions instead of the current algorithm
This commit is contained in:
@@ -6,6 +6,8 @@ All rights reserved.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
.view__item_page {
|
.view__item_page {
|
||||||
|
display: none;
|
||||||
|
|
||||||
& > div {
|
& > div {
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ All rights reserved.
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
.view__mod_page {
|
.view__mod_page {
|
||||||
|
display: none;
|
||||||
|
|
||||||
& > div {
|
& > div {
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ exports.DefaultMods = [
|
|||||||
'buildcraft',
|
'buildcraft',
|
||||||
'enderio',
|
'enderio',
|
||||||
'industrial_craft_2',
|
'industrial_craft_2',
|
||||||
|
'railcraft',
|
||||||
'thermal_expansion',
|
'thermal_expansion',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ All rights reserved.
|
|||||||
|
|
||||||
BaseController = require './base_controller'
|
BaseController = require './base_controller'
|
||||||
{Duration} = require '../constants'
|
{Duration} = require '../constants'
|
||||||
|
{Event} = require '../constants'
|
||||||
ImageLoader = require './image_loader'
|
ImageLoader = require './image_loader'
|
||||||
|
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
@@ -14,8 +15,8 @@ ImageLoader = require './image_loader'
|
|||||||
module.exports = class CraftingGridController extends BaseController
|
module.exports = class CraftingGridController extends BaseController
|
||||||
|
|
||||||
constructor: (options={})->
|
constructor: (options={})->
|
||||||
|
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
|
||||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||||
options.imageLoader ?= new ImageLoader defaultUrl:'/images/unknown.png'
|
|
||||||
options.templateName = 'crafting_grid'
|
options.templateName = 'crafting_grid'
|
||||||
super options
|
super options
|
||||||
|
|
||||||
@@ -23,6 +24,8 @@ module.exports = class CraftingGridController extends BaseController
|
|||||||
@_modPack = options.modPack
|
@_modPack = options.modPack
|
||||||
@_slotCount = 9
|
@_slotCount = 9
|
||||||
|
|
||||||
|
@_modPack.on Event.change, => @tryRefresh()
|
||||||
|
|
||||||
# BaseController Methods #######################################################################
|
# BaseController Methods #######################################################################
|
||||||
|
|
||||||
onDidRender: ->
|
onDidRender: ->
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ Storage = require '../models/storage'
|
|||||||
module.exports = class CraftingPageController extends BaseController
|
module.exports = class CraftingPageController extends BaseController
|
||||||
|
|
||||||
constructor: (options={})->
|
constructor: (options={})->
|
||||||
|
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
|
||||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||||
|
|
||||||
options.model ?= new CraftingPage modPack:options.modPack
|
options.model ?= new CraftingPage modPack:options.modPack
|
||||||
options.imageLoader ?= new ImageLoader defaultUrl:'/images/unknown.png'
|
|
||||||
options.storage ?= new Storage storage:window.localStorage
|
options.storage ?= new Storage storage:window.localStorage
|
||||||
options.templateName = 'crafting_page'
|
options.templateName = 'crafting_page'
|
||||||
super options
|
super options
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ All rights reserved.
|
|||||||
|
|
||||||
BaseController = require './base_controller'
|
BaseController = require './base_controller'
|
||||||
{Duration} = require '../constants'
|
{Duration} = require '../constants'
|
||||||
|
{Event} = require '../constants'
|
||||||
ImageLoader = require './image_loader'
|
ImageLoader = require './image_loader'
|
||||||
MinimalRecipeController = require './minimal_recipe_controller'
|
MinimalRecipeController = require './minimal_recipe_controller'
|
||||||
|
|
||||||
@@ -15,14 +16,14 @@ MinimalRecipeController = require './minimal_recipe_controller'
|
|||||||
module.exports = class CraftingTableController extends BaseController
|
module.exports = class CraftingTableController extends BaseController
|
||||||
|
|
||||||
constructor: (options={})->
|
constructor: (options={})->
|
||||||
|
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
|
||||||
if not options.model? then throw new Error 'options.model is required'
|
if not options.model? then throw new Error 'options.model is required'
|
||||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||||
options.imageLoader ?= new ImageLoader defaultUrl:'/images/unknown.png'
|
|
||||||
options.templateName = 'crafting_table'
|
options.templateName = 'crafting_table'
|
||||||
super options
|
super options
|
||||||
|
|
||||||
@_imageLoader = options.imageLoader
|
@imageLoader = options.imageLoader
|
||||||
@_modPack = options.modPack
|
@modPack = options.modPack
|
||||||
|
|
||||||
# Event Methods ################################################################################
|
# Event Methods ################################################################################
|
||||||
|
|
||||||
@@ -42,7 +43,7 @@ module.exports = class CraftingTableController extends BaseController
|
|||||||
# BaseController Overrides #####################################################################
|
# BaseController Overrides #####################################################################
|
||||||
|
|
||||||
onDidRender: ->
|
onDidRender: ->
|
||||||
@recipeController = @addChild MinimalRecipeController, '.view__minimal_recipe', imageLoader:@_imageLoader, modPack:@_modPack
|
@recipeController = @addChild MinimalRecipeController, '.view__minimal_recipe', imageLoader:@imageLoader, modPack:@modPack
|
||||||
|
|
||||||
@$next = @$('.next')
|
@$next = @$('.next')
|
||||||
@$prev = @$('.prev')
|
@$prev = @$('.prev')
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ InventoryTableController = require './inventory_table_controller'
|
|||||||
module.exports = class FullRecipeController extends BaseController
|
module.exports = class FullRecipeController extends BaseController
|
||||||
|
|
||||||
constructor: (options={})->
|
constructor: (options={})->
|
||||||
|
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
|
||||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||||
options.imageLoader ?= new ImageLoader defaultUrl:'/images/unknown.png'
|
|
||||||
options.templateName = 'full_recipe'
|
options.templateName = 'full_recipe'
|
||||||
super options
|
super options
|
||||||
|
|
||||||
@_imageLoader = options.imageLoader
|
@imageLoader = options.imageLoader
|
||||||
@modPack = options.modPack
|
@modPack = options.modPack
|
||||||
|
|
||||||
# BaseController Overrides #####################################################################
|
# BaseController Overrides #####################################################################
|
||||||
@@ -30,17 +30,19 @@ module.exports = class FullRecipeController extends BaseController
|
|||||||
onDidRender: ->
|
onDidRender: ->
|
||||||
@gridController = @addChild CraftingGridController, '.view__crafting_grid',
|
@gridController = @addChild CraftingGridController, '.view__crafting_grid',
|
||||||
modPack: @modPack
|
modPack: @modPack
|
||||||
imageLoader: @_imageLoader
|
imageLoader: @imageLoader
|
||||||
|
|
||||||
@inputController = @addChild InventoryTableController, '.input .view__inventory_table',
|
@inputController = @addChild InventoryTableController, '.input .view__inventory_table',
|
||||||
editable: false
|
editable: false
|
||||||
model: new Inventory
|
imageLoader: @imageLoader
|
||||||
modPack: @modPack
|
model: new Inventory
|
||||||
|
modPack: @modPack
|
||||||
|
|
||||||
@outputController = @addChild InventoryTableController, '.output .view__inventory_table',
|
@outputController = @addChild InventoryTableController, '.output .view__inventory_table',
|
||||||
editable: false
|
editable: false
|
||||||
model: new Inventory
|
imageLoader: @imageLoader
|
||||||
modPack: @modPack
|
model: new Inventory
|
||||||
|
modPack: @modPack
|
||||||
|
|
||||||
@$tool = @$('.tool p')
|
@$tool = @$('.tool p')
|
||||||
super
|
super
|
||||||
|
|||||||
@@ -19,12 +19,13 @@ module.exports = class InventoryController extends BaseController
|
|||||||
@ONLY_DIGITS = /^[0-9]*$/
|
@ONLY_DIGITS = /^[0-9]*$/
|
||||||
|
|
||||||
constructor: (options={})->
|
constructor: (options={})->
|
||||||
|
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
|
||||||
if not options.model? then throw new Error 'options.model is required'
|
if not options.model? then throw new Error 'options.model is required'
|
||||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||||
|
|
||||||
@editable = options.editable ?= true
|
@editable = options.editable ?= true
|
||||||
@icon = options.icon ?= '/images/chest_front.png'
|
@icon = options.icon ?= '/images/chest_front.png'
|
||||||
@imageLoader = options.imageLoader ?= new ImageLoader defaultUrl:'/images/unknown.png'
|
@imageLoader = options.imageLoader
|
||||||
@modPack = options.modPack
|
@modPack = options.modPack
|
||||||
@nameFinder = options.nameFinder ?= new NameFinder options.modPack
|
@nameFinder = options.nameFinder ?= new NameFinder options.modPack
|
||||||
@onChange = options.onChange ?= -> # do nothing
|
@onChange = options.onChange ?= -> # do nothing
|
||||||
@@ -168,6 +169,7 @@ module.exports = class InventoryController extends BaseController
|
|||||||
minLength: 0
|
minLength: 0
|
||||||
change: onChanged
|
change: onChanged
|
||||||
close: onChanged
|
close: onChanged
|
||||||
|
minLength: 3
|
||||||
select: onSelected
|
select: onSelected
|
||||||
|
|
||||||
_refreshStacks: ->
|
_refreshStacks: ->
|
||||||
@@ -185,7 +187,9 @@ module.exports = class InventoryController extends BaseController
|
|||||||
modPack: @modPack
|
modPack: @modPack
|
||||||
onRemove: if not @editable then null else (stack)=> @_removeStack(stack)
|
onRemove: if not @editable then null else (stack)=> @_removeStack(stack)
|
||||||
controller.render()
|
controller.render()
|
||||||
|
controller.$el.hide()
|
||||||
controller.$el.insertBefore $lastRow
|
controller.$el.insertBefore $lastRow
|
||||||
|
controller.$el.slideDown duration:Duration.fast
|
||||||
@_stackControllers.push controller
|
@_stackControllers.push controller
|
||||||
else
|
else
|
||||||
controller.model = stack
|
controller.model = stack
|
||||||
|
|||||||
@@ -20,11 +20,12 @@ module.exports = class InventoryTableController extends BaseController
|
|||||||
@ONLY_DIGITS = /^[0-9]*$/
|
@ONLY_DIGITS = /^[0-9]*$/
|
||||||
|
|
||||||
constructor: (options={})->
|
constructor: (options={})->
|
||||||
|
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
|
||||||
if not options.model? then throw new Error 'options.model is required'
|
if not options.model? then throw new Error 'options.model is required'
|
||||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||||
|
|
||||||
@editable = options.editable ?= true
|
@editable = options.editable ?= true
|
||||||
@imageLoader = options.imageLoader ?= new ImageLoader defaultUrl:'/images/unknown.png'
|
@imageLoader = options.imageLoader
|
||||||
@modPack = options.modPack
|
@modPack = options.modPack
|
||||||
@nameFinder = options.nameFinder ?= new NameFinder options.modPack
|
@nameFinder = options.nameFinder ?= new NameFinder options.modPack
|
||||||
@onChange = options.onChange ?= -> # do nothing
|
@onChange = options.onChange ?= -> # do nothing
|
||||||
@@ -127,14 +128,13 @@ module.exports = class InventoryTableController extends BaseController
|
|||||||
$lastRow = @$table.find 'tr:last-child'
|
$lastRow = @$table.find 'tr:last-child'
|
||||||
@_stackControllers = []
|
@_stackControllers = []
|
||||||
@model.each (stack)=>
|
@model.each (stack)=>
|
||||||
options =
|
controller = new StackController
|
||||||
editable: @editable
|
editable: @editable
|
||||||
imageLoader: @imageLoader
|
imageLoader: @imageLoader
|
||||||
model: stack
|
model: stack
|
||||||
modPack: @modPack
|
modPack: @modPack
|
||||||
onRemove: if not @editable then null else (stack)=> @_removeStack(stack)
|
onRemove: if not @editable then null else (stack)=> @_removeStack(stack)
|
||||||
|
|
||||||
controller = new StackController options
|
|
||||||
controller.render()
|
controller.render()
|
||||||
controller.$el.insertBefore $lastRow
|
controller.$el.insertBefore $lastRow
|
||||||
@_stackControllers.push controller
|
@_stackControllers.push controller
|
||||||
|
|||||||
@@ -12,12 +12,14 @@ BaseController = require './base_controller'
|
|||||||
module.exports = class ItemController extends BaseController
|
module.exports = class ItemController extends BaseController
|
||||||
|
|
||||||
constructor: (options={})->
|
constructor: (options={})->
|
||||||
|
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
|
||||||
if not options.model? then throw new Error 'options.model is required'
|
if not options.model? then throw new Error 'options.model is required'
|
||||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||||
options.templateName = 'item'
|
options.templateName = 'item'
|
||||||
super options
|
super options
|
||||||
|
|
||||||
@_modPack = options.modPack
|
@_imageLoader = options.imageLoader
|
||||||
|
@_modPack = options.modPack
|
||||||
|
|
||||||
# BaseController Overrides #####################################################################
|
# BaseController Overrides #####################################################################
|
||||||
|
|
||||||
@@ -30,7 +32,7 @@ module.exports = class ItemController extends BaseController
|
|||||||
refresh: ->
|
refresh: ->
|
||||||
display = @_modPack.findItemDisplay @model.slug
|
display = @_modPack.findItemDisplay @model.slug
|
||||||
|
|
||||||
@$icon.attr 'src', display.iconUrl
|
@_imageLoader.load display.iconUrl, @$icon
|
||||||
@$name.html display.itemName
|
@$name.html display.itemName
|
||||||
@$nameLink.attr 'href', display.itemUrl
|
@$nameLink.attr 'href', display.itemUrl
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,14 @@ ItemController = require './item_controller'
|
|||||||
module.exports = class ItemGroupController extends BaseController
|
module.exports = class ItemGroupController extends BaseController
|
||||||
|
|
||||||
constructor: (options={})->
|
constructor: (options={})->
|
||||||
|
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
|
||||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||||
options.title ?= ''
|
options.title ?= ''
|
||||||
options.templateName = 'item_group'
|
options.templateName = 'item_group'
|
||||||
super options
|
super options
|
||||||
|
|
||||||
@_delayStep = 20
|
@_delayStep = 20
|
||||||
|
@_imageLoader = options.imageLoader
|
||||||
@_itemControllers = []
|
@_itemControllers = []
|
||||||
@_modPack = options.modPack
|
@_modPack = options.modPack
|
||||||
@_title = options.title
|
@_title = options.title
|
||||||
@@ -53,14 +55,12 @@ module.exports = class ItemGroupController extends BaseController
|
|||||||
# Private Methods ##############################################################################
|
# Private Methods ##############################################################################
|
||||||
|
|
||||||
_createItemController: (item, delay)->
|
_createItemController: (item, delay)->
|
||||||
controller = new ItemController model:item, modPack:@_modPack
|
controller = new ItemController imageLoader:@_imageLoader, model:item, modPack:@_modPack
|
||||||
@_itemControllers.push controller
|
@_itemControllers.push controller
|
||||||
|
|
||||||
attachController = =>
|
attachController = =>
|
||||||
controller.render()
|
controller.render()
|
||||||
controller.$el.hide()
|
|
||||||
@$items.append controller.$el
|
@$items.append controller.$el
|
||||||
controller.$el.fadeIn duration:Duration.fast
|
|
||||||
|
|
||||||
_.delay attachController, delay
|
_.delay attachController, delay
|
||||||
|
|
||||||
@@ -81,4 +81,4 @@ module.exports = class ItemGroupController extends BaseController
|
|||||||
|
|
||||||
while @_itemControllers.length > controllerIndex
|
while @_itemControllers.length > controllerIndex
|
||||||
controller = @_itemControllers.pop()
|
controller = @_itemControllers.pop()
|
||||||
controller.$el.fadeOut duration:Duration.normal, complete:-> @remove()
|
controller.$el.slideUp duration:Duration.normal, complete:-> @remove()
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ ItemPage = require '../models/item_page'
|
|||||||
module.exports = class ItemPageController extends BaseController
|
module.exports = class ItemPageController extends BaseController
|
||||||
|
|
||||||
constructor: (options={})->
|
constructor: (options={})->
|
||||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
|
||||||
if not options.itemSlug? then throw new Error 'options.itemSlug is required'
|
if not options.itemSlug? then throw new Error 'options.itemSlug is required'
|
||||||
|
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
|
||||||
|
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||||
|
|
||||||
options.imageLoader ?= new ImageLoader defaultUrl:'/images/unknown.png'
|
|
||||||
options.model ?= new ItemPage modPack:options.modPack
|
options.model ?= new ItemPage modPack:options.modPack
|
||||||
options.templateName ?= 'item_page'
|
options.templateName ?= 'item_page'
|
||||||
|
|
||||||
@@ -34,23 +34,27 @@ module.exports = class ItemPageController extends BaseController
|
|||||||
@_itemSlug = options.itemSlug
|
@_itemSlug = options.itemSlug
|
||||||
@_modPack = options.modPack
|
@_modPack = options.modPack
|
||||||
|
|
||||||
@_modPack.on Event.change, => @refresh()
|
@_modPack.on Event.change, => @tryRefresh()
|
||||||
|
|
||||||
# BaseController Overrides #####################################################################
|
# BaseController Overrides #####################################################################
|
||||||
|
|
||||||
onDidRender: ->
|
onDidRender: ->
|
||||||
@_similarItemsController = @addChild ItemGroupController, '.similar .view__item_group', modPack:@_modPack
|
@_similarItemsController = @addChild ItemGroupController, '.similar .view__item_group',
|
||||||
@_usedToMakeController = @addChild ItemGroupController, '.usedToMake .view__item_group', modPack:@_modPack
|
imageLoader: @_imageLoader
|
||||||
|
modPack: @_modPack
|
||||||
|
@_usedToMakeController = @addChild ItemGroupController, '.usedToMake .view__item_group',
|
||||||
|
imageLoader: @_imageLoader
|
||||||
|
modPack: @_modPack
|
||||||
|
|
||||||
@$byline = @$('.byline')
|
@$byline = @$('.byline')
|
||||||
@$bylineLink = @$('.byline a')
|
@$bylineLink = @$('.byline a')
|
||||||
@$craftingPlanLink = @$('a.craftingPlan')
|
@$craftingPlanLink = @$('a.craftingPlan')
|
||||||
@$name = @$('h1.name')
|
@$name = @$('h1.name')
|
||||||
@$recipeContainer = @$('.recipes .panel')
|
@$recipeContainer = @$('.recipes .panel')
|
||||||
@$recipesSection = @$('.recipes')
|
@$recipesSection = @$('.recipes')
|
||||||
@$similarContainer = @$('.similar')
|
@$similarSection = @$('.similar')
|
||||||
@$titleImage = @$('.titleImage img')
|
@$titleImage = @$('.titleImage img')
|
||||||
@$usedToMakeContainer = @$('.usedToMake')
|
@$usedToMakeSection = @$('.usedToMake')
|
||||||
super
|
super
|
||||||
|
|
||||||
refresh: ->
|
refresh: ->
|
||||||
@@ -60,13 +64,13 @@ module.exports = class ItemPageController extends BaseController
|
|||||||
if @model.item?
|
if @model.item?
|
||||||
display = @_modPack.findItemDisplay @model.item.slug
|
display = @_modPack.findItemDisplay @model.item.slug
|
||||||
@$craftingPlanLink.attr href:display.craftingUrl
|
@$craftingPlanLink.attr href:display.craftingUrl
|
||||||
@$craftingPlanLink.fadeIn duration:Duration.normal
|
@$craftingPlanLink.fadeIn duration:Duration.fast
|
||||||
@_imageLoader.load display.iconUrl, @$titleImage
|
@_imageLoader.load display.iconUrl, @$titleImage
|
||||||
@$name.html display.itemName
|
@$name.html display.itemName
|
||||||
|
|
||||||
|
@$el.slideDown duration:Duration.normal
|
||||||
else
|
else
|
||||||
@$craftingPlanLink.fadeOut duration:Duration.normal
|
@$el.slideUp duration:Duration.normal
|
||||||
@$titleImage.removeAttr 'src'
|
|
||||||
@$name.html ''
|
|
||||||
|
|
||||||
@_refreshByline()
|
@_refreshByline()
|
||||||
@_refreshRecipes()
|
@_refreshRecipes()
|
||||||
@@ -89,18 +93,18 @@ module.exports = class ItemPageController extends BaseController
|
|||||||
if mod?.name?.length > 0
|
if mod?.name?.length > 0
|
||||||
@$bylineLink.attr 'href', Url.mod modSlug:mod.slug
|
@$bylineLink.attr 'href', Url.mod modSlug:mod.slug
|
||||||
@$bylineLink.html mod.name
|
@$bylineLink.html mod.name
|
||||||
@$byline.fadeIn duration:Duration.normal
|
@$byline.fadeIn duration:Duration.fast
|
||||||
else
|
else
|
||||||
@$byline.fadeOut duration:Duration.normal
|
@$byline.fadeOut duration:Duration.fast
|
||||||
|
|
||||||
_refreshUsedToMake: ->
|
_refreshUsedToMake: ->
|
||||||
@_usedToMakeController.title = 'Used to Make'
|
@_usedToMakeController.title = 'Used to Make'
|
||||||
|
|
||||||
@_usedToMakeController.model = @model.findComponentInItems()
|
@_usedToMakeController.model = @model.findComponentInItems()
|
||||||
if @_usedToMakeController.model?
|
if @_usedToMakeController.model?
|
||||||
@$usedToMakeContainer.fadeIn duration:Duration.normal
|
@$usedToMakeSection.slideDown duration:Duration.normal
|
||||||
else
|
else
|
||||||
@$usedToMakeContainer.fadeOut duration:Duration.normal
|
@$usedToMakeSection.slideUp duration:Duration.normal
|
||||||
|
|
||||||
_refreshRecipes: ->
|
_refreshRecipes: ->
|
||||||
@_recipeControllers ?= []
|
@_recipeControllers ?= []
|
||||||
@@ -108,26 +112,24 @@ module.exports = class ItemPageController extends BaseController
|
|||||||
|
|
||||||
recipes = @model.findRecipes()
|
recipes = @model.findRecipes()
|
||||||
if recipes?
|
if recipes?
|
||||||
@$recipesSection.fadeIn duration:Duration.normal
|
@$recipesSection.slideDown duration:Duration.normal
|
||||||
|
|
||||||
for recipe in @model.findRecipes()
|
for recipe in @model.findRecipes()
|
||||||
controller = @_recipeControllers[index]
|
controller = @_recipeControllers[index]
|
||||||
if not controller?
|
if not controller?
|
||||||
controller = new FullRecipeController modPack:@_modPack, model:recipe
|
controller = new FullRecipeController imageLoader:@_imageLoader, modPack:@_modPack, model:recipe
|
||||||
@_recipeControllers.push controller
|
@_recipeControllers.push controller
|
||||||
controller.render()
|
controller.render()
|
||||||
controller.$el.hide()
|
|
||||||
@$recipeContainer.append controller.$el
|
@$recipeContainer.append controller.$el
|
||||||
controller.$el.fadeIn duration:Duration.normal
|
|
||||||
else
|
else
|
||||||
controller.model = recipe
|
controller.model = recipe
|
||||||
index++
|
index++
|
||||||
else
|
else
|
||||||
@$recipesSection.fadeOut duration:Duration.normal
|
@$recipesSection.slideUp duration:Duration.normal
|
||||||
|
|
||||||
while @_recipeControllers.length > index
|
while @_recipeControllers.length > index
|
||||||
controller = @_recipeControllers.pop()
|
controller = @_recipeControllers.pop()
|
||||||
controller.fadeOut duration:Duration.normal, complete:-> controller.$el.remove()
|
controller.$el.slideUp duration:Duration.normal, complete:-> controller.$el.remove()
|
||||||
|
|
||||||
_refreshSimilarItems: ->
|
_refreshSimilarItems: ->
|
||||||
group = @model.item?.group
|
group = @model.item?.group
|
||||||
@@ -138,9 +140,9 @@ module.exports = class ItemPageController extends BaseController
|
|||||||
@_similarItemsController.model = null
|
@_similarItemsController.model = null
|
||||||
|
|
||||||
if @_similarItemsController.model?
|
if @_similarItemsController.model?
|
||||||
@$similarContainer.fadeIn duration:Duration.normal
|
@$similarSection.slideDown duration:Duration.normal
|
||||||
else
|
else
|
||||||
@$similarContainer.fadeOut duration:Duration.normal
|
@$similarSection.slideUp duration:Duration.normal
|
||||||
|
|
||||||
_resolveItemSlug: ->
|
_resolveItemSlug: ->
|
||||||
@model.item = @_modPack.findItem @_itemSlug, includeDisabled:true
|
@model.item = @_modPack.findItem @_itemSlug, includeDisabled:true
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ ImageLoader = require './image_loader'
|
|||||||
module.exports = class MinimalRecipeController extends BaseController
|
module.exports = class MinimalRecipeController extends BaseController
|
||||||
|
|
||||||
constructor: (options={})->
|
constructor: (options={})->
|
||||||
|
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
|
||||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||||
options.imageLoader ?= new ImageLoader defaultUrl:'/images/unknown.png'
|
|
||||||
options.templateName = 'minimal_recipe'
|
options.templateName = 'minimal_recipe'
|
||||||
super options
|
super options
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ module.exports = class ModController extends BaseController
|
|||||||
onVersionChanged: ->
|
onVersionChanged: ->
|
||||||
@model.activeVersion = @$version.val()
|
@model.activeVersion = @$version.val()
|
||||||
@_plan.removeUncraftableItems()
|
@_plan.removeUncraftableItems()
|
||||||
|
@_plan.craft()
|
||||||
|
|
||||||
# BaseController Overrides #####################################################################
|
# BaseController Overrides #####################################################################
|
||||||
|
|
||||||
|
|||||||
@@ -19,15 +19,18 @@ ItemGroupController = require './item_group_controller'
|
|||||||
module.exports = class ModPageController extends BaseController
|
module.exports = class ModPageController extends BaseController
|
||||||
|
|
||||||
constructor: (options={})->
|
constructor: (options={})->
|
||||||
|
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
|
||||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||||
options.delayStep ?= 10
|
options.delayStep ?= 10
|
||||||
options.templateName = 'mod_page'
|
options.templateName = 'mod_page'
|
||||||
super options
|
super options
|
||||||
|
|
||||||
|
@imageLoader = options.imageLoader
|
||||||
|
@modPack = options.modPack
|
||||||
|
|
||||||
@_delayStep = options.delayStep
|
@_delayStep = options.delayStep
|
||||||
@_effectiveModVersion = null
|
@_effectiveModVersion = null
|
||||||
@_groupControllers = []
|
@_groupControllers = []
|
||||||
@_modPack = options.modPack
|
|
||||||
|
|
||||||
Object.defineProperties this,
|
Object.defineProperties this,
|
||||||
effectiveModVersion: {get:@_getEffectiveModVersion}
|
effectiveModVersion: {get:@_getEffectiveModVersion}
|
||||||
@@ -59,10 +62,15 @@ module.exports = class ModPageController extends BaseController
|
|||||||
refresh: ->
|
refresh: ->
|
||||||
$('title').html if @model? then "#{@model.name} | #{Text.title}" else Text.title
|
$('title').html if @model? then "#{@model.name} | #{Text.title}" else Text.title
|
||||||
|
|
||||||
@$name.html if @model? then @model.name else ''
|
if @model?
|
||||||
@$byline.html if @model? then "by #{@model.author}" else ''
|
@$name.html @model.name
|
||||||
@$titleImage.attr 'src', (if @model? then Url.modLogoImage(modSlug:@model.slug) else '')
|
@$byline.html "by #{@model.author}"
|
||||||
@$description.html if @model? then @model.description else ''
|
@$titleImage.attr 'src', Url.modLogoImage modSlug:@model.slug
|
||||||
|
@$description.html @model.description
|
||||||
|
|
||||||
|
@$el.slideDown duration:Duration.normal
|
||||||
|
else
|
||||||
|
@$el.slideUp duration:Duration.normal
|
||||||
|
|
||||||
@_refreshLink @$homePageLink, @model.homePageUrl
|
@_refreshLink @$homePageLink, @model.homePageUrl
|
||||||
@_refreshLink @$documentationLink, @model.documentationUrl
|
@_refreshLink @$documentationLink, @model.documentationUrl
|
||||||
@@ -98,7 +106,11 @@ module.exports = class ModPageController extends BaseController
|
|||||||
items = modVersion.allItemsInGroup group
|
items = modVersion.allItemsInGroup group
|
||||||
if not controller?
|
if not controller?
|
||||||
title = if group is Item.Group.Other then 'Items' else group
|
title = if group is Item.Group.Other then 'Items' else group
|
||||||
controller = new ItemGroupController model:items, modPack:@_modPack, title:title
|
controller = new ItemGroupController
|
||||||
|
imageLoader: @imageLoader
|
||||||
|
model: items
|
||||||
|
modPack: @modPack
|
||||||
|
title: title
|
||||||
controller.render()
|
controller.render()
|
||||||
@$groupContainer.append controller.$el
|
@$groupContainer.append controller.$el
|
||||||
@_groupControllers[groupIndex] = controller
|
@_groupControllers[groupIndex] = controller
|
||||||
@@ -114,10 +126,10 @@ module.exports = class ModPageController extends BaseController
|
|||||||
|
|
||||||
_refreshLink: ($link, url)->
|
_refreshLink: ($link, url)->
|
||||||
if url?
|
if url?
|
||||||
$link.fadeIn duration:Duration.normal
|
$link.slideDown duration:Duration.normal
|
||||||
$link.attr 'href', url
|
$link.attr 'href', url
|
||||||
else
|
else
|
||||||
$link.fadeOut duration:Duration.normal
|
$link.sludeUp duration:Duration.normal
|
||||||
|
|
||||||
_refreshVersions: ->
|
_refreshVersions: ->
|
||||||
@$versionSelector.empty()
|
@$versionSelector.empty()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ All rights reserved.
|
|||||||
###
|
###
|
||||||
|
|
||||||
BaseController = require './base_controller'
|
BaseController = require './base_controller'
|
||||||
|
{Event} = require '../constants'
|
||||||
ImageLoader = require './image_loader'
|
ImageLoader = require './image_loader'
|
||||||
|
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
@@ -13,10 +14,10 @@ ImageLoader = require './image_loader'
|
|||||||
module.exports = class StackController extends BaseController
|
module.exports = class StackController extends BaseController
|
||||||
|
|
||||||
constructor: (options={})->
|
constructor: (options={})->
|
||||||
|
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
|
||||||
if not options.model? then throw new Error 'options.model is required'
|
if not options.model? then throw new Error 'options.model is required'
|
||||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||||
|
|
||||||
options.imageLoader ?= new ImageLoader defaultUrl:'/images/unknown.png'
|
|
||||||
options.editable ?= false
|
options.editable ?= false
|
||||||
options.onRemove ?= (stack)-> # do nothing
|
options.onRemove ?= (stack)-> # do nothing
|
||||||
options.templateName = 'stack'
|
options.templateName = 'stack'
|
||||||
@@ -27,6 +28,8 @@ module.exports = class StackController extends BaseController
|
|||||||
@onRemove = options.onRemove
|
@onRemove = options.onRemove
|
||||||
@_imageLoader = options.imageLoader
|
@_imageLoader = options.imageLoader
|
||||||
|
|
||||||
|
@modPack.on Event.change, => @tryRefresh()
|
||||||
|
|
||||||
# Event Methods ################################################################################
|
# Event Methods ################################################################################
|
||||||
|
|
||||||
onRemoveClicked: ->
|
onRemoveClicked: ->
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ CraftingPageController = require './controllers/crafting_page_controller'
|
|||||||
HeaderController = require './controllers/header_controller'
|
HeaderController = require './controllers/header_controller'
|
||||||
ItemPageController = require './controllers/item_page_controller'
|
ItemPageController = require './controllers/item_page_controller'
|
||||||
ItemSlug = require './models/item_slug'
|
ItemSlug = require './models/item_slug'
|
||||||
|
ImageLoader = require './controllers/image_loader'
|
||||||
Mod = require './models/mod'
|
Mod = require './models/mod'
|
||||||
ModPack = require './models/mod_pack'
|
ModPack = require './models/mod_pack'
|
||||||
ModPageController = require './controllers/mod_page_controller'
|
ModPageController = require './controllers/mod_page_controller'
|
||||||
@@ -31,9 +32,10 @@ module.exports = class CraftingGuideRouter extends Backbone.Router
|
|||||||
@_lastReported = null
|
@_lastReported = null
|
||||||
super options
|
super options
|
||||||
|
|
||||||
@modPack = new ModPack
|
@imageLoader = new ImageLoader defaultUrl:'/images/unknown.png'
|
||||||
@storage = new Storage storage:window.localStorage
|
@modPack = new ModPack
|
||||||
@_defaultOptions = modPack:@modPack, storage:@storage
|
@storage = new Storage storage:window.localStorage
|
||||||
|
@_defaultOptions = imageLoader:@imageLoader, modPack:@modPack, storage:@storage
|
||||||
|
|
||||||
@headerController = new HeaderController el:'.view__header'
|
@headerController = new HeaderController el:'.view__header'
|
||||||
|
|
||||||
@@ -124,11 +126,11 @@ module.exports = class CraftingGuideRouter extends Backbone.Router
|
|||||||
controller.$el.addClass 'page'
|
controller.$el.addClass 'page'
|
||||||
$pageContent.replaceWith controller.$el
|
$pageContent.replaceWith controller.$el
|
||||||
|
|
||||||
controller.$el.fadeIn showDuration, ->
|
controller.$el.slideDown showDuration, ->
|
||||||
controller.onDidShow()
|
controller.onDidShow()
|
||||||
|
|
||||||
if @_controller?
|
if @_controller?
|
||||||
showDuration = Duration.long
|
showDuration = showDuration / 2
|
||||||
@_controller.$el.fadeOut showDuration, show
|
@_controller.$el.slideUp showDuration, show
|
||||||
else
|
else
|
||||||
show()
|
show()
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ module.exports = class CraftingPlan extends BaseModel
|
|||||||
item = @modPack.findItem stack.itemSlug
|
item = @modPack.findItem stack.itemSlug
|
||||||
@need.add item.slug, stack.quantity
|
@need.add item.slug, stack.quantity
|
||||||
|
|
||||||
@steps = (recipe:recipe for recipeSlug, recipe of @steps)
|
@steps = (step for recipeSlug, step of @steps)
|
||||||
@_resolveNeeds()
|
@_resolveNeeds()
|
||||||
@_removeExtraSteps()
|
@_removeExtraSteps()
|
||||||
|
|
||||||
@@ -97,10 +97,6 @@ module.exports = class CraftingPlan extends BaseModel
|
|||||||
|
|
||||||
# Private Methods ##############################################################################
|
# Private Methods ##############################################################################
|
||||||
|
|
||||||
_addStep: (recipe)->
|
|
||||||
logger.verbose -> "adding step for: #{recipe.slug}"
|
|
||||||
@steps[recipe.slug] = recipe
|
|
||||||
|
|
||||||
_chooseRecipe: (item)->
|
_chooseRecipe: (item)->
|
||||||
recipes = @modPack.findRecipes item.slug
|
recipes = @modPack.findRecipes item.slug
|
||||||
return null unless recipes? and recipes.length > 0
|
return null unless recipes? and recipes.length > 0
|
||||||
@@ -143,7 +139,8 @@ module.exports = class CraftingPlan extends BaseModel
|
|||||||
for inputStack in recipe.input
|
for inputStack in recipe.input
|
||||||
@_findSteps inputStack.itemSlug, parentSteps
|
@_findSteps inputStack.itemSlug, parentSteps
|
||||||
|
|
||||||
@_addStep recipe
|
logger.verbose -> "adding step for: #{recipe.slug}"
|
||||||
|
@steps[recipe.slug] = recipe:recipe, itemSlug:item.slug
|
||||||
foundValidRecipe = true
|
foundValidRecipe = true
|
||||||
break
|
break
|
||||||
catch error
|
catch error
|
||||||
@@ -159,8 +156,8 @@ module.exports = class CraftingPlan extends BaseModel
|
|||||||
throw new Error 'invalid recipe path'
|
throw new Error 'invalid recipe path'
|
||||||
|
|
||||||
_hasStep: (itemSlug)->
|
_hasStep: (itemSlug)->
|
||||||
for recipeSlug, recipe of @steps
|
for recipeSlug, step of @steps
|
||||||
return true if recipe.produces itemSlug
|
return true if step.recipe.produces itemSlug
|
||||||
return false
|
return false
|
||||||
|
|
||||||
_qualifyItemSlug: (itemSlug)->
|
_qualifyItemSlug: (itemSlug)->
|
||||||
@@ -176,9 +173,8 @@ module.exports = class CraftingPlan extends BaseModel
|
|||||||
for i in [@steps.length-1..0] by -1
|
for i in [@steps.length-1..0] by -1
|
||||||
step = @steps[i]
|
step = @steps[i]
|
||||||
recipe = step.recipe
|
recipe = step.recipe
|
||||||
stepItemSlug = @_qualifyItemSlug step.recipe.itemSlug
|
|
||||||
|
|
||||||
step.multiplier = Math.ceil(@need.quantityOf(stepItemSlug) / recipe.output[0].quantity)
|
step.multiplier = Math.ceil(@need.quantityOf(step.itemSlug) / recipe.output[0].quantity)
|
||||||
|
|
||||||
if @includingTools
|
if @includingTools
|
||||||
for stack in recipe.tools
|
for stack in recipe.tools
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ module.exports = class ItemPage extends BaseModel
|
|||||||
|
|
||||||
result = []
|
result = []
|
||||||
@item.modVersion.eachItemInGroup @item.group, (item)=>
|
@item.modVersion.eachItemInGroup @item.group, (item)=>
|
||||||
return if item is @item
|
|
||||||
result.push item
|
result.push item
|
||||||
|
|
||||||
return null unless result.length > 0
|
return null unless result.length > 0
|
||||||
|
|||||||
@@ -43,35 +43,24 @@ module.exports = class NameFinder
|
|||||||
|
|
||||||
# Private Methods ##############################################################################
|
# Private Methods ##############################################################################
|
||||||
|
|
||||||
_isMatch: (name, hint)->
|
|
||||||
nameWords = name.split ' '
|
|
||||||
hintWords = hint.split ' '
|
|
||||||
|
|
||||||
for hintWord in hintWords
|
|
||||||
while true
|
|
||||||
return false if nameWords.length is 0
|
|
||||||
nameWord = nameWords.shift()
|
|
||||||
break if nameWord.indexOf(hintWord) is 0
|
|
||||||
|
|
||||||
return true
|
|
||||||
|
|
||||||
_findNames: (nameHint=null)->
|
_findNames: (nameHint=null)->
|
||||||
names = []
|
names = []
|
||||||
nameMap = {}
|
nameMap = {}
|
||||||
|
hintRegex = new RegExp(nameHint, 'i') if nameHint?
|
||||||
|
|
||||||
@modPack.eachMod (mod)=>
|
@modPack.eachMod (mod)=>
|
||||||
return unless mod.enabled or @includeDisabledMods
|
return unless mod.enabled or @includeDisabledMods
|
||||||
|
|
||||||
mod.eachName (name, itemSlug)=>
|
mod.eachName (name, itemSlug)=>
|
||||||
return if nameMap[name]
|
return if nameMap[name]?
|
||||||
|
|
||||||
item = mod.findItem itemSlug
|
item = mod.findItem itemSlug
|
||||||
if not @includeGatherable
|
if not @includeGatherable
|
||||||
return unless item? and item.isCraftable
|
return unless item? and item.isCraftable
|
||||||
|
|
||||||
scanName = "#{mod.name} : #{name}"
|
scanName = "#{mod.name} : #{name}"
|
||||||
if nameHint?
|
if hintRegex?
|
||||||
return unless @_isMatch scanName.toLowerCase(), nameHint
|
return unless hintRegex.test scanName
|
||||||
|
|
||||||
nameMap[name] = name
|
nameMap[name] = name
|
||||||
names.push value:name, label:scanName, mod:mod
|
names.push value:name, label:scanName, mod:mod
|
||||||
|
|||||||
@@ -50,16 +50,21 @@ module.exports = class Recipe extends BaseModel
|
|||||||
if aValue isnt bValue
|
if aValue isnt bValue
|
||||||
return if aValue > bValue then -1 else +1
|
return if aValue > bValue then -1 else +1
|
||||||
|
|
||||||
aValue = a.getInputCount()
|
|
||||||
bValue = b.getInputCount()
|
|
||||||
if aValue isnt bValue
|
|
||||||
return if aValue < bValue then -1 else +1
|
|
||||||
|
|
||||||
aValue = a.getOutputCount()
|
aValue = a.getOutputCount()
|
||||||
bValue = b.getOutputCount()
|
bValue = b.getOutputCount()
|
||||||
if aValue isnt bValue
|
if aValue isnt bValue
|
||||||
return if aValue > bValue then -1 else +1
|
return if aValue > bValue then -1 else +1
|
||||||
|
|
||||||
|
aValue = a.tools.length
|
||||||
|
bValue = b.tools.length
|
||||||
|
if aValue isnt bValue
|
||||||
|
return if aValue < bValue then -1 else +1
|
||||||
|
|
||||||
|
aValue = a.getInputCount()
|
||||||
|
bValue = b.getInputCount()
|
||||||
|
if aValue isnt bValue
|
||||||
|
return if aValue < bValue then -1 else +1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
# Public Methods ###############################################################################
|
# Public Methods ###############################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user