Allow user to select actual version of a mod

This commit is contained in:
Andrew Miner
2015-01-22 12:06:47 -08:00
parent 6ef3473534
commit 64b6b97807
10 changed files with 93 additions and 52 deletions
+1
View File
@@ -10,6 +10,7 @@ All rights reserved.
@import 'feedback'; @import 'feedback';
@import 'inventory'; @import 'inventory';
@import 'item_page'; @import 'item_page';
@import 'mod';
@import 'mod_pack'; @import 'mod_pack';
@import 'recipe'; @import 'recipe';
@import 'stack'; @import 'stack';
+35
View File
@@ -0,0 +1,35 @@
/*
Crafting Table - mod.scss
Copyright (c) 2014-2015 by Redwood Labs
All rights reserved.
*/
.view__mod {
position: relative; width: 100%;
padding: 1em;
div, p {
display: inline-block;
}
.version {
position: relative; width: 10em;
margin-right: 1em;
}
.name {
position: relative; width: 15em;
margin-right: 1em;
p {
font-family: $font-family-normal;
font-size: $font-size-normal;
// text-decoration: underline;
}
}
&.disabled {
p { color: $color-gray-light; }
}
}
+8 -17
View File
@@ -7,21 +7,12 @@ All rights reserved.
.view__mod_pack { .view__mod_pack {
input { border: 0; font-size: 1.5em; width: 90%; } input {
border: 0; font-size: 1.5em; width: 90%;
}
table { .mods {
margin: 0 auto; position: relative; width: 100%;
width: 100%;
td {
position: relative; height: 2 * $font-size-normal;
padding: 0 1em;
vertical-align: middle;
}
td:nth-child(1) { width: 5%; }
td:nth-child(2) { width: 30%; }
td:nth-child(3) { width: 65%; border-left: 0.1em solid $color-brick-light; }
} }
.panel { .panel {
@@ -29,13 +20,13 @@ All rights reserved.
} }
.toolbar { .toolbar {
position: relative; width: 35%; position: relative; width: 100%;
margin-top: 1em; margin-top: 1em;
padding: 1em 1em; padding: 1em 1em;
text-align: center; text-align: left;
button { button {
position: relative; width: 66%; position: relative; width: 20em;
} }
} }
} }
+7
View File
@@ -28,3 +28,10 @@ If you've seen it before, go look again. There's a whole new site now, which sup
* You can now make many different items at once (e.g., a whole NanoSuit) * You can now make many different items at once (e.g., a whole NanoSuit)
[crafting-guide.com](http://crafting-guide.com) [crafting-guide.com](http://crafting-guide.com)
########################################################################################################################
A few more updates to report! First, now your preferences for which mods are active and whether tools are included
will be remembered between visits. Second, I've finished adding support for Thermal Expansion 4. The crafting algorithm
doesn't yet taken into account the ore-doubling/tripling machinery, but all the recipes for the entire mod are present
and functional. I'll work on using the machines in a future update. Next up: IC2 Experimental!
+2 -1
View File
@@ -52,7 +52,8 @@ ModelState.failed = 'failed'
exports.Url = Url = {} exports.Url = Url = {}
Url.itemIcon = _.template "/data/<%= modSlug %>/<%= modVersion %>/images/<%= slug %>.png" Url.itemIcon = _.template "/data/<%= modSlug %>/<%= modVersion %>/images/<%= slug %>.png"
Url.item = _.template "/item/<%= slug %>" Url.item = _.template "/item/<%= slug %>"
Url.mod = _.template "/data/<%= modSlug %>/mod.cg" Url.mod = _.template "/mod/<%= modSlug %>"
Url.modData = _.template "/data/<%= modSlug %>/mod.cg"
Url.modVersion = _.template "/data/<%= modSlug %>/<%= modVersion %>/mod-version.cg" Url.modVersion = _.template "/data/<%= modSlug %>/<%= modVersion %>/mod-version.cg"
exports.UrlParam = UrlParam = {} exports.UrlParam = UrlParam = {}
+29 -22
View File
@@ -9,6 +9,7 @@ BaseController = require './base_controller'
{Event} = require '../constants' {Event} = require '../constants'
Mod = require '../models/mod' Mod = require '../models/mod'
{RequiredMods} = require '../constants' {RequiredMods} = require '../constants'
{Url} = require '../constants'
######################################################################################################################## ########################################################################################################################
@@ -25,38 +26,44 @@ module.exports = class ModController extends BaseController
# Event Methods ################################################################################ # Event Methods ################################################################################
onEnabledChanged: -> onVersionChanged: ->
return unless @rendered @model.activeVersion = @$version.val()
enabled = @$(':checked').length > 0
if enabled
@model.activeVersion = Mod.Version.Latest
else
@model.activeVersion = Mod.Version.None
@_plan.removeUncraftableItems()
# BaseController Overrides ##################################################################### # BaseController Overrides #####################################################################
onDidRender: -> onDidRender: ->
@$enabled = @$('td:nth-child(1) input') @$version = @$('.version')
@$name = @$('td:nth-child(2) p') @$nameLink = @$('.name a')
@$description = @$('td:nth-child(3) p') @$nameText = @$('.name p')
@$description = @$('.description p')
super super
refresh: -> refresh: ->
if @model.slug in RequiredMods if @model.activeVersion is Mod.Version.None
@$enabled.attr 'checked', 'checked' @$el.addClass 'disabled'
@$enabled.attr 'disabled', 'disabled'
else else
@$enabled.removeAttr 'disabled' @$el.removeClass 'disabled'
if @model.activeVersion is Mod.Version.None
@$enabled.removeAttr 'checked'
else
@$enabled.attr 'checked', 'checked'
@$name.html "#{@model.name}" @$version.empty()
@$description.html "#{@model.description}"
if not (@model.slug in RequiredMods)
option = $("<option value=\"none\">Disabled</option>")
if @model.activeVersion is Mod.Version.None
option.attr 'selected', 'selected'
@$version.append option
@model.eachModVersion (modVersion)=>
option = $("<option value=\"#{modVersion.version}\">#{modVersion.version}</option>")
if modVersion is @model.activeModVersion
option.attr 'selected', 'selected'
@$version.append option
# @$nameLink.attr 'href', Url.mod modSlug:@model.slug
@$nameText.html @model.name
@$description.html @model.description
# Backbone.View Overrides ###################################################################### # Backbone.View Overrides ######################################################################
events: events:
'change input[type="checkbox"]': 'onEnabledChanged' 'change .version': 'onVersionChanged'
@@ -34,7 +34,7 @@ module.exports = class ModPackController extends BaseController
# BaseController Overrides ##################################################################### # BaseController Overrides #####################################################################
onDidRender: -> onDidRender: ->
@$table = @$('table') @$mods = @$('.mods')
@$toolbar = @$('.toolbar') @$toolbar = @$('.toolbar')
super super
@@ -56,7 +56,8 @@ module.exports = class ModPackController extends BaseController
controller.render() controller.render()
@_controllers.push controller @_controllers.push controller
controller.$el.hide duration:0 controller.$el.hide duration:0
@$table.append controller.$el
@$mods.append controller.$el
controller.$el.slideDown duration:Duration.normal controller.$el.slideDown duration:Duration.normal
index++ index++
+1 -1
View File
@@ -130,7 +130,7 @@ module.exports = class Mod extends BaseModel
return null # prevent calling `set` return null # prevent calling `set`
url: -> url: ->
return Url.mod modSlug:@slug return Url.modData modSlug:@slug
# Private Methods ############################################################################## # Private Methods ##############################################################################
+6 -4
View File
@@ -5,7 +5,9 @@
//- All rights reserved. //- All rights reserved.
//- //-
tr .view__mod
td: input(type="checkbox") select.version
td: p option(value="none") None
td: p .name
a: p
.description: p
+1 -5
View File
@@ -11,10 +11,6 @@
p Mod Pack p Mod Pack
.panel .panel
table .mods
tr
td &nbsp;
td &nbsp;
.toolbar .toolbar
button(name="suggestMod") suggest a mod button(name="suggestMod") suggest a mod