Upgraded level info popover; made it a click instead of a hover; added view scores button to it when level has been completed.

This commit is contained in:
Nick Winter 2015-02-03 18:25:38 -08:00
parent 762192a4a7
commit 5542bd8a89
6 changed files with 83 additions and 84 deletions

Binary file not shown.

After

(image error) Size: 63 KiB

Binary file not shown.

After

(image error) Size: 12 KiB

View file

@ -344,6 +344,7 @@
leaderboard: leaderboard:
leaderboard: "Leaderboard" leaderboard: "Leaderboard"
view_other_solutions: "View Other Solutions" view_other_solutions: "View Other Solutions"
scores: "Scores"
top_solutions: "Top Solutions" top_solutions: "Top Solutions"
day: "Today" day: "Today"
week: "This Week" week: "This Week"

View file

@ -201,37 +201,61 @@ $gameControlMargin: 30px
display: none display: none
position: absolute position: absolute
z-index: 3 z-index: 3
padding: 10px width: 362px
border-width: 16px 12px //min-height: 179px
// Using modernizr-mixin for compat detection padding: 17px 20px 20px 20px
@include yep(borderimage) border: 0
border-style: solid background: transparent url(/images/pages/play/level-info-background.png) no-repeat center center
border-image: url(/images/level/popover_border_background.png) 16 12 fill round background-size: 100% 100%
@include nope(borderimage)
background-color: rgb(247, 242, 218)
.level-info.complete h3:after
content: " - Complete!"
color: green
.level-info.started h3:after
content: " - Started"
color: desaturate(green, 50%)
.level-info .level-info
h3 h3
margin-top: 0 color: rgb(232, 217, 87)
margin-bottom: 0px text-shadow: black 2px 2px 0, black -2px -2px 0, black 2px -2px 0, black -2px 2px 0, black 2px 0px 0, black 0px -2px 0, black -2px 0px 0, black 0px 2px 0
padding: 0 2px
margin: 0 0 10px 31px
white-space: nowrap
overflow: hidden
text-overflow: ellipsis
.level-description .level-description
color: black color: black
text-shadow: 0 1px 0 white
.start-level .level-status
display: block background: transparent url(/images/pages/play/level-info-status-spritesheet.png) no-repeat 0 0
margin: 10px auto 0 auto width: 60px
width: 200px height: 60px
position: absolute
left: -15px
top: -15px
&.complete .level-status
background-position: -60px 0
&.premium .level-status
background-position: -120px 0
&.complete.premium .level-status
background-position: -180px 0
.start-level
min-width: 200px
display: block
margin: 10px auto 0 auto
&.complete
.start-level, .view-solutions
min-width: initial
display: inline-block
width: calc(50% - 5px)
.start-level
margin: 10px 0 0 5px
.view-solutions
margin: 10px 5px 0 0
.campaign-switch .campaign-switch
color: purple color: purple
position: absolute position: absolute
@ -440,16 +464,7 @@ $gameControlMargin: 30px
z-index: 2 z-index: 2
body:not(.ipad) #campaign-view
.level-info-container
pointer-events: none
body.ipad #campaign-view body.ipad #campaign-view
// iPad only supports up to Kithgard Gates for now. // iPad only supports up to Kithgard Gates for now.
.campaign-switch .campaign-switch
display: none display: none
.old-levels
display: none

View file

