From ee75415729d9ce59de65b2a969265406c9ef1c26 Mon Sep 17 00:00:00 2001 From: Andrew Miner Date: Tue, 10 Mar 2015 09:57:23 -0700 Subject: [PATCH] Allow each mod to have a default version When a visitor arrives at the site for the first time, this will ensure they have a certain set of mods on/off. Right now, that means IC2-Classic is off by default, and everything else is on. --- .gitignore | 2 +- scripts/sitemap | 2 +- src/coffee/constants.coffee | 19 +-- .../controllers/item_page_controller.coffee | 6 +- .../controllers/mod_pack_controller.coffee | 1 - src/coffee/crafting_guide_router.coffee | 4 +- src/coffee/models/storage.coffee | 25 +-- src/coffee/views.js | 157 ------------------ 8 files changed, 29 insertions(+), 187 deletions(-) delete mode 100644 src/coffee/views.js diff --git a/.gitignore b/.gitignore index e3b12347e..e0e0ab3c7 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ build dist node_modules -src/scripts/views.js +src/coffee/views.js diff --git a/scripts/sitemap b/scripts/sitemap index a68d45077..5986ae28e 100755 --- a/scripts/sitemap +++ b/scripts/sitemap @@ -26,7 +26,7 @@ urls = [ "#{base}/craft/" ] -for modSlug in DefaultMods +for modSlug, modData of DefaultMods modSlugs[modSlug] = modSlug mod = new Mod slug:modSlug diff --git a/src/coffee/constants.coffee b/src/coffee/constants.coffee index 280aec066..15e27cceb 100644 --- a/src/coffee/constants.coffee +++ b/src/coffee/constants.coffee @@ -6,16 +6,15 @@ All rights reserved. ### # Minecraft must be first -exports.DefaultMods = [ - 'minecraft', - 'applied_energistics_2', - 'buildcraft', - 'enderio', - 'ic2_classic', - 'industrial_craft_2', - 'railcraft', - 'thermal_expansion', -] +exports.DefaultMods = + minecraft: { defaultVersion: '1.7.10' } + applied_energistics_2: { defaultVersion: 'rv1-stable-1' } + buildcraft: { defaultVersion: '6.2.6' } + enderio: { defaultVersion: '2.2.7.235' } + ic2_classic: { defaultVersion: 'none' } + industrial_craft_2: { defaultVersion: '2.2.663' } + railcraft: { defaultVersion: '9.5.0' } + thermal_expansion: { defaultVersion: '4.0.0B6-23' } exports.Duration = Duration = {} Duration.snap = 200 diff --git a/src/coffee/controllers/item_page_controller.coffee b/src/coffee/controllers/item_page_controller.coffee index 030872a94..f586c8cdd 100644 --- a/src/coffee/controllers/item_page_controller.coffee +++ b/src/coffee/controllers/item_page_controller.coffee @@ -113,8 +113,6 @@ module.exports = class ItemPageController extends PageController @$byline.fadeOut duration:Duration.fast _refreshDescription: -> - logger.debug "refreshing description" - logger.debug "item.description: #{@model?.item?.description}" description = @model.compileDescription() if description? @$descriptionPanel.html description @@ -189,6 +187,4 @@ module.exports = class ItemPageController extends PageController @model.item = item item.fetch() - item.on Event.sync, => - logger.debug "item loaded" - @refresh() + item.on Event.sync, => @refresh() diff --git a/src/coffee/controllers/mod_pack_controller.coffee b/src/coffee/controllers/mod_pack_controller.coffee index c71118c37..e4252d164 100644 --- a/src/coffee/controllers/mod_pack_controller.coffee +++ b/src/coffee/controllers/mod_pack_controller.coffee @@ -6,7 +6,6 @@ All rights reserved. ### BaseController = require './base_controller' -{DefaultMods} = require '../constants' {Duration} = require '../constants' Mod = require '../models/mod' ModSelectorController = require './mod_selector_controller' diff --git a/src/coffee/crafting_guide_router.coffee b/src/coffee/crafting_guide_router.coffee index ebb654b30..71c5b1690 100644 --- a/src/coffee/crafting_guide_router.coffee +++ b/src/coffee/crafting_guide_router.coffee @@ -49,10 +49,10 @@ module.exports = class CraftingGuideRouter extends Backbone.Router makeResponder = (m)-> return -> m.activeModVersion.fetch() if m.activeModVersion? - for modSlug in DefaultMods + for modSlug, modData of DefaultMods mod = new Mod slug:modSlug mod.on Event.change + ':activeModVersion', makeResponder mod - @storage.register "mod:#{mod.slug}", mod, 'activeVersion' + @storage.register "mod:#{mod.slug}", mod, 'activeVersion', modData.defaultVersion mod.fetch() @modPack.addMod mod diff --git a/src/coffee/models/storage.coffee b/src/coffee/models/storage.coffee index e7bf2e8e2..8f205678c 100644 --- a/src/coffee/models/storage.coffee +++ b/src/coffee/models/storage.coffee @@ -26,17 +26,16 @@ module.exports = class Storage @storage.setItem key, value logger.verbose -> "stored #{value} into #{key}" - register: (key, model, properties...)-> + register: (key, model, property, defaultValue=null)-> modelData = @_models[key] if not modelData? then modelData = @_models[key] = model:model, properties:{} makeStoreMethod = (k, m, p)=> return => @_storeProperty(k, m, p) - for property in properties - continue if modelData.properties[property]? - modelData.properties[property] = property + return if modelData.properties[property]? + modelData.properties[property] = property - @_loadProperty key, model, property - model.on "change:#{property}", makeStoreMethod(key, model, property) + @_loadProperty key, model, property, defaultValue + model.on "change:#{property}", makeStoreMethod(key, model, property) unregister: (key, property)-> modelData = @_models[key] @@ -45,13 +44,19 @@ module.exports = class Storage # Private Methods ############################################################################## - _loadProperty: (key, model, property)-> - value = @load "#{key}:#{property}" - value = JSON.parse(value) if value? - return unless value? + _loadProperty: (key, model, property, defaultValue=null)-> + loadedValue = @load "#{key}:#{property}" + if value? + value = JSON.parse loadedValue + else + value = defaultValue + return unless value? model[property] = value + if value? and not loadedValue? + @_storeProperty key, model, property + _storeProperty: (key, model, property)-> value = JSON.stringify model[property] @store "#{key}:#{property}", value diff --git a/src/coffee/views.js b/src/coffee/views.js deleted file mode 100644 index 11389a338..000000000 --- a/src/coffee/views.js +++ /dev/null @@ -1,157 +0,0 @@ -var jade = jade || require('jade').runtime; - -this["JST"] = this["JST"] || {}; - -this["JST"]["browse_page"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("
\n\n\n\n

