add state arg to few functions

[?]
Jul 13, 2022, 12:05 AM
P4376EXKQXGN6KUOKIZDSGN65J5C33XVX3RDXHYVOOTG7P2ISZWQC

Dependencies

  • [2] LF7BWEG4 group all editor globals
  • [3] C6QTJYA4 keep online help inside of drawing
  • [4] 4KC7I3E2 make colors easier to edit
  • [5] BERHYBXM fix help for rectangles and squares
  • [6] NUCZBE77 bugfix: alignment of help screen
  • [7] HOSPP2AN crisp font rendering
  • [8] DRFE3B3Z mouse buttons are integers, not strings
  • [9] XRLJDW3W casting about for more helpers to extract..
  • [10] DXT4QTAH a few more integer coordinates
  • [11] NQH7DEEW bugfix: missed rename in one file
  • [12] M6TH7VSZ rip out notion of Line_width
  • [13] 7JH2ZT3F add state arg to Drawing.draw
  • [14] LAW2O3NW extract variable Margin_left
  • [15] BLWAYPKV extract a module
  • [16] GSV7DABC make online help fit within a drawing
  • [17] VHQCNMAR several more modules
  • [18] WTDKUACN rectangle and square shapes
  • [19] 253TWKDA clean up
  • [20] JFFUF5AL override mouse state lookups in tests
  • [21] WPW3AVFS more precise shape selection

