Add in next/prev buttons for crafting table

This commit is contained in:
Andrew Miner
2015-01-08 12:34:33 -08:00
parent 9424af9d84
commit fb3db0f393
12 changed files with 662 additions and 7 deletions
+27
View File
@@ -9,13 +9,40 @@ All rights reserved.
min-height: 14em; min-height: 14em;
width: 100%; width: 100%;
.panel { .panel {
position: absolute; top: 5em; right: 2em; bottom: 0; left: 2em; position: absolute; top: 5em; right: 2em; bottom: 0; left: 2em;
background: $color-table-background; background: $color-table-background;
.prev {
background: url('/images/arrow-left-disabled.png');
position: absolute; top: 50%; left: 1em; height: 8em; width: 4em;
@include transform(translateY(-50%));
&.enabled {
background: url('/images/arrow-left.png');
cursor: pointer;
&:hover { background: url('/images/arrow-left-hover.png'); }
}
}
.view__crafting_grid { .view__crafting_grid {
position: absolute; top: 50%; left: 33%; position: absolute; top: 50%; left: 33%;
@include transform(translate(-50%, -50%)); @include transform(translate(-50%, -50%));
} }
.next {
background: url('/images/arrow-right-disabled.png');
position: absolute; top: 50%; right: 1em; height: 8em; width: 4em;
@include transform(translateY(-50%));
&.enabled {
background: url('/images/arrow-right.png');
cursor: pointer;
&:hover { background: url('/images/arrow-right-hover.png'); }
}
}
} }
} }
+554
View File
@@ -0,0 +1,554 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ApplicationVersion</key>
<array>
<string>com.omnigroup.OmniGraffle.MacAppStore</string>
<string>139.18</string>
</array>
<key>CreationDate</key>
<string>2015-01-08 19:09:04 +0000</string>
<key>Creator</key>
<string>Andrew Miner</string>
<key>GraphDocumentVersion</key>
<integer>8</integer>
<key>GuidesLocked</key>
<string>NO</string>
<key>GuidesVisible</key>
<string>YES</string>
<key>ImageCounter</key>
<integer>1</integer>
<key>LinksVisible</key>
<string>NO</string>
<key>MagnetsVisible</key>
<string>NO</string>
<key>MasterSheets</key>
<array/>
<key>ModificationDate</key>
<string>2015-01-08 19:15:47 +0000</string>
<key>Modifier</key>
<string>Andrew Miner</string>
<key>NotesVisible</key>
<string>NO</string>
<key>OriginVisible</key>
<string>NO</string>
<key>PageBreaks</key>
<string>NO</string>
<key>PrintInfo</key>
<dict>
<key>NSBottomMargin</key>
<array>
<string>float</string>
<string>41</string>
</array>
<key>NSHorizonalPagination</key>
<array>
<string>coded</string>
<string>BAtzdHJlYW10eXBlZIHoA4QBQISEhAhOU051bWJlcgCEhAdOU1ZhbHVlAISECE5TT2JqZWN0AIWEASqEhAFxlwCG</string>
</array>
<key>NSLeftMargin</key>
<array>
<string>float</string>
<string>18</string>
</array>
<key>NSPaperSize</key>
<array>
<string>size</string>
<string>{611.99998474121094, 792}</string>
</array>
<key>NSPrintReverseOrientation</key>
<array>
<string>int</string>
<string>0</string>
</array>
<key>NSRightMargin</key>
<array>
<string>float</string>
<string>18</string>
</array>
<key>NSTopMargin</key>
<array>
<string>float</string>
<string>18</string>
</array>
</dict>
<key>ReadOnly</key>
<string>NO</string>
<key>Sheets</key>
<array>
<dict>
<key>ActiveLayerIndex</key>
<integer>0</integer>
<key>AutoAdjust</key>
<false/>
<key>BackgroundGraphic</key>
<dict>
<key>Bounds</key>
<string>{{0, 0}, {40, 80}}</string>
<key>Class</key>
<string>SolidGraphic</string>
<key>ID</key>
<integer>2</integer>
<key>Style</key>
<dict>
<key>shadow</key>
<dict>
<key>Draws</key>
<string>NO</string>
</dict>
<key>stroke</key>
<dict>
<key>Draws</key>
<string>NO</string>
</dict>
</dict>
</dict>
<key>BaseZoom</key>
<integer>0</integer>
<key>CanvasOrigin</key>
<string>{0, 0}</string>
<key>CanvasSize</key>
<string>{40, 80}</string>
<key>ColumnAlign</key>
<integer>1</integer>
<key>ColumnSpacing</key>
<real>36</real>
<key>DisplayScale</key>
<string>1 pt = 1 px</string>
<key>GraphicsList</key>
<array>
<dict>
<key>AllowConnections</key>
<string>NO</string>
<key>AllowLabelDrop</key>
<false/>
<key>AllowToConnect</key>
<false/>
<key>Class</key>
<string>LineGraphic</string>
<key>ID</key>
<integer>3</integer>
<key>Points</key>
<array>
<string>{30, 10}</string>
<string>{10, 40}</string>
<string>{30, 70}</string>
</array>
<key>Style</key>
<dict>
<key>stroke</key>
<dict>
<key>Color</key>
<dict>
<key>b</key>
<string>0.755581</string>
<key>g</key>
<string>0.755568</string>
<key>r</key>
<string>0.755591</string>
</dict>
<key>HeadArrow</key>
<string>0</string>
<key>Legacy</key>
<true/>
<key>TailArrow</key>
<string>0</string>
<key>Width</key>
<real>4</real>
</dict>
</dict>
</dict>
</array>
<key>GridInfo</key>
<dict>
<key>GridSpacing</key>
<real>10</real>
<key>MajorGridSpacing</key>
<integer>10</integer>
<key>ShowsGrid</key>
<string>YES</string>
<key>SnapsToGrid</key>
<string>YES</string>
</dict>
<key>HPages</key>
<integer>1</integer>
<key>KeepToScale</key>
<false/>
<key>Layers</key>
<array>
<dict>
<key>Lock</key>
<string>NO</string>
<key>Name</key>
<string>Layer 1</string>
<key>Print</key>
<string>YES</string>
<key>View</key>
<string>YES</string>
</dict>
</array>
<key>LayoutInfo</key>
<dict>
<key>Animate</key>
<string>NO</string>
<key>circoMinDist</key>
<real>18</real>
<key>circoSeparation</key>
<real>0.0</real>
<key>layoutEngine</key>
<string>dot</string>
<key>neatoSeparation</key>
<real>0.0</real>
<key>twopiSeparation</key>
<real>0.0</real>
</dict>
<key>Orientation</key>
<integer>2</integer>
<key>PrintOnePage</key>
<false/>
<key>RowAlign</key>
<integer>1</integer>
<key>RowSpacing</key>
<real>36</real>
<key>SheetTitle</key>
<string>normal</string>
<key>UniqueID</key>
<integer>1</integer>
<key>VPages</key>
<integer>1</integer>
</dict>
<dict>
<key>ActiveLayerIndex</key>
<integer>0</integer>
<key>AutoAdjust</key>
<false/>
<key>BackgroundGraphic</key>
<dict>
<key>Bounds</key>
<string>{{0, 0}, {40, 80}}</string>
<key>Class</key>
<string>SolidGraphic</string>
<key>ID</key>
<integer>2</integer>
<key>Style</key>
<dict>
<key>shadow</key>
<dict>
<key>Draws</key>
<string>NO</string>
</dict>
<key>stroke</key>
<dict>
<key>Draws</key>
<string>NO</string>
</dict>
</dict>
</dict>
<key>BaseZoom</key>
<integer>0</integer>
<key>CanvasOrigin</key>
<string>{0, 0}</string>
<key>CanvasSize</key>
<string>{40, 80}</string>
<key>ColumnAlign</key>
<integer>1</integer>
<key>ColumnSpacing</key>
<real>36</real>
<key>DisplayScale</key>
<string>1 pt = 1 px</string>
<key>GraphicsList</key>
<array>
<dict>
<key>AllowConnections</key>
<string>NO</string>
<key>AllowLabelDrop</key>
<false/>
<key>AllowToConnect</key>
<false/>
<key>Class</key>
<string>LineGraphic</string>
<key>ID</key>
<integer>3</integer>
<key>Points</key>
<array>
<string>{30, 10}</string>
<string>{10, 40}</string>
<string>{30, 70}</string>
</array>
<key>Style</key>
<dict>
<key>stroke</key>
<dict>
<key>Color</key>
<dict>
<key>b</key>
<string>0.424669</string>
<key>g</key>
<string>0.424661</string>
<key>r</key>
<string>0.424674</string>
</dict>
<key>HeadArrow</key>
<string>0</string>
<key>Legacy</key>
<true/>
<key>TailArrow</key>
<string>0</string>
<key>Width</key>
<real>4</real>
</dict>
</dict>
</dict>
</array>
<key>GridInfo</key>
<dict>
<key>GridSpacing</key>
<real>10</real>
<key>MajorGridSpacing</key>
<integer>10</integer>
<key>ShowsGrid</key>
<string>YES</string>
<key>SnapsToGrid</key>
<string>YES</string>
</dict>
<key>HPages</key>
<integer>1</integer>
<key>KeepToScale</key>
<false/>
<key>Layers</key>
<array>
<dict>
<key>Lock</key>
<string>NO</string>
<key>Name</key>
<string>Layer 1</string>
<key>Print</key>
<string>YES</string>
<key>View</key>
<string>YES</string>
</dict>
</array>
<key>LayoutInfo</key>
<dict>
<key>Animate</key>
<string>NO</string>
<key>circoMinDist</key>
<real>18</real>
<key>circoSeparation</key>
<real>0.0</real>
<key>layoutEngine</key>
<string>dot</string>
<key>neatoSeparation</key>
<real>0.0</real>
<key>twopiSeparation</key>
<real>0.0</real>
</dict>
<key>Orientation</key>
<integer>2</integer>
<key>PrintOnePage</key>
<false/>
<key>RowAlign</key>
<integer>1</integer>
<key>RowSpacing</key>
<real>36</real>
<key>SheetTitle</key>
<string>hover</string>
<key>UniqueID</key>
<integer>2</integer>
<key>VPages</key>
<integer>1</integer>
</dict>
<dict>
<key>ActiveLayerIndex</key>
<integer>0</integer>
<key>AutoAdjust</key>
<false/>
<key>BackgroundGraphic</key>
<dict>
<key>Bounds</key>
<string>{{0, 0}, {40, 80}}</string>
<key>Class</key>
<string>SolidGraphic</string>
<key>ID</key>
<integer>2</integer>
<key>Style</key>
<dict>
<key>shadow</key>
<dict>
<key>Draws</key>
<string>NO</string>
</dict>
<key>stroke</key>
<dict>
<key>Draws</key>
<string>NO</string>
</dict>
</dict>
</dict>
<key>BaseZoom</key>
<integer>0</integer>
<key>CanvasOrigin</key>
<string>{0, 0}</string>
<key>CanvasSize</key>
<string>{40, 80}</string>
<key>ColumnAlign</key>
<integer>1</integer>
<key>ColumnSpacing</key>
<real>36</real>
<key>DisplayScale</key>
<string>1 pt = 1 px</string>
<key>GraphicsList</key>
<array>
<dict>
<key>AllowConnections</key>
<string>NO</string>
<key>AllowLabelDrop</key>
<false/>
<key>AllowToConnect</key>
<false/>
<key>Class</key>
<string>LineGraphic</string>
<key>ID</key>
<integer>3</integer>
<key>Points</key>
<array>
<string>{30, 10}</string>
<string>{10, 40}</string>
<string>{30, 70}</string>
</array>
<key>Style</key>
<dict>
<key>stroke</key>
<dict>
<key>Color</key>
<dict>
<key>b</key>
<string>0.937305</string>
<key>g</key>
<string>0.937289</string>
<key>r</key>
<string>0.937317</string>
</dict>
<key>HeadArrow</key>
<string>0</string>
<key>Legacy</key>
<true/>
<key>TailArrow</key>
<string>0</string>
<key>Width</key>
<real>4</real>
</dict>
</dict>
</dict>
</array>
<key>GridInfo</key>
<dict>
<key>GridSpacing</key>
<real>10</real>
<key>MajorGridSpacing</key>
<integer>10</integer>
<key>ShowsGrid</key>
<string>YES</string>
<key>SnapsToGrid</key>
<string>YES</string>
</dict>
<key>HPages</key>
<integer>1</integer>
<key>KeepToScale</key>
<false/>
<key>Layers</key>
<array>
<dict>
<key>Lock</key>
<string>NO</string>
<key>Name</key>
<string>Layer 1</string>
<key>Print</key>
<string>YES</string>
<key>View</key>
<string>YES</string>
</dict>
</array>
<key>LayoutInfo</key>
<dict>
<key>Animate</key>
<string>NO</string>
<key>circoMinDist</key>
<real>18</real>
<key>circoSeparation</key>
<real>0.0</real>
<key>layoutEngine</key>
<string>dot</string>
<key>neatoSeparation</key>
<real>0.0</real>
<key>twopiSeparation</key>
<real>0.0</real>
</dict>
<key>Orientation</key>
<integer>2</integer>
<key>PrintOnePage</key>
<false/>
<key>RowAlign</key>
<integer>1</integer>
<key>RowSpacing</key>
<real>36</real>
<key>SheetTitle</key>
<string>disabled</string>
<key>UniqueID</key>
<integer>3</integer>
<key>VPages</key>
<integer>1</integer>
</dict>
</array>
<key>SmartAlignmentGuidesActive</key>
<string>YES</string>
<key>SmartDistanceGuidesActive</key>
<string>YES</string>
<key>UseEntirePage</key>
<false/>
<key>WindowInfo</key>
<dict>
<key>CurrentSheet</key>
<integer>2</integer>
<key>ExpandedCanvases</key>
<array/>
<key>Frame</key>
<string>{{306, -0}, {974, 777}}</string>
<key>ListView</key>
<true/>
<key>OutlineWidth</key>
<integer>142</integer>
<key>RightSidebar</key>
<false/>
<key>ShowRuler</key>
<true/>
<key>Sidebar</key>
<true/>
<key>SidebarWidth</key>
<integer>120</integer>
<key>VisibleRegion</key>
<string>{{-53, -15}, {146.67832705845066, 111.0139900859549}}</string>
<key>Zoom</key>
<real>5.7199997901916504</real>
<key>ZoomValues</key>
<array>
<array>
<string>normal</string>
<real>5.7199997901916504</real>
<real>5.630000114440918</real>
</array>
<array>
<string>hover</string>
<real>5.7199997901916504</real>
<real>1</real>
</array>
<array>
<string>disabled</string>
<real>5.7199997901916504</real>
<real>1</real>
</array>
</array>
</dict>
</dict>
</plist>
Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

