mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Set up thang types to now have a raster portrait icon if we want to give them custom ones not based on vector artwork.
This commit is contained in:
parent
9ee3c6f3fe
commit
f8d4e42c67
8 changed files with 24 additions and 20 deletions
|
@ -264,7 +264,10 @@ module.exports = class ThangType extends CocoModel
|
|||
@wizardType.fetch()
|
||||
@wizardType
|
||||
|
||||
getPortraitURL: -> "/file/db/thang.type/#{@get('original')}/portrait.png"
|
||||
getPortraitURL: ->
|
||||
if iconURL = @get('rasterIcon')
|
||||
return "/file/#{iconURL}"
|
||||
"/file/db/thang.type/#{@get('original')}/portrait.png"
|
||||
|
||||
# Item functions
|
||||
|
||||
|
|
|
@ -124,6 +124,7 @@ _.extend ThangTypeSchema.properties,
|
|||
type: 'number'
|
||||
positions: PositionsSchema
|
||||
raster: {type: 'string', format: 'image-file', title: 'Raster Image'}
|
||||
rasterIcon: { type: 'string', format: 'image-file', title: 'Raster Image Icon' }
|
||||
colorGroups: c.object
|
||||
title: 'Color Groups'
|
||||
additionalProperties:
|
||||
|
|
|
@ -5,7 +5,6 @@ div.editor-nano-container.nano
|
|||
for group in groups
|
||||
h4= group.name
|
||||
for thangType in group.thangs
|
||||
div.add-thang-palette-icon(data-thang-type=thangType.name)
|
||||
- path = '/file/db/thang.type/'+thangType.original+'/portrait.png'
|
||||
img(title="Add " + thangType.name, src=path, alt="")
|
||||
div.add-thang-palette-icon(data-thang-type=thangType.get('name'))
|
||||
img(title="Add " + thangType.get('name'), src=thangType.getPortraitURL(), alt="")
|
||||
div.clearfix
|
|
@ -12,14 +12,13 @@ table.table
|
|||
th(data-i18n="general.description") Description
|
||||
th(data-i18n="general.version") Version
|
||||
|
||||
for data in documents
|
||||
- data = data.attributes;
|
||||
for thang in documents
|
||||
tr
|
||||
td
|
||||
- path = '/file/db/thang.type/'+data.original+'/portrait.png'
|
||||
img(title="Add " + data.name, src=path, alt="").portrait
|
||||
img(title="Add " + thang.get('name'), src=thang.getPortraitURL(), alt="").portrait
|
||||
td
|
||||
a(href="/editor/thang/#{data.slug || data._id}")
|
||||
| #{data.name}
|
||||
td.body-row #{data.description}
|
||||
td #{data.version.major}.#{data.version.minor}
|
||||
a(href="/editor/thang/#{thang.get('slug') || thang.id}")
|
||||
| #{thang.get('name')}
|
||||
td.body-row #{thang.get('description')}
|
||||
- var version = thang.get('version')
|
||||
td #{version.major}.#{version.minor}
|
|
@ -4,7 +4,7 @@ ThangType = require 'models/ThangType'
|
|||
CocoCollection = require 'collections/CocoCollection'
|
||||
|
||||
class ThangTypeSearchCollection extends CocoCollection
|
||||
url: '/db/thang.type?project=true'
|
||||
url: '/db/thang.type?project=original,name,version,description,slug,kind,rasterIcon'
|
||||
model: ThangType
|
||||
|
||||
addTerm: (term) ->
|
||||
|
@ -33,18 +33,18 @@ module.exports = class AddThangsView extends CocoView
|
|||
else
|
||||
models = @supermodel.getModels(ThangType)
|
||||
|
||||
thangTypes = (thangType.attributes for thangType in models)
|
||||
thangTypes = _.uniq thangTypes, false, 'original'
|
||||
thangTypes = _.reject thangTypes, kind: 'Mark'
|
||||
thangTypes = _.uniq models, false, (thangType) -> thangType.get('original')
|
||||
thangTypes = _.reject thangTypes, (thangType) -> thangType.get('kind') is 'Mark'
|
||||
groupMap = {}
|
||||
for thangType in thangTypes
|
||||
groupMap[thangType.kind] ?= []
|
||||
groupMap[thangType.kind].push thangType
|
||||
kind = thangType.get('kind')
|
||||
groupMap[kind] ?= []
|
||||
groupMap[kind].push thangType
|
||||
|
||||
groups = []
|
||||
for groupName in Object.keys(groupMap).sort()
|
||||
someThangTypes = groupMap[groupName]
|
||||
someThangTypes = _.sortBy someThangTypes, 'name'
|
||||
someThangTypes = _.sortBy someThangTypes, (thangType) -> thangType.get('name')
|
||||
group =
|
||||
name: groupName
|
||||
thangs: someThangTypes
|
||||
|
|
|
@ -119,7 +119,7 @@ module.exports = class ThangsTabView extends CocoView
|
|||
$('#thangs-list').bind 'mousewheel', @preventBodyScrollingInThangList
|
||||
@$el.find('#extant-thangs-filter button:first').button('toggle')
|
||||
$(window).resize @onWindowResize
|
||||
@addThangsView = @insertSubView new AddThangsView world: @world, supermodel: @supermodel
|
||||
@addThangsView = @insertSubView new AddThangsView world: @world
|
||||
@buildInterface() # refactor to not have this trigger when this view re-renders?
|
||||
if @thangsTreema.data.length
|
||||
@$el.find('#canvas-overlay').css('display', 'none')
|
||||
|
|
|
@ -6,6 +6,7 @@ module.exports = class ThangTypeSearchView extends SearchView
|
|||
model: require 'models/ThangType'
|
||||
modelURL: '/db/thang.type'
|
||||
tableTemplate: require 'templates/editor/thang/table'
|
||||
projection: ['original', 'name', 'version', 'description', 'slug', 'kind', 'rasterIcon']
|
||||
|
||||
getRenderData: ->
|
||||
context = super()
|
||||
|
|
|
@ -21,6 +21,7 @@ ThangTypeHandler = class ThangTypeHandler extends Handler
|
|||
'colorGroups'
|
||||
'kind'
|
||||
'raster'
|
||||
'rasterIcon'
|
||||
]
|
||||
|
||||
hasAccess: (req) ->
|
||||
|
|
Loading…
Reference in a new issue