help.lua 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. function draw_help_without_mouse_pressed(State, drawing_index)
  2. local drawing = State.lines[drawing_index]
  3. local line_cache = State.line_cache[drawing_index]
  4. App.color(Help_color)
  5. local y = line_cache.starty+10
  6. love.graphics.print("Things you can do:", State.left+30,y)
  7. y = y + State.line_height
  8. love.graphics.print("* Press the mouse button to start drawing a "..current_shape(State), State.left+30,y)
  9. y = y + State.line_height
  10. love.graphics.print("* Hover on a point and press 'ctrl+u' to pick it up and start moving it,", State.left+30,y)
  11. y = y + State.line_height
  12. love.graphics.print("then press the mouse button to drop it", State.left+30+State.font:getWidth('* '),y)
  13. y = y + State.line_height
  14. love.graphics.print("* Hover on a point and press 'ctrl+n', type a name, then press 'enter'", State.left+30,y)
  15. y = y + State.line_height
  16. love.graphics.print("* Hover on a point or shape and press 'ctrl+d' to delete it", State.left+30,y)
  17. y = y + State.line_height
  18. if State.current_drawing_mode ~= 'freehand' then
  19. love.graphics.print("* Press 'ctrl+p' to switch to drawing freehand strokes", State.left+30,y)
  20. y = y + State.line_height
  21. end
  22. if State.current_drawing_mode ~= 'line' then
  23. love.graphics.print("* Press 'ctrl+l' to switch to drawing lines", State.left+30,y)
  24. y = y + State.line_height
  25. end
  26. if State.current_drawing_mode ~= 'manhattan' then
  27. love.graphics.print("* Press 'ctrl+m' to switch to drawing horizontal/vertical lines", State.left+30,y)
  28. y = y + State.line_height
  29. end
  30. if State.current_drawing_mode ~= 'circle' then
  31. love.graphics.print("* Press 'ctrl+o' to switch to drawing circles/arcs", State.left+30,y)
  32. y = y + State.line_height
  33. end
  34. if State.current_drawing_mode ~= 'polygon' then
  35. love.graphics.print("* Press 'ctrl+g' to switch to drawing polygons", State.left+30,y)
  36. y = y + State.line_height
  37. end
  38. if State.current_drawing_mode ~= 'rectangle' then
  39. love.graphics.print("* Press 'ctrl+r' to switch to drawing rectangles", State.left+30,y)
  40. y = y + State.line_height
  41. end
  42. if State.current_drawing_mode ~= 'square' then
  43. love.graphics.print("* Press 'ctrl+s' to switch to drawing squares", State.left+30,y)
  44. y = y + State.line_height
  45. end
  46. love.graphics.print("* Press 'ctrl+=' or 'ctrl+-' to zoom in or out, ctrl+0 to reset zoom", State.left+30,y)
  47. y = y + State.line_height
  48. love.graphics.print("Press 'esc' now to hide this message", State.left+30,y)
  49. y = y + State.line_height
  50. App.color(Help_background_color)
  51. love.graphics.rectangle('fill', State.left,line_cache.starty, State.width, math.max(Drawing.pixels(drawing.h, State.width),y-line_cache.starty))
  52. end
  53. function draw_help_with_mouse_pressed(State, drawing_index)
  54. local drawing = State.lines[drawing_index]
  55. local line_cache = State.line_cache[drawing_index]
  56. App.color(Help_color)
  57. local y = line_cache.starty+10
  58. love.graphics.print("You're currently drawing a "..current_shape(State, drawing.pending), State.left+30,y)
  59. y = y + State.line_height
  60. love.graphics.print('Things you can do now:', State.left+30,y)
  61. y = y + State.line_height
  62. if State.current_drawing_mode == 'freehand' then
  63. love.graphics.print('* Release the mouse button to finish drawing the stroke', State.left+30,y)
  64. y = y + State.line_height
  65. elseif State.current_drawing_mode == 'line' or State.current_drawing_mode == 'manhattan' then
  66. love.graphics.print('* Release the mouse button to finish drawing the line', State.left+30,y)
  67. y = y + State.line_height
  68. elseif State.current_drawing_mode == 'circle' then
  69. if drawing.pending.mode == 'circle' then
  70. love.graphics.print('* Release the mouse button to finish drawing the circle', State.left+30,y)
  71. y = y + State.line_height
  72. love.graphics.print("* Press 'a' to draw just an arc of a circle", State.left+30,y)
  73. else
  74. love.graphics.print('* Release the mouse button to finish drawing the arc', State.left+30,y)
  75. end
  76. y = y + State.line_height
  77. elseif State.current_drawing_mode == 'polygon' then
  78. love.graphics.print('* Release the mouse button to finish drawing the polygon', State.left+30,y)
  79. y = y + State.line_height
  80. love.graphics.print("* Press 'p' to add a vertex to the polygon", State.left+30,y)
  81. y = y + State.line_height
  82. elseif State.current_drawing_mode == 'rectangle' then
  83. if #drawing.pending.vertices < 2 then
  84. love.graphics.print("* Press 'p' to add a vertex to the rectangle", State.left+30,y)
  85. y = y + State.line_height
  86. else
  87. love.graphics.print('* Release the mouse button to finish drawing the rectangle', State.left+30,y)
  88. y = y + State.line_height
  89. love.graphics.print("* Press 'p' to replace the second vertex of the rectangle", State.left+30,y)
  90. y = y + State.line_height
  91. end
  92. elseif State.current_drawing_mode == 'square' then
  93. if #drawing.pending.vertices < 2 then
  94. love.graphics.print("* Press 'p' to add a vertex to the square", State.left+30,y)
  95. y = y + State.line_height
  96. else
  97. love.graphics.print('* Release the mouse button to finish drawing the square', State.left+30,y)
  98. y = y + State.line_height
  99. love.graphics.print("* Press 'p' to replace the second vertex of the square", State.left+30,y)
  100. y = y + State.line_height
  101. end
  102. end
  103. love.graphics.print("* Press 'esc' then release the mouse button to cancel the current shape", State.left+30,y)
  104. y = y + State.line_height
  105. y = y + State.line_height
  106. if State.current_drawing_mode ~= 'line' then
  107. love.graphics.print("* Press 'l' to switch to drawing lines", State.left+30,y)
  108. y = y + State.line_height
  109. end
  110. if State.current_drawing_mode ~= 'manhattan' then
  111. love.graphics.print("* Press 'm' to switch to drawing horizontal/vertical lines", State.left+30,y)
  112. y = y + State.line_height
  113. end
  114. if State.current_drawing_mode ~= 'circle' then
  115. love.graphics.print("* Press 'o' to switch to drawing circles/arcs", State.left+30,y)
  116. y = y + State.line_height
  117. end
  118. if State.current_drawing_mode ~= 'polygon' then
  119. love.graphics.print("* Press 'g' to switch to drawing polygons", State.left+30,y)
  120. y = y + State.line_height
  121. end
  122. if State.current_drawing_mode ~= 'rectangle' then
  123. love.graphics.print("* Press 'r' to switch to drawing rectangles", State.left+30,y)
  124. y = y + State.line_height
  125. end
  126. if State.current_drawing_mode ~= 'square' then
  127. love.graphics.print("* Press 's' to switch to drawing squares", State.left+30,y)
  128. y = y + State.line_height
  129. end
  130. App.color(Help_background_color)
  131. love.graphics.rectangle('fill', State.left,line_cache.starty, State.width, math.max(Drawing.pixels(drawing.h, State.width),y-line_cache.starty))
  132. end
  133. function current_shape(State, shape)
  134. if State.current_drawing_mode == 'freehand' then
  135. return 'freehand stroke'
  136. elseif State.current_drawing_mode == 'line' then
  137. return 'straight line'
  138. elseif State.current_drawing_mode == 'manhattan' then
  139. return 'horizontal/vertical line'
  140. elseif State.current_drawing_mode == 'circle' and shape and shape.start_angle then
  141. return 'arc'
  142. else
  143. return State.current_drawing_mode
  144. end
  145. end