Permalink
Browse files

Fix build tool select. Thanks @zirman!

  • Loading branch information...
1 parent 5246638 commit 8ec9ea3a8dee3338bd11e4731e7853b79e7fa6e5 @stephank committed Apr 29, 2012
Showing with 16 additions and 12 deletions.
  1. +16 −12 src/client/renderer/base.coffee
@@ -224,20 +224,24 @@ class BaseRenderer
@currentTool = null
tools = $('<div id="tool-select" />').appendTo(@hud)
for toolType in ['forest', 'road', 'building', 'pillbox', 'mine']
- toolname = "tool-#{toolType}"
- tool = $('<input/>', type: 'radio', name: 'tool', id: toolname).appendTo(tools)
- label = $('<label/>', for: toolname).appendTo(tools)
- label.append $('<span/>', class: "bolo-tool bolo-#{toolname}")
- tool.click (e) =>
- if @currentTool == toolType
- @currentTool = null
- tools.find('input').removeAttr('checked')
- tools.buttonset('refresh')
- else
- @currentTool = toolType
- @world.input.focus()
+ @initHudTool(tools, toolType)
tools.buttonset()
+ # Create a single build tool item.
+ initHudTool: (tools, toolType) ->
+ toolname = "tool-#{toolType}"
+ tool = $('<input/>', type: 'radio', name: 'tool', id: toolname).appendTo(tools)
+ label = $('<label/>', for: toolname).appendTo(tools)
+ label.append $('<span/>', class: "bolo-tool bolo-#{toolname}")
+ tool.click (e) =>
+ if @currentTool == toolType
+ @currentTool = null
+ tools.find('input').removeAttr('checked')
+ tools.buttonset('refresh')
+ else
+ @currentTool = toolType
+ @world.input.focus()
+
# Show WIP notice and Github ribbon. These are really a temporary hacks, so FIXME someday.
initHudNotices: ->
if location.hostname.split('.')[1] == 'github'

0 comments on commit 8ec9ea3

Please sign in to comment.