Change contents

  • replacement in help.lua at line 1
    [3.6622][3.6623:6673]()
    function draw_help_without_mouse_pressed(drawing)
    [3.6622]
    [3.289]
    function draw_help_without_mouse_pressed(State, drawing)
  • replacement in help.lua at line 4
    [3.6732][2.87052:88146]()
    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
    [3.6732]
    [3.7459]
    love.graphics.print("Things you can do:", State.margin_left+30,y)
    y = y + State.line_height
    love.graphics.print("* Press the mouse button to start drawing a "..current_shape(State), State.margin_left+30,y)
    y = y + State.line_height
    love.graphics.print("* Hover on a point and press 'ctrl+u' to pick it up and start moving it,", State.margin_left+30,y)
    y = y + State.line_height
    love.graphics.print("then press the mouse button to drop it", State.margin_left+30+bullet_indent(),y)
    y = y + State.line_height
    love.graphics.print("* Hover on a point and press 'ctrl+n', type a name, then press 'enter'", State.margin_left+30,y)
    y = y + State.line_height
    love.graphics.print("* Hover on a point or shape and press 'ctrl+d' to delete it", State.margin_left+30,y)
    y = y + State.line_height
    if State.current_drawing_mode ~= 'freehand' then
    love.graphics.print("* Press 'ctrl+p' to switch to drawing freehand strokes", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 20
    [3.7465][2.88147:88340]()
    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
    [3.7465]
    [3.7613]
    if State.current_drawing_mode ~= 'line' then
    love.graphics.print("* Press 'ctrl+l' to switch to drawing lines", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 24
    [3.7619][2.88341:88559]()
    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
    [3.7619]
    [3.7792]
    if State.current_drawing_mode ~= 'manhattan' then
    love.graphics.print("* Press 'ctrl+m' to switch to drawing horizontal/vertical lines", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 28
    [3.7798][2.88560:88762]()
    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
    [3.7798]
    [3.7955]
    if State.current_drawing_mode ~= 'circle' then
    love.graphics.print("* Press 'ctrl+o' to switch to drawing circles/arcs", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 32
    [3.7961][2.88763:88962]()
    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
    [3.7961]
    [3.422]
    if State.current_drawing_mode ~= 'polygon' then
    love.graphics.print("* Press 'ctrl+g' to switch to drawing polygons", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 36
    [3.428][2.88963:89166]()
    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
    [3.428]
    [3.586]
    if State.current_drawing_mode ~= 'rectangle' then
    love.graphics.print("* Press 'ctrl+r' to switch to drawing rectangles", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 40
    [3.592][2.89167:89364]()
    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
    [3.592]
    [3.8115]
    if State.current_drawing_mode ~= 'square' then
    love.graphics.print("* Press 'ctrl+s' to switch to drawing squares", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 44
    [3.8121][2.89365:89653]()
    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
    [3.8121]
    [3.314]
    love.graphics.print("* Press 'ctrl+=' or 'ctrl+-' to zoom in or out, ctrl+0 to reset zoom", State.margin_left+30,y)
    y = y + State.line_height
    love.graphics.print("Press 'esc' now to hide this message", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 49
    [3.349][2.89654:89817]()
    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))
    [3.349]
    [3.8578]
    love.graphics.rectangle('fill', State.margin_left,drawing.y, App.screen.width-State.margin_width, math.max(Drawing.pixels(drawing.h),y-drawing.y))
  • replacement in help.lua at line 52
    [3.8583][3.8583:8630]()
    function draw_help_with_mouse_pressed(drawing)
    [3.8583]
    [3.350]
    function draw_help_with_mouse_pressed(State, drawing)
  • replacement in help.lua at line 55
    [3.8689][2.89818:90611]()
    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
    [3.8689]
    [3.9302]
    love.graphics.print("You're currently drawing a "..current_shape(State, drawing.pending), State.margin_left+30,y)
    y = y + State.line_height
    love.graphics.print('Things you can do now:', State.margin_left+30,y)
    y = y + State.line_height
    if State.current_drawing_mode == 'freehand' then
    love.graphics.print('* Release the mouse button to finish drawing the stroke', State.margin_left+30,y)
    y = y + State.line_height
    elseif State.current_drawing_mode == 'line' or State.current_drawing_mode == 'manhattan' then
    love.graphics.print('* Release the mouse button to finish drawing the line', State.margin_left+30,y)
    y = y + State.line_height
    elseif State.current_drawing_mode == 'circle' then
  • replacement in help.lua at line 67
    [3.9347][2.90612:90871]()
    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)
    [3.9347]
    [3.9561]
    love.graphics.print('* Release the mouse button to finish drawing the circle', State.margin_left+30,y)
    y = y + State.line_height
    love.graphics.print("* Press 'a' to draw just an arc of a circle", State.margin_left+30,y)
  • replacement in help.lua at line 71
    [3.9570][2.90872:90985]()
    love.graphics.print('* Release the mouse button to finish drawing the arc', Editor_state.margin_left+30,y)
    [3.9570]
    [3.9670]
    love.graphics.print('* Release the mouse button to finish drawing the arc', State.margin_left+30,y)
  • replacement in help.lua at line 73
    [3.9678][2.90986:91437]()
    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
    [3.9678]
    [3.62]
    y = y + State.line_height
    elseif State.current_drawing_mode == 'polygon' then
    love.graphics.print('* Release the mouse button to finish drawing the polygon', State.margin_left+30,y)
    y = y + State.line_height
    love.graphics.print("* Press 'p' to add a vertex to the polygon", State.margin_left+30,y)
    y = y + State.line_height
    elseif State.current_drawing_mode == 'rectangle' then
  • replacement in help.lua at line 81
    [3.104][2.91438:91582]()
    love.graphics.print("* Press 'p' to add a vertex to the rectangle", Editor_state.margin_left+30,y)
    y = y + Editor_state.line_height
    [3.104]
    [3.222]
    love.graphics.print("* Press 'p' to add a vertex to the rectangle", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 84
    [3.231][2.91583:91898]()
    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
    [3.231]
    [3.495]
    love.graphics.print('* Release the mouse button to finish drawing the rectangle', State.margin_left+30,y)
    y = y + State.line_height
    love.graphics.print("* Press 'p' to replace the second vertex of the rectangle", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 89
    [3.503][2.91899:91959]()
    elseif Editor_state.current_drawing_mode == 'square' then
    [3.503]
    [3.550]
    elseif State.current_drawing_mode == 'square' then
  • replacement in help.lua at line 91
    [3.592][2.91960:92101]()
    love.graphics.print("* Press 'p' to add a vertex to the square", Editor_state.margin_left+30,y)
    y = y + Editor_state.line_height
    [3.592]
    [3.707]
    love.graphics.print("* Press 'p' to add a vertex to the square", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 94
    [3.716][2.92102:92411]()
    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
    [3.716]
    [3.974]
    love.graphics.print('* Release the mouse button to finish drawing the square', State.margin_left+30,y)
    y = y + State.line_height
    love.graphics.print("* Press 'p' to replace the second vertex of the square", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 100
    [3.9976][2.92412:92798]()
    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
    [3.9976]
    [3.10266]
    love.graphics.print("* Press 'esc' then release the mouse button to cancel the current shape", State.margin_left+30,y)
    y = y + State.line_height
    y = y + State.line_height
    if State.current_drawing_mode ~= 'line' then
    love.graphics.print("* Press 'l' to switch to drawing lines", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 107
    [3.10272][2.92799:93012]()
    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
    [3.10272]
    [3.10440]
    if State.current_drawing_mode ~= 'manhattan' then
    love.graphics.print("* Press 'm' to switch to drawing horizontal/vertical lines", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 111
    [3.10446][2.93013:93210]()
    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
    [3.10446]
    [3.10598]
    if State.current_drawing_mode ~= 'circle' then
    love.graphics.print("* Press 'o' to switch to drawing circles/arcs", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 115
    [3.10604][2.93211:93405]()
    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
    [3.10604]
    [3.745]
    if State.current_drawing_mode ~= 'polygon' then
    love.graphics.print("* Press 'g' to switch to drawing polygons", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 119
    [3.751][2.93406:93604]()
    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
    [3.751]
    [3.904]
    if State.current_drawing_mode ~= 'rectangle' then
    love.graphics.print("* Press 'r' to switch to drawing rectangles", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 123
    [3.910][2.93605:93797]()
    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
    [3.910]
    [3.10753]
    if State.current_drawing_mode ~= 'square' then
    love.graphics.print("* Press 's' to switch to drawing squares", State.margin_left+30,y)
    y = y + State.line_height
  • replacement in help.lua at line 128
    [3.410][2.93798:93961]()
    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))
    [3.410]
    [3.10910]
    love.graphics.rectangle('fill', State.margin_left,drawing.y, App.screen.width-State.margin_width, math.max(Drawing.pixels(drawing.h),y-drawing.y))
  • replacement in help.lua at line 131
    [3.10915][3.10915:10945](),[3.10945][2.93962:94020]()
    function current_shape(shape)
    if Editor_state.current_drawing_mode == 'freehand' then
    [3.10915]
    [3.10990]
    function current_shape(State, shape)
    if State.current_drawing_mode == 'freehand' then
  • replacement in help.lua at line 134
    [3.11019][2.94021:94079]()
    elseif Editor_state.current_drawing_mode == 'line' then
    [3.11019]
    [3.11064]
    elseif State.current_drawing_mode == 'line' then
  • replacement in help.lua at line 136
    [3.11091][2.94080:94143]()
    elseif Editor_state.current_drawing_mode == 'manhattan' then
    [3.11091]
    [3.11141]
    elseif State.current_drawing_mode == 'manhattan' then
  • replacement in help.lua at line 138
    [3.11179][2.94144:94236]()
    elseif Editor_state.current_drawing_mode == 'circle' and shape and shape.start_angle then
    [3.11179]
    [3.11258]
    elseif State.current_drawing_mode == 'circle' and shape and shape.start_angle then
  • replacement in help.lua at line 141
    [3.11282][2.94237:94282]()
    return Editor_state.current_drawing_mode
    [3.11282]
    [3.11314]
    return State.current_drawing_mode
  • replacement in drawing.lua at line 19
    [3.1584][3.663:704](),[3.1643][3.663:704](),[3.663][3.663:704]()
    draw_help_with_mouse_pressed(line)
    [3.1584]
    [3.704]
    draw_help_with_mouse_pressed(State, line)
  • replacement in drawing.lua at line 25
    [3.757][3.757:799]()
    draw_help_without_mouse_pressed(line)
    [3.757]
    [3.799]
    draw_help_without_mouse_pressed(State, line)