about summary refs log tree commit diff stats
path: root/help.lua
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2022-07-12 14:18:50 -0700
committerKartik K. Agaram <vc@akkartik.com>2022-07-12 15:24:56 -0700
commit8bbc1ffe349a78ed2130e24e0356276ddbb22955 (patch)
tree8e3f748433d5147e258fd1008e75cf2c41700e28 /help.lua
parenta5f725ab3b860b22199036f7ab0d0a0193a5a6ac (diff)
downloadlines.love-8bbc1ffe349a78ed2130e24e0356276ddbb22955.tar.gz
group all editor globals
We're still accessing them through a global. But we'll change that next.
Diffstat (limited to 'help.lua')
-rw-r--r--help.lua214
1 files changed, 107 insertions, 107 deletions
diff --git a/help.lua b/help.lua
index 92cdb0a..c65e33d 100644
--- a/help.lua
+++ b/help.lua
@@ -1,144 +1,144 @@
 function draw_help_without_mouse_pressed(drawing)
   App.color(Help_color)
   local y = drawing.y+10
-  love.graphics.print("Things you can do:", Margin_left+30,y)
-  y = y + Line_height
-  love.graphics.print("* Press the mouse button to start drawing a "..current_shape(), Margin_left+30,y)
-  y = y + Line_height
-  love.graphics.print("* Hover on a point and press 'ctrl+u' to pick it up and start moving it,", Margin_left+30,y)
-  y = y + Line_height
-  love.graphics.print("then press the mouse button to drop it", Margin_left+30+bullet_indent(),y)
-  y = y + Line_height
-  love.graphics.print("* Hover on a point and press 'ctrl+n', type a name, then press 'enter'", Margin_left+30,y)
-  y = y + Line_height
-  love.graphics.print("* Hover on a point or shape and press 'ctrl+d' to delete it", Margin_left+30,y)
-  y = y + Line_height
-  if Current_drawing_mode ~= 'freehand' then
-    love.graphics.print("* Press 'ctrl+p' to switch to drawing freehand strokes", Margin_left+30,y)
-    y = y + Line_height
-  end
-  if Current_drawing_mode ~= 'line' then
-    love.graphics.print("* Press 'ctrl+l' to switch to drawing lines", Margin_left+30,y)
-    y = y + Line_height
-  end
-  if Current_drawing_mode ~= 'manhattan' then
-    love.graphics.print("* Press 'ctrl+m' to switch to drawing horizontal/vertical lines", Margin_left+30,y)
-    y = y + Line_height
-  end
-  if Current_drawing_mode ~= 'circle' then
-    love.graphics.print("* Press 'ctrl+o' to switch to drawing circles/arcs", Margin_left+30,y)
-    y = y + Line_height
-  end
-  if Current_drawing_mode ~= 'polygon' then
-    love.graphics.print("* Press 'ctrl+g' to switch to drawing polygons", Margin_left+30,y)
-    y = y + Line_height
-  end
-  if Current_drawing_mode ~= 'rectangle' then
-    love.graphics.print("* Press 'ctrl+r' to switch to drawing rectangles", Margin_left+30,y)
-    y = y + Line_height
-  end
-  if Current_drawing_mode ~= 'square' then
-    love.graphics.print("* Press 'ctrl+s' to switch to drawing squares", Margin_left+30,y)
-    y = y + Line_height
-  end
-  love.graphics.print("* Press 'ctrl+=' or 'ctrl+-' to zoom in or out, ctrl+0 to reset zoom", Margin_left+30,y)
-  y = y + Line_height
-  love.graphics.print("Press 'esc' now to hide this message", Margin_left+30,y)
-  y = y + Line_height
+  love.graphics.print("Things you can do:", Editor_state.margin_left+30,y)
+  y = y + Editor_state.line_height
+  love.graphics.print("* Press the mouse button to start drawing a "..current_shape(), Editor_state.margin_left+30,y)
+  y = y + Editor_state.line_height
+  love.graphics.print("* Hover on a point and press 'ctrl+u' to pick it up and start moving it,", Editor_state.margin_left+30,y)
+  y = y + Editor_state.line_height
+  love.graphics.print("then press the mouse button to drop it", Editor_state.margin_left+30+bullet_indent(),y)
+  y = y + Editor_state.line_height
+  love.graphics.print("* Hover on a point and press 'ctrl+n', type a name, then press 'enter'", Editor_state.margin_left+30,y)
+  y = y + Editor_state.line_height
+  love.graphics.print("* Hover on a point or shape and press 'ctrl+d' to delete it", Editor_state.margin_left+30,y)
+  y = y + Editor_state.line_height
+  if Editor_state.current_drawing_mode ~= 'freehand' then
+    love.graphics.print("* Press 'ctrl+p' to switch to drawing freehand strokes", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
+  end
+  if Editor_state.current_drawing_mode ~= 'line' then
+    love.graphics.print("* Press 'ctrl+l' to switch to drawing lines", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
+  end
+  if Editor_state.current_drawing_mode ~= 'manhattan' then
+    love.graphics.print("* Press 'ctrl+m' to switch to drawing horizontal/vertical lines", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
+  end
+  if Editor_state.current_drawing_mode ~= 'circle' then
+    love.graphics.print("* Press 'ctrl+o' to switch to drawing circles/arcs", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
+  end
+  if Editor_state.current_drawing_mode ~= 'polygon' then
+    love.graphics.print("* Press 'ctrl+g' to switch to drawing polygons", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
+  end
+  if Editor_state.current_drawing_mode ~= 'rectangle' then
+    love.graphics.print("* Press 'ctrl+r' to switch to drawing rectangles", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
+  end
+  if Editor_state.current_drawing_mode ~= 'square' then
+    love.graphics.print("* Press 'ctrl+s' to switch to drawing squares", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
+  end
+  love.graphics.print("* Press 'ctrl+=' or 'ctrl+-' to zoom in or out, ctrl+0 to reset zoom", Editor_state.margin_left+30,y)
+  y = y + Editor_state.line_height
+  love.graphics.print("Press 'esc' now to hide this message", Editor_state.margin_left+30,y)
+  y = y + Editor_state.line_height
   App.color(Help_background_color)
-  love.graphics.rectangle('fill', Margin_left,drawing.y, App.screen.width-Margin_width, math.max(Drawing.pixels(drawing.h),y-drawing.y))
+  love.graphics.rectangle('fill', Editor_state.margin_left,drawing.y, App.screen.width-Editor_state.margin_width, math.max(Drawing.pixels(drawing.h),y-drawing.y))
 end
 
 function draw_help_with_mouse_pressed(drawing)
   App.color(Help_color)
   local y = drawing.y+10
-  love.graphics.print("You're currently drawing a "..current_shape(drawing.pending), Margin_left+30,y)
-  y = y + Line_height
-  love.graphics.print('Things you can do now:', Margin_left+30,y)
-  y = y + Line_height
-  if Current_drawing_mode == 'freehand' then
-    love.graphics.print('* Release the mouse button to finish drawing the stroke', Margin_left+30,y)
-    y = y + Line_height
-  elseif Current_drawing_mode == 'line' or Current_drawing_mode == 'manhattan' then
-    love.graphics.print('* Release the mouse button to finish drawing the line', Margin_left+30,y)
-    y = y + Line_height
-  elseif Current_drawing_mode == 'circle' then
+  love.graphics.print("You're currently drawing a "..current_shape(drawing.pending), Editor_state.margin_left+30,y)
+  y = y + Editor_state.line_height
+  love.graphics.print('Things you can do now:', Editor_state.margin_left+30,y)
+  y = y + Editor_state.line_height
+  if Editor_state.current_drawing_mode == 'freehand' then
+    love.graphics.print('* Release the mouse button to finish drawing the stroke', Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
+  elseif Editor_state.current_drawing_mode == 'line' or Editor_state.current_drawing_mode == 'manhattan' then
+    love.graphics.print('* Release the mouse button to finish drawing the line', Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
+  elseif Editor_state.current_drawing_mode == 'circle' then
     if drawing.pending.mode == 'circle' then
-      love.graphics.print('* Release the mouse button to finish drawing the circle', Margin_left+30,y)
-      y = y + Line_height
-      love.graphics.print("* Press 'a' to draw just an arc of a circle", Margin_left+30,y)
+      love.graphics.print('* Release the mouse button to finish drawing the circle', Editor_state.margin_left+30,y)
+      y = y + Editor_state.line_height
+      love.graphics.print("* Press 'a' to draw just an arc of a circle", Editor_state.margin_left+30,y)
     else
-      love.graphics.print('* Release the mouse button to finish drawing the arc', Margin_left+30,y)
+      love.graphics.print('* Release the mouse button to finish drawing the arc', Editor_state.margin_left+30,y)
     end
-    y = y + Line_height
-  elseif Current_drawing_mode == 'polygon' then
-    love.graphics.print('* Release the mouse button to finish drawing the polygon', Margin_left+30,y)
-    y = y + Line_height
-    love.graphics.print("* Press 'p' to add a vertex to the polygon", Margin_left+30,y)
-    y = y + Line_height
-  elseif Current_drawing_mode == 'rectangle' then
+    y = y + Editor_state.line_height
+  elseif Editor_state.current_drawing_mode == 'polygon' then
+    love.graphics.print('* Release the mouse button to finish drawing the polygon', Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
+    love.graphics.print("* Press 'p' to add a vertex to the polygon", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
+  elseif Editor_state.current_drawing_mode == 'rectangle' then
     if #drawing.pending.vertices < 2 then
-      love.graphics.print("* Press 'p' to add a vertex to the rectangle", Margin_left+30,y)
-      y = y + Line_height
+      love.graphics.print("* Press 'p' to add a vertex to the rectangle", Editor_state.margin_left+30,y)
+      y = y + Editor_state.line_height
     else
-      love.graphics.print('* Release the mouse button to finish drawing the rectangle', Margin_left+30,y)
-      y = y + Line_height
-      love.graphics.print("* Press 'p' to replace the second vertex of the rectangle", Margin_left+30,y)
-      y = y + Line_height
+      love.graphics.print('* Release the mouse button to finish drawing the rectangle', Editor_state.margin_left+30,y)
+      y = y + Editor_state.line_height
+      love.graphics.print("* Press 'p' to replace the second vertex of the rectangle", Editor_state.margin_left+30,y)
+      y = y + Editor_state.line_height
     end
-  elseif Current_drawing_mode == 'square' then
+  elseif Editor_state.current_drawing_mode == 'square' then
     if #drawing.pending.vertices < 2 then
-      love.graphics.print("* Press 'p' to add a vertex to the square", Margin_left+30,y)
-      y = y + Line_height
+      love.graphics.print("* Press 'p' to add a vertex to the square", Editor_state.margin_left+30,y)
+      y = y + Editor_state.line_height
     else
-      love.graphics.print('* Release the mouse button to finish drawing the square', Margin_left+30,y)
-      y = y + Line_height
-      love.graphics.print("* Press 'p' to replace the second vertex of the square", Margin_left+30,y)
-      y = y + Line_height
+      love.graphics.print('* Release the mouse button to finish drawing the square', Editor_state.margin_left+30,y)
+      y = y + Editor_state.line_height
+      love.graphics.print("* Press 'p' to replace the second vertex of the square", Editor_state.margin_left+30,y)
+      y = y + Editor_state.line_height
     end
   end
-  love.graphics.print("* Press 'esc' then release the mouse button to cancel the current shape", Margin_left+30,y)
-  y = y + Line_height
-  y = y + Line_height
-  if Current_drawing_mode ~= 'line' then
-    love.graphics.print("* Press 'l' to switch to drawing lines", Margin_left+30,y)
-    y = y + Line_height
+  love.graphics.print("* Press 'esc' then release the mouse button to cancel the current shape", Editor_state.margin_left+30,y)
+  y = y + Editor_state.line_height
+  y = y + Editor_state.line_height
+  if Editor_state.current_drawing_mode ~= 'line' then
+    love.graphics.print("* Press 'l' to switch to drawing lines", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
   end
-  if Current_drawing_mode ~= 'manhattan' then
-    love.graphics.print("* Press 'm' to switch to drawing horizontal/vertical lines", Margin_left+30,y)
-    y = y + Line_height
+  if Editor_state.current_drawing_mode ~= 'manhattan' then
+    love.graphics.print("* Press 'm' to switch to drawing horizontal/vertical lines", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
   end
-  if Current_drawing_mode ~= 'circle' then
-    love.graphics.print("* Press 'o' to switch to drawing circles/arcs", Margin_left+30,y)
-    y = y + Line_height
+  if Editor_state.current_drawing_mode ~= 'circle' then
+    love.graphics.print("* Press 'o' to switch to drawing circles/arcs", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
   end
-  if Current_drawing_mode ~= 'polygon' then
-    love.graphics.print("* Press 'g' to switch to drawing polygons", Margin_left+30,y)
-    y = y + Line_height
+  if Editor_state.current_drawing_mode ~= 'polygon' then
+    love.graphics.print("* Press 'g' to switch to drawing polygons", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
   end
-  if Current_drawing_mode ~= 'rectangle' then
-    love.graphics.print("* Press 'r' to switch to drawing rectangles", Margin_left+30,y)
-    y = y + Line_height
+  if Editor_state.current_drawing_mode ~= 'rectangle' then
+    love.graphics.print("* Press 'r' to switch to drawing rectangles", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
   end
-  if Current_drawing_mode ~= 'square' then
-    love.graphics.print("* Press 's' to switch to drawing squares", Margin_left+30,y)
-    y = y + Line_height
+  if Editor_state.current_drawing_mode ~= 'square' then
+    love.graphics.print("* Press 's' to switch to drawing squares", Editor_state.margin_left+30,y)
+    y = y + Editor_state.line_height
   end
   App.color(Help_background_color)
-  love.graphics.rectangle('fill', Margin_left,drawing.y, App.screen.width-Margin_width, math.max(Drawing.pixels(drawing.h),y-drawing.y))
+  love.graphics.rectangle('fill', Editor_state.margin_left,drawing.y, App.screen.width-Editor_state.margin_width, math.max(Drawing.pixels(drawing.h),y-drawing.y))
 end
 
 function current_shape(shape)
-  if Current_drawing_mode == 'freehand' then
+  if Editor_state.current_drawing_mode == 'freehand' then
     return 'freehand stroke'
-  elseif Current_drawing_mode == 'line' then
+  elseif Editor_state.current_drawing_mode == 'line' then
     return 'straight line'
-  elseif Current_drawing_mode == 'manhattan' then
+  elseif Editor_state.current_drawing_mode == 'manhattan' then
     return 'horizontal/vertical line'
-  elseif Current_drawing_mode == 'circle' and shape and shape.start_angle then
+  elseif Editor_state.current_drawing_mode == 'circle' and shape and shape.start_angle then
     return 'arc'
   else
-    return Current_drawing_mode
+    return Editor_state.current_drawing_mode
   end
 end