@@ -17,11 +17,35 @@ module.exports = class CraftingTableController extends BaseController
options.templateName = 'crafting_table' options.templateName = 'crafting_table'
super options super options
# Event Methods ################################################################################
onNextClicked: ->
@model.step += 1
onPrevClicked: ->
@model.step -= 1
# BaseController Overrides ##################################################################### # BaseController Overrides #####################################################################
onDidRender: -> onDidRender: ->
@gridController = @addChild CraftingGridController, '.view__crafting_grid', model:@model.grid @gridController = @addChild CraftingGridController, '.view__crafting_grid', model:@model.grid
@$nextButton = @$('button[name="next"]') @$next = @$('.next')
@$prevButton = @$('button[name="prev"]') @$prev = @$('.prev')
super super
refresh: ->
@$prev.removeClass 'enabled'
@$next.removeClass 'enabled'
if @model.hasSteps
if @model.hasPrevStep then @$prev.addClass 'enabled'
if @model.hasNextStep then @$next.addClass 'enabled'
super
# Backbone.View Overrides ######################################################################
events:
'click .next': 'onNextClicked'
'click .prev': 'onPrevClicked'
+52 -5
View File
@@ -15,23 +15,70 @@ module.exports = class CraftingTable extends BaseModel
constructor: (attributes={}, options={})-> constructor: (attributes={}, options={})->
if not attributes.plan? then throw new Error "attributes.plan is required" if not attributes.plan? then throw new Error "attributes.plan is required"
attributes.grid ?= new CraftingGrid modPack:attributes.plan.modPack attributes.grid ?= new CraftingGrid modPack:attributes.plan.modPack
attributes.step ?= 0
super attributes, options super attributes, options
@plan.on 'change', => @reset() @plan.on 'change', => @reset()
@_step = 0
@_steps = []
Object.defineProperties this, {
hasNextStep: { get:@hasNextStep }
hasPrevStep: { get:@hasPrevStep }
hasSteps: { get:@hasSteps }
step: { get:@getStep, set:@setStep }
}
# Public Methods ############################################################################### # Public Methods ###############################################################################
reset: -> reset: ->
logger.trace "CraftingTable.reset()" @_compactSteps()
@step = 0 @step = 0
@grid.recipe = @plan.steps[0]
return this
# Property Methods #############################################################################
hasNextStep: ->
return @_step + 1 < @_steps.length
hasPrevStep: ->
return @_step > 0
getStep: ->
return @_step
setStep: (newStep)->
newStep = Math.max 0, Math.min @_steps.length, newStep
@_step = newStep
@grid.recipe = @_steps[@_step]?.recipe
@trigger 'change', this @trigger 'change', this
return this return this
hasSteps: ->
return @_steps.length > 0
# Object Overrides ############################################################################# # Object Overrides #############################################################################
toString: -> toString: ->
return "#{@constructor.name} (#{@cid}) { plan:#{@plan}, step:#{@step} }" return "#{@constructor.name} (#{@cid}) { plan:#{@plan}, step:#{@_step} }"
# Private Methods ##############################################################################
_compactSteps: ->
@_steps = []
currentStep = null
for recipe in @plan.steps
if currentStep?
if currentStep.recipe.name is recipe.name
currentStep.multiplier += 1
else
currentStep = null
if not currentStep
currentStep = multiplier:1, recipe:recipe
@_steps.push currentStep
return @_steps
+1
View File
@@ -27,6 +27,7 @@ module.exports = class Recipe extends BaseModel
getItemSlugAt: (index)-> getItemSlugAt: (index)->
patternDigit = @pattern[index] patternDigit = @pattern[index]
return null unless patternDigit? return null unless patternDigit?
return null unless patternDigit.match /[0-9]/
stack = @input[parseInt(patternDigit)] stack = @input[parseInt(patternDigit)]
return null unless stack? return null unless stack?
+2
View File
@@ -11,4 +11,6 @@
p Crafting Table p Crafting Table
.panel .panel
.prev
table.view__crafting_grid table.view__crafting_grid
.next