Active Mods

");;return buf.join(""); -}; - -this["JST"]["configure_page"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("
\n\n\n\n
");;return buf.join(""); -}; - -this["JST"]["craft_page"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("
");;return buf.join(""); -}; - -this["JST"]["crafting_grid"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("
");;return buf.join(""); -}; - -this["JST"]["crafting_table"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("

Crafting Plan

");;return buf.join(""); -}; - -this["JST"]["feedback"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("

Sending failed. Please try again later.

Feedback

");;return buf.join(""); -}; - -this["JST"]["full_recipe"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("

Ingredients

Produces

");;return buf.join(""); -}; - -this["JST"]["home_page"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("
\n\n\n\n

What's new?

2015-03-01

2015-02-26

This release adds a new section to the item pages called \"Used as Tool to Make\". The new section\nshows all the other items which can be made by that tool. For example, the IC2 Macerator shows\na bunch of things like Iron Dust, Gold Dust, etc.\n

2015-02-24

This release changes the crafting page to let you modify the quantity of items in the \"Items You\nWant\" and \"Items You Have\" section. Let's say you want to make 64 Potions of Healing. You add \"Potion of Healing\" just\nas as you always did, but now you can click on the quantity to change it to whatever you want.

At the same time, I've changed the quantity field to allow up to 9999 of any item. Have fun with\nthose huge builds!\n

2015-02-22

Woo hoo! Or, should I say: Choo choo! I just added support for RailCraft! I also pushed up lots\nof performance improvements (55% faster at computing crafting plans)! Hopefully, you won't\nreally notice anything except that entering new items and computing really complicated crafting\nplans don't take so long.\n

2015-02-19

I just made some major updates to the crafting algorithm. Without getting into details, I'll say\nthat there are a few things you should notice:

  1. it will favor recipes which produce more of an item versus those which produce fewer (e.g.,\nIC2 plates get made with the Block Cutter instead of the Forge Hammer)
  2. metal ingots will frequently (but not always) get crafted using 2x recipes instead of\nsmelting ore directly in a furnace
  3. recipes for vanilla items added by mods are now available (e.g., smelting Iron Dust into Iron\ningots)

2015-02-10

I just pushed up some fixes to avoid confusing various items of the same name from different\nmods. The best example of this are the two Wrenches from Buildcraft and IC2, but there are a\nbunch of others.\n

2015-02-09

This release fixes a number of small issues and improves performance in a number of places. Most\nespecially, all links within the site have been changed to update the page in place without the\nneed to re-download anything. This should make browsing between item pages much faster.\n

2015-02-08

This is the singlest largest expansion of the website yet! Each item from each mod now has its\nown page! This will expand in the future, but for now this shows all the recipes for the item as\nwell as all the closely related items and the others items that can be made using the item.

This also changes things so that links to Crafting Guide from other sites will first go to the\nitem's page (instead of to the crafting plan). Not to worry though... there's still a direct\nlink from each item to the full crafting plan for that item.\n

2015-02-02

Crafting Guide now has support for EnderIO! I tend to add new mods in order of those with the\nmost votes, so remember to suggest your favorites!

");;return buf.join(""); -}; - -this["JST"]["inventory"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("

");;return buf.join(""); -}; - -this["JST"]["inventory_table"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("
");;return buf.join(""); -}; - -this["JST"]["item"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("
");;return buf.join(""); -}; - -this["JST"]["item_group"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("

");;return buf.join(""); -}; - -this["JST"]["item_page"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("

See Crafting Plan

\n\n\n\n

from

Description

Recipes

");;return buf.join(""); -}; - -this["JST"]["minimal_recipe"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("

");;return buf.join(""); -}; - -this["JST"]["mod"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("

");;return buf.join(""); -}; - -this["JST"]["mod_pack"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("

Mod Pack

");;return buf.join(""); -}; - -this["JST"]["mod_page"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("

Offical Home Page

Documentation

Download

\n\n\n\n

");;return buf.join(""); -}; - -this["JST"]["mod_selector"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("

");;return buf.join(""); -}; - -this["JST"]["stack"] = function template(locals) { -var buf = []; -var jade_mixins = {}; -var jade_interp; - -buf.push("");;return buf.join(""); -}; - -if (typeof exports === 'object' && exports) {module.exports = this["JST"];} \ No newline at end of file