Skip to content
This repository
Browse code

Fix build tool select. Thanks @zirman!

  • Loading branch information...
commit 8ec9ea3a8dee3338bd11e4731e7853b79e7fa6e5 1 parent 5246638
Stéphan Kochen authored April 29, 2012

Showing 1 changed file with 16 additions and 12 deletions. Show diff stats Hide diff stats

  1. 28  src/client/renderer/base.coffee
28  src/client/renderer/base.coffee
@@ -224,20 +224,24 @@ class BaseRenderer
224 224
     @currentTool = null
225 225
     tools = $('<div id="tool-select" />').appendTo(@hud)
226 226
     for toolType in ['forest', 'road', 'building', 'pillbox', 'mine']
227  
-      toolname = "tool-#{toolType}"
228  
-      tool = $('<input/>', type: 'radio', name: 'tool', id: toolname).appendTo(tools)
229  
-      label = $('<label/>', for: toolname).appendTo(tools)
230  
-      label.append $('<span/>', class: "bolo-tool bolo-#{toolname}")
231  
-      tool.click (e) =>
232  
-        if @currentTool == toolType
233  
-          @currentTool = null
234  
-          tools.find('input').removeAttr('checked')
235  
-          tools.buttonset('refresh')
236  
-        else
237  
-          @currentTool = toolType
238  
-        @world.input.focus()
  227
+      @initHudTool(tools, toolType)
239 228
     tools.buttonset()
240 229
 
  230
+  # Create a single build tool item.
  231
+  initHudTool: (tools, toolType) ->
  232
+    toolname = "tool-#{toolType}"
  233
+    tool = $('<input/>', type: 'radio', name: 'tool', id: toolname).appendTo(tools)
  234
+    label = $('<label/>', for: toolname).appendTo(tools)
  235
+    label.append $('<span/>', class: "bolo-tool bolo-#{toolname}")
  236
+    tool.click (e) =>
  237
+      if @currentTool == toolType
  238
+        @currentTool = null
  239
+        tools.find('input').removeAttr('checked')
  240
+        tools.buttonset('refresh')
  241
+      else
  242
+        @currentTool = toolType
  243
+      @world.input.focus()
  244
+
241 245
   # Show WIP notice and Github ribbon. These are really a temporary hacks, so FIXME someday.
242 246
   initHudNotices: ->
243 247
     if location.hostname.split('.')[1] == 'github'

0 notes on commit 8ec9ea3

Please sign in to comment.
Something went wrong with that request. Please try again.