@ -19,7 +19,9 @@
img.banner(src="/images/pages/play/level-banner-started.png") img.banner(src="/images/pages/play/level-banner-started.png")
div(style="left: #{level.position.x}%; bottom: #{level.position.y}%", class="level-shadow" + (level.next ? " next" : "") + " " + (levelStatusMap[level.slug] || "")) div(style="left: #{level.position.x}%; bottom: #{level.position.y}%", class="level-shadow" + (level.next ? " next" : "") + " " + (levelStatusMap[level.slug] || ""))
.level-info-container(data-level-slug=level.slug, data-level-path=level.levelPath || 'level', data-level-name=level.name) .level-info-container(data-level-slug=level.slug, data-level-path=level.levelPath || 'level', data-level-name=level.name)
div(class="level-info " + (levelStatusMap[level.slug] || "")) - var playCount = levelPlayCountMap[level.slug]
div(class="level-info " + (levelStatusMap[level.slug] || "") + (level.requiresSubscription ? " premium" : ""))
.level-status
h3= i18n(level, 'name') + (level.disabled ? " (Coming soon!)" : (level.locked ? " (Locked)" : "")) h3= i18n(level, 'name') + (level.disabled ? " (Coming soon!)" : (level.locked ? " (Locked)" : ""))
- var description = i18n(level, 'description') || level.description || "" - var description = i18n(level, 'description') || level.description || ""
.level-description!= marked(description) .level-description!= marked(description)
@ -30,16 +32,17 @@
strong(data-i18n="play.awaiting_levels_adventurer") Sign up as an Adventurer strong(data-i18n="play.awaiting_levels_adventurer") Sign up as an Adventurer
span.spl(data-i18n="play.awaiting_levels_adventurer_suffix") to be the first to play new levels. span.spl(data-i18n="play.awaiting_levels_adventurer_suffix") to be the first to play new levels.
- var playCount = levelPlayCountMap[level.slug] if !level.disabled && !level.locked
if playCount && playCount.sessions > 20 if playCount && playCount.sessions
div .play-counts.hidden
span.spr #{playCount.sessions} span.spl.spr= playCount.sessions
span(data-i18n="play.players") players span(data-i18n="play.players") players
span.spr , #{Math.round(playCount.playtime / 3600)} span.spr , #{Math.round(playCount.playtime / 3600)}
span(data-i18n="play.hours_played") hours played span(data-i18n="play.hours_played") hours played
if levelStatusMap[level.slug] === 'complete'
if isIPadApp && !level.disabled && !level.locked button.btn.btn-warning.btn.btn-lg.btn-illustrated.view-solutions(data-level-slug=level.slug)
button.btn.btn-success.btn-lg.start-level(data-i18n="common.play") Play span(data-i18n="leaderboard.scores")
button.btn.btn-success.btn.btn-lg.btn-illustrated.start-level(data-i18n="common.play") Play
else if level.unlocksHero && !level.purchasedHero else if level.unlocksHero && !level.purchasedHero
img.hero-portrait(src="/file/db/thang.type/#{level.unlocksHero}/portrait.png", style="left: #{level.position.x}%; bottom: #{level.position.y}%;") img.hero-portrait(src="/file/db/thang.type/#{level.unlocksHero}/portrait.png", style="left: #{level.position.x}%; bottom: #{level.position.y}%;")

View file

