Show all recipes for an item on its detail page
This commit is contained in:
@@ -6,6 +6,8 @@ All rights reserved.
|
||||
*/
|
||||
|
||||
.view__full_recipe {
|
||||
display: block;
|
||||
|
||||
& > div {
|
||||
position: relative; width: 33%;
|
||||
display: inline-block;
|
||||
|
||||
@@ -57,11 +57,16 @@ All rights reserved.
|
||||
}
|
||||
}
|
||||
|
||||
.recipe {
|
||||
.recipes {
|
||||
display: none;
|
||||
|
||||
.view__full_recipe {
|
||||
width: 100%;
|
||||
margin-top: 3em;
|
||||
|
||||
&:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,3 +47,20 @@ I just pushed up a big new feature! Now, each Mod has a dedicated page of its o
|
||||
in that mod. Clicking on an item will take you to the crafting guide for that item. It's super fast to switch back and
|
||||
forth to explore the items in any given mod. This is the first of many steps for the new mod pages, so keep an eye out
|
||||
for more to come!
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
|
||||
I've been working on a project to make it easier to deal with complex recipes, and I recently finished adding all the
|
||||
core Minecraft recipes. The gist of the site is that you tell it what item(s) you want to make, and it will figure out
|
||||
all the raw ingredients you need along with step-by-step instructions for any number of whatever items you like. For
|
||||
example, [http://crafting-guide.com/crafting/16.potion_of_fire_resistance_8_00:16.potion_of_healing_ii here's how you
|
||||
make] 16 potions of healing II and fire resistance (with extended duration).
|
||||
|
||||
The maintainers of many of the mods I've added (e.g., BuildCraft / Applied Energistics) have found it useful to include
|
||||
links to Crafting Guide in their official documentation, and I was hoping you would think it a good idea to add links
|
||||
from this wiki to CraftingGuide as well. I'd be happy to do the work of adding the links myself, but I'd like to make
|
||||
sure there are no objections first!
|
||||
|
||||
Thanks!
|
||||
~~~~
|
||||
@@ -38,17 +38,17 @@ module.exports = class ItemPageController extends BaseController
|
||||
# BaseController Overrides #####################################################################
|
||||
|
||||
onDidRender: ->
|
||||
@_recipeController = @addChild FullRecipeController, '.view__full_recipe', modPack:@_modPack
|
||||
@_similarItemsController = @addChild ItemGroupController, '.similar .view__item_group', modPack:@_modPack
|
||||
@_usedInMakingController = @addChild ItemGroupController, '.usedInMaking .view__item_group', modPack:@_modPack
|
||||
|
||||
@$byline = @$('.byline')
|
||||
@$bylineLink = @$('.byline a')
|
||||
@$usedInMakingContainer = @$('.usedInMaking')
|
||||
@$name = @$('h1.name')
|
||||
@$recipeContainer = @$('.recipe')
|
||||
@$recipeContainer = @$('.recipes .panel')
|
||||
@$recipesSection = @$('.recipes')
|
||||
@$similarContainer = @$('.similar')
|
||||
@$titleImage = @$('.titleImage img')
|
||||
@$usedInMakingContainer = @$('.usedInMaking')
|
||||
super
|
||||
|
||||
refresh: ->
|
||||
@@ -63,7 +63,7 @@ module.exports = class ItemPageController extends BaseController
|
||||
@$name.html ''
|
||||
|
||||
@_refreshByline()
|
||||
@_refreshRecipe()
|
||||
@_refreshRecipes()
|
||||
@_refreshSimilarItems()
|
||||
@_refreshComponentIn()
|
||||
|
||||
@@ -89,12 +89,32 @@ module.exports = class ItemPageController extends BaseController
|
||||
else
|
||||
@$usedInMakingContainer.fadeOut duration:Duration.fast
|
||||
|
||||
_refreshRecipe: ->
|
||||
@_recipeController.model = @model.primaryRecipe
|
||||
if @_recipeController.model?
|
||||
@$recipeContainer.fadeIn duration:Duration.fast
|
||||
_refreshRecipes: ->
|
||||
@_recipeControllers ?= []
|
||||
index = 0
|
||||
|
||||
recipes = @model.findRecipes()
|
||||
if recipes?
|
||||
@$recipesSection.fadeIn duration:Duration.normal
|
||||
|
||||
for recipe in @model.findRecipes()
|
||||
controller = @_recipeControllers[index]
|
||||
if not controller?
|
||||
controller = new FullRecipeController modPack:@_modPack, model:recipe
|
||||
@_recipeControllers.push controller
|
||||
controller.render()
|
||||
controller.$el.hide()
|
||||
@$recipeContainer.append controller.$el
|
||||
controller.$el.fadeIn duration:Duration.normal
|
||||
else
|
||||
@$recipeContainer.fadeOut duration:Duration.fast
|
||||
controller.model = recipe
|
||||
index++
|
||||
else
|
||||
@$recipesSection.fadeOut duration:Duration.fast
|
||||
|
||||
while @_recipeControllers.length > index
|
||||
controller = @_recipeControllers.pop()
|
||||
controller.fadeOut duration:Duration.fast, complete:-> controller.$el.remove()
|
||||
|
||||
_refreshSimilarItems: ->
|
||||
group = @model.item?.group
|
||||
|
||||
@@ -25,7 +25,6 @@ module.exports = class ItemPage extends BaseModel
|
||||
Object.defineProperties this,
|
||||
craftingRawMaterials: {get:-> @_plan.need}
|
||||
craftingSteps: {get:-> @_plan.steps}
|
||||
primaryRecipe: {get:-> @_primaryRecipe}
|
||||
|
||||
# Property Methods #############################################################################
|
||||
|
||||
@@ -56,6 +55,11 @@ module.exports = class ItemPage extends BaseModel
|
||||
return null unless result.length > 0
|
||||
return result
|
||||
|
||||
findRecipes: ->
|
||||
result = @modPack.findRecipes @item?.slug
|
||||
return null unless result.length > 0
|
||||
return result
|
||||
|
||||
# Private Methods ##############################################################################
|
||||
|
||||
_updateCraftingPlan: ->
|
||||
|
||||
@@ -14,10 +14,9 @@
|
||||
.byline: p from <a></a>
|
||||
.description: p
|
||||
|
||||
.recipe.section
|
||||
h2 Recipe
|
||||
.recipes.section
|
||||
h2 Recipes
|
||||
.panel
|
||||
.view__full_recipe
|
||||
|
||||
.usedInMaking: .view__item_group
|
||||
.similar: .view__item_group
|
||||
|
||||
Reference in New Issue
Block a user