Display images for each item referenced
This commit is contained in:
@@ -44,6 +44,8 @@ module.exports = (grunt)->
|
|||||||
copy:
|
copy:
|
||||||
data:
|
data:
|
||||||
files: [expand:true, cwd:'./src/data', src:'**/*.json', dest:'./dist/data']
|
files: [expand:true, cwd:'./src/data', src:'**/*.json', dest:'./dist/data']
|
||||||
|
data_images:
|
||||||
|
files: [expand:true, cwd:'./src/data', src:'**/*.png', dest:'./dist/data']
|
||||||
fonts:
|
fonts:
|
||||||
files: [expand:true, cwd:'./src/fonts', src:'**/*.ttf', dest:'./dist/fonts']
|
files: [expand:true, cwd:'./src/fonts', src:'**/*.ttf', dest:'./dist/fonts']
|
||||||
images:
|
images:
|
||||||
|
|||||||
@@ -7,17 +7,6 @@ All rights reserved.
|
|||||||
|
|
||||||
.view__crafting_table {
|
.view__crafting_table {
|
||||||
|
|
||||||
.quantity {
|
|
||||||
border-radius: 0.75em;
|
|
||||||
background: $color-ice;
|
|
||||||
color: $color-table-background;
|
|
||||||
display: inline-block;
|
|
||||||
text-align: center;
|
|
||||||
min-width: 3em;
|
|
||||||
margin-right: 0.5em;
|
|
||||||
padding: 0 0.5em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.recipe_selector {
|
.recipe_selector {
|
||||||
background: $color-table-background;
|
background: $color-table-background;
|
||||||
padding: 1em;
|
padding: 1em;
|
||||||
@@ -39,10 +28,6 @@ All rights reserved.
|
|||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
li {
|
|
||||||
margin: 0.25em 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
table { background: $color-table-background; width: 100%; }
|
table { background: $color-table-background; width: 100%; }
|
||||||
|
|
||||||
td {
|
td {
|
||||||
|
|||||||
@@ -7,3 +7,4 @@ All rights reserved.
|
|||||||
|
|
||||||
@import 'crafting_table';
|
@import 'crafting_table';
|
||||||
@import 'mod_pack';
|
@import 'mod_pack';
|
||||||
|
@import 'stack';
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
Crafting Guide - stack.scss
|
||||||
|
|
||||||
|
Copyright (c) 2014 by Redwood Labs
|
||||||
|
All rights reserved.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.view__stack {
|
||||||
|
position: relative; width: 100%; height: 1.8em;
|
||||||
|
|
||||||
|
.quantity {
|
||||||
|
border-radius: 0.75em;
|
||||||
|
background: $color-ice;
|
||||||
|
color: $color-table-background;
|
||||||
|
display: inline-block;
|
||||||
|
font-size: $font-size-small;
|
||||||
|
text-align: center;
|
||||||
|
min-width: 3em;
|
||||||
|
margin-right: 0.5em;
|
||||||
|
padding: 0 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.name {
|
||||||
|
padding-right: 2.4em;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
position: absolute; top: 0; right: 0; height: 1.6em; width: 1.6em;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -244,7 +244,7 @@
|
|||||||
"tools": "Crafting Table"
|
"tools": "Crafting Table"
|
||||||
}, {
|
}, {
|
||||||
"output": "Charcoal",
|
"output": "Charcoal",
|
||||||
"input": ["{furnace fuel}", "Oak Log"],
|
"input": ["{furnace fuel}", "Oak Wood"],
|
||||||
"tools": "Furnace"
|
"tools": "Furnace"
|
||||||
}, {
|
}, {
|
||||||
"output": "Charcoal",
|
"output": "Charcoal",
|
||||||
@@ -816,7 +816,7 @@
|
|||||||
"tools": "Crafting Table"
|
"tools": "Crafting Table"
|
||||||
}, {
|
}, {
|
||||||
"output": [[8, "Magenta Stained Glass"]],
|
"output": [[8, "Magenta Stained Glass"]],
|
||||||
"input": [[8, "Glass"], "Magenta"],
|
"input": [[8, "Glass"], "Magenta Dye"],
|
||||||
"tools": "Crafting Table"
|
"tools": "Crafting Table"
|
||||||
}, {
|
}, {
|
||||||
"output": [[16, "Magenta Stained Glass Pane"]],
|
"output": [[16, "Magenta Stained Glass Pane"]],
|
||||||
@@ -844,7 +844,7 @@
|
|||||||
"tools": "Cow"
|
"tools": "Cow"
|
||||||
}, {
|
}, {
|
||||||
"output": "Minecart",
|
"output": "Minecart",
|
||||||
"input": [[5, "Iron"]],
|
"input": [[5, "Iron Ingot"]],
|
||||||
"tools": "Crafting Table"
|
"tools": "Crafting Table"
|
||||||
}, {
|
}, {
|
||||||
"output": "Minecart with Chest",
|
"output": "Minecart with Chest",
|
||||||
@@ -901,7 +901,7 @@
|
|||||||
"tools": "Crafting Table"
|
"tools": "Crafting Table"
|
||||||
}, {
|
}, {
|
||||||
"output": [[4, "Oak Wood Planks"]],
|
"output": [[4, "Oak Wood Planks"]],
|
||||||
"input": "Oak Log"
|
"input": "Oak Wood"
|
||||||
}, {
|
}, {
|
||||||
"output": [[6, "Oak Wood Slab"]],
|
"output": [[6, "Oak Wood Slab"]],
|
||||||
"input": [[3, "Oak Wood Planks"]],
|
"input": [[3, "Oak Wood Planks"]],
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
@@ -31,6 +31,8 @@ Event.load.failed = 'load:failed' # controller, error message
|
|||||||
Event.load.finished = 'load:finished' # controller
|
Event.load.finished = 'load:finished' # controller
|
||||||
Event.remove = 'remove' # collection, item...
|
Event.remove = 'remove' # collection, item...
|
||||||
|
|
||||||
|
exports.ImageUrl = _.template "/data/<%= modSlug %>/images/<%= itemSlug %>.png"
|
||||||
|
|
||||||
exports.Key = Key = {}
|
exports.Key = Key = {}
|
||||||
Key.Return = 13
|
Key.Return = 13
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ BaseController = require './base_controller'
|
|||||||
{Event} = require '../constants'
|
{Event} = require '../constants'
|
||||||
InventoryParser = require '../models/inventory_parser'
|
InventoryParser = require '../models/inventory_parser'
|
||||||
{Key} = require '../constants'
|
{Key} = require '../constants'
|
||||||
|
StackController = require './stack_controller'
|
||||||
url = require 'url'
|
url = require 'url'
|
||||||
{UrlParam} = require '../constants'
|
{UrlParam} = require '../constants'
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ module.exports = class CraftingTableController extends BaseController
|
|||||||
super options
|
super options
|
||||||
|
|
||||||
@_parser = new InventoryParser
|
@_parser = new InventoryParser
|
||||||
|
@_resetStackControllers()
|
||||||
|
|
||||||
@model.modPack.on Event.change, => @onModPackChanged()
|
@model.modPack.on Event.change, => @onModPackChanged()
|
||||||
|
|
||||||
@@ -99,16 +101,17 @@ module.exports = class CraftingTableController extends BaseController
|
|||||||
@$makeList.empty()
|
@$makeList.empty()
|
||||||
@$resultList.empty()
|
@$resultList.empty()
|
||||||
|
|
||||||
|
makeController = (name, stack)=>
|
||||||
|
controller = new StackController model:stack, modPack:@model.modPack
|
||||||
|
controller.render()
|
||||||
|
this["$#{name}List"].append controller.$el
|
||||||
|
this["_#{name}Controllers"].push controller
|
||||||
|
|
||||||
if @model.plan?
|
if @model.plan?
|
||||||
@model.plan.need.each (stack)=>
|
@_resetStackControllers()
|
||||||
name = @model.modPack.findName stack.itemSlug
|
@model.plan.need.each (stack)=> makeController 'need', stack
|
||||||
@$needList.append "<li><span class='quantity'>#{stack.quantity}</span> #{name}</li>"
|
@model.plan.make.each (stack)=> makeController 'make', stack
|
||||||
@model.plan.make.each (stack)=>
|
@model.plan.result.each (stack)=> makeController 'result', stack
|
||||||
name = @model.modPack.findName stack.itemSlug
|
|
||||||
@$makeList.append "<li><span class='quantity'>#{stack.quantity}</span> #{name}</li>"
|
|
||||||
@model.plan.result.each (stack)=>
|
|
||||||
name = @model.modPack.findName stack.itemSlug
|
|
||||||
@$resultList.append "<li><span class='quantity'>#{stack.quantity}</span> #{name}</li>"
|
|
||||||
|
|
||||||
super
|
super
|
||||||
|
|
||||||
@@ -133,6 +136,11 @@ module.exports = class CraftingTableController extends BaseController
|
|||||||
@model.craft()
|
@model.craft()
|
||||||
@refresh()
|
@refresh()
|
||||||
|
|
||||||
|
_resetStackControllers: ->
|
||||||
|
@_needControllers = []
|
||||||
|
@_makeControllers = []
|
||||||
|
@_resultControllers = []
|
||||||
|
|
||||||
_updateNameAutocomplete: ->
|
_updateNameAutocomplete: ->
|
||||||
onChanged = => @onNameFieldChanged()
|
onChanged = => @onNameFieldChanged()
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
###
|
###
|
||||||
# Crafting Guide - mod_version_controller.coffee
|
Crafting Guide - mod_version_controller.coffee
|
||||||
#
|
|
||||||
# Copyright (c) 2014 by Redwood Labs
|
Copyright (c) 2014 by Redwood Labs
|
||||||
# All rights reserved.
|
All rights reserved.
|
||||||
###
|
###
|
||||||
|
|
||||||
BaseController = require './base_controller'
|
BaseController = require './base_controller'
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
###
|
||||||
|
Crafting Guide - stack_controller.coffee
|
||||||
|
|
||||||
|
Copyright (c) 2014 by Redwood Labs
|
||||||
|
All rights reserved.
|
||||||
|
###
|
||||||
|
|
||||||
|
BaseController = require './base_controller'
|
||||||
|
{ImageUrl} = require '../constants'
|
||||||
|
|
||||||
|
########################################################################################################################
|
||||||
|
|
||||||
|
module.exports = class StackController 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.templateName = 'stack'
|
||||||
|
super options
|
||||||
|
|
||||||
|
@modPack = options.modPack
|
||||||
|
@_loadImage()
|
||||||
|
|
||||||
|
# Event Methods ################################################################################
|
||||||
|
|
||||||
|
onImageLoaded: ->
|
||||||
|
return if @_image.loaded
|
||||||
|
|
||||||
|
logger.trace "#{@constructor.name}.onImageLoaded(#{@_image.src})"
|
||||||
|
@_image.loaded = true
|
||||||
|
@$image.attr 'src', @_image.src
|
||||||
|
|
||||||
|
# BaseController Overrides #####################################################################
|
||||||
|
|
||||||
|
onDidRender: ->
|
||||||
|
@$image = @$('img')
|
||||||
|
@$nameField = @$('.name')
|
||||||
|
@$quantityField = @$('.quantity')
|
||||||
|
super
|
||||||
|
|
||||||
|
refresh: ->
|
||||||
|
{itemName} = @_gatherData()
|
||||||
|
@$nameField.html itemName
|
||||||
|
@$quantityField.html @model.quantity
|
||||||
|
@$image.attr 'src', (if @_image?.loaded then @_image.src else '/images/unknown.png')
|
||||||
|
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
|
||||||
|
|
||||||
|
_loadImage: ->
|
||||||
|
{itemSlug, modSlug} = @_gatherData()
|
||||||
|
url = ImageUrl(modSlug:modSlug, itemSlug:itemSlug)
|
||||||
|
return if @$image?.attr('src').indexOf(url) is -1
|
||||||
|
|
||||||
|
@_image = new Image()
|
||||||
|
@_image.loaded = false
|
||||||
|
@_image.onload = => @onImageLoaded()
|
||||||
|
@_image.src = url
|
||||||
|
logger.verbose "loading image: #{url}"
|
||||||
@@ -17,6 +17,7 @@ module.exports = class Item extends BaseModel
|
|||||||
if not attributes.name? then throw new Error 'attributes.name is required'
|
if not attributes.name? then throw new Error 'attributes.name is required'
|
||||||
|
|
||||||
attributes.isGatherable ?= false
|
attributes.isGatherable ?= false
|
||||||
|
attributes.modVersion ?= null
|
||||||
attributes.recipes ?= []
|
attributes.recipes ?= []
|
||||||
attributes.slug ?= _.slugify attributes.name
|
attributes.slug ?= _.slugify attributes.name
|
||||||
attributes.stackSize ?= Item.DEFAULT_STACK_SIZE
|
attributes.stackSize ?= Item.DEFAULT_STACK_SIZE
|
||||||
|
|||||||
@@ -17,9 +17,10 @@ module.exports = class ModVersion extends BaseModel
|
|||||||
if _.isEmpty(attributes.version) then throw new Error 'version cannot be empty'
|
if _.isEmpty(attributes.version) then throw new Error 'version cannot be empty'
|
||||||
|
|
||||||
attributes.description ?= ''
|
attributes.description ?= ''
|
||||||
attributes.items ?= {}
|
|
||||||
attributes.enabled ?= attributes.name in RequiredMods
|
attributes.enabled ?= attributes.name in RequiredMods
|
||||||
|
attributes.items ?= {}
|
||||||
attributes.names ?= {}
|
attributes.names ?= {}
|
||||||
|
attributes.slug ?= _.slugify attributes.name
|
||||||
super attributes, options
|
super attributes, options
|
||||||
|
|
||||||
# Public Methods ###############################################################################
|
# Public Methods ###############################################################################
|
||||||
@@ -27,6 +28,7 @@ module.exports = class ModVersion extends BaseModel
|
|||||||
addItem: (item)->
|
addItem: (item)->
|
||||||
if @items[item.slug]? then throw new Error "duplicate item for #{item.slug}"
|
if @items[item.slug]? then throw new Error "duplicate item for #{item.slug}"
|
||||||
@items[item.slug] = item
|
@items[item.slug] = item
|
||||||
|
item.modVersion = this
|
||||||
return this
|
return this
|
||||||
|
|
||||||
compareTo: (that)->
|
compareTo: (that)->
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ _.mixin
|
|||||||
|
|
||||||
result = text.toLowerCase()
|
result = text.toLowerCase()
|
||||||
result = result.replace /[^a-zA-Z0-9_]/g, '_'
|
result = result.replace /[^a-zA-Z0-9_]/g, '_'
|
||||||
result = result.replace /_+/, '_'
|
result = result.replace /__+/, '_'
|
||||||
result = result.replace /_$/, ''
|
result = result.replace /_$/, ''
|
||||||
result = result.replace /^_/, ''
|
result = result.replace /^_/, ''
|
||||||
return result
|
return result
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
//-
|
||||||
|
//- Crafting Guide - stack.jade
|
||||||
|
//-
|
||||||
|
//- Copyright (c) 2014 by Redwood Labs
|
||||||
|
//- All rights reserved.
|
||||||
|
//-
|
||||||
|
|
||||||
|
li.view__stack
|
||||||
|
p.quantity
|
||||||
|
a.name: p
|
||||||
|
img(src='')
|
||||||
Reference in New Issue
Block a user