@ -39,9 +39,7 @@ module.exports = class CampaignView extends RootView
'click .level a': 'onClickLevel' 'click .level a': 'onClickLevel'
'dblclick .level a': 'onDoubleClickLevel' 'dblclick .level a': 'onDoubleClickLevel'
'click .level-info-container .start-level': 'onClickStartLevel' 'click .level-info-container .start-level': 'onClickStartLevel'
'mouseenter .level a': 'onMouseEnterLevel' 'click .level-info-container .view-solutions': 'onClickViewSolutions'
'mouseleave .level a': 'onMouseLeaveLevel'
'mousemove .map': 'onMouseMoveMap'
'click #volume-button': 'onToggleVolume' 'click #volume-button': 'onToggleVolume'
constructor: (options, @terrain='dungeon') -> constructor: (options, @terrain='dungeon') ->
@ -105,6 +103,7 @@ module.exports = class CampaignView extends RootView
getLevelPlayCounts: -> getLevelPlayCounts: ->
return unless me.isAdmin() return unless me.isAdmin()
return # TODO: get rid of all this? It's redundant with new campaign editor analytics, unless we want to show player counts on leaderboards buttons.
success = (levelPlayCounts) => success = (levelPlayCounts) =>
return if @destroyed return if @destroyed
for level in levelPlayCounts for level in levelPlayCounts
@ -302,23 +301,9 @@ module.exports = class CampaignView extends RootView
levelOriginal = levelElement.data('level-original') levelOriginal = levelElement.data('level-original')
if @editorMode if @editorMode
return @trigger 'level-clicked', levelOriginal return @trigger 'level-clicked', levelOriginal
level = _.find _.values(@campaign.get('levels')), slug: levelSlug @$levelInfo = @$el.find(".level-info-container[data-level-slug=#{levelSlug}]").show()
if application.isIPadApp @adjustLevelInfoPosition e
@$levelInfo = @$el.find(".level-info-container[data-level-slug=#{levelSlug}]").show() @endHighlight()
@adjustLevelInfoPosition e
@endHighlight()
else
if level.requiresSubscription and @requiresSubscription and not @levelStatusMap[level.slug] and not level.adventurer
@openModalView new SubscribeModal()
window.tracker?.trackEvent 'Show subscription modal', category: 'Subscription', label: 'map level clicked', level: levelSlug
else if $(e.target).attr('disabled') and not me.isAdmin()
Backbone.Mediator.publish 'router:navigate', route: '/contribute/adventurer'
return
else if $(e.target).parent().hasClass 'locked'
return
else
@startLevel levelElement
window.tracker?.trackEvent 'Clicked Level', category: 'World Map', levelID: levelSlug, ['Google Analytics']
onDoubleClickLevel: (e) -> onDoubleClickLevel: (e) ->
return unless @editorMode return unless @editorMode
@ -328,8 +313,16 @@ module.exports = class CampaignView extends RootView
onClickStartLevel: (e) -> onClickStartLevel: (e) ->
levelElement = $(e.target).parents('.level-info-container') levelElement = $(e.target).parents('.level-info-container')
@startLevel levelElement levelSlug = levelElement.data('level-slug')
window.tracker?.trackEvent 'Clicked Start Level', category: 'World Map', levelID: levelElement.data('level-slug'), ['Google Analytics'] levelOriginal = levelElement.data('level-original')
level = _.find _.values(@campaign.get('levels')), slug: levelSlug
if level.requiresSubscription and @requiresSubscription and not @levelStatusMap[level.slug] and not level.adventurer
@openModalView new SubscribeModal()
window.tracker?.trackEvent 'Show subscription modal', category: 'Subscription', label: 'map level clicked', level: levelSlug
else
@startLevel levelElement
window.tracker?.trackEvent 'Clicked Start Level', category: 'World Map', levelID: levelSlug, ['Google Analytics']
startLevel: (levelElement) -> startLevel: (levelElement) ->
@setupManager?.destroy() @setupManager?.destroy()
@ -337,23 +330,10 @@ module.exports = class CampaignView extends RootView
@setupManager.open() @setupManager.open()
@$levelInfo?.hide() @$levelInfo?.hide()
onMouseEnterLevel: (e) -> onClickViewSolutions: (e) ->
return if application.isIPadApp levelElement = $(e.target).parents('.level-info-container')
return if @editorMode levelSlug = levelElement.data('level-slug')
levelSlug = $(e.target).parents('.level').data('level-slug') @showLeaderboard levelSlug
@$levelInfo = @$el.find(".level-info-container[data-level-slug=#{levelSlug}]").show()
@adjustLevelInfoPosition e
@endHighlight()
onMouseLeaveLevel: (e) ->
return if application.isIPadApp
levelSlug = $(e.target).parents('.level').data('level-slug')
@$el.find(".level-info-container[data-level-slug='#{levelSlug}']").hide()
@$levelInfo = null
onMouseMoveMap: (e) ->
return if application.isIPadApp
@adjustLevelInfoPosition e
adjustLevelInfoPosition: (e) -> adjustLevelInfoPosition: (e) ->
return unless @$levelInfo return unless @$levelInfo
@ -366,7 +346,7 @@ module.exports = class CampaignView extends RootView
@$levelInfo.css('left', Math.min(Math.max(margin, mapX - width / 2), @$map.width() - width - margin)) @$levelInfo.css('left', Math.min(Math.max(margin, mapX - width / 2), @$map.width() - width - margin))
height = @$levelInfo.outerHeight() height = @$levelInfo.outerHeight()
top = mapY - @$levelInfo.outerHeight() - 60 top = mapY - @$levelInfo.outerHeight() - 60
if top < 20 if top < 100
top = mapY + 60 top = mapY + 60
@$levelInfo.css('top', top) @$levelInfo.css